New Preorderstatus handling at import
This commit is contained in:
@@ -70,7 +70,83 @@ class AddressDB {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
|
||||
public static function handleRimoStatusUpdate($wohneinheit_id) {
|
||||
if(!$wohneinheit_id) return true;
|
||||
|
||||
$log = mfLoghandler::singleton();
|
||||
//echo "in handleRimoStatusUpdate\n";
|
||||
|
||||
$wohneinheit = new ADBWohneinheit($wohneinheit_id);
|
||||
if(!$wohneinheit->id) return false;
|
||||
|
||||
$hausnummer = $wohneinheit->hausnummer;
|
||||
if(!$hausnummer->netzgebiet->getOption("statuschange")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$preorder = PreorderModel::getFirstActive(["adb_wohneinheit_id" => $wohneinheit->id]);
|
||||
if(!$preorder) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$b_ex_state = strtolower($hausnummer->rimo_ex_state);
|
||||
$b_op_state = strtolower($hausnummer->rimo_op_state);
|
||||
|
||||
$h_ex_state = strtolower($wohneinheit->rimo_ex_state);
|
||||
$h_op_state = strtolower($wohneinheit->rimo_op_state);
|
||||
|
||||
$wo_state = false;
|
||||
$workorder = $wohneinheit->rimo_workorder;
|
||||
if($workorder) {
|
||||
$wo_state = strtolower($workorder->rimo_status);
|
||||
}
|
||||
|
||||
|
||||
$order_type = $preorder->type;
|
||||
|
||||
foreach(TT_PREORDER_RIMO_STATUS_MATRIX as $matrix) {
|
||||
//echo "wohneinheit ".$wohneinheit->id."\n";
|
||||
//var_dump($matrix);
|
||||
if($matrix["rbop"] && $matrix["rbop"] != $b_op_state) continue;
|
||||
if($matrix["rbex"] && $matrix["rbex"] != $b_ex_state) continue;
|
||||
|
||||
if($matrix["rhop"] && $matrix["rhop"] != $h_op_state) continue;
|
||||
if($matrix["rhex"] && $matrix["rhex"] != $h_ex_state) continue;
|
||||
|
||||
if($matrix["rwo"] && (!$workorder || $matrix["rwo"] != $wo_state)) continue;
|
||||
|
||||
if($matrix["pt"] && $matrix["pt"] != $order_type) continue;
|
||||
// seems all criteria match => set new status
|
||||
|
||||
$log->debug(__METHOD__.": new Preorder Status: ".$matrix["p"]);
|
||||
|
||||
$preorderstatus = $matrix["p"];
|
||||
if(!$preorderstatus) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$preorder->setNewStatusCode($preorderstatus);
|
||||
$preorder->save();
|
||||
|
||||
$hausnummer_status = $matrix["h"];
|
||||
if($hausnummer_status) {
|
||||
$log->debug(__METHOD__.": new Hausnummer (".$hausnummer->id.") status: ".$matrix["h"]);
|
||||
$hausnummer->setNewStatusCode($hausnummer_status);
|
||||
$hausnummer->save();
|
||||
}
|
||||
|
||||
$wohneinheit_status = $matrix["w"];
|
||||
if($wohneinheit_status) {
|
||||
$wohneinheit->setNewStatusCode($wohneinheit_status);
|
||||
$wohneinheit->save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function import($input) {
|
||||
$path = __DIR__."/Importer/";
|
||||
$dir = opendir($path);
|
||||
|
||||
Reference in New Issue
Block a user