public function get_projects(array $groups = null)
{
$p = $this->kga['server_prefix'];
if (empty($groups)) {
$query = "SELECT project.*, customer.name AS customerName, customer.visible as customerVisible\n FROM {$p}projects AS project\n JOIN {$p}customers AS customer USING(customerID)\n WHERE project.trash=0";
} else {
$query = "SELECT DISTINCT project.*, customer.name AS customerName, customer.visible as customerVisible\n FROM {$p}projects AS project\n JOIN {$p}customers AS customer USING(customerID)\n JOIN {$p}groups_projects USING(projectID)\n WHERE {$p}groups_projects.groupID IN (" . implode($groups, ',') . ")\n AND project.trash=0";
}
if ($this->kga->getSettings()->isFlipProjectDisplay()) {
$query .= " ORDER BY project.visible DESC, customer.visible DESC, customerName, name;";
} else {
$query .= " ORDER BY project.visible DESC, customer.visible DESC, name, customerName;";
}
$result = $this->conn->Query($query);
if ($result == false) {
$this->logLastError('get_projects');
return false;
}
$rows = $this->conn->RecordsArray(MYSQLI_ASSOC);
if ($rows) {
$arr = array();
$i = 0;
foreach ($rows as $row) {
$arr[$i]['projectID'] = $row['projectID'];
$arr[$i]['customerID'] = $row['customerID'];
$arr[$i]['name'] = $row['name'];
$arr[$i]['comment'] = $row['comment'];
$arr[$i]['visible'] = $row['visible'];
$arr[$i]['filter'] = $row['filter'];
$arr[$i]['trash'] = $row['trash'];
$arr[$i]['budget'] = $row['budget'];
$arr[$i]['effort'] = $row['effort'];
$arr[$i]['approved'] = $row['approved'];
$arr[$i]['internal'] = $row['internal'];
$arr[$i]['customerName'] = $row['customerName'];
$arr[$i]['customerVisible'] = $row['customerVisible'];
$i++;
}
return $arr;
}
return array();
}