db_onedev = $this->load->database("onedev", true); } public function search() { $prm = $this->sys_input; if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $nolab = $prm["nolab"]; $nama = $prm["name"]; //$startdate = $prm["startdate"]; //$enddate = $prm["enddate"]; $groupid = 3; $subgroupid = $prm["subgroupid"]; $join_group = ''; if($groupid != 0){ $join_group = "JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID AND Nat_GroupID = {$groupid}"; } $join_subgroup = ''; if($subgroupid != 0){ $join_group = "JOIN nat_subgroup ON T_TestNat_SubgroupID = Nat_SubgroupID AND Nat_SubgroupID = {$subgroupid}"; } if(!isset($prm['current_page'])) $prm['current_page'] = 1; $sql_where = "WHERE Result_FrontOfficeStatus = 'P' "; $number_limit = 10; $number_offset = ($prm['current_page'] - 1) * $number_limit ; //$sql_param = array(); if ($nolab != "" ) { if ($sql_where != "") { $sql_where .=" and "; } $sql_where .= " T_OrderHeaderLabNumber like '%$nolab%' "; } if ($nama != "") { if ($sql_where != "") { $sql_where .=" and "; } $sql_where .= " M_PatientName like '%$nama%' "; } $sql = "SELECT Result_FrontOfficeID as xid, T_OrderHeaderID as orderid, T_OrderHeaderLabNumber as ordernumber, UPPER(CONCAT(M_TitleName,' ',M_PatientName)) as patient_fullname, Result_FrontOfficeTestName as test_name, 'N' as chex FROM result_frontoffice join t_orderheader ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID JOIN m_sex ON M_PatientM_SexID = M_SexID LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID $sql_where "; // echo $sql; $query = $this->db_onedev->query($sql); $rows = $query->result_array(); foreach($rows as $k => $v){ if($v['chex'] == 'N') $rows[$k]['chex'] = false; else $rows[$k]['chex'] = true; } $result = array("total" => count($rst), "records" => $rows, "sql"=> ''); $this->sys_ok($result); exit; } function dosend(){ if (! $this->isLogin) { $this->sys_error("Invalid Token"); exit; } $prm = $this->sys_input; $userid = $this->sys_user['M_UserID']; $selected = $prm['selected']; foreach($selected as $k => $v){ $sql = "UPDATE result_frontoffice SET Result_FrontOfficeStatus = 'S' WHERE Result_FrontOfficeID = {$v['xid']}"; $this->db_onedev->query($sql); } $result = array( "total" => 1 , "records" => array('status'=>'OK'), ); $this->sys_ok($result); exit; } }