now Caching Preorder load + auto updating attrib inhouse_cabling_supplied
This commit is contained in:
@@ -41,6 +41,11 @@ class Preorder extends mfBaseModel {
|
||||
if($this->uid === "string") {
|
||||
$this->uid = "";
|
||||
}
|
||||
|
||||
if($this->id) {
|
||||
//echo "[{$this->_ruid}] preorder::afterload: adding to cache\n";
|
||||
mfValuecache::singleton()->set("mfObjectmodel-preorder-" . $this->id, $this);
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeSave($_params = []) {
|
||||
@@ -57,6 +62,7 @@ class Preorder extends mfBaseModel {
|
||||
$this->building = null;
|
||||
$this->adb_hausnummer = null;
|
||||
$this->adb_wohneinheit = null;
|
||||
$this->attribute = null;
|
||||
$this->services = null;
|
||||
$this->ordered_services = null;
|
||||
$this->creator = null;
|
||||
@@ -475,7 +481,11 @@ class Preorder extends mfBaseModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
$hausnummer = new ADBHausnummer($this->adb_hausnummer_id);
|
||||
$hausnummer = mfValuecache::singleton()->get("mfObjectmodel-adb_hausnummer-" . $this->adb_hausnummer_id);
|
||||
if(!$hausnummer) {
|
||||
$hausnummer = new ADBHausnummer($this->adb_hausnummer_id);
|
||||
if($hausnummer->id) mfValuecache::singleton()->set("mfObjectmodel-adb_hausnummer-".$this->adb_hausnummer_id, $hausnummer);
|
||||
}
|
||||
if(!$hausnummer->id) {
|
||||
$this->log->warning("[".$this->_ruid."] ".__METHOD__ . ": hausnummer " . $this->adb_hausnummer_id . " not found!");
|
||||
return true;
|
||||
@@ -519,7 +529,11 @@ class Preorder extends mfBaseModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
$wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id);
|
||||
$wohneinheit = mfValuecache::singleton()->get("mfObjectmodel-adb_wohneinheit-" . $this->adb_wohneinheit_id);
|
||||
if(!$wohneinheit) {
|
||||
$wohneinheit = new ADBwohneinheit($this->adb_wohneinheit_id);
|
||||
if($wohneinheit->id) mfValuecache::singleton()->set("mfObjectmodel-adb_wohneinheit-".$this->adb_wohneinheit_id, $wohneinheit);
|
||||
}
|
||||
if(!$wohneinheit->id) return true;
|
||||
|
||||
$this->log->debug("[".$this->_ruid."] ".__METHOD__ . ": new wohneinheit status code " . $new_wohneinheit_status->code);
|
||||
@@ -536,6 +550,24 @@ class Preorder extends mfBaseModel {
|
||||
if(is_array($flags) && count($flags)) {
|
||||
foreach($flags as $flag) {
|
||||
if(strlen($flag->value->value) && array_key_exists($flag->code, TT_PREORDER_STATUS_FLAG_MATRIX)) {
|
||||
|
||||
if($flag->code == "145") {
|
||||
//echo "flag 145\n";
|
||||
$attribs = $this->getProperty("attribute");
|
||||
if(!is_array($attribs)) {
|
||||
$attribs = [];
|
||||
}
|
||||
|
||||
if(!array_key_exists("inhouse_cabling_supplied", $attribs) || $attribs["inhouse_cabling_supplied"] != $flag->value->value) {
|
||||
$attribs["inhouse_cabling_supplied"] = (int)$flag->value->value;
|
||||
//echo "[{$this->_ruid}] preorder::aftersave: updating attrib to ".(int)$flag->value->value."\n";
|
||||
$this->attributes = json_encode($attribs);
|
||||
$this->save(["no_aftersave" => true]);
|
||||
//print_r($this->attributes);echo "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$flag_matrix_item = TT_PREORDER_STATUS_FLAG_MATRIX[$flag->code];
|
||||
if(!$flag_matrix_item["flag"]) continue;
|
||||
|
||||
@@ -1051,7 +1083,7 @@ class Preorder extends mfBaseModel {
|
||||
public function setStatusFlag($code, $value = 1) {
|
||||
if(!$code) return false;
|
||||
|
||||
$sflag = PreorderstatusflagModel::getFirst(["code" => $code]);
|
||||
$sflag = PreorderStatusflagModel::getFirst(["code" => $code]);
|
||||
if(!$sflag) return false;
|
||||
|
||||
$sflag->preorder_id = $this->id;
|
||||
@@ -1503,12 +1535,28 @@ class Preorder extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "adb_hausnummer") {
|
||||
$this->adb_hausnummer = new ADBHausnummer($this->adb_hausnummer_id);
|
||||
$hausnummer = mfValuecache::singleton()->get("mfObjectmodel-adb_hausnummer-" . $this->adb_hausnummer_id);
|
||||
if(!$hausnummer) {
|
||||
$hausnummer = new ADBHausnummer($this->adb_hausnummer_id);
|
||||
}
|
||||
if($hausnummer && $hausnummer->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-adb_hausnummer-" . $this->adb_hausnummer_id, $hausnummer);
|
||||
$this->adb_hausnummer = $hausnummer;
|
||||
}
|
||||
|
||||
return $this->adb_hausnummer;
|
||||
}
|
||||
|
||||
if($name == "adb_wohneinheit") {
|
||||
$this->adb_wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id);
|
||||
$wohneinheit = mfValuecache::singleton()->get("mfObjectmodel-adb_wohneinheit-" . $this->adb_wohneinheit_id);
|
||||
if(!$wohneinheit) {
|
||||
$wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id);
|
||||
}
|
||||
if($wohneinheit && $wohneinheit->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-adb_wohneinheit-" . $this->adb_wohneinheit_id, $wohneinheit);
|
||||
$this->adb_wohneinheit = $wohneinheit;
|
||||
}
|
||||
|
||||
return $this->adb_wohneinheit;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user