feat: FCP filter counts now respect all active search filters
This commit is contained in:
@@ -482,6 +482,40 @@ class PreorderModel
|
||||
return self::count($filter);
|
||||
}
|
||||
|
||||
public static function countActiveGroupedByFcp($filter = [])
|
||||
{
|
||||
if (!is_array($filter)) return false;
|
||||
|
||||
if (!array_key_exists("deleted", $filter)) {
|
||||
$filter["deleted"] = null;
|
||||
}
|
||||
|
||||
if (!array_key_exists("<status_code", $filter) && !array_key_exists(">status_code", $filter) && !array_key_exists("status_code", $filter)
|
||||
&& !array_key_exists("<status_id", $filter) && !array_key_exists(">status_id", $filter) && !array_key_exists("status_id", $filter)) {
|
||||
$filter["<status_code"] = 899;
|
||||
$filter["!status_code"] = 20;
|
||||
}
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT adb_hausnummer.fcp_id, COUNT(*) as cnt FROM `" . FRONKDB_DBNAME . "`.Preorder tt_preorder
|
||||
LEFT JOIN `" . FRONKDB_DBNAME . "`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
WHERE $where AND adb_hausnummer.fcp_id IS NOT NULL
|
||||
GROUP BY adb_hausnummer.fcp_id
|
||||
";
|
||||
|
||||
$res = $db->query($sql);
|
||||
$counts = [];
|
||||
if ($db->num_rows($res)) {
|
||||
while ($row = $db->fetch_object($res)) {
|
||||
$counts[$row->fcp_id] = (int)$row->cnt;
|
||||
}
|
||||
}
|
||||
return $counts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filter
|
||||
* @param $limit
|
||||
|
||||
Reference in New Issue
Block a user