snopp can also update active state for estmk networks now

This commit is contained in:
Frank Schubert
2024-09-30 16:01:23 +02:00
parent f52aa5825c
commit fa404eec3c

View File

@@ -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"]);
}