189 lines
6.8 KiB
PHP
189 lines
6.8 KiB
PHP
<?php
|
|
class Registrationmember extends MY_Controller
|
|
{
|
|
|
|
var $load;
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
|
// print_r($cek);
|
|
echo "Registration Member";
|
|
}
|
|
|
|
function search_z()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$search = str_replace("'", "\\'", $prm["search"]);
|
|
|
|
$sql_where = "WHERE M_PatientIsActive = 'Y' ";
|
|
$sql_param = array();
|
|
if ($search != "") {
|
|
if ($sql_where != "") {
|
|
$sql_where .= " AND ";
|
|
}
|
|
$sql_where .= " (M_PatientName LIKE '%{$search}%' OR M_PatientNoReg LIKE '%{$search}%' OR M_PatientIDNumber LIKE '%{$search}%')";
|
|
// $sql_param[] = "%$nama%";
|
|
}
|
|
|
|
$sql = "SELECT
|
|
M_PatientID,
|
|
M_PatientNoReg,
|
|
M_PatientPrefix,
|
|
M_PatientName,
|
|
M_PatientSuffix,
|
|
M_PatientHP,
|
|
M_PatientEmail,
|
|
M_PatientPOB,
|
|
M_PatientPhone,
|
|
M_PatientIDNumber,
|
|
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
|
M_PatientNote,
|
|
M_PatientNIK,
|
|
M_PatientJabatan,
|
|
M_PatientKedudukan,
|
|
M_PatientPJ,
|
|
M_PatientLocation,
|
|
M_PatientJob,
|
|
M_PatientM_SexID,
|
|
M_SexName,
|
|
M_PatientM_TitleID,
|
|
M_TitleName,
|
|
M_PatientM_ReligionID,
|
|
M_ReligionName
|
|
FROM m_patient
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
LEFT JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
LEFT JOIN m_religion ON M_PatientM_ReligionID = M_ReligionID
|
|
JOIN m_patient_nat_verif ON M_PatientID = M_PatientNatVerifM_PatientID
|
|
AND M_PatientNatVerifIsActive = 'Y'
|
|
$sql_where
|
|
ORDER BY M_PatientName ASC
|
|
limit 100";
|
|
|
|
$query = $this->db_onedev->query($sql, $sql_param);
|
|
// echo $this->db_onedev->last_query();
|
|
// exit;
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
} else {
|
|
$this->sys_error_db("select patient error", $this->db_onedev);
|
|
exit;
|
|
}
|
|
|
|
$result = array("total" => 1, "records" => $rows, "sql" => $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
exit;
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function search()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
$prm = $this->sys_input;
|
|
$userid = $this->sys_user['M_UserID'];
|
|
|
|
$number_limit = 10;
|
|
$number_offset = (!isset($prm['current_page']) ? 1 : $prm['current_page'] - 1) * $number_limit;
|
|
|
|
$q = [
|
|
'name' => '',
|
|
'noreg' => '',
|
|
'nik' => ''
|
|
];
|
|
|
|
if ($prm['search'] != '') {
|
|
$e = explode('+', $prm['search']);
|
|
if (isset($e[0])) {
|
|
$e[0] = str_replace("'", "\\'", $e[0]);
|
|
$q['name'] = "AND (M_PatientName LIKE '%{$e[0]}%')";
|
|
}
|
|
if (isset($e[1]))
|
|
$q['noreg'] = "AND M_PatientNoReg = '{$e[1]}'";
|
|
if (isset($e[2]))
|
|
$q['nik'] = "AND M_PatientIDNumber = '{$e[2]}'";
|
|
}
|
|
|
|
if ($prm['search'] != '') {
|
|
|
|
$sql = "SELECT
|
|
'N' divider,
|
|
M_PatientID,
|
|
M_PatientNoReg,
|
|
M_PatientPrefix,
|
|
M_PatientName,
|
|
M_PatientSuffix,
|
|
M_PatientHP,
|
|
M_PatientEmail,
|
|
M_PatientPOB,
|
|
M_PatientPhone,
|
|
M_PatientIDNumber,
|
|
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
|
M_PatientNote,
|
|
M_PatientNIK,
|
|
M_PatientJabatan,
|
|
M_PatientKedudukan,
|
|
M_PatientPJ,
|
|
M_PatientLocation,
|
|
M_PatientJob,
|
|
M_PatientM_SexID,
|
|
M_SexName,
|
|
M_PatientM_TitleID,
|
|
M_TitleName,
|
|
M_PatientM_ReligionID,
|
|
M_ReligionName
|
|
FROM m_patient
|
|
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
|
LEFT JOIN m_sex ON M_PatientM_SexID = M_SexID
|
|
LEFT JOIN m_religion ON M_PatientM_ReligionID = M_ReligionID
|
|
JOIN m_patient_nat_verif ON M_PatientID = M_PatientNatVerifM_PatientID
|
|
AND M_PatientNatVerifIsActive = 'Y'
|
|
WHERE M_PatientIsActive = 'Y'
|
|
{$q['name']}
|
|
{$q['noreg']}
|
|
{$q['nik']}
|
|
LIMIT $number_limit offset $number_offset";
|
|
|
|
$query = $this->db_onedev->query($sql);
|
|
// echo $this->db_onedev->last_query();
|
|
// exit;
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
|
|
|
|
$result = array("total" => sizeof($rows), "records" => $rows, "sql" => $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
} else {
|
|
$this->sys_error_db("select patient error", $this->db_onedev);
|
|
exit;
|
|
}
|
|
} else {
|
|
$result = array("total" => 0, "records" => [], "sql" => $this->db_onedev->last_query());
|
|
$this->sys_ok($result);
|
|
}
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
}
|