updated dashboard to use preordermodel calculation
This commit is contained in:
@@ -196,7 +196,7 @@ class DashboardNewController extends mfBaseController {
|
||||
$campaign_ids = array_map(fn($campaign) => $campaign->id, $owner_campaigns);
|
||||
}
|
||||
|
||||
$order_max_homes = $this->getTotalHomes($campaign_ids, $gemeinde_ids);
|
||||
$order_max_homes = PreorderModel::countTotalUnits($campaign_ids, $gemeinde_ids)['total_unit_count'];
|
||||
|
||||
$efh_connection_types = ["single-dwelling", "business"];
|
||||
$mph_connection_types = ["apartment-building", "apartment", "multi-dwelling"];
|
||||
@@ -370,7 +370,7 @@ class DashboardNewController extends mfBaseController {
|
||||
$campaign_ids = [$campaign->id];
|
||||
$gemeinde_ids = []; // Empty array as in original
|
||||
|
||||
$order_max_homes = $this->getTotalHomes($campaign_ids, $gemeinde_ids);
|
||||
$order_max_homes = PreorderModel::countTotalUnits($campaign_ids, $gemeinde_ids)['total_unit_count'];
|
||||
|
||||
$efh_connection_types = [0, 1]; // Single-dwelling and business
|
||||
$mph_connection_types = [2]; // Apartment-building, apartment, multi-dwelling
|
||||
@@ -568,43 +568,6 @@ class DashboardNewController extends mfBaseController {
|
||||
return $timeline;
|
||||
}
|
||||
|
||||
private function getTotalHomes(array $preordercampaign_id = [], array $gemeinde_id = []) {
|
||||
$baseSQL = "SELECT COUNT(adb_wohneinheit.id) as cnt FROM `" . ADDRESSDB_DBNAME . "`.Wohneinheit adb_wohneinheit
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Hausnummer adb_hausnummer ON (adb_wohneinheit.hausnummer_id = adb_hausnummer.id)
|
||||
LEFT JOIN `" . ADDRESSDB_DBNAME . "`.Strasse adb_strasse ON (adb_hausnummer.strasse_id = adb_strasse.id)
|
||||
WHERE 1=1";
|
||||
|
||||
$where = "";
|
||||
|
||||
if (!empty($preordercampaign_id)) {
|
||||
$netzgebiet_ids = [];
|
||||
foreach ($preordercampaign_id as $campaign_id) {
|
||||
$campaign = new Preordercampaign($campaign_id);
|
||||
if ($campaign->network_id) {
|
||||
$network = new Network($campaign->network_id);
|
||||
$netzgebiet_ids[] = $network->adb_netzgebiet_id;
|
||||
}
|
||||
}
|
||||
|
||||
$where .= " AND adb_hausnummer.netzgebiet_id IN (" . implode(',', array_map('intval', $netzgebiet_ids)) . ")";
|
||||
}
|
||||
|
||||
if (!empty($gemeinde_id)) {
|
||||
$where .= " AND adb_strasse.gemeinde_id IN (" . implode(',', array_map('intval', $gemeinde_id)) . ")";
|
||||
}
|
||||
|
||||
$sql = $baseSQL . $where;
|
||||
|
||||
$res = $this->db()->query($sql);
|
||||
if ($this->db()->num_rows($res)) {
|
||||
$data = $this->db()->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function getDashboardAddressDBDataAction() {
|
||||
if (!$this->me->is("Admin")) self::sendError("Keine Berechtigung");
|
||||
$baseFilter = [];
|
||||
|
||||
Reference in New Issue
Block a user