db->query($sql); if (!$qry) { echo json_encode(["status" => "ERR", "message" => "Err " . $this->db->error()["message"]]); exit; } $rows = $qry->result_array(); if (count($rows) == 0) { echo json_encode(["status" => "ERR", "message" => "No Default Branch" ]); exit; } $branchName = $rows[0]["M_BranchName"]; $branchAddress = $rows[0]["M_BranchAddress"]; $branchCity = $rows[0]["M_CityName"]; $sql = "select FutureOrderNumber, M_TitleName, M_PatientPrefix, M_PatientName, M_PatientSuffix from future_order join m_patient on FutureOrderNumber=? and FutureOrderM_PatientID = M_PatientID join m_title on M_PatientM_TitleID = M_TitleID"; $qry = $this->db->query($sql,[$code]); if (!$qry) { echo json_encode(["status" => "ERR", "message" => "Err " . $this->db->error()["message"]]); exit; } $rows = $qry->result_array(); if (count($rows)==0){ echo json_encode(["status" => "ERR", "message" => "Kode Booking $code not found." ]); exit; } $r = $rows[0]; $patient = $r["M_TitleName"]; if ($r["M_PatientPrefix"] != "") { if ($patient!= "") $patient .= " " .$r["M_PatientPrefix"]; } if ($r["M_PatientName"] != "") { if ($patient!= "") $patient .= " " .$r["M_PatientName"]; } if ($r["M_PatientSuffix"] != "") { if ($patient!= "") $patient .= " " .$r["M_PatientSuffix"]; } echo json_encode([ "branchName"=> $branchName, "branchCity"=> $branchCity, "branchAddress"=> $branchAddress, "patient"=> $patient ]); } }