Added Preorder network Operators/ISPs & snopp api
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?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"]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user