Added admin-button to remove OAID from Wohneinheit

This commit is contained in:
Frank Schubert
2025-06-11 10:59:10 +02:00
parent a6971cded6
commit d237fd6f4b
2 changed files with 30 additions and 0 deletions

View File

@@ -177,6 +177,10 @@
<?php else: ?>
<?=$unit->oaid?>
<?php endif; ?>
<?php if($me->is("Admin")): ?>
<a class="text-danger ml-2" href="<?=self::getUrl("ADBWohneinheit", "removeOaid", ["id" => $unit->id])?>" title="OAID von Wohneinheit entfernen" onclick="if(!confirm('OAID wirklich ungeprüft von der Wohneinheit entfernen?')) return false;"><i class="fas fa-trash-can"></i></a>
<?php endif; ?>
<?php endif; ?>
</td>
<td id="unit-<?=$unit->id?>-status" class="text-monospace">

View File

@@ -159,6 +159,32 @@ class ADBWohneinheitController extends mfBaseController {
}
protected function removeOaid() {
$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");
}
if(!$unit->oaid) {
$this->layout()->setFlash("Wohneinheit hat keine OAID.", "error");
$this->redirect("AddressDB", "view", ["id" => $unit->hausnummer_id]);
}
$unit->oaid = null;
$unit->save();
$this->layout()->setFlash("OAID erfolgreich entfernt.", "success");
$this->redirect("AddressDB", "view", ["id" => $unit->hausnummer_id]);
}
protected function duplicateAction() {
$duplicateHomes = array_merge(ADBWohneinheitModel::searchDuplicateExtref(),
ADBWohneinheitModel::searchDuplicateOAID(),