calculating preoder count with connection_count

This commit is contained in:
Frank Schubert
2022-10-21 11:36:28 +02:00
parent 915ff4a6f7
commit 1e4d8ed90c
3 changed files with 47 additions and 1 deletions

View File

@@ -100,7 +100,7 @@
<td><?=$camp->area?></td>
<td>
<a href="<?=self::getUrl("Preorder", "Index", ["filter" => ["preordercampaign_id" => $camp->id]])?>">
<?=count($camp->active_preorders)?>
<?=$camp->active_preorder_count?>
<?php if($camp->homes_total): ?>
/ <?=$camp->homes_total?> (<?=(round((count($camp->active_preorders) / $camp->homes_total) * 100, 2))?> %)
<?php endif; ?>

View File

@@ -4,6 +4,7 @@ class Preordercampaign extends mfBaseModel {
private $network;
private $preorders;
private $active_preorders;
private $active_preorder_count = 0;
private $types;
private $setup_products = [];
private $salesclusters;
@@ -106,6 +107,21 @@ class Preordercampaign extends mfBaseModel {
return $this->active_preorders;
}
if($name == "active_preorder_count") {
$count = 0;
foreach($this->getProperty("active_preorders") as $preorder) {
//echo "/c:".$preorder->connection_count."/";
if($preorder->connection_count) {
$count += (int)$preorder->connection_count;
} else {
$count++;
}
//echo "/s:$count/";
}
$this->active_preorder_count = $count;
return $this->active_preorder_count;
}
if($name == "types") {
$types = PreordercampaignTypeModel::search(['preordercampaign_id' => $this->id]);
foreach($types as $type) {

View File

@@ -225,6 +225,36 @@ while($csv = fgetcsv($input, 0, ";")) {
echo "\n".($i-1)." Straßen importiert\n";
$filename = "$folder/STRASSE.csv";
$input = fopen($filename, "r");
$i = 0;
while($csv = fgetcsv($input, 0, ";")) {
$i++;
if($i == 1) continue;
if($i % 1000 == 0) {
echo ".";
}
if(!trim($csv[0])) {
continue;
}
$skz = trim($csv[0]);
$strasse_name = trim($csv[1]);
$gkz = trim($csv[4]);
if(!$skz) continue;
$gemeinde = getGemeinde($gkz);
if(!$gemeinde) {
die("Kann Strasse nicht importieren: Gemeinde nicht gefunden ($gkz)\n");
}
}
function getGemeinde($kz) {
global $gemeinden_cache;