FHM09062601IBL - getaddress: ganti join ke tabel regional, decrypt address description
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -644,101 +644,76 @@ class Registrationv3 extends MY_Controller
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query = " SELECT m_patientaddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,
|
||||
'' as action
|
||||
FROM m_patientaddress
|
||||
JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
WHERE
|
||||
M_PatientAddressIsActive = 'Y' AND M_PatientAddressM_PatientID = ?
|
||||
ORDER BY M_PatientAddressID ASC
|
||||
LIMIT 1
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$address = $this->db_onedev->query($query, array($prm['id']))->row_array();
|
||||
$address['M_PatientAddressDescription'] = stripslashes($address['M_PatientAddressDescription']);
|
||||
$query = "SELECT m_patientaddress.*,
|
||||
IFNULL(r.regional_nm, '') AS M_KelurahanName,
|
||||
IFNULL(r.full_name, '') AS M_RegionalFullName,
|
||||
IFNULL(r.pro_cd, '') AS pro_cd,
|
||||
IFNULL(r.kab_cd, '') AS kab_cd,
|
||||
IFNULL(r.kec_cd, '') AS kec_cd,
|
||||
IFNULL(pro.regional_nm, '') AS M_ProvinceName,
|
||||
IFNULL(kab.regional_nm, '') AS M_CityName,
|
||||
IFNULL(kec.regional_nm, '') AS M_DistrictName,
|
||||
'' AS action
|
||||
FROM m_patientaddress
|
||||
LEFT JOIN regional r ON M_PatientAddressRegionalCd = r.regional_cd
|
||||
LEFT JOIN regional pro ON CONCAT(r.pro_cd, REPEAT('0', 8)) = pro.regional_cd
|
||||
LEFT JOIN regional kab ON CONCAT(r.pro_cd, r.kab_cd, REPEAT('0', 6)) = kab.regional_cd
|
||||
LEFT JOIN regional kec ON CONCAT(r.pro_cd, r.kab_cd, r.kec_cd, REPEAT('0', 3)) = kec.regional_cd
|
||||
WHERE M_PatientAddressIsActive = 'Y' AND M_PatientAddressM_PatientID = ?
|
||||
ORDER BY M_PatientAddressID ASC
|
||||
LIMIT 1";
|
||||
|
||||
$address = $this->db_onedev->query($query, [$prm['id']])->row_array();
|
||||
$address['M_PatientAddressDescription'] = $this->ibl_encryptor->decrypt($address['M_PatientAddressDescription_enc'] ?? '') ?: stripslashes($address['M_PatientAddressDescription'] ?? '');
|
||||
unset($address['M_PatientAddressDescription_enc']);
|
||||
$rows['address'] = $address;
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityIsActive = 'Y' AND M_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows['city_address'] = $this->db_onedev->query($query, array($address['M_CityID']))->row_array();
|
||||
$pro_cd = $address['pro_cd'] ?? '';
|
||||
$kab_cd = $address['kab_cd'] ?? '';
|
||||
$kec_cd = $address['kec_cd'] ?? '';
|
||||
$regional_cd = $address['M_PatientAddressRegionalCd'] ?? '';
|
||||
|
||||
$rows['province_address'] = $pro_cd ? $this->db_onedev->query(
|
||||
"SELECT regional_cd AS M_ProvinceID, regional_nm AS M_ProvinceName FROM regional WHERE regional_cd = ?",
|
||||
[$pro_cd . str_repeat('0', 8)]
|
||||
)->row_array() : [];
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityIsActive = 'Y' AND M_CityM_ProvinceID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows['cities'] = $this->db_onedev->query($query, array($rows['city_address']['M_CityM_ProvinceID']))->result_array();
|
||||
$rows['provinces'] = $this->db_onedev->query(
|
||||
"SELECT regional_cd AS M_ProvinceID, regional_nm AS M_ProvinceName FROM regional WHERE RIGHT(regional_cd, 8) = '00000000' ORDER BY regional_nm"
|
||||
)->result_array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_province
|
||||
WHERE
|
||||
M_ProvinceIsActive = 'Y' AND M_ProvinceID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows['province_address'] = $this->db_onedev->query($query, array($rows['city_address']['M_CityM_ProvinceID']))->row_array();
|
||||
$rows['city_address'] = ($pro_cd && $kab_cd) ? $this->db_onedev->query(
|
||||
"SELECT regional_cd AS M_CityID, regional_nm AS M_CityName FROM regional WHERE regional_cd = ?",
|
||||
[$pro_cd . $kab_cd . str_repeat('0', 6)]
|
||||
)->row_array() : [];
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_province
|
||||
WHERE
|
||||
M_ProvinceIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['provinces'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['cities'] = $pro_cd ? $this->db_onedev->query(
|
||||
"SELECT regional_cd AS M_CityID, regional_nm AS M_CityName FROM regional WHERE pro_cd = ? AND RIGHT(regional_cd, 8) != '00000000' AND RIGHT(regional_cd, 6) = '000000' ORDER BY regional_nm",
|
||||
[$pro_cd]
|
||||
)->result_array() : [];
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows['districts'] = $this->db_onedev->query($query, array($rows['city_address']['M_CityID']))->result_array();
|
||||
$rows['district_address'] = ($pro_cd && $kab_cd && $kec_cd) ? $this->db_onedev->query(
|
||||
"SELECT regional_cd AS M_DistrictID, regional_nm AS M_DistrictName FROM regional WHERE regional_cd = ?",
|
||||
[$pro_cd . $kab_cd . $kec_cd . str_repeat('0', 3)]
|
||||
)->row_array() : [];
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows['district_address'] = $this->db_onedev->query($query, array($address['M_DistrictID']))->row_array();
|
||||
$rows['districts'] = ($pro_cd && $kab_cd) ? $this->db_onedev->query(
|
||||
"SELECT regional_cd AS M_DistrictID, regional_nm AS M_DistrictName FROM regional WHERE pro_cd = ? AND kab_cd = ? AND RIGHT(regional_cd, 6) != '000000' AND RIGHT(regional_cd, 3) = '000' ORDER BY regional_nm",
|
||||
[$pro_cd, $kab_cd]
|
||||
)->result_array() : [];
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows['kelurahans'] = $this->db_onedev->query($query, array($address['M_DistrictID']))->result_array();
|
||||
$rows['kelurahan_address'] = $regional_cd ? $this->db_onedev->query(
|
||||
"SELECT regional_cd AS M_KelurahanID, regional_nm AS M_KelurahanName FROM regional WHERE regional_cd = ?",
|
||||
[$regional_cd]
|
||||
)->row_array() : [];
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows['kelurahan_address'] = $this->db_onedev->query($query, array($address['M_PatientAddressM_KelurahanID']))->row_array();
|
||||
$rows['kelurahans'] = ($pro_cd && $kab_cd && $kec_cd) ? $this->db_onedev->query(
|
||||
"SELECT regional_cd AS M_KelurahanID, regional_nm AS M_KelurahanName FROM regional WHERE pro_cd = ? AND kab_cd = ? AND kec_cd = ? AND RIGHT(regional_cd, 3) != '000' ORDER BY regional_nm",
|
||||
[$pro_cd, $kab_cd, $kec_cd]
|
||||
)->result_array() : [];
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
$this->sys_ok(["total" => count($rows), "records" => $rows]);
|
||||
exit;
|
||||
}
|
||||
function savenewaddress()
|
||||
|
||||
Reference in New Issue
Block a user