Updated preorder api
This commit is contained in:
@@ -168,7 +168,10 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "rimo_workorder") {
|
||||
$this->rimo_workorder = RimoWorkorderModel::getFirst(['adb_wohneinheit_id' => $this->id]);
|
||||
$this->rimo_workorder = new RimoWorkorder();
|
||||
if($this->id) {
|
||||
$this->rimo_workorder = RimoWorkorderModel::getFirst(['adb_wohneinheit_id' => $this->id]);
|
||||
}
|
||||
return $this->rimo_workorder;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class ADBWohneinheitModel {
|
||||
ORDER BY hausnummer_id,block,stiege,LENGTH(stock),stock,LENGTH(tuer),tuer,num
|
||||
LIMIT 1";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
@@ -96,7 +96,7 @@ class ADBWohneinheitModel {
|
||||
) as tbl
|
||||
";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
//mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
|
||||
@@ -82,7 +82,7 @@ class OpenAccessIdModel {
|
||||
if(!$oaid) return null;
|
||||
|
||||
$where = self::getSqlFilter(["oaid" => $oaid]);
|
||||
mfLoghandler::singleton()->debug($where);
|
||||
//mfLoghandler::singleton()->debug($where);
|
||||
$res = $db->select("OpenAccessId", "*", "$where ORDER BY id");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
|
||||
@@ -359,7 +359,11 @@ class Preorder extends mfBaseModel {
|
||||
$a['cifurl'] = $this->cifurl;
|
||||
$a['oaid'] = $this->oaid;
|
||||
$a['extref'] = $this->extref;
|
||||
$a['orderDate'] = ($this->order_date) ? date("Y-m-d",$this->order_date) : null;
|
||||
$a['status'] = $this->getProperty("status")->getApiArray();
|
||||
$a['ciftoken'] = ($this->ciftoken) ? $this->ciftoken : null;
|
||||
$a['cifurl'] = ($this->cifurl) ? $this->cifurl : null;
|
||||
$a['installationDate'] = ($this->installation_date) ? date("c", $this->installation_date) : null;
|
||||
$a['connectionType'] = $this->connection_type;
|
||||
$a['connectionCount'] = ($this->connection_count) ? (int)$this->connection_count : 1;
|
||||
$a['isAdditionalOrder'] = ($this->is_additional_order) ? true : false;
|
||||
|
||||
@@ -797,6 +797,9 @@ class PreorderController extends mfBaseController {
|
||||
case "updateStatus":
|
||||
$return = $this->updateStatusApi();
|
||||
break;
|
||||
case "deleteWorkorder":
|
||||
$return = $this->deleteWorkorderApi();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
@@ -997,4 +1000,33 @@ class PreorderController extends mfBaseController {
|
||||
return ["message" => "Status saved successfully", "id" => $preorder_id, "update" => $update];
|
||||
}
|
||||
|
||||
private function deleteWorkorderApi() {
|
||||
if(!$this->me->is("Admin")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$preorder_id = $this->request->id;
|
||||
|
||||
if(!is_numeric($preorder_id) || $preorder_id < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$preorder = new Preorder($preorder_id);
|
||||
if(!$preorder->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$preorder->adb_wohneinheit_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$workorder = RimoWorkorderModel::getFirst(["adb_wohneinheit_id" => $preorder->adb_wohneinheit_id]);
|
||||
if(!$workorder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$workorder->delete();
|
||||
return ["Message" => "Workorder deleted successfully", "id" => $preorder->id];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class RimoWorkorderModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
mfLoghandler::singleton()->debug($where);
|
||||
//mfLoghandler::singleton()->debug($where);
|
||||
$res = $db->select("RimoWorkorder", "*", "$where ORDER BY `create`");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
|
||||
Reference in New Issue
Block a user