From 67024e0be29608b0962a950f25328314a75ea9e7 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 16 Dec 2025 01:39:44 +0100 Subject: [PATCH] Rimo Import: Checking if FCP Status Matrix exists before using it --- scripts/adb-rimo-import/rimo-import.php | 46 +++++++++++++------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/scripts/adb-rimo-import/rimo-import.php b/scripts/adb-rimo-import/rimo-import.php index 4c8e6eb05..1b9829a8b 100755 --- a/scripts/adb-rimo-import/rimo-import.php +++ b/scripts/adb-rimo-import/rimo-import.php @@ -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; } } }