Added percentage of preorders to total homes
This commit is contained in:
@@ -98,7 +98,15 @@
|
||||
<td><?=$camp->network->name?></td>
|
||||
<td><?=$camp->name?></td>
|
||||
<td><?=$camp->area?></td>
|
||||
<td><a href="<?=self::getUrl("Preorder", "Index", ["filter" => ["preordercampaign_id" => $camp->id]])?>"><?=count($camp->active_preorders)?></a></td>
|
||||
<td>
|
||||
<a class="btn btn-sm btn-outline-primary mr-2" href="<?=self::getUrl("Preorder", "add", ["preordercampaign_id" => $camp->id])?>"><i class="fas fa-plus" title="Vorbestellung hinzufügen"></i></a>
|
||||
<a href="<?=self::getUrl("Preorder", "Index", ["filter" => ["preordercampaign_id" => $camp->id]])?>">
|
||||
<?=count($camp->active_preorders)?>
|
||||
<?php if($camp->total_homes): ?>
|
||||
/ <?=$camp->total_homes?> (<?=(round((count($camp->active_preorders) / $camp->total_homes) * 100, 2))?> %)
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</td>
|
||||
<td><?=date('d.m.Y',$camp->from)?></td>
|
||||
<td><?=date('d.m.Y',$camp->to)?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
|
||||
@@ -129,6 +129,15 @@ class ADBHausnummerModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("netzgebiet_id", $filter)) {
|
||||
$netzgebiet_id = $filter['netzgebiet_id'];
|
||||
if(is_numeric($netzgebiet_id)) {
|
||||
$where .= " AND Hausnummer.netzgebiet_id=$netzgebiet_id";
|
||||
} elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) {
|
||||
$where .= " AND Hausnummer.netzgebiet_id IN (". implode(",", $netzgebiet_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("plz_id", $filter)) {
|
||||
$plz_id = $filter['plz_id'];
|
||||
if(is_numeric($plz_id)) {
|
||||
@@ -147,8 +156,6 @@ class ADBHausnummerModel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("hausnummer", $filter)) {
|
||||
$hausnummer = FronkDB::singleton()->escape($filter['hausnummer']);
|
||||
if($hausnummer) {
|
||||
|
||||
@@ -79,10 +79,15 @@ class ADBWohneinheitModel {
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM Wohneinheit
|
||||
WHERE $where
|
||||
$sql = "SELECT COUNT(*) as cnt FROM
|
||||
(SELECT Wohneinheit.* FROM Wohneinheit
|
||||
LEFT JOIN Hausnummer ON (Hausnummer.id = Wohneinheit.hausnummer_id)
|
||||
WHERE $where
|
||||
GROUP BY Wohneinheit.id
|
||||
) as tbl
|
||||
";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
@@ -97,7 +102,9 @@ class ADBWohneinheitModel {
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT Wohneinheit.* FROM Wohneinheit
|
||||
LEFT JOIN Hausnummer ON (Hausnummer.id = Wohneinheit.hausnummer_id)
|
||||
WHERE $where
|
||||
GROUP BY Wohneinheit.id
|
||||
ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
@@ -128,6 +135,15 @@ class ADBWohneinheitModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("netzgebiet_id", $filter)) {
|
||||
$netzgebiet_id = $filter['netzgebiet_id'];
|
||||
if(is_numeric($netzgebiet_id)) {
|
||||
$where .= " AND Hausnummer.netzgebiet_id=$netzgebiet_id";
|
||||
} elseif(is_array($netzgebiet_id) && count($netzgebiet_id)) {
|
||||
$where .= " AND Hausnummer.netzgebiet_id IN (". implode(",", $netzgebiet_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("hausnummer_id", $filter)) {
|
||||
$hausnummer_id = $filter['hausnummer_id'];
|
||||
if(is_numeric($hausnummer_id)) {
|
||||
|
||||
@@ -131,9 +131,9 @@ class PreorderModel {
|
||||
if(is_numeric($deleted)) {
|
||||
$where .= " AND deleted=$deleted";
|
||||
}
|
||||
if($deleted === null) {
|
||||
/*if($deleted === null) {
|
||||
$where .= " AND deleted IS NULL";
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if(array_key_exists("preordercampaign_id", $filter)) {
|
||||
|
||||
@@ -9,6 +9,7 @@ class Preordercampaign extends mfBaseModel {
|
||||
private $salesclusters;
|
||||
private $apiusers;
|
||||
private $corsorigins;
|
||||
private $total_homes;
|
||||
|
||||
|
||||
public function addTypes(Array $types) {
|
||||
@@ -70,6 +71,17 @@ class Preordercampaign extends mfBaseModel {
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "total_homes") {
|
||||
$total = 0;
|
||||
foreach($this->getProperty("salesclusters") as $scluster) {
|
||||
$netzgebiet_id = $scluster->salescluster_id;
|
||||
$total += ADBWohneinheitModel::count(['netzgebiet_id' => $netzgebiet_id]);
|
||||
}
|
||||
$this->total_homes = $total;
|
||||
return $total;
|
||||
}
|
||||
|
||||
|
||||
if($name == "preorders") {
|
||||
$this->preorders = PreorderModel::search(['preordercampaign_id' => $this->id]);
|
||||
return $this->preorders;
|
||||
|
||||
Reference in New Issue
Block a user