From 50bfe054439fe6c271f2381665414c6023e83ace Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 9 Oct 2024 17:20:08 +0200 Subject: [PATCH 1/2] Preorder save() now handles OAID of changeing Wohneinheit --- application/Preorder/Preorder.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index 2439cd9c9..fd19c7f50 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -60,7 +60,9 @@ class Preorder extends mfBaseModel { $this->setOrCreateOaid(); if($this->oaid != $old_oaid) { + $this->resetSaveNesting(); $this->save(); + return true; } //TODO: history start @@ -334,11 +336,16 @@ class Preorder extends mfBaseModel { } if(!$this->adb_wohneinheit_id) { + $this->oaid = null; return false; } $wohneinheit = new ADBWohneinheit($this->adb_wohneinheit_id); + if(!$wohneinheit) { + return true; + } + if($this->oaid) { // If current OAID is from correct Origin then do nothing if($campaign->oaid_origin == "thetool") { @@ -358,6 +365,10 @@ class Preorder extends mfBaseModel { if(!$wohneinheit->oaid) { $wohneinheit->oaid = $current_oaid->oaid; $wohneinheit->save(); + } elseif($wohneinheit->oaid != $this->oaid) { + // also check if wohneinheit has a different OAID and set it in the Preorder + // No need to update OAID object, it should be correct already, because Wohneinheit is the source of oaid data, + $this->oaid = $wohneinheit->oaid; } return true; } From cb71af915f9fbb0f04f4df2b7fc425e209690e8d Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 9 Oct 2024 17:46:04 +0200 Subject: [PATCH 2/2] same for thetool OAIDs --- application/Preorder/Preorder.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php index fd19c7f50..28aa2687a 100644 --- a/application/Preorder/Preorder.php +++ b/application/Preorder/Preorder.php @@ -352,6 +352,11 @@ class Preorder extends mfBaseModel { $current_oaid = OpenAccessIdModel::getFirstOaid($this->oaid); if($current_oaid) { $this->log->warning("OAID of Preorder " . $this->id . " should be thetool, but is OFAA"); + } else { + if($wohneinheit->oaid != $this->oaid) { + $this->oaid = $wohneinheit->oaid; + return true; + } } } elseif($campaign->oaid_origin == "ofaa") { $current_oaid = OpenAccessIdModel::getFirstOaid($this->oaid);