db_smartone = $this->load->database("onedev", true); } public function search_province() { $prm = $this->sys_input; $src = "%"; if ($prm['search']) $src = "%{$prm['search']}%"; $max_rst = 40; $tot_count =0; // QUERY TOTAL $sql = "select count(*) total from m_province where M_ProvinceName LIKE ? and M_ProvinceIsActive = 'Y'"; $query = $this->db_smartone->query($sql, array($src)); if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("m_province count",$this->db_smartone); exit; } $sql = "select M_ProvinceID, M_ProvinceName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default from m_province left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_provinceid = M_ProvinceID where M_ProvinceName LIKE ? and M_ProvinceIsActive = 'Y' order by M_ProvinceName limit 0, {$max_rst} "; $query = $this->db_smartone->query($sql, array($src)); if ($query) { $rows = $query->result_array(); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows)); $this->sys_ok($result); } else { $this->sys_error_db("m_province rows",$this->db_smartone); exit; } } public function search_city() { $prm = $this->sys_input; $src = "%"; if ($prm['search']) $src = "%{$prm['search']}%"; $max_rst = 40; $tot_count =0; // QUERY TOTAL $sql = "select count(*) total from m_city where M_CityName LIKE ? and M_CityIsActive = 'Y' and M_CityM_ProvinceID = ?"; $query = $this->db_smartone->query($sql, array($src, $prm['province_id'])); if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("m_city count",$this->db_smartone); exit; } $sql = "select M_CityID, M_CityName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default from m_city left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_cityid = M_CityID where M_CityName LIKE ? and M_CityIsActive = 'Y' and M_CityM_ProvinceID = ? order by M_CityName limit 0, {$max_rst} "; $query = $this->db_smartone->query($sql, array($src, $prm['province_id'])); if ($query) { $rows = $query->result_array(); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows)); $this->sys_ok($result); } else { $this->sys_error_db("m_city rows",$this->db_smartone); exit; } } public function search_district() { $prm = $this->sys_input; $src = "%"; if ($prm['search']) $src = "%{$prm['search']}%"; $max_rst = 40; $tot_count =0; // QUERY TOTAL $sql = "select count(*) total from m_district where M_DistrictName LIKE ? and M_DistrictIsActive = 'Y' and M_DistrictM_CityID = ?"; $query = $this->db_smartone->query($sql, array($src, $prm['city_id'])); if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("m_district count",$this->db_smartone); exit; } $sql = "select M_DistrictID, M_DistrictName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default from m_district left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_districtid = M_DistrictID where M_DistrictName LIKE ? and M_DistrictIsActive = 'Y' and M_DistrictM_CityID = ? order by M_DistrictName -- limit 0, {$max_rst} "; $query = $this->db_smartone->query($sql, array($src, $prm['city_id'])); if ($query) { $rows = $query->result_array(); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows)); $this->sys_ok($result); } else { $this->sys_error_db("m_district rows",$this->db_smartone); exit; } } public function search_kelurahan() { $prm = $this->sys_input; $src = "%"; if ($prm['search']) $src = "%{$prm['search']}%"; $max_rst = 40; $tot_count =0; // QUERY TOTAL $sql = "select count(*) total from m_kelurahan where M_KelurahanName LIKE ? and M_KelurahanIsActive = 'Y' and M_KelurahanM_DistrictID = ?"; $query = $this->db_smartone->query($sql, array($src, $prm['district_id'])); if ($query) { $tot_count = $query->result_array()[0]["total"]; } else { $this->sys_error_db("m_kelurahan count",$this->db_smartone); exit; } $sql = "select M_KelurahanID, M_KelurahanName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default from m_kelurahan left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_kelurahanid = M_KelurahanID where M_KelurahanName LIKE ? and M_KelurahanIsActive = 'Y' and M_KelurahanM_DistrictID = ? order by M_KelurahanName limit 0, {$max_rst} "; $query = $this->db_smartone->query($sql, array($src, $prm['district_id'])); if ($query) { $rows = $query->result_array(); $result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows)); $this->sys_ok($result); } else { $this->sys_error_db("m_kelurahan rows",$this->db_smartone); exit; } } }