Added Stats inside ConstructionConsent
This commit is contained in:
@@ -531,6 +531,42 @@ class ConstructionConsent extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("inspection_planner", $filter)) {
|
||||
$inspection_planner = $filter["inspection_planner"];
|
||||
if($inspection_planner == "!NULL") {
|
||||
$where .= " AND inspection_planner IS NOT NULL";
|
||||
} elseif($inspection_planner == "NULL") {
|
||||
$where .= " AND inspection_planner IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("conduit_installed_building", $filter)) {
|
||||
$conduit_installed_building = $filter["conduit_installed_building"];
|
||||
if($conduit_installed_building == "!NULL") {
|
||||
$where .= " AND conduit_installed_building IS NOT NULL";
|
||||
} elseif($conduit_installed_building == "NULL") {
|
||||
$where .= " AND conduit_installed_building IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("conduit_installed_ftu", $filter)) {
|
||||
$conduit_installed_ftu = $filter["conduit_installed_ftu"];
|
||||
if($conduit_installed_ftu == "!NULL") {
|
||||
$where .= " AND conduit_installed_ftu IS NOT NULL";
|
||||
} elseif($conduit_installed_ftu == "NULL") {
|
||||
$where .= " AND conduit_installed_ftu IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("inhouse_cabling", $filter)) {
|
||||
$inhouse_cabling = $filter["inhouse_cabling"];
|
||||
if($inhouse_cabling == "!NULL") {
|
||||
$where .= " AND inhouse_cabling IS NOT NULL";
|
||||
} elseif($inhouse_cabling == "NULL") {
|
||||
$where .= " AND inhouse_cabling IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
|
||||
@@ -72,6 +72,7 @@ class ConstructionConsentController extends mfBaseController {
|
||||
|
||||
$items = ConstructionConsent::search($filter, $pagination);
|
||||
$this->layout->set("items", $items);
|
||||
$this->layout()->set("stats", $this->generateStats($filter));
|
||||
|
||||
if(array_key_exists("project_id", $filter) && $filter["project_id"]) {
|
||||
$project = new ConstructionConsentProject($filter["project_id"]);
|
||||
@@ -936,4 +937,24 @@ class ConstructionConsentController extends mfBaseController {
|
||||
|
||||
return ["message" => "ConstructionConsent saved successfully"];
|
||||
}
|
||||
|
||||
private function generateStats($baseFilter = []): array {
|
||||
$allCount = ConstructionConsent::count([...$baseFilter]);
|
||||
$streetCount = ConstructionConsent::count(["object_type" => "street", ...$baseFilter]);
|
||||
$buildingCount = ConstructionConsent::count(["object_type" => "building", ...$baseFilter]);
|
||||
$inspection_planner = ConstructionConsent::count(["inspection_planner" => "!NULL", ...$baseFilter]);
|
||||
$conduit_installed_building = ConstructionConsent::count(["conduit_installed_building" => "!NULL", ...$baseFilter]);
|
||||
$conduit_installed_ftu = ConstructionConsent::count(["conduit_installed_ftu" => "!NULL", ...$baseFilter]);
|
||||
$inhouse_cabling = ConstructionConsent::count(["inhouse_cabling" => "!NULL", ...$baseFilter]);
|
||||
|
||||
return [
|
||||
"all" => $allCount,
|
||||
"street" => $streetCount,
|
||||
"building" => $buildingCount,
|
||||
"inspection_planner" => $inspection_planner,
|
||||
"conduit_installed_building" => $conduit_installed_building,
|
||||
"conduit_installed_ftu" => $conduit_installed_ftu,
|
||||
"inhouse_cabling" => $inhouse_cabling
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user