diff --git a/Layout/default/OpenAccessId/Index.php b/Layout/default/OpenAccessId/Index.php
index cd0251af7..082c49fd4 100644
--- a/Layout/default/OpenAccessId/Index.php
+++ b/Layout/default/OpenAccessId/Index.php
@@ -122,8 +122,8 @@
Herkunft |
Besitzer |
Zugewiesen |
- Exportiert |
|
+ Exportiert |
|
@@ -136,6 +136,7 @@
=$oaid->owner->getCompanyOrName()?> |
">
=($oaid->adb_wohneinheit_id) ? $oaid->adb_wohneinheit_count."x" : ""?>
+ $oaid->id])?>" title="OAID freigeben" onclick="if(!confirm('Sind Sie sicher, dass die OAID von Wohneinheit, Preorder und Rimo-FTU entfernt werden soll?')) return false;">
|
termination_id): ?>
@@ -151,7 +152,11 @@
=((string)$oaid->adb_wohneinheit) ? " - ".(string)$oaid->adb_wohneinheit : ""?>
|
- =($oaid->assigned) ? date("d.m.Y H:i",$oaid->assigned) : ""?> |
+
+ assigned): ?>
+ =date("d.m.Y H:i",$oaid->assigned)?>
+
+ |
exported_to): ?>
[=$oaid->exported_to?>]
diff --git a/application/ADBHausnummer/ADBHausnummer.php b/application/ADBHausnummer/ADBHausnummer.php
index df17b46b0..1194c35e5 100644
--- a/application/ADBHausnummer/ADBHausnummer.php
+++ b/application/ADBHausnummer/ADBHausnummer.php
@@ -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) {
diff --git a/application/ADBWohneinheit/ADBWohneinheit.php b/application/ADBWohneinheit/ADBWohneinheit.php
index fac68ebfa..8d0873f5e 100644
--- a/application/ADBWohneinheit/ADBWohneinheit.php
+++ b/application/ADBWohneinheit/ADBWohneinheit.php
@@ -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();
}
diff --git a/application/ADBWohneinheitStatusflagValue/ADBWohneinheitStatusflagValue.php b/application/ADBWohneinheitStatusflagValue/ADBWohneinheitStatusflagValue.php
index ac116eba3..f7c748fc5 100644
--- a/application/ADBWohneinheitStatusflagValue/ADBWohneinheitStatusflagValue.php
+++ b/application/ADBWohneinheitStatusflagValue/ADBWohneinheitStatusflagValue.php
@@ -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) {
diff --git a/application/Address/Address.php b/application/Address/Address.php
index c0dc8a2b4..63d4d0a14 100644
--- a/application/Address/Address.php
+++ b/application/Address/Address.php
@@ -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++;
diff --git a/application/OpenAccessId/OpenAccessIdController.php b/application/OpenAccessId/OpenAccessIdController.php
index 83d249819..03794d5b2 100644
--- a/application/OpenAccessId/OpenAccessIdController.php
+++ b/application/OpenAccessId/OpenAccessIdController.php
@@ -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;
diff --git a/application/Preorder/Preorder.php b/application/Preorder/Preorder.php
index c5a90a801..2557a3cc7 100644
--- a/application/Preorder/Preorder.php
+++ b/application/Preorder/Preorder.php
@@ -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() {
diff --git a/lib/mvcfronk/mfBase/mfBaseModel.php b/lib/mvcfronk/mfBase/mfBaseModel.php
index 20a3e384a..5b1aa08bb 100644
--- a/lib/mvcfronk/mfBase/mfBaseModel.php
+++ b/lib/mvcfronk/mfBase/mfBaseModel.php
@@ -148,9 +148,9 @@ class mfBaseModel {
return true;
}
- public function save() {
+ public function save($_params = []) {
if(method_exists($this, "beforeSave")) {
- $this->beforeSave();
+ $this->beforeSave($_params);
}
$fields = $this->buildFields();
@@ -179,7 +179,7 @@ class mfBaseModel {
if($this->db->update($this->table, $fields, $where, $forcestr)) {
$this->saved++;
if(method_exists($this, "afterSave")) {
- $this->afterSave();
+ $this->afterSave($_params);
}
return $id;
}
@@ -189,7 +189,7 @@ class mfBaseModel {
$this->id = $id;
$this->saved++;
if(method_exists($this, "afterSave")) {
- $this->afterSave();
+ $this->afterSave($_params);
}
return $id;
}
|