db_smartone = $this->load->database("onedev", true); } function load() { $prm = $this->sys_input; $sql = "CALL sp_fo_register_load_mcu('{$this->sys_user['M_UserID']}');"; $query = $this->db_smartone->query($sql); if ($query) { $rst = $query->row(); if ($rst->status == "OK") { $rst->data = json_decode($rst->data); $this->sys_ok($rst->data); exit; } else { $this->sys_error("Tidak ada order"); exit; } } else { $this->sys_error_db("Tidak ada order", $this->db_smartone); exit; } } public function load_pxs() { $prm = $this->sys_input; $mouCompanyID = $prm["mouCompanyID"]; $sql_param = array($mouCompanyID); $tot_count = 0; $query = $this->db_smartone->query("CALL sp_fo_px_load_mcu(?, ?)", [$prm['order_id'], $mouCompanyID]); $this->clean_mysqli_connection($this->db_smartone->conn_id); // echo $this->db_smartone->last_query(); // $query = $this->db_smartone->query($sql); if ($query) { $rows = $query->result_array(); // var_dump($rows); foreach ($rows as $k => $v) { $rows[$k]['requirement'] = []; $id_to_remove = []; $x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$v['T_TestID']}') x") ->row(); if ($x->x != null) $rows[$k]['requirement'] = json_decode($x->x); $rows[$k]['nat_test'] = json_decode($v['nat_test']); $rows[$k]['child_test'] = json_decode($v['child_test']); // IF PROFILE if ($v['px_type'] == "PR" || $v['px_type'] == "PXR") { if ($v['T_TestID'] == null) { $id_to_remove[] = $k; continue; } else { foreach ($rows[$k]['child_test'] as $l => $w) { $rows[$k]['child_test'][$l]->requirement = []; $rows[$k]['child_test'][$l]->nat_test = json_decode($w->nat_test); $x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$w->T_TestID}') x") ->row(); if ($x->x != null) $rows[$k]['child_test'][$l]->requirement = json_decode($x->x); } } } } // REMOVE INDEXES foreach ($id_to_remove as $l => $w) { $x = $w - $l; array_splice($rows, $x, 1); } $result = array("total" => $tot_count, "records" => (array) $rows ); $this->sys_ok($result); exit; } } public function load_doctor() { $prm = $this->sys_input; $max_rst = 1; $tot_count = 0; $sql = "select M_DoctorID, M_DoctorIsDefault, IF(M_DoctorPJID IS NULL, 'Y', 'N') M_DoctorIsPJ, fn_global_doctor_name(M_DoctorID) as M_DoctorName, fn_fo_delivery_code('DOCTOR', 'EMAIL', 0) as delivery_email_code, IF(M_DoctorEmail IS NULL OR M_DoctorEmail = '', 'N', M_DoctorEmailIsDefault) email_default, IFNULL( concat('[', group_concat(JSON_OBJECT('M_DoctorAddressDescription', M_DoctorAddressDescription, 'M_DoctorAddressID', M_DoctorAddressID, 'delivery_default', M_DoctorAddressDeliveryDefault, 'delivery_code', fn_fo_delivery_code('DOCTOR', 'ADDRESS', M_DoctorAddressID)) SEPARATOR ','), ']'), '[]') as address from m_doctor left join m_doctoraddress on M_DoctorAddressIsActive = 'Y' and M_DoctorAddressM_DoctorID = M_DoctorID left join m_doctorpj on M_DoctorPJM_DoctorID = M_DoctorID and M_DoctorPjIsactive = 'Y' where M_DoctorIsActive = 'Y' AND M_DoctorIsDefaultMcu = 'Y' group by M_DoctorID limit 1"; $query = $this->db_smartone->query($sql, array($q['search'])); if ($query) { $rows = $query->result_array(); $tot_count = 1; foreach ($rows as $k => $v) $rows[$k]['address'] = json_decode($v['address']); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows)); $this->sys_ok($result); } else { $this->sys_error_db("DOCTOR MCU rows",$this->db_smartone); exit; } } }