OAIDs can be released now
This commit is contained in:
@@ -122,8 +122,8 @@
|
|||||||
<th>Herkunft</th>
|
<th>Herkunft</th>
|
||||||
<th>Besitzer</th>
|
<th>Besitzer</th>
|
||||||
<th colspan="2" title="Anzahl ADB Wohneinheiten">Zugewiesen</th>
|
<th colspan="2" title="Anzahl ADB Wohneinheiten">Zugewiesen</th>
|
||||||
<th>Exportiert</th>
|
|
||||||
<th></th>
|
<th></th>
|
||||||
|
<th>Exportiert</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
<?php foreach($oaids as $oaid): ?>
|
<?php foreach($oaids as $oaid): ?>
|
||||||
@@ -136,6 +136,7 @@
|
|||||||
<td><?=$oaid->owner->getCompanyOrName()?></td>
|
<td><?=$oaid->owner->getCompanyOrName()?></td>
|
||||||
<td class="text-right <?=($oaid->adb_wohneinheit_count > 1 || $oaid->adb_wohneinheit_id && $oaid->adb_wohneinheit_count < 1) ? "text-danger" : ""?>">
|
<td class="text-right <?=($oaid->adb_wohneinheit_count > 1 || $oaid->adb_wohneinheit_id && $oaid->adb_wohneinheit_count < 1) ? "text-danger" : ""?>">
|
||||||
<?=($oaid->adb_wohneinheit_id) ? $oaid->adb_wohneinheit_count."x" : ""?>
|
<?=($oaid->adb_wohneinheit_id) ? $oaid->adb_wohneinheit_count."x" : ""?>
|
||||||
|
<a class="ml-2" href="<?=self::getUrl("OpenAccessId", "release", ["id" => $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;"><i class="far fa-link-slash"></i></a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php if($oaid->termination_id): ?>
|
<?php if($oaid->termination_id): ?>
|
||||||
@@ -151,7 +152,11 @@
|
|||||||
<?=((string)$oaid->adb_wohneinheit) ? " - ".(string)$oaid->adb_wohneinheit : ""?>
|
<?=((string)$oaid->adb_wohneinheit) ? " - ".(string)$oaid->adb_wohneinheit : ""?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</td>
|
</td>
|
||||||
<td><?=($oaid->assigned) ? date("d.m.Y H:i",$oaid->assigned) : ""?></td>
|
<td>
|
||||||
|
<?php if($oaid->assigned): ?>
|
||||||
|
<?=date("d.m.Y H:i",$oaid->assigned)?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php if($oaid->exported_to): ?>
|
<?php if($oaid->exported_to): ?>
|
||||||
[<?=$oaid->exported_to?>]
|
[<?=$oaid->exported_to?>]
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ADBHausnummer extends mfBaseModel {
|
|||||||
mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$this->id, 0);
|
mfValuecache::singleton()->set("adbhausnummer-save-nesting-level-".$this->id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterSave() {
|
public function afterSave($_params = []) {
|
||||||
// prevent potential infinite loop
|
// prevent potential infinite loop
|
||||||
$nesting_level = mfValuecache::singleton()->get("adbhausnummer-save-nesting-level-".$this->id);
|
$nesting_level = mfValuecache::singleton()->get("adbhausnummer-save-nesting-level-".$this->id);
|
||||||
if(!$nesting_level) {
|
if(!$nesting_level) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ADBWohneinheit extends mfBaseModel {
|
|||||||
$this->refreshUnitCount();
|
$this->refreshUnitCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function afterSave() {
|
protected function afterSave($_params = []) {
|
||||||
if(!$this->id) return true;
|
if(!$this->id) return true;
|
||||||
if(!$this->hausnummer_id) return true;
|
if(!$this->hausnummer_id) return true;
|
||||||
|
|
||||||
@@ -40,8 +40,12 @@ class ADBWohneinheit extends mfBaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->logChanges();
|
$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();
|
$this->refreshUnitCount();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class ADBWohneinheitStatusflagValue extends mfBaseModel {
|
|||||||
$this->table = "WohneinheitStatusflagValue";
|
$this->table = "WohneinheitStatusflagValue";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function afterSave() {
|
protected function afterSave($_params = []) {
|
||||||
if(!property_exists($this->_old_data, "value") || $this->_old_data->value != $this->data->value) {
|
if(!property_exists($this->_old_data, "value") || $this->_old_data->value != $this->data->value) {
|
||||||
// cascade new status to all preorders
|
// cascade new status to all preorders
|
||||||
foreach(PreorderModel::search(["adb_wohneinheit_id" => $this->wohneinheit_id]) as $preorder) {
|
foreach(PreorderModel::search(["adb_wohneinheit_id" => $this->wohneinheit_id]) as $preorder) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Address extends mfBaseModel {
|
|||||||
private $creator;
|
private $creator;
|
||||||
private $editor;
|
private $editor;
|
||||||
|
|
||||||
public function afterSave() {
|
public function afterSave($_params = []) {
|
||||||
// prevent potential infinite loop
|
// prevent potential infinite loop
|
||||||
if($this->in_after_save) return true;
|
if($this->in_after_save) return true;
|
||||||
$this->in_after_save++;
|
$this->in_after_save++;
|
||||||
|
|||||||
@@ -86,7 +86,56 @@ class OpenAccessIdController extends mfBaseController {
|
|||||||
|
|
||||||
return $new_filter;
|
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() {
|
protected function changeADBWohneinheitAction() {
|
||||||
$this->layout()->setTemplate("OpenAccessId/ChangeUnit");
|
$this->layout()->setTemplate("OpenAccessId/ChangeUnit");
|
||||||
$id = $this->request->id;
|
$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)) {
|
if(!isset($this->data->status_id)) {
|
||||||
$this->data->status_id = 1;
|
$this->data->status_id = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterSave() {
|
public function afterSave($_params = []) {
|
||||||
// reset auto magic properties
|
// reset auto magic properties
|
||||||
$this->status = null;
|
$this->status = null;
|
||||||
$this->campaign = null;
|
$this->campaign = null;
|
||||||
@@ -71,29 +71,36 @@ class Preorder extends mfBaseModel {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update preorder OAID if it's different from the unit OAID
|
if(!array_key_exists("no_oaid_update", $_params) || !$_params['no_oaid_update']) {
|
||||||
// but only if the unit OAID is of the same origin as the campaign
|
// update preorder OAID if it's different from the unit OAID
|
||||||
$old_oaid = $this->oaid;
|
// but only if the unit OAID is of the same origin as the campaign
|
||||||
|
$old_oaid = $this->oaid;
|
||||||
|
|
||||||
$this->setOrCreateOaid();
|
$this->setOrCreateOaid();
|
||||||
if($this->oaid != $old_oaid) {
|
if($this->oaid != $old_oaid) {
|
||||||
$this->resetSaveNesting();
|
$this->resetSaveNesting();
|
||||||
$this->save();
|
$this->save();
|
||||||
//return true;
|
//return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: history start
|
//TODO: history start
|
||||||
//if($this->status_id != $this->_old_data->status_id) {
|
//if($this->status_id != $this->_old_data->status_id) {
|
||||||
$this->createHistoryEntry();
|
$this->createHistoryEntry();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
$this->updateRimoWorkorderContact();
|
if(!array_key_exists("dont_cascade", $_params) || !$_params['dont_cascade']) {
|
||||||
// run triggers based on new status
|
$this->updateRimoWorkorderContact();
|
||||||
$this->runStatusTrigger();
|
// run triggers based on new status
|
||||||
// Cascade status changes down to adb_hausnummer and adb_wohneinheit
|
$this->runStatusTrigger();
|
||||||
$this->cascadeStatus();
|
// Cascade status changes down to adb_hausnummer and adb_wohneinheit
|
||||||
// Cascade status changes down all active preorders with the same hausnummer
|
$this->cascadeStatus();
|
||||||
$this->cascadeStatusToPreorders();
|
// Cascade status changes down all active preorders with the same hausnummer
|
||||||
|
$this->cascadeStatusToPreorders();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resetSaveNesting() {
|
public function resetSaveNesting() {
|
||||||
|
|||||||
@@ -148,9 +148,9 @@ class mfBaseModel {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save($_params = []) {
|
||||||
if(method_exists($this, "beforeSave")) {
|
if(method_exists($this, "beforeSave")) {
|
||||||
$this->beforeSave();
|
$this->beforeSave($_params);
|
||||||
}
|
}
|
||||||
$fields = $this->buildFields();
|
$fields = $this->buildFields();
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ class mfBaseModel {
|
|||||||
if($this->db->update($this->table, $fields, $where, $forcestr)) {
|
if($this->db->update($this->table, $fields, $where, $forcestr)) {
|
||||||
$this->saved++;
|
$this->saved++;
|
||||||
if(method_exists($this, "afterSave")) {
|
if(method_exists($this, "afterSave")) {
|
||||||
$this->afterSave();
|
$this->afterSave($_params);
|
||||||
}
|
}
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ class mfBaseModel {
|
|||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->saved++;
|
$this->saved++;
|
||||||
if(method_exists($this, "afterSave")) {
|
if(method_exists($this, "afterSave")) {
|
||||||
$this->afterSave();
|
$this->afterSave($_params);
|
||||||
}
|
}
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user