Merge branch 'fronkdev' into 'master'
OAIDs can be released now See merge request fronk/thetool!1348
This commit is contained in:
@@ -17,7 +17,7 @@ class ADBHausnummer extends mfBaseModel {
|
||||
mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$this->id, 0);
|
||||
}
|
||||
|
||||
public function afterSave() {
|
||||
public function afterSave($_params = []) {
|
||||
// prevent potential infinite loop
|
||||
$nesting_level = mfValuecache::singleton()->get("adbhausnummer-save-nesting-level-".$this->id);
|
||||
if(!$nesting_level) {
|
||||
|
||||
@@ -22,7 +22,7 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
$this->refreshUnitCount();
|
||||
}
|
||||
|
||||
protected function afterSave() {
|
||||
protected function afterSave($_params = []) {
|
||||
if(!$this->id) return true;
|
||||
if(!$this->hausnummer_id) return true;
|
||||
|
||||
@@ -40,8 +40,12 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
}
|
||||
|
||||
$this->logChanges();
|
||||
// Statuschange from Rimo statuschange
|
||||
AddressDB::handleRimoStatusUpdate($this->id);
|
||||
|
||||
if(!array_key_exists("no_updates", $_params) || !$_params['no_updates']) {
|
||||
// Statuschange from Rimo statuschange
|
||||
AddressDB::handleRimoStatusUpdate($this->id);
|
||||
}
|
||||
|
||||
|
||||
$this->refreshUnitCount();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class ADBWohneinheitStatusflagValue extends mfBaseModel {
|
||||
$this->table = "WohneinheitStatusflagValue";
|
||||
}
|
||||
|
||||
protected function afterSave() {
|
||||
protected function afterSave($_params = []) {
|
||||
if(!property_exists($this->_old_data, "value") || $this->_old_data->value != $this->data->value) {
|
||||
// cascade new status to all preorders
|
||||
foreach(PreorderModel::search(["adb_wohneinheit_id" => $this->wohneinheit_id]) as $preorder) {
|
||||
|
||||
@@ -20,7 +20,7 @@ class Address extends mfBaseModel {
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
public function afterSave() {
|
||||
public function afterSave($_params = []) {
|
||||
// prevent potential infinite loop
|
||||
if($this->in_after_save) return true;
|
||||
$this->in_after_save++;
|
||||
|
||||
@@ -86,7 +86,56 @@ class OpenAccessIdController extends mfBaseController {
|
||||
|
||||
return $new_filter;
|
||||
}
|
||||
|
||||
|
||||
protected function releaseAction() {
|
||||
$id = $this->request->id;
|
||||
if(!$id || $id <1) {
|
||||
$this->layout()->setFlash("Ungültige OAID", "error");
|
||||
$this->redirect("OpenAccessId");
|
||||
}
|
||||
|
||||
$oaid = new OpenAccessId($id);
|
||||
if(!$oaid->id) {
|
||||
$this->layout()->setFlash("Ungültige OAID", "error");
|
||||
$this->redirect("OpenAccessId");
|
||||
}
|
||||
|
||||
$oaid->startTransaction();
|
||||
|
||||
// remove from Preorders
|
||||
foreach(PreorderModel::search(["oaid" => $oaid->oaid]) as $preorder) {
|
||||
$preorder->oaid = null;
|
||||
$preorder->save(["no_oaid_update" => true, "dont_cascade" => true]);
|
||||
}
|
||||
|
||||
// remove from Wohneinheiten
|
||||
foreach(ADBWohneinheitModel::search(["oaid" => $oaid->oaid]) as $unit) {
|
||||
$unit->oaid = null;
|
||||
$unit->save(["no_updates" => 1]);
|
||||
|
||||
$ftu_id = $unit->ftu_data["id"];
|
||||
if($ftu_id) {
|
||||
$this->log->debug(__METHOD__.": trying to unassign Oaid ".$oaid->oaid." from Rimo FTU ".$ftu_id);
|
||||
//Rimoapi::unassignOaid($oaid->oaid, $ftu_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$oaid->assigned = 0;
|
||||
$oaid->adb_wohneinheit_id = null;
|
||||
$oaid->exported = 0;
|
||||
$oaid->exported_to = null;
|
||||
$oaid->export_data = null;
|
||||
$oaid->address = null;
|
||||
$oaid->unit_string = null;
|
||||
$oaid->save();
|
||||
|
||||
$oaid->commitTransaction();
|
||||
|
||||
$this->layout()->setFlash("OAID erfolgreich freigegeben");
|
||||
$this->redirect("OpenAccessId");
|
||||
}
|
||||
|
||||
protected function changeADBWohneinheitAction() {
|
||||
$this->layout()->setTemplate("OpenAccessId/ChangeUnit");
|
||||
$id = $this->request->id;
|
||||
|
||||
@@ -38,13 +38,13 @@ class Preorder extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeSave() {
|
||||
public function beforeSave($_params = []) {
|
||||
if(!isset($this->data->status_id)) {
|
||||
$this->data->status_id = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function afterSave() {
|
||||
public function afterSave($_params = []) {
|
||||
// reset auto magic properties
|
||||
$this->status = null;
|
||||
$this->campaign = null;
|
||||
@@ -71,29 +71,36 @@ class Preorder extends mfBaseModel {
|
||||
return true;
|
||||
}
|
||||
|
||||
// update preorder OAID if it's different from the unit OAID
|
||||
// but only if the unit OAID is of the same origin as the campaign
|
||||
$old_oaid = $this->oaid;
|
||||
if(!array_key_exists("no_oaid_update", $_params) || !$_params['no_oaid_update']) {
|
||||
// update preorder OAID if it's different from the unit OAID
|
||||
// but only if the unit OAID is of the same origin as the campaign
|
||||
$old_oaid = $this->oaid;
|
||||
|
||||
$this->setOrCreateOaid();
|
||||
if($this->oaid != $old_oaid) {
|
||||
$this->resetSaveNesting();
|
||||
$this->save();
|
||||
//return true;
|
||||
$this->setOrCreateOaid();
|
||||
if($this->oaid != $old_oaid) {
|
||||
$this->resetSaveNesting();
|
||||
$this->save();
|
||||
//return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO: history start
|
||||
//if($this->status_id != $this->_old_data->status_id) {
|
||||
$this->createHistoryEntry();
|
||||
//}
|
||||
|
||||
$this->updateRimoWorkorderContact();
|
||||
// run triggers based on new status
|
||||
$this->runStatusTrigger();
|
||||
// Cascade status changes down to adb_hausnummer and adb_wohneinheit
|
||||
$this->cascadeStatus();
|
||||
// Cascade status changes down all active preorders with the same hausnummer
|
||||
$this->cascadeStatusToPreorders();
|
||||
if(!array_key_exists("dont_cascade", $_params) || !$_params['dont_cascade']) {
|
||||
$this->updateRimoWorkorderContact();
|
||||
// run triggers based on new status
|
||||
$this->runStatusTrigger();
|
||||
// Cascade status changes down to adb_hausnummer and adb_wohneinheit
|
||||
$this->cascadeStatus();
|
||||
// Cascade status changes down all active preorders with the same hausnummer
|
||||
$this->cascadeStatusToPreorders();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function resetSaveNesting() {
|
||||
|
||||
Reference in New Issue
Block a user