Merge branch 'fronkdev' into 'master'

Added script to delete OAIDs incl. all linked data from Preorders

See merge request fronk/thetool!652
This commit is contained in:
Frank Schubert
2024-10-09 14:55:00 +00:00
5 changed files with 211 additions and 17 deletions

View File

@@ -8,6 +8,8 @@ class ADBNetzgebietModel {
public $rimo_id;
public $freigabe;
public $unit_count;
public $unit_count_sd;
public $unit_count_md;
public $create = null;
public $edit = null;

View File

@@ -44,7 +44,30 @@ class ADBWohneinheit extends mfBaseModel {
if($hausnummer->netzgebiet_id) {
$netzgebiet = new ADBNetzgebiet($hausnummer->netzgebiet_id);
if($netzgebiet->id) {
$netzgebiet->unit_count = ADBWohneinheitModel::count(['netzgebiet_id' => $hausnummer->netzgebiet_id]);
/*$netzgebiet->unit_count = ADBWohneinheitModel::count(['netzgebiet_id' => $hausnummer->netzgebiet_id]);
$gda_egenschaft = strtolower($hausnummer->gdaeigenschaft);
if($gda_egenschaft && array_key_exists($gda_egenschaft, TT_ADB_GDA_TYPES)) {
$netzgebiet->{"unit_count_".TT_ADB_GDA_TYPES[$gda_egenschaft]};
}*/
$unit_count = ADBWohneinheitModel::count(['netzgebiet_id' => $hausnummer->netzgebiet_id]);
if($unit_count) {
$unit_count_gda = [];
foreach(ADBHausnummerModel::search(["netzgebiet_id" => $hausnummer->netzgebiet_id]) as $hausnummer) {
$gda_egenschaft = strtolower($hausnummer->gdaeigenschaft);
if($gda_egenschaft && array_key_exists($gda_egenschaft, TT_ADB_GDA_TYPES)) {
$type = TT_ADB_GDA_TYPES[$gda_egenschaft];
if(!array_key_exists($type, $unit_count_gda)) {
$unit_count_gda[$type] = 0;
}
$unit_count_gda[$type] += $hausnummer->unit_count;
}
}
foreach($unit_count_gda as $type => $count) {
$netzgebiet->{"unit_count_$type"} = $count;
}
}
$netzgebiet->unit_count = $unit_count;
$netzgebiet->save();
}
}

View File

@@ -5,13 +5,18 @@ class Preordercampaign extends mfBaseModel {
private $adb_netzgebiet;
private $preorders;
private $active_preorders;
private $active_preorder_count = 0;
private $active_preorder_count;
private $active_preorder_count_sd;
private $active_preorder_count_md;
private $types;
private $setup_products = [];
private $salesclusters;
private $apiusers;
private $corsorigins;
private $total_homes;
private $total_homes_sd;
private $total_homes_md;
private $workorder_count;
private $required_fields = [];
private $banned_fcps;
private $all_fcp_names;
@@ -95,9 +100,29 @@ class Preordercampaign extends mfBaseModel {
public function getProperty($name) {
if($this->$name == null) {
if($name == "workorder_count") {
$wo_count = PreorderModel::count(["rimo_workorder" => true, "preordercampaign_id" => $this->id]);
if($wo_count) {
$this->workorder_count = $wo_count;
}
return $wo_count;
}
if($name == "total_homes_sd") {
$this->getProperty("total_homes");
return $this->total_homes_sd;
}
if($name == "total_homes_md") {
$this->getProperty("total_homes");
return $this->total_homes_md;
}
if($name == "total_homes") {
$total = 0;
$total_sd = 0;
$total_md = 0;
$netzgebiet_ids = null;
foreach($this->getProperty("salesclusters") as $scluster) {
@@ -106,10 +131,14 @@ class Preordercampaign extends mfBaseModel {
if(is_array($netzgebiet_ids) && count($netzgebiet_ids)) {
foreach(ADBNetzgebietModel::search(["netzgebiet_id" => $netzgebiet_ids]) as $netzgebiet) {
$total += $netzgebiet->unit_count;
$total_sd += $netzgebiet->unit_count_sd;
$total_md += $netzgebiet->unit_count_md;
}
}
$this->total_homes = $total;
$this->total_homes_sd = $total_sd;
$this->total_homes_md = $total_md;
return $total;
}
@@ -130,21 +159,37 @@ 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/";
if($name == "active_preorder_count_sd") {
$this->getProperty("active_preorder_count");
return $this->active_preorder_count_sd;
}
$this->active_preorder_count = $count;
return $this->active_preorder_count;
}
if($name == "active_preorder_count_md") {
$this->getProperty("active_preorder_count");
return $this->active_preorder_count_md;
}
if($name == "active_preorder_count") {
$count = 0;
$count_sd = 0;
$count_md = 0;
foreach($this->getProperty("active_preorders") as $preorder) {
//echo "/c:".$preorder->connection_count."/";
if($preorder->connection_type == "single-dwelling") {
$count_sd += $preorder->connection_count ? (int)$preorder->connection_count : 1;
} elseif ($preorder->connection_type == "multi-dwelling") {
$count_md += $preorder->connection_count ? (int)$preorder->connection_count : 1;
}
$count += (int)$preorder->connection_count;
//echo "/s:$count/";
}
$this->active_preorder_count = $count;
$this->active_preorder_count_sd = $count_sd;
$this->active_preorder_count_md = $count_md;
return $this->active_preorder_count;
}
if($name == "types") {
$types = PreordercampaignTypeModel::search(['preordercampaign_id' => $this->id]);
foreach($types as $type) {