Kimai_Database_Mysql::get_activities_by_customer PHP Method

get_activities_by_customer() public method

returns list of activities used with specified customer
Author: sl
public get_activities_by_customer ( integer $customer_ID ) : array
$customer_ID integer filter for only this ID of a customer
return array
    public function get_activities_by_customer($customer_ID)
    {
        $p = $this->kga['server_prefix'];
        $customer_ID = MySQL::SQLValue($customer_ID, MySQL::SQLVALUE_NUMBER);
        $query = "SELECT DISTINCT activityID, name, visible\n          FROM {$p}activities\n          WHERE activityID IN\n              (SELECT activityID FROM {$p}timeSheet\n                WHERE projectID IN (SELECT projectID FROM {$p}projects WHERE customerID = {$customer_ID}))\n            AND trash=0";
        $result = $this->conn->Query($query);
        if ($result == false) {
            $this->logLastError('get_activities_by_customer');
            return false;
        }
        $arr = array();
        $i = 0;
        if ($this->conn->RowCount()) {
            $this->conn->MoveFirst();
            while (!$this->conn->EndOfSeek()) {
                $row = $this->conn->Row();
                $arr[$i]['activityID'] = $row->activityID;
                $arr[$i]['name'] = $row->name;
                $arr[$i]['visible'] = $row->visible;
                $i++;
            }
            return $arr;
        } else {
            return array();
        }
    }
Kimai_Database_Mysql