Added saving Remarks to workorder and to rimo in Preorder
This commit is contained in:
@@ -1058,6 +1058,9 @@ class PreorderController extends mfBaseController {
|
||||
case "setStatusFlag":
|
||||
$return = $this->setStatusFlagApi();
|
||||
break;
|
||||
case "addWorkorderRemark":
|
||||
$return = $this->addWorkorderRemarkApi();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
@@ -1071,6 +1074,40 @@ class PreorderController extends mfBaseController {
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
private function addWorkorderRemarkApi() {
|
||||
$preorder_id = $this->request->preorder_id;
|
||||
$workorder_id = $this->request->workorder_id;
|
||||
$new_remark = $this->request->remark;
|
||||
|
||||
$preorder = new Preorder($preorder_id);
|
||||
if(!$preorder->id) {
|
||||
$this->log->debug(__METHOD__.": preorder ($preorder_id) not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
$workorder = new RimoWorkorder($workorder_id);
|
||||
if(!$workorder->id) {
|
||||
$this->log->debug(__METHOD__.": workorder ($workorder_id) not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
// upload remark to Rimo
|
||||
if(!Rimoapi::addRemark($workorder->rimo_id, $new_remark)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$remarks = $workorder->remarks;
|
||||
if($remarks) {
|
||||
$remarks .= "\n";
|
||||
}
|
||||
$remarks .= date("d.m.Y").": ".$new_remark;
|
||||
|
||||
$workorder->remarks = $remarks;
|
||||
$workorder->save();
|
||||
|
||||
return ["message" => "Remark added successfully", "preorder_id" => $preorder_id, "workorder_id" => $workorder_id, "remark" => $workorder->remarks];
|
||||
}
|
||||
|
||||
private function setStatusFlagApi() {
|
||||
$preorder_id = $this->request->preorder_id;
|
||||
$flag_id = $this->request->flag_id;
|
||||
|
||||
Reference in New Issue
Block a user