diff --git a/Layout/default/Preordercampaign/Index.php b/Layout/default/Preordercampaign/Index.php index b6476d4c2..2c19ee0ca 100644 --- a/Layout/default/Preordercampaign/Index.php +++ b/Layout/default/Preordercampaign/Index.php @@ -113,8 +113,10 @@ ["preordercampaign_id" => $camp->id]])?>"> active_preorder_count?> - homes_total): ?> + homes_total): // manual value ?> / homes_total?> (active_preorder_count / $camp->homes_total) * 100, 2))?> %) + total_homes): // automatic value from AdressDB ?> + / total_homes?> (active_preorder_count / $camp->total_homes) * 100, 2))?> %) diff --git a/application/ADBWohneinheit/ADBWohneinheitModel.php b/application/ADBWohneinheit/ADBWohneinheitModel.php index 612b251ea..8353801a5 100644 --- a/application/ADBWohneinheit/ADBWohneinheitModel.php +++ b/application/ADBWohneinheit/ADBWohneinheitModel.php @@ -95,7 +95,7 @@ class ADBWohneinheitModel { ) as tbl "; - //mfLoghandler::singleton()->debug($sql); + mfLoghandler::singleton()->debug($sql); $res = $db->query($sql); if($db->num_rows($res)) { $data = $db->fetch_object($res); diff --git a/application/Preordercampaign/Preordercampaign.php b/application/Preordercampaign/Preordercampaign.php index a58223dff..603995c18 100644 --- a/application/Preordercampaign/Preordercampaign.php +++ b/application/Preordercampaign/Preordercampaign.php @@ -82,10 +82,15 @@ class Preordercampaign extends mfBaseModel { if($name == "total_homes") { $total = 0; + + $netzgebiet_ids = null; foreach($this->getProperty("salesclusters") as $scluster) { - $netzgebiet_id = $scluster->salescluster_id; - $total += ADBWohneinheitModel::count(['netzgebiet_id' => $netzgebiet_id]); + $netzgebiet_ids[] = $scluster->id; } + if(count($netzgebiet_ids)) { + $total = ADBWohneinheitModel::count(['netzgebiet_id' => $netzgebiet_ids]); + } + $this->total_homes = $total; return $total; }