Merge branch 'fronkdev' into 'master'

Fronkdev

See merge request fronk/thetool!653
This commit is contained in:
Frank Schubert
2024-10-09 15:46:27 +00:00

View File

@@ -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,17 +336,27 @@ 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") {
$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);
@@ -358,6 +370,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;
}