Initial import
This commit is contained in:
31
application/controllers/cpone/Patient.http
Normal file
31
application/controllers/cpone/Patient.http
Normal file
@@ -0,0 +1,31 @@
|
||||
POST https://{{host}}/cpone/patient/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/patient/generate_adm_patient
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"date": "2023-07-11",
|
||||
"corporateID": 46
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/patient/insert_patient
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"patientoldID": "0001170402882"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/patient/patientloop
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
377
application/controllers/cpone/Patient.php
Normal file
377
application/controllers/cpone/Patient.php
Normal file
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("cpone", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "PATIENT GENERATE ADM API";
|
||||
}
|
||||
|
||||
public function generate_adm_patient()
|
||||
{
|
||||
try {
|
||||
// $this->db->trans_begin();
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//$date = $prm['date'];
|
||||
|
||||
$sql = "SELECT
|
||||
REG_DATE,
|
||||
REG_NO,
|
||||
PATIENT_ID,
|
||||
PATIENT_NAME,
|
||||
SEX_ID,
|
||||
DOB,
|
||||
AGE,
|
||||
NPK,
|
||||
JOB_TITLE,
|
||||
DEPT,
|
||||
DIVISION,
|
||||
LOCATION,
|
||||
AGREEMENT_NAME,
|
||||
OTHER_ID
|
||||
FROM x_adm_rekap_patient
|
||||
WHERE STAGE = '20'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select adm rekap patient error", $this->db);
|
||||
}
|
||||
|
||||
// print_r($rows);
|
||||
// exit;
|
||||
$count_m_patient = 1;
|
||||
$insert_query = [];
|
||||
foreach ($rows as $key => $value) {
|
||||
|
||||
// print_r($value['PATIENT_ID']);
|
||||
// exit;
|
||||
$timestamp = strtotime($value['DOB']);
|
||||
$pdob = date('Y-m-d', $timestamp);
|
||||
$p_name = addslashes($value['PATIENT_NAME']);
|
||||
$sql_check = "SELECT
|
||||
M_PatientID,
|
||||
M_PatientOldPID,
|
||||
M_PatientName
|
||||
FROM m_patient
|
||||
WHERE M_PatientIsActive = 'Y'
|
||||
AND
|
||||
(
|
||||
( M_PatientName = '{$p_name}' AND M_PatientDOB = '{$pdob}' AND '{$value['OTHER_ID']}' = '') OR
|
||||
('{$value['NPK']}' <> '' AND M_PatientNIP = '{$value['NPK']}' AND M_PatientDOB = M_PatientDOB = '{$pdob}' ) OR
|
||||
('{$value['OTHER_ID']}' <> '' AND M_PatientDOB = '{$pdob}' AND trim(M_PatientIdentifierValue) = '{$value['OTHER_ID']}')
|
||||
) ";
|
||||
$qry_check = $this->db->query($sql_check);
|
||||
|
||||
|
||||
if ($qry_check) {
|
||||
$rows_check = $qry_check->result_array();
|
||||
} else {
|
||||
/* $this->db->trans_rollback();
|
||||
$this->sys_error_db("select check patient error", $this->db);
|
||||
exit;*/
|
||||
}
|
||||
|
||||
// print_r(count($rows_check));
|
||||
// exit;
|
||||
|
||||
$title_id = 0;
|
||||
$gender = "";
|
||||
if (TRIM($value['SEX_ID']) == 'M') {
|
||||
$title_id = 1;
|
||||
$gender = "male";
|
||||
} else {
|
||||
$title_id = 3;
|
||||
$gender = "female";
|
||||
}
|
||||
|
||||
if (count($rows_check) == 0) {
|
||||
// print_r("insert");
|
||||
// exit;
|
||||
$p_name = addslashes($value['PATIENT_NAME']);
|
||||
$sql_insert = "INSERT INTO m_patient(
|
||||
M_PatientRegisteredByCorporateID,
|
||||
M_PatientOldPID,
|
||||
M_PatientNoReg,
|
||||
M_PatientM_TitleID,
|
||||
M_PatientName,
|
||||
M_PatientGender,
|
||||
M_PatientDOB,
|
||||
M_PatientNIP,
|
||||
M_PatientJob,
|
||||
M_PatientDivisi,
|
||||
M_PatientLocation,
|
||||
M_PatientDepartement,
|
||||
M_PatientCreated,
|
||||
M_PatientLastUpdated
|
||||
) VALUES(
|
||||
50,
|
||||
'{$value['PATIENT_ID']}',
|
||||
`fn_numbering_cpone`('P'),
|
||||
{$title_id},
|
||||
'{$p_name}',
|
||||
'{$gender}',
|
||||
'{$pdob}',
|
||||
'{$value['NPK']}',
|
||||
'{$value['JOB_TITLE']}',
|
||||
'{$value['DIVISION']}',
|
||||
'{$value['LOCATION']}',
|
||||
'{$value['DEPT']}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
$qry_insert = $this->db->query($sql_insert);
|
||||
$insert_query [] = $this->db->last_query();
|
||||
|
||||
/*if (!$qry_insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("insert m_patient error", $this->db);
|
||||
exit;
|
||||
}*/
|
||||
$count_m_patient = $count_m_patient +1;
|
||||
} else {
|
||||
$sql_select = "SELECT X_PatientM_PatientID,
|
||||
X_PatientM_PatientOldPID
|
||||
FROM x_patient
|
||||
WHERE X_PatientM_PatientID = {$rows_check[0]['M_PatientID']}";
|
||||
$qry_select = $this->db->query($sql_select);
|
||||
if ($qry_select) {
|
||||
$rows = $qry_select->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select x_patient", $this->db);
|
||||
}
|
||||
|
||||
|
||||
if (count($rows) == 0) {
|
||||
$sql = "UPDATE m_patient SET M_PatientOldPID = '{$value['PATIENT_ID']}'
|
||||
WHERE M_PatientID = {$rows_check[0]['M_PatientID']} ";
|
||||
$this->db->query($sql);
|
||||
if ($rows_check[0]['M_PatientOldPID'] == "") {
|
||||
$sql = "INSERT INTO x_patient(
|
||||
X_PatientM_PatientID,
|
||||
X_PatientM_PatientOldPID,
|
||||
X_PatientCreated) VALUES(
|
||||
'{$rows_check[0]['M_PatientID']}',
|
||||
'{$value['PATIENT_ID']}',
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db->query($sql);
|
||||
/*if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("insert m_patient error", $this->db);
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$this->db->trans_commit();
|
||||
$result = array(
|
||||
"message" => "Pasien berhasil ditambahkan sebanyak ".$count_m_patient,
|
||||
"affected_rows" => $this->db->affected_rows(),
|
||||
"sql_insert"=> JOIN(";",$insert_query)
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
/* function patientloop()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$patientoldID = $prm['patientoldID'];
|
||||
$sql = "select *
|
||||
from x_adm_rekap_patient";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$this->insert_patient($value['PATIENT_ID']);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"message" => "Selesai"
|
||||
]);
|
||||
} */
|
||||
|
||||
public function insert_patient()
|
||||
{
|
||||
try {
|
||||
|
||||
//$this->db->trans_begin();
|
||||
|
||||
$sql_adm = "SELECT REG_DATE,
|
||||
REG_NO,
|
||||
PATIENT_ID,
|
||||
PATIENT_NAME,
|
||||
AGE,
|
||||
top_patient.M_PatientID as m_patient_id
|
||||
FROM x_adm_rekap_patient
|
||||
JOIN m_patient as top_patient ON PATIENT_ID = top_patient.M_PatientOldPID
|
||||
WHERE
|
||||
STAGE = '20'";
|
||||
$qry_adm = $this->db->query($sql_adm);
|
||||
//echo $this->db->last_query();
|
||||
if (!$qry_adm) {
|
||||
//$this->db->trans_rollback();
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db('select x_adm_rekap_patient error', $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry_adm->result_array();
|
||||
//print_r($rows);
|
||||
// exit;
|
||||
$count_order = 1;
|
||||
foreach ($rows as $key => $row_adm) {
|
||||
$sql_check_order = "SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderOldLabNumber,
|
||||
T_OrderHeaderM_PatientID
|
||||
FROM x_t_orderheader
|
||||
WHERE T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderOldLabNumber = ?";
|
||||
$qry_check_order = $this->db->query($sql_check_order, array(
|
||||
$row_adm['REG_NO']
|
||||
));
|
||||
// echo $this->db->last_query();
|
||||
if ($qry_check_order) {
|
||||
$rows_check_order = $qry_check_order->result_array();
|
||||
} else {
|
||||
//$this->db->trans_rollback();
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("select check t_orderheader", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$reg_date = $row_adm['REG_DATE'];
|
||||
$full_date = $reg_date . ' 12:00:00';
|
||||
|
||||
if (count($rows_check_order) == 0) {
|
||||
// print_r('belum ada');
|
||||
// exit;
|
||||
|
||||
$sql_insert_order = "INSERT INTO x_t_orderheader(
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderOldLabNumber,
|
||||
T_OrderHeaderM_PatientID,
|
||||
T_OrderHeaderCorporateID,
|
||||
T_OrderHeaderMgm_McuID,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
T_OrderHeaderCreated,
|
||||
T_OrderHeaderLastUpdated) VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now())";
|
||||
$qry_insert_order = $this->db->query($sql_insert_order, array(
|
||||
$full_date,
|
||||
$row_adm['REG_NO'],
|
||||
$row_adm['REG_NO'],
|
||||
$row_adm['m_patient_id'],
|
||||
77,
|
||||
0,
|
||||
$row_adm['AGE']
|
||||
));
|
||||
//echo $this->db->last_query();
|
||||
if (!$qry_insert_order) {
|
||||
//$this->db->trans_rollback();
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("insert t_orderheader error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$count_order = $count_order + 1;
|
||||
$insertid = $this->db->insert_id();
|
||||
|
||||
$sql_select_testid = "SELECT
|
||||
name,
|
||||
name_v,
|
||||
test_id
|
||||
FROM x_map_lab";
|
||||
$qry_select_testid = $this->db->query($sql_select_testid);
|
||||
//echo $this->db->last_query();
|
||||
if ($qry_select_testid) {
|
||||
$rows_test = $qry_select_testid->result_array();
|
||||
} else {
|
||||
//$this->db->trans_rollback;
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("select x_map_lab", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// print_r($rows_test);
|
||||
// exit;
|
||||
foreach ($rows_test as $key => $value) {
|
||||
// print_r($value);
|
||||
// exit;
|
||||
$sql_insert_detail = "insert into x_t_orderdetail (
|
||||
T_OrderDetailT_OrderHeaderID,
|
||||
T_OrderDetailT_TestID,
|
||||
T_OrderDetailT_TestCode,
|
||||
T_OrderDetailT_TestSasCode,
|
||||
T_OrderDetailT_TestName,
|
||||
T_OrderDetailT_TestIsResult,
|
||||
T_OrderDetailT_TestIsPrice )
|
||||
SELECT
|
||||
?,
|
||||
T_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice
|
||||
FROM t_test
|
||||
WHERE T_TestID in (?)";
|
||||
$qry_insert_detail = $this->db->query($sql_insert_detail, array(
|
||||
$insertid,
|
||||
$value['test_id']
|
||||
));
|
||||
//echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry_insert_detail) {
|
||||
// $this->db->trans_rollback();
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db('insert t_orderdetail error', $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$this->db->trans_commit();
|
||||
$result = array(
|
||||
"message" => "Berhasil",
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
368
application/controllers/cpone/Patient.php-minusnpk
Normal file
368
application/controllers/cpone/Patient.php-minusnpk
Normal file
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("cpone", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "PATIENT GENERATE ADM API";
|
||||
}
|
||||
|
||||
public function generate_adm_patient()
|
||||
{
|
||||
try {
|
||||
// $this->db->trans_begin();
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
//$date = $prm['date'];
|
||||
|
||||
$sql = "SELECT
|
||||
REG_DATE,
|
||||
REG_NO,
|
||||
PATIENT_ID,
|
||||
PATIENT_NAME,
|
||||
SEX_ID,
|
||||
DOB,
|
||||
AGE,
|
||||
NPK,
|
||||
JOB_TITLE,
|
||||
DEPT,
|
||||
DIVISION,
|
||||
LOCATION,
|
||||
AGREEMENT_NAME
|
||||
FROM x_adm_rekap_patient
|
||||
WHERE STAGE = '3'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select adm rekap patient error", $this->db);
|
||||
}
|
||||
|
||||
// print_r($rows);
|
||||
// exit;
|
||||
$count_m_patient = 1;
|
||||
foreach ($rows as $key => $value) {
|
||||
|
||||
// print_r($value['PATIENT_ID']);
|
||||
// exit;
|
||||
$timestamp = strtotime($value['DOB']);
|
||||
$pdob = date('Y-m-d', $timestamp);
|
||||
$p_name = addslashes($value['PATIENT_NAME']);
|
||||
$sql_check = "SELECT
|
||||
M_PatientID,
|
||||
M_PatientOldPID,
|
||||
M_PatientName
|
||||
FROM m_patient
|
||||
WHERE M_PatientIsActive = 'Y'
|
||||
AND M_PatientName = '{$p_name}'
|
||||
AND M_PatientDOB = '{$pdob}'
|
||||
AND M_PatientNIP = '{$value['NPK']}'";
|
||||
$qry_check = $this->db->query($sql_check);
|
||||
|
||||
if ($qry_check) {
|
||||
$rows_check = $qry_check->result_array();
|
||||
} else {
|
||||
/* $this->db->trans_rollback();
|
||||
$this->sys_error_db("select check patient error", $this->db);
|
||||
exit;*/
|
||||
}
|
||||
|
||||
// print_r(count($rows_check));
|
||||
// exit;
|
||||
|
||||
$title_id = 0;
|
||||
$gender = "";
|
||||
if (TRIM($value['SEX_ID']) == 'M') {
|
||||
$title_id = 1;
|
||||
$gender = "male";
|
||||
} else {
|
||||
$title_id = 3;
|
||||
$gender = "female";
|
||||
}
|
||||
|
||||
if (count($rows_check) == 0) {
|
||||
// print_r("insert");
|
||||
// exit;
|
||||
$p_name = addslashes($value['PATIENT_NAME']);
|
||||
$sql_insert = "INSERT INTO m_patient(
|
||||
M_PatientRegisteredByCorporateID,
|
||||
M_PatientOldPID,
|
||||
M_PatientNoReg,
|
||||
M_PatientM_TitleID,
|
||||
M_PatientName,
|
||||
M_PatientGender,
|
||||
M_PatientDOB,
|
||||
M_PatientNIP,
|
||||
M_PatientJob,
|
||||
M_PatientDivisi,
|
||||
M_PatientLocation,
|
||||
M_PatientDepartement,
|
||||
M_PatientCreated,
|
||||
M_PatientLastUpdated
|
||||
) VALUES(
|
||||
50,
|
||||
'{$value['PATIENT_ID']}',
|
||||
`fn_numbering_cpone`('P'),
|
||||
{$title_id},
|
||||
'{$p_name}',
|
||||
'{$gender}',
|
||||
'{$pdob}',
|
||||
'{$value['NPK']}',
|
||||
'{$value['JOB_TITLE']}',
|
||||
'{$value['DIVISION']}',
|
||||
'{$value['LOCATION']}',
|
||||
'{$value['DEPT']}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
$qry_insert = $this->db->query($sql_insert);
|
||||
//echo $this->db->last_query();
|
||||
/*if (!$qry_insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("insert m_patient error", $this->db);
|
||||
exit;
|
||||
}*/
|
||||
$count_m_patient = $count_m_patient +1;
|
||||
} else {
|
||||
$sql_select = "SELECT X_PatientM_PatientID,
|
||||
X_PatientM_PatientOldPID
|
||||
FROM x_patient
|
||||
WHERE X_PatientM_PatientID = {$rows_check[0]['M_PatientID']}";
|
||||
$qry_select = $this->db->query($sql_select);
|
||||
if ($qry_select) {
|
||||
$rows = $qry_select->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select x_patient", $this->db);
|
||||
}
|
||||
|
||||
|
||||
if (count($rows) == 0) {
|
||||
$sql = "UPDATE m_patient SET M_PatientOldPID = '{$value['PATIENT_ID']}'
|
||||
WHERE M_PatientID = {$rows_check[0]['M_PatientID']} ";
|
||||
$this->db->query($sql);
|
||||
if ($rows_check[0]['M_PatientOldPID'] == "") {
|
||||
$sql = "INSERT INTO x_patient(
|
||||
X_PatientM_PatientID,
|
||||
X_PatientM_PatientOldPID,
|
||||
X_PatientCreated) VALUES(
|
||||
'{$rows_check[0]['M_PatientID']}',
|
||||
'{$value['PATIENT_ID']}',
|
||||
NOW()
|
||||
)";
|
||||
$qry = $this->db->query($sql);
|
||||
/*if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("insert m_patient error", $this->db);
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$this->db->trans_commit();
|
||||
$result = array(
|
||||
"message" => "Pasien berhasil ditambahkan sebanyak ".$count_m_patient,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function patientloop()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$patientoldID = $prm['patientoldID'];
|
||||
$sql = "select *
|
||||
from x_adm_rekap_patient";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$this->insert_patient($value['PATIENT_ID']);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
"message" => "Selesai"
|
||||
]);
|
||||
}
|
||||
|
||||
public function insert_patient()
|
||||
{
|
||||
try {
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$sql_adm = "SELECT REG_DATE,
|
||||
REG_NO,
|
||||
PATIENT_ID,
|
||||
PATIENT_NAME,
|
||||
AGE,
|
||||
top_patient.M_PatientID as m_patient_id
|
||||
FROM x_adm_rekap_patient
|
||||
JOIN m_patient as top_patient ON PATIENT_ID = top_patient.M_PatientOldPID
|
||||
WHERE
|
||||
STAGE = '2'";
|
||||
$qry_adm = $this->db->query($sql_adm);
|
||||
//echo $this->db->last_query();
|
||||
if (!$qry_adm) {
|
||||
$this->db->trans_rollback();
|
||||
//echo $this->db->last_query();
|
||||
$this->sys_error_db('select x_adm_rekap_patient error', $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry_adm->result_array();
|
||||
//print_r($rows);
|
||||
// exit;
|
||||
foreach ($rows as $key => $row_adm) {
|
||||
$sql_check_order = "SELECT
|
||||
T_OrderHeaderID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderOldLabNumber,
|
||||
T_OrderHeaderM_PatientID
|
||||
FROM x_t_orderheader
|
||||
WHERE T_OrderHeaderIsActive = 'Y'
|
||||
AND T_OrderHeaderOldLabNumber = ?";
|
||||
$qry_check_order = $this->db->query($sql_check_order, array(
|
||||
$row_adm['REG_NO']
|
||||
));
|
||||
// echo $this->db->last_query();
|
||||
if ($qry_check_order) {
|
||||
$rows_check_order = $qry_check_order->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
//echo $this->db->last_query();
|
||||
$this->sys_error_db("select check t_orderheader", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$reg_date = $row_adm['REG_DATE'];
|
||||
$full_date = $reg_date . ' 12:00:00';
|
||||
|
||||
if (count($rows_check_order) == 0) {
|
||||
// print_r('belum ada');
|
||||
// exit;
|
||||
|
||||
$sql_insert_order = "INSERT INTO x_t_orderheader(
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderOldLabNumber,
|
||||
T_OrderHeaderM_PatientID,
|
||||
T_OrderHeaderCorporateID,
|
||||
T_OrderHeaderMgm_McuID,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
T_OrderHeaderCreated,
|
||||
T_OrderHeaderLastUpdated) VALUES(
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now())";
|
||||
$qry_insert_order = $this->db->query($sql_insert_order, array(
|
||||
$full_date,
|
||||
$row_adm['REG_NO'],
|
||||
$row_adm['REG_NO'],
|
||||
$row_adm['m_patient_id'],
|
||||
50,
|
||||
0,
|
||||
$row_adm['AGE']
|
||||
));
|
||||
//echo $this->db->last_query();
|
||||
if (!$qry_insert_order) {
|
||||
$this->db->trans_rollback();
|
||||
//echo $this->db->last_query();
|
||||
$this->sys_error_db("insert t_orderheader error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$insertid = $this->db->insert_id();
|
||||
|
||||
$sql_select_testid = "SELECT
|
||||
name,
|
||||
name_v,
|
||||
test_id
|
||||
FROM x_map_lab";
|
||||
$qry_select_testid = $this->db->query($sql_select_testid);
|
||||
//echo $this->db->last_query();
|
||||
if ($qry_select_testid) {
|
||||
$rows_test = $qry_select_testid->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback;
|
||||
//echo $this->db->last_query();
|
||||
$this->sys_error_db("select x_map_lab", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
// print_r($rows_test);
|
||||
// exit;
|
||||
foreach ($rows_test as $key => $value) {
|
||||
// print_r($value);
|
||||
// exit;
|
||||
$sql_insert_detail = "insert into x_t_orderdetail (
|
||||
T_OrderDetailT_OrderHeaderID,
|
||||
T_OrderDetailT_TestID,
|
||||
T_OrderDetailT_TestCode,
|
||||
T_OrderDetailT_TestSasCode,
|
||||
T_OrderDetailT_TestName,
|
||||
T_OrderDetailT_TestIsResult,
|
||||
T_OrderDetailT_TestIsPrice )
|
||||
SELECT
|
||||
?,
|
||||
T_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice
|
||||
FROM t_test
|
||||
WHERE T_TestID in (?)";
|
||||
$qry_insert_detail = $this->db->query($sql_insert_detail, array(
|
||||
$insertid,
|
||||
$value['test_id']
|
||||
));
|
||||
//echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry_insert_detail) {
|
||||
$this->db->trans_rollback();
|
||||
// echo $this->db->last_query();
|
||||
$this->sys_error_db('insert t_orderdetail error', $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"message" => "Berhasil",
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
application/controllers/cpone/Result.http
Normal file
35
application/controllers/cpone/Result.http
Normal file
@@ -0,0 +1,35 @@
|
||||
POST https://{{host}}/cpone/result/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/result/get_branch
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/result/search
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"date": "2024-03-08",
|
||||
"branchCode": "W001",
|
||||
"search": "",
|
||||
"current_page": 1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/result/getlistlogapi
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"resultID": 23,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
169
application/controllers/cpone/Result.php
Normal file
169
application/controllers/cpone/Result.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
class Result extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("cpone", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "RESULT API";
|
||||
}
|
||||
|
||||
function get_branch()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_BranchID as branchID,
|
||||
M_BranchCode,
|
||||
M_BranchName,
|
||||
M_BranchAddress
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("branch select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
}
|
||||
$test_name = "";
|
||||
if (isset($prm['test_name'])) {
|
||||
$test_name = trim($prm["test_name"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) AS total FROM(
|
||||
SELECT api_result.*, IF(Nat_TestName IS NULL, 'Belum Mapping', Nat_TestName) AS Nat_TestName
|
||||
FROM api_result
|
||||
LEFT JOIN nat_testmap ON Nat_TestMapCode = api_ResultTestCode
|
||||
LEFT JOIN nat_test ON Nat_TestMapNat_TestID = Nat_TestID
|
||||
WHERE `api_ResultNolab` = ? AND (`api_ResultTestName` LIKE CONCAT('%', ?, '%') OR api_ResultTestCode LIKE CONCAT('%', ?, '%'))
|
||||
) x";
|
||||
$qry_tot = $this->db->query($sql_tot, [ $search, $test_name, $test_name]);
|
||||
//echo $this->db->last_query();
|
||||
//exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("result count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT api_result.*, IF(Nat_TestName IS NULL, 'Belum Mapping', Nat_TestName) AS Nat_TestName, IF(Nat_TestCode IS NULL, '', Nat_TestCode) AS Nat_TestCode
|
||||
FROM api_result
|
||||
LEFT JOIN nat_testmap ON Nat_TestMapCode = api_ResultTestCode
|
||||
LEFT JOIN nat_test ON Nat_TestMapNat_TestID = Nat_TestID
|
||||
WHERE `api_ResultNolab` = ? AND (`api_ResultTestName` LIKE CONCAT('%', ?, '%') OR api_ResultTestCode LIKE CONCAT('%', ?, '%'))
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [ $search, $test_name, $test_name,$number_limit, $number_offset]);
|
||||
//echo $this->db->last_query();
|
||||
//exit;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select result error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getlistlogapi()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$resultID = $prm["resultID"];
|
||||
|
||||
$sql = "SELECT log_ApiID,
|
||||
log_ApiDate,
|
||||
log_ApiM_BranchCode,
|
||||
log_ApiEndpoint,
|
||||
log_ApiParam,
|
||||
log_ApiResponse,
|
||||
log_ApiType,
|
||||
log_ApiIsParsed
|
||||
FROM cpone_log.log_api
|
||||
JOIN api_result ON log_ApiID = api_ResultLog_ApiID
|
||||
WHERE api_ResultID = ?";
|
||||
$qry = $this->db->query($sql, [$resultID]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select log_api error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key]["log_ApiParam"] = json_encode(json_decode($value["log_ApiParam"]), JSON_PRETTY_PRINT);
|
||||
}
|
||||
$result = array(
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
169
application/controllers/cpone/Result.php--050325
Normal file
169
application/controllers/cpone/Result.php--050325
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
class Result extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("cpone", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "RESULT API";
|
||||
}
|
||||
|
||||
function get_branch()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_BranchID as branchID,
|
||||
M_BranchCode,
|
||||
M_BranchName,
|
||||
M_BranchAddress
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("branch select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
}
|
||||
$test_name = "";
|
||||
if (isset($prm['test_name'])) {
|
||||
$test_name = trim($prm["test_name"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) AS total FROM(
|
||||
SELECT api_result.*, IF(Nat_TestName IS NULL, 'Belum Mapping', Nat_TestName) AS Nat_TestName
|
||||
FROM api_result
|
||||
LEFT JOIN nat_testmap ON Nat_TestMapCode = api_ResultTestCode
|
||||
LEFT JOIN nat_test ON Nat_TestMapNat_TestID = Nat_TestID
|
||||
WHERE `api_ResultNolab` = ? AND (`api_ResultTestName` LIKE CONCAT('%', ?, '%') OR api_ResultTestCode LIKE CONCAT('%', ?, '%'))
|
||||
) x";
|
||||
$qry_tot = $this->db->query($sql_tot, [ $search, $test_name, $test_name]);
|
||||
//echo $this->db->last_query();
|
||||
//exit;
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("result count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT api_result.*, IF(Nat_TestName IS NULL, 'Belum Mapping', Nat_TestName) AS Nat_TestName
|
||||
FROM api_result
|
||||
LEFT JOIN nat_testmap ON Nat_TestMapCode = api_ResultTestCode
|
||||
LEFT JOIN nat_test ON Nat_TestMapNat_TestID = Nat_TestID
|
||||
WHERE `api_ResultNolab` = ? AND (`api_ResultTestName` LIKE CONCAT('%', ?, '%') OR api_ResultTestCode LIKE CONCAT('%', ?, '%'))
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [ $search, $test_name, $test_name,$number_limit, $number_offset]);
|
||||
//echo $this->db->last_query();
|
||||
//exit;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select result error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getlistlogapi()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$resultID = $prm["resultID"];
|
||||
|
||||
$sql = "SELECT log_ApiID,
|
||||
log_ApiDate,
|
||||
log_ApiM_BranchCode,
|
||||
log_ApiEndpoint,
|
||||
log_ApiParam,
|
||||
log_ApiResponse,
|
||||
log_ApiType,
|
||||
log_ApiIsParsed
|
||||
FROM cpone_log.log_api
|
||||
JOIN api_result ON log_ApiID = api_ResultLog_ApiID
|
||||
WHERE api_ResultID = ?";
|
||||
$qry = $this->db->query($sql, [$resultID]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select log_api error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key]["log_ApiParam"] = json_encode(json_decode($value["log_ApiParam"]), JSON_PRETTY_PRINT);
|
||||
}
|
||||
$result = array(
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
2907
application/controllers/cpone/inject/Corporate.php
Normal file
2907
application/controllers/cpone/inject/Corporate.php
Normal file
File diff suppressed because it is too large
Load Diff
2907
application/controllers/cpone/inject/Preregisterv2.php
Normal file
2907
application/controllers/cpone/inject/Preregisterv2.php
Normal file
File diff suppressed because it is too large
Load Diff
15
application/controllers/cpone/masterdata/Fisiktemplate.http
Normal file
15
application/controllers/cpone/masterdata/Fisiktemplate.http
Normal file
@@ -0,0 +1,15 @@
|
||||
POST https://{{host}}/cpone/masterdata/fisiktemplate/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/masterdata/fisiktemplate/lookupfisikbyname
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"lookupfisikbyname": "",
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
906
application/controllers/cpone/masterdata/Fisiktemplate.php
Normal file
906
application/controllers/cpone/masterdata/Fisiktemplate.php
Normal file
@@ -0,0 +1,906 @@
|
||||
<?php
|
||||
|
||||
class Fisiktemplate extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "PATIENT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookupfisikbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$fisikname = $prm['fisikname'];
|
||||
$filter = '';
|
||||
if (isset($sexid)) {
|
||||
$filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) ";
|
||||
}
|
||||
if (isset($flagid)) {
|
||||
$filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))";
|
||||
}
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "SELECT COUNT(*) as total FROM
|
||||
(SELECT *
|
||||
FROM fisik_template_mapping
|
||||
WHERE FisikTemplateMappingIsActive = 'Y' AND
|
||||
FisikTemplateMappingName LIKE '%{$fisikname}%'
|
||||
GROUP BY FisikTemplateMappingID) x";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template_mapping count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT FisikTemplateMappingID as id,
|
||||
FisikTemplateMappingID,
|
||||
FisikTemplateMappingName
|
||||
FROM fisik_template_mapping
|
||||
WHERE FisikTemplateMappingIsActive = 'Y' AND
|
||||
FisikTemplateMappingName LIKE '%{$fisikname}%'
|
||||
GROUP BY FisikTemplateMappingID
|
||||
ORDER BY FisikTemplateMappingName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
// $sql_param = array($search);
|
||||
$query = $this->db->query($sql);
|
||||
// echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template_mapping select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addfisik()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO fisik_template_mapping(
|
||||
FisikTemplateMappingName,
|
||||
FisikTemplateMappingCreated,
|
||||
FisikTemplateMappingCreatedUserID,
|
||||
FisikTemplateMappingLastUpdated
|
||||
) VALUES(?,NOW(),?,NOW())";
|
||||
$qry = $this->db->query($sql, array($name, $userid));
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("save fisik_template_mapping error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookupfisikdetailbyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$all = $prm['all'];
|
||||
// $filter = '';
|
||||
// if ($status != 'A') {
|
||||
// $filter .= "AND status = '{$status}' ";
|
||||
// } else {
|
||||
// $filter .= "";
|
||||
// }
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "SELECT COUNT(*) as total
|
||||
FROM (
|
||||
SELECT *, IF(IFNULL(FisikTemplateMappingDetailID, 0) > 0, 'Y', 'N') AS status
|
||||
FROM fisik_template
|
||||
LEFT JOIN fisik_template_mapping_detail ON FisikTemplateID = FisikTemplateMappingDetailFisikTemplateID
|
||||
AND FisikTemplateMappingDetailFisikTemplateMappingID = $id AND FisikTemplateMappingDetailIsActive = 'Y'
|
||||
) x
|
||||
WHERE
|
||||
FisikTemplateCode LIKE '%{$code}%' AND
|
||||
FisikTemplateTitle LIKE '%{$name}%'";
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT FisikTemplateID as id,
|
||||
FisikTemplateJSON as xjson,
|
||||
FisikTemplateID,
|
||||
FisikTemplateType,
|
||||
FisikTemplateCode,
|
||||
FisikTemplateTableName,
|
||||
FisikTemplateTitle,
|
||||
FisikTemplateMappingDetailID,
|
||||
FisikTemplateMappingDetailFisikTemplateMappingID,
|
||||
FisikTemplateMappingDetailFisikTemplateID,
|
||||
FisikTemplateIsActive,
|
||||
IF(IFNULL(FisikTemplateMappingDetailID, 0) > 0, 'Y', 'N') AS status
|
||||
FROM fisik_template
|
||||
LEFT JOIN fisik_template_mapping_detail ON FisikTemplateID = FisikTemplateMappingDetailFisikTemplateID
|
||||
AND FisikTemplateMappingDetailFisikTemplateMappingID = $id AND FisikTemplateMappingDetailIsActive = 'Y'
|
||||
WHERE FisikTemplateIsActive = 'Y' AND
|
||||
FisikTemplateCode LIKE '%{$code}%' AND
|
||||
FisikTemplateTitle LIKE '%{$name}%'
|
||||
|
||||
|
||||
GROUP BY FisikTemplateID
|
||||
ORDER BY FisikTemplateCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$query = $this->db->query($sql);
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key]['xjson'] = json_decode($value['xjson']);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function saveaddeditfisikdetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$mappingdetailid = $prm['FisikTemplateMappingDetailID'];
|
||||
$templatemappingID = $prm['templatemappingID'];
|
||||
$templateID = $prm['FisikTemplateID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($status == 'Y') {
|
||||
$sql = "INSERT INTO fisik_template_mapping_detail(
|
||||
FisikTemplateMappingDetailFisikTemplateMappingID,
|
||||
FisikTemplateMappingDetailFisikTemplateID,
|
||||
FisikTemplateMappingDetailCreated,
|
||||
FisikTemplateMappingDetailCreatedUserID,
|
||||
FisikTemplateMappingDetailLastUpdated) VALUES(?,?,NOW(),?,NOW())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$templatemappingID,
|
||||
$templateID,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fisik_template_mapping_detail insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE fisik_template_mapping_detail SET
|
||||
FisikTemplateMappingDetailIsActive = 'N',
|
||||
FisikTemplateMappingDetailLastUpdated = NOW(),
|
||||
FisikTemplateMappingDetailLastUpdatedUserID = ?
|
||||
WHERE FisikTemplateMappingDetailID = ?";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$userid,
|
||||
$mappingdetailid,
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fisik_template_mapping_detail insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookupuserbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupname = $prm['groupname'];
|
||||
$filter = '';
|
||||
if (isset($sexid)) {
|
||||
$filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) ";
|
||||
}
|
||||
if (isset($flagid)) {
|
||||
$filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))";
|
||||
}
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from m_usergroup
|
||||
WHERE
|
||||
M_UserGroupIsActive = 'Y' AND
|
||||
M_UserGroupName like '%{$groupname}%'
|
||||
$filter GROUP BY M_UserGroupID) a";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT m_usergroup.*,
|
||||
M_UserGroupID as id,
|
||||
M_UserGroupID,
|
||||
M_UserGroupName
|
||||
FROM m_usergroup
|
||||
WHERE
|
||||
M_UserGroupIsActive = 'Y' AND
|
||||
M_UserGroupName like '%{$groupname}%'
|
||||
$filter
|
||||
GROUP BY M_UserGroupID
|
||||
ORDER BY M_UserGroupName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function lookupreportbyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$reportgroup = $prm['reportgroup'];
|
||||
$reportcode = $prm['reportcode'];
|
||||
$reportname = $prm['reportname'];
|
||||
$status = $prm['status'];
|
||||
$all = $prm['all'];
|
||||
$filter = '';
|
||||
if ($status != 'A') {
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *, IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
|
||||
from r_report
|
||||
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
|
||||
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
|
||||
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
|
||||
WHERE
|
||||
R_ReportIsActive = 'Y') a
|
||||
WHERE
|
||||
R_ReportGroupName like '%{$reportgroup}%' AND
|
||||
R_ReportCode like '%{$reportcode}%' AND
|
||||
R_ReportName like '%{$reportname}%' $filter";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("r_report count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select R_ReportID as id,
|
||||
R_ReportID,
|
||||
R_ReportCode,
|
||||
R_ReportName,
|
||||
R_ReportGroupName,
|
||||
UserGroupReportID,
|
||||
UserGroupReportM_UserGroupID,
|
||||
UserGroupReportR_ReportID,
|
||||
IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
|
||||
from r_report
|
||||
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
|
||||
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
|
||||
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
|
||||
WHERE
|
||||
R_ReportIsActive = 'Y') a
|
||||
WHERE
|
||||
R_ReportGroupName like '%{$reportgroup}%' AND
|
||||
R_ReportCode like '%{$reportcode}%' AND
|
||||
R_ReportName like '%{$reportname}%' $filter
|
||||
GROUP BY R_ReportID
|
||||
ORDER BY R_ReportGroupName ASC, R_ReportName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("r_report select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function getsexreg()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query = "
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getstatus()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
|
||||
$query = "
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewreport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $prm['userid'];
|
||||
$reportcode = $prm['reportcode'];
|
||||
$reportname = $prm['reportname'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into r_report(
|
||||
R_ReportCode,
|
||||
R_ReportName,
|
||||
R_ReportUserID,
|
||||
R_ReportCreated,
|
||||
R_ReportLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$reportcode,
|
||||
$reportname,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function saveaddeditreport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$usergroupid = $prm['userid'];
|
||||
$reportid = $prm['R_ReportID'];
|
||||
$reportuserid = $prm['UserGroupReportID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($status == 'Y') {
|
||||
$sql = "insert into usergroup_report(
|
||||
UserGroupReportM_UserGroupID,
|
||||
UserGroupReportR_ReportID,
|
||||
UserGroupUserID,
|
||||
UserGroupReportCreated,
|
||||
UserGroupReportLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$usergroupid,
|
||||
$reportid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("usergroup_report insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE usergroup_report SET
|
||||
UserGroupReportIsActive = 'N',
|
||||
UserGroupUserID = ?,
|
||||
UserGroupReportCreated = now(),
|
||||
UserGroupReportLastUpdated = now()
|
||||
WHERE UserGroupReportID = ?";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$userid,
|
||||
$reportuserid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("usergroup_report insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveallreport()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$details = $prm['details'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach ($details as $k => $v) {
|
||||
$query = "UPDATE usergroup_report SET
|
||||
UserGroupReportM_UserGroupID = '{$v['UserGroupReportM_UserGroupID']}',
|
||||
UserGroupReportAdviceIna = '{$v['UserGroupReportAdviceIna']}',
|
||||
UserGroupReportAdviceEng = '{$v['UserGroupReportAdviceEng']}',
|
||||
UserGroupReportUserID = {$userid},
|
||||
UserGroupReportCreated = now(),
|
||||
UserGroupReportLastUpdated = now()
|
||||
WHERE UserGroupReportID = {$v['UserGroupReportID']}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function deleteuser()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update nat_methode SET
|
||||
Nat_MethodeIsActive = 'N'
|
||||
WHERE
|
||||
Nat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_methode delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update m_usergroup SET
|
||||
M_UserGroupIsActive = 'N'
|
||||
WHERE
|
||||
M_UserGroupNat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deletereport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update m_usergroup SET
|
||||
M_UserGroupIsActive = 'N'
|
||||
WHERE
|
||||
M_UserGroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchuser()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchuserbyname()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchtest()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("t_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
ORDER BY T_TestName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("t_test rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
882
application/controllers/cpone/masterdata/Maplocaltest.php
Normal file
882
application/controllers/cpone/masterdata/Maplocaltest.php
Normal file
@@ -0,0 +1,882 @@
|
||||
<?php
|
||||
|
||||
class Maplocaltest extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "PATIENT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookupbranchbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$branchname = $prm['branchname'];
|
||||
$filter = '';
|
||||
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 50';
|
||||
}
|
||||
$number_limit = 50;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "SELECT COUNT(*) as total FROM
|
||||
(SELECT *
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y' AND
|
||||
M_BranchName LIKE CONCAT('%', ?, '%')
|
||||
GROUP BY M_BranchID) x";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql, array($branchname));
|
||||
//echo $this->db->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("m_branch count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_BranchID as id,
|
||||
M_BranchID,
|
||||
M_BranchCode,
|
||||
M_BranchName,
|
||||
M_BranchCodeBridging
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y' AND
|
||||
M_BranchName LIKE CONCAT('%', ?, '%')
|
||||
GROUP BY M_BranchID
|
||||
ORDER BY M_BranchName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
// $sql_param = array($search);
|
||||
$query = $this->db->query($sql, array($branchname));
|
||||
// echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_branch select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addfisik()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO fisik_template_mapping(
|
||||
FisikTemplateMappingName,
|
||||
FisikTemplateMappingCreated,
|
||||
FisikTemplateMappingCreatedUserID,
|
||||
FisikTemplateMappingLastUpdated
|
||||
) VALUES(?,NOW(),?,NOW())";
|
||||
$qry = $this->db->query($sql, array($name, $userid));
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("save fisik_template_mapping error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookupdetailbyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$status = $prm['status'];
|
||||
// $filter = '';
|
||||
// if ($status != 'A') {
|
||||
// $filter .= "AND status = '{$status}' ";
|
||||
// } else {
|
||||
// $filter .= "";
|
||||
// }
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 50';
|
||||
}
|
||||
$number_limit = 50;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "SELECT COUNT(*) as total
|
||||
FROM (
|
||||
SELECT DISTINCT Nat_TestID as id,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
IF(IFNULL(Nat_TestReferID, 0) > 0, 'Y', 'N') AS status
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testrefer ON Nat_TestReferNat_TestID = Nat_TestID AND
|
||||
Nat_TestReferM_BranchID = ? AND Nat_TestReferIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y' AND
|
||||
(? = 'A' OR ((? = 'Y') AND Nat_TestReferID IS NOT NULL) OR (? = 'N' AND Nat_TestReferID IS NULL)) AND
|
||||
Nat_TestCode LIKE CONCAT('%', ?, '%') AND
|
||||
Nat_TestName LIKE CONCAT('%', ?, '%')
|
||||
ORDER BY Nat_TestCode ASC
|
||||
) x";
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql, array($id, $status, $status, $status, $code, $name));
|
||||
//echo $this->db->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT Nat_TestID as id,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
IF(IFNULL(Nat_TestReferID, 0) > 0, 'Y', 'N') AS status
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testrefer ON Nat_TestReferNat_TestID = Nat_TestID AND
|
||||
Nat_TestReferM_BranchID = ? AND Nat_TestReferIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y' AND
|
||||
(? = 'A' OR ((? = 'Y') AND Nat_TestReferID IS NOT NULL) OR (? = 'N' AND Nat_TestReferID IS NULL)) AND
|
||||
Nat_TestCode LIKE CONCAT('%', ?, '%') AND
|
||||
Nat_TestName LIKE CONCAT('%', ?, '%')
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$query = $this->db->query($sql, array($id, $status, $status, $status, $code, $name));
|
||||
//echo $this->db->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key]['xjson'] = json_decode($value['xjson']);
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("fisik_template select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function saveaddeditfisikdetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$nat_testid = $prm['nat_testid'];
|
||||
$new_status = $prm['new_status'];
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$sql = "UPDATE nat_testrefer SET
|
||||
Nat_TestReferIsActive = 'N',
|
||||
Nat_TestReferDeleted = NOW(),
|
||||
Nat_TestReferDeletedUserID = ?
|
||||
WHERE Nat_TestReferNat_TestID = ?AND Nat_TestReferM_BranchID = ? AND Nat_TestReferIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, array($userid, $nat_testid, $id));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_testrefer update", $this->db);
|
||||
exit;
|
||||
}
|
||||
if($new_status == 'Y'){
|
||||
$sql = "INSERT INTO nat_testrefer(
|
||||
Nat_TestReferNat_TestID,
|
||||
Nat_TestReferM_BranchID,
|
||||
Nat_TestReferCreated,
|
||||
Nat_TestReferCreatedUserID
|
||||
) VALUES(?,?,NOW(),?)";
|
||||
$query = $this->db->query($sql, array($nat_testid, $id, $userid));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_testrefer insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookupuserbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$groupname = $prm['groupname'];
|
||||
$filter = '';
|
||||
if (isset($sexid)) {
|
||||
$filter .= "AND ($sexid = 0 or ($sexid > 0 and Nat_SexID = $sexid)) ";
|
||||
}
|
||||
if (isset($flagid)) {
|
||||
$filter .= "AND ($flagid = 0 or ($flagid > 0 and Nat_FlagID = $flagid))";
|
||||
}
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *
|
||||
from m_usergroup
|
||||
WHERE
|
||||
M_UserGroupIsActive = 'Y' AND
|
||||
M_UserGroupName like '%{$groupname}%'
|
||||
$filter GROUP BY M_UserGroupID) a";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT m_usergroup.*,
|
||||
M_UserGroupID as id,
|
||||
M_UserGroupID,
|
||||
M_UserGroupName
|
||||
FROM m_usergroup
|
||||
WHERE
|
||||
M_UserGroupIsActive = 'Y' AND
|
||||
M_UserGroupName like '%{$groupname}%'
|
||||
$filter
|
||||
GROUP BY M_UserGroupID
|
||||
ORDER BY M_UserGroupName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function lookupreportbyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$reportgroup = $prm['reportgroup'];
|
||||
$reportcode = $prm['reportcode'];
|
||||
$reportname = $prm['reportname'];
|
||||
$status = $prm['status'];
|
||||
$all = $prm['all'];
|
||||
$filter = '';
|
||||
if ($status != 'A') {
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
FROM(SELECT *, IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
|
||||
from r_report
|
||||
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
|
||||
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
|
||||
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
|
||||
WHERE
|
||||
R_ReportIsActive = 'Y') a
|
||||
WHERE
|
||||
R_ReportGroupName like '%{$reportgroup}%' AND
|
||||
R_ReportCode like '%{$reportcode}%' AND
|
||||
R_ReportName like '%{$reportname}%' $filter";
|
||||
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("r_report count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select R_ReportID as id,
|
||||
R_ReportID,
|
||||
R_ReportCode,
|
||||
R_ReportName,
|
||||
R_ReportGroupName,
|
||||
UserGroupReportID,
|
||||
UserGroupReportM_UserGroupID,
|
||||
UserGroupReportR_ReportID,
|
||||
IF(IFNULL(UserGroupReportID,0) > 0 , 'Y', 'N') as status
|
||||
from r_report
|
||||
LEFT JOIN usergroup_report ON R_ReportID = UserGroupReportR_ReportID AND UserGroupReportM_UserGroupID = $id AND UserGroupReportIsActive = 'Y'
|
||||
LEFT JOIN m_usergroup ON UserGroupReportM_UserGroupID = M_UserGroupID AND M_UserGroupIsActive = 'Y'
|
||||
LEFT JOIN r_reportgroup ON R_ReportR_ReportGroupID = R_ReportGroupID
|
||||
WHERE
|
||||
R_ReportIsActive = 'Y') a
|
||||
WHERE
|
||||
R_ReportGroupName like '%{$reportgroup}%' AND
|
||||
R_ReportCode like '%{$reportcode}%' AND
|
||||
R_ReportName like '%{$reportname}%' $filter
|
||||
GROUP BY R_ReportID
|
||||
ORDER BY R_ReportGroupName ASC, R_ReportName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("r_report select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "total_filter" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function getsexreg()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query = "
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getstatus()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
|
||||
$query = "
|
||||
SELECT 'A' as M_StatusID, 'Semua' as M_StatusName
|
||||
UNION
|
||||
SELECT 'Y' as M_StatusID, 'Terpilih' as M_StatusName
|
||||
UNION
|
||||
SELECT 'N' as M_StatusID, 'Belum Terpilih' as M_StatusName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_statuss'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewreport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $prm['userid'];
|
||||
$reportcode = $prm['reportcode'];
|
||||
$reportname = $prm['reportname'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into r_report(
|
||||
R_ReportCode,
|
||||
R_ReportName,
|
||||
R_ReportUserID,
|
||||
R_ReportCreated,
|
||||
R_ReportLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$reportcode,
|
||||
$reportname,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function saveaddeditreport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$usergroupid = $prm['userid'];
|
||||
$reportid = $prm['R_ReportID'];
|
||||
$reportuserid = $prm['UserGroupReportID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($status == 'Y') {
|
||||
$sql = "insert into usergroup_report(
|
||||
UserGroupReportM_UserGroupID,
|
||||
UserGroupReportR_ReportID,
|
||||
UserGroupUserID,
|
||||
UserGroupReportCreated,
|
||||
UserGroupReportLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$usergroupid,
|
||||
$reportid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("usergroup_report insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE usergroup_report SET
|
||||
UserGroupReportIsActive = 'N',
|
||||
UserGroupUserID = ?,
|
||||
UserGroupReportCreated = now(),
|
||||
UserGroupReportLastUpdated = now()
|
||||
WHERE UserGroupReportID = ?";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$userid,
|
||||
$reportuserid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("usergroup_report insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function saveallreport()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$details = $prm['details'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach ($details as $k => $v) {
|
||||
$query = "UPDATE usergroup_report SET
|
||||
UserGroupReportM_UserGroupID = '{$v['UserGroupReportM_UserGroupID']}',
|
||||
UserGroupReportAdviceIna = '{$v['UserGroupReportAdviceIna']}',
|
||||
UserGroupReportAdviceEng = '{$v['UserGroupReportAdviceEng']}',
|
||||
UserGroupReportUserID = {$userid},
|
||||
UserGroupReportCreated = now(),
|
||||
UserGroupReportLastUpdated = now()
|
||||
WHERE UserGroupReportID = {$v['UserGroupReportID']}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function deleteuser()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update nat_methode SET
|
||||
Nat_MethodeIsActive = 'N'
|
||||
WHERE
|
||||
Nat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_methode delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update m_usergroup SET
|
||||
M_UserGroupIsActive = 'N'
|
||||
WHERE
|
||||
M_UserGroupNat_MethodeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deletereport()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update m_usergroup SET
|
||||
M_UserGroupIsActive = 'N'
|
||||
WHERE
|
||||
M_UserGroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_usergroup delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchuser()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchuserbyname()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_MethodeID, Nat_MethodeName
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchtest()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'";
|
||||
$query = $this->db_onedev->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("t_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestName like ?
|
||||
AND T_TestIsActive = 'Y' AND T_TestIsResult = 'Y'
|
||||
ORDER BY T_TestName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("t_test rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
application/controllers/cpone/masterdata/Nattestmap.http
Normal file
16
application/controllers/cpone/masterdata/Nattestmap.http
Normal file
@@ -0,0 +1,16 @@
|
||||
POST https://{{host}}/cpone/masterdata/nattestmap/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/masterdata/nattestmap/search
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"search":"",
|
||||
"current_page":1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
300
application/controllers/cpone/masterdata/Nattestmap.php
Normal file
300
application/controllers/cpone/masterdata/Nattestmap.php
Normal file
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
class Nattestmap extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NAT TEST MAP API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$status = $prm['status'];
|
||||
// $all = $prm['all'];
|
||||
$filter = '';
|
||||
if ($status != 'A') {
|
||||
$filter .= "AND status = '{$status}' ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$total_result = 0;
|
||||
$total_belum_result = 0;
|
||||
$total_price = 0;
|
||||
$total_belum_price = 0;
|
||||
$sql_result = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsResult = 'Y') x";
|
||||
$qry_result = $this->db->query($sql_result);
|
||||
if ($qry_result) {
|
||||
$total_result = $qry_result->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_belum_result = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsResult = 'Y') x
|
||||
WHERE status = 'N'";
|
||||
$qry_belum_result = $this->db->query($sql_belum_result);
|
||||
if ($qry_belum_result) {
|
||||
$total_belum_result = $qry_belum_result->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_price = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsPrice = 'Y') x";
|
||||
$qry_price = $this->db->query($sql_price);
|
||||
if ($qry_price) {
|
||||
$total_price = $qry_price->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_belum_price = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsPrice = 'Y') x
|
||||
WHERE status = 'N'";
|
||||
$qry_belum_price = $this->db->query($sql_belum_price);
|
||||
if ($qry_belum_price) {
|
||||
$total_belum_price = $qry_belum_price->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) AS total FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND (Nat_TestIsResult = 'Y'
|
||||
OR Nat_TestIsPrice = 'Y')) x
|
||||
WHERE (Nat_TestCode LIKE ? OR Nat_TestName LIKE ? OR TestMapCode LIKE ?) $filter
|
||||
";
|
||||
$qry_tot = $this->db->query($sql_tot, [$search, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM
|
||||
(SELECT
|
||||
IF(ISNULL(Nat_TestMapID),'N','Y') as status,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
Nat_TestName,
|
||||
Nat_TestMapID,
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
IFNULL(Nat_TestMapCode, '') AS TestMapCode
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_testmap ON Nat_TestID = Nat_TestMapNat_TestID
|
||||
AND Nat_TestMapIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND (Nat_TestIsResult = 'Y'
|
||||
OR Nat_TestIsPrice = 'Y')) x
|
||||
WHERE (Nat_TestCode LIKE ? OR Nat_TestName LIKE ? OR TestMapCode LIKE ?)
|
||||
$filter
|
||||
ORDER BY Nat_TestCode ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $search, $search, $number_limit, $number_offset]);
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nat_test error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_result" => $total_result,
|
||||
"total_belum_result" => $total_belum_result,
|
||||
"total_price" => $total_price,
|
||||
"total_belum_price" => $total_belum_price,
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saverow()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if ($prm["Nat_TestMapID"]) {
|
||||
// print_r("sudah ada sample id");
|
||||
// exit;
|
||||
$sql = "UPDATE nat_testmap SET
|
||||
Nat_TestMapCode = '{$prm["codeMapping"]}',
|
||||
Nat_TestMapLastUpdated = NOW(),
|
||||
Nat_TestMapUserID = '{$userid}'
|
||||
WHERE Nat_TestMapID = {$prm["Nat_TestMapID"]}";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("update nat_testmap error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_selec_del = "SELECT Nat_TestMapID,
|
||||
Nat_TestMapCode
|
||||
FROM nat_testmap
|
||||
WHERE Nat_TestMapIsActive = 'Y'
|
||||
AND Nat_TestMapID = {$prm["Nat_TestMapID"]}";
|
||||
$row = $this->db->query($sql_selec_del)->row_array();
|
||||
|
||||
if ($row["Nat_TestMapCode"] == "") {
|
||||
$sql_del = "DELETE FROM nat_testmap
|
||||
WHERE Nat_TestMapID = {$prm["Nat_TestMapID"]}";
|
||||
$qry_del = $this->db->query($sql_del);
|
||||
if (!$qry_del) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("delete nat_testmap error", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// print_r("belum ada sample id");
|
||||
// exit;
|
||||
$sql = "INSERT INTO nat_testmap(
|
||||
Nat_TestMapNat_TestID,
|
||||
Nat_TestMapCode,
|
||||
Nat_TestMapCreated,
|
||||
Nat_TestMapLastUpdated,
|
||||
Nat_TestMapUserID
|
||||
) VALUES(
|
||||
{$prm["Nat_TestID"]},
|
||||
'{$prm["codeMapping"]}',
|
||||
NOW(),
|
||||
NOW(),
|
||||
{$userid})";
|
||||
$qry = $this->db->query($sql);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("nat_testmap insert error", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
application/controllers/cpone/masterdata/Nonlabtemplate.http
Normal file
19
application/controllers/cpone/masterdata/Nonlabtemplate.http
Normal file
@@ -0,0 +1,19 @@
|
||||
POST https://{{host}}/cpone/masterdata/nonlabtemplate/search
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"search":"",
|
||||
"current_page":1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/masterdata/nonlabtemplate/searchdetail
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"nonlabID": 2,
|
||||
"search":"",
|
||||
"current_page":1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
486
application/controllers/cpone/masterdata/Nonlabtemplate.php
Normal file
486
application/controllers/cpone/masterdata/Nonlabtemplate.php
Normal file
@@ -0,0 +1,486 @@
|
||||
<?php
|
||||
class Nonlabtemplate extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NON LAN TEMPLATE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)";
|
||||
$qry_tot = $this->db->query($sql_tot, [$search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateID,
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateIsActive,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateLastUpdated
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)
|
||||
ORDER BY NonlabTemplateID ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_template(
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateCreatedUserID,
|
||||
NonlabTemplateLastUpdated,
|
||||
NonlabTemplateLastUpdatedUserID
|
||||
) VALUES(?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$name,
|
||||
$isfisik,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateName = ?,
|
||||
NonlabTemplateFlagOther = ?,
|
||||
NonlabTemplateLastUpdated = NOW(),
|
||||
NonlabTemplateLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($name, $isfisik, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletenonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateIsActive = 'N',
|
||||
NonlabTemplateDelete = NOW(),
|
||||
NonlabTemplateDeleteUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabID = $prm["nonlabID"];
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_total = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$nonlabID, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template detail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateDetailID,
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetaiNat_UnitID,
|
||||
NonlabTemplateDetailFlagActive,
|
||||
NonlabTemplateDetaiM_LangID,
|
||||
NonlabTemplateDetailIsActive
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)
|
||||
limit ? offset ?";
|
||||
$qry = $this->db->query($sql, [$nonlabID, $search, $search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template detail", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function adddetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
$nonlabid = "";
|
||||
if (isset($prm["nonlabid"])) {
|
||||
$nonlabid = trim($prm["nonlabid"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_template_detail(
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetailCreated,
|
||||
NonlabTemplateDetailCreatedUserID,
|
||||
NonlabTemplateDetailLastUpdated,
|
||||
NonlabTemplateDetailLastUpdatedUserID
|
||||
) VALUES(?,?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$nonlabid,
|
||||
$code,
|
||||
$name,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletedetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailIsActive = 'N',
|
||||
NonlabTemplateDetailDelete = NOW(),
|
||||
NonlabTemplateDetailDeleteUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveeditflag()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$flagstatus = $prm['flagstatus'];
|
||||
$templatedetailid = $prm['templatedetailid'];
|
||||
|
||||
if ($flagstatus == "Y") {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'Y',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'N',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail no avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
716
application/controllers/cpone/masterdata/Nonlabtemplatev2.php
Normal file
716
application/controllers/cpone/masterdata/Nonlabtemplatev2.php
Normal file
@@ -0,0 +1,716 @@
|
||||
<?php
|
||||
class Nonlabtemplatev2 extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NON LAN TEMPLATE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)";
|
||||
$qry_tot = $this->db->query($sql_tot, [$search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateID,
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateIsActive,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateLastUpdated
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)
|
||||
ORDER BY NonlabTemplateID ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_template(
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateCreatedUserID,
|
||||
NonlabTemplateLastUpdated,
|
||||
NonlabTemplateLastUpdatedUserID
|
||||
) VALUES(?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$name,
|
||||
$isfisik,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateName = ?,
|
||||
NonlabTemplateFlagOther = ?,
|
||||
NonlabTemplateLastUpdated = NOW(),
|
||||
NonlabTemplateLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($name, $isfisik, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletenonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateIsActive = 'N',
|
||||
NonlabTemplateDelete = NOW(),
|
||||
NonlabTemplateDeleteUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabID = $prm["nonlabID"];
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_total = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$nonlabID, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template detail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateDetailID,
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetaiNat_UnitID,
|
||||
NonlabTemplateDetailFlagActive,
|
||||
NonlabTemplateDetaiM_LangID,
|
||||
NonlabTemplateDetailIsActive
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)
|
||||
limit ? offset ?";
|
||||
$qry = $this->db->query($sql, [$nonlabID, $search, $search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template detail", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function adddetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$nonlabid = intval($prm["nonlabid"]);
|
||||
|
||||
if ($nonlabid === 0) {
|
||||
$this->sys_error("Anda belum memilih nonlab template, silahkan pilih nonlab template dulu");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
// $nonlabid = "";
|
||||
// if (isset($prm["nonlabid"])) {
|
||||
// $nonlabid = trim($prm["nonlabid"]);
|
||||
// }
|
||||
|
||||
$sql = "INSERT INTO nonlab_template_detail(
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetailCreated,
|
||||
NonlabTemplateDetailCreatedUserID,
|
||||
NonlabTemplateDetailLastUpdated,
|
||||
NonlabTemplateDetailLastUpdatedUserID
|
||||
) VALUES(?,?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$nonlabid,
|
||||
$code,
|
||||
$name,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletedetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailIsActive = 'N',
|
||||
NonlabTemplateDetailDelete = NOW(),
|
||||
NonlabTemplateDetailDeleteUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveeditflag()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$flagstatus = $prm['flagstatus'];
|
||||
$templatedetailid = $prm['templatedetailid'];
|
||||
|
||||
if ($flagstatus == "Y") {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'Y',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'N',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail no avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail SET
|
||||
NonlabTemplateDetailCode = ?,
|
||||
NonlabTemplateDetailName = ?,
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($code, $name, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptest()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm["search"])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = "%" . $prm["search"] . "%";
|
||||
} else {
|
||||
$search = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabtemplate_id = 0;
|
||||
if (isset($prm['nonlabtemplate_id'])) {
|
||||
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
||||
}
|
||||
$status = $prm['status'];
|
||||
$filter = '';
|
||||
if ($status == 'Y') {
|
||||
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NOT NULL ";
|
||||
} else {
|
||||
if ($status == 'N') {
|
||||
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NULL ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_dasar = "SELECT
|
||||
n.Nat_TestID,
|
||||
IF(ntm.NonlabTemplateMappingNonlabTemplateID IS NULL, 'N', 'Y') AS status,
|
||||
ntm.NonlabTemplateMappingNat_TestID,
|
||||
n.Nat_TestCode,
|
||||
n.Nat_TestName,
|
||||
n.Nat_TestShortName
|
||||
FROM nat_test as n
|
||||
LEFT JOIN nonlab_template_mapping as ntm ON n.Nat_TestID = ntm.NonlabTemplateMappingNat_TestID
|
||||
AND ntm.NonlabTemplateMappingIsActive = 'Y'
|
||||
LEFT JOIN nonlab_template as nt ON ntm.NonlabTemplateMappingNonlabTemplateID = nt.NonlabTemplateID
|
||||
AND nt.NonlabTemplateIsActive = 'Y'
|
||||
WHERE n.Nat_TestIsActive = 'Y'
|
||||
AND n.Nat_TestIsNonLab <> ''
|
||||
AND n.Nat_TestIsResult = 'Y'
|
||||
AND (n.Nat_TestCode LIKE '{$search}' OR n.Nat_TestName LIKE '{$search}')
|
||||
AND (nt.NonlabTemplateID = {$nonlabtemplate_id} OR nt.NonlabTemplateID IS NULL)
|
||||
$filter";
|
||||
|
||||
$qry_filter = "SELECT COUNT(*) as total FROM ($sql_dasar) as x";
|
||||
|
||||
$qry_filter = $this->db->query($qry_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
$sql = $sql_dasar . " ORDER BY n.Nat_TestCode LIMIT $number_limit OFFSET $number_offset";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveedittestmap()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$nonlabtemplate_id = 0;
|
||||
if (isset($prm['nonlabtemplate_id'])) {
|
||||
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
||||
}
|
||||
$test_id = 0;
|
||||
if (isset($prm['test_id'])) {
|
||||
$test_id = trim($prm["test_id"]);
|
||||
}
|
||||
|
||||
$status = $prm["status"];
|
||||
|
||||
$sql = "SELECT NonlabTemplateMappingID,
|
||||
NonlabTemplateMappingNonlabTemplateID,
|
||||
NonlabTemplateMappingNat_TestID
|
||||
FROM nonlab_template_mapping
|
||||
WHERE NonlabTemplateMappingNonlabTemplateID = ?
|
||||
AND NonlabTemplateMappingNat_TestID = ?";
|
||||
$qry = $this->db->query($sql, [$nonlabtemplate_id, $test_id]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$nonlabtemplatemapid = $rows[0]["NonlabTemplateMappingID"];
|
||||
$sql_update = "UPDATE nonlab_template_mapping SET
|
||||
NonlabTemplateMappingLastUpdated = NOW(),
|
||||
NonlabTemplateMappingLastUpdatedUserID = ?,
|
||||
NonlabTemplateMappingDeleted = NOW(),
|
||||
NonlabTemplateMappingIsActive = ?
|
||||
WHERE NonlabTemplateMappingID = ?";
|
||||
$qry_update = $this->db->query($sql_update, [$userid, $status, $nonlabtemplatemapid]);
|
||||
if (!$qry_update) {
|
||||
$this->sys_error_db("map test update", $this->db);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql_insert = "INSERT INTO nonlab_template_mapping(
|
||||
NonlabTemplateMappingNonlabTemplateID,
|
||||
NonlabTemplateMappingNat_TestID,
|
||||
NonlabTemplateMappingCreated,
|
||||
NonlabTemplateMappingCreatedUserID,
|
||||
NonlabTemplateMappingIsActive) VALUES(?,?,NOW(),?,'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, [$nonlabtemplate_id, $test_id, $userid]);
|
||||
if (!$qry_insert) {
|
||||
$this->sys_error_db("nonlab_template_mapping test insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
879
application/controllers/cpone/masterdata/Nonlabtemplatev3.php
Normal file
879
application/controllers/cpone/masterdata/Nonlabtemplatev3.php
Normal file
@@ -0,0 +1,879 @@
|
||||
<?php
|
||||
class Nonlabtemplatev3 extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NON LAN TEMPLATE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_tot = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)";
|
||||
$qry_tot = $this->db->query($sql_tot, [$search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_tot) {
|
||||
$tot_count = $qry_tot->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateID,
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateIsActive,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateLastUpdated
|
||||
FROM nonlab_template
|
||||
WHERE NonlabTemplateIsActive = 'Y'
|
||||
AND (NonlabTemplateName LIKE ?)
|
||||
ORDER BY NonlabTemplateID ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_template(
|
||||
NonlabTemplateName,
|
||||
NonlabTemplateFlagOther,
|
||||
NonlabTemplateCreated,
|
||||
NonlabTemplateCreatedUserID,
|
||||
NonlabTemplateLastUpdated,
|
||||
NonlabTemplateLastUpdatedUserID
|
||||
) VALUES(?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$name,
|
||||
$isfisik,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editnonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
$isfisik = "";
|
||||
if (isset($prm["isfisik"])) {
|
||||
$isfisik = trim($prm["isfisik"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateName = ?,
|
||||
NonlabTemplateFlagOther = ?,
|
||||
NonlabTemplateLastUpdated = NOW(),
|
||||
NonlabTemplateLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($name, $isfisik, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletenonlab()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template
|
||||
SET NonlabTemplateIsActive = 'N',
|
||||
NonlabTemplateDelete = NOW(),
|
||||
NonlabTemplateDeleteUserID = ?
|
||||
WHERE NonlabTemplateID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabID = $prm["nonlabID"];
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_total = "SELECT COUNT(*) as total
|
||||
FROM nonlab_template_detail
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$nonlabID, $search, $search]);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template detail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
NonlabTemplateDetailID,
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailGender,
|
||||
CASE
|
||||
WHEN NonlabTemplateDetailGender = 'male' THEN 'Laki-laki'
|
||||
WHEN NonlabTemplateDetailGender = 'female' THEN 'Perempuan'
|
||||
ELSE 'Semua'
|
||||
END AS NonlabTemplateDetailGenderText,
|
||||
NonlabTemplateDetailName,
|
||||
IFNULL(NonlabTemplateDetailLangName, NonlabTemplateDetailName) AS NonlabTemplateDetailNameLangEng,
|
||||
NonlabTemplateDetaiNat_UnitID as unit_id,
|
||||
unit.Nat_UnitName as unit_name,
|
||||
IFNULL(NonlabTemplateDetailLangNat_UnitID,0) as unit_eng_id,
|
||||
uniteng.Nat_UnitName AS unit_eng_name,
|
||||
NonlabTemplateDetailFlagActive,
|
||||
NonlabTemplateDetaiM_LangID,
|
||||
NonlabTemplateDetailIsActive
|
||||
FROM nonlab_template_detail
|
||||
LEFT JOIN nonlab_template_detail_lang ON NonlabTemplateDetailLangNonlabTemplateDetailID = NonlabTemplateDetailID AND
|
||||
NonlabTemplateDetailLangM_LangID = '2' AND NonlabTemplateDetailLangIsActive = 'Y'
|
||||
LEFT JOIN nat_unit unit ON unit.Nat_UnitID = NonlabTemplateDetaiNat_UnitID AND unit.Nat_UnitIsActive = 'Y'
|
||||
LEFT JOIN nat_unit uniteng ON uniteng.Nat_UnitID = NonlabTemplateDetailLangNat_UnitID AND uniteng.Nat_UnitIsActive = 'Y'
|
||||
WHERE NonlabTemplateDetailNonlabTemplateID = ?
|
||||
AND NonlabTemplateDetailIsActive = 'Y'
|
||||
AND (NonlabTemplateDetailCode LIKE ? OR NonlabTemplateDetailName LIKE ?)
|
||||
limit ? offset ?";
|
||||
$qry = $this->db->query($sql, [$nonlabID, $search, $search, $number_limit, $number_offset]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("select nonlab template detail", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total_filter" => $tot_count,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getunits()
|
||||
{
|
||||
try {
|
||||
$rst = array(
|
||||
array('id' => '0', 'value' => 'Tanpa Satuan'),
|
||||
);
|
||||
$sql = "SELECT Nat_UnitID, Nat_UnitName FROM nat_unit WHERE Nat_UnitIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $row) {
|
||||
$rst[] = array('id' => $row['Nat_UnitID'], 'value' => $row['Nat_UnitName']);
|
||||
}
|
||||
$this->sys_ok($rst);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function adddetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$nonlabid = intval($prm["nonlabid"]);
|
||||
|
||||
if ($nonlabid === 0) {
|
||||
$this->sys_error("Anda belum memilih nonlab template, silahkan pilih nonlab template dulu");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
if($name == ""){
|
||||
$this->sys_error("Anda belum mengisi nama");
|
||||
exit;
|
||||
}
|
||||
|
||||
$name_eng = "";
|
||||
if (isset($prm["name_eng"])) {
|
||||
$name_eng = trim($prm["name_eng"]);
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
if($code == ""){
|
||||
$this->sys_error("Anda belum mengisi kode");
|
||||
exit;
|
||||
}
|
||||
|
||||
$gender = "";
|
||||
if (isset($prm["gender"])) {
|
||||
$gender = trim($prm["gender"]);
|
||||
}
|
||||
if($gender == ""){
|
||||
$this->sys_error("Anda belum mengisi gender");
|
||||
exit;
|
||||
}
|
||||
|
||||
$unit = "";
|
||||
if (isset($prm["unit"])) {
|
||||
$unit = trim($prm["unit"]);
|
||||
}
|
||||
|
||||
$uniteng = "";
|
||||
if (isset($prm["uniteng"])) {
|
||||
$uniteng = trim($prm["uniteng"]);
|
||||
}
|
||||
// $nonlabid = "";
|
||||
// if (isset($prm["nonlabid"])) {
|
||||
// $nonlabid = trim($prm["nonlabid"]);
|
||||
// }
|
||||
|
||||
$sql = "INSERT INTO nonlab_template_detail(
|
||||
NonlabTemplateDetailNonlabTemplateID,
|
||||
NonlabTemplateDetailGender,
|
||||
NonlabTemplateDetaiNat_UnitID,
|
||||
NonlabTemplateDetailCode,
|
||||
NonlabTemplateDetailName,
|
||||
NonlabTemplateDetailCreated,
|
||||
NonlabTemplateDetailCreatedUserID,
|
||||
NonlabTemplateDetailLastUpdated,
|
||||
NonlabTemplateDetailLastUpdatedUserID
|
||||
) VALUES(?,?,?,?,?,NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$nonlabid,
|
||||
$gender,
|
||||
$unit,
|
||||
$code,
|
||||
$name,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $this->db->insert_id();
|
||||
|
||||
$sql_lang = "INSERT INTO nonlab_template_detail_lang(
|
||||
NonlabTemplateDetailLangNonlabTemplateDetailID,
|
||||
NonlabTemplateDetailLangGender,
|
||||
NonlabTemplateDetailLangM_LangID,
|
||||
NonlabTemplateDetailLangName,
|
||||
NonlabTemplateDetailLangNat_UnitID,
|
||||
NonlabTemplateDetailLangCreated,
|
||||
NonlabTemplateDetailLangCreatedUserID,
|
||||
NonlabTemplateDetailLangLastUpdated,
|
||||
NonlabTemplateDetailLangLastUpdatedUserID
|
||||
) VALUES(?,?,?,?,?,NOW(),?,NOW(),?)";
|
||||
$qry_lang = $this->db->query($sql_lang, array(
|
||||
$last_id,
|
||||
$gender,
|
||||
"2",
|
||||
$name_eng,
|
||||
$uniteng,
|
||||
$userid,
|
||||
$userid
|
||||
));
|
||||
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletedetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailIsActive = 'N',
|
||||
NonlabTemplateDetailDelete = NOW(),
|
||||
NonlabTemplateDetailDeleteUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveeditflag()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$flagstatus = $prm['flagstatus'];
|
||||
$templatedetailid = $prm['templatedetailid'];
|
||||
|
||||
if ($flagstatus == "Y") {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'Y',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE nonlab_template_detail
|
||||
SET NonlabTemplateDetailFlagActive = 'N',
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$templatedetailid
|
||||
));
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail no avtive", $this->db);
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_commit();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$name = "";
|
||||
if (isset($prm["name"])) {
|
||||
$name = trim($prm["name"]);
|
||||
}
|
||||
if($name == ""){
|
||||
$this->sys_error("Anda belum mengisi nama");
|
||||
exit;
|
||||
}
|
||||
$name_eng = "";
|
||||
if (isset($prm["name_eng"])) {
|
||||
$name_eng = trim($prm["name_eng"]);
|
||||
}
|
||||
if($name_eng == ""){
|
||||
$this->sys_error("Anda belum mengisi nama inggris");
|
||||
exit;
|
||||
}
|
||||
$code = "";
|
||||
if (isset($prm["code"])) {
|
||||
$code = trim($prm["code"]);
|
||||
}
|
||||
if($code == ""){
|
||||
$this->sys_error("Anda belum mengisi kode");
|
||||
exit;
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
$gender = "";
|
||||
if (isset($prm["gender"])) {
|
||||
$gender = trim($prm["gender"]);
|
||||
}
|
||||
if($gender == ""){
|
||||
$this->sys_error("Anda belum mengisi gender");
|
||||
exit;
|
||||
}
|
||||
$unit = "";
|
||||
if (isset($prm["unit"])) {
|
||||
$unit = trim($prm["unit"]);
|
||||
}
|
||||
|
||||
$uniteng = "";
|
||||
if (isset($prm["uniteng"])) {
|
||||
$uniteng = trim($prm["uniteng"]);
|
||||
}
|
||||
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail SET
|
||||
NonlabTemplateDetailGender = ?,
|
||||
NonlabTemplateDetaiNat_UnitID = ?,
|
||||
NonlabTemplateDetailCode = ?,
|
||||
NonlabTemplateDetailName = ?,
|
||||
NonlabTemplateDetailLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($gender, $unit, $code, $name, $userid, $id));
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$error = array(
|
||||
"message" => $this->db->error()["message"],
|
||||
"sql" => $last_qry
|
||||
);
|
||||
$this->sys_error_db($error, $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT NonlabTemplateDetailLangID
|
||||
FROM nonlab_template_detail_lang
|
||||
WHERE
|
||||
NonlabTemplateDetailLangNonlabTemplateDetailID = ?
|
||||
AND NonlabTemplateDetailLangM_LangID = '2' AND
|
||||
NonlabTemplateDetailLangIsActive = 'Y'
|
||||
";
|
||||
$qry = $this->db->query($sql, array($id));
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail lang", $this->db);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0) {
|
||||
$langid = $rows[0]["NonlabTemplateDetailLangID"];
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_template_detail_lang SET
|
||||
NonlabTemplateDetailLangGender = ?,
|
||||
NonlabTemplateDetailLangNat_UnitID = ?,
|
||||
NonlabTemplateDetailLangName = ?,
|
||||
NonlabTemplateDetailLangLastUpdated = NOW(),
|
||||
NonlabTemplateDetailLangLastUpdatedUserID = ?
|
||||
WHERE NonlabTemplateDetailLangID = ?";
|
||||
$qry = $this->db->query($sql, array($gender, $uniteng, $name_eng, $userid, $langid));
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab template detail lang", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$this->db->trans_commit();
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function lookuptest()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = "";
|
||||
if (isset($prm["search"])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = "%" . $prm["search"] . "%";
|
||||
} else {
|
||||
$search = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$nonlabtemplate_id = 0;
|
||||
if (isset($prm['nonlabtemplate_id'])) {
|
||||
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
||||
}
|
||||
$status = $prm['status'];
|
||||
$filter = '';
|
||||
if ($status == 'Y') {
|
||||
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NOT NULL ";
|
||||
} else {
|
||||
if ($status == 'N') {
|
||||
$filter .= "AND ntm.NonlabTemplateMappingNonlabTemplateID IS NULL ";
|
||||
} else {
|
||||
$filter .= "";
|
||||
}
|
||||
}
|
||||
|
||||
$number_offset = 0;
|
||||
$number_limit = 10;
|
||||
if ($prm["current_page"] > 0) {
|
||||
$number_offset = ($prm["current_page"] - 1) * $number_limit;
|
||||
}
|
||||
|
||||
$sql_dasar = "SELECT
|
||||
n.Nat_TestID,
|
||||
IF(ntm.NonlabTemplateMappingNonlabTemplateID IS NULL, 'N', 'Y') AS status,
|
||||
ntm.NonlabTemplateMappingNat_TestID,
|
||||
n.Nat_TestCode,
|
||||
n.Nat_TestName,
|
||||
n.Nat_TestShortName
|
||||
FROM nat_test as n
|
||||
LEFT JOIN nonlab_template_mapping as ntm ON n.Nat_TestID = ntm.NonlabTemplateMappingNat_TestID
|
||||
AND ntm.NonlabTemplateMappingIsActive = 'Y'
|
||||
LEFT JOIN nonlab_template as nt ON ntm.NonlabTemplateMappingNonlabTemplateID = nt.NonlabTemplateID
|
||||
AND nt.NonlabTemplateIsActive = 'Y'
|
||||
WHERE n.Nat_TestIsActive = 'Y'
|
||||
AND n.Nat_TestIsNonLab <> ''
|
||||
AND n.Nat_TestIsResult = 'Y'
|
||||
AND (n.Nat_TestCode LIKE '{$search}' OR n.Nat_TestName LIKE '{$search}')
|
||||
AND (nt.NonlabTemplateID = {$nonlabtemplate_id} OR nt.NonlabTemplateID IS NULL)
|
||||
$filter";
|
||||
|
||||
$qry_filter = "SELECT COUNT(*) as total FROM ($sql_dasar) as x";
|
||||
|
||||
$qry_filter = $this->db->query($qry_filter);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($qry_filter) {
|
||||
$tot_count = $qry_filter->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("test count error", $this->db);
|
||||
}
|
||||
|
||||
$sql = $sql_dasar . " ORDER BY n.Nat_TestCode LIMIT $number_limit OFFSET $number_offset";
|
||||
|
||||
$qry = $this->db->query($sql);
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows,
|
||||
"sql" => $this->db->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveedittestmap()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$nonlabtemplate_id = 0;
|
||||
if (isset($prm['nonlabtemplate_id'])) {
|
||||
$nonlabtemplate_id = trim($prm["nonlabtemplate_id"]);
|
||||
}
|
||||
$test_id = 0;
|
||||
if (isset($prm['test_id'])) {
|
||||
$test_id = trim($prm["test_id"]);
|
||||
}
|
||||
|
||||
$status = $prm["status"];
|
||||
|
||||
$sql = "SELECT NonlabTemplateMappingID,
|
||||
NonlabTemplateMappingNonlabTemplateID,
|
||||
NonlabTemplateMappingNat_TestID
|
||||
FROM nonlab_template_mapping
|
||||
WHERE NonlabTemplateMappingNonlabTemplateID = ?
|
||||
AND NonlabTemplateMappingNat_TestID = ?";
|
||||
$qry = $this->db->query($sql, [$nonlabtemplate_id, $test_id]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$nonlabtemplatemapid = $rows[0]["NonlabTemplateMappingID"];
|
||||
$sql_update = "UPDATE nonlab_template_mapping SET
|
||||
NonlabTemplateMappingLastUpdated = NOW(),
|
||||
NonlabTemplateMappingLastUpdatedUserID = ?,
|
||||
NonlabTemplateMappingDeleted = NOW(),
|
||||
NonlabTemplateMappingIsActive = ?
|
||||
WHERE NonlabTemplateMappingID = ?";
|
||||
$qry_update = $this->db->query($sql_update, [$userid, $status, $nonlabtemplatemapid]);
|
||||
if (!$qry_update) {
|
||||
$this->sys_error_db("map test update", $this->db);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql_insert = "INSERT INTO nonlab_template_mapping(
|
||||
NonlabTemplateMappingNonlabTemplateID,
|
||||
NonlabTemplateMappingNat_TestID,
|
||||
NonlabTemplateMappingCreated,
|
||||
NonlabTemplateMappingCreatedUserID,
|
||||
NonlabTemplateMappingIsActive) VALUES(?,?,NOW(),?,'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, [$nonlabtemplate_id, $test_id, $userid]);
|
||||
if (!$qry_insert) {
|
||||
$this->sys_error_db("nonlab_template_mapping test insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
1028
application/controllers/cpone/masterdata/Requirement.php
Normal file
1028
application/controllers/cpone/masterdata/Requirement.php
Normal file
File diff suppressed because it is too large
Load Diff
924
application/controllers/cpone/mcuoffline/Packetcpone.php
Normal file
924
application/controllers/cpone/mcuoffline/Packetcpone.php
Normal file
@@ -0,0 +1,924 @@
|
||||
<?php
|
||||
class Packetcpone extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function savesetupv0()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$T_PacketName = strtoupper($prm['namapacket']);
|
||||
$T_PriceHeaderID = $prm['priceheader']['T_PriceHeaderID'];
|
||||
$T_PacketType = $prm['jenispacket'];
|
||||
$T_PacketPrice = $prm['T_PacketPrice'];
|
||||
$T_PacketOriginalPrice = $prm['T_PacketOriginalPrice'];
|
||||
$T_PacketSasCode = "";
|
||||
$T_PacketOriginalBruto = 0;
|
||||
$detail_packet = $prm['detailpacket'];
|
||||
// $act = $prm['act'];
|
||||
|
||||
if($prm["act"] == 'new'){
|
||||
// check paket exists or not
|
||||
$sqlCheck = "SELECT *
|
||||
FROM t_packet
|
||||
WHERE T_PacketIsActive = 'Y'
|
||||
AND T_PacketName = '$T_PacketName'";
|
||||
|
||||
$qryCheck = $this->db_onedev->query($sqlCheck);
|
||||
|
||||
if(!$qryCheck){
|
||||
$this->sys_error_db("t_packet check", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowCheck = $qryCheck->result_array();
|
||||
|
||||
if(count($rowCheck) > 0){
|
||||
$this->sys_error("Data dengan nama paket ".$T_PacketName." Sudah Ada");
|
||||
exit;
|
||||
} else {
|
||||
// get numbering
|
||||
$sql_get_numbering = "SELECT fn_numbering_cpone('PC') as numberx";
|
||||
$qry_get_numbering = $this->db_onedev->query($sql_get_numbering);
|
||||
if(!$qry_get_numbering){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("packet numbering cpone", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data_numbering = $qry_get_numbering->result_array();
|
||||
|
||||
$T_PacketSasCode = $data_numbering[0]['numberx'];
|
||||
|
||||
// insert t_packet
|
||||
$sql_insert = "INSERT INTO t_packet
|
||||
(
|
||||
T_PacketT_PriceHeaderID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketPrice,
|
||||
T_PacketOriginalPrice,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsActive,
|
||||
T_PacketCreated,
|
||||
T_PacketOriginalBruto
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
$T_PriceHeaderID, -- T_PacketT_PriceHeaderID
|
||||
'$T_PacketType', -- T_PacketType (assuming 'PR' for Profile)
|
||||
'$T_PacketName', -- T_PacketName
|
||||
$T_PacketPrice, -- T_PacketPrice
|
||||
$T_PacketOriginalPrice, -- T_PacketOriginalPrice
|
||||
'$T_PacketSasCode', -- T_PacketSasCode
|
||||
'Y', -- T_PacketIsActive
|
||||
NOW(), -- T_PacketCreated
|
||||
$T_PacketOriginalBruto -- T_PacketOriginalBruto (can be NULL)
|
||||
)";
|
||||
|
||||
$qryInsert = $this->db_onedev->query($sql_insert);
|
||||
if(!$qryInsert){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packet insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
// insert t_packetdetail
|
||||
if(count($detail_packet) > 0) {
|
||||
foreach($detail_packet as $k => $v){
|
||||
$T_PriceTotalPacket = $v['T_PriceTotalPacket'];
|
||||
|
||||
// bisa berubah ubah kalau PN
|
||||
if($T_PacketType == "PN"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $T_PriceTotalPacket;
|
||||
}
|
||||
|
||||
if($T_PacketType == "PR"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $v['T_PriceTotal'];
|
||||
}
|
||||
|
||||
$T_PacketDetailPriceAmount = 0;
|
||||
$T_PacketDetailPriceDisc = 0;
|
||||
$T_PacketDetailPriceDiscRp = 0;
|
||||
$T_PacketDetailPriceSubTotal = 0;
|
||||
|
||||
if(!empty($v['T_PriceAmount'])){
|
||||
$T_PacketDetailPriceAmount = $v['T_PriceAmount'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDisc'])){
|
||||
$T_PacketDetailPriceDisc = $v['T_PriceDisc'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDiscRp'])){
|
||||
$T_PacketDetailPriceDiscRp = $v['T_PriceDiscRp'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceSubTotal'])){
|
||||
$T_PacketDetailPriceSubTotal = $v['T_PriceSubTotal'];
|
||||
}
|
||||
|
||||
$sql_insert_detail = "INSERT INTO t_packetdetail
|
||||
(
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice,
|
||||
T_PacketDetailPrice,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal
|
||||
) VALUES (
|
||||
$last_id, -- T_PacketDetailT_PacketID
|
||||
{$v['T_TestID']}, -- T_PacketDetailT_TestID
|
||||
{$T_PacketDetailOriginalPrice}, -- T_PacketDetailOriginalPrice
|
||||
{$T_PacketDetailPrice}, -- T_PacketDetailPrice
|
||||
'Y', -- T_PacketDetailIsActive
|
||||
NOW(), -- T_PacketDetailCreated
|
||||
{$T_PacketDetailPriceAmount}, -- T_PacketDetailPriceAmount
|
||||
{$T_PacketDetailPriceDisc}, -- T_PacketDetailPriceDisc
|
||||
{$T_PacketDetailPriceDiscRp}, -- T_PacketDetailPriceDiscRp
|
||||
{$T_PacketDetailPriceSubTotal} -- T_PacketDetailPriceSubTotal
|
||||
)";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_insert_detail);
|
||||
if(!$qry_detail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT T_PacketName as xnumber
|
||||
FROM t_packet
|
||||
WHERE T_PacketID = {$last_id}";
|
||||
|
||||
//echo $sql;
|
||||
$row = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $row,
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
} else{
|
||||
// check paket exists or not
|
||||
$sqlCheck = "SELECT *
|
||||
FROM t_packet
|
||||
WHERE T_PacketIsActive = 'Y'
|
||||
AND T_PacketName = '$T_PacketName'
|
||||
AND T_PacketID <> {$prm["xid"]}";
|
||||
|
||||
$qryCheck = $this->db_onedev->query($sqlCheck);
|
||||
|
||||
if(!$qryCheck){
|
||||
$this->sys_error_db("t_packet check", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowCheck = $qryCheck->result_array();
|
||||
if(count($rowCheck) > 0){
|
||||
// echo $sqlCheck;
|
||||
// exit;
|
||||
$this->sys_error("Data dengan nama paket ".$T_PacketName." Sudah Ada");
|
||||
exit;
|
||||
} else {
|
||||
// update t_packet
|
||||
$sql_update = "UPDATE t_packet
|
||||
SET
|
||||
T_PacketT_PriceHeaderID = $T_PriceHeaderID,
|
||||
T_PacketType = '$T_PacketType',
|
||||
T_PacketName = '$T_PacketName',
|
||||
T_PacketPrice = $T_PacketPrice,
|
||||
T_PacketOriginalPrice = $T_PacketOriginalPrice,
|
||||
T_PacketIsActive = 'Y',
|
||||
T_PacketLastUpdated = NOW(),
|
||||
T_PacketOriginalBruto = $T_PacketOriginalBruto
|
||||
WHERE
|
||||
T_PacketID = {$prm["xid"]}";
|
||||
|
||||
$qryUpdate = $this->db_onedev->query($sql_update);
|
||||
if(!$qryUpdate){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("error t_packet update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $prm["xid"];
|
||||
|
||||
// // update detail packet
|
||||
// // update isActive N kan semua
|
||||
$sqlUpdatePacket = "UPDATE t_packetdetail
|
||||
SET
|
||||
T_PacketDetailIsActive = 'N',
|
||||
T_PacketDetailLastUpdated = NOW()
|
||||
WHERE T_PacketDetailT_PacketID = $last_id";
|
||||
|
||||
// echo $sqlUpdatePacket;
|
||||
|
||||
$qry_mgm_update_tpacketdetails = $this->db_onedev->query($sqlUpdatePacket);
|
||||
if(!$qry_mgm_update_tpacketdetails){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// insert t_packetdetail
|
||||
if(count($detail_packet) > 0) {
|
||||
foreach($detail_packet as $k => $v){
|
||||
$T_PriceTotalPacket = $v['T_PriceTotalPacket'];
|
||||
|
||||
// bisa berubah ubah kalau PN
|
||||
if($T_PacketType == "PN"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $T_PriceTotalPacket;
|
||||
}
|
||||
|
||||
if($T_PacketType == "PR"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $v['T_PriceTotal'];
|
||||
}
|
||||
|
||||
$T_PacketDetailPriceAmount = 0;
|
||||
$T_PacketDetailPriceDisc = 0;
|
||||
$T_PacketDetailPriceDiscRp = 0;
|
||||
$T_PacketDetailPriceSubTotal = 0;
|
||||
|
||||
if(!empty($v['T_PriceAmount'])){
|
||||
$T_PacketDetailPriceAmount = $v['T_PriceAmount'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDisc'])){
|
||||
$T_PacketDetailPriceDisc = $v['T_PriceDisc'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDiscRp'])){
|
||||
$T_PacketDetailPriceDiscRp = $v['T_PriceDiscRp'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceSubTotal'])){
|
||||
$T_PacketDetailPriceSubTotal = $v['T_PriceSubTotal'];
|
||||
}
|
||||
|
||||
$sql_insert_detail = "INSERT INTO t_packetdetail
|
||||
(
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice,
|
||||
T_PacketDetailPrice,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal
|
||||
) VALUES (
|
||||
$last_id, -- T_PacketDetailT_PacketID
|
||||
{$v['T_TestID']}, -- T_PacketDetailT_TestID
|
||||
{$T_PacketDetailOriginalPrice}, -- T_PacketDetailOriginalPrice
|
||||
{$T_PacketDetailPrice}, -- T_PacketDetailPrice
|
||||
'Y', -- T_PacketDetailIsActive
|
||||
NOW(), -- T_PacketDetailCreated
|
||||
{$T_PacketDetailPriceAmount}, -- T_PacketDetailPriceAmount
|
||||
{$T_PacketDetailPriceDisc}, -- T_PacketDetailPriceDisc
|
||||
{$T_PacketDetailPriceDiscRp}, -- T_PacketDetailPriceDiscRp
|
||||
{$T_PacketDetailPriceSubTotal} -- T_PacketDetailPriceSubTotal
|
||||
)";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_insert_detail);
|
||||
if(!$qry_detail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT T_PacketName as xnumber
|
||||
FROM t_packet
|
||||
WHERE T_PacketID = {$last_id}";
|
||||
|
||||
//echo $sql;
|
||||
$row = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $row,
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletev0(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// packet
|
||||
$query_t_packet = $this->db_onedev->query("UPDATE t_packet SET
|
||||
T_PacketIsActive = 'N',
|
||||
T_PacketLastUpdated = NOW()
|
||||
WHERE
|
||||
T_PacketID = '{$prm['id']}'
|
||||
");
|
||||
|
||||
if (!$query_t_packet) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packet update error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// packet details
|
||||
$query_t_packetdetail = $this->db_onedev->query("UPDATE t_packetdetail SET
|
||||
T_PacketDetailIsActive = 'N',
|
||||
T_PacketDetailLastUpdated = NOW()
|
||||
WHERE
|
||||
T_PacketDetailT_PacketID = '{$prm['id']}'
|
||||
");
|
||||
|
||||
if (!$query_t_packetdetail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail update error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $rows = $this->db_onedev->query($query_mgmmcu);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getTTestByTPriceHeaderCurrent()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// $search_kode = $prm['searchKode'];
|
||||
// $search_nama = $prm['searchNama'];
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
|
||||
$natsubgroup = "";
|
||||
$sql_where_natsubgroup = "";
|
||||
|
||||
if(isset($prm['natsubgroup']) && !empty($prm['natsubgroup']) && $prm['natsubgroup'] != "All"){
|
||||
$natsubgroup = $prm['natsubgroup'];
|
||||
$sql_where_natsubgroup = " AND Nat_SubGroupID = $natsubgroup";
|
||||
}
|
||||
|
||||
// if($natsubgroup != "All"){
|
||||
// $sql_where_natsubgroup = " AND Nat_SubGroupID = $natsubgroup";
|
||||
// }
|
||||
|
||||
$tpriceheader = $prm['tpriceheader'];
|
||||
$sql_where_tpriceheader = "";
|
||||
|
||||
if(isset($prm['tpriceheader']) && !empty($prm['tpriceheader'])){
|
||||
$sql_where_tpriceheader = " AND ph.T_PriceHeaderID = $tpriceheader";
|
||||
}
|
||||
|
||||
$sqlSearch = "T_TestName LIKE '%%' AND T_TestCode LIKE '%%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
|
||||
if(isset($prm['searchKode']) && !empty($prm['searchKode'])){
|
||||
$sqlSearch = " T_TestCode LIKE '%{$prm['searchKode']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
if(isset($prm['searchNama']) && !empty($prm['searchNama'])){
|
||||
$sqlSearch = " T_TestName LIKE '%{$prm['searchNama']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
if(
|
||||
((isset($prm['searchKode']) && !empty($prm['searchKode'])))
|
||||
&& (isset($prm['searchNama']) && !empty($prm['searchNama']))
|
||||
){
|
||||
$sqlSearch = " T_TestName LIKE '%{$prm['searchNama']}%' AND T_TestCode LIKE '%{$prm['searchKode']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
$sql_where = "
|
||||
WHERE (
|
||||
".$sqlSearch."
|
||||
)";
|
||||
|
||||
|
||||
|
||||
// $sql_where = "
|
||||
// WHERE (
|
||||
// T_TestCode LIKE '%{$prm['searchKode']}%'
|
||||
// OR T_TestName LIKE '%{$prm['searchNama']}%'
|
||||
// )";
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
IFNULL(p.T_PriceID, 0) AS T_PriceID
|
||||
FROM
|
||||
t_price p
|
||||
JOIN
|
||||
t_priceheader ph
|
||||
ON
|
||||
p.T_PriceT_PriceHeaderID = ph.T_PriceHeaderID
|
||||
AND p.T_PriceIsActive = 'Y'
|
||||
AND ph.T_PriceHeaderIsActive = 'Y'
|
||||
JOIN
|
||||
t_test testx
|
||||
ON p.T_PriceT_TestID = testx.T_TestID
|
||||
AND testx.T_TestIsActive = 'Y'
|
||||
LEFT JOIN nat_subgroup
|
||||
ON T_TestNat_SubgroupID = Nat_SubgroupID
|
||||
AND Nat_SubGroupIsActive = 'Y'
|
||||
$sql_where
|
||||
) x";
|
||||
|
||||
$sql_param = array();
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("tprice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT
|
||||
ROW_NUMBER() OVER (ORDER BY T_PriceID) AS RowNum,
|
||||
IFNULL(p.T_PriceTotal, 0) AS T_PriceTotalPacket,
|
||||
IFNULL(p.T_PriceID, 0) AS T_PriceID,
|
||||
IFNULL(p.T_PriceT_PriceHeaderID, 0) AS T_PriceT_PriceHeaderID,
|
||||
IFNULL(p.T_PriceT_TestID, 0) AS T_PriceT_TestID,
|
||||
IFNULL(p.T_PriceIsCito, 'N') AS T_PriceIsCito,
|
||||
IFNULL(p.T_PricePriority, 1) AS T_PricePriority,
|
||||
IFNULL(p.T_PriceAmount, 0) AS T_PriceAmount,
|
||||
IFNULL(p.T_PriceDisc, 0) AS T_PriceDisc,
|
||||
IFNULL(p.T_PriceDiscRp, 0) AS T_PriceDiscRp,
|
||||
IFNULL(p.T_PriceSubTotal, 0) AS T_PriceSubTotal,
|
||||
IFNULL(p.T_PriceOther, 0) AS T_PriceOther,
|
||||
IFNULL(p.T_PriceTotal, 0) AS T_PriceTotal,
|
||||
IFNULL(p.T_PriceIsActive, 'Y') AS T_PriceIsActive,
|
||||
IFNULL(p.T_PriceCreated, '0000-00-00') AS T_PriceCreated,
|
||||
IFNULL(p.T_PriceLastUpdated, '0000-00-00') AS T_PriceLastUpdated,
|
||||
IFNULL(p.T_PriceUserID, 0) AS T_PriceUserID,
|
||||
IFNULL(ph.T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
||||
IFNULL(ph.T_PriceHeaderName, '') AS T_PriceHeaderName,
|
||||
IFNULL(ph.T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
||||
IFNULL(ph.T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
||||
IFNULL(ph.T_PriceHeaderIsActive, 'Y') AS T_PriceHeaderIsActive,
|
||||
IFNULL(ph.T_PriceHeaderUserID, 0) AS T_PriceHeaderUserID,
|
||||
IFNULL(ph.T_PriceHeaderCreated, '0000-00-00 00:00:00') AS T_PriceHeaderCreated,
|
||||
IFNULL(ph.T_PriceHeaderCraetdUserID, 0) AS T_PriceHeaderCraetdUserID,
|
||||
IFNULL(ph.T_PriceHeaderLastUpdated, '0000-00-00 00:00:00') AS T_PriceHeaderLastUpdated,
|
||||
IFNULL(ph.T_PriceHeaderLastUpdatedUserID, 0) AS T_PriceHeaderLastUpdatedUserID,
|
||||
IFNULL(ph.T_PriceHeaderDeleted, '0000-00-00 00:00:00') AS T_PriceHeaderDeleted,
|
||||
IFNULL(ph.T_PriceHeaderDeletedUserID, 0) AS T_PriceHeaderDeletedUserID,
|
||||
IFNULL(testx.T_TestID, 0) AS T_TestID,
|
||||
IFNULL(testx.T_TestCode, '') AS T_TestCode,
|
||||
IFNULL(testx.T_TestName, '') AS T_TestName
|
||||
FROM
|
||||
t_price p
|
||||
JOIN
|
||||
t_priceheader ph
|
||||
ON
|
||||
p.T_PriceT_PriceHeaderID = ph.T_PriceHeaderID
|
||||
AND p.T_PriceIsActive = 'Y'
|
||||
AND ph.T_PriceHeaderIsActive = 'Y'
|
||||
JOIN
|
||||
t_test testx
|
||||
ON p.T_PriceT_TestID = testx.T_TestID
|
||||
AND testx.T_TestIsActive = 'Y'
|
||||
LEFT JOIN nat_subgroup
|
||||
ON T_TestNat_SubgroupID = Nat_SubgroupID
|
||||
AND Nat_SubGroupIsActive = 'Y'
|
||||
$sql_where
|
||||
ORDER BY p.T_PriceID DESC
|
||||
limit $number_limit offset $number_offset
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
if ($query === false) {
|
||||
// If query failed, log the error and exit
|
||||
$this->sys_error_db("select t_price data", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getTPriceHeader()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_priceheader
|
||||
WHERE T_PriceHeaderIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("t_priceheader select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$new_entry = array(
|
||||
'T_PriceHeaderID' => 'All',
|
||||
'T_PriceHeaderName' => 'All',
|
||||
'T_PriceHeaderStartDate' => "",
|
||||
'T_PriceHeaderEndDate' => "",
|
||||
'T_PriceHeaderIsActive' => "",
|
||||
'T_PriceHeaderUserID' => "",
|
||||
'T_PriceHeaderCreated' => "",
|
||||
'T_PriceHeaderCraetdUserID' => "",
|
||||
'T_PriceHeaderLastUpdated' => "",
|
||||
'T_PriceHeaderLastUpdatedUserID' => "",
|
||||
'T_PriceHeaderDeleted' => "",
|
||||
'T_PriceHeaderDeletedUserID' => ""
|
||||
);
|
||||
|
||||
array_unshift($rows, $new_entry);
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getTPriceHeaderCurrent()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
IFNULL(T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
||||
IFNULL(T_PriceHeaderName, '') AS T_PriceHeaderName,
|
||||
IFNULL(T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
||||
IFNULL(T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
||||
IFNULL(T_PriceHeaderIsActive, 'Y') AS T_PriceHeaderIsActive,
|
||||
IFNULL(T_PriceHeaderUserID, 0) AS T_PriceHeaderUserID,
|
||||
IFNULL(T_PriceHeaderCreated, '0000-00-00 00:00:00') AS T_PriceHeaderCreated,
|
||||
IFNULL(T_PriceHeaderCraetdUserID, 0) AS T_PriceHeaderCraetdUserID,
|
||||
IFNULL(T_PriceHeaderLastUpdated, '0000-00-00 00:00:00') AS T_PriceHeaderLastUpdated,
|
||||
IFNULL(T_PriceHeaderLastUpdatedUserID, 0) AS T_PriceHeaderLastUpdatedUserID,
|
||||
IFNULL(T_PriceHeaderDeleted, '0000-00-00 00:00:00') AS T_PriceHeaderDeleted,
|
||||
IFNULL(T_PriceHeaderDeletedUserID, 0) AS T_PriceHeaderDeletedUserID
|
||||
FROM
|
||||
t_priceheader
|
||||
WHERE T_PriceHeaderIsActive = 'Y'
|
||||
AND CURDATE() BETWEEN T_PriceHeaderStartDate AND T_PriceHeaderEndDate";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("t_priceheader select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function searchv0()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
// $search = $prm['search'];
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
// $limit = '';
|
||||
// $filter_paket = $prm['searchPacket'];
|
||||
// if($all == 'N'){
|
||||
// $limit = ' LIMIT 10';
|
||||
// }
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
// $sql_where = " (
|
||||
// T_PacketName LIKE '%{$prm['search']}%'
|
||||
// OR T_PacketType LIKE '%{$prm['search']}%'
|
||||
// ) AND T_PacketIsActive = 'Y'";
|
||||
|
||||
$sql_where_tpriceheader = "";
|
||||
$tpriceheader = "";
|
||||
|
||||
|
||||
if(isset($prm['tpriceheader'])){
|
||||
$tpriceheader = $prm['tpriceheader'];
|
||||
}
|
||||
|
||||
if($tpriceheader != "All"){
|
||||
$sql_where_tpriceheader = " AND T_PacketT_PriceHeaderID = $tpriceheader";
|
||||
}
|
||||
|
||||
$sql_where = " (
|
||||
T_PacketName LIKE '%{$prm['search']}%'
|
||||
) AND T_PacketIsActive = 'Y'
|
||||
$sql_where_tpriceheader";
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_packet
|
||||
WHERE $sql_where
|
||||
";
|
||||
|
||||
$sql_param = array();
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_packet count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT
|
||||
IFNULL(T_PacketID, 0) AS T_PacketID,
|
||||
IFNULL(T_PacketT_PriceHeaderID, 0) AS T_PacketT_PriceHeaderID,
|
||||
IFNULL(T_PacketType,'') AS T_PacketType,
|
||||
IFNULL(T_PacketName,'') AS T_PacketName,
|
||||
IFNULL(T_PacketPrice,0) AS T_PacketPrice,
|
||||
IFNULL(T_PacketOriginalPrice,0) AS T_PacketOriginalPrice,
|
||||
IFNULL(T_PacketSasCode,'') AS T_PacketSasCode,
|
||||
IFNULL(T_PacketIsActive,'') AS T_PacketIsActive,
|
||||
IFNULL(T_PacketCreated,'') AS T_PacketCreated,
|
||||
IFNULL(T_PacketLastUpdated,'') AS T_PacketLastUpdated
|
||||
FROM t_packet
|
||||
WHERE $sql_where
|
||||
GROUP BY T_PacketID
|
||||
ORDER BY T_PacketID DESC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
if ($query === false) {
|
||||
// If query failed, log the error and exit
|
||||
$this->sys_error_db("select t_packet data", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql"=> $this->db_onedev->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getPaketById()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $prm['T_PacketID'];
|
||||
|
||||
$sql_paket = "SELECT
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
T_PriceHeaderID,
|
||||
T_PriceHeaderName,
|
||||
T_PacketType,
|
||||
'' as detailpackets
|
||||
FROM t_packet
|
||||
JOIN t_priceheader
|
||||
ON T_PacketT_PriceHeaderID = T_PriceHeaderID
|
||||
AND T_PacketIsActive = 'Y'
|
||||
AND T_PriceHeaderIsActive = 'Y'
|
||||
AND T_PacketID = $id
|
||||
JOIN t_packetdetail
|
||||
ON T_PacketID = T_PacketDetailT_PacketID
|
||||
AND T_PacketDetailIsActive = 'Y'
|
||||
GROUP BY T_PacketID";
|
||||
|
||||
$qry = $this->db_onedev->query($sql_paket);
|
||||
if(!$qry){
|
||||
$this->sys_error_db("t_packet count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $key => $vx) {
|
||||
$sql_detail = "SELECT
|
||||
T_PacketDetailID,
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice as T_PriceTotal,
|
||||
T_PacketDetailPrice as T_PriceTotalPacket,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailLastUpdated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal,
|
||||
T_TestID,
|
||||
T_TestName
|
||||
FROM t_packetdetail
|
||||
JOIN t_test
|
||||
ON T_PacketDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
AND T_PacketDetailIsActive = 'Y'
|
||||
AND T_PacketDetailT_PacketID = $id";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_detail);
|
||||
if(!$qry_detail){
|
||||
$this->sys_error_db("t_packetdetail count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowdet = $qry_detail->result_array();
|
||||
$rows[$key]['sumhargaawal'] = 0;
|
||||
$rows[$key]['sumhargapaket'] = 0;
|
||||
$rows[$key]['detailpackets'] = $rowdet;
|
||||
|
||||
foreach($rowdet as $k => $vk){
|
||||
$rows[$key]['sumhargaawal'] += $vk['T_PriceTotal'];
|
||||
$rows[$key]['sumhargapaket'] += $vk['T_PriceTotalPacket'];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
$result = array(
|
||||
// "total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql"=> $this->db_onedev->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
public function getGroupPemeriksaan() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
Nat_SubGroupID,
|
||||
Nat_SubGroupNat_GroupID,
|
||||
Nat_SubGroupCode,
|
||||
Nat_SubGroupName,
|
||||
Nat_SubGroupLangName,
|
||||
Nat_SubGroupIsResult,
|
||||
Nat_SubGroupReportTitle,
|
||||
Nat_SubGroupCreated,
|
||||
Nat_SubGroupLastUpdated,
|
||||
Nat_SubGroupIsActive
|
||||
FROM
|
||||
nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nat_subgroup select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$new_entry = array(
|
||||
"Nat_SubGroupID" => "All",
|
||||
"Nat_SubGroupNat_GroupID" => "",
|
||||
"Nat_SubGroupCode" => "",
|
||||
"Nat_SubGroupName" => "All",
|
||||
"Nat_SubGroupLangName" => "",
|
||||
"Nat_SubGroupIsResult" => "",
|
||||
"Nat_SubGroupReportTitle" => "",
|
||||
"Nat_SubGroupCreated"=> "",
|
||||
"Nat_SubGroupLastUpdated"=> "",
|
||||
"Nat_SubGroupIsActive"=> ""
|
||||
);
|
||||
|
||||
array_unshift($rows, $new_entry);
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
62
application/controllers/cpone/mcuoffline/Preregister.http
Normal file
62
application/controllers/cpone/mcuoffline/Preregister.http
Normal file
@@ -0,0 +1,62 @@
|
||||
POST https://{{host}}/cpone/mcuoffline/preregister/index
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/mcuoffline/preregister/getmgmmcu
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/mcuoffline/preregister/savecsv
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"xid": "1",
|
||||
"corporateID": "1",
|
||||
"data": [
|
||||
{
|
||||
"PID": "23232333",
|
||||
"NAMA": "Yacoba",
|
||||
"TANGGAL_LAHIR": "5/12/95",
|
||||
"JENIS_KELAMIN": "L",
|
||||
"NIK": "13211313",
|
||||
"KTP": 3131323433444,
|
||||
"JABATAN": "IT",
|
||||
"EMAIL": "coba@gmail.com",
|
||||
"HP": "4536634666",
|
||||
"LOKASI": "Klodran",
|
||||
"JOB": "IT"
|
||||
},
|
||||
{
|
||||
"PID": "325452",
|
||||
"NAMA": "Coba",
|
||||
"TANGGAL_LAHIR": "5/2/99",
|
||||
"JENIS_KELAMIN": "P",
|
||||
"NIK": "445353",
|
||||
"KTP": 32424422444,
|
||||
"JABATAN": "Marketing",
|
||||
"EMAIL": "cobaa@gmail.com",
|
||||
"HP": "43242424",
|
||||
"LOKASI": "Solo",
|
||||
"JOB": "Marketing"
|
||||
}
|
||||
],
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
|
||||
###
|
||||
POST https://{{host}}/cpone/mcuoffline/preregister/search
|
||||
Content-Type: "application/json"
|
||||
|
||||
{
|
||||
"search":"",
|
||||
"current_page":1,
|
||||
"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjIiLCJNX1VzZXJFbWFpbCI6Impva29AZ21haWwuY29tIiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL29uZS1mby1yZWdpc3RyYXRpb24tdjI3IiwiTV9Vc2VyRGVmYXVsdFRfU2FtcGxlU3RhdGlvbklEIjoiMSIsIk1fU3RhZmZOYW1lIjpudWxsLCJpc19jb3VyaWVyIjoiTiIsInRpbWVfYXV0b2xvZ291dCI6IjE1IiwiaXAiOiIxMzkuMTkyLjE3My42MiIsImFnZW50IjoiTW96aWxsYVwvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQpIEFwcGxlV2ViS2l0XC81MzcuMzYgKEtIVE1MLCBsaWtlIEdlY2tvKSBDaHJvbWVcLzEyNS4wLjAuMCBTYWZhcmlcLzUzNy4zNiIsInZlcnNpb24iOiJ2MiIsImxhc3QtbG9naW4iOiIyMDI0LTA2LTA2IDE2OjQ3OjAwIn0.5S84dVOQbpET7_L7vN-DZMr2uSWuhsxPZYtq-HvzKkI"
|
||||
}
|
||||
1272
application/controllers/cpone/mcuoffline/Preregister.php
Normal file
1272
application/controllers/cpone/mcuoffline/Preregister.php
Normal file
File diff suppressed because it is too large
Load Diff
1248
application/controllers/cpone/mcuoffline/Preregister.php--100924
Normal file
1248
application/controllers/cpone/mcuoffline/Preregister.php--100924
Normal file
File diff suppressed because it is too large
Load Diff
1448
application/controllers/cpone/mcuoffline/Preregisterv2.php
Normal file
1448
application/controllers/cpone/mcuoffline/Preregisterv2.php
Normal file
File diff suppressed because it is too large
Load Diff
1329
application/controllers/cpone/mcuoffline/Preregisterv2.php--120425
Normal file
1329
application/controllers/cpone/mcuoffline/Preregisterv2.php--120425
Normal file
File diff suppressed because it is too large
Load Diff
2409
application/controllers/cpone/mcuoffline/Setupmcucpone.php
Normal file
2409
application/controllers/cpone/mcuoffline/Setupmcucpone.php
Normal file
File diff suppressed because it is too large
Load Diff
1290
application/controllers/cpone/mcuoffline/corporate/Corporate.php
Normal file
1290
application/controllers/cpone/mcuoffline/corporate/Corporate.php
Normal file
File diff suppressed because it is too large
Load Diff
1293
application/controllers/cpone/mcuoffline/corporate/Corporatev2.php
Normal file
1293
application/controllers/cpone/mcuoffline/corporate/Corporatev2.php
Normal file
File diff suppressed because it is too large
Load Diff
1729
application/controllers/cpone/mcuoffline/corporate/Corporatev3.php
Normal file
1729
application/controllers/cpone/mcuoffline/corporate/Corporatev3.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1486
application/controllers/cpone/mcuoffline/corporate/Corporateview.php
Normal file
1486
application/controllers/cpone/mcuoffline/corporate/Corporateview.php
Normal file
File diff suppressed because it is too large
Load Diff
2391
application/controllers/cpone/mcuoffline/doctor/Doctor.php
Normal file
2391
application/controllers/cpone/mcuoffline/doctor/Doctor.php
Normal file
File diff suppressed because it is too large
Load Diff
2424
application/controllers/cpone/mcuoffline/doctor/Doctorv2.php
Normal file
2424
application/controllers/cpone/mcuoffline/doctor/Doctorv2.php
Normal file
File diff suppressed because it is too large
Load Diff
194
application/controllers/cpone/mcuoffline/doctor/Photo.php
Normal file
194
application/controllers/cpone/mcuoffline/doctor/Photo.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Photo extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Photo API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->load->library('ImageManipulator');
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
|
||||
$home_dir = "/home/one/project/one/";
|
||||
$target_dir = $home_dir . "one-media/one-photo/doctor/" . date("Y") . "/";
|
||||
$y = $this->regenerateOldPhoto($home_dir, $inp['id']);
|
||||
|
||||
// get patient mr
|
||||
// $p = $this->db_smartone->select("M_DoctorCode")
|
||||
// ->where("M_DoctorID", $inp['id'])
|
||||
// ->get('m_doctor')
|
||||
// ->row();
|
||||
|
||||
$sql = "SELECT M_DoctorCode FROM m_doctor WHERE M_DoctorID = {$inp['id']}";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db("doctor select error", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$p = $qry->row();
|
||||
|
||||
if (!file_exists($target_dir)) {
|
||||
mkdir($target_dir, 0755, true);
|
||||
}
|
||||
|
||||
$target_path = $target_dir . $p->M_DoctorCode . ".jpg";
|
||||
$this->base64_to_jpeg($inp['data'], $target_path);
|
||||
|
||||
// CROP Image
|
||||
$im = new ImageManipulator($target_path);
|
||||
$w = $im->getWidth();
|
||||
$h = $im->getHeight();
|
||||
|
||||
$mw = ceil(3 * $h / 4);
|
||||
if ($w <= $mw)
|
||||
{
|
||||
$x1 = 0;
|
||||
$y1 = 0;
|
||||
$x2 = $w;
|
||||
$y2 = $h;
|
||||
}
|
||||
else
|
||||
{
|
||||
$x1 = floor(($w - $mw) / 2);
|
||||
$y1 = 0;
|
||||
$x2 = ceil($w - (($w - $mw) / 2));
|
||||
$y2 = $h;
|
||||
}
|
||||
|
||||
$im->crop($x1, $y1, $x2, $y2); // takes care of out of boundary conditions automatically
|
||||
$im->save($target_path);
|
||||
|
||||
$x = $this->generateThumbnail($target_path, 75, 100);
|
||||
|
||||
// Save to DB
|
||||
// $this->db_smartone->set("M_DoctorPhoto", "/" . str_replace($home_dir, "", $target_path))
|
||||
// ->set("M_DoctorPhotoThumb", "/" . str_replace($home_dir, "", $x))
|
||||
// ->set('M_DoctorPhotoCounter', '`M_DoctorPhotoCounter` + 1', false)
|
||||
// ->where('M_DoctorID', $inp['id'])
|
||||
// ->update('m_doctor');
|
||||
|
||||
$M_DoctorPhoto = "/" . str_replace($home_dir, "", $target_path);
|
||||
$M_DoctorPhotoThumb = "/" . str_replace($home_dir, "", $x);
|
||||
$M_DoctorID = $inp['id'];
|
||||
|
||||
$sql = "UPDATE m_doctor
|
||||
SET
|
||||
M_DoctorPhoto = '$M_DoctorPhoto',
|
||||
M_DoctorPhotoThumb = '$M_DoctorPhotoThumb',
|
||||
M_DoctorPhotoCounter = '`M_DoctorPhotoCounter` + 1',
|
||||
M_DoctorPhotoLastUpdated = NOW()
|
||||
WHERE M_DoctorID = $M_DoctorID";
|
||||
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db("doctor update photo error", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// LOGGING
|
||||
// $code = $y ? "PHOTO.PATIENT.EDIT" : "PHOTO.PATIENT.ADD";
|
||||
// $one_log = $this->load->database('onelog', true);
|
||||
// $one_log->set('Log_PhotoCode', $code)
|
||||
// ->set('Log_PhotoM_PatientID', $inp['id'])
|
||||
// ->set('Log_PhotoUrl', $y ? $y : "/" . str_replace($home_dir, "", $target_path))
|
||||
// ->insert('log_photo');
|
||||
|
||||
$this->sys_ok(
|
||||
[
|
||||
"rename"=>$y,
|
||||
"patient_id"=>$inp['id'],
|
||||
"patient_mr"=>$p->M_DoctorCode,
|
||||
"photo_url"=>"http://" . $_SERVER['SERVER_NAME'] . "/" . str_replace($home_dir, "", $target_path) . "?d=" . date("YmdHis")
|
||||
]);
|
||||
}
|
||||
|
||||
function base64_to_jpeg($base64_string, $output_file) {
|
||||
// open the output file for writing
|
||||
$ifp = fopen( $output_file, 'wb' );
|
||||
|
||||
// split the string on commas
|
||||
// $data[ 0 ] == "data:image/png;base64"
|
||||
// $data[ 1 ] == <actual base64 string>
|
||||
$data = explode( ',', $base64_string );
|
||||
|
||||
// we could add validation here with ensuring count( $data ) > 1
|
||||
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
|
||||
|
||||
// clean up the file resource
|
||||
fclose( $ifp );
|
||||
|
||||
return $output_file;
|
||||
}
|
||||
|
||||
function generateThumbnail($img, $width, $height, $quality = 90)
|
||||
{
|
||||
if (is_file($img)) {
|
||||
$imagick = new Imagick(realpath($img));
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->thumbnailImage($width, $height, false, false);
|
||||
$filename_no_ext = reset(explode('.', $img));
|
||||
if (file_put_contents($filename_no_ext . '_thumb' . '.jpg', $imagick) === false) {
|
||||
throw new Exception("Could not put contents.");
|
||||
}
|
||||
return $filename_no_ext . '_thumb' . '.jpg';
|
||||
}
|
||||
else {
|
||||
throw new Exception("No valid image provided with {$img}.");
|
||||
}
|
||||
}
|
||||
|
||||
function regenerateOldPhoto($home_dir, $id)
|
||||
{
|
||||
// $r = $this->db_smartone->select('m_doctorphoto, m_doctorphotocounter', false)
|
||||
// ->where('m_doctorid', $id)
|
||||
// ->get('m_doctor')
|
||||
// ->row();
|
||||
|
||||
// $r = $this->db_smartone->select('M_DoctorPhoto, M_DoctorPhotoCounter', false)
|
||||
// ->where('M_DoctorID', $id)
|
||||
// ->get('m_doctor')
|
||||
// ->row();
|
||||
|
||||
$sql = "SELECT * FROM m_doctor WHERE M_DoctorID = $id";
|
||||
$qry = $this->db_smartone->query($sql);
|
||||
|
||||
if(!$qry){
|
||||
$this->sys_error_db("doctor select error", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$r = $qry->row();
|
||||
|
||||
if ($r->M_DoctorPhoto != null && $r->M_DoctorPhotoCounter > 0) {
|
||||
$full_path = substr_replace($home_dir ,"", -1) . $r->M_DoctorPhoto;
|
||||
$path_parts = pathinfo($full_path);
|
||||
|
||||
$rename = $path_parts['dirname'] . '/' . $path_parts['filename'] . '-' . $r->M_DoctorPhotoCounter . '.' . $path_parts['extension'];
|
||||
rename($full_path, $rename);
|
||||
// echo $path_parts['dirname'], "\n";
|
||||
// echo $path_parts['extension'], "\n";
|
||||
// echo $path_parts['filename'], "\n";
|
||||
|
||||
return "/" . str_replace($home_dir, "", $rename);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,946 @@
|
||||
<?php
|
||||
class Packetcponev2 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function savesetupv0()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$T_PacketName = strtoupper($prm['namapacket']);
|
||||
$T_PriceHeaderID = $prm['priceheader']['T_PriceHeaderID'];
|
||||
$T_PacketType = $prm['jenispacket'];
|
||||
$T_PacketPrice = $prm['T_PacketPrice'];
|
||||
$T_PacketOriginalPrice = $prm['T_PacketOriginalPrice'];
|
||||
$T_PacketSasCode = "";
|
||||
$T_PacketOriginalBruto = 0;
|
||||
$detail_packet = $prm['detailpacket'];
|
||||
$T_PacketStartDate = date('Y-m-d',strtotime($prm["T_PacketStartDate"]));
|
||||
$T_PacketEndDate = date('Y-m-d',strtotime($prm["T_PacketEndDate"]));
|
||||
// $act = $prm['act'];
|
||||
|
||||
if($prm["act"] == 'new'){
|
||||
// check paket exists or not
|
||||
$sqlCheck = "SELECT *
|
||||
FROM t_packet
|
||||
WHERE T_PacketIsActive = 'Y'
|
||||
AND T_PacketName = '$T_PacketName'";
|
||||
|
||||
$qryCheck = $this->db_onedev->query($sqlCheck);
|
||||
|
||||
if(!$qryCheck){
|
||||
$this->sys_error_db("t_packet check", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowCheck = $qryCheck->result_array();
|
||||
|
||||
if(count($rowCheck) > 0){
|
||||
$this->sys_error("Data dengan nama paket ".$T_PacketName." Sudah Ada");
|
||||
exit;
|
||||
} else {
|
||||
// get numbering
|
||||
$sql_get_numbering = "SELECT fn_numbering_cpone('PCPN') as numberx";
|
||||
if($T_PacketType == 'PR'){
|
||||
$sql_get_numbering = "SELECT fn_numbering_cpone('PCPR') as numberx";
|
||||
}
|
||||
|
||||
$qry_get_numbering = $this->db_onedev->query($sql_get_numbering);
|
||||
if(!$qry_get_numbering){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("packet numbering cpone", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$data_numbering = $qry_get_numbering->result_array();
|
||||
|
||||
$T_PacketSasCode = $data_numbering[0]['numberx'];
|
||||
|
||||
// insert t_packet
|
||||
$sql_insert = "INSERT INTO t_packet
|
||||
(
|
||||
T_PacketT_PriceHeaderID,
|
||||
T_PacketType,
|
||||
T_PacketName,
|
||||
T_PacketPrice,
|
||||
T_PacketOriginalPrice,
|
||||
T_PacketSasCode,
|
||||
T_PacketIsActive,
|
||||
T_PacketCreated,
|
||||
T_PacketOriginalBruto,
|
||||
T_PacketStartDate,
|
||||
T_PacketEndDate
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
$T_PriceHeaderID, -- T_PacketT_PriceHeaderID
|
||||
'$T_PacketType', -- T_PacketType (assuming 'PR' for Profile)
|
||||
'$T_PacketName', -- T_PacketName
|
||||
$T_PacketPrice, -- T_PacketPrice
|
||||
$T_PacketOriginalPrice, -- T_PacketOriginalPrice
|
||||
'$T_PacketSasCode', -- T_PacketSasCode
|
||||
'Y', -- T_PacketIsActive
|
||||
NOW(), -- T_PacketCreated
|
||||
$T_PacketOriginalBruto, -- T_PacketOriginalBruto (can be NULL)
|
||||
'$T_PacketStartDate',
|
||||
'$T_PacketEndDate'
|
||||
)";
|
||||
|
||||
$qryInsert = $this->db_onedev->query($sql_insert);
|
||||
if(!$qryInsert){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packet insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
// insert t_packetdetail
|
||||
if(count($detail_packet) > 0) {
|
||||
foreach($detail_packet as $k => $v){
|
||||
$T_PriceTotalPacket = $v['T_PriceTotalPacket'];
|
||||
|
||||
// bisa berubah ubah kalau PN
|
||||
if($T_PacketType == "PN"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $T_PriceTotalPacket;
|
||||
}
|
||||
|
||||
if($T_PacketType == "PR"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $v['T_PriceTotal'];
|
||||
}
|
||||
|
||||
$T_PacketDetailPriceAmount = 0;
|
||||
$T_PacketDetailPriceDisc = 0;
|
||||
$T_PacketDetailPriceDiscRp = 0;
|
||||
$T_PacketDetailPriceSubTotal = 0;
|
||||
|
||||
if(!empty($v['T_PriceAmount'])){
|
||||
$T_PacketDetailPriceAmount = $v['T_PriceAmount'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDisc'])){
|
||||
$T_PacketDetailPriceDisc = $v['T_PriceDisc'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDiscRp'])){
|
||||
$T_PacketDetailPriceDiscRp = $v['T_PriceDiscRp'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceSubTotal'])){
|
||||
$T_PacketDetailPriceSubTotal = $v['T_PriceSubTotal'];
|
||||
}
|
||||
|
||||
$sql_insert_detail = "INSERT INTO t_packetdetail
|
||||
(
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice,
|
||||
T_PacketDetailPrice,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal
|
||||
) VALUES (
|
||||
$last_id, -- T_PacketDetailT_PacketID
|
||||
{$v['T_TestID']}, -- T_PacketDetailT_TestID
|
||||
{$T_PacketDetailOriginalPrice}, -- T_PacketDetailOriginalPrice
|
||||
{$T_PacketDetailPrice}, -- T_PacketDetailPrice
|
||||
'Y', -- T_PacketDetailIsActive
|
||||
NOW(), -- T_PacketDetailCreated
|
||||
{$T_PacketDetailPriceAmount}, -- T_PacketDetailPriceAmount
|
||||
{$T_PacketDetailPriceDisc}, -- T_PacketDetailPriceDisc
|
||||
{$T_PacketDetailPriceDiscRp}, -- T_PacketDetailPriceDiscRp
|
||||
{$T_PacketDetailPriceSubTotal} -- T_PacketDetailPriceSubTotal
|
||||
)";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_insert_detail);
|
||||
if(!$qry_detail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT T_PacketName as xnumber
|
||||
FROM t_packet
|
||||
WHERE T_PacketID = {$last_id}";
|
||||
|
||||
//echo $sql;
|
||||
$row = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $row,
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
} else{
|
||||
// check paket exists or not
|
||||
$sqlCheck = "SELECT *
|
||||
FROM t_packet
|
||||
WHERE T_PacketIsActive = 'Y'
|
||||
AND T_PacketName = '$T_PacketName'
|
||||
AND T_PacketID <> {$prm["xid"]}";
|
||||
|
||||
// echo $sqlCheck;
|
||||
// exit;
|
||||
|
||||
$qryCheck = $this->db_onedev->query($sqlCheck);
|
||||
|
||||
if(!$qryCheck){
|
||||
$this->sys_error_db("t_packet check", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowCheck = $qryCheck->result_array();
|
||||
if(count($rowCheck) > 0){
|
||||
// echo $sqlCheck;
|
||||
// exit;
|
||||
$this->sys_error("Data dengan nama paket ".$T_PacketName." Sudah Ada", $this->db_onedev);
|
||||
exit;
|
||||
} else {
|
||||
// update t_packet
|
||||
$sql_update = "UPDATE t_packet
|
||||
SET
|
||||
T_PacketT_PriceHeaderID = $T_PriceHeaderID,
|
||||
T_PacketType = '$T_PacketType',
|
||||
T_PacketName = '$T_PacketName',
|
||||
T_PacketPrice = $T_PacketPrice,
|
||||
T_PacketOriginalPrice = $T_PacketOriginalPrice,
|
||||
T_PacketIsActive = 'Y',
|
||||
T_PacketLastUpdated = NOW(),
|
||||
T_PacketOriginalBruto = $T_PacketOriginalBruto,
|
||||
T_PacketStartDate = '$T_PacketStartDate',
|
||||
T_PacketEndDate = '$T_PacketEndDate'
|
||||
WHERE
|
||||
T_PacketID = {$prm["xid"]}";
|
||||
|
||||
$qryUpdate = $this->db_onedev->query($sql_update);
|
||||
if(!$qryUpdate){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("error t_packet update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$last_id = $prm["xid"];
|
||||
|
||||
// // update detail packet
|
||||
// // update isActive N kan semua
|
||||
$sqlUpdatePacket = "UPDATE t_packetdetail
|
||||
SET
|
||||
T_PacketDetailIsActive = 'N',
|
||||
T_PacketDetailLastUpdated = NOW()
|
||||
WHERE T_PacketDetailT_PacketID = $last_id";
|
||||
|
||||
// echo $sqlUpdatePacket;
|
||||
|
||||
$qry_mgm_update_tpacketdetails = $this->db_onedev->query($sqlUpdatePacket);
|
||||
if(!$qry_mgm_update_tpacketdetails){
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// insert t_packetdetail
|
||||
if(count($detail_packet) > 0) {
|
||||
foreach($detail_packet as $k => $v){
|
||||
$T_PriceTotalPacket = $v['T_PriceTotalPacket'];
|
||||
|
||||
// bisa berubah ubah kalau PN
|
||||
if($T_PacketType == "PN"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $T_PriceTotalPacket;
|
||||
}
|
||||
|
||||
if($T_PacketType == "PR"){
|
||||
$T_PacketDetailOriginalPrice = $v['T_PriceTotal'];
|
||||
$T_PacketDetailPrice = $v['T_PriceTotal'];
|
||||
}
|
||||
|
||||
$T_PacketDetailPriceAmount = 0;
|
||||
$T_PacketDetailPriceDisc = 0;
|
||||
$T_PacketDetailPriceDiscRp = 0;
|
||||
$T_PacketDetailPriceSubTotal = 0;
|
||||
|
||||
if(!empty($v['T_PriceAmount'])){
|
||||
$T_PacketDetailPriceAmount = $v['T_PriceAmount'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDisc'])){
|
||||
$T_PacketDetailPriceDisc = $v['T_PriceDisc'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceDiscRp'])){
|
||||
$T_PacketDetailPriceDiscRp = $v['T_PriceDiscRp'];
|
||||
}
|
||||
|
||||
if(!empty($v['T_PriceSubTotal'])){
|
||||
$T_PacketDetailPriceSubTotal = $v['T_PriceSubTotal'];
|
||||
}
|
||||
|
||||
$sql_insert_detail = "INSERT INTO t_packetdetail
|
||||
(
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice,
|
||||
T_PacketDetailPrice,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal
|
||||
) VALUES (
|
||||
$last_id, -- T_PacketDetailT_PacketID
|
||||
{$v['T_TestID']}, -- T_PacketDetailT_TestID
|
||||
{$T_PacketDetailOriginalPrice}, -- T_PacketDetailOriginalPrice
|
||||
{$T_PacketDetailPrice}, -- T_PacketDetailPrice
|
||||
'Y', -- T_PacketDetailIsActive
|
||||
NOW(), -- T_PacketDetailCreated
|
||||
{$T_PacketDetailPriceAmount}, -- T_PacketDetailPriceAmount
|
||||
{$T_PacketDetailPriceDisc}, -- T_PacketDetailPriceDisc
|
||||
{$T_PacketDetailPriceDiscRp}, -- T_PacketDetailPriceDiscRp
|
||||
{$T_PacketDetailPriceSubTotal} -- T_PacketDetailPriceSubTotal
|
||||
)";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_insert_detail);
|
||||
if(!$qry_detail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT T_PacketName as xnumber
|
||||
FROM t_packet
|
||||
WHERE T_PacketID = {$last_id}";
|
||||
|
||||
//echo $sql;
|
||||
$row = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $row,
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletev0(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// packet
|
||||
$query_t_packet = $this->db_onedev->query("UPDATE t_packet SET
|
||||
T_PacketIsActive = 'N',
|
||||
T_PacketLastUpdated = NOW()
|
||||
WHERE
|
||||
T_PacketID = '{$prm['id']}'
|
||||
");
|
||||
|
||||
if (!$query_t_packet) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packet update error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// packet details
|
||||
$query_t_packetdetail = $this->db_onedev->query("UPDATE t_packetdetail SET
|
||||
T_PacketDetailIsActive = 'N',
|
||||
T_PacketDetailLastUpdated = NOW()
|
||||
WHERE
|
||||
T_PacketDetailT_PacketID = '{$prm['id']}'
|
||||
");
|
||||
|
||||
if (!$query_t_packetdetail) {
|
||||
$this->db_onedev->trans_rollback();
|
||||
$this->sys_error_db("t_packetdetail update error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $rows = $this->db_onedev->query($query_mgmmcu);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getTTestByTPriceHeaderCurrent()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// $search_kode = $prm['searchKode'];
|
||||
// $search_nama = $prm['searchNama'];
|
||||
|
||||
$number_limit = 30;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
|
||||
$natsubgroup = "";
|
||||
$sql_where_natsubgroup = "";
|
||||
|
||||
if(isset($prm['natsubgroup']) && !empty($prm['natsubgroup']) && $prm['natsubgroup'] != "All"){
|
||||
$natsubgroup = $prm['natsubgroup'];
|
||||
$sql_where_natsubgroup = " AND Nat_SubGroupID = $natsubgroup";
|
||||
}
|
||||
|
||||
// if($natsubgroup != "All"){
|
||||
// $sql_where_natsubgroup = " AND Nat_SubGroupID = $natsubgroup";
|
||||
// }
|
||||
|
||||
$tpriceheader = $prm['tpriceheader'];
|
||||
$sql_where_tpriceheader = "";
|
||||
|
||||
if(isset($prm['tpriceheader']) && !empty($prm['tpriceheader'])){
|
||||
$sql_where_tpriceheader = " AND ph.T_PriceHeaderID = $tpriceheader";
|
||||
}
|
||||
|
||||
$sqlSearch = "T_TestName LIKE '%%' AND T_TestCode LIKE '%%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
|
||||
if(isset($prm['searchKode']) && !empty($prm['searchKode'])){
|
||||
$sqlSearch = " T_TestCode LIKE '%{$prm['searchKode']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
if(isset($prm['searchNama']) && !empty($prm['searchNama'])){
|
||||
$sqlSearch = " T_TestName LIKE '%{$prm['searchNama']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
if(
|
||||
((isset($prm['searchKode']) && !empty($prm['searchKode'])))
|
||||
&& (isset($prm['searchNama']) && !empty($prm['searchNama']))
|
||||
){
|
||||
$sqlSearch = " T_TestName LIKE '%{$prm['searchNama']}%' AND T_TestCode LIKE '%{$prm['searchKode']}%' ".$sql_where_tpriceheader.$sql_where_natsubgroup;
|
||||
}
|
||||
|
||||
$sql_where = "
|
||||
WHERE (
|
||||
".$sqlSearch."
|
||||
)";
|
||||
|
||||
|
||||
|
||||
// $sql_where = "
|
||||
// WHERE (
|
||||
// T_TestCode LIKE '%{$prm['searchKode']}%'
|
||||
// OR T_TestName LIKE '%{$prm['searchNama']}%'
|
||||
// )";
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT
|
||||
IFNULL(p.T_PriceID, 0) AS T_PriceID
|
||||
FROM
|
||||
t_price p
|
||||
JOIN
|
||||
t_priceheader ph
|
||||
ON
|
||||
p.T_PriceT_PriceHeaderID = ph.T_PriceHeaderID
|
||||
AND p.T_PriceIsActive = 'Y'
|
||||
AND ph.T_PriceHeaderIsActive = 'Y'
|
||||
JOIN
|
||||
t_test testx
|
||||
ON p.T_PriceT_TestID = testx.T_TestID
|
||||
AND testx.T_TestIsActive = 'Y'
|
||||
LEFT JOIN nat_subgroup
|
||||
ON T_TestNat_SubgroupID = Nat_SubgroupID
|
||||
AND Nat_SubGroupIsActive = 'Y'
|
||||
$sql_where
|
||||
) x";
|
||||
|
||||
$sql_param = array();
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("tprice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT
|
||||
ROW_NUMBER() OVER (ORDER BY T_PriceID) AS RowNum,
|
||||
IFNULL(p.T_PriceTotal, 0) AS T_PriceTotalPacket,
|
||||
IFNULL(p.T_PriceID, 0) AS T_PriceID,
|
||||
IFNULL(p.T_PriceT_PriceHeaderID, 0) AS T_PriceT_PriceHeaderID,
|
||||
IFNULL(p.T_PriceT_TestID, 0) AS T_PriceT_TestID,
|
||||
IFNULL(p.T_PriceIsCito, 'N') AS T_PriceIsCito,
|
||||
IFNULL(p.T_PricePriority, 1) AS T_PricePriority,
|
||||
IFNULL(p.T_PriceAmount, 0) AS T_PriceAmount,
|
||||
IFNULL(p.T_PriceDisc, 0) AS T_PriceDisc,
|
||||
IFNULL(p.T_PriceDiscRp, 0) AS T_PriceDiscRp,
|
||||
IFNULL(p.T_PriceSubTotal, 0) AS T_PriceSubTotal,
|
||||
IFNULL(p.T_PriceOther, 0) AS T_PriceOther,
|
||||
IFNULL(p.T_PriceTotal, 0) AS T_PriceTotal,
|
||||
IFNULL(p.T_PriceIsActive, 'Y') AS T_PriceIsActive,
|
||||
IFNULL(p.T_PriceCreated, '0000-00-00') AS T_PriceCreated,
|
||||
IFNULL(p.T_PriceLastUpdated, '0000-00-00') AS T_PriceLastUpdated,
|
||||
IFNULL(p.T_PriceUserID, 0) AS T_PriceUserID,
|
||||
IFNULL(ph.T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
||||
IFNULL(ph.T_PriceHeaderName, '') AS T_PriceHeaderName,
|
||||
IFNULL(ph.T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
||||
IFNULL(ph.T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
||||
IFNULL(ph.T_PriceHeaderIsActive, 'Y') AS T_PriceHeaderIsActive,
|
||||
IFNULL(ph.T_PriceHeaderUserID, 0) AS T_PriceHeaderUserID,
|
||||
IFNULL(ph.T_PriceHeaderCreated, '0000-00-00 00:00:00') AS T_PriceHeaderCreated,
|
||||
IFNULL(ph.T_PriceHeaderCraetdUserID, 0) AS T_PriceHeaderCraetdUserID,
|
||||
IFNULL(ph.T_PriceHeaderLastUpdated, '0000-00-00 00:00:00') AS T_PriceHeaderLastUpdated,
|
||||
IFNULL(ph.T_PriceHeaderLastUpdatedUserID, 0) AS T_PriceHeaderLastUpdatedUserID,
|
||||
IFNULL(ph.T_PriceHeaderDeleted, '0000-00-00 00:00:00') AS T_PriceHeaderDeleted,
|
||||
IFNULL(ph.T_PriceHeaderDeletedUserID, 0) AS T_PriceHeaderDeletedUserID,
|
||||
IFNULL(testx.T_TestID, 0) AS T_TestID,
|
||||
IFNULL(testx.T_TestCode, '') AS T_TestCode,
|
||||
IFNULL(testx.T_TestName, '') AS T_TestName
|
||||
FROM
|
||||
t_price p
|
||||
JOIN
|
||||
t_priceheader ph
|
||||
ON
|
||||
p.T_PriceT_PriceHeaderID = ph.T_PriceHeaderID
|
||||
AND p.T_PriceIsActive = 'Y'
|
||||
AND ph.T_PriceHeaderIsActive = 'Y'
|
||||
JOIN
|
||||
t_test testx
|
||||
ON p.T_PriceT_TestID = testx.T_TestID
|
||||
AND testx.T_TestIsActive = 'Y'
|
||||
LEFT JOIN nat_subgroup
|
||||
ON T_TestNat_SubgroupID = Nat_SubgroupID
|
||||
AND Nat_SubGroupIsActive = 'Y'
|
||||
$sql_where
|
||||
ORDER BY p.T_PriceID DESC
|
||||
limit $number_limit offset $number_offset
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
if ($query === false) {
|
||||
// If query failed, log the error and exit
|
||||
$this->sys_error_db("select t_price data", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getTPriceHeader()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM t_priceheader
|
||||
WHERE T_PriceHeaderIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("t_priceheader select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$new_entry = array(
|
||||
'T_PriceHeaderID' => 'All',
|
||||
'T_PriceHeaderName' => 'All',
|
||||
'T_PriceHeaderStartDate' => "",
|
||||
'T_PriceHeaderEndDate' => "",
|
||||
'T_PriceHeaderIsActive' => "",
|
||||
'T_PriceHeaderUserID' => "",
|
||||
'T_PriceHeaderCreated' => "",
|
||||
'T_PriceHeaderCraetdUserID' => "",
|
||||
'T_PriceHeaderLastUpdated' => "",
|
||||
'T_PriceHeaderLastUpdatedUserID' => "",
|
||||
'T_PriceHeaderDeleted' => "",
|
||||
'T_PriceHeaderDeletedUserID' => ""
|
||||
);
|
||||
|
||||
array_unshift($rows, $new_entry);
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getTPriceHeaderCurrent()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
IFNULL(T_PriceHeaderID, 0) AS T_PriceHeaderID,
|
||||
IFNULL(T_PriceHeaderName, '') AS T_PriceHeaderName,
|
||||
IFNULL(T_PriceHeaderStartDate, '0000-00-00') AS T_PriceHeaderStartDate,
|
||||
IFNULL(T_PriceHeaderEndDate, '0000-00-00') AS T_PriceHeaderEndDate,
|
||||
IFNULL(T_PriceHeaderIsActive, 'Y') AS T_PriceHeaderIsActive,
|
||||
IFNULL(T_PriceHeaderUserID, 0) AS T_PriceHeaderUserID,
|
||||
IFNULL(T_PriceHeaderCreated, '0000-00-00 00:00:00') AS T_PriceHeaderCreated,
|
||||
IFNULL(T_PriceHeaderCraetdUserID, 0) AS T_PriceHeaderCraetdUserID,
|
||||
IFNULL(T_PriceHeaderLastUpdated, '0000-00-00 00:00:00') AS T_PriceHeaderLastUpdated,
|
||||
IFNULL(T_PriceHeaderLastUpdatedUserID, 0) AS T_PriceHeaderLastUpdatedUserID,
|
||||
IFNULL(T_PriceHeaderDeleted, '0000-00-00 00:00:00') AS T_PriceHeaderDeleted,
|
||||
IFNULL(T_PriceHeaderDeletedUserID, 0) AS T_PriceHeaderDeletedUserID,
|
||||
T_PriceHeaderIsGenerated
|
||||
FROM
|
||||
t_priceheader
|
||||
WHERE T_PriceHeaderIsActive = 'Y'";
|
||||
// -- AND CURDATE() BETWEEN T_PriceHeaderStartDate AND T_PriceHeaderEndDate";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("t_priceheader select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function searchv0()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
// $search = $prm['search'];
|
||||
// if (isset($prm['search'])) {
|
||||
// $search = trim($prm["search"]);
|
||||
// if ($search != "") {
|
||||
// $search = '%' . $prm['search'] . '%';
|
||||
// }else{
|
||||
// $search = '%%';
|
||||
// }
|
||||
// }
|
||||
|
||||
// $limit = '';
|
||||
// $filter_paket = $prm['searchPacket'];
|
||||
// if($all == 'N'){
|
||||
// $limit = ' LIMIT 10';
|
||||
// }
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
// $sql_where = " (
|
||||
// T_PacketName LIKE '%{$prm['search']}%'
|
||||
// OR T_PacketType LIKE '%{$prm['search']}%'
|
||||
// ) AND T_PacketIsActive = 'Y'";
|
||||
|
||||
$sql_where_tpriceheader = "";
|
||||
$tpriceheader = "";
|
||||
|
||||
|
||||
if(isset($prm['tpriceheader'])){
|
||||
$tpriceheader = $prm['tpriceheader'];
|
||||
}
|
||||
|
||||
if($tpriceheader != "All"){
|
||||
$sql_where_tpriceheader = " AND T_PacketT_PriceHeaderID = $tpriceheader";
|
||||
}
|
||||
|
||||
$sql_where = " (
|
||||
T_PacketName LIKE '%{$prm['search']}%'
|
||||
) AND T_PacketIsActive = 'Y'
|
||||
$sql_where_tpriceheader";
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_packet
|
||||
WHERE $sql_where
|
||||
";
|
||||
|
||||
$sql_param = array();
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_packet count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
// sql data
|
||||
$sql = "SELECT
|
||||
IFNULL(T_PacketID, 0) AS T_PacketID,
|
||||
IFNULL(T_PacketT_PriceHeaderID, 0) AS T_PacketT_PriceHeaderID,
|
||||
IFNULL(T_PacketType,'') AS T_PacketType,
|
||||
IFNULL(T_PacketName,'') AS T_PacketName,
|
||||
IFNULL(T_PacketPrice,0) AS T_PacketPrice,
|
||||
IFNULL(T_PacketOriginalPrice,0) AS T_PacketOriginalPrice,
|
||||
IFNULL(T_PacketSasCode,'') AS T_PacketSasCode,
|
||||
IFNULL(T_PacketIsActive,'') AS T_PacketIsActive,
|
||||
IFNULL(T_PacketCreated,'') AS T_PacketCreated,
|
||||
IFNULL(T_PacketLastUpdated,'') AS T_PacketLastUpdated,
|
||||
IFNULL(T_PacketStartDate, '0000-00-00 00:00:00') AS T_PacketStartDate,
|
||||
IFNULL(T_PacketEndDate, '0000-00-00 00:00:00') AS T_PacketEndDate,
|
||||
T_PacketIsGenerated,
|
||||
T_PacketGeneratedDate
|
||||
FROM t_packet
|
||||
WHERE $sql_where
|
||||
GROUP BY T_PacketID
|
||||
ORDER BY T_PacketID DESC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
if ($query === false) {
|
||||
// If query failed, log the error and exit
|
||||
$this->sys_error_db("select t_packet data", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql"=> $this->db_onedev->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getPaketById()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $prm['T_PacketID'];
|
||||
|
||||
$sql_paket = "SELECT
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
T_PriceHeaderID,
|
||||
T_PriceHeaderName,
|
||||
T_PacketType,
|
||||
IFNULL(T_PacketStartDate, '0000-00-00 00:00:00') AS T_PacketStartDate,
|
||||
IFNULL(T_PacketEndDate, '0000-00-00 00:00:00') AS T_PacketEndDate,
|
||||
'' as detailpackets
|
||||
FROM t_packet
|
||||
JOIN t_priceheader
|
||||
ON T_PacketT_PriceHeaderID = T_PriceHeaderID
|
||||
AND T_PacketIsActive = 'Y'
|
||||
AND T_PriceHeaderIsActive = 'Y'
|
||||
AND T_PacketID = $id
|
||||
JOIN t_packetdetail
|
||||
ON T_PacketID = T_PacketDetailT_PacketID
|
||||
AND T_PacketDetailIsActive = 'Y'
|
||||
GROUP BY T_PacketID";
|
||||
|
||||
$qry = $this->db_onedev->query($sql_paket);
|
||||
if(!$qry){
|
||||
$this->sys_error_db("t_packet count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $key => $vx) {
|
||||
$sql_detail = "SELECT
|
||||
T_PacketDetailID,
|
||||
T_PacketDetailT_PacketID,
|
||||
T_PacketDetailT_TestID,
|
||||
T_PacketDetailOriginalPrice as T_PriceTotal,
|
||||
T_PacketDetailPrice as T_PriceTotalPacket,
|
||||
T_PacketDetailIsActive,
|
||||
T_PacketDetailCreated,
|
||||
T_PacketDetailLastUpdated,
|
||||
T_PacketDetailPriceAmount,
|
||||
T_PacketDetailPriceDisc,
|
||||
T_PacketDetailPriceDiscRp,
|
||||
T_PacketDetailPriceSubTotal,
|
||||
T_TestID,
|
||||
T_TestName
|
||||
FROM t_packetdetail
|
||||
JOIN t_test
|
||||
ON T_PacketDetailT_TestID = T_TestID
|
||||
AND T_TestIsActive = 'Y'
|
||||
AND T_PacketDetailIsActive = 'Y'
|
||||
AND T_PacketDetailT_PacketID = $id";
|
||||
|
||||
$qry_detail = $this->db_onedev->query($sql_detail);
|
||||
if(!$qry_detail){
|
||||
$this->sys_error_db("t_packetdetail count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rowdet = $qry_detail->result_array();
|
||||
$rows[$key]['sumhargaawal'] = 0;
|
||||
$rows[$key]['sumhargapaket'] = 0;
|
||||
$rows[$key]['detailpackets'] = $rowdet;
|
||||
|
||||
foreach($rowdet as $k => $vk){
|
||||
$rows[$key]['sumhargaawal'] += $vk['T_PriceTotal'];
|
||||
$rows[$key]['sumhargapaket'] += $vk['T_PriceTotalPacket'];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
$result = array(
|
||||
// "total" => $tot_page,
|
||||
"records" => $rows,
|
||||
"sql"=> $this->db_onedev->last_query()
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
public function getGroupPemeriksaan() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
Nat_SubGroupID,
|
||||
Nat_SubGroupNat_GroupID,
|
||||
Nat_SubGroupCode,
|
||||
Nat_SubGroupName,
|
||||
Nat_SubGroupLangName,
|
||||
Nat_SubGroupIsResult,
|
||||
Nat_SubGroupReportTitle,
|
||||
Nat_SubGroupCreated,
|
||||
Nat_SubGroupLastUpdated,
|
||||
Nat_SubGroupIsActive
|
||||
FROM
|
||||
nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'";
|
||||
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nat_subgroup select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
|
||||
$new_entry = array(
|
||||
"Nat_SubGroupID" => "All",
|
||||
"Nat_SubGroupNat_GroupID" => "",
|
||||
"Nat_SubGroupCode" => "",
|
||||
"Nat_SubGroupName" => "All",
|
||||
"Nat_SubGroupLangName" => "",
|
||||
"Nat_SubGroupIsResult" => "",
|
||||
"Nat_SubGroupReportTitle" => "",
|
||||
"Nat_SubGroupCreated"=> "",
|
||||
"Nat_SubGroupLastUpdated"=> "",
|
||||
"Nat_SubGroupIsActive"=> ""
|
||||
);
|
||||
|
||||
array_unshift($rows, $new_entry);
|
||||
|
||||
$result = array(
|
||||
"records" => $rows,
|
||||
"sql" => $this->db_onedev->last_query()
|
||||
);
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1155
application/controllers/cpone/mcuoffline/packet/Packetcponev3.php
Normal file
1155
application/controllers/cpone/mcuoffline/packet/Packetcponev3.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1300
application/controllers/cpone/mcuoffline/packet/Packetcponev4.php
Normal file
1300
application/controllers/cpone/mcuoffline/packet/Packetcponev4.php
Normal file
File diff suppressed because it is too large
Load Diff
1305
application/controllers/cpone/mcuoffline/packet/Packetcponev5.php
Normal file
1305
application/controllers/cpone/mcuoffline/packet/Packetcponev5.php
Normal file
File diff suppressed because it is too large
Load Diff
1860
application/controllers/cpone/mcuoffline/packet/Packetcponev6.php
Normal file
1860
application/controllers/cpone/mcuoffline/packet/Packetcponev6.php
Normal file
File diff suppressed because it is too large
Load Diff
2331
application/controllers/cpone/mcuoffline/patient/Patient.php
Normal file
2331
application/controllers/cpone/mcuoffline/patient/Patient.php
Normal file
File diff suppressed because it is too large
Load Diff
143
application/controllers/cpone/mcuoffline/patient/Photo.php
Normal file
143
application/controllers/cpone/mcuoffline/patient/Photo.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Photo extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Photo API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->load->library('ImageManipulator');
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
|
||||
$home_dir = "/home/one/project/one/";
|
||||
$target_dir = $home_dir . "one-media/one-photo/patient/" . date("Y") . "/";
|
||||
$y = $this->regenerateOldPhoto($home_dir, $inp['id']);
|
||||
|
||||
// get patient mr
|
||||
$p = $this->db_smartone->select("M_PatientNoReg")
|
||||
->where("M_PatientID", $inp['id'])
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
if (!file_exists($target_dir)) {
|
||||
mkdir($target_dir, 0755, true);
|
||||
}
|
||||
|
||||
$target_path = $target_dir . $p->M_PatientNoReg . ".jpg";
|
||||
$this->base64_to_jpeg($inp['data'], $target_path);
|
||||
|
||||
// CROP Image
|
||||
$im = new ImageManipulator($target_path);
|
||||
$w = $im->getWidth();
|
||||
$h = $im->getHeight();
|
||||
|
||||
$mw = ceil(3 * $h / 4);
|
||||
if ($w <= $mw)
|
||||
{
|
||||
$x1 = 0;
|
||||
$y1 = 0;
|
||||
$x2 = $w;
|
||||
$y2 = $h;
|
||||
}
|
||||
else
|
||||
{
|
||||
$x1 = floor(($w - $mw) / 2);
|
||||
$y1 = 0;
|
||||
$x2 = ceil($w - (($w - $mw) / 2));
|
||||
$y2 = $h;
|
||||
}
|
||||
|
||||
$im->crop($x1, $y1, $x2, $y2); // takes care of out of boundary conditions automatically
|
||||
$im->save($target_path);
|
||||
|
||||
$x = $this->generateThumbnail($target_path, 75, 100);
|
||||
|
||||
// Save to DB
|
||||
$this->db_smartone->set("M_PatientPhoto", "/" . str_replace($home_dir, "", $target_path))
|
||||
->set("M_PatientPhotoThumb", "/" . str_replace($home_dir, "", $x))
|
||||
->set('M_PatientPhotoCounter', '`M_PatientPhotoCounter` + 1', false)
|
||||
->where('M_PatientID', $inp['id'])
|
||||
->update('m_patient');
|
||||
|
||||
// LOGGING
|
||||
$code = $y ? "PHOTO.PATIENT.EDIT" : "PHOTO.PATIENT.ADD";
|
||||
$one_log = $this->load->database('onelog', true);
|
||||
$one_log->set('Log_PhotoCode', $code)
|
||||
->set('Log_PhotoM_PatientID', $inp['id'])
|
||||
->set('Log_PhotoUrl', $y ? $y : "/" . str_replace($home_dir, "", $target_path))
|
||||
->insert('log_photo');
|
||||
|
||||
$this->sys_ok(["rename"=>$y, "patient_id"=>$inp['id'], "patient_mr"=>$p->M_PatientNoReg, "photo_url"=>"http://" . $_SERVER['SERVER_NAME'] . "/" . str_replace($home_dir, "", $target_path) . "?d=" . date("YmdHis")]);
|
||||
}
|
||||
|
||||
function base64_to_jpeg($base64_string, $output_file) {
|
||||
// open the output file for writing
|
||||
$ifp = fopen( $output_file, 'wb' );
|
||||
|
||||
// split the string on commas
|
||||
// $data[ 0 ] == "data:image/png;base64"
|
||||
// $data[ 1 ] == <actual base64 string>
|
||||
$data = explode( ',', $base64_string );
|
||||
|
||||
// we could add validation here with ensuring count( $data ) > 1
|
||||
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
|
||||
|
||||
// clean up the file resource
|
||||
fclose( $ifp );
|
||||
|
||||
return $output_file;
|
||||
}
|
||||
|
||||
function generateThumbnail($img, $width, $height, $quality = 90)
|
||||
{
|
||||
if (is_file($img)) {
|
||||
$imagick = new Imagick(realpath($img));
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->thumbnailImage($width, $height, false, false);
|
||||
$filename_no_ext = reset(explode('.', $img));
|
||||
if (file_put_contents($filename_no_ext . '_thumb' . '.jpg', $imagick) === false) {
|
||||
throw new Exception("Could not put contents.");
|
||||
}
|
||||
return $filename_no_ext . '_thumb' . '.jpg';
|
||||
}
|
||||
else {
|
||||
throw new Exception("No valid image provided with {$img}.");
|
||||
}
|
||||
}
|
||||
|
||||
function regenerateOldPhoto($home_dir, $id)
|
||||
{
|
||||
$r = $this->db_smartone->select('m_patientphoto, m_patientphotocounter', false)
|
||||
->where('m_patientid', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
if ($r->m_patientphoto != null && $r->m_patientphotocounter > 0) {
|
||||
$full_path = substr_replace($home_dir ,"", -1) . $r->m_patientphoto;
|
||||
$path_parts = pathinfo($full_path);
|
||||
|
||||
$rename = $path_parts['dirname'] . '/' . $path_parts['filename'] . '-' . $r->m_patientphotocounter . '.' . $path_parts['extension'];
|
||||
rename($full_path, $rename);
|
||||
// echo $path_parts['dirname'], "\n";
|
||||
// echo $path_parts['extension'], "\n";
|
||||
// echo $path_parts['filename'], "\n";
|
||||
|
||||
return "/" . str_replace($home_dir, "", $rename);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
2442
application/controllers/cpone/mcuoffline/setupmcu/Setupmcugrafik.php
Normal file
2442
application/controllers/cpone/mcuoffline/setupmcu/Setupmcugrafik.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user