changed logic of unit count calculation based on internal tool type

This commit is contained in:
Luca Haid
2025-06-10 09:45:57 +02:00
parent 327d6686fb
commit 28546cf4d0
8 changed files with 135 additions and 678 deletions
+22 -21
View File
@@ -148,28 +148,29 @@ class DashboardController extends mfBaseController {
}
private function getTotalHomes($preordercampaign_id = [], $gemeinde_id = false) {
$total_homes = 0;
return 0;
// $i_total_calculated_homes = 0;
if($gemeinde_id) {
$sql = "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 adb_strasse.gemeinde_id = $gemeinde_id
";
$res = $this->db()->query($sql);
if($this->db()->num_rows($res)) {
$data = $this->db()->fetch_object($res);
return $data->cnt;
}
} else {
foreach($preordercampaign_id as $campaign_id) {
$campaign = new Preordercampaign($campaign_id);
if($campaign->id) {
$total_homes += ($campaign->homes_total) ? $campaign->homes_total : $campaign->total_homes;
}
}
}
return $total_homes;
// if($gemeinde_id) {
// $sql = "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 adb_strasse.gemeinde_id = $gemeinde_id
// ";
// $res = $this->db()->query($sql);
// if($this->db()->num_rows($res)) {
// $data = $this->db()->fetch_object($res);
// return $data->cnt;
// }
// } else {
// foreach($preordercampaign_id as $campaign_id) {
// $campaign = new Preordercampaign($campaign_id);
// if($campaign->id) {
// $i_total_calculated_homes += ($campaign->homes_DEPRECATED_total) ? $campaign->homes_DEPRECATED_total : $campaign->homes_DEPRECATED_total;
// }
// }
// }
// return $i_total_calculated_homes;
}
private function getPartnerOrderCount($preordercampaign_id = [], $gemeinde_id = false) {