1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| function getCustomersOnCriteria($subscriberId, $countryCol, $where, $order) {
$db = dbConnect();
$dbc= dbConnectCommon();
$where = (empty($where)) ? '': " AND $where";
$sql = <<<SQL
SELECT d.id, d.company_name, d.country AS country_code ,c.$countryCol AS country, d.locality, d.phone, d.fax, d.mail
,e.directcall, e.firstname, e.familyname, e.freerole
,t.is_customer, is_to_see, t.actionlevel, t.actionlevel2, t.date_next_call, DATE_FORMAT(t.date_next_call,'%d/%m/%Y') AS eur_date_call
FROM sirep.dat_customers d
INNER JOIN common.countries c
ON d.country=c.id
LEFT JOIN sirep.dat_employees e
ON e.id_customer=d.id
LEFT JOIN sirep.dat_trading t
ON d.id=t.id
WHERE id_subscriber=:id_subscriber$where
ORDER BY $order
SQL;
$stmt = $db->prepare($sql);
$stmt->execute([':id_subscriber'=>$subscriberId]);
return $stmt->fetchAll();
} |
Partager