Wohneinheiten can be deleted in AddressDB now
This commit is contained in:
@@ -154,6 +154,7 @@
|
||||
<th>Beschreibung</th>
|
||||
<th>Extref</th>
|
||||
<th title="Anzahl Bestellungen">Best.</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($address->wohneinheiten as $unit): ?>
|
||||
<tr>
|
||||
@@ -191,6 +192,7 @@
|
||||
0
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><a href="<?=self::getUrl("ADBWohneinheit", "delete", ["id" => $unit->id])?>" onclick="if(!confirm('Wohneinheit wirklich löschen?')) return false"><i class="fas fa-trash-alt text-danger"></i></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
@@ -124,7 +124,6 @@
|
||||
<th colspan="2" title="Anzahl ADB Wohneinheiten">Zugewiesen</th>
|
||||
<th>Exportiert</th>
|
||||
<th></th>
|
||||
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($oaids as $oaid): ?>
|
||||
@@ -162,9 +161,6 @@
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?=($oaid->exported) ? date("d.m.Y H:i", $oaid->exported) : ""?></td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<!--a href="<?=self::getUrl("OpenAccessId", "edit", ["id" => $oaid->id])?>"><i class="far fa-edit" title="OAID Bearbeiten"></i></a-->
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
|
||||
@@ -101,5 +101,48 @@ class ADBWohneinheitController extends mfBaseController {
|
||||
$this->layout()->setFlash("Wohneinheit erfolgreich gespeichert.", "success");
|
||||
$this->redirect("AddressDB", "view", ["id" => $unit->hausnummer_id]);
|
||||
}
|
||||
|
||||
protected function deleteAction() {
|
||||
$id = $this->request->id;
|
||||
if(!is_numeric($id) || $id < 1) {
|
||||
$this->layout()->setFlash("Wohneinheit nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
$unit = new ADBWohneinheit($id);
|
||||
if(!$unit->id) {
|
||||
$this->layout()->setFlash("Wohneinheit nicht gefunden", "error");
|
||||
$this->redirect("AddressDB");
|
||||
}
|
||||
|
||||
$hausnummer_id = $unit->hausnummer_id;
|
||||
|
||||
if($unit->oaid) {
|
||||
$oaid = OpenAccessIdModel::getFirstOaid($unit->oaid);
|
||||
if($oaid && $oaid->origin == "ofaa") {
|
||||
$this->layout()->setFlash("Wohneinheit kann nicht gelöscht werden, da sie eine extern generierte OAID zugeordnet hat.", "error");
|
||||
$this->redirect("AddressDB", "view", ["id" => $hausnummer_id]);
|
||||
}
|
||||
}
|
||||
|
||||
if(PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id])) {
|
||||
$this->layout()->setFlash("Wohneinheit kann nicht gelöscht werden, da sie in einer Bestellung verwendet wird.", "error");
|
||||
$this->redirect("AddressDB", "view", ["id" => $hausnummer_id]);
|
||||
}
|
||||
|
||||
// delete workorders
|
||||
foreach(RimoWorkorderModel::search(["adb_wohneinheit_id" => $unit->id]) as $wo) {
|
||||
$wo->delete();
|
||||
}
|
||||
|
||||
if(!$unit->delete()) {
|
||||
$this->layout()->setFlash("Beim Löschen der Wohneinheit ist ein Fehler aufgetreten.", "error");
|
||||
$this->redirect("AddressDB", "view", ["id" => $hausnummer_id]);
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Wohneinheit erfolgreich gelöscht.", "success");
|
||||
$this->redirect("AddressDB", "view", ["id" => $hausnummer_id]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -607,7 +607,7 @@ class Preorder extends mfBaseModel {
|
||||
$pflag_value->value = ($val) ? 1 : 0;
|
||||
//var_dump($pflag_value);
|
||||
$pflag_value->save();
|
||||
echo "saved value ".$pflag_value->value." for flag_id ".$pflag->id."\n";
|
||||
//echo "saved value ".$pflag_value->value." for flag_id ".$pflag->id."\n";
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user