From d237fd6f4b9ded356cb90519e34d6b2ff641aecd Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 11 Jun 2025 10:59:10 +0200 Subject: [PATCH] Added admin-button to remove OAID from Wohneinheit --- Layout/default/AddressDB/View.php | 4 +++ .../ADBWohneinheitController.php | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/Layout/default/AddressDB/View.php b/Layout/default/AddressDB/View.php index f58beea92..55c9dad4f 100644 --- a/Layout/default/AddressDB/View.php +++ b/Layout/default/AddressDB/View.php @@ -177,6 +177,10 @@ oaid?> + + is("Admin")): ?> + $unit->id])?>" title="OAID von Wohneinheit entfernen" onclick="if(!confirm('OAID wirklich ungeprüft von der Wohneinheit entfernen?')) return false;"> + diff --git a/application/ADBWohneinheit/ADBWohneinheitController.php b/application/ADBWohneinheit/ADBWohneinheitController.php index 7bb1a1866..5c21eb09c 100644 --- a/application/ADBWohneinheit/ADBWohneinheitController.php +++ b/application/ADBWohneinheit/ADBWohneinheitController.php @@ -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(),