Rimo Import: Checking if FCP Status Matrix exists before using it

This commit is contained in:
Frank Schubert
2025-12-16 01:39:44 +01:00
parent 54ade253c2
commit 67024e0be2

View File

@@ -1045,32 +1045,34 @@ foreach ($clusters as $cluster_data) {
$fcp->update((array)$fcp);
// see if buildings and preorders need to get flag 141 set
foreach(TT_PREORDER_RIMO_FCP_STATUS_MATRIX as $matrix) {
if(!$matrix["pf"] && !$matrix["hf"]) {
continue;
}
//echo "checking if need to set pf {$matrix["pf"]} or hf {$matrix["hf"]}\n";
if(!is_array($matrix["fcpop"])) $matrix["fcpop"] = [$matrix["fcpop"]];
if(!is_array($matrix["fcpex"])) $matrix["fcpex"] = [$matrix["fcpex"]];
if(!in_array(strtolower($fcp->rimo_ex_state), $matrix["fcpex"])) continue;
if(!in_array(strtolower($fcp->rimo_op_state), $matrix["fcpop"])) continue;
foreach(\ADBHausnummerModel::search(["fcp_id" => $fcp->id]) as $hausnummer) {
if(array_key_exists("hf", $matrix) && $matrix["hf"]) {
//echo "setting hausnummer {$hausnummer->id} flag {$matrix["hf"]}\n";
$hausnummer->setStatusflag($matrix["hf"], 1);
if(defined("TT_PREORDER_RIMO_FCP_STATUS_MATRIX")) {
foreach (TT_PREORDER_RIMO_FCP_STATUS_MATRIX as $matrix) {
if (!$matrix["pf"] && !$matrix["hf"]) {
continue;
}
if(array_key_exists("pf", $matrix) && $matrix["pf"]) {
foreach(\PreorderModel::searchActive(["adb_hausnummer_id" => $hausnummer->id]) as $preorder) {
//echo "setting preorder {$preorder->id} flag {$matrix["pf"]}\n";
$preorder->setStatusFlag($matrix["pf"], 1);
//echo "checking if need to set pf {$matrix["pf"]} or hf {$matrix["hf"]}\n";
if (!is_array($matrix["fcpop"])) $matrix["fcpop"] = [$matrix["fcpop"]];
if (!is_array($matrix["fcpex"])) $matrix["fcpex"] = [$matrix["fcpex"]];
if (!in_array(strtolower($fcp->rimo_ex_state), $matrix["fcpex"])) continue;
if (!in_array(strtolower($fcp->rimo_op_state), $matrix["fcpop"])) continue;
foreach (\ADBHausnummerModel::search(["fcp_id" => $fcp->id]) as $hausnummer) {
if (array_key_exists("hf", $matrix) && $matrix["hf"]) {
//echo "setting hausnummer {$hausnummer->id} flag {$matrix["hf"]}\n";
$hausnummer->setStatusflag($matrix["hf"], 1);
}
if (array_key_exists("pf", $matrix) && $matrix["pf"]) {
foreach (\PreorderModel::searchActive(["adb_hausnummer_id" => $hausnummer->id]) as $preorder) {
//echo "setting preorder {$preorder->id} flag {$matrix["pf"]}\n";
$preorder->setStatusFlag($matrix["pf"], 1);
}
}
}
break;
}
break;
}
}
}