WIP ADBWohneinheit afterSave Satus check
This commit is contained in:
@@ -14,6 +14,22 @@ class ADBWohneinheit extends mfBaseModel {
|
|||||||
protected function afterSave() {
|
protected function afterSave() {
|
||||||
if(!$this->id) return true;
|
if(!$this->id) return true;
|
||||||
if(!$this->hausnummer_id) return true;
|
if(!$this->hausnummer_id) return true;
|
||||||
|
|
||||||
|
// prevent potential infinite loop
|
||||||
|
$nesting_level = mfValuecache::singleton()->get("adbwohneinheit-save-nesting-level-".$this->id);
|
||||||
|
if(!$nesting_level) {
|
||||||
|
$nesting_level = 1;
|
||||||
|
} else {
|
||||||
|
$nesting_level++;
|
||||||
|
}
|
||||||
|
mfValuecache::singleton()->set("dbwohneinheit-save-nesting-level-".$this->id, $nesting_level);
|
||||||
|
|
||||||
|
if($nesting_level > 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Statuschange from Rimo statuschange
|
||||||
|
$this->setStatusFromRimo();
|
||||||
|
|
||||||
// ADBWohneinheit_onSave_noAutoUnitCount can be defined if doing bulk
|
// ADBWohneinheit_onSave_noAutoUnitCount can be defined if doing bulk
|
||||||
// operations where unit count is calculated seperately
|
// operations where unit count is calculated seperately
|
||||||
@@ -35,6 +51,55 @@ class ADBWohneinheit extends mfBaseModel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setStatusFromRimo() {
|
||||||
|
return true; // XXX disabled for now
|
||||||
|
if(!$this->id) return true;
|
||||||
|
if(!$this->rimo_id) return true;
|
||||||
|
|
||||||
|
if(!$this->hausnummer->netzgebiet->getOption("statuschange")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$preorder = PreorderModel::getFirstActive(["adb_wohneinheit_id" => $this->id]);
|
||||||
|
if(!$preorder) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$b_ex_state = strtolower($this->hausnummer->rimo_ex_state);
|
||||||
|
$b_op_state = strtolower($this->hausnummer->rimo_op_state);
|
||||||
|
|
||||||
|
$h_ex_state = strtolower($this->rimo_ex_state);
|
||||||
|
$h_op_state = strtolower($this->rimo_op_state);
|
||||||
|
|
||||||
|
$workorder = $this->getProperty("rimo_workorder");
|
||||||
|
$wo_state = strtolower($workorder->rimo_status);
|
||||||
|
|
||||||
|
foreach(TT_PREORDER_RIMO_STATUS_MATRIX as $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;
|
||||||
|
|
||||||
|
// seems all criteria match => set new status
|
||||||
|
|
||||||
|
$preorderstatus = $matrix["p"];
|
||||||
|
if(!$preorderstatus) continue;
|
||||||
|
|
||||||
|
$new_status = PreorderstatusModel::getFirst(["code" => $preorderstatus]);
|
||||||
|
if(!$new_status) continue;
|
||||||
|
if($preorderstatus->status->code < $new_status->code) {
|
||||||
|
$preorder->status_id = $new_status->id;
|
||||||
|
$preorder->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function parseHausnummerZusatz($text) {
|
public static function parseHausnummerZusatz($text) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ require_once(LIBDIR . "/mvcfronk/mfRouter/mfRouter.php");
|
|||||||
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseModel.php");
|
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseModel.php");
|
||||||
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseController.php");
|
require_once(LIBDIR . "/mvcfronk/mfBase/mfBaseController.php");
|
||||||
|
|
||||||
$me = new \User(1);
|
$me = new \User(TT_RIMO_IMPORT_USER_ID);
|
||||||
|
|
||||||
define("INTERNAL_USER_ID", $me->id);
|
define("INTERNAL_USER_ID", $me->id);
|
||||||
define("INTERNAL_USER_USERNAME", $me->username);
|
define("INTERNAL_USER_USERNAME", $me->username);
|
||||||
|
|||||||
Reference in New Issue
Block a user