public function get_customers(array $groups = null)
{
$p = $this->kga['server_prefix'];
if (empty($groups)) {
$query = "SELECT customerID, name, contact, visible\n FROM {$p}customers\n WHERE trash=0\n ORDER BY visible DESC, name;";
} else {
$query = "SELECT DISTINCT customerID, name, contact, visible\n FROM {$p}customers\n JOIN {$p}groups_customers AS g_c USING (customerID)\n WHERE g_c.groupID IN (" . implode($groups, ',') . ")\n AND trash=0\n ORDER BY visible DESC, name;";
}
$result = $this->conn->Query($query);
if ($result == false) {
$this->logLastError('get_customers');
return false;
}
$i = 0;
if ($this->conn->RowCount()) {
$arr = array();
$this->conn->MoveFirst();
while (!$this->conn->EndOfSeek()) {
$row = $this->conn->Row();
$arr[$i]['customerID'] = $row->customerID;
$arr[$i]['name'] = $row->name;
$arr[$i]['contact'] = $row->contact;
$arr[$i]['visible'] = $row->visible;
$i++;
}
return $arr;
}
return array();
}