Files
thetool/application/Api/v1/Modules/Operationaldata/Snopp.php
2024-09-26 17:31:07 +02:00

74 lines
2.1 KiB
PHP

<?php
namespace application\Api\v1\Modules\Operationaldata;
use application\Api\v1\Modules;
require_once(APPDIR."/Api/v1/Modules/ApiControllerModule.php");
/*
* API Endpoints for Operationaldata from SNOPP
*/
class Snopp extends Modules\ApiControllerModule
{
public function init()
{
}
public function setPreorderConnected($id) {
if(!$id || !is_numeric($id)) {
return \mfResponse::BadRequest(["message" => "id missing"]);
}
$wohneinheit = new \ADBWohneinheit($id);
if(!$wohneinheit->id) {
return \mfResponse::NotFound(["message" => "Home not found"]);
}
$preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $id]);
if(!$preorder) {
return \mfResponse::NotFound(["message" => "Home not found"]);
}
$new_status = \PreorderstatusModel::getFirst(["code" => 300]);
if(!$new_status) {
return \mfResponse::InternalServerError();
}
if($preorder->status->code < $new_status->code) {
$preorder->status_id = $new_status->id;
$preorder->save();
}
return \mfResponse::Ok(["message" => "OK"]);
}
public function setPreorderActive($id) {
if(!$id || !is_numeric($id)) {
return \mfResponse::BadRequest(["message" => "id missing"]);
}
$wohneinheit = new \ADBWohneinheit($id);
if(!$wohneinheit->id) {
return \mfResponse::NotFound(["message" => "Home not found"]);
}
$preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $id]);
if(!$preorder) {
return \mfResponse::NotFound(["message" => "Home not found"]);
}
$new_status = \PreorderstatusModel::getFirst(["code" => 500]);
if(!$new_status) {
return \mfResponse::InternalServerError();
}
if($preorder->status->code < $new_status->code) {
$preorder->status_id = $new_status->id;
$preorder->save();
}
return \mfResponse::Ok(["message" => "OK"]);
}
}