From fa404eec3ce8ca21fd3d02f4daaa22cea8c6444a Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Mon, 30 Sep 2024 16:01:23 +0200 Subject: [PATCH] snopp can also update active state for estmk networks now --- .../Api/v1/Modules/Operationaldata/Snopp.php | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/application/Api/v1/Modules/Operationaldata/Snopp.php b/application/Api/v1/Modules/Operationaldata/Snopp.php index b77bba351..ce1046d49 100644 --- a/application/Api/v1/Modules/Operationaldata/Snopp.php +++ b/application/Api/v1/Modules/Operationaldata/Snopp.php @@ -56,17 +56,25 @@ class Snopp extends Modules\ApiControllerModule return \mfResponse::Ok(["message" => "OK"]); } - public function setPreorderActive($id) { - if(!$id || !is_numeric($id)) { + public function setPreorderActive($req_id) { + if(!$req_id) { return \mfResponse::BadRequest(["message" => "id missing"]); } - $wohneinheit = new \ADBWohneinheit($id); - if(!$wohneinheit->id) { - return \mfResponse::NotFound(["message" => "Home not found"]); + $wohneinheit = false; + if(is_numeric($req_id)) { + $id = $req_id; + $wohneinheit = new \ADBWohneinheit($id); + } + if(!$wohneinheit || !$wohneinheit->id) { + $oaid = $req_id; + $wohneinheit = \ADBWohneinheitModel::getFirst(["oaid" => $oaid]); + if (!$wohneinheit) { + return \mfResponse::NotFound(["message" => "Home not found"]); + } } - $preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $id]); + $preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $wohneinheit->id]); if(!$preorder) { return \mfResponse::NotFound(["message" => "Home not found"]); }