db_smartone = $this->load->database("onedev", true); } function save() { $prm = $this->sys_input; $hdr = $prm['header']; $header_json = addslashes(str_replace('\n', '\\\n', json_encode($hdr))); $detail_json = str_replace('\n', '\\\n', json_encode($prm['detail'])); $delivery_json = addslashes(str_replace('\n', '\\\n', json_encode($prm['delivery']))); $req_json = json_encode($prm['req']); $sql = "CALL sp_fo_register_save('{$prm['order_id']}', '{$header_json}', '{$delivery_json}', '{$detail_json}', '{$req_json}', '{$this->sys_user['M_UserID']}');"; $query = $this->db_smartone->query($sql); if ($query) { $rst = $query->row(); $rst->data = json_decode($rst->data); $x = preg_match("/janji hasi/", $rst->message); if ($x) $rst->message = "Masih ada pemeriksaan yang BELUM DISET JANJI HASILNYA !"; $rst->message = ["text"=>$rst->message, "query"=>$this->db_smartone->last_query()]; // pe : add broadcast notification $this->broadcast("fo-register"); echo json_encode($rst); } else { $this->sys_error_db("save order", $this->db_smartone); exit; } } function load_from_clinic() { $prm = $this->sys_input; $sql = "CALL sp_fo_clinic_load('{$prm['queue']}');"; $query = $this->db_smartone->query($sql); if ($query) { $rst = $query->row(); if ($rst->status == "OK") { $rst->data = json_decode($rst->data); $rst->data->doctor->address = $rst->data->doctor_address; unset($rst->data->doctor_address); $rst->data->company->mou = [$rst->data->mou]; unset($rst->data->mou); } else { $this->sys_error("Tidak ada order"); exit; } echo json_encode($rst); } else { $this->sys_error_db("save order", $this->db_smartone); exit; } } function load() { $prm = $this->sys_input; $sql = "CALL sp_fo_register_load('{$prm['id']}');"; $query = $this->db_smartone->query($sql); if ($query) { $rst = $query->row(); if ($rst->status == "OK") { $rst->data = json_decode($rst->data); $rst->data->doctor->address = $rst->data->doctor_address; unset($rst->data->doctor_address); $rst->data->company->mou = [$rst->data->mou]; unset($rst->data->mou); } else { $this->sys_error("Tidak ada order"); exit; } echo json_encode($rst); } else { $this->sys_error_db("save order", $this->db_smartone); exit; } } }