Initial import
This commit is contained in:
@@ -0,0 +1,863 @@
|
||||
<?php
|
||||
|
||||
class Advicekelainan extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "ABNORMAL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupkelainanbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$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 mcu_kelainan
|
||||
WHERE
|
||||
Mcu_KelainanIsActive = 'Y' AND
|
||||
Mcu_KelainanName like '%{$name}%'
|
||||
GROUP BY Mcu_KelainanID) a";
|
||||
// $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("mcu_kelainan count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT mcu_kelainan.*,
|
||||
Mcu_KelainanID as id
|
||||
from mcu_kelainan
|
||||
WHERE
|
||||
Mcu_KelainanIsActive = 'Y' AND
|
||||
Mcu_KelainanName like '%{$name}%'
|
||||
GROUP BY Mcu_KelainanID
|
||||
ORDER BY Mcu_KelainanName 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("mcu_kelainan 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 lookupadvicebyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$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(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter";
|
||||
// $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("nat_advice count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select Nat_AdviceID as id,
|
||||
Nat_AdviceID,
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdvicekelainanID,
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_KelainanName,
|
||||
Nat_AdvicekelainanMcu_KelainanID,
|
||||
Nat_AdvicekelainanNat_AdviceID,
|
||||
IF(IFNULL(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y') a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter
|
||||
GROUP BY Nat_AdviceID
|
||||
ORDER BY Nat_AdviceID 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("nat_advice 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 listingadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'";
|
||||
// $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("nat_advice count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'
|
||||
ORDER BY Nat_AdviceID 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("nat_advice 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 *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db->query($query)->result_array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_advice_fisiktype
|
||||
WHERE
|
||||
M_AdviceFisikTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db->query($query)->result_array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['minageunites'] = $this->db->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['maxageunites'] = $this->db->query($query)->result_array();
|
||||
|
||||
$query = "
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db->query($query)->result_array();
|
||||
|
||||
$query = "
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db->query($query)->result_array();
|
||||
|
||||
$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->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->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewkelainan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into mcu_kelainan(
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_KelainanName,
|
||||
M_AdviceKelainanUserID,
|
||||
Mcu_KelainanCreated,
|
||||
Mcu_KelainanLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan 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 editkelainan()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE mcu_kelainan SET
|
||||
Mcu_KelainanClasification = '{$prm['code']}',
|
||||
Mcu_KelainanName = '{$prm['name']}',
|
||||
M_AdviceKelainanUserID = {$userid}
|
||||
WHERE
|
||||
Mcu_KelainanID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db->query($query);
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db->last_query(), $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function addnewadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$kelainanid = $prm['kelainanid'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into nat_advice(
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdviceUserID,
|
||||
Nat_AdviceCreated,
|
||||
Nat_AdviceLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$adviceina,
|
||||
$adviceeng,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan 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);
|
||||
}
|
||||
}
|
||||
public function saveaddeditadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$kelainanid = $prm['kelainanid'];
|
||||
$adviceid = $prm['Nat_AdviceID'];
|
||||
$advicekelainanid = $prm['Nat_AdvicekelainanID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($status == 'Y') {
|
||||
$sql = "insert into nat_advice_kelainan(
|
||||
Nat_AdvicekelainanMcu_KelainanID,
|
||||
Nat_AdvicekelainanNat_AdviceID,
|
||||
Nat_AdvicekelainanUserID,
|
||||
Nat_AdvicekelainanCreated,
|
||||
Nat_AdvicekelainanLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$kelainanid,
|
||||
$adviceid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan 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 nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanIsActive = 'N',
|
||||
Nat_AdvicekelainanUserID = ?,
|
||||
Nat_AdvicekelainanCreated = now(),
|
||||
Nat_AdvicekelainanLastUpdated = now()
|
||||
WHERE Nat_AdvicekelainanID = ?";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$userid,
|
||||
$advicekelainanid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan 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 saveeditsaran()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_advice SET
|
||||
Nat_AdviceIna = '{$prm['ina']}',
|
||||
Nat_AdviceEng = '{$prm['eng']}',
|
||||
Nat_AdviceIsActive = '{$prm['status']}',
|
||||
Nat_AdviceUserID = {$userid}
|
||||
WHERE
|
||||
Nat_AdviceID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db->query($query);
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db->last_query(), $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function savealladvice()
|
||||
{
|
||||
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 nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanMcu_KelainanID = '{$v['Nat_AdvicekelainanMcu_KelainanID']}',
|
||||
Nat_AdvicefisikAdviceIna = '{$v['Nat_AdvicefisikAdviceIna']}',
|
||||
Nat_AdvicefisikAdviceEng = '{$v['Nat_AdvicefisikAdviceEng']}',
|
||||
Nat_AdvicekelainanUserID = {$userid},
|
||||
Nat_AdvicekelainanCreated = now(),
|
||||
Nat_AdvicekelainanLastUpdated = now()
|
||||
WHERE Nat_AdvicekelainanID = {$v['Nat_AdvicekelainanID']}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db->query($query);
|
||||
}
|
||||
|
||||
|
||||
if ($action) {
|
||||
$result = array(
|
||||
"total" => 1,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db($this->db->last_query(), $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function deletekelainan()
|
||||
{
|
||||
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 mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N'
|
||||
WHERE
|
||||
Mcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanIsActive = 'N'
|
||||
WHERE
|
||||
Nat_AdvicekelainanMcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan 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 deleteadvice()
|
||||
{
|
||||
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 mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N'
|
||||
WHERE
|
||||
Mcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan 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 searchkelainan()
|
||||
{
|
||||
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->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);
|
||||
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->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->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);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelainanbyname()
|
||||
{
|
||||
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->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);
|
||||
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->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->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);
|
||||
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->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);
|
||||
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->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->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);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,863 @@
|
||||
<?php
|
||||
|
||||
class Advicekelainan extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ABNORMAL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function lookupkelainanbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$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 mcu_kelainan
|
||||
WHERE
|
||||
Mcu_KelainanIsActive = 'Y' AND
|
||||
Mcu_KelainanName like '%{$name}%'
|
||||
GROUP BY Mcu_KelainanID) 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("mcu_kelainan count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT mcu_kelainan.*,
|
||||
Mcu_KelainanID as id
|
||||
from mcu_kelainan
|
||||
WHERE
|
||||
Mcu_KelainanIsActive = 'Y' AND
|
||||
Mcu_KelainanName like '%{$name}%'
|
||||
GROUP BY Mcu_KelainanID
|
||||
ORDER BY Mcu_KelainanName 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("mcu_kelainan 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 lookupadvicebyid()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$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(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' GROUP BY Nat_AdviceID) a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(select Nat_AdviceID as id,
|
||||
Nat_AdviceID,
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdvicekelainanID,
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_KelainanName,
|
||||
Nat_AdvicekelainanMcu_KelainanID,
|
||||
Nat_AdvicekelainanNat_AdviceID,
|
||||
IF(IFNULL(Nat_AdvicekelainanID,0) > 0 , 'Y', 'N') as status
|
||||
from nat_advice
|
||||
LEFT JOIN nat_advice_kelainan ON Nat_AdviceID = Nat_AdvicekelainanNat_AdviceID AND Nat_AdvicekelainanMcu_KelainanID = $id AND Nat_AdvicekelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_kelainan ON Nat_AdvicekelainanMcu_KelainanID = Mcu_KelainanID AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y') a
|
||||
WHERE
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%' $filter
|
||||
GROUP BY Nat_AdviceID
|
||||
ORDER BY Nat_AdviceID 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("nat_advice 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 listingadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if ($all == 'N') {
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit;
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'";
|
||||
// $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("nat_advice count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
from nat_advice
|
||||
WHERE
|
||||
Nat_AdviceIsActive = 'Y' AND
|
||||
Nat_AdviceIna like '%{$adviceina}%' AND
|
||||
Nat_AdviceEng like '%{$adviceeng}%'
|
||||
ORDER BY Nat_AdviceID 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("nat_advice 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 *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM m_advice_fisiktype
|
||||
WHERE
|
||||
M_AdviceFisikTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['minageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = " SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['maxageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = "
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query = "
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$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 addnewkelainan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into mcu_kelainan(
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_KelainanName,
|
||||
M_AdviceKelainanUserID,
|
||||
Mcu_KelainanCreated,
|
||||
Mcu_KelainanLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan 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 editkelainan()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE mcu_kelainan SET
|
||||
Mcu_KelainanClasification = '{$prm['code']}',
|
||||
Mcu_KelainanName = '{$prm['name']}',
|
||||
M_AdviceKelainanUserID = {$userid}
|
||||
WHERE
|
||||
Mcu_KelainanID = {$prm['id']}
|
||||
";
|
||||
|
||||
//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 addnewadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$kelainanid = $prm['kelainanid'];
|
||||
$adviceina = $prm['adviceina'];
|
||||
$adviceeng = $prm['adviceeng'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "insert into nat_advice(
|
||||
Nat_AdviceIna,
|
||||
Nat_AdviceEng,
|
||||
Nat_AdviceUserID,
|
||||
Nat_AdviceCreated,
|
||||
Nat_AdviceLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$adviceina,
|
||||
$adviceeng,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan 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 saveaddeditadvice()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$kelainanid = $prm['kelainanid'];
|
||||
$adviceid = $prm['Nat_AdviceID'];
|
||||
$advicekelainanid = $prm['Nat_AdvicekelainanID'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($status == 'Y') {
|
||||
$sql = "insert into nat_advice_kelainan(
|
||||
Nat_AdvicekelainanMcu_KelainanID,
|
||||
Nat_AdvicekelainanNat_AdviceID,
|
||||
Nat_AdvicekelainanUserID,
|
||||
Nat_AdvicekelainanCreated,
|
||||
Nat_AdvicekelainanLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$kelainanid,
|
||||
$adviceid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan 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 nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanIsActive = 'N',
|
||||
Nat_AdvicekelainanUserID = ?,
|
||||
Nat_AdvicekelainanCreated = now(),
|
||||
Nat_AdvicekelainanLastUpdated = now()
|
||||
WHERE Nat_AdvicekelainanID = ?";
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$userid,
|
||||
$advicekelainanid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan 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 saveeditsaran()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_advice SET
|
||||
Nat_AdviceIna = '{$prm['ina']}',
|
||||
Nat_AdviceEng = '{$prm['eng']}',
|
||||
Nat_AdviceIsActive = '{$prm['status']}',
|
||||
Nat_AdviceUserID = {$userid}
|
||||
WHERE
|
||||
Nat_AdviceID = {$prm['id']}
|
||||
";
|
||||
|
||||
//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;
|
||||
}
|
||||
}
|
||||
function savealladvice()
|
||||
{
|
||||
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 nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanMcu_KelainanID = '{$v['Nat_AdvicekelainanMcu_KelainanID']}',
|
||||
Nat_AdvicefisikAdviceIna = '{$v['Nat_AdvicefisikAdviceIna']}',
|
||||
Nat_AdvicefisikAdviceEng = '{$v['Nat_AdvicefisikAdviceEng']}',
|
||||
Nat_AdvicekelainanUserID = {$userid},
|
||||
Nat_AdvicekelainanCreated = now(),
|
||||
Nat_AdvicekelainanLastUpdated = now()
|
||||
WHERE Nat_AdvicekelainanID = {$v['Nat_AdvicekelainanID']}";
|
||||
|
||||
//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 deletekelainan()
|
||||
{
|
||||
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 mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N'
|
||||
WHERE
|
||||
Mcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update nat_advice_kelainan SET
|
||||
Nat_AdvicekelainanIsActive = 'N'
|
||||
WHERE
|
||||
Nat_AdvicekelainanMcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_advice_kelainan 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 deleteadvice()
|
||||
{
|
||||
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 mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N'
|
||||
WHERE
|
||||
Mcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan 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 searchkelainan()
|
||||
{
|
||||
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 searchkelainanbyname()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
486
one-api/application/controllers/mockup/masterdata/Almarirack.php
Normal file
486
one-api/application/controllers/mockup/masterdata/Almarirack.php
Normal file
@@ -0,0 +1,486 @@
|
||||
<?php
|
||||
|
||||
class Almarirack extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ALMARI RACK API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookuprack(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select M_RackID as id,
|
||||
M_RackID as almariid,
|
||||
M_RackCode as code,
|
||||
M_RackRows as xrows,
|
||||
M_RackColumns as xcols,
|
||||
'xxx' as action
|
||||
from m_rack
|
||||
where
|
||||
M_RackM_AlmariID = {$id} AND M_RackIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_almari
|
||||
where
|
||||
M_AlmariIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select M_AlmariID as id, M_AlmariCode as code, M_AlmariName as name, CONCAT('[ ',M_AlmariCode,' ]',' ', M_AlmariName) as description , 'xxx' as almarirack
|
||||
from m_almari
|
||||
where
|
||||
( M_AlmariCode LIKE CONCAT('%','{$search}','%') OR
|
||||
M_AlmariName LIKE CONCAT('%','{$search}','%')
|
||||
)AND
|
||||
M_AlmariIsActive = 'Y' $limit";
|
||||
$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_almari select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewalmari()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_almari WHERE M_AlmariIsActive = 'Y' AND M_AlmariCode = '{$code}'";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM m_almari WHERE M_AlmariIsActive = 'Y' AND M_AlmariName = '{$name}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
//echo $exist_name;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into m_almari(
|
||||
M_AlmariCode,
|
||||
M_AlmariName,
|
||||
M_AlmariCreated,
|
||||
M_AlmariLastUpdated,
|
||||
M_AlmariUserID
|
||||
)
|
||||
values( ?, ?, now(), now(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_almari insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editalmari()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_almari = $prm['id'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM m_almari WHERE M_AlmariIsActive = 'Y' AND M_AlmariCode = '{$code}' AND M_AlmariID <> {$id_almari}";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
//echo $this->db_onedev->last_query();
|
||||
$query = "SELECT COUNT(*) as exist FROM m_almari WHERE M_AlmariIsActive = 'Y' AND M_AlmariName = '{$name}' AND M_AlmariID <> {$id_almari}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
//echo 'IN';
|
||||
$sql = "update m_almari SET
|
||||
M_AlmariCode = ?,
|
||||
M_AlmariName = ?,
|
||||
M_AlmariLastUpdated = now()
|
||||
where
|
||||
M_AlmariID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$id_almari
|
||||
)
|
||||
);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_almari update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_almari));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewrack()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$almariid = $prm['almariid'];
|
||||
$code = $prm['code'];
|
||||
$rows = $prm['rows'];
|
||||
$cols = $prm['cols'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM m_rack WHERE M_RackIsActive = 'Y' AND M_RackCode = '{$code}' AND M_RackM_AlmariID = '{$almariid}'";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into m_rack(
|
||||
M_RackM_AlmariID,
|
||||
M_RackCode,
|
||||
M_RackRows,
|
||||
M_RackColumns,
|
||||
M_RackCreated,
|
||||
M_RackLastUpdated,
|
||||
M_RackUserID
|
||||
)
|
||||
values( ?,?,?,?,now(),now(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$almariid,
|
||||
$code,
|
||||
$rows,
|
||||
$cols,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_rack insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM m_rack WHERE M_RackIsActive = 'Y' AND M_RackCode = '{$code}' AND M_RackM_AlmariID <> '{$almariid}'";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
$query = "SELECT * FROM m_rack WHERE M_RackID = '{$prm['xid']}'";
|
||||
$data_rack = $this->db_onedev->query($query)->row();
|
||||
$exist_sample = array();
|
||||
if($data_rack->M_RackRows != $rows || $data_rack->M_RackColumns != $cols){
|
||||
$query = "SELECT * FROM summary_samplestorage JOIN t_samplestorage_detail ON T_SampleStorageDetailID = Summary_SampleStorageReffID WHERE Summary_SampleStorageM_RackID = '{$prm['xid']}' AND Summary_SampleStorageStatus = 'FILLED'";
|
||||
$exist_sample = $this->db_onedev->query($query)->result_array();
|
||||
}
|
||||
if($exist_code == 0 && count($exist_sample) == 0){
|
||||
$sql = "UPDATE m_rack SET M_RackCode = '{$code}', M_RackRows = '{$rows}', M_RackColumns = '{$cols}' , M_RackUserID = '{$userid}' WHERE M_RackID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
$error_sample = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if(count($exist_sample) != 0){
|
||||
array_push($errors,array('field'=>'existsample','msg'=>'Masih ada sample di rak dong'));
|
||||
foreach($exist_sample as $k => $v){
|
||||
array_push($error_sample,array('msg'=>'Pada rak baris '.$v['Summary_SampleStorageRowPosition'].' kolom '.$v['Summary_SampleStorageColPosition'].' ada sample '.$v['T_SampleStorageDetailBarcode']));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors,"samples" => $error_sample,"records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deleterack()
|
||||
{
|
||||
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"];
|
||||
|
||||
$query = "SELECT * FROM m_rack WHERE M_RackID = '{$prm['id']}'";
|
||||
$data_rack = $this->db_onedev->query($query)->row();
|
||||
$exist_sample = array();
|
||||
if($data_rack->M_RackRows != $rows || $data_rack->M_RackColumns != $cols){
|
||||
$query = "SELECT * FROM summary_samplestorage JOIN t_samplestorage_detail ON T_SampleStorageDetailID = Summary_SampleStorageReffID WHERE Summary_SampleStorageM_RackID = '{$prm['id']}' AND Summary_SampleStorageStatus = 'FILLED'";
|
||||
$exist_sample = $this->db_onedev->query($query)->result_array();
|
||||
}
|
||||
if(count($exist_sample) == 0){
|
||||
$sql = "update m_rack SET
|
||||
M_RackIsActive = 'N',
|
||||
M_RackLastUpdated = now(),
|
||||
M_RackUserID = ?
|
||||
WHERE
|
||||
M_RackID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_rack delete");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
if(count($exist_sample) != 0){
|
||||
$errors = array();
|
||||
$error_sample = array();
|
||||
array_push($errors,array('field'=>'existsample','msg'=>'Masih ada sample di rak dong'));
|
||||
foreach($exist_sample as $k => $v){
|
||||
array_push($error_sample,array('msg'=>'Pada rak baris '.$v['Summary_SampleStorageRowPosition'].' kolom '.$v['Summary_SampleStorageColPosition'].' ada sample '.$v['T_SampleStorageDetailBarcode']));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors,"samples" => $error_sample,"records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deletealmari()
|
||||
{
|
||||
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"];
|
||||
$exist_sample = array();
|
||||
|
||||
$query = " SELECT *
|
||||
FROM summary_samplestorage
|
||||
JOIN t_samplestorage_detail ON T_SampleStorageDetailID = Summary_SampleStorageReffID
|
||||
JOIN m_rack ON Summary_SampleStorageM_RackID = M_RackID
|
||||
WHERE Summary_SampleStorageM_AlmariID = '{$prm['id']}' AND Summary_SampleStorageStatus = 'FILLED'";
|
||||
$exist_sample = $this->db_onedev->query($query)->result_array();
|
||||
if(count($exist_sample) == 0){
|
||||
$sql = "update m_almari SET
|
||||
M_AlmariIsActive = 'N',
|
||||
M_AlmariLastUpdated = now(),
|
||||
M_AlmariUserID = ?
|
||||
WHERE
|
||||
M_AlmariID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_almari delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE m_rack SET
|
||||
M_RackIsActive = 'N',
|
||||
M_RackLastUpdated = now(),
|
||||
M_RackUserID = ?
|
||||
WHERE
|
||||
M_RackM_AlmariID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid ,
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_rack delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else{
|
||||
if(count($exist_sample) != 0){
|
||||
$errors = array();
|
||||
$error_sample = array();
|
||||
array_push($errors,array('field'=>'existsample','msg'=>'Masih ada sample di lemari dong'));
|
||||
foreach($exist_sample as $k => $v){
|
||||
array_push($error_sample,array('msg'=>'Pada rak '.$v['M_RackCode'].' baris '.$v['Summary_SampleStorageRowPosition'].' kolom '.$v['Summary_SampleStorageColPosition'].' ada sample '.$v['T_SampleStorageDetailBarcode']));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors,"samples" => $error_sample,"records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,771 @@
|
||||
<?php
|
||||
|
||||
class Autoverification extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "AUTO VERIFICATION API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookuptrendanalys(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select nat_trend_analysis.*,T_TestID as testid
|
||||
from nat_trend_analysis
|
||||
JOIN t_test ON Nat_TrendAnalysisT_TestID = T_TestID AND T_TestIsActive = 'Y'
|
||||
where
|
||||
Nat_TrendAnalysisT_TestID = {$id} AND Nat_TrendAnalysisIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_trend_analysis select");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function lookuphasil(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select Nat_MultiruleID as id, M_ValueName as name, Nat_MultiruleM_ValueID as hasilid, Nat_MultiruleT_TestID as testid
|
||||
from nat_multirule
|
||||
JOIN m_value ON Nat_MultiruleM_ValueID = M_ValueID AND M_ValueIsActive = 'Y'
|
||||
where
|
||||
Nat_MultiruleT_TestID = {$id} AND Nat_MultiruleIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_multirule");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from t_test
|
||||
LEFT JOIN nat_trend_analysis ON T_TestID = Nat_TrendAnalysisT_TestID
|
||||
LEFT JOIN nat_delta_check ON T_TestID = Nat_DeltaCheckT_TestID
|
||||
where
|
||||
T_TestIsActive = 'Y' AND
|
||||
T_TestIsQuantitative = 'Y' AND
|
||||
T_TestIsResult = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select T_TestID as id, CONCAT(T_TestName,' ' ,'[ ',T_TestCode,' ]') as name,
|
||||
Nat_TrendAnalysisT_TestID,Nat_TrendAnalysisMinimunTest,Nat_TrendAnalysisValue,
|
||||
nat_delta_check.*, M_TimeName as xtime, M_DifferenceName as xdif,T_TestIsDeltaCheck,T_TestIsTrendAnalysis
|
||||
from t_test
|
||||
LEFT JOIN nat_trend_analysis ON T_TestID = Nat_TrendAnalysisT_TestID
|
||||
LEFT JOIN nat_delta_check ON T_TestID = Nat_DeltaCheckT_TestID
|
||||
LEFT JOIN m_time ON Nat_DeltaCheckM_TimeID = M_TimeID
|
||||
LEFT JOIN m_difference ON Nat_DeltaCheckM_DifferenceID = M_DifferenceID
|
||||
where
|
||||
(T_TestName LIKE CONCAT('%','{$search}','%') OR T_TestCode LIKE CONCAT('%','{$search}','%')) AND
|
||||
T_TestIsActive = 'Y' AND
|
||||
T_TestIsQuantitative = 'Y' AND
|
||||
(T_TestIsDeltaCheck = 'Y' OR T_TestIsTrendAnalysis = 'Y') $limit";
|
||||
// echo $sql;
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("t_test select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_schedule = $prm['name'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_schedule WHERE M_ScheduleIsActive = 'Y' AND M_ScheduleName = '{$name_schedule}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into m_schedule(
|
||||
M_ScheduleName,
|
||||
M_ScheduleCreated,
|
||||
M_ScheduleLastUpdated
|
||||
)
|
||||
values( ?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_schedule
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_schedule = $prm['id'];
|
||||
$name_schedule = $prm['name'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM m_schedule WHERE M_ScheduleIsActive = 'Y' AND M_ScheduleName = '{$name_schedule}' AND M_ScheduleID <> {$id_schedule}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "update m_schedule SET
|
||||
M_ScheduleName = ?,
|
||||
M_ScheduleLastUpdated = now()
|
||||
where
|
||||
M_ScheduleID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_schedule,
|
||||
$id_schedule
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_schedule));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function savetrendanalys()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$mintest = $prm['mintest'];
|
||||
$trendvalue = $prm['trendvalue'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_trend_analysis WHERE Nat_TrendAnalysisIsActive = 'Y' AND Nat_TrendAnalysisT_TestID = '{$testid}'";
|
||||
$exist_test = $this->db_onedev->query($query)->row()->exist;
|
||||
if($exist_test == 0){
|
||||
$sql = "insert into nat_trend_analysis(
|
||||
Nat_TrendAnalysisT_TestID,
|
||||
Nat_TrendAnalysisMinimunTest,
|
||||
Nat_TrendAnalysisValue,
|
||||
Nat_TrendAnalysisCreated,
|
||||
Nat_TrendAnalysisLastUpdated
|
||||
)
|
||||
values( ?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$mintest,
|
||||
$trendvalue
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_trend_analysis insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$sql = "update nat_trend_analysis SET
|
||||
Nat_TrendAnalysisMinimunTest = ?,
|
||||
Nat_TrendAnalysisValue = ?,
|
||||
Nat_TrendAnalysisLastUpdated = now()
|
||||
WHERE
|
||||
Nat_TrendAnalysisIsActive = 'Y' AND
|
||||
Nat_TrendAnalysisT_TestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$mintest,
|
||||
$trendvalue,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_trend_analysis update");
|
||||
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 savedeltacheck()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$differenceid = $prm['differenceid'];
|
||||
$validinterval = $prm['validinterval'];
|
||||
$timeid = $prm['timeid'];
|
||||
$upperlimit = $prm['upperlimit'];
|
||||
$lowerlimit = $prm['lowerlimit'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_delta_check WHERE Nat_DeltaCheckIsActive = 'Y' AND Nat_DeltaCheckT_TestID = '{$testid}'";
|
||||
$exist_test = $this->db_onedev->query($query)->row()->exist;
|
||||
if($exist_test == 0){
|
||||
$sql = "insert into nat_delta_check(
|
||||
Nat_DeltaCheckT_TestID,
|
||||
Nat_DeltaCheckM_DifferenceID,
|
||||
Nat_DeltaCheckValidInterval,
|
||||
Nat_DeltaCheckM_TimeID,
|
||||
Nat_DeltaCheckUpperLimit,
|
||||
Nat_DeltaCheckLowerLimit,
|
||||
Nat_DeltaCheckCreated,
|
||||
Nat_DeltaCheckLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$differenceid,
|
||||
$validinterval,
|
||||
$timeid,
|
||||
$upperlimit,
|
||||
$lowerlimit
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_delta_check insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
$sql = "update nat_delta_check SET
|
||||
Nat_DeltaCheckM_DifferenceID = ?,
|
||||
Nat_DeltaCheckValidInterval = ?,
|
||||
Nat_DeltaCheckM_TimeID = ?,
|
||||
Nat_DeltaCheckUpperLimit = ?,
|
||||
Nat_DeltaCheckLowerLimit = ?,
|
||||
Nat_DeltaCheckLastUpdated = now()
|
||||
WHERE
|
||||
Nat_DeltaCheckIsActive = 'Y' AND
|
||||
Nat_DeltaCheckT_TestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$differenceid,
|
||||
$validinterval,
|
||||
$timeid,
|
||||
$upperlimit,
|
||||
$lowerlimit,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_delta_check update");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function selectvaluex(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_value
|
||||
WHERE
|
||||
M_ValueIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['valuexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function selecttime(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_time
|
||||
WHERE
|
||||
M_TimeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['times'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function selectdif(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_difference
|
||||
WHERE
|
||||
M_DifferenceIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['difs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
public function savemultirule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$hasilid = $prm['hasilid'];
|
||||
|
||||
$sql = "insert into nat_multirule(
|
||||
Nat_MultiruleT_TestID,
|
||||
Nat_MultiruleM_ValueID,
|
||||
Nat_MultiruleCreated,
|
||||
Nat_MultiruleLastUpdated
|
||||
)
|
||||
values( ?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$hasilid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_multirule insert");
|
||||
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 deleteschedulepromise()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_schedulepromise SET
|
||||
M_SchedulePromiseIsActive = 'N',
|
||||
M_SchedulePromiseLastUpdate = now()
|
||||
WHERE
|
||||
M_SchedulePromiseID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise 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 deletescheduletest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_scheduletest SET
|
||||
M_ScheduleTestIsActive = 'N',
|
||||
M_ScheduleTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleTestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_scheduletest 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 deleteschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_schedule SET
|
||||
M_ScheduleIsActive = 'N',
|
||||
M_ScheduleLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_scheduletest SET
|
||||
M_ScheduleTestIsActive = 'N',
|
||||
M_ScheduleTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleTestM_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_scheduletest delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_schedulepromise SET
|
||||
M_SchedulePromiseIsActive = 'N',
|
||||
M_SchedulePromiseLastUpdate = now()
|
||||
WHERE
|
||||
M_SchedulePromiseM_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise 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 searchtest()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$scheduleid = $prm['id'];
|
||||
$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
|
||||
LEFT JOIN m_scheduletest ON M_ScheduleTestT_TestID = T_TestID AND M_ScheduleTestM_ScheduleID = ? AND M_ScheduleTestIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(M_ScheduleTestID) AND
|
||||
|
||||
T_TestIsActive = 'Y'
|
||||
AND T_TestName like ?";
|
||||
$query = $this->db_onedev->query($sql,array($scheduleid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_test count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_TestID as id,
|
||||
T_TestName as name
|
||||
FROM t_test
|
||||
LEFT JOIN m_scheduletest ON M_ScheduleTestT_TestID = T_TestID AND M_ScheduleTestM_ScheduleID = ? AND M_ScheduleTestIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(M_ScheduleTestID) AND
|
||||
T_TestIsActive = 'Y'
|
||||
AND T_TestName like ?
|
||||
ORDER BY T_TestCode ASC
|
||||
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($scheduleid,$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
424
one-api/application/controllers/mockup/masterdata/Bahan.php
Normal file
424
one-api/application/controllers/mockup/masterdata/Bahan.php
Normal file
@@ -0,0 +1,424 @@
|
||||
<?php
|
||||
|
||||
class Bahan extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "BAHAN API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookupsampletype(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select Nat_SampleTypeID as id,
|
||||
Nat_SampleTypeNat_BahanID as bahanid,
|
||||
Nat_SampleTypeCode as code,
|
||||
Nat_SampleTypeName as name,
|
||||
Nat_SampleTypeSuffix as suffix,
|
||||
'xxx' as action
|
||||
from nat_sampletype
|
||||
where
|
||||
Nat_SampleTypeNat_BahanID = {$id} AND Nat_SampleTypeIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_bahan
|
||||
where
|
||||
Nat_BahanIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select Nat_BahanID as id, Nat_BahanCode as code, Nat_BahanName as name, CONCAT('[ ',Nat_BahanCode,' ]',' ', Nat_BahanName) as description , 'xxx' as bahansampletype
|
||||
from nat_bahan
|
||||
where
|
||||
( Nat_BahanCode LIKE CONCAT('%','{$search}','%') OR
|
||||
Nat_BahanName LIKE CONCAT('%','{$search}','%')
|
||||
)AND
|
||||
Nat_BahanIsActive = 'Y' $limit";
|
||||
$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("nat_bahan select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code_bahan = $prm['code'];
|
||||
$name_bahan = $prm['name'];
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanCode = '{$code_bahan}'";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanName = '{$name_bahan}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
//echo $exist_name;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into nat_bahan(
|
||||
Nat_BahanCode,
|
||||
Nat_BahanName,
|
||||
Nat_BahanCreated,
|
||||
Nat_BahanLastUpdated
|
||||
)
|
||||
values( ?, ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_bahan = $prm['id'];
|
||||
$code_bahan = $prm['code'];
|
||||
$name_bahan = $prm['name'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanCode = '{$code_bahan}' AND Nat_BahanID <> {$id_bahan}";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_bahan WHERE Nat_BahanIsActive = 'Y' AND Nat_BahanName = '{$name_bahan}' AND Nat_BahanID <> {$id_bahan}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "update nat_bahan SET
|
||||
Nat_BahanCode = ?,
|
||||
Nat_BahanName = ?,
|
||||
Nat_BahanLastUpdated = now()
|
||||
where
|
||||
Nat_BahanID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code_bahan,
|
||||
$name_bahan,
|
||||
$id_bahan
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_bahan));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewsampletype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$bahanid = $prm['bahanid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$suffix = $prm['suffix'];
|
||||
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeCode = '{$code}'";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeName = '{$name}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into nat_sampletype(
|
||||
Nat_SampleTypeNat_BahanID,
|
||||
Nat_SampleTypeCode,
|
||||
Nat_SampleTypeName,
|
||||
Nat_SampleTypeSuffix,
|
||||
Nat_SampleTypeCreated,
|
||||
Nat_SampleTypeLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$bahanid,
|
||||
$code,
|
||||
$name,
|
||||
$suffix
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeCode = '{$code}' AND Nat_SampleTypeID <> {$prm['xid']}";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
$query = "SELECT COUNT(*) as exist FROM nat_sampletype WHERE Nat_SampleTypeIsActive = 'Y' AND Nat_SampleTypeName = '{$name}' AND Nat_SampleTypeID <> {$prm['xid']}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "UPDATE nat_sampletype SET Nat_SampleTypeCode = '{$code}', Nat_SampleTypeName = '{$name}', Nat_SampleTypeSuffix = '{$suffix}' WHERE Nat_SampleTypeID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','msg'=>'Kode sudah ada yang pakai dong'));
|
||||
}
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deletesampletype()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_sampletype SET
|
||||
Nat_SampleTypeIsActive = 'N',
|
||||
Nat_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
Nat_SampleTypeID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype 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 deletebahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_bahan SET
|
||||
Nat_BahanIsActive = 'N',
|
||||
Nat_BahanLastUpdated = now()
|
||||
WHERE
|
||||
Nat_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE nat_sampletype SET
|
||||
Nat_SampleTypeIsActive = 'N',
|
||||
Nat_SampleTypeLastUpdated = now()
|
||||
WHERE
|
||||
Nat_SampleTypeNat_BahanID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_sampletype delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1310
one-api/application/controllers/mockup/masterdata/Company.php
Normal file
1310
one-api/application/controllers/mockup/masterdata/Company.php
Normal file
File diff suppressed because it is too large
Load Diff
1204
one-api/application/controllers/mockup/masterdata/Companylevel.php
Normal file
1204
one-api/application/controllers/mockup/masterdata/Companylevel.php
Normal file
File diff suppressed because it is too large
Load Diff
1770
one-api/application/controllers/mockup/masterdata/Companynew.php
Normal file
1770
one-api/application/controllers/mockup/masterdata/Companynew.php
Normal file
File diff suppressed because it is too large
Load Diff
1839
one-api/application/controllers/mockup/masterdata/Companynewx.php
Normal file
1839
one-api/application/controllers/mockup/masterdata/Companynewx.php
Normal file
File diff suppressed because it is too large
Load Diff
1839
one-api/application/controllers/mockup/masterdata/Companynewx2.php
Normal file
1839
one-api/application/controllers/mockup/masterdata/Companynewx2.php
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
197
one-api/application/controllers/mockup/masterdata/Counter.php
Normal file
197
one-api/application/controllers/mockup/masterdata/Counter.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
class Counter extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SERVICE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_antrione = $this->load->database("antrione", true);
|
||||
}
|
||||
|
||||
public function loadx()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select COUNT(*) as total
|
||||
from counter
|
||||
where
|
||||
counterIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_antrione->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select *
|
||||
from counter
|
||||
where
|
||||
counterIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_antrione->query($sql,$sql_param);
|
||||
//echo $this->db_antrione->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("counter select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$ip = $prm['ip'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM counter WHERE counterIsActive = 'Y' AND counterCode = '{$code}'";
|
||||
$exist_code = $this->db_antrione->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0){
|
||||
$sql = "insert into counter(
|
||||
counterCode,
|
||||
counterIP
|
||||
)
|
||||
values( ?,?)";
|
||||
$query = $this->db_antrione->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$ip
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("counter insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$code = $prm['code'];
|
||||
$ip = $prm['ip'];
|
||||
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM counter WHERE counterIsActive = 'Y' AND counterCode = '{$code}' AND counterID <> {$id}";
|
||||
//echo $query;
|
||||
$exist_code = $this->db_antrione->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0){
|
||||
$sql = "update counter set
|
||||
counterCode = ?,
|
||||
counterIP = ?
|
||||
where counterID = ?
|
||||
";
|
||||
$query = $this->db_antrione->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$priority,
|
||||
$id
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("counter update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deletex()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$sql = "update counter set
|
||||
counterIsActive = 'N'
|
||||
where counterID = ?
|
||||
";
|
||||
$query = $this->db_antrione->query($sql,
|
||||
array(
|
||||
$id
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("counter delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
1024
one-api/application/controllers/mockup/masterdata/Courierarea.php
Normal file
1024
one-api/application/controllers/mockup/masterdata/Courierarea.php
Normal file
File diff suppressed because it is too large
Load Diff
489
one-api/application/controllers/mockup/masterdata/Day.php
Normal file
489
one-api/application/controllers/mockup/masterdata/Day.php
Normal file
@@ -0,0 +1,489 @@
|
||||
<?php
|
||||
class Day extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "DAY API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookuppromise(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select distinct
|
||||
SsNoPromiseID as id,
|
||||
M_DayOfWeekID as usergroupid,
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName As name,
|
||||
group_concat(distinct M_DayOfWeekName order by M_DayOfWeekID) AS Hari ,
|
||||
group_concat(distinct SsNoPromiseHour separator ' , ' ) AS Jam,
|
||||
group_concat(distinct M_MouName) AS Agreement,
|
||||
'xxx' as action
|
||||
|
||||
from ss_no_promise
|
||||
join nat_test on SSNoPromiseNat_TestID = Nat_TestID
|
||||
join m_dayofweek on SsNoPromiseDow = M_DayOfWeekID
|
||||
join m_mou on json_contains(SsNoPromiseInAgreementJson, M_MouID )
|
||||
where
|
||||
M_DayOfWeekID = {$id} AND SsNoPromiseInAgreement = 'Y'
|
||||
group by Nat_TestCode
|
||||
";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_dayofweek
|
||||
where
|
||||
M_DayOfWeekIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select M_DayOfWeekID as id,
|
||||
M_DayOfWeekName as code,
|
||||
M_DayOfWeekName as name,
|
||||
M_DayOfWeekName as description ,
|
||||
'xxx' as usergrouptype
|
||||
from m_dayofweek
|
||||
where
|
||||
M_DayOfWeekName LIKE CONCAT('%','{$search}','%') AND
|
||||
M_DayOfWeekIsActive = 'Y' $limit";
|
||||
$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_dayofweek select",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewstation()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$name_station = $prm['name'];
|
||||
$code_station = $prm['code'];
|
||||
$isnonlab_station = $prm['isnonlab'];
|
||||
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
//echo $exist_name;
|
||||
if($exist_name == 0 ){
|
||||
$sql = "insert into t_samplestation(
|
||||
T_SampleStationCode,
|
||||
T_SampleStationName,
|
||||
T_SampleStationIsNonLab,
|
||||
T_SampleStationCreated,
|
||||
T_SampleStationLastUpdated
|
||||
)
|
||||
values( ?, ?, ?,now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_station,
|
||||
$code_station,
|
||||
$isnonlab_station
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else{
|
||||
$errors = array();
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada '));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editstation()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_station = $prm['id'];
|
||||
$code_station = $prm['code'];
|
||||
$name_station = $prm['name'];
|
||||
$isnonlab_station = $prm['isnonlab'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'
|
||||
AND T_SampleStationID <> {$id_station} ";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
if($exist_name == 0){
|
||||
|
||||
$sql = "update t_samplestation SET
|
||||
T_SampleStationCode = ?,
|
||||
T_SampleStationName = ?,
|
||||
T_SampleStationIsNonLab = ?,
|
||||
T_SampleStationLastUpdated = now()
|
||||
where
|
||||
T_SampleStationID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code_station,
|
||||
$name_station,
|
||||
$isnonlab_station,
|
||||
$id_station
|
||||
)
|
||||
);
|
||||
//file_put_contents("/tmp/adi-update-user.sql",$this->db_onedev->last_query());
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_station));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$bahanid = $prm['xid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$xstationname = $prm['xstationname'];
|
||||
|
||||
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'
|
||||
and T_BahanID <> $bahanid ";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
|
||||
$sql = "update m_user SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanT_SampleStationID = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where T_BahanID = ? ";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$xstationname["T_SampleStationID"],
|
||||
$bahanid
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan update",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $bahanid));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$errors = array();
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$stationid = $prm['stationid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into t_bahan(
|
||||
T_BahanT_SampleStationID,
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$stationid,
|
||||
$code,
|
||||
$name
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}' AND T_BahanID <> {$prm['xid']}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
|
||||
//echo $query;
|
||||
if($exist_name == 0 ){
|
||||
$sql = "UPDATE t_bahan SET T_BahanName = '{$name}', T_BahanCode = '{$code}' WHERE T_BahanID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'name sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function deletebahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_bahan SET
|
||||
T_BahanIsActive = 'N',
|
||||
T_BahanLastUpdated = now()
|
||||
WHERE
|
||||
T_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan 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 deleteselect()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_samplestation SET
|
||||
T_SampleStationIsActive = 'N',
|
||||
T_SampleStationLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleStationID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE m_user SET
|
||||
M_UserIsActive = 'N',
|
||||
M_UserLastUpdated = now()
|
||||
WHERE
|
||||
M_UserM_UserGroupID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_user delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
490
one-api/application/controllers/mockup/masterdata/Day_bkp.php
Normal file
490
one-api/application/controllers/mockup/masterdata/Day_bkp.php
Normal file
@@ -0,0 +1,490 @@
|
||||
<?php
|
||||
class Day extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "DAY API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookuppromise(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select
|
||||
|
||||
distinct
|
||||
SsNoPromiseID as id,
|
||||
M_DayOfWeekID as dayid,
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName As name,
|
||||
group_concat(distinct M_DayOfWeekName order by M_DayOfWeekID) AS Hari ,
|
||||
group_concat(distinct SsNoPromiseHour )AS Jam,
|
||||
group_concat(distinct M_MouName) AS Agreement,
|
||||
'xxx' as action
|
||||
|
||||
from
|
||||
ss_no_promise
|
||||
join nat_test on SSNoPromiseNat_TestID = Nat_TestID
|
||||
join m_dayofweek on SsNoPromiseDow = M_DayOfWeekID
|
||||
join m_mou on json_contains(SsNoPromiseInAgreementJson, M_MouID )
|
||||
where
|
||||
SsNoPromiseDow = {$id} AND SsNoPromiseInAgreement = 'Y'
|
||||
group by Nat_TestCode";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_dayofweek
|
||||
where
|
||||
M_DayOfWeekIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select M_DayOfWeekID as id,
|
||||
'' as code,
|
||||
M_DayOfWeekName as name,
|
||||
M_DayOfWeekName as description , 'xxx' as usergrouptype
|
||||
from t_samplestation
|
||||
where
|
||||
M_DayOfWeekName LIKE CONCAT('%','{$search}','%') AND
|
||||
M_DayOfWeekIsActive = 'Y' $limit";
|
||||
$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("t_samplestation select",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewstation()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$name_station = $prm['name'];
|
||||
$code_station = $prm['code'];
|
||||
$isnonlab_station = $prm['isnonlab'];
|
||||
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
//echo $exist_name;
|
||||
if($exist_name == 0 ){
|
||||
$sql = "insert into t_samplestation(
|
||||
T_SampleStationCode,
|
||||
T_SampleStationName,
|
||||
T_SampleStationIsNonLab,
|
||||
T_SampleStationCreated,
|
||||
T_SampleStationLastUpdated
|
||||
)
|
||||
values( ?, ?, ?,now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_station,
|
||||
$code_station,
|
||||
$isnonlab_station
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else{
|
||||
$errors = array();
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada '));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editstation()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_station = $prm['id'];
|
||||
$code_station = $prm['code'];
|
||||
$name_station = $prm['name'];
|
||||
$isnonlab_station = $prm['isnonlab'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'
|
||||
AND T_SampleStationID <> {$id_station} ";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
if($exist_name == 0){
|
||||
|
||||
$sql = "update t_samplestation SET
|
||||
T_SampleStationCode = ?,
|
||||
T_SampleStationName = ?,
|
||||
T_SampleStationIsNonLab = ?,
|
||||
T_SampleStationLastUpdated = now()
|
||||
where
|
||||
T_SampleStationID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code_station,
|
||||
$name_station,
|
||||
$isnonlab_station,
|
||||
$id_station
|
||||
)
|
||||
);
|
||||
//file_put_contents("/tmp/adi-update-user.sql",$this->db_onedev->last_query());
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_station));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$bahanid = $prm['xid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$xstationname = $prm['xstationname'];
|
||||
|
||||
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'
|
||||
and T_BahanID <> $bahanid ";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
|
||||
$sql = "update m_user SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanT_SampleStationID = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where T_BahanID = ? ";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$xstationname["T_SampleStationID"],
|
||||
$bahanid
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan update",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $bahanid));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$errors = array();
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$stationid = $prm['stationid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into t_bahan(
|
||||
T_BahanT_SampleStationID,
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$stationid,
|
||||
$code,
|
||||
$name
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}' AND T_BahanID <> {$prm['xid']}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
|
||||
//echo $query;
|
||||
if($exist_name == 0 ){
|
||||
$sql = "UPDATE t_bahan SET T_BahanName = '{$name}', T_BahanCode = '{$code}' WHERE T_BahanID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'name sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function deletebahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_bahan SET
|
||||
T_BahanIsActive = 'N',
|
||||
T_BahanLastUpdated = now()
|
||||
WHERE
|
||||
T_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan 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 deleteselect()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_samplestation SET
|
||||
T_SampleStationIsActive = 'N',
|
||||
T_SampleStationLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleStationID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE m_user SET
|
||||
M_UserIsActive = 'N',
|
||||
M_UserLastUpdated = now()
|
||||
WHERE
|
||||
M_UserM_UserGroupID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_user delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
714
one-api/application/controllers/mockup/masterdata/Doctor.php
Normal file
714
one-api/application/controllers/mockup/masterdata/Doctor.php
Normal file
@@ -0,0 +1,714 @@
|
||||
<?php
|
||||
class Doctor extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$staff = $prm['staff'];
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
$sql_where .= " M_DoctorIsMarketingConfirm = '{$status}' AND M_DoctorIsActive = 'Y' ";
|
||||
if ($sql_where != "") {
|
||||
$sql_where = " where $sql_where";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
if(intval($staff) > 0){
|
||||
$sql_where = "$sql_where AND M_DoctorM_StaffID = {$staff}";
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
LEFT JOIN m_staff ON M_DoctorM_StaffID = M_StaffID
|
||||
|
||||
$sql_where
|
||||
";
|
||||
$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("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_DoctorID,
|
||||
M_DoctorOldCode,
|
||||
M_DoctorCode ,
|
||||
M_DoctorPrefix ,
|
||||
M_DoctorPrefix2 ,
|
||||
M_DoctorName ,
|
||||
M_DoctorSufix ,
|
||||
M_DoctorSufix2 ,
|
||||
M_DoctorSufix3 ,
|
||||
M_DoctorM_SexID ,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
IFNULL(M_DoctorEmail,'') as M_DoctorEmail,
|
||||
M_DoctorHP ,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone ,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
ifnull(M_DoctorPjIsPJ,'N') M_DoctorIsPJ,
|
||||
ifnull(M_DoctorPjIsDefaultPJ,'N') M_DoctorIsDefaultPJ ,
|
||||
M_DoctorM_SpecialID ,
|
||||
ifnull(M_DoctorPjIsClinic,'N') M_DoctorIsClinic ,
|
||||
ifnull(M_DoctorPjIsDefault,'N') M_DoctorIsDefault ,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorCreated ,
|
||||
M_DoctorLastUpdated,
|
||||
M_DoctorIsActive,
|
||||
M_DoctorReportCode ,
|
||||
M_DoctorPrivateRequest,
|
||||
M_DoctorM_UserID ,
|
||||
";
|
||||
$sql = "SELECT $doctor_field
|
||||
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_fullname,
|
||||
M_SexName,
|
||||
M_ReligionName,
|
||||
M_StaffName,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N', 'Belum dikonfirmasi marketing','Sudah dikonfirmasi marketing') as status
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
left join m_doctorpj on M_DoctorID = M_DoctorPjM_DoctorID AND M_DoctorPjIsActive = 'Y'
|
||||
left JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
left JOIN m_staff ON M_DoctorM_StaffID = M_StaffID
|
||||
$sql_where
|
||||
ORDER BY M_DoctorName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_onedev->query($query)->result_array();
|
||||
$query ="
|
||||
SELECT 0 as M_StaffID, 'Semua' as M_StaffName
|
||||
UNION
|
||||
SELECT M_StaffID, M_StaffName
|
||||
FROM m_staff
|
||||
WHERE
|
||||
M_StaffIsActive = 'Y' and M_StaffM_PositionID = '2'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['staffs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['jpas'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function searchcity(){
|
||||
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 m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = '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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getjpa(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
// $rows['jpas'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
// ambil data lama
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$old_doctor = array();
|
||||
if (count($rows) > 0 ) $old_doctor = $rows[0];
|
||||
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
if($prm['M_DoctorEmail'] == ''){
|
||||
$prm['M_DoctorEmailIsDefault'] = 'N';
|
||||
}
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorPrefix2 = '{$prm['M_DoctorPrefix2']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorSufix2 = '{$prm['M_DoctorSufix2']}',
|
||||
M_DoctorSufix3 = '{$prm['M_DoctorSufix3']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorM_StaffID = '{$prm['M_DoctorM_StaffID']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorNote = '{$prm['M_DoctorNote']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorIsPJ = '{$prm['M_DoctorIsPJ']}',
|
||||
M_DoctorIsDefaultPJ = '{$prm['M_DoctorIsDefaultPJ']}',
|
||||
M_DoctorIsClinic = '{$prm['M_DoctorIsClinic']}',
|
||||
M_DoctorIsDefault = '{$prm['M_DoctorIsDefault']}',
|
||||
M_DoctorEmailIsDefault = '{$prm['M_DoctorEmailIsDefault']}'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$sqlx = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y'";
|
||||
$qryx= $this->db_onedev->query($sqlx,array($prm["M_DoctorID"]));
|
||||
$rowsx = $qryx->result_array();
|
||||
if (count($rowsx) > 0 ) {
|
||||
$sql = "UPDATE m_doctorpj set
|
||||
M_DoctorPjIsPJ = ?, M_DoctorPjIsDefaultPJ = ?, M_DoctorPjIsClinic = ?, M_DoctorPjIsDefault =?
|
||||
where M_DoctorPjM_DoctorID = ? AND M_DoctorPjIsActive = 'Y'";
|
||||
$this->db_onedev->query($sql, array($ispj,$isdefaultpj,$isclinic,$isdefault,$prm["M_DoctorID"]));
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}else{
|
||||
//sipe modifikasi ispj
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$sql = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y' ";
|
||||
$qry = $this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$sql = "insert into m_doctorpj(M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ, M_DoctorPjIsDefaultPJ, M_DoctorPjIsClinic, M_DoctorPjIsDefault)
|
||||
values(?,?,?,?,?)";
|
||||
$this->db_onedev->query($sql, array($prm["M_DoctorID"],$ispj,$isdefaultpj,$isclinic,$isdefault));
|
||||
}
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
} else {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsActive= 'N', M_DoctorPjIsPJ = 'N'
|
||||
where M_DoctorPjM_DoctorID = ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
// ambil data baru
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$new_doctor = array();
|
||||
if (count($rows) > 0 ) $new_doctor = $rows[0];
|
||||
$d_doctor = json_encode(array("old" => $old_doctor , "new" => $new_doctor));
|
||||
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorM_StaffID,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorIsPJ,
|
||||
M_DoctorIsDefaultPJ,
|
||||
M_DoctorIsClinic,
|
||||
M_DoctorIsDefault,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorM_UserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorPrefix2']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorSufix2']}',
|
||||
'{$prm['M_DoctorSufix3']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorM_StaffID']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorNote']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
'{$prm['M_DoctorEmailIsDefault']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($rows){
|
||||
if($isdefault == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefault = 'N' WHERE M_DoctorPjIsDefault = 'Y'
|
||||
";
|
||||
$rows = $this->db_onedev->query($querydefault);
|
||||
}
|
||||
if($isdefaultpj == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefaultPJ = 'N' WHERE M_DoctorPjIsDefaultPJ = 'Y'
|
||||
";
|
||||
$rows = $this->db_onedev->query($querydefault);
|
||||
}
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$querypj ="INSERT INTO m_doctorpj (
|
||||
M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ,
|
||||
M_DoctorPjIsDefaultPJ,
|
||||
M_DoctorPjIsClinic,
|
||||
M_DoctorPjIsDefault,
|
||||
M_DoctorPjCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$rows = $this->db_onedev->query($querypj);
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
//sipe tambah log doctor
|
||||
$prm["M_DoctorID"] = $last_id;
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_ADD','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// sipe nambah ambil userid
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_doctoraddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,Nat_JpaName,
|
||||
'' as action
|
||||
FROM m_doctoraddress
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
left join nat_jpa on M_DoctorAddressNat_JpaID = Nat_JpaID
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressNat_JpaID,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
'{$prm['M_DoctorAddressNat_JpaID']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
M_DoctorAddressNat_JpaID = '{$prm['M_DoctorAddressNat_JpaID']}'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
655
one-api/application/controllers/mockup/masterdata/Doctor0.php
Normal file
655
one-api/application/controllers/mockup/masterdata/Doctor0.php
Normal file
@@ -0,0 +1,655 @@
|
||||
<?php
|
||||
class Doctor extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_DoctorName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
$sql_where .= " M_DoctorIsMarketingConfirm = '{$status}' AND M_DoctorIsActive = 'Y' ";
|
||||
if ($sql_where != "") {
|
||||
$sql_where = " where $sql_where";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
$sql_where
|
||||
";
|
||||
$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("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$doctor_field = "
|
||||
M_DoctorID,
|
||||
M_DoctorOldCode,
|
||||
M_DoctorCode ,
|
||||
M_DoctorPrefix ,
|
||||
M_DoctorPrefix2 ,
|
||||
M_DoctorName ,
|
||||
M_DoctorSufix ,
|
||||
M_DoctorSufix2 ,
|
||||
M_DoctorSufix3 ,
|
||||
M_DoctorM_SexID ,
|
||||
M_DoctorM_ReligionID,
|
||||
IFNULL(M_DoctorEmail,'') as M_DoctorEmail,
|
||||
M_DoctorHP ,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone ,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
ifnull(M_DoctorPjIsPJ,'N') M_DoctorIsPJ,
|
||||
ifnull(M_DoctorPjIsDefaultPJ,'N') M_DoctorIsDefaultPJ ,
|
||||
M_DoctorM_SpecialID ,
|
||||
ifnull(M_DoctorPjIsClinic,'N') M_DoctorIsClinic ,
|
||||
ifnull(M_DoctorPjIsDefault,'N') M_DoctorIsDefault ,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorIsDefaultMcu,
|
||||
M_DoctorCreated ,
|
||||
M_DoctorLastUpdated,
|
||||
M_DoctorIsActive,
|
||||
M_DoctorReportCode ,
|
||||
M_DoctorPrivateRequest,
|
||||
M_DoctorM_UserID ,
|
||||
";
|
||||
$sql = "SELECT $doctor_field
|
||||
CONCAT(IFNULL(M_DoctorPrefix,''),IFNULL(M_DoctorPrefix2,''),' ',M_DoctorName,' ',IFNULL(M_DoctorSufix,''),IFNULL(M_DoctorSufix2,''),IFNULL(M_DoctorSufix3,'')) as doctor_fullname,
|
||||
M_SexName,
|
||||
M_ReligionName,
|
||||
IF(M_DoctorIsMarketingConfirm = 'N', 'Belum dikonfirmasi marketing','Sudah dikonfirmasi marketing') as status
|
||||
FROM m_doctor
|
||||
JOIN m_sex ON M_DoctorM_SexID = M_SexID
|
||||
left join m_doctorpj on M_DoctorID = M_DoctorPjM_DoctorID AND M_DoctorPjIsActive = 'Y'
|
||||
left JOIN m_religion ON M_DoctorM_ReligionID = M_ReligionID
|
||||
$sql_where
|
||||
ORDER BY M_DoctorName ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function searchcity(){
|
||||
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 m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = '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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdistrict(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
// ambil data lama
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$old_doctor = array();
|
||||
if (count($rows) > 0 ) $old_doctor = $rows[0];
|
||||
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
if($prm['M_DoctorEmail'] == ''){
|
||||
$prm['M_DoctorEmailIsDefault'] = 'N';
|
||||
}
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorPrefix2 = '{$prm['M_DoctorPrefix2']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
M_DoctorSufix2 = '{$prm['M_DoctorSufix2']}',
|
||||
M_DoctorSufix3 = '{$prm['M_DoctorSufix3']}',
|
||||
M_DoctorM_SexID = '{$prm['M_DoctorM_SexID']}',
|
||||
M_DoctorM_ReligionID = '{$prm['M_DoctorM_ReligionID']}',
|
||||
M_DoctorEmail = '{$prm['M_DoctorEmail']}',
|
||||
M_DoctorHP = '{$prm['M_DoctorHP']}',
|
||||
M_DoctorNote = '{$prm['M_DoctorNote']}',
|
||||
M_DoctorPhone = '{$prm['M_DoctorPhone']}',
|
||||
M_DoctorIsMarketingConfirm = '{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
M_DoctorIsPJ = '{$prm['M_DoctorIsPJ']}',
|
||||
M_DoctorIsDefaultPJ = '{$prm['M_DoctorIsDefaultPJ']}',
|
||||
M_DoctorIsClinic = '{$prm['M_DoctorIsClinic']}',
|
||||
M_DoctorIsDefault = '{$prm['M_DoctorIsDefault']}',
|
||||
M_DoctorEmailIsDefault = '{$prm['M_DoctorEmailIsDefault']}'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$sqlx = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y'";
|
||||
$qryx= $this->db_onedev->query($sqlx,array($prm["M_DoctorID"]));
|
||||
$rowsx = $qryx->result_array();
|
||||
if (count($rowsx) > 0 ) {
|
||||
$sql = "UPDATE m_doctorpj set
|
||||
M_DoctorPjIsPJ = ?, M_DoctorPjIsDefaultPJ = ?, M_DoctorPjIsClinic = ?, M_DoctorPjIsDefault =?
|
||||
where M_DoctorPjM_DoctorID = ? AND M_DoctorPjIsActive = 'Y'";
|
||||
$this->db_onedev->query($sql, array($ispj,$isdefaultpj,$isclinic,$isdefault,$prm["M_DoctorID"]));
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}else{
|
||||
//sipe modifikasi ispj
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$sql = "select * from m_doctorpj
|
||||
where M_DoctorPjM_DoctorID = ? and M_DoctorPjIsActive = 'Y' ";
|
||||
$qry = $this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) == 0 ) {
|
||||
$sql = "insert into m_doctorpj(M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ, M_DoctorPjIsDefaultPJ, M_DoctorPjIsClinic, M_DoctorPjIsDefault)
|
||||
values(?,?,?,?,?)";
|
||||
$this->db_onedev->query($sql, array($prm["M_DoctorID"],$ispj,$isdefaultpj,$isclinic,$isdefault));
|
||||
}
|
||||
if ($isdefaultpj == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefaultPj= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
if ($isdefault == "Y" ) {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsDefault= 'N'
|
||||
where M_DoctorPjM_DoctorID <> ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
} else {
|
||||
$sql = "update m_doctorpj set M_DoctorPjIsActive= 'N', M_DoctorPjIsPJ = 'N'
|
||||
where M_DoctorPjM_DoctorID = ? ";
|
||||
$this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
|
||||
// ambil data baru
|
||||
$sql = "select * from m_doctor where M_DoctorID = ?";
|
||||
$qry = $this->db_onedev->query($sql,array($prm["M_DoctorID"]));
|
||||
$rows = $qry->result_array();
|
||||
$new_doctor = array();
|
||||
if (count($rows) > 0 ) $new_doctor = $rows[0];
|
||||
$d_doctor = json_encode(array("old" => $old_doctor , "new" => $new_doctor));
|
||||
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$ispj = $prm['M_DoctorIsPJ'];
|
||||
$isdefaultpj = $prm['M_DoctorIsDefaultPJ'];
|
||||
$isdefault = $prm['M_DoctorIsDefault'];
|
||||
$isclinic = $prm['M_DoctorIsClinic'];
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorIsPJ,
|
||||
M_DoctorIsDefaultPJ,
|
||||
M_DoctorIsClinic,
|
||||
M_DoctorIsDefault,
|
||||
M_DoctorEmailIsDefault,
|
||||
M_DoctorM_UserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorPrefix2']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorSufix2']}',
|
||||
'{$prm['M_DoctorSufix3']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorNote']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
'{$prm['M_DoctorEmailIsDefault']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($rows){
|
||||
if($isdefault == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefault = 'N' WHERE M_DoctorPjIsDefault = 'Y'
|
||||
";
|
||||
$rows = $this->db_onedev->query($querydefault);
|
||||
}
|
||||
if($isdefaultpj == 'Y'){
|
||||
$querydefault ="UPDATE m_doctorpj SET
|
||||
M_DoctorPjIsDefaultPJ = 'N' WHERE M_DoctorPjIsDefaultPJ = 'Y'
|
||||
";
|
||||
$rows = $this->db_onedev->query($querydefault);
|
||||
}
|
||||
if($ispj == 'Y' || $isdefaultpj == 'Y' || $isdefault == 'Y' || $isclinic === 'Y'){
|
||||
$querypj ="INSERT INTO m_doctorpj (
|
||||
M_DoctorPjM_DoctorID,
|
||||
M_DoctorPjIsPJ,
|
||||
M_DoctorPjIsDefaultPJ,
|
||||
M_DoctorPjIsClinic,
|
||||
M_DoctorPjIsDefault,
|
||||
M_DoctorPjCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
$rows = $this->db_onedev->query($querypj);
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
//sipe tambah log doctor
|
||||
$prm["M_DoctorID"] = $last_id;
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_ADD','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
// sipe nambah ambil userid
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_doctoraddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,
|
||||
'' as action
|
||||
FROM m_doctoraddress
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
WHERE
|
||||
M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_DoctorAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}' AND M_DoctorAddressNote = 'Utama' AND M_DoctorAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_DoctorAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_DoctorAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_doctoraddress (
|
||||
M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID,
|
||||
M_DoctorAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
'{$prm['M_DoctorAddressNote']}',
|
||||
'{$prm['M_DoctorAddressDescription']}',
|
||||
'{$prm['M_DoctorAddressM_KelurahanID']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressM_DoctorID = '{$prm['M_DoctorAddressM_DoctorID']}',
|
||||
M_DoctorAddressNote = '{$prm['M_DoctorAddressNote']}',
|
||||
M_DoctorAddressDescription = '{$prm['M_DoctorAddressDescription']}',
|
||||
M_DoctorAddressM_KelurahanID = '{$prm['M_DoctorAddressM_KelurahanID']}'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_EDIT','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_doctoraddress SET
|
||||
M_DoctorAddressIsActive = 'N'
|
||||
WHERE
|
||||
M_DoctorAddressID = '{$prm['M_DoctorAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
//adi tambah log doctor
|
||||
$prm["M_DoctorM_UserID"] = $userid;
|
||||
$d_doctor = json_encode($prm);
|
||||
$this->db_onedev->query("call one_log.log_me('DOCTOR','DOCTOR_ADDR_DELETE','{$d_doctor}',$userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
754
one-api/application/controllers/mockup/masterdata/Doctorso.php
Normal file
754
one-api/application/controllers/mockup/masterdata/Doctorso.php
Normal file
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
|
||||
class Doctorso extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "DOCTORSO API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookupdoctorso(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select M_DoctorSOID as id,
|
||||
M_DoctorSOM_DoctorID as doctorid,
|
||||
M_DoctorSONat_SubGroupID as subgroupid,
|
||||
M_DoctorID,
|
||||
CONCAT(Nat_SubGroupName,' ' ,'[ ',Nat_SubGroupCode,' ]') as description,
|
||||
CONCAT(Nat_SubGroupName,' ' ,'[ ',Nat_SubGroupCode,' ]') as Nat_SubGroupNames,
|
||||
Nat_SubGroupID,
|
||||
'xxx' as action
|
||||
from m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID
|
||||
JOIN nat_subgroup ON M_DoctorSONat_SubGroupID = Nat_SubGroupID
|
||||
where
|
||||
M_DoctorSOM_DoctorID = {$id} AND M_DoctorSOIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = 'LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_doctor
|
||||
where
|
||||
M_DoctorIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "SELECT * FROM (select M_DoctorID as id, M_DoctorName as name,
|
||||
CONCAT(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) as description
|
||||
from m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
where
|
||||
( description LIKE CONCAT('%','{$search}','%')
|
||||
)
|
||||
ORDER BY id ASC $limit";
|
||||
$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_doctor select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewdoctor()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_doctor = $prm['name'];
|
||||
$address_doctor = $prm['address'];
|
||||
$phone_doctor = $prm['phone'];
|
||||
$email_doctor = $prm['email'];
|
||||
$pic_doctor = $prm['pic'];
|
||||
$doctortypenew_doctor = $prm['doctortypenew'];
|
||||
$doctortype_doctor = $prm['doctortype'];
|
||||
$islabfrom = $prm['islabfrom'];
|
||||
$islabto = $prm['islabto'];
|
||||
$city = $prm['city'];
|
||||
$district = $prm['district'];
|
||||
$kelurahan = $prm['kelurahan'];
|
||||
$doctormindp = $prm['doctormindp'];
|
||||
$doctor = $prm['doctor'];
|
||||
|
||||
if($doctortypenew_doctor != ''){
|
||||
$sql = "insert into m_doctortype(
|
||||
M_DoctorTypeName,
|
||||
M_DoctorTypeCreated,
|
||||
M_DoctorTypeLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$doctortypenew_doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctortype insert");
|
||||
exit;
|
||||
}
|
||||
$doctortypenewid = $this->db_onedev->insert_id();
|
||||
$sqldoctor = "insert into m_doctor(
|
||||
M_DoctorName,
|
||||
M_DoctorNat_CityID,
|
||||
M_DoctorNat_DistrictID,
|
||||
M_DoctorNat_KelurahanID,
|
||||
M_DoctorAddress,
|
||||
M_DoctorPhone,
|
||||
M_DoctorEmail,
|
||||
M_DoctorPIC,
|
||||
M_DoctorM_DoctorTypeID,
|
||||
M_DoctorIsLabFrom,
|
||||
M_DoctorIsLabTo,
|
||||
M_DoctorMinDP,
|
||||
M_DoctorNat_DoctorID,
|
||||
M_DoctorCreated,
|
||||
M_DoctorLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now())";
|
||||
$querydoctor = $this->db_onedev->query($sqldoctor,
|
||||
array(
|
||||
$name_doctor,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_doctor,
|
||||
$phone_doctor,
|
||||
$email_doctor,
|
||||
$pic_doctor,
|
||||
$doctortypenewid,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$doctormindp,
|
||||
$doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$querydoctor) {
|
||||
$this->sys_error_db("m_doctor insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else{
|
||||
$sql = "insert into m_doctor(
|
||||
M_DoctorName,
|
||||
M_DoctorNat_CityID,
|
||||
M_DoctorNat_DistrictID,
|
||||
M_DoctorNat_KelurahanID,
|
||||
M_DoctorAddress,
|
||||
M_DoctorPhone,
|
||||
M_DoctorEmail,
|
||||
M_DoctorPIC,
|
||||
M_DoctorM_DoctorTypeID,
|
||||
M_DoctorIsLabFrom,
|
||||
M_DoctorIsLabTo,
|
||||
M_DoctorMinDP,
|
||||
M_DoctorNat_DoctorID,
|
||||
M_DoctorCreated,
|
||||
M_DoctorLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_doctor,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_doctor,
|
||||
$phone_doctor,
|
||||
$email_doctor,
|
||||
$pic_doctor,
|
||||
$doctortype_doctor,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$doctormindp,
|
||||
$doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctor insert");
|
||||
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 editdoctor()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_doctor = $prm['id'];
|
||||
$name_doctor = $prm['name'];
|
||||
$address_doctor = $prm['address'];
|
||||
$phone_doctor = $prm['phone'];
|
||||
$email_doctor = $prm['email'];
|
||||
$pic_doctor = $prm['pic'];
|
||||
$doctortypenew_doctor = $prm['doctortypenew'];
|
||||
$doctortype_doctor = $prm['doctortype'];
|
||||
$islabfrom = $prm['islabfrom'];
|
||||
$islabto = $prm['islabto'];
|
||||
$city = $prm['city'];
|
||||
$district = $prm['district'];
|
||||
$kelurahan = $prm['kelurahan'];
|
||||
$doctormindp = $prm['doctormindp'];
|
||||
$doctor = $prm['doctor'];
|
||||
|
||||
if($doctortypenew_doctor != ''){
|
||||
$sql = "insert into m_doctortype(
|
||||
M_DoctorTypeName,
|
||||
M_DoctorTypeCreated,
|
||||
M_DoctorTypeLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$doctortypenew_doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctortype insert");
|
||||
exit;
|
||||
}
|
||||
$doctortypenewid = $this->db_onedev->insert_id();
|
||||
$sqldoctor = "update m_doctor SET
|
||||
M_DoctorName = ?,
|
||||
M_DoctorNat_CityID = ?,
|
||||
M_DoctorNat_DistrictID = ?,
|
||||
M_DoctorNat_KelurahanID = ?,
|
||||
M_DoctorAddress = ?,
|
||||
M_DoctorPhone = ?,
|
||||
M_DoctorEmail = ?,
|
||||
M_DoctorPIC = ?,
|
||||
M_DoctorM_DoctorTypeID = ?,
|
||||
M_DoctorIsLabFrom = ?,
|
||||
M_DoctorIsLabTo = ?,
|
||||
M_DoctorMinDP = ?,
|
||||
M_DoctorNat_DoctorID = ?,
|
||||
M_DoctorLastUpdated = now()
|
||||
where
|
||||
M_DoctorID = ?
|
||||
";
|
||||
$querydoctor = $this->db_onedev->query($sqldoctor,
|
||||
array(
|
||||
$name_doctor,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_doctor,
|
||||
$phone_doctor,
|
||||
$email_doctor,
|
||||
$pic_doctor,
|
||||
$doctortypenewid,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$doctormindp,
|
||||
$doctor,
|
||||
$id_doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$querydoctor) {
|
||||
$this->sys_error_db("m_doctor update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_doctor));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "update m_doctor SET
|
||||
M_DoctorName = ?,
|
||||
M_DoctorNat_CityID = ?,
|
||||
M_DoctorNat_DistrictID = ?,
|
||||
M_DoctorNat_KelurahanID = ?,
|
||||
M_DoctorAddress = ?,
|
||||
M_DoctorPhone = ?,
|
||||
M_DoctorEmail = ?,
|
||||
M_DoctorPIC = ?,
|
||||
M_DoctorM_DoctorTypeID = ?,
|
||||
M_DoctorIsLabFrom = ?,
|
||||
M_DoctorIsLabTo = ?,
|
||||
M_DoctorMinDP = ?,
|
||||
M_DoctorNat_DoctorID = ?,
|
||||
M_DoctorLastUpdated = now()
|
||||
where
|
||||
M_DoctorID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_doctor,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_doctor,
|
||||
$phone_doctor,
|
||||
$email_doctor,
|
||||
$pic_doctor,
|
||||
$doctortype_doctor,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$doctormindp,
|
||||
$doctor,
|
||||
$id_doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctor update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_doctor));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewdoctorso()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$doctorid = $prm['doctorid'];
|
||||
$subgroupid = $prm['natsubgroupid'];
|
||||
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$sql = "insert into m_doctorso(
|
||||
M_DoctorSOM_DoctorID,
|
||||
M_DoctorSONat_SubGroupID,
|
||||
M_DoctorSOCreated,
|
||||
M_DoctorSOLastUpdated
|
||||
)
|
||||
values( ?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$doctorid,
|
||||
$subgroupid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctorso insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}else{
|
||||
$subgroupid = $prm['natsubgroupid'];
|
||||
$sql = "UPDATE m_doctorso SET M_DoctorSONat_SubGroupID = '{$doctorid}' WHERE M_DoctorSOID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deletedoctorso()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_doctorso SET
|
||||
M_DoctorSOIsActive = 'N',
|
||||
M_DoctorSOLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorSOID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctorso 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 deletedoctor()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_doctor SET
|
||||
M_DoctorIsActive = 'N',
|
||||
M_DoctorLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctor delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE m_doctorso SET
|
||||
M_DoctorSOIsActive = 'N',
|
||||
M_DoctorSOLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorSOM_DoctorID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctorso 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 selectdoctortype(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_doctortype
|
||||
WHERE
|
||||
M_DoctorTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['doctortypes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function selectdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_doctor
|
||||
WHERE
|
||||
Nat_DoctorIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['doctors'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function searchnatsubgroup(){
|
||||
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_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupName like ?
|
||||
AND Nat_SubGroupIsActive = '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_subgroup count",$this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(Nat_SubGroupName,' ' ,'[ ',Nat_SubGroupCode,' ]') as Nat_SubGroupNames
|
||||
FROM nat_subgroup
|
||||
WHERE Nat_SubGroupIsActive = 'Y') a
|
||||
WHERE
|
||||
Nat_SubGroupNames like ?
|
||||
AND Nat_SubGroupIsActive = 'Y'
|
||||
ORDER BY Nat_SubGroupName DESC
|
||||
";
|
||||
$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_subgroup rows",$this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcity(){
|
||||
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_city
|
||||
WHERE
|
||||
Nat_CityName like ?
|
||||
AND Nat_CityIsActive = '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_city count",$this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM nat_city
|
||||
WHERE
|
||||
Nat_CityName like ?
|
||||
AND Nat_CityIsActive = 'Y'
|
||||
ORDER BY Nat_CityName DESC
|
||||
";
|
||||
$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_city rows",$this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getdistrict(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_district
|
||||
WHERE
|
||||
Nat_DistrictIsActive = 'Y' AND Nat_DistrictNat_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_kelurahan
|
||||
WHERE
|
||||
Nat_KelurahanIsActive = 'Y' AND Nat_KelurahanNat_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
class Emailconfig extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "EMAIL CONFIG API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function getdata()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select *
|
||||
from one_preorder_dev .m_emailconfig
|
||||
where
|
||||
M_EmailConfigIsActive = 'Y' LIMIT 1";
|
||||
$rows = $this->db_onedev->query($sql)->row_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$rows) {
|
||||
$this->sys_error_db("emailconfig select");
|
||||
exit;
|
||||
|
||||
}
|
||||
$result = array ("total" => count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update one_preorder_dev .m_emailconfig SET
|
||||
M_EmailConfigSender = ?,
|
||||
M_EmailConfigUsername = ?,
|
||||
M_EmailConfigPassword = ?,
|
||||
M_EmailConfigServer = ?,
|
||||
M_EmailConfigMaxRetry = ?,
|
||||
M_EmailConfigHomeServiceFormat = ?,
|
||||
M_EmailConfigCc = ?,
|
||||
M_EmailConfigLastUpdate = now()
|
||||
where
|
||||
M_EmailConfigID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,$prm);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_bahan update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array());
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
429
one-api/application/controllers/mockup/masterdata/Favorite.php
Normal file
429
one-api/application/controllers/mockup/masterdata/Favorite.php
Normal file
@@ -0,0 +1,429 @@
|
||||
<?php
|
||||
|
||||
class Favorite extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ITEM API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function lookupitem()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_itemadditional
|
||||
where
|
||||
M_ItemAdditionalIsActive = 'Y'";
|
||||
$total = $this->db_onedev->query($sql)->row()->total;
|
||||
|
||||
|
||||
$sql = "select M_ItemAdditionalID as id, M_ItemAdditionalCode as code, M_ItemAdditionalName as name,M_ItemAdditionalMandatory as flagmandatory, IF(M_ItemAdditionalMandatory = 'N',CONCAT('[ ',M_ItemAdditionalCode,' ] ',M_ItemAdditionalName),CONCAT('[ ',M_ItemAdditionalCode,' ] ',M_ItemAdditionalName,'*')) as namex,M_ItemAdditionalPrice as price,'xxx' as itemtests
|
||||
from m_itemadditional
|
||||
where
|
||||
( M_ItemAdditionalCode LIKE CONCAT('%',?,'%') OR M_ItemAdditionalName LIKE CONCAT('%',?,'%')) AND
|
||||
M_ItemAdditionalIsActive = 'Y' $limit";
|
||||
$sql_param = array($search,$search);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("m_itemadditional select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$price = $prm['price'];
|
||||
$flagmandatory = $prm['flagmandatory'];
|
||||
if($prm['act'] == 'new'){
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalCode = '{$code}'";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalName = '{$name}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into m_itemadditional(
|
||||
M_ItemAdditionalCode,
|
||||
M_ItemAdditionalName,
|
||||
M_ItemAdditionalMandatory,
|
||||
M_ItemAdditionalPrice,
|
||||
M_ItemAdditionalUserID,
|
||||
M_ItemAdditionalCreatedDate,
|
||||
M_ItemAdditionalLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$flagmandatory,
|
||||
$price,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_itemadditional insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code > 0){
|
||||
array_push($errors,"errorcode");
|
||||
}
|
||||
if($exist_name > 0){
|
||||
array_push($errors,"errorname");
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalCode = '{$code}' AND M_ItemAdditionalID <> {$prm['id']}";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalName = '{$name}' AND M_ItemAdditionalID <> {$prm['id']}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "UPDATE m_itemadditional SET
|
||||
M_ItemAdditionalCode = ?,
|
||||
M_ItemAdditionalName = ?,
|
||||
M_ItemAdditionalMandatory = ?,
|
||||
M_ItemAdditionalPrice = ?,
|
||||
M_ItemAdditionalLastUpdated = now()
|
||||
WHERE
|
||||
M_ItemAdditionalID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$flagmandatory,
|
||||
$price,
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_itemadditional update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $prm['id']));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code > 0){
|
||||
array_push($errors,"errorcode");
|
||||
}
|
||||
if($exist_name > 0){
|
||||
array_push($errors,"errorname");
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deleteitem()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_itemadditional SET
|
||||
M_ItemAdditionalIsActive = 'N',
|
||||
M_ItemAdditionalUserID = ?,
|
||||
M_ItemAdditionalLastUpdated = now()
|
||||
WHERE
|
||||
M_ItemAdditionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_item delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_itemadditionaltest SET
|
||||
M_ItemAdditionalTestIsActive = 'N',
|
||||
M_ItemAdditionalTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ItemAdditionalTestM_ItemAdditionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_itemadditionaltest 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 lookupitemtests(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "
|
||||
select
|
||||
T_FavoriteID as id,
|
||||
T_TestName as testname,
|
||||
T_FavoriteT_TestID as testid,
|
||||
T_FavoriteIsPacket as ispaket,
|
||||
T_FavoriteT_PacketID as paketid,
|
||||
T_FavoriteType as testtype
|
||||
|
||||
from t_favorite
|
||||
JOIN t_test ON T_FavoriteT_TestID = T_TestID AND T_TestIsActive = 'Y'
|
||||
where
|
||||
T_FavoriteIsActive= 'Y' AND T_FavoriteIsPacket = 'N'
|
||||
UNION
|
||||
select
|
||||
T_FavoriteID as id,
|
||||
T_PacketName as testname,
|
||||
T_FavoriteT_TestID as testid,
|
||||
T_FavoriteIsPacket as ispaket,
|
||||
T_FavoriteT_PacketID as paketid,
|
||||
T_FavoriteType as testtype
|
||||
|
||||
from t_favorite
|
||||
JOIN t_packet ON T_FavoriteT_PacketID = T_PacketID
|
||||
where
|
||||
T_FavoriteIsActive= 'Y' AND T_FavoriteIsPacket = 'Y'
|
||||
";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("t_favorite select");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookuptests()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["search"];
|
||||
$sql_param = array($search,$search);
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
|
||||
WHERE
|
||||
(T_TestCode like CONCAT('%','{$search}','%') OR T_TestName like CONCAT('%','{$search}','%')) AND
|
||||
T_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("t_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
T_TestID as testid,
|
||||
T_TestSasCode as testcode,
|
||||
T_TestName as testname,
|
||||
'PX' as testtype,
|
||||
'N' as ispaket
|
||||
|
||||
|
||||
FROM t_test
|
||||
WHERE
|
||||
(T_TestCode like CONCAT('%','{$search}','%') OR T_TestName like CONCAT('%','{$search}','%')) AND
|
||||
T_TestIsActive = 'Y' and T_TestIsPrice = 'Y'
|
||||
union
|
||||
select
|
||||
T_PacketID as testid,
|
||||
T_PacketSasCode as testcode,
|
||||
T_PacketName as testname,
|
||||
T_PacketType as testtype,
|
||||
'Y' as ispaket
|
||||
|
||||
FROM t_packet
|
||||
WHERE
|
||||
(T_PacketSasCode like CONCAT('%','{$search}','%') OR T_PacketName like CONCAT('%','{$search}','%')) AND
|
||||
T_PacketIsActive = 'Y'
|
||||
ORDER BY testcode ASC";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveitemtest(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['itemid'];
|
||||
$itemtests = $prm['favorites'];
|
||||
$deleteditemtests = $prm['deletedfavorite'];
|
||||
|
||||
foreach($itemtests as $k=>$v){
|
||||
if($v['id'] == 0){
|
||||
$testid = $v['testid'];
|
||||
$packetid = 0;
|
||||
if($v['testtype'] != 'PX'){
|
||||
$packetid = $v['testid'];
|
||||
$testid = 0;
|
||||
}
|
||||
$sql = "INSERT INTO t_favorite (
|
||||
T_FavoriteType,
|
||||
T_FavoriteIsPacket,
|
||||
T_FavoriteT_TestID,
|
||||
T_FavoriteT_PacketID,
|
||||
T_FavoriteUserID
|
||||
)
|
||||
VALUES('{$v['testtype']}','{$v['ispaket']}','{$testid}','{$packetid}',{$userid})";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
}
|
||||
|
||||
if($deleteditemtests){
|
||||
foreach($deleteditemtests as $k=>$v){
|
||||
$sql = "UPDATE t_favorite SET
|
||||
T_FavoriteIsActive = 'N',
|
||||
T_FavoriteUserID = ?
|
||||
WHERE
|
||||
T_FavoriteID = ?
|
||||
";
|
||||
$sql_param = array($userid,$v['id']);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array());
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
381
one-api/application/controllers/mockup/masterdata/Item.php
Normal file
381
one-api/application/controllers/mockup/masterdata/Item.php
Normal file
@@ -0,0 +1,381 @@
|
||||
<?php
|
||||
|
||||
class Item extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ITEM API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function lookupitem()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_itemadditional
|
||||
where
|
||||
M_ItemAdditionalIsActive = 'Y'";
|
||||
$total = $this->db_onedev->query($sql)->row()->total;
|
||||
|
||||
|
||||
$sql = "select M_ItemAdditionalID as id, M_ItemAdditionalCode as code, M_ItemAdditionalName as name,M_ItemAdditionalMandatory as flagmandatory, IF(M_ItemAdditionalMandatory = 'N',CONCAT('[ ',M_ItemAdditionalCode,' ] ',M_ItemAdditionalName),CONCAT('[ ',M_ItemAdditionalCode,' ] ',M_ItemAdditionalName,'*')) as namex,M_ItemAdditionalPrice as price,'xxx' as itemtests
|
||||
from m_itemadditional
|
||||
where
|
||||
( M_ItemAdditionalCode LIKE CONCAT('%',?,'%') OR M_ItemAdditionalName LIKE CONCAT('%',?,'%')) AND
|
||||
M_ItemAdditionalIsActive = 'Y' $limit";
|
||||
$sql_param = array($search,$search);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("m_itemadditional select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$price = $prm['price'];
|
||||
$flagmandatory = $prm['flagmandatory'];
|
||||
if($prm['act'] == 'new'){
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalCode = '{$code}'";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalName = '{$name}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into m_itemadditional(
|
||||
M_ItemAdditionalCode,
|
||||
M_ItemAdditionalName,
|
||||
M_ItemAdditionalMandatory,
|
||||
M_ItemAdditionalPrice,
|
||||
M_ItemAdditionalUserID,
|
||||
M_ItemAdditionalCreatedDate,
|
||||
M_ItemAdditionalLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$flagmandatory,
|
||||
$price,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_itemadditional insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code > 0){
|
||||
array_push($errors,"errorcode");
|
||||
}
|
||||
if($exist_name > 0){
|
||||
array_push($errors,"errorname");
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalCode = '{$code}' AND M_ItemAdditionalID <> {$prm['id']}";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalName = '{$name}' AND M_ItemAdditionalID <> {$prm['id']}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "UPDATE m_itemadditional SET
|
||||
M_ItemAdditionalCode = ?,
|
||||
M_ItemAdditionalName = ?,
|
||||
M_ItemAdditionalMandatory = ?,
|
||||
M_ItemAdditionalPrice = ?,
|
||||
M_ItemAdditionalLastUpdated = now()
|
||||
WHERE
|
||||
M_ItemAdditionalID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$flagmandatory,
|
||||
$price,
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_itemadditional update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $prm['id']));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code > 0){
|
||||
array_push($errors,"errorcode");
|
||||
}
|
||||
if($exist_name > 0){
|
||||
array_push($errors,"errorname");
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deleteitem()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_itemadditional SET
|
||||
M_ItemAdditionalIsActive = 'N',
|
||||
M_ItemAdditionalUserID = ?,
|
||||
M_ItemAdditionalLastUpdated = now()
|
||||
WHERE
|
||||
M_ItemAdditionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_item delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_itemadditionaltest SET
|
||||
M_ItemAdditionalTestIsActive = 'N',
|
||||
M_ItemAdditionalTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ItemAdditionalTestM_ItemAdditionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_itemadditionaltest 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 lookupitemtests(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select M_ItemAdditionalTestID as id, T_TestName as testname, M_ItemAdditionalTestT_TestID as testid
|
||||
from m_itemadditionaltest
|
||||
JOIN t_test ON M_ItemAdditionalTestT_TestID = T_TestID AND T_TestIsActive = 'Y'
|
||||
where
|
||||
M_ItemAdditionalTestM_ItemAdditionalID = {$id} AND M_ItemAdditionalTestIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_itemadditionaltest select by itemadditional");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookuptests()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["search"];
|
||||
$sql_param = array($search,$search);
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
WHERE
|
||||
(T_TestCode like CONCAT('%','{$search}','%') OR T_TestName like CONCAT('%','{$search}','%')) AND
|
||||
T_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("t_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT T_TestID as testid,
|
||||
T_TestCode as testcode,
|
||||
T_TestName as testname
|
||||
FROM t_test
|
||||
WHERE
|
||||
(T_TestCode like CONCAT('%','{$search}','%') OR T_TestName like CONCAT('%','{$search}','%')) AND
|
||||
T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC
|
||||
limit 0,20";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveitemtest(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['itemid'];
|
||||
$itemtests = $prm['itemtests'];
|
||||
$deleteditemtests = $prm['deleteditemtest'];
|
||||
|
||||
foreach($itemtests as $k=>$v){
|
||||
if($v['id'] == 0){
|
||||
$sql = "INSERT INTO m_itemadditionaltest (
|
||||
M_ItemAdditionalTestT_TestID,
|
||||
M_ItemAdditionalTestM_ItemAdditionalID,
|
||||
M_ItemAdditionalTestUserID
|
||||
)
|
||||
VALUES(?,?,?)";
|
||||
$sql_param = array($v['testid'],$id,$userid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
}
|
||||
}
|
||||
|
||||
if($deleteditemtests){
|
||||
foreach($deleteditemtests as $k=>$v){
|
||||
$sql = "UPDATE m_itemadditionaltest SET
|
||||
M_ItemAdditionalTestIsActive = 'N',
|
||||
M_ItemAdditionalTestUserID = ?
|
||||
WHERE
|
||||
M_ItemAdditionalTestID = ?
|
||||
";
|
||||
$sql_param = array($userid,$v['id']);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array());
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
381
one-api/application/controllers/mockup/masterdata/Item0.php
Normal file
381
one-api/application/controllers/mockup/masterdata/Item0.php
Normal file
@@ -0,0 +1,381 @@
|
||||
<?php
|
||||
|
||||
class Item extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "ITEM API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function lookupitem()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_itemadditional
|
||||
where
|
||||
M_ItemAdditionalIsActive = 'Y'";
|
||||
$total = $this->db_onedev->query($sql)->row()->total;
|
||||
|
||||
|
||||
$sql = "select M_ItemAdditionalID as id, M_ItemAdditionalCode as code, M_ItemAdditionalName as name,M_ItemAdditionalMandatory as flagmandatory, IF(M_ItemAdditionalMandatory = 'N',CONCAT('[ ',M_ItemAdditionalCode,' ] ',M_ItemAdditionalName),CONCAT('[ ',M_ItemAdditionalCode,' ] ',M_ItemAdditionalName,'*')) as namex,M_ItemAdditionalPrice as price,'xxx' as itemtests
|
||||
from m_itemadditional
|
||||
where
|
||||
( M_ItemAdditionalCode LIKE CONCAT('%',?,'%') OR M_ItemAdditionalName LIKE CONCAT('%',?,'%')) AND
|
||||
M_ItemAdditionalIsActive = 'Y' $limit";
|
||||
$sql_param = array($search,$search);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("m_itemadditional select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$price = $prm['price'];
|
||||
$flagmandatory = $prm['flagmandatory'];
|
||||
if($prm['act'] == 'new'){
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalCode = '{$code}'";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalName = '{$name}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "insert into m_itemadditional(
|
||||
M_ItemAdditionalCode,
|
||||
M_ItemAdditionalName,
|
||||
M_ItemAdditionalMandatory,
|
||||
M_ItemAdditionalPrice,
|
||||
M_ItemAdditionalUserID,
|
||||
M_ItemAdditionalCreatedDate,
|
||||
M_ItemAdditionalLastUpdated
|
||||
)
|
||||
values( ?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$flagmandatory,
|
||||
$price,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_itemadditional insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code > 0){
|
||||
array_push($errors,"errorcode");
|
||||
}
|
||||
if($exist_name > 0){
|
||||
array_push($errors,"errorname");
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalCode = '{$code}' AND M_ItemAdditionalID <> {$prm['id']}";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
$query = "SELECT COUNT(*) as exist FROM m_itemadditional WHERE M_ItemAdditionalIsActive = 'Y' AND M_ItemAdditionalName = '{$name}' AND M_ItemAdditionalID <> {$prm['id']}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0 && $exist_name == 0){
|
||||
$sql = "UPDATE m_itemadditional SET
|
||||
M_ItemAdditionalCode = ?,
|
||||
M_ItemAdditionalName = ?,
|
||||
M_ItemAdditionalMandatory = ?,
|
||||
M_ItemAdditionalPrice = ?,
|
||||
M_ItemAdditionalLastUpdated = now()
|
||||
WHERE
|
||||
M_ItemAdditionalID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$flagmandatory,
|
||||
$price,
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_itemadditional update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $prm['id']));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_code > 0){
|
||||
array_push($errors,"errorcode");
|
||||
}
|
||||
if($exist_name > 0){
|
||||
array_push($errors,"errorname");
|
||||
}
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deleteitem()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_itemadditional SET
|
||||
M_ItemAdditionalIsActive = 'N',
|
||||
M_ItemAdditionalUserID = ?,
|
||||
M_ItemAdditionalLastUpdated = now()
|
||||
WHERE
|
||||
M_ItemAdditionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_item delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_itemadditionaltest SET
|
||||
M_ItemAdditionalTestIsActive = 'N',
|
||||
M_ItemAdditionalTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ItemAdditionalTestM_ItemAdditionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
//echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("m_itemadditionaltest 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 lookupitemtests(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select M_ItemAdditionalTestID as id, T_TestName as testname, M_ItemAdditionalTestT_TestID as testid
|
||||
from m_itemadditionaltest
|
||||
JOIN t_test ON M_ItemAdditionalTestT_TestID = T_TestID AND T_TestIsActive = 'Y'
|
||||
where
|
||||
M_ItemAdditionalTestM_ItemAdditionalID = {$id} AND M_ItemAdditionalTestIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_itemadditionaltest select by itemadditional");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookuptests()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["search"];
|
||||
$sql_param = array($search,$search);
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
WHERE
|
||||
(T_TestCode like CONCAT('%','{$search}','%') OR T_TestName like CONCAT('%','{$search}','%')) AND
|
||||
T_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("t_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT T_TestID as testid,
|
||||
T_TestCode as testcode,
|
||||
T_TestName as testname
|
||||
FROM t_test
|
||||
WHERE
|
||||
(T_TestCode like CONCAT('%','{$search}','%') OR T_TestName like CONCAT('%','{$search}','%')) AND
|
||||
T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC
|
||||
limit 0,20";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveitemtest(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['itemid'];
|
||||
$itemtests = $prm['itemtests'];
|
||||
$deleteditemtests = $prm['deleteditemtest'];
|
||||
|
||||
foreach($itemtests as $k=>$v){
|
||||
if($v['id'] == 0){
|
||||
$sql = "INSERT INTO m_itemadditionaltest (
|
||||
M_ItemAdditionalTestT_TestID,
|
||||
M_ItemAdditionalTestM_ItemAdditionalID,
|
||||
M_ItemAdditionalTestUserID
|
||||
)
|
||||
VALUES(?,?,?)";
|
||||
$sql_param = array($v['testid'],$id,$userid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
}
|
||||
}
|
||||
|
||||
if($deleteditemtests){
|
||||
foreach($deleteditemtests as $k=>$v){
|
||||
$sql = "UPDATE m_itemadditionaltest SET
|
||||
M_ItemAdditionalTestIsActive = 'N',
|
||||
M_ItemAdditionalTestUserID = ?
|
||||
WHERE
|
||||
M_ItemAdditionalTestID = ?
|
||||
";
|
||||
$sql_param = array($userid,$v['id']);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array());
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
class Jpaleft extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT nat_jpa.*,'N' as open_edit
|
||||
FROM nat_jpa
|
||||
WHERE
|
||||
Nat_JpaIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if(intval($prm['id']) != 0){
|
||||
if($prm['status'] == 'N')
|
||||
$query =" UPDATE nat_jpa SET Nat_JpaIsActive = 'N', Nat_JpaUserID = {$userid} WHERE Nat_JpaID = {$prm['id']}";
|
||||
else
|
||||
$query =" UPDATE nat_jpa SET Nat_JpaName = '{$prm['Nat_JpaName']}', Nat_JpaUserID = {$userid} WHERE Nat_JpaID = {$prm['id']}";
|
||||
}
|
||||
else{
|
||||
$query = "insert into nat_jpa(
|
||||
Nat_JpaName,
|
||||
Nat_JpaUserID,
|
||||
Nat_JpaCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['value']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
}
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
233
one-api/application/controllers/mockup/masterdata/Jparight.php
Normal file
233
one-api/application/controllers/mockup/masterdata/Jparight.php
Normal file
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
class Jparight extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_JPAGroupID,
|
||||
Nat_JPAGroupName,
|
||||
{$prm['Nat_JpaID']} as Nat_JpaID,
|
||||
fn_jpa_get_discount({$prm['Nat_JpaID']},Nat_JPAGroupID) as Nat_JPADetailDiscount
|
||||
FROM nat_jpagroup
|
||||
WHERE
|
||||
Nat_JPAGroupIsActive = 'Y'
|
||||
GROUP BY Nat_JPAGroupID
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_listing()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_JPAGroupID,
|
||||
Nat_JPAGroupName
|
||||
FROM nat_jpagroup
|
||||
WHERE
|
||||
Nat_JPAGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "insert into nat_jpadetail(
|
||||
Nat_JPADetailNat_JPAID,
|
||||
Nat_JPADetailNat_JPAGroupID,
|
||||
Nat_JPADetailDiscount,
|
||||
Nat_JPADetailUserID,
|
||||
Nat_JPADetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_JpaID']}',
|
||||
'{$prm['Nat_JPAGroupID']}',
|
||||
'{$prm['Nat_JPADetailDiscount']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_JPADetailDiscount = {$prm['Nat_JPADetailDiscount']},
|
||||
Nat_JPADetailUserID = {$userid}";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savejpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "insert into nat_jpagroup(
|
||||
Nat_JPAGroupName,
|
||||
Nat_JPAGroupUserID,
|
||||
Nat_JPAGroupCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['value']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savelistingjpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_jpagroup SET
|
||||
Nat_JPAGroupName = '{$prm['name']}',
|
||||
Nat_JPAGroupIsActive = '{$prm['status']}',
|
||||
Nat_JPAGroupUserID = {$userid}
|
||||
WHERE
|
||||
Nat_JPAGroupID = {$prm['id']}
|
||||
";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savealljpadetail(){
|
||||
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 = "insert into nat_jpadetail(
|
||||
Nat_JPADetailNat_JPAID,
|
||||
Nat_JPADetailNat_JPAGroupID,
|
||||
Nat_JPADetailDiscount,
|
||||
Nat_JPADetailUserID,
|
||||
Nat_JPADetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$v['Nat_JpaID']}',
|
||||
'{$v['Nat_JPAGroupID']}',
|
||||
'{$v['Nat_JPADetailDiscount']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_JPADetailDiscount = {$v['Nat_JPADetailDiscount']},
|
||||
Nat_JPADetailUserID = {$userid}";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,690 @@
|
||||
<?php
|
||||
class Jpatestleft extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$join_sql = 'LEFT ';
|
||||
$status = $prm["status"];
|
||||
$jpagroup = $prm["jpagroup"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
|
||||
$number_limit = 20;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " Nat_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " Nat_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
$where_status = " AND JPA_TestNat_JpaGroupID = {$jpagroup} ";
|
||||
|
||||
if($status == 'Y'){
|
||||
$join_sql = '';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
$join_sql JOIN jpa_test ON JPA_TestNat_TestID = Nat_TestID $where_status AND JPA_TestIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$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_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT nat_test.*, IF(ISNULL(JPA_TestID),'N','Y') as status
|
||||
FROM nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
$join_sql JOIN jpa_test ON JPA_TestNat_TestID = Nat_TestID $where_status AND JPA_TestIsActive = 'Y'
|
||||
WHERE Nat_TestIsActive = 'Y' $sql_where
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getinitdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
|
||||
$query =" SELECT Nat_TestTypeID as id, Nat_TestTypeName as name
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
function searchunit(){
|
||||
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_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = '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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_UnitId as id, Nat_UnitName as name
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'
|
||||
ORDER BY Nat_UnitName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchsample(){
|
||||
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_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = '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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_SampleTypeName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "INSERT INTO jpa_test (
|
||||
JPA_TestNat_JpaGroupID,
|
||||
JPA_TestNat_TestID,
|
||||
JPA_TestUserID,
|
||||
JPA_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
{$prm['jpagroupid']},
|
||||
{$prm['Nat_TestID']},
|
||||
{$userid},
|
||||
NOW()
|
||||
)
|
||||
on duplicate key update
|
||||
JPA_TestIsActive = '{$prm['status']}',
|
||||
JPA_TestUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $data_log_header,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_test
|
||||
WHERE Nat_TestCode = '{$prm['code']}' AND Nat_TestIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdataselected(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['Nat_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
Nat_TestCode as code,
|
||||
Nat_TestName as name,
|
||||
Nat_TestShortName as shortname,
|
||||
Nat_TestShortNameBarcode as codebarcode,
|
||||
'' as xgroup,
|
||||
Nat_GroupID as group_id,
|
||||
Nat_GroupName as group_name,
|
||||
'' as subgroup,
|
||||
Nat_SubGroupID as subgroup_id,
|
||||
Nat_SubGroupName as subgroup_name,
|
||||
'' as subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
|
||||
'' as type,
|
||||
Nat_TestNat_TestTypeID as type_id,
|
||||
Nat_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
Nat_TestIsNonLab as nonlab,
|
||||
Nat_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
Nat_TestFontSize as fontsize,
|
||||
Nat_TestFontColor as fontcolor,
|
||||
Nat_TestIsBold as flagbold,
|
||||
Nat_TestIsItalic as flagitalic,
|
||||
Nat_TestFlagGluc as flaggluc,
|
||||
Nat_TestIsQuantitative as flagquantitative,
|
||||
Nat_TestIsDeltaCheck as deltacheck,
|
||||
Nat_TestIsResult as isresult,
|
||||
Nat_TestIsPrice as isprice,
|
||||
Nat_TestIsPrintResult as printresult,
|
||||
Nat_TestIsPrintNota as printnote,
|
||||
Nat_TestIsTrendAnalysis as trendanalysis,
|
||||
Nat_TestIsWorklist as isworklist,
|
||||
Nat_TestWorklistName as worklistname,
|
||||
Nat_TestFlagLow as flaglow,
|
||||
Nat_TestFlagHigh as flaghigh
|
||||
FROM nat_test
|
||||
JOIN nat_group ON Nat_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON Nat_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON Nat_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE Nat_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
$rows['xform']['unit'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
|
||||
|
||||
$rows['xform']['sample'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
|
||||
|
||||
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
|
||||
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
|
||||
$rows['xform']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_name']);
|
||||
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
||||
|
||||
|
||||
if($rows['xform']['nonlab'] == '')
|
||||
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
||||
else
|
||||
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
||||
|
||||
unset($rows['xform']['sample_id']);
|
||||
unset($rows['xform']['unit_id']);
|
||||
unset($rows['xform']['group_id']);
|
||||
unset($rows['xform']['subgroup_id']);
|
||||
unset($rows['xform']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_name']);
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaddtest(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rtn = true;
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$codefrom = $prm['codefrom'];
|
||||
$codetoward = $prm['codetoward'];
|
||||
$leng = strlen($codetoward);
|
||||
$code_parent = substr($codetoward, 0,-2);
|
||||
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->existtest;
|
||||
if($xcount == 0){
|
||||
$sql = "
|
||||
select T_TestID ,T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
||||
UNION
|
||||
select T_TestID , T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
||||
";
|
||||
//echo $sql;
|
||||
$toupdate = $this->db_onedev->query($sql)->result();
|
||||
if($toupdate){
|
||||
foreach($toupdate as $k => $v){
|
||||
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
||||
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
|
||||
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestParentT_TestID,
|
||||
T_TestNat_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
SELECT
|
||||
{$parentid},
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
'{$codetoward}',
|
||||
Nat_TestName,
|
||||
Nat_TestShortName,
|
||||
Nat_TestShortNameBarcode,
|
||||
Nat_TestNat_GroupID,
|
||||
Nat_TestNat_SubGroupID,
|
||||
Nat_TestNat_SampleTypeID,
|
||||
Nat_TestFontSize,
|
||||
Nat_TestFontColor,
|
||||
Nat_TestIsBold,
|
||||
Nat_TestIsItalic,
|
||||
Nat_TestFlagGluc,
|
||||
Nat_TestIsQuantitative,
|
||||
Nat_TestIsDeltaCheck,
|
||||
Nat_TestIsResult,
|
||||
Nat_TestIsPrice,
|
||||
Nat_TestIsPrintResult,
|
||||
Nat_TestIsPrintNota,
|
||||
Nat_TestIsTrendAnalysis,
|
||||
Nat_TestIsWorklist,
|
||||
Nat_TestIsNonLab,
|
||||
Nat_TestWorklistName,
|
||||
Nat_TestFlagLow,
|
||||
Nat_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM nat_test
|
||||
WHERE
|
||||
Nat_TestCode = '{$codefrom}' AND Nat_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
|
||||
$data_parent = $this->db_onedev->query($sql)->row();
|
||||
if($data_parent){
|
||||
$testidparent = $data_parent->T_TestID;
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $xcount,
|
||||
"debug"=>$query
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
class Jpatestright extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingverify API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_JPAGroupID,
|
||||
Nat_JPAGroupName
|
||||
FROM nat_jpagroup
|
||||
WHERE
|
||||
Nat_JPAGroupIsActive = 'Y'
|
||||
GROUP BY Nat_JPAGroupID
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_listing()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_JPAGroupID,
|
||||
Nat_JPAGroupName
|
||||
FROM nat_jpagroup
|
||||
WHERE
|
||||
Nat_JPAGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "insert into nat_jpadetail(
|
||||
Nat_JPADetailNat_JPAID,
|
||||
Nat_JPADetailNat_JPAGroupID,
|
||||
Nat_JPADetailDiscount,
|
||||
Nat_JPADetailUserID,
|
||||
Nat_JPADetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_JpaID']}',
|
||||
'{$prm['Nat_JPAGroupID']}',
|
||||
'{$prm['Nat_JPADetailDiscount']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_JPADetailDiscount = {$prm['Nat_JPADetailDiscount']},
|
||||
Nat_JPADetailUserID = {$userid}";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savejpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "insert into nat_jpagroup(
|
||||
Nat_JPAGroupName,
|
||||
Nat_JPAGroupUserID,
|
||||
Nat_JPAGroupCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['value']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savelistingjpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE nat_jpagroup SET
|
||||
Nat_JPAGroupName = '{$prm['name']}',
|
||||
Nat_JPAGroupIsActive = '{$prm['status']}',
|
||||
Nat_JPAGroupUserID = {$userid}
|
||||
WHERE
|
||||
Nat_JPAGroupID = {$prm['id']}
|
||||
";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savealljpadetail(){
|
||||
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 = "insert into nat_jpadetail(
|
||||
Nat_JPADetailNat_JPAID,
|
||||
Nat_JPADetailNat_JPAGroupID,
|
||||
Nat_JPADetailDiscount,
|
||||
Nat_JPADetailUserID,
|
||||
Nat_JPADetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$v['Nat_JpaID']}',
|
||||
'{$v['Nat_JPAGroupID']}',
|
||||
'{$v['Nat_JPADetailDiscount']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_JPADetailDiscount = {$v['Nat_JPADetailDiscount']},
|
||||
Nat_JPADetailUserID = {$userid}";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,559 @@
|
||||
<?php
|
||||
class Mapnonlabmcu extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
// public function __construct()
|
||||
// {
|
||||
// parent::__construct();
|
||||
// // $this->db = $this->load->database("onedev", true);
|
||||
// }
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$norm = $prm["snorm"];
|
||||
$nama = $prm["name"];
|
||||
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "WHERE NonlabTemplateIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_TestName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 100';
|
||||
}
|
||||
$number_limit = 100;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
//echo $this->db->last_query();
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
NonlabTemplateMappingID,
|
||||
NonlabTemplateID,
|
||||
NonlabTemplateMappingNat_TestID,
|
||||
NonlabTemplateMappingNonlabTemplateID,
|
||||
Nat_TestName
|
||||
FROM nonlab_template_mapping
|
||||
JOIN nat_test ON NonlabTemplateMappingNat_TestID = Nat_TestID
|
||||
JOIN nonlab_template ON NonlabTemplateMappingNonlabTemplateID = NonlabTemplateID AND
|
||||
NonlabTemplateFlagOther = 'N' AND
|
||||
NonlabTemplateIsActive = 'Y' AND NonlabTemplateMappingIsActive = 'Y'
|
||||
$sql_where
|
||||
ORDER BY Nat_TestName ASC
|
||||
limit 100
|
||||
";
|
||||
// echo $sql;
|
||||
$query = $this->db->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => 1, "records" => $rows, "sql"=> $this->db->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function gettemplatedetail(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$sql ="SELECT nonlab_template_detail.*,
|
||||
{$prm['NonlabTemplateID']} as NonlabTemplateID,
|
||||
IFNULL(NonlabTemplateMcuID,0) as xid,
|
||||
IF(ISNULL(NonlabTemplateMcuID),'N','Y') as xcheck,
|
||||
M_LangName,
|
||||
M_LangID as lang_id,
|
||||
NonlabTemplateMappingNat_TestID as nat_testid
|
||||
FROM nonlab_template_detail
|
||||
JOIN nonlab_template ON NonlabTemplateID = NonlabTemplateDetailNonlabTemplateID AND NonlabTemplateDetailIsActive = 'Y'
|
||||
JOIN nonlab_template_mapping ON NonlabTemplateMappingNonlabTemplateID = NonlabTemplateID AND NonlabTemplateMappingNat_TestID = {$prm['NonlabTemplateMappingNat_TestID']} AND
|
||||
NonlabTemplateMappingIsActive = 'Y'
|
||||
JOIN m_lang ON NonlabTemplateDetaiM_LangID = M_LangID
|
||||
LEFT JOIN nonlab_template_mcu ON NonlabTemplateMcuNat_TestID = NonlabTemplateMappingNat_TestID AND
|
||||
NonlabTemplateMcuNonlabTemplateDetailID = NonlabTemplateDetailID AND
|
||||
NonlabTemplateMcuIsActive = 'Y'
|
||||
WHERE
|
||||
NonlabTemplateDetailNonlabTemplateID = {$prm['NonlabTemplateID']} AND
|
||||
NonlabTemplateDetailIsActive = 'Y'
|
||||
GROUP BY NonlabTemplateDetailID
|
||||
ORDER BY NonlabTemplateDetailID, NonlabTemplateDetaiM_LangID
|
||||
";
|
||||
//echo $query;
|
||||
$query = $this->db->query($sql);
|
||||
if(!$query){
|
||||
echo $this->db->last_query();
|
||||
$this->sys_error_db("nonlab_template_detail",$this->db);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$sql = "SELECT *
|
||||
FROM ";
|
||||
|
||||
$rows[$k]['xcheck'] = false;
|
||||
if($v['xcheck'] == 'Y')
|
||||
$rows[$k]['xcheck'] = true;
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchcity(){
|
||||
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 m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'";
|
||||
$query = $this->db->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city rows",$this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getdistrict(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
|
||||
//echo $sql;
|
||||
|
||||
foreach($prm['details'] as $k => $v){
|
||||
if($v['xcheck']){
|
||||
$sql = "UPDATE nonlab_template_mcu SET NonlabTemplateMcuIsActive = 'N', NonlabTemplateMcuDeleted = NOW(), NonlabTemplateMcuDeletedUserID = {$userid}
|
||||
WHERE
|
||||
NonlabTemplateMcuNat_TestID = {$v['nat_testid']} AND
|
||||
NonlabTemplateMcuM_LangID = {$v['lang_id']} AND
|
||||
NonlabTemplateMcuIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$this->db->query($sql);
|
||||
$sql = "INSERT INTO nonlab_template_mcu (
|
||||
NonlabTemplateMcuM_LangID,
|
||||
NonlabTemplateMcuNat_TestID,
|
||||
NonlabTemplateMcuNonlabTemplateDetailID,
|
||||
NonlabTemplateMcuNonlabTemplateDetailName,
|
||||
NonlabTemplateMcuCreatedUserID,
|
||||
NonlabTemplateMcuCreated
|
||||
)
|
||||
VALUES(
|
||||
{$v['lang_id']},
|
||||
{$v['nat_testid']},
|
||||
{$v['NonlabTemplateDetailID']},
|
||||
'{$v['NonlabTemplateDetailName']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_PatientDOB"] = $pdob;
|
||||
$xbefore = json_encode($rows_before);
|
||||
$ptn = json_encode($ptn);
|
||||
/*$this->db->query("INSERT INTO one_log.log_patient (
|
||||
Log_PatientCode,
|
||||
Log_PatientJson,
|
||||
Log_PatientJsonBefore,
|
||||
Log_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'PATIENT.EDIT',
|
||||
'{$ptn}',
|
||||
'{$xbefore}',
|
||||
'{$userid}'
|
||||
)");*/
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$query ="INSERT INTO m_patient (
|
||||
M_PatientM_TitleID,
|
||||
M_PatientPrefix,
|
||||
M_PatientName,
|
||||
M_PatientSuffix,
|
||||
M_PatientDOB,
|
||||
M_PatientM_SexID,
|
||||
M_PatientM_ReligionID,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientHP,
|
||||
M_PatientPhone,
|
||||
M_PatientM_IdTypeID,
|
||||
M_PatientIDNumber,
|
||||
M_PatientNote,
|
||||
M_PatientNIK,
|
||||
M_PatientJabatan,
|
||||
M_PatientKedudukan,
|
||||
M_PatientPJ,
|
||||
M_PatientLocation,
|
||||
M_PatientJob,
|
||||
M_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientM_TitleID']}',
|
||||
'{$prm['M_PatientPrefix']}',
|
||||
'{$prm['M_PatientName']}',
|
||||
'{$prm['M_PatientSuffix']}',
|
||||
'{$pdob}',
|
||||
'{$prm['M_PatientM_SexID']}',
|
||||
'{$prm['M_PatientM_ReligionID']}',
|
||||
'{$prm['M_PatientEmail']}',
|
||||
'{$prm['M_PatientPOB']}',
|
||||
'{$prm['M_PatientHP']}',
|
||||
'{$prm['M_PatientPhone']}',
|
||||
'{$prm['M_PatientM_IdTypeID']}',
|
||||
'{$prm['M_PatientIDNumber']}',
|
||||
'{$prm['M_PatientNote']}',
|
||||
'{$prm['M_PatientNIK']}',
|
||||
'{$prm['M_PatientJabatan']}',
|
||||
'{$prm['M_PatientKedudukan']}',
|
||||
'{$prm['M_PatientPJ']}',
|
||||
'{$prm['M_PatientLocation']}',
|
||||
'{$prm['M_PatientJob']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db->query($query);
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_PatientID"] = $last_id;
|
||||
$ptn["M_PatientDOB"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADD', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletepatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_patient SET
|
||||
M_PatientIsActive = 'N',
|
||||
M_PatientUserID = {$userid}
|
||||
WHERE
|
||||
M_PatientID = '{$prm['M_PatientID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_PatientDOB"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db->query("CALL one_log.log_me('PATIENT', 'PATIENT.DELETE', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_patientaddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,
|
||||
'' as action
|
||||
FROM m_patientaddress
|
||||
JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
WHERE
|
||||
M_PatientAddressIsActive = 'Y' AND M_PatientAddressM_PatientID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_PatientAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressNote = 'Utama' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_PatientAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_PatientAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_patientaddress (
|
||||
M_PatientAddressM_PatientID,
|
||||
M_PatientAddressNote,
|
||||
M_PatientAddressDescription,
|
||||
M_PatientAddressM_KelurahanID,
|
||||
M_PatientAddressCreated,
|
||||
M_PatientAddressUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientAddressM_PatientID']}',
|
||||
'{$prm['M_PatientAddressNote']}',
|
||||
'{$prm['M_PatientAddressDescription']}',
|
||||
'{$prm['M_PatientAddressM_KelurahanID']}',
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_ADD', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$sql = "SELECT * FROM m_patientaddress WHERE M_PatientAddressID = {$prm['M_PatientAddressID']}";
|
||||
$rows_before = $this->db->query($sql)->row_array();
|
||||
$query ="UPDATE m_patientaddress SET
|
||||
M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}',
|
||||
M_PatientAddressNote = '{$prm['M_PatientAddressNote']}',
|
||||
M_PatientAddressDescription = '{$prm['M_PatientAddressDescription']}',
|
||||
M_PatientAddressM_KelurahanID = '{$prm['M_PatientAddressM_KelurahanID']}',
|
||||
M_PatientAddressUserID = {$userid}
|
||||
WHERE
|
||||
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$xbefore = json_encode($rows_before);
|
||||
$ptn = json_encode($ptn);
|
||||
/*$this->db->query("INSERT INTO one_log.log_patient (
|
||||
Log_PatientCode,
|
||||
Log_PatientJson,
|
||||
Log_PatientJsonBefore,
|
||||
Log_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'PATIENT.ADDR_EDIT',
|
||||
'{$ptn}',
|
||||
'{$xbefore}',
|
||||
'{$userid}'
|
||||
)");*/
|
||||
//$this->db->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_EDIT', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_patientaddress SET
|
||||
M_PatientAddressIsActive = 'N',
|
||||
M_PatientAddressUserID = {$userid}
|
||||
WHERE
|
||||
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
//$this->db->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_DELETE', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
219
one-api/application/controllers/mockup/masterdata/Methode.php
Normal file
219
one-api/application/controllers/mockup/masterdata/Methode.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
class Methode extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Methode API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["scode"];
|
||||
$nama = $prm["nama"];
|
||||
|
||||
// echo $nik;
|
||||
|
||||
$sql_where = "WHERE Nat_MethodeIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_MethodeName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
if ($code == "xxx") {
|
||||
$sql_where .= " Nat_MethodeCode = Nat_MethodeOldCode ";
|
||||
$sql_param[] = "%$code%";
|
||||
} else {
|
||||
$sql_where .= " Nat_MethodeCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_StaffIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_methode
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_methode count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM nat_methode
|
||||
$sql_where
|
||||
ORDER BY Nat_MethodeCode ASC
|
||||
limit 0,$tot_count";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_methode($v['M_StaffID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['Nat_MethodePriority'] == '')
|
||||
$prm['Nat_MethodePriority'] = 0;
|
||||
|
||||
$query ="UPDATE nat_methode SET
|
||||
Nat_MethodeName = '{$prm['Nat_MethodeName']}',
|
||||
Nat_MethodeNameInResult = '{$prm['Nat_MethodeNameInResult']}',
|
||||
Nat_MethodeCode = '{$prm['Nat_MethodeCode']}',
|
||||
Nat_MethodePriority = '{$prm['Nat_MethodePriority']}',
|
||||
Nat_MethodeM_UserID = '{$userid}',
|
||||
Nat_MethodeLastUpdated = now()
|
||||
WHERE Nat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function newmethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
if($prm['Nat_MethodePriority'] == '')
|
||||
$prm['Nat_MethodePriority'] = 0;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_methode (
|
||||
Nat_MethodeName,
|
||||
Nat_MethodeNameInResult,
|
||||
Nat_MethodeCode,
|
||||
Nat_MethodePriority,
|
||||
Nat_MethodeM_UserID,
|
||||
Nat_MethodeCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_MethodeName']}',
|
||||
'{$prm['Nat_MethodeNameInResult']}',
|
||||
'{$prm['Nat_MethodeCode']}',
|
||||
'{$prm['Nat_MethodePriority']}',
|
||||
'{$userid}',
|
||||
now()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function deletemethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE nat_methode SET
|
||||
Nat_MethodeIsActive = 'N'
|
||||
WHERE
|
||||
Nat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$query ="UPDATE nat_normalvalue SET
|
||||
Nat_NormalValueIsActive = 'N'
|
||||
WHERE
|
||||
Nat_NormalValueNat_MethodeID = '{$prm['Nat_MethodeID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM nat_methode
|
||||
WHERE Nat_MethodeCode = '{$prm['code']}' AND Nat_MethodeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,587 @@
|
||||
<?php
|
||||
class Methodepriority extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Methode Priority API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["code"];
|
||||
$nama = $prm["nama"];
|
||||
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "WHERE Nat_TestIsActive = 'Y' AND Nat_TestNat_TestTypeID <> 2";
|
||||
$sql_param = array();
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_TestCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_TestName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_PatientIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM nat_test
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM nat_test
|
||||
$sql_where
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function searchcompany(){
|
||||
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 m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y' AND M_CompanyIsLabFrom = '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("m_company count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y' AND M_CompanyIsLabFrom = 'Y'
|
||||
ORDER BY M_CompanyName DESC
|
||||
";
|
||||
$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("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getmou(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouIsActive = 'Y' AND M_MouM_CompanyID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getmethodereg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['methodees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$query ="UPDATE m_patient SET
|
||||
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
||||
M_PatientName = '{$prm['M_PatientName']}',
|
||||
M_PatientDOB = '{$pdob}',
|
||||
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
||||
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
||||
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
||||
M_PatientHP = '{$prm['M_PatientHP']}',
|
||||
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
||||
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
||||
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
||||
M_PatientNote = '{$prm['M_PatientNote']}'
|
||||
WHERE
|
||||
M_PatientID = '{$prm['M_PatientID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newreceivereference(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdate = date('Y-m-d',strtotime($prm['sdate']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_test (
|
||||
Nat_TestM_CompanyID,
|
||||
Nat_TestM_MouID,
|
||||
Nat_TestDate,
|
||||
Nat_TestNote,
|
||||
Nat_TestUserID,
|
||||
Nat_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['companyid']}',
|
||||
'{$prm['mouid']}',
|
||||
'{$pdate}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogNat_TestID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$last_id}',
|
||||
'1',
|
||||
'{$userid}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $querylog;
|
||||
$insert_new_log = $this->db_onedev->query($querylog);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function sendorder(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE nat_test SET
|
||||
Nat_TestIsSent = 'Y',
|
||||
Nat_TestSentDate = now(),
|
||||
Nat_TestUserID = '{$userid}'
|
||||
WHERE
|
||||
Nat_TestID = '{$prm['Nat_TestID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogNat_TestID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$prm['Nat_TestID']}',
|
||||
'2',
|
||||
'{$userid}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $querylog;
|
||||
$insert_new_log = $this->db_onedev->query($querylog);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getmethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT Nat_MethodeID,
|
||||
Nat_MethodeName,
|
||||
Nat_TestName,
|
||||
GROUP_CONCAT(DISTINCT M_DayOfWeekName ORDER BY M_DayOfWeekID ASC SEPARATOR ', ') as M_DayOfWeekName,
|
||||
M_MethodePriorityNumber,
|
||||
'xxx' as days,
|
||||
'' as action
|
||||
FROM nat_test
|
||||
JOIN nat_normalvalue ON Nat_TestID = Nat_NormalValueNat_TestID
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
LEFT JOIN m_methode_priority ON M_MethodePriorityNat_TestID = Nat_TestID AND M_MethodePriorityNat_MethodeID = Nat_MethodeID AND M_MethodePriorityIsActive = 'Y'
|
||||
LEFT JOIN m_dayofweek ON M_MethodePriorityM_DayOfWeekID = M_DayOfWeekID
|
||||
WHERE
|
||||
Nat_TestID = ?
|
||||
GROUP BY Nat_MethodeID
|
||||
ORDER BY Nat_MethodeID ASC
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
$x = $this->db_onedev->query("select concat( '[', group_concat( json_object('id',IFNULL(M_MethodePriorityID,M_DayOfWeekID), 'dayname', M_DayOfWeekName,'prioritas', M_MethodePriorityNumber ,'status', IF(IFNULL(M_MethodePriorityNumber,0) = 0, 'N','Y')) separator ',' ), ']' )
|
||||
as n FROM
|
||||
(SELECT M_MethodePriorityID,M_DayOfWeekID,M_DayOfWeekName,IFNULL(M_MethodePriorityNumber,0) as M_MethodePriorityNumber
|
||||
FROM m_dayofweek
|
||||
JOIN nat_test ON Nat_TestID = '{$prm['id']}'
|
||||
JOIN nat_normalvalue ON Nat_TestID = Nat_NormalValueNat_TestID AND Nat_NormalValueNat_MethodeID = '{$v['Nat_MethodeID']}'
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
LEFT JOIN m_methode_priority ON Nat_TestID = M_MethodePriorityNat_TestID AND Nat_MethodeID = M_MethodePriorityNat_MethodeID AND M_DayOfWeekID = M_MethodePriorityM_DayOfWeekID AND M_MethodePriorityIsActive = 'Y'
|
||||
GROUP BY M_DayOfWeekID) a")->row();
|
||||
$rows[$k]['dayx'] = json_decode($x->n);
|
||||
$rows[$k]['days'] = $this->add_day($prm['id'],$v['Nat_MethodeID']);
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function add_day($testid,$methodeid){
|
||||
$query =" SELECT m_methode_priority.*,IFNULL(M_MethodePriorityNumber,0) as M_MethodePriorityNumber, m_dayofweek.*,IF(M_MethodePriorityID IS NULL,'N','Y') as isday, IFNULL(M_MethodePriorityNat_MethodeID,0) as xid
|
||||
FROM m_dayofweek
|
||||
JOIN nat_test ON Nat_TestID = '{$testid}'
|
||||
JOIN nat_normalvalue ON Nat_TestID = Nat_NormalValueNat_TestID AND Nat_NormalValueNat_MethodeID = '{$methodeid}'
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
LEFT JOIN m_methode_priority ON Nat_TestID = M_MethodePriorityNat_TestID AND Nat_MethodeID = M_MethodePriorityNat_MethodeID AND M_DayOfWeekID = M_MethodePriorityM_DayOfWeekID AND M_MethodePriorityIsActive = 'Y'
|
||||
GROUP BY M_DayOfWeekID";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function savenewmethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach($prm['orderdays'] as $k=>$v){
|
||||
$query = "INSERT INTO m_methode_priority (
|
||||
M_MethodePriorityM_MethodePriorityID,
|
||||
M_MethodePriorityT_TestID,
|
||||
M_MethodePriorityT_TestCode,
|
||||
M_MethodePriorityT_TestName,
|
||||
M_MethodePriorityT_TestPrice,
|
||||
M_MethodePriorityT_TestDisc,
|
||||
M_MethodePriorityT_TestDiscRp,
|
||||
M_MethodePriorityT_TestTotal,
|
||||
M_MethodePriorityUserID,
|
||||
M_MethodePriorityCreated,
|
||||
M_MethodePriorityLastUpdated
|
||||
)
|
||||
VALUE(
|
||||
?,?,?,?,?,?,?,?,?, now(),now()
|
||||
)";
|
||||
$insert_new_test = $this->db_onedev->query($query,array(
|
||||
$orderpatient_id,
|
||||
$v['T_TestID'],
|
||||
$v['T_TestCode'],
|
||||
$v['T_TestName'],
|
||||
$v['T_PriceAmount'],
|
||||
$v['T_PriceDisc'],
|
||||
$v['T_PriceDiscRp'],
|
||||
$v['total'],
|
||||
$userid
|
||||
));
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditmethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$test_id = $prm['M_MethodePriorityNat_TestID'];
|
||||
$methode_id = $prm['M_MethodePriorityNat_MethodeID'];
|
||||
$priority = $prm['M_MethodePriorityNumber'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
foreach($prm['orderdays'] as $k=>$v){
|
||||
if(($v['xid'] == 0 || $v['xid'] == '0') && ($v['isday'] === 'Y')){
|
||||
$query = "INSERT INTO m_methode_priority(
|
||||
M_MethodePriorityNat_TestID,
|
||||
M_MethodePriorityNat_MethodeID,
|
||||
M_MethodePriorityM_DayOfWeekID,
|
||||
M_MethodePriorityNumber,
|
||||
M_MethodePriorityUserID,
|
||||
M_MethodePriorityCreated,
|
||||
M_MethodePriorityLastUpdated
|
||||
)
|
||||
VALUE(
|
||||
?,?,?,?,?,now(),now()
|
||||
)";
|
||||
$insert_methode = $this->db_onedev->query($query,array(
|
||||
$test_id,
|
||||
$methode_id,
|
||||
$v['M_DayOfWeekID'],
|
||||
$priority,
|
||||
$userid
|
||||
));
|
||||
}elseif($v['xid'] > 0 && $v['isday'] === 'N'){
|
||||
$queryupdate ="UPDATE m_methode_priority SET
|
||||
M_MethodePriorityIsActive = 'N',
|
||||
M_MethodePriorityUserID = '{$userid}',
|
||||
M_MethodePriorityLastUpdated = now()
|
||||
WHERE
|
||||
M_MethodePriorityID = ?
|
||||
";
|
||||
// echo $queryupdate;
|
||||
$update_methode = $this->db_onedev->query($queryupdate,array($v['M_MethodePriorityID'],));
|
||||
// echo $update_methode;
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_methode_priority SET
|
||||
M_MethodePriorityNumber = '{$priority}',
|
||||
M_MethodePriorityUserID = '{$userid}',
|
||||
M_MethodePriorityLastUpdated = now()
|
||||
WHERE
|
||||
M_MethodePriorityID = ?
|
||||
";
|
||||
// echo $queryupdate;
|
||||
$update_methode = $this->db_onedev->query($queryupdate,array($v['M_MethodePriorityID'],));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletepatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE t_receivereferencepatient SET
|
||||
M_MethodePriorityIsActive = 'N',
|
||||
M_MethodePriorityUserID = '{$userid}'
|
||||
WHERE
|
||||
M_MethodePriorityID = '{$prm['M_MethodePriorityID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$query ="UPDATE m_methode_priority SET
|
||||
M_MethodePriorityIsActive = 'N',
|
||||
M_MethodePriorityUserID = '{$userid}'
|
||||
WHERE
|
||||
M_MethodePriorityM_MethodePriorityID = '{$prm['M_MethodePriorityID']}' AND M_MethodePriorityIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchtest(){
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
$mou_id = $prm['mouid'];
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
JOIN t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
||||
WHERE
|
||||
T_TestName like ? AND
|
||||
T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("test count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT 'Y' as editable, 0 as xid, T_TestID, T_TestCode, T_TestName, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceAmount - ((T_PriceDisc/100) * T_PriceAmount) - T_PriceDiscRp as total,
|
||||
M_CompanyID,'N' as M_CompanyIsBill, 0 as M_CompanyMinDP
|
||||
FROM one_lis_dev.t_test
|
||||
JOIN one_lis_dev.t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
||||
JOIN one_lis_dev.m_mou ON M_MouID = '{$mou_id}'
|
||||
JOIN one_lis_dev.m_company ON M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_TestName like ? AND
|
||||
T_TestIsActive = '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("test rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
793
one-api/application/controllers/mockup/masterdata/Multirule.php
Normal file
793
one-api/application/controllers/mockup/masterdata/Multirule.php
Normal file
@@ -0,0 +1,793 @@
|
||||
<?php
|
||||
class Multirule extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Multirule API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
function getdetails($id){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT Nat_MultiruleID,
|
||||
Nat_MultiruleT_TestID,
|
||||
Nat_MultiruleName,
|
||||
Nat_MultiruleM_ValueID,
|
||||
M_ValueName,
|
||||
'' as criterias
|
||||
FROM nat_multirule
|
||||
LEFT JOIN m_value ON Nat_MultiruleM_ValueID = M_ValueID
|
||||
WHERE Nat_MultiruleT_TestID = {$id} AND Nat_MultiruleIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['criterias'] = $this->getcriterias($v['Nat_MultiruleID']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function getcriterias($id){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT Nat_MultiruleDetailID,
|
||||
Nat_MultiruleDetailNat_MultiruleID,
|
||||
Nat_MultiruleDetailT_TestID,
|
||||
T_TestName
|
||||
Nat_MultiruleDetailM_ValueID,
|
||||
M_ValueName
|
||||
FROM nat_multiruledetail
|
||||
LEFT JOIN t_test ON Nat_MultiruleDetailT_TestID = T_TestID
|
||||
LEFT JOIN m_value ON Nat_MultiruleDetailM_ValueID = M_ValueID
|
||||
WHERE Nat_MultiruleDetailNat_MultiruleID = {$id} AND Nat_MultiruleDetailIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
function lookupdetail(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "SELECT Nat_MultiruleDetailID,
|
||||
Nat_MultiruleDetailNat_MultiruleID,
|
||||
Nat_MultiruleDetailT_TestID,
|
||||
T_TestName,
|
||||
Nat_MultiruleDetailM_ValueID,
|
||||
M_ValueName
|
||||
FROM nat_multirule_detail
|
||||
LEFT JOIN t_test ON Nat_MultiruleDetailT_TestID = T_TestID
|
||||
LEFT JOIN m_value ON Nat_MultiruleDetailM_ValueID = M_ValueID
|
||||
WHERE Nat_MultiruleDetailNat_MultiruleID = {$id} AND Nat_MultiruleDetailIsActive = 'Y'";
|
||||
// echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["search"];
|
||||
|
||||
$sql_where = "WHERE T_TestIsResult = 'Y' AND T_TestIsActive = 'Y' AND T_TestIsQuantitative = 'Y'";
|
||||
|
||||
//$sql_param = array();
|
||||
if ($search != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( T_TestCode like '%$search%' OR T_TestName like '%$search%' ) ";
|
||||
}
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("t_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT t_test.*, '' as details
|
||||
FROM t_test
|
||||
$sql_where
|
||||
GROUP BY T_TestCode
|
||||
ORDER BY T_TestCode ASC
|
||||
limit 0,$tot_count";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['details'] = $this->getdetails($v['T_TestID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function selectvaluex(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_value
|
||||
WHERE
|
||||
M_ValueIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['valuexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function getordersamples(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$doctorid = $prm['doctorid'];
|
||||
$doctoraddressid = $prm['doctoraddressid'];
|
||||
$sql = "SELECT
|
||||
0 as idx,
|
||||
M_SexName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
T_SampleTypeName as samplename,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_SampleTypeID as sampleid,
|
||||
'Y' as active,
|
||||
'N' as flag_image
|
||||
FROM t_samplingso
|
||||
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_sampletype ON T_SamplingSoT_SampleTypeID = T_SampleTypeID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
WHERE
|
||||
T_SamplingSoM_DoctorID = {$doctorid} AND T_SamplingSoM_DoctorAddressID = {$doctoraddressid} AND T_SamplingSoVerifyFlagWL = 'N' AND T_SamplingSoIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getnormalvalue(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$methodeid = $prm['methodeid'];
|
||||
/*$sql = "SELECT
|
||||
0 as idx,
|
||||
M_SexName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
T_SampleTypeName as samplename,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_SampleTypeID as sampleid,
|
||||
'Y' as active,
|
||||
'N' as flag_image
|
||||
FROM t_samplingso
|
||||
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_sampletype ON T_SamplingSoT_SampleTypeID = T_SampleTypeID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
WHERE
|
||||
T_SamplingSoM_DoctorID = {$doctorid} AND T_SamplingSoM_DoctorAddressID = {$doctoraddressid} AND T_SamplingSoVerifyFlagWL = 'N' AND T_SamplingSoIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();*/
|
||||
if($methodeid == 1){
|
||||
$rows = array(
|
||||
array(
|
||||
'id'=>1,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">MALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
7th - 14th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">0 - 51</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>2,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">MALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
15th - 24th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">20 - 60</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>3,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">FEMALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
7th - 14th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">0 - 31</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>4,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">FEMALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
15th - 24th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">10 - 60</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if($methodeid == 2){
|
||||
$rows = array(
|
||||
array(
|
||||
'id'=>1,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">MALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
7th - 14th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">10 - 31</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>2,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">MALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
15th - 24th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">20 - 40</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>3,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">FEMALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
7th - 14th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">15 - 41</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>4,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">FEMALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
15th - 24th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">30 - 60</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function getgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as title, CONCAT('GROUP : ',Nat_GroupName) as fulltitle, '' as childrens
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y' AND ( Nat_GroupCode = 2 OR Nat_GroupCode = 3 )
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
if($rows['groups']){
|
||||
foreach($rows['groups'] as $k => $v){
|
||||
$childrens = array(array('id'=>0, 'title'=>'Semua', 'fulltitle'=>'Subgroub : Semua'));
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as title, CONCAT('SUBGROUP : ',Nat_SubGroupName) as fulltitle
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupNat_GroupID = {$v['id']} AND Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$xrst = $this->db_onedev->query($query)->result_array();
|
||||
if($xrst){
|
||||
foreach($xrst as $ki => $vi){
|
||||
array_push($childrens,$vi);
|
||||
}
|
||||
}
|
||||
$rows['groups'][$k]['childrens'] = $childrens ;
|
||||
}
|
||||
}
|
||||
$query =" SELECT M_LangID as id, M_LangName as name
|
||||
FROM m_lang
|
||||
WHERE
|
||||
M_LangIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['langs'] = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = array(array('id'=>0, 'title'=>'Semua', 'fulltitle'=>'Subgroub : Semua'));
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as title, CONCAT('SUBGROUP : ',Nat_SubGroupName) as fulltitle
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupNat_GroupID = {$prm['id']} AND Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->result_array();
|
||||
if($rst){
|
||||
foreach($rst as $k => $v){
|
||||
array_push($rows,$v);
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getstation(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT T_SampleStationID as id, T_SampleStationName as name
|
||||
FROM t_samplestation
|
||||
WHERE
|
||||
T_SampleStationIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
//print_r($statuses);
|
||||
foreach($statuses as $k=>$v){
|
||||
array_push($rows['statuses'],$v);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdoctoraddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$prm['id']} AND M_DoctorAddressIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
public function savemultirule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$multirulename = $prm['multirulename'];
|
||||
$valueid = $prm['valueid'];
|
||||
|
||||
$sql = "insert into nat_multirule(
|
||||
Nat_MultiruleT_TestID,
|
||||
Nat_MultiruleName,
|
||||
Nat_MultiruleM_ValueID,
|
||||
Nat_MultiruleCreated,
|
||||
Nat_MultiruleLastUpdated
|
||||
)
|
||||
values( ?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$multirulename,
|
||||
$valueid
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_multirule insert");
|
||||
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 savemultiruledetailold()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$multiruleid = $prm['multiruleid'];
|
||||
$valueid = $prm['valueid'];
|
||||
|
||||
$sql = "insert into nat_multiruledetail(
|
||||
Nat_MultiruleDetailT_TestID,
|
||||
Nat_MultiruleDetailNat_MultiruleID,
|
||||
Nat_MultiruleDetailM_ValueID,
|
||||
Nat_MultiruleDetailCreated,
|
||||
Nat_MultiruleDetailLastUpdated
|
||||
)
|
||||
values( ?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$multiruleid,
|
||||
$valueid
|
||||
)
|
||||
);
|
||||
echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_multiruledetail insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function savemultiruledetail(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="INSERT INTO nat_multirule_detail (
|
||||
Nat_MultiruleDetailT_TestID,
|
||||
Nat_MultiruleDetailNat_MultiruleID,
|
||||
Nat_MultiruleDetailM_ValueID,
|
||||
Nat_MultiruleDetailCreated,
|
||||
Nat_MultiruleDetailLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['testid']}',
|
||||
'{$prm['multiruleid']}',
|
||||
'{$prm['valueid']}',
|
||||
NOW(),
|
||||
now()
|
||||
)
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
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 DESC
|
||||
";
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
function deletetrx(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierIsActive = 'N',
|
||||
So_WalkLetterCourierUserID = '{$userid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $prm['trx_id'];
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $prm['trx_numbering'],
|
||||
"id" => $prm['trx_id']
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['act'] == 'RELEASEC' || $prm['act'] === 'RCVDOC' ){
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierStatus = '{$prm['act']}',
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
if($prm['act'] === 'DONE'){
|
||||
$details = $prm['details'];
|
||||
$count_n = 0;
|
||||
foreach($details as $k => $v){
|
||||
if($v['flag_image_receive'] === 'N'){
|
||||
$count_n++;
|
||||
}
|
||||
if($v['flag_result_receive'] === 'N'){
|
||||
$count_n++;
|
||||
}
|
||||
$query ="UPDATE so_walklettercourierdetail SET
|
||||
So_WalkLetterCourierDetailFlagReceiveImage = '{$v['flag_image_receive']}',
|
||||
So_WalkLetterCourierDetailFlagReceiveResult = '{$v['flag_result_receive']}',
|
||||
So_WalkLetterCourierDetailUserID = '{$userid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierDetailID = {$v['idx']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
$status = 'DONE';
|
||||
if($count_n > 0){
|
||||
$status = 'PARTDONE';
|
||||
}
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierStatus = '{$status}',
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
if($prm['act'] == 'FORCEDONE'){
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierStatus = 'DONE',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
class Natinstrumentmethode extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "NatInstrumentMethode API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_one= $this->load->database("onedev", true);
|
||||
}
|
||||
function list_instrument() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_instrument where Nat_InstrumentIsActive='Y' and Nat_InstrumentName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatInstrument List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function list_test() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_test where Nat_TestIsResult = 'Y'
|
||||
and Nat_TestIsActive='Y' and Nat_TestName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatTest List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function delete_instrument() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
try {
|
||||
$sql = "update nat_instrument
|
||||
set
|
||||
Nat_InstrumentIsActive = 'N'
|
||||
,Nat_InstrumentUserID = ?
|
||||
where
|
||||
Nat_InstrumentID= ?";
|
||||
|
||||
$id = $param["Nat_InstrumentID"];
|
||||
|
||||
$qry = $this->db_one->query($sql, array($userid,$id));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("Nat_Instrument save", $this->db_one);
|
||||
}
|
||||
}
|
||||
|
||||
function save_instrument() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($param["Nat_InstrumentID"] == 0 ) {
|
||||
//add
|
||||
try {
|
||||
$sql = "insert into nat_instrument( Nat_InstrumentCode, Nat_InstrumentName
|
||||
,Nat_InstrumentUserID)
|
||||
values (?, ?, ? )
|
||||
";
|
||||
$code= $param["Nat_InstrumentCode"];
|
||||
$name = $param["Nat_InstrumentName"];
|
||||
$qry = $this->db_one->query($sql, array($code, $name, $userid ));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$sql = "update nat_instrument
|
||||
set
|
||||
Nat_InstrumentCode = ?
|
||||
,Nat_InstrumentName = ?
|
||||
,Nat_InstrumentUserID = ?
|
||||
where
|
||||
Nat_InstrumentID= ?";
|
||||
|
||||
$id = $param["Nat_InstrumentID"];
|
||||
$code= $param["Nat_InstrumentCode"];
|
||||
$name = $param["Nat_InstrumentName"];
|
||||
|
||||
$qry = $this->db_one->query($sql, array($code, $name, $userid,
|
||||
$id));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("Nat_Instrument save", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
function save() {
|
||||
$param = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if ($param["M_InstrumentMethodeID"] == 0 ) {
|
||||
//add
|
||||
try {
|
||||
$sql = "insert into m_instrumentmethode(M_InstrumentMethodeNat_InstrumentID,
|
||||
M_InstrumentMethodeNat_MethodeID, M_InstrumentMethodeNat_TestID,
|
||||
M_InstrumentMethodeResultFormatSF, M_InstrumentMethodeResultFormatAboveSF,
|
||||
M_InstrumentMethodeUserID)
|
||||
values (?, ?, ?, ?, ?, ? )
|
||||
";
|
||||
$instrumentID = $param["Nat_InstrumentID"];
|
||||
$methodeID= $param["Nat_MethodeID"];
|
||||
$testID= $param["Nat_TestID"];
|
||||
$resultFormatSF= $param["ResultFormatSF"];
|
||||
$resultFormatAboveSF= $param["ResultFormatAboveSF"];
|
||||
$qry = $this->db_one->query($sql, array($instrumentID, $methodeID, $testID,
|
||||
$resultFormatSF, $resultFormatAboveSF, $userid ));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
$sql = "update m_instrumentmethode
|
||||
set M_InstrumentMethodeNat_InstrumentID = ?,
|
||||
M_InstrumentMethodeNat_MethodeID =?,
|
||||
M_InstrumentMethodeNat_TestID =?,
|
||||
M_InstrumentMethodeResultFormatSF = ?,
|
||||
M_InstrumentMethodeResultFormatAboveSF = ? ,
|
||||
M_InstrumentMethodeUserID = ?
|
||||
where
|
||||
M_InstrumentMethodeID = ?
|
||||
";
|
||||
$methodePxID = $param["M_InstrumentMethodeID"];
|
||||
$instrumentID = $param["Nat_InstrumentID"];
|
||||
$methodeID= $param["Nat_MethodeID"];
|
||||
$testID= $param["Nat_TestID"];
|
||||
$resultFormatSF= $param["ResultFormatSF"];
|
||||
$resultFormatAboveSF= $param["ResultFormatAboveSF"];
|
||||
$qry = $this->db_one->query($sql, array($instrumentID, $methodeID, $testID,
|
||||
$resultFormatSF, $resultFormatAboveSF, $userid, $methodePxID));
|
||||
if ($qry) {
|
||||
$result = array("status" => "OK");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Saving Result", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
function list_methode() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$search= "%" . $prm["search"] . "%";
|
||||
try {
|
||||
$sql = "select * from nat_methode where Nat_MethodeIsActive='Y' and Nat_MethodeName like ?";
|
||||
$qry = $this->db_one->query($sql, array($search));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
function list_methodepx() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$instrumentID = $prm["Nat_InstrumentID"] ;
|
||||
try {
|
||||
$sql = "select * , Nat_TestName, Nat_MethodeName
|
||||
from m_instrumentmethode
|
||||
join nat_test on Nat_TestID = M_InstrumentMethodeNat_TestID
|
||||
join nat_methode on Nat_MethodeID = M_InstrumentMethodeNat_MethodeID
|
||||
where M_InstrumentMethodeIsActive='Y'
|
||||
and M_InstrumentMethodeNat_InstrumentID = ?";
|
||||
$qry = $this->db_one->query($sql, array($instrumentID));
|
||||
$rows = $qry->result_array();
|
||||
$tot_count = count($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("NatMethode List", $this->db_one);
|
||||
}
|
||||
}
|
||||
|
||||
function get_test_methode() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$id= $prm["Nat_TestID"] ;
|
||||
try {
|
||||
$sql = "select * from nat_test where Nat_TestID = ?";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $test= $rows[0];
|
||||
|
||||
$id= $prm["Nat_MethodeID"] ;
|
||||
$sql = "select * from nat_methode where Nat_MethodeID= ?";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
if (count($rows) > 0 ) $methode = $rows[0];
|
||||
|
||||
$result = array("status" => "OK" ,
|
||||
"data" => array("test" => $test , "methode" => $methode )
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$result = $this->sys_ok( array("status" => "ERR") );
|
||||
}
|
||||
} else {
|
||||
$result = $this->sys_ok( array("status" => "ERR") );
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
}
|
||||
function delete_methodepx() {
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$id= $prm["id"] ;
|
||||
try {
|
||||
$sql = "update
|
||||
m_instrumentmethode
|
||||
set M_InstrumentMethodeIsActive = 'N'
|
||||
where M_InstrumentMethodeID = ? ";
|
||||
$qry = $this->db_one->query($sql, array($id));
|
||||
if ($qry) {
|
||||
$result = array("records" => "");
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
$this->sys_error_db("MethodePx delete", $this->db_one);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,970 @@
|
||||
<?php
|
||||
class Normalvalue extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Normal Value API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["code"];
|
||||
$nama = $prm["nama"];
|
||||
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "WHERE Nat_TestIsActive = 'Y' AND Nat_TestIsResult = 'Y'";
|
||||
$sql_param = array();
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_TestCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " Nat_TestName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_PatientIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM nat_test
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("nat_test count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM nat_test
|
||||
$sql_where
|
||||
ORDER BY Nat_TestCode ASC
|
||||
limit 0,$tot_count";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
function searchmethode(){
|
||||
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->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);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM nat_methode
|
||||
WHERE
|
||||
Nat_MethodeName like ?
|
||||
AND Nat_MethodeIsActive = 'Y'
|
||||
ORDER BY Nat_MethodeName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->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);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany(){
|
||||
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 m_company
|
||||
WHERE
|
||||
Nat_TestName like ?
|
||||
AND Nat_TestIsActive = 'Y' AND Nat_TestIsLabFrom = '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("m_company count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
Nat_TestName like ?
|
||||
AND Nat_TestIsActive = 'Y' AND Nat_TestIsLabFrom = 'Y'
|
||||
ORDER BY Nat_TestName DESC
|
||||
";
|
||||
$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("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getmou(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouIsActive = 'Y' AND M_MouNat_TestID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_normalvaluetype
|
||||
WHERE
|
||||
Nat_NormalValueTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['normalvaluetypees'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['flages'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT 'HARI' as Nat_AgeUnitID,'HARI' as Nat_AgeUnitName
|
||||
UNION SELECT 'BULAN' as Nat_AgeUnitID, 'BULAN' as Nat_AgeUnitName
|
||||
UNION SELECT 'TAHUN' as Nat_AgeUnitID, 'TAHUN' as Nat_AgeUnitName
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ageunites'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_SexID, 'Semua' as Nat_SexName
|
||||
UNION
|
||||
SELECT Nat_SexID, Nat_SexName
|
||||
FROM nat_sex
|
||||
WHERE
|
||||
Nat_SexIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$rows['f_sexs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query ="
|
||||
SELECT 0 as Nat_FlagID, 'Semua' as Nat_FlagName
|
||||
UNION
|
||||
SELECT Nat_FlagID, Nat_FlagName
|
||||
FROM nat_flag
|
||||
WHERE
|
||||
Nat_FlagIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['f_flags'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$query ="UPDATE m_patient SET
|
||||
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
||||
M_PatientName = '{$prm['M_PatientName']}',
|
||||
M_PatientDOB = '{$pdob}',
|
||||
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
||||
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
||||
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
||||
M_PatientHP = '{$prm['M_PatientHP']}',
|
||||
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
||||
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
||||
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
||||
M_PatientNote = '{$prm['M_PatientNote']}'
|
||||
WHERE
|
||||
M_PatientID = '{$prm['M_PatientID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newreceivereference(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdate = date('Y-m-d',strtotime($prm['sdate']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_test (
|
||||
Nat_TestNat_TestID,
|
||||
Nat_TestM_MouID,
|
||||
Nat_TestDate,
|
||||
Nat_TestNote,
|
||||
Nat_TestUserID,
|
||||
Nat_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['companyid']}',
|
||||
'{$prm['mouid']}',
|
||||
'{$pdate}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogNat_TestID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$last_id}',
|
||||
'1',
|
||||
'{$userid}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $querylog;
|
||||
$insert_new_log = $this->db_onedev->query($querylog);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function sendorder(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE nat_test SET
|
||||
Nat_TestIsSent = 'Y',
|
||||
Nat_TestSentDate = now(),
|
||||
Nat_TestUserID = '{$userid}'
|
||||
WHERE
|
||||
Nat_TestID = '{$prm['Nat_TestID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogNat_TestID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$prm['Nat_TestID']}',
|
||||
'2',
|
||||
'{$userid}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $querylog;
|
||||
$insert_new_log = $this->db_onedev->query($querylog);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getnilainormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$methodename = $prm['methodename'];
|
||||
$sexid = $prm['sexid'];
|
||||
$flagid = $prm['flagid'];
|
||||
$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))";
|
||||
}
|
||||
$query =" SELECT nat_normalvalue.*,
|
||||
Nat_TestName,
|
||||
Nat_SexID,
|
||||
Nat_SexName,
|
||||
Nat_MethodeID,
|
||||
Nat_MethodeName,
|
||||
Nat_NormalValueTypeID,
|
||||
Nat_NormalValueTypeName,
|
||||
Nat_FlagID,
|
||||
Nat_FlagName,
|
||||
CASE
|
||||
WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' - ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
||||
WHEN Nat_NormalValueMinAgeInclusive = 'Y' AND Nat_NormalValueMaxAgeInclusive = 'N' THEN CONCAT(Nat_NormalValueMinAge,' > ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
||||
WHEN Nat_NormalValueMinAgeInclusive = 'N' AND Nat_NormalValueMaxAgeInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinAge,' < ',Nat_NormalValueMaxAge,' (',Nat_NormalValueAgeUnit,')')
|
||||
ELSE '-'
|
||||
END as Nat_NormalValueAge,
|
||||
CASE
|
||||
WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' - ',Nat_NormalValueMaxValue)
|
||||
WHEN Nat_NormalValueMinValueInclusive = 'Y' AND Nat_NormalValueMaxValueInclusive = 'N' THEN CONCAT(Nat_NormalValueMinValue,' > ',Nat_NormalValueMaxValue)
|
||||
WHEN Nat_NormalValueMinValueInclusive = 'N' AND Nat_NormalValueMaxValueInclusive = 'Y' THEN CONCAT(Nat_NormalValueMinValue,' < ',Nat_NormalValueMaxValue)
|
||||
ELSE '-'
|
||||
END as Nat_NormalValueValue,
|
||||
IF(Nat_NormalValueIsAbnormal = 'N',Nat_NormalValueID,Nat_NormalValueParentID) as parentid,
|
||||
DATE_FORMAT(Nat_NormalValueValidDate,'%d-%m-%Y') as Nat_NormalValueValidDatex,
|
||||
'' as tes,
|
||||
'xxx' as tests,
|
||||
'' as action,
|
||||
'N' as show_detail
|
||||
|
||||
FROM nat_normalvalue
|
||||
LEFT JOIN nat_sex ON Nat_NormalValueNat_SexID = Nat_SexID
|
||||
JOIN nat_test ON Nat_NormalValueNat_TestID = Nat_TestID
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID AND Nat_MethodeIsActive = 'Y'
|
||||
JOIN nat_normalvaluetype ON Nat_NormalValueNat_NormalValueTypeID = Nat_NormalValueTypeID
|
||||
LEFT JOIN nat_flag ON Nat_NormalValueNat_FlagID = Nat_FlagID
|
||||
WHERE
|
||||
Nat_NormalValueIsActive = 'Y' AND Nat_NormalValueNat_TestID = {$prm['id']} AND
|
||||
Nat_MethodeName like '%{$methodename}%'
|
||||
$filter
|
||||
GROUP BY Nat_NormalValueID
|
||||
ORDER BY Nat_NormalValueNat_SexID ASC, Nat_NormalValueMinAge ASC, Nat_NormalValueMaxAge ASC, parentid ASC
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($rows){
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['tesx'] = json_decode($x->n);
|
||||
$rows[$k]['tests'] = $this->add_test($v['Nat_NormalValueID']);
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function add_test($orderid){
|
||||
$query ="SELECT IFNULL(Nat_NormalValueLangID,0) as id,
|
||||
IFNULL(Nat_NormalValueLangNat_NormalValueID,$orderid) as Nat_NormalValueLangNat_NormalValueID,
|
||||
Nat_LangName,
|
||||
IFNULL(Nat_NormalValueLangNote, '') as Nat_NormalValueLangNote,
|
||||
IFNULL(Nat_NormalValueLangNoteSI, '') as Nat_NormalValueLangNoteSI,
|
||||
IFNULL(Nat_NormalValueLangDescription, '') as Nat_NormalValueLangDescription,
|
||||
IFNULL(Nat_NormalValueLangDescriptionSI, '') as Nat_NormalValueLangDescriptionSI,
|
||||
IFNULL(Nat_NormalValueLangNat_LangID, Nat_LangID) as Nat_NormalValueLangNat_LangID,
|
||||
'xxx' as action,
|
||||
'Y' as show_detail,
|
||||
Nat_LangID as idx,
|
||||
Nat_LangID
|
||||
from nat_lang
|
||||
left join nat_normalvaluelang ON Nat_LangID = Nat_NormalValueLangNat_LangID AND Nat_NormalValueLangNat_NormalValueID = {$orderid}
|
||||
left join nat_normalvalue ON Nat_NormalValueLangNat_NormalValueID = Nat_NormalValueID
|
||||
where
|
||||
Nat_LangIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function savenewnilainormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pvaliddate = date('Y-m-d',strtotime($prm['Nat_NormalValueValidDate ']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_normalvalue (
|
||||
Nat_NormalValueNat_TestID,
|
||||
Nat_NormalValueNat_MethodeID,
|
||||
Nat_NormalValueNat_NormalValueTypeID,
|
||||
Nat_NormalValueNat_FlagID,
|
||||
Nat_NormalValueValidDate,
|
||||
Nat_NormalValueMinAge,
|
||||
Nat_NormalValueMaxAge,
|
||||
Nat_NormalValueMinAgeInclusive,
|
||||
Nat_NormalValueMaxAgeInclusive,
|
||||
Nat_NormalValueAgeUnit,
|
||||
Nat_NormalValueNat_SexID,
|
||||
Nat_NormalValueNote,
|
||||
Nat_NormalValueMinValue,
|
||||
Nat_NormalValueMaxValue,
|
||||
Nat_NormalValueMinValueInclusive,
|
||||
Nat_NormalValueMaxValueInclusive,
|
||||
Nat_NormalValueDescription,
|
||||
Nat_NormalValueIsAbnormal,
|
||||
Nat_NormalValueUserID,
|
||||
Nat_NormalValueLastUpdated
|
||||
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_NormalValueNat_TestID']}',
|
||||
'{$prm['Nat_NormalValueNat_MethodeID']}',
|
||||
'{$prm['Nat_NormalValueNat_NormalValueTypeID']}',
|
||||
'{$prm['Nat_NormalValueNat_FlagID']}',
|
||||
'{$prm['Nat_NormalValueValidDate']}',
|
||||
'{$prm['Nat_NormalValueMinAge']}',
|
||||
'{$prm['Nat_NormalValueMaxAge']}',
|
||||
'{$prm['Nat_NormalValueMinAgeInclusive']}',
|
||||
'{$prm['Nat_NormalValueMaxAgeInclusive']}',
|
||||
'{$prm['Nat_NormalValueAgeUnit']}',
|
||||
'{$prm['Nat_NormalValueNat_SexID']}',
|
||||
'{$prm['Nat_NormalValueNote']}',
|
||||
'{$prm['Nat_NormalValueMinValue']}',
|
||||
'{$prm['Nat_NormalValueMaxValue']}',
|
||||
'{$prm['Nat_NormalValueMinValueInclusive']}',
|
||||
'{$prm['Nat_NormalValueMaxValueInclusive']}',
|
||||
'{$prm['Nat_NormalValueDescription']}',
|
||||
'{$prm['Nat_NormalValueIsAbnormal']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$ordernormalvalue_id = $this->db_onedev->insert_id();
|
||||
$sql_param = $ordernormalvalue_id;
|
||||
$sql = "select * from nat_normalvalue
|
||||
where Nat_NormalValueID= ?";
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
||||
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
||||
$data = json_encode($rows);
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
$sql_param = array("NormalValue.Add", $data , $userID);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if (! $query) {
|
||||
$this->sys_error_db( $this->db_onedev->last_query());
|
||||
exit;
|
||||
}
|
||||
$querylang ="INSERT INTO nat_normalvaluelang (
|
||||
Nat_NormalValueLangNat_NormalValueID,
|
||||
Nat_NormalValueLangNat_LangID,
|
||||
Nat_NormalValueLangNote,
|
||||
Nat_NormalValueLangDescription,
|
||||
Nat_NormalValueLangUserID,
|
||||
Nat_NormalValueLangCreated,
|
||||
Nat_NormalValueLangLastUpdated
|
||||
|
||||
)
|
||||
VALUES(
|
||||
'{$ordernormalvalue_id}',
|
||||
'1',
|
||||
'{$prm['Nat_NormalValueNote']}',
|
||||
'{$prm['Nat_NormalValueDescription']}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
now()
|
||||
)
|
||||
";
|
||||
$rows = $this->db_onedev->query($querylang);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditnilainormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm['Nat_NormalValueID'];
|
||||
$pvaliddate = date('Y-m-d',strtotime($prm['Nat_NormalValueValidDate ']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE nat_normalvalue SET
|
||||
Nat_NormalValueNat_TestID = '{$prm['Nat_NormalValueNat_TestID']}',
|
||||
Nat_NormalValueNat_MethodeID = '{$prm['Nat_NormalValueNat_MethodeID']}',
|
||||
Nat_NormalValueNat_NormalValueTypeID = '{$prm['Nat_NormalValueNat_NormalValueTypeID']}',
|
||||
Nat_NormalValueNat_FlagID = '{$prm['Nat_NormalValueNat_FlagID']}',
|
||||
Nat_NormalValueValidDate = '{$prm['Nat_NormalValueValidDate']}',
|
||||
Nat_NormalValueMinAge = '{$prm['Nat_NormalValueMinAge']}',
|
||||
Nat_NormalValueMaxAge = '{$prm['Nat_NormalValueMaxAge']}',
|
||||
Nat_NormalValueMinAgeInclusive = '{$prm['Nat_NormalValueMinAgeInclusive']}',
|
||||
Nat_NormalValueMaxAgeInclusive = '{$prm['Nat_NormalValueMaxAgeInclusive']}',
|
||||
Nat_NormalValueAgeUnit = '{$prm['Nat_NormalValueAgeUnit']}',
|
||||
Nat_NormalValueNat_SexID = '{$prm['Nat_NormalValueNat_SexID']}',
|
||||
Nat_NormalValueNote = '{$prm['Nat_NormalValueNote']}',
|
||||
Nat_NormalValueMinValue = '{$prm['Nat_NormalValueMinValue']}',
|
||||
Nat_NormalValueMaxValue = '{$prm['Nat_NormalValueMaxValue']}',
|
||||
Nat_NormalValueMinValueInclusive = '{$prm['Nat_NormalValueMinValueInclusive']}',
|
||||
Nat_NormalValueMaxValueInclusive = '{$prm['Nat_NormalValueMaxValueInclusive']}',
|
||||
Nat_NormalValueDescription = '{$prm['Nat_NormalValueDescription']}',
|
||||
Nat_NormalValueIsAbnormal = '{$prm['Nat_NormalValueIsAbnormal']}',
|
||||
Nat_NormalValueUserID = '{$userid}',
|
||||
Nat_NormalValueLastUpdated = now()
|
||||
WHERE
|
||||
Nat_NormalValueID = '{$prm['Nat_NormalValueID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$sql_param = $order_id;
|
||||
$sql = "select * from nat_normalvalue
|
||||
where Nat_NormalValueID= ?";
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
||||
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
||||
$data = json_encode($rows);
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
$sql_param = array("NormalValue.Update", $data , $userID);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if (! $query) {
|
||||
$this->sys_error_db( $this->db_onedev->last_query());
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function savenewnilaiabnormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pvaliddate = date('Y-m-d',strtotime($prm['Nat_NormalValueValidDate ']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO nat_normalvalue (
|
||||
Nat_NormalValueNat_TestID,
|
||||
Nat_NormalValueNat_MethodeID,
|
||||
Nat_NormalValueNat_NormalValueTypeID,
|
||||
Nat_NormalValueNat_FlagID,
|
||||
Nat_NormalValueValidDate,
|
||||
Nat_NormalValueMinAge,
|
||||
Nat_NormalValueMaxAge,
|
||||
Nat_NormalValueMinAgeInclusive,
|
||||
Nat_NormalValueMaxAgeInclusive,
|
||||
Nat_NormalValueAgeUnit,
|
||||
Nat_NormalValueNat_SexID,
|
||||
Nat_NormalValueNote,
|
||||
Nat_NormalValueMinValue,
|
||||
Nat_NormalValueMaxValue,
|
||||
Nat_NormalValueMinValueInclusive,
|
||||
Nat_NormalValueMaxValueInclusive,
|
||||
Nat_NormalValueDescription,
|
||||
Nat_NormalValueParentID,
|
||||
Nat_NormalValueIsAbnormal,
|
||||
Nat_NormalValueUserID,
|
||||
Nat_NormalValueLastUpdated
|
||||
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['Nat_NormalValueNat_TestID']}',
|
||||
'{$prm['Nat_NormalValueNat_MethodeID']}',
|
||||
'{$prm['Nat_NormalValueNat_NormalValueTypeID']}',
|
||||
'{$prm['Nat_NormalValueNat_FlagID']}',
|
||||
'{$prm['Nat_NormalValueValidDate']}',
|
||||
'{$prm['Nat_NormalValueMinAge']}',
|
||||
'{$prm['Nat_NormalValueMaxAge']}',
|
||||
'{$prm['Nat_NormalValueMinAgeInclusive']}',
|
||||
'{$prm['Nat_NormalValueMaxAgeInclusive']}',
|
||||
'{$prm['Nat_NormalValueAgeUnit']}',
|
||||
'{$prm['Nat_NormalValueNat_SexID']}',
|
||||
'{$prm['Nat_NormalValueNote']}',
|
||||
'{$prm['Nat_NormalValueMinValue']}',
|
||||
'{$prm['Nat_NormalValueMaxValue']}',
|
||||
'{$prm['Nat_NormalValueMinValueInclusive']}',
|
||||
'{$prm['Nat_NormalValueMaxValueInclusive']}',
|
||||
'{$prm['Nat_NormalValueDescription']}',
|
||||
'{$prm['Nat_NormalValueParentID']}',
|
||||
'{$prm['Nat_NormalValueIsAbnormal']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$ordernormalvalue_id = $this->db_onedev->insert_id();
|
||||
$sql_param = $ordernormalvalue_id;
|
||||
$sql = "select * from nat_normalvalue
|
||||
where Nat_NormalValueID= ?";
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
||||
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
||||
$data = json_encode($rows);
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
$sql_param = array("NormalValue.Add", $data , $userID);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if (! $query) {
|
||||
$this->sys_error_db( $this->db_onedev->last_query());
|
||||
exit;
|
||||
}
|
||||
$querylang ="INSERT INTO nat_normalvaluelang (
|
||||
Nat_NormalValueLangNat_NormalValueID,
|
||||
Nat_NormalValueLangNat_LangID,
|
||||
Nat_NormalValueLangNote,
|
||||
Nat_NormalValueLangDescription,
|
||||
Nat_NormalValueLangUserID,
|
||||
Nat_NormalValueLangCreated,
|
||||
Nat_NormalValueLangLastUpdated
|
||||
|
||||
)
|
||||
VALUES(
|
||||
'{$ordernormalvalue_id}',
|
||||
'1',
|
||||
'{$prm['Nat_NormalValueNote']}',
|
||||
'{$prm['Nat_NormalValueDescription']}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
now()
|
||||
)
|
||||
";
|
||||
$rows = $this->db_onedev->query($querylang);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function deletenilainormal(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE nat_normalvalue SET
|
||||
Nat_NormalValueIsActive = 'N',
|
||||
Nat_NormalValueUserID = '{$userid}'
|
||||
WHERE
|
||||
Nat_NormalValueID = '{$prm['Nat_NormalValueID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$sql_param = $prm['Nat_NormalValueID'];
|
||||
$sql = "select * from nat_normalvalue
|
||||
where Nat_NormalValueID= ?";
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nat_normalvalue select by normalvalue");
|
||||
exit;
|
||||
}
|
||||
$sql = "insert into nasional_log.log_normalvalue(Log_NormalValueCode,
|
||||
Log_NormalValueData, Log_NormalValueUserID) values(?,?,?)";
|
||||
$data = json_encode($rows);
|
||||
$userID = $this->sys_user["M_UserID"];
|
||||
$sql_param = array("NormalValue.Delete", $data , $userID);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if (! $query) {
|
||||
$this->sys_error_db( $this->db_onedev->last_query());
|
||||
exit;
|
||||
}
|
||||
$query ="UPDATE nat_normalvaluelang SET
|
||||
Nat_NormalValueLangIsActive = 'N',
|
||||
Nat_NormalValueLangUserID = '{$userid}'
|
||||
WHERE
|
||||
Nat_NormalValueLangNat_NormalValueID = '{$prm['Nat_NormalValueID']}' AND Nat_NormalValueLangIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function savenormalvaluelang(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$normalvalue_id = $prm['normalvalueid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach($prm['ordertests'] as $k=>$v){
|
||||
if($v['id'] == 0 || $v['id'] == '0'){
|
||||
$query = "INSERT INTO nat_normalvaluelang (
|
||||
Nat_NormalValueLangNat_NormalValueID,
|
||||
Nat_NormalValueLangNat_LangID,
|
||||
Nat_NormalValueLangNote,
|
||||
Nat_NormalValueLangNoteSI,
|
||||
Nat_NormalValueLangDescription,
|
||||
Nat_NormalValueLangDescriptionSI,
|
||||
Nat_NormalValueLangUserID,
|
||||
Nat_NormalValueLangCreated,
|
||||
Nat_NormalValueLangLastUpdated
|
||||
)
|
||||
VALUE(
|
||||
?,?,?,?,?,?,?,now(),now()
|
||||
)";
|
||||
$insert_new_normalvaluelang = $this->db->query($query,array(
|
||||
$normalvalue_id,
|
||||
$v['Nat_LangID'],
|
||||
$v['Nat_NormalValueLangNote'],
|
||||
$v['Nat_NormalValueLangNoteSI'],
|
||||
$v['Nat_NormalValueLangDescription'],
|
||||
$v['Nat_NormalValueLangDescriptionSI'],
|
||||
$userid
|
||||
));
|
||||
} else {
|
||||
$query = "UPDATE nat_normalvaluelang SET
|
||||
Nat_NormalValueLangNat_LangID = ?,
|
||||
Nat_NormalValueLangNote = ?,
|
||||
Nat_NormalValueLangNoteSI = ?,
|
||||
Nat_NormalValueLangDescription = ?,
|
||||
Nat_NormalValueLangDescriptionSI = ?,
|
||||
Nat_NormalValueLangUserID = ?
|
||||
WHERE
|
||||
Nat_NormalValueLangID = ?";
|
||||
$update_normalvaluelang = $this->db->query($query,array($v['Nat_LangID'],$v['Nat_NormalValueLangNote'],$v['Nat_NormalValueLangNoteSI'],$v['Nat_NormalValueLangDescription'],$v['Nat_NormalValueLangDescriptionSI'],$userid,$v['id']));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchtest(){
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
$mou_id = $prm['mouid'];
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
JOIN t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
||||
WHERE
|
||||
T_TestName like ? AND
|
||||
T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("test count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT 'Y' as editable, 0 as xid, T_TestID, T_TestCode, T_TestName, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceAmount - ((T_PriceDisc/100) * T_PriceAmount) - T_PriceDiscRp as total,
|
||||
Nat_TestID, Nat_TestIsBill, Nat_TestMinDP
|
||||
FROM one.t_test
|
||||
JOIN one.t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
||||
JOIN one.m_mou ON M_MouID = '{$mou_id}'
|
||||
JOIN one.m_company ON M_MouNat_TestID = Nat_TestID
|
||||
WHERE
|
||||
T_TestName like ? AND
|
||||
T_TestIsActive = '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("test rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
522
one-api/application/controllers/mockup/masterdata/Patient.php
Normal file
522
one-api/application/controllers/mockup/masterdata/Patient.php
Normal file
@@ -0,0 +1,522 @@
|
||||
<?php
|
||||
class Patient 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);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$norm = $prm["snorm"];
|
||||
$nama = $prm["nama"];
|
||||
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "WHERE M_PatientIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($norm != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientNoReg like ? ";
|
||||
$sql_param[] = "%$norm%";
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_PatientIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_patient
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
LEFT JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_PatientM_ReligionID = M_ReligionID
|
||||
LEFT JOIN m_idtype ON M_PatientM_IdTypeID = M_IdTypeID
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patient count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
M_PatientID,
|
||||
M_PatientNoReg,
|
||||
M_PatientName,
|
||||
M_PatientHP,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientPhone,
|
||||
M_PatientNote,
|
||||
M_PatientIDNumber,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
||||
M_PatientNote,
|
||||
M_PatientM_SexID,
|
||||
M_SexName,
|
||||
M_PatientM_TitleID,
|
||||
M_TitleName,
|
||||
M_PatientM_ReligionID,
|
||||
M_ReligionName,
|
||||
M_PatientM_IdTypeID,
|
||||
M_IdTypeName,
|
||||
M_PatientIDNumber
|
||||
FROM m_patient
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
LEFT JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_PatientM_ReligionID = M_ReligionID
|
||||
LEFT JOIN m_idtype ON M_PatientM_IdTypeID = M_IdTypeID
|
||||
$sql_where
|
||||
ORDER BY M_PatientName ASC
|
||||
limit 0,20";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_PatientID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_title
|
||||
WHERE
|
||||
M_TitleIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['titles'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM m_idtype
|
||||
WHERE
|
||||
M_IdTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['kartuidentitass'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchcity(){
|
||||
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 m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = '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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getdistrict(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$query ="UPDATE m_patient SET
|
||||
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
||||
M_PatientName = '{$prm['M_PatientName']}',
|
||||
M_PatientDOB = '{$pdob}',
|
||||
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
||||
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
||||
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
||||
M_PatientPOB = '{$prm['M_PatientPOB']}',
|
||||
M_PatientHP = '{$prm['M_PatientHP']}',
|
||||
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
||||
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
||||
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
||||
M_PatientNote = '{$prm['M_PatientNote']}'
|
||||
WHERE
|
||||
M_PatientID = '{$prm['M_PatientID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_PatientDOB"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.EDIT', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$query ="INSERT INTO m_patient (
|
||||
M_PatientM_TitleID,
|
||||
M_PatientName,
|
||||
M_PatientDOB,
|
||||
M_PatientM_SexID,
|
||||
M_PatientM_ReligionID,
|
||||
M_PatientEmail,
|
||||
M_PatientPOB,
|
||||
M_PatientHP,
|
||||
M_PatientPhone,
|
||||
M_PatientM_IdTypeID,
|
||||
M_PatientIDNumber,
|
||||
M_PatientNote,
|
||||
M_PatientUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientM_TitleID']}',
|
||||
'{$prm['M_PatientName']}',
|
||||
'{$pdob}',
|
||||
'{$prm['M_PatientM_SexID']}',
|
||||
'{$prm['M_PatientM_ReligionID']}',
|
||||
'{$prm['M_PatientEmail']}',
|
||||
'{$prm['M_PatientPOB']}',
|
||||
'{$prm['M_PatientHP']}',
|
||||
'{$prm['M_PatientPhone']}',
|
||||
'{$prm['M_PatientM_IdTypeID']}',
|
||||
'{$prm['M_PatientIDNumber']}',
|
||||
'{$prm['M_PatientNote']}',
|
||||
$userid
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_PatientID"] = $last_id;
|
||||
$ptn["M_PatientDOB"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADD', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletepatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_patient SET
|
||||
M_PatientIsActive = 'N'
|
||||
WHERE
|
||||
M_PatientID = '{$prm['M_PatientID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_PatientDOB"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.DELETE', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_patientaddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,
|
||||
'' as action
|
||||
FROM m_patientaddress
|
||||
JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
WHERE
|
||||
M_PatientAddressIsActive = 'Y' AND M_PatientAddressM_PatientID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_PatientAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_patientaddress WHERE M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}' AND M_PatientAddressNote = 'Utama' AND M_PatientAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_PatientAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_PatientAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_patientaddress (
|
||||
M_PatientAddressM_PatientID,
|
||||
M_PatientAddressNote,
|
||||
M_PatientAddressDescription,
|
||||
M_PatientAddressM_KelurahanID,
|
||||
M_PatientAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_PatientAddressM_PatientID']}',
|
||||
'{$prm['M_PatientAddressNote']}',
|
||||
'{$prm['M_PatientAddressDescription']}',
|
||||
'{$prm['M_PatientAddressM_KelurahanID']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_ADD', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_patientaddress SET
|
||||
M_PatientAddressM_PatientID = '{$prm['M_PatientAddressM_PatientID']}',
|
||||
M_PatientAddressNote = '{$prm['M_PatientAddressNote']}',
|
||||
M_PatientAddressDescription = '{$prm['M_PatientAddressDescription']}',
|
||||
M_PatientAddressM_KelurahanID = '{$prm['M_PatientAddressM_KelurahanID']}'
|
||||
WHERE
|
||||
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_EDIT', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_patientaddress SET
|
||||
M_PatientAddressIsActive = 'N'
|
||||
WHERE
|
||||
M_PatientAddressID = '{$prm['M_PatientAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$ptn = $prm;
|
||||
$ptn["M_UserID"] = $pdob;
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_onedev->query("CALL one_log.log_me('PATIENT', 'PATIENT.ADDR_DELETE', '{$ptn}', $userid)");
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,571 @@
|
||||
<?php
|
||||
class Polakelainannonlab extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "KELAINAN LAB API";
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$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_total = "SELECT count(*) as total
|
||||
FROM mcu_summarynonlab
|
||||
JOIN nat_test ON Mcu_SummaryNonlabNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
JOIN mcu_kelainan ON Mcu_SummaryNonlabMcu_KelainanID = Mcu_KelainanID
|
||||
AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE Mcu_SummaryNonlabIsActive = 'Y'
|
||||
AND (CONCAT(Nat_TestCode,' ',Nat_TestName) LIKE ? OR Mcu_KelainanName LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$search, $search]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$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->db->trans_rollback();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("mcu_summarynonlab count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT Mcu_SummaryNonlabID,
|
||||
Mcu_SummaryNonlabNat_TestID,
|
||||
Mcu_SummaryNonlabNat_Code,
|
||||
Mcu_SummaryNonlabMcu_KelainanID,
|
||||
Mcu_SummaryNonlabValue,
|
||||
Mcu_SummaryNonlabConclusionDetailIDs,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
CONCAT(Nat_TestCode,' ',Nat_TestName) AS codeNameTest,
|
||||
Mcu_KelainanID,
|
||||
Mcu_KelainanName,
|
||||
Mcu_FitnessCategoryID,
|
||||
Mcu_FitnessCategoryName,
|
||||
Mcu_FitnessCategoryEng,
|
||||
CONCAT(Mcu_FitnessCategoryName,' ','(',Mcu_FitnessCategoryEng,')') as fitnessname,
|
||||
'' as rownumber,
|
||||
'' as xvalue
|
||||
FROM mcu_summarynonlab
|
||||
JOIN nat_test ON Mcu_SummaryNonlabNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
JOIN mcu_kelainan ON Mcu_SummaryNonlabMcu_KelainanID = Mcu_KelainanID
|
||||
AND Mcu_KelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_fitness_category ON Mcu_SummaryNonlabMcu_FitnessCategoryID = Mcu_FitnessCategoryID
|
||||
AND Mcu_FitnessCategoryIsActive = 'Y'
|
||||
WHERE Mcu_SummaryNonlabIsActive = 'Y'
|
||||
AND (CONCAT(Nat_TestCode,' ',Nat_TestName) LIKE ? OR Mcu_KelainanName LIKE ?)
|
||||
ORDER BY Mcu_SummaryNonlabID DESC
|
||||
limit ? offset ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$search, $search, $number_limit, $number_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("mcu_summarynonlab select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $k => $v) {
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
$rows[$k]['xvalue'] = $this->add_value($v['Mcu_SummaryNonlabID']);
|
||||
}
|
||||
|
||||
|
||||
$result = [
|
||||
"total_page" => $tot_page,
|
||||
"total" => $tot_count,
|
||||
"records" => $rows,
|
||||
"last_qry" => $last_qry
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function add_value($orderid)
|
||||
{
|
||||
$sql = $this->db->query("SELECT Mcu_SummaryNonlabConclusionDetailIDs FROM mcu_summarynonlab
|
||||
WHERE Mcu_SummaryNonlabID = {$orderid}")->row();
|
||||
$svalue = $sql->Mcu_SummaryNonlabConclusionDetailIDs;
|
||||
$pieces = explode(",", $svalue);
|
||||
|
||||
$Mcu_SummaryNonlabConclusionDetailIDs = "''";
|
||||
foreach ($pieces as $idx => $detail) {
|
||||
$Mcu_SummaryNonlabConclusionDetailIDs .= "," . "'" . $detail . "'";
|
||||
}
|
||||
|
||||
|
||||
$query = "SELECT NonlabConclusionDetailID, NonlabConclusionDetailCode, NonlabConclusionDetailName
|
||||
|
||||
FROM mcu_summarynonlab
|
||||
JOIN nonlab_conclusion_detail ON NonlabConclusionDetailID IN($Mcu_SummaryNonlabConclusionDetailIDs)
|
||||
WHERE
|
||||
Mcu_SummaryNonlabID = {$orderid}";
|
||||
//echo $query;
|
||||
$rows = $this->db->query($query)->result_array();
|
||||
if (!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
function searchtest()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$number_limit = 10;
|
||||
$tot_count = 0;
|
||||
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$sql_total = "SELECT count(*) as total
|
||||
FROM nat_test
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsResult = 'Y'
|
||||
AND (CONCAT(Nat_TestCode,' ',Nat_TestName) LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_total = $this->db->query($sql_total, [$search, $number_limit]);
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("nat_test count");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_search = "SELECT Nat_TestID,
|
||||
Nat_TestCode,
|
||||
CONCAT(Nat_TestCode,' ',Nat_TestName) as codeNameTest
|
||||
FROM nat_test
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsResult = 'Y'
|
||||
AND (CONCAT(Nat_TestCode,' ',Nat_TestName) LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_search = $this->db->query($sql_search, [$search, $number_limit]);
|
||||
if ($qry_search) {
|
||||
$rows = $qry_search->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("nat_test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_count,
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchkelainan()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$number_limit = 10;
|
||||
$tot_count = 0;
|
||||
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$sql_total = "SELECT count(*) as total
|
||||
FROM mcu_kelainan
|
||||
WHERE Mcu_KelainanIsActive = 'Y'
|
||||
AND (Mcu_KelainanName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_total = $this->db->query($sql_total, [$search, $number_limit]);
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("kelainan count");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_search = "SELECT Mcu_KelainanID,
|
||||
Mcu_KelainanName,
|
||||
Mcu_KelainanClasification
|
||||
FROM mcu_kelainan
|
||||
WHERE Mcu_KelainanIsActive = 'Y'
|
||||
AND (Mcu_KelainanName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_search = $this->db->query($sql_search, [$search, $number_limit]);
|
||||
if ($qry_search) {
|
||||
$rows = $qry_search->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("kelainan select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_count,
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function searchstatusresult()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$number_limit = 10;
|
||||
$tot_count = 0;
|
||||
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$sql_total = "SELECT count(*) as total
|
||||
FROM nonlab_conclusion_detail
|
||||
WHERE NonlabConclusionDetailIsActive = 'Y'
|
||||
AND (NonlabConclusionDetailName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_total = $this->db->query($sql_total, [$search, $number_limit]);
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("kelainan count");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_search = "SELECT NonlabConclusionDetailID,
|
||||
NonlabConclusionDetailCode,
|
||||
NonlabConclusionDetailName
|
||||
FROM nonlab_conclusion_detail
|
||||
WHERE NonlabConclusionDetailIsActive = 'Y'
|
||||
AND (NonlabConclusionDetailName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_search = $this->db->query($sql_search, [$search, $number_limit]);
|
||||
if ($qry_search) {
|
||||
$rows = $qry_search->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("kelainan select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_count,
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function add()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$testId = "";
|
||||
if (isset($prm["testId"])) {
|
||||
$testId = trim($prm["testId"]);
|
||||
}
|
||||
$kelainanId = "";
|
||||
if (isset($prm["kelainanId"])) {
|
||||
$kelainanId = trim($prm["kelainanId"]);
|
||||
}
|
||||
$testCode = "";
|
||||
if (isset($prm["testCode"])) {
|
||||
$testCode = trim($prm["testCode"]);
|
||||
}
|
||||
$fitnessId = 0;
|
||||
if (isset($prm["fitnessId"])) {
|
||||
$fitnessId = trim($prm["fitnessId"]);
|
||||
}
|
||||
|
||||
$codes = array_map(function ($item) {
|
||||
return $item["NonlabConclusionDetailID"];
|
||||
}, $prm["orderstatusresults"]);
|
||||
$vcode = implode(",", $codes);
|
||||
|
||||
$sql_exist = "SELECT Mcu_SummaryNonlabID,
|
||||
Mcu_SummaryNonlabNat_TestID,
|
||||
Mcu_SummaryNonlabMcu_KelainanID
|
||||
FROM mcu_summarynonlab
|
||||
WHERE Mcu_SummaryNonlabIsActive = 'Y'
|
||||
AND Mcu_SummaryNonlabNat_TestID = ?
|
||||
AND Mcu_SummaryNonlabMcu_KelainanID = ?";
|
||||
$qry_exist = $this->db->query($sql_exist, [$testId, $kelainanId]);
|
||||
if ($qry_exist) {
|
||||
$tot_exist = $qry_exist->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("mcu_summarynonlab count");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($tot_exist) > 0) {
|
||||
echo json_encode(["status" => "OK", "flag" => true, "msg" => "Tidak bisa disimpan karena ada kelainan yang sama dengan pemeriksaan yang sudah ada, silahkan pilih kelainan lainnya!"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$sql = "INSERT INTO mcu_summarynonlab(
|
||||
Mcu_SummaryNonlabNat_TestID,
|
||||
Mcu_SummaryNonlabNat_Code,
|
||||
Mcu_SummaryNonlabMcu_KelainanID,
|
||||
Mcu_SummaryNonlabMcu_FitnessCategoryID,
|
||||
Mcu_SummaryNonlabConclusionDetailIDs,
|
||||
Mcu_SummaryNonlabUserID,
|
||||
Mcu_SummaryNonlabCreated,
|
||||
Mcu_SummaryNonlabLastUpdated
|
||||
) VALUES(?,?,?,?,?,?,NOW(),NOW())";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$testId,
|
||||
$testCode,
|
||||
$kelainanId,
|
||||
$fitnessId,
|
||||
$vcode,
|
||||
$userid
|
||||
));
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("save mcu_summarynonlab 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 edit()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$xid = "";
|
||||
if (isset($prm["xid"])) {
|
||||
$xid = trim($prm["xid"]);
|
||||
}
|
||||
$fitnessId = 0;
|
||||
if (isset($prm["fitnessId"])) {
|
||||
$fitnessId = trim($prm["fitnessId"]);
|
||||
}
|
||||
|
||||
$codes = array_map(function ($item) {
|
||||
return $item["NonlabConclusionDetailID"];
|
||||
}, $prm["orderstatusresults"]);
|
||||
$vcode = implode(",", $codes);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = "UPDATE mcu_summarynonlab SET
|
||||
Mcu_SummaryNonlabMcu_FitnessCategoryID = ?,
|
||||
Mcu_SummaryNonlabConclusionDetailIDs = ?,
|
||||
Mcu_SummaryNonlabUserID = ?,
|
||||
Mcu_SummaryNonlabLastUpdated = NOW()
|
||||
WHERE Mcu_SummaryNonlabID = ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$fitnessId,
|
||||
$vcode,
|
||||
$userid,
|
||||
$xid
|
||||
]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("update mcu_summarynonlab 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);
|
||||
}
|
||||
}
|
||||
|
||||
function deleterow()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$xid = "";
|
||||
if (isset($prm["xid"])) {
|
||||
$xid = trim($prm["xid"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE mcu_summarynonlab SET
|
||||
Mcu_SummaryNonlabIsActive = 'N',
|
||||
Mcu_SummaryNonlabUserID = ?,
|
||||
Mcu_SummaryNonlabLastUpdated = NOW()
|
||||
WHERE Mcu_SummaryNonlabID = ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$userid,
|
||||
$xid
|
||||
]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("delete mcu_summarynonlab 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);
|
||||
}
|
||||
}
|
||||
|
||||
function getfitness()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql = "SELECT Mcu_FitnessCategoryID,
|
||||
Mcu_FitnessCategoryName,
|
||||
Mcu_FitnessCategoryEng,
|
||||
CONCAT(Mcu_FitnessCategoryName,' ','(',Mcu_FitnessCategoryEng,')') as fitnessname,
|
||||
Mcu_FitnessCategoryLevel
|
||||
FROM mcu_fitness_category
|
||||
WHERE Mcu_FitnessCategoryIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("mcu fitness error", $this->db);
|
||||
}
|
||||
|
||||
$result = array("records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
447
one-api/application/controllers/mockup/masterdata/Price.php
Normal file
447
one-api/application/controllers/mockup/masterdata/Price.php
Normal file
@@ -0,0 +1,447 @@
|
||||
<?php
|
||||
|
||||
class Price extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Price API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select distinct count(*) total
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y' and M_CompanyName LIKE ?
|
||||
order by M_CompanyName ASC";
|
||||
$query = $this->db_smartone->query($sql, ['%'.$prm['search'].'%']);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select distinct M_CompanyID, M_CompanyName
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y' and M_CompanyName LIKE ?
|
||||
order by M_CompanyName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, ['%'.$prm['search'].'%']);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$company = $prm["company_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
|
||||
and date(now()) >= M_MouStartDate
|
||||
and date(now()) <= M_MouEndDate
|
||||
order by M_MouName ASC";
|
||||
$query = $this->db_smartone->query($sql, [$company, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_MouID, M_MouName, M_MouStartDate, M_MouEndDate, M_MouIsVerified
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
|
||||
and date(now()) >= M_MouStartDate
|
||||
and date(now()) <= M_MouEndDate
|
||||
order by M_MouName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$company, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_price()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$mou = $prm["mou_id"];
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_price
|
||||
join t_test on t_pricet_testid = t_testid
|
||||
where T_PriceIsActive = 'Y'
|
||||
and T_PriceM_MouID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_smartone->query($sql, [$mou, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_PriceID, T_TestID, T_TestCode, T_TestName, T_PriceIsCito,
|
||||
T_PriceM_CompanyID,
|
||||
T_PriceM_MouID,
|
||||
T_PricePriority,
|
||||
T_PriceAmount,
|
||||
T_PriceDisc,
|
||||
T_PriceDiscRp,
|
||||
T_PriceSubTotal,
|
||||
T_PriceOther,
|
||||
T_PriceTotal,
|
||||
JSON_OBJECT('T_TestID', T_TestID, 'T_TestCode', T_TestCode, 'T_TestName', T_TestName) px,
|
||||
M_MouIsVerified
|
||||
from t_price
|
||||
join t_test on t_pricet_testid = t_testid
|
||||
join m_mou on t_pricem_mouid = m_mouid
|
||||
|
||||
where T_PriceIsActive = 'Y'
|
||||
and T_PriceM_MouID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$mou, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['px'] = json_decode($v['px']);
|
||||
|
||||
$sql = "select t_addonid id, t_addonname name, t_priceaddonamount price
|
||||
from t_priceaddon
|
||||
join t_addon on t_priceaddont_addonid = t_addonid
|
||||
where t_priceaddont_priceid = ?
|
||||
and t_priceaddonisactive = 'Y'";
|
||||
|
||||
$query = $this->db_smartone->query($sql, [$v['T_PriceID']]);
|
||||
|
||||
$rows2 = [];
|
||||
if ($query)
|
||||
{
|
||||
$rows2 = $query->result_array();
|
||||
}
|
||||
|
||||
$rows[$k]['others'] = $rows2;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function del_price()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "update t_price
|
||||
set t_priceisactive = 'N'
|
||||
where T_PriceIsActive = 'Y'
|
||||
and T_PriceID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$sql = "update t_priceaddon
|
||||
set t_priceaddonisactive = 'N'
|
||||
where T_PriceaddonIsActive = 'Y'
|
||||
and t_priceaddont_priceid = ?";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
$result = array("query"=>$this->db_smartone->last_query(), "id"=>$id);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_test
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and ((T_TestIsPrice = 'Y') OR (T_TestIsPrice = 'N' AND LENGTH(T_TestSasCode) = 8))
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_smartone->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_TestID, T_TestCode, T_TestName
|
||||
from t_test
|
||||
where T_TestIsActive = 'Y'
|
||||
and T_TestName LIKE ?
|
||||
and ((T_TestIsPrice = 'Y') OR (T_TestIsPrice = 'N' AND LENGTH(T_TestSasCode) = 8))
|
||||
order by T_TestSasCode ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("px rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$data = $prm["data"];
|
||||
$data_others = $prm["data_others"];
|
||||
|
||||
// QUERY
|
||||
// $sql = "INSERT INTO t_addon(T_AddonName) values('{$name}')";
|
||||
$query = $this->db_smartone->query("CALL sp_master_price_save('{$data}', '{$data_others}', '0')");
|
||||
|
||||
if ($query) {
|
||||
$result = $query->row();
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon new", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_addon()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_addon
|
||||
where T_AddonIsActive = 'Y'
|
||||
and T_AddonName LIKE ?
|
||||
order by T_AddonName ASC";
|
||||
$query = $this->db_smartone->query($sql, [$search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_AddonID, T_AddonName
|
||||
from t_addon
|
||||
where T_AddonIsActive = 'Y'
|
||||
and T_AddonName LIKE ?
|
||||
order by T_AddonName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_addon()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$name = $prm["name"];
|
||||
|
||||
// QUERY
|
||||
// $sql = "INSERT INTO t_addon(T_AddonName) values('{$name}')";
|
||||
$query = $this->db_smartone->set('T_AddonName', $name)
|
||||
->insert('t_addon');
|
||||
|
||||
if ($query) {
|
||||
$result = array("inserted_id" => $this->db_smartone->insert_id(), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("addon new", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_company_2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = '%'.$prm['search'].'%';
|
||||
|
||||
$max_rst = 25;
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName,
|
||||
IFNULL( concat('[', group_concat( json_object('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
JOIN m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName LIKE ?
|
||||
group by m_companyid
|
||||
order by M_CompanyName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => 1, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function copy_price()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_master_price_copy(?, ?, ?, 'N')";
|
||||
$query = $this->db_smartone->query($sql, [$prm['source_id'], $prm['target_id'], $prm['disc']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row;
|
||||
$this->sys_ok($rows->status);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price copy rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_single_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$sql = "SELECT M_CompanyID, M_CompanyName, CONCAT('[', GROUP_CONCAT(JSON_OBJECT('M_MouID', M_MouID, 'M_MouName', M_MouName, 'M_MouStartDate', M_MouStartDate, 'M_MouEndDate', M_MouEndDate, 'M_MouIsVerified', M_MouIsVerified) SEPARATOR ','), ']') mou
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now()) AND M_MouID = ?
|
||||
where M_CompanyIsActive = 'Y'
|
||||
GROUP BY M_CompanyID
|
||||
order by M_CompanyName ASC";
|
||||
$query = $this->db_smartone->query($sql, [$prm['id']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$rows[0]['mou'] = json_decode($rows[0]['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
208
one-api/application/controllers/mockup/masterdata/Priceref.php
Normal file
208
one-api/application/controllers/mockup/masterdata/Priceref.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
class Priceref extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Price Ref API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_company()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyIsLabTo = 'Y'
|
||||
order by M_CompanyName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CompanyID, M_CompanyName
|
||||
from m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyIsLabTo = 'Y'
|
||||
order by M_CompanyName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$company, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price company rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_mou()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$company = $prm["company_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC";
|
||||
$query = $this->db_smartone->query($sql, [$company, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_MouID, M_MouName, M_MouStartDate, M_MouEndDate
|
||||
from m_mou
|
||||
where M_MouIsActive = 'Y'
|
||||
and M_MouM_CompanyID = ?
|
||||
and M_MouName LIKE ?
|
||||
order by M_MouName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$company, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_price()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 12;
|
||||
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$mou = $prm["mou_id"];
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from t_priceref
|
||||
join t_test on t_pricereft_testid = t_testid
|
||||
where T_PriceRefIsActive = 'Y'
|
||||
and T_PriceRefM_MouID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC";
|
||||
$query = $this->db_smartone->query($sql, [$mou, $search]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_PriceRefID, T_TestID, T_TestCode, T_TestName,
|
||||
T_PriceRefM_CompanyID,
|
||||
T_PriceRefM_MouID,
|
||||
T_PriceRefAmount,
|
||||
T_PriceRefStartDate,
|
||||
T_PriceRefEndDate,
|
||||
JSON_OBJECT('T_TestID', T_TestID, 'T_TestCode', T_TestCode, 'T_TestName', T_TestName) px
|
||||
from t_priceref
|
||||
join t_test on t_pricereft_testid = t_testid
|
||||
|
||||
where T_PriceRefIsActive = 'Y'
|
||||
and T_PriceRefM_MouID = ?
|
||||
and T_TestName LIKE ?
|
||||
order by T_TestName ASC
|
||||
limit 0, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$mou, $search]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k => $v)
|
||||
$rows[$k]['px'] = json_decode($v['px']);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price mou rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function save_px()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 50;
|
||||
|
||||
$data = $prm["data"];
|
||||
|
||||
// QUERY
|
||||
$query = $this->db_smartone->query("CALL sp_master_price_ref_save('{$data}', '0')");
|
||||
|
||||
if ($query) {
|
||||
$result = $query->row();
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price ref new", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function del_price()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "update t_priceref
|
||||
set t_pricerefisactive = 'N'
|
||||
where T_PriceRefIsActive = 'Y'
|
||||
and T_PriceRefID = ?";
|
||||
$query = $this->db_smartone->query($sql, [$id]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$result = array("query"=>$this->db_smartone->last_query(), "id"=>$id);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("price ref rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
218
one-api/application/controllers/mockup/masterdata/Priviledge.php
Normal file
218
one-api/application/controllers/mockup/masterdata/Priviledge.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
class Priviledge extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "USERGROUP PRIVILEDGE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function lookupusergroup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_usergroup
|
||||
where
|
||||
M_UserGroupIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select M_UserGroupID as id, M_UserGroupDashboard as dashboard, M_UserGroupName as name, M_UserGroupIsClinic as clinic, M_UserGroupName as description , 'xxx' as usergrouptype
|
||||
from m_usergroup
|
||||
where
|
||||
M_UserGroupName LIKE CONCAT('%','{$search}','%') AND
|
||||
M_UserGroupIsActive = 'Y' $limit";
|
||||
$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" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookuppriviledge()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT S_MenuID as id, S_MenuUrl, S_MenuName as name, '' as childs FROM s_menu WHERE S_MenuParentS_MenuID = 0 AND S_MenuIsActive = 'Y' ORDER BY S_MenuOrder ASC";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['S_MenuUrl'] == '#'){
|
||||
$sql = " SELECT S_MenuID as id, S_MenuID, S_MenuUrl, S_MenuName, S_PrivilegeID, {$prm['id']} as usergroupid, IF(ISNULL(S_PrivilegeID),'N','Y') as status, 'N' as active, '' as childs
|
||||
FROM s_menu
|
||||
LEFT JOIN s_privilege ON S_PrivilegeS_MenuID = S_MenuID AND S_PrivilegeIsActive = 'Y' AND S_PrivilegeM_UserGroupID = '{$prm['id']}'
|
||||
WHERE
|
||||
S_MenuIsActive = 'Y' AND S_MenuParentS_MenuID = '{$v['id']}'
|
||||
ORDER BY S_MenuOrder ASC";
|
||||
$rows[$k]['childs'] = $this->db_onedev->query($sql)->result_array();
|
||||
if($rows[$k]['childs']){
|
||||
foreach($rows[$k]['childs'] as $kx => $vx){
|
||||
if($vx['S_MenuUrl'] == '#'){
|
||||
$sql = " SELECT S_MenuID, S_MenuUrl, S_MenuName, S_PrivilegeID, {$prm['id']} as usergroupid, IF(ISNULL(S_PrivilegeID),'N','Y') as status, 'N' as active, '' as childs
|
||||
FROM s_menu
|
||||
LEFT JOIN s_privilege ON S_PrivilegeS_MenuID = S_MenuID AND S_PrivilegeIsActive = 'Y' AND S_PrivilegeM_UserGroupID = '{$prm['id']}'
|
||||
WHERE
|
||||
S_MenuIsActive = 'Y' AND S_MenuParentS_MenuID = '{$vx['id']}'
|
||||
ORDER BY S_MenuOrder ASC";
|
||||
$rows[$k]['childs'][$kx]['childs'] = $this->db_onedev->query($sql)->result_array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
$sql = " SELECT S_MenuID, S_MenuUrl, S_MenuName, S_PrivilegeID, {$prm['id']} as usergroupid, IF(ISNULL(S_PrivilegeID),'N','Y') as status, 'N' as active, '' as childs
|
||||
FROM s_menu
|
||||
LEFT JOIN s_privilege ON S_PrivilegeS_MenuID = S_MenuID AND S_PrivilegeIsActive = 'Y' AND S_PrivilegeM_UserGroupID = '{$prm['id']}'
|
||||
WHERE
|
||||
S_MenuIsActive = 'Y' AND S_MenuID = '{$v['id']}'
|
||||
ORDER BY S_MenuOrder ASC";
|
||||
$rows[$k]['childs'] = $this->db_onedev->query($sql)->result_array();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_usergroup select");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$datas = $prm['datas'];
|
||||
foreach ($datas as $k => $v){
|
||||
foreach ($v['childs'] as $kx => $vx){
|
||||
if($vx['active'] == 'Y'){
|
||||
if(is_null($vx['S_PrivilegeID']) && $vx['status'] == 'Y'){
|
||||
$sql = "INSERT INTO s_privilege (
|
||||
S_PrivilegeM_UserGroupID,
|
||||
S_PrivilegeS_MenuID,
|
||||
S_PrivilegeCreated
|
||||
)
|
||||
VALUES(
|
||||
{$vx['usergroupid']},
|
||||
{$vx['S_MenuID']},
|
||||
NOW()
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
|
||||
if(!is_null($vx['S_PrivilegeID'])){
|
||||
$sql = "UPDATE s_privilege SET
|
||||
S_PrivilegeIsActive = '{$vx['status']}'
|
||||
WHERE
|
||||
S_PrivilegeID = '{$vx['S_PrivilegeID']}'
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
}
|
||||
if($vx['childs']){
|
||||
foreach ($vx['childs'] as $kxz => $vxz){
|
||||
if($vxz['active'] == 'Y'){
|
||||
if(is_null($vxz['S_PrivilegeID']) && $vxz['status'] == 'Y'){
|
||||
$sql = "INSERT INTO s_privilege (
|
||||
S_PrivilegeM_UserGroupID,
|
||||
S_PrivilegeS_MenuID,
|
||||
S_PrivilegeCreated
|
||||
)
|
||||
VALUES(
|
||||
{$vxz['usergroupid']},
|
||||
{$vxz['S_MenuID']},
|
||||
NOW()
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
|
||||
if(!is_null($vxz['S_PrivilegeID'])){
|
||||
$sql = "UPDATE s_privilege SET
|
||||
S_PrivilegeIsActive = '{$vxz['status']}'
|
||||
WHERE
|
||||
S_PrivilegeID = '{$vxz['S_PrivilegeID']}'
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total"=>1,"records" => array());
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
1027
one-api/application/controllers/mockup/masterdata/Requirement.php
Normal file
1027
one-api/application/controllers/mockup/masterdata/Requirement.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,344 @@
|
||||
<?php
|
||||
|
||||
class Resultflagused extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
public function index()
|
||||
{
|
||||
echo "RESULT FLAG USED API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
function searchtest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search_resulttest_name'] != '') {
|
||||
$q['search'] = "%{$prm['search_resulttest_name']}%";
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_TestID, Nat_TestName,Nat_TestCode FROM nat_test
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsQuantitative= 'N'
|
||||
AND Nat_TestIsResult = 'Y'
|
||||
AND Nat_TestName LIKE ?
|
||||
LIMIT 20;";
|
||||
$query = $this->db_regional->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_regional->last_query();
|
||||
$result = array("last_query" => $this->db_regional->last_query(), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("Test rows", $this->db_regional, array(
|
||||
"last_query" => $this->db_regional->last_query()
|
||||
));
|
||||
exit;
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchresultflag()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if (!empty($prm['search_resulttest_name'])) {
|
||||
$q['search'] = "%{$prm['search_resulttest_name']}%";
|
||||
}
|
||||
|
||||
$resultname = $prm["resultname"] ?? '';
|
||||
$resultflag = $prm["resultflag"] ?? '';
|
||||
|
||||
$number_limit = 10;
|
||||
$curr_page = max(1, (int) $prm["current_page"]);
|
||||
$number_offset = ($curr_page - 1) * $number_limit;
|
||||
|
||||
$params = [$q['search']];
|
||||
$rstflg = "";
|
||||
$rstname = "";
|
||||
|
||||
if (!empty($resultflag)) {
|
||||
$rstflg = "AND M_ResultFlagFlag = ?";
|
||||
$params[] = strtoupper($resultflag);
|
||||
}
|
||||
|
||||
if (!empty($resultname)) {
|
||||
$rstname = "AND M_ResultFlagResult LIKE ?";
|
||||
$params[] = "%{$resultname}%";
|
||||
}
|
||||
|
||||
// hitung total
|
||||
$sql_count = "SELECT COUNT(*) as total
|
||||
FROM m_resultflag
|
||||
JOIN nat_test ON M_ResultFlagNat_TestID = Nat_TestID
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND M_ResultFlagIsActive = 'Y'
|
||||
AND Nat_TestName LIKE ?
|
||||
$rstflg
|
||||
$rstname";
|
||||
|
||||
$query = $this->db_regional->query($sql_count, $params);
|
||||
$tot_count = $query ? $query->row()->total : 0;
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
|
||||
// ambil data
|
||||
$sql = "SELECT *
|
||||
FROM m_resultflag
|
||||
JOIN nat_test ON M_ResultFlagNat_TestID = Nat_TestID
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND M_ResultFlagIsActive = 'Y'
|
||||
AND Nat_TestName LIKE ?
|
||||
$rstflg
|
||||
$rstname
|
||||
LIMIT ? OFFSET ?";
|
||||
|
||||
$params_data = array_merge($params, [$number_limit, $number_offset]);
|
||||
$query = $this->db_regional->query($sql, $params_data);
|
||||
|
||||
$rows = $query ? $query->result_array() : [];
|
||||
|
||||
$result = [
|
||||
"last_query" => $this->db_regional->last_query(),
|
||||
"message" => $rows ? "Data Ditemukan" : "Data Tidak Ditemukan",
|
||||
"total" => $tot_count,
|
||||
"total_page" => $tot_page,
|
||||
"records" => $rows
|
||||
];
|
||||
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function addresultflag()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$this->db_regional->trans_begin();
|
||||
|
||||
$resulttest = $prm["nattestid"];
|
||||
$resultname = $prm["resultname"];
|
||||
$resultflag = $prm["resultflag"];
|
||||
$description = $prm["description"];
|
||||
|
||||
|
||||
$sql = "SELECT * FROM m_resultflag WHERE
|
||||
M_ResultFlagNat_TestID = ?
|
||||
AND M_ResultFlagResult = ?
|
||||
AND M_ResultFlagIsActive = 'Y';";
|
||||
$query = $this->db_regional->query($sql, [$resulttest, $resultname]);
|
||||
|
||||
$rows = $query->result_array();
|
||||
if ($rows) {
|
||||
$result = [
|
||||
"message" => "Data Sudah Pernah Dibuat",
|
||||
"last_query" => $this->db_regional->last_query(),
|
||||
];
|
||||
$data = $this->sys_ok($result);
|
||||
return $data;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO m_resultflag
|
||||
(`M_ResultFlagNat_TestID`,
|
||||
`M_ResultFlagResult`,
|
||||
`M_ResultFlagFlag`,
|
||||
`M_ResultFlagNote`,
|
||||
`M_ResultFlagIsActive`,
|
||||
`M_ResultFlagCreated`,
|
||||
`M_ResultFlagLasUpdated`,
|
||||
`M_ResultFlagCreatedUserID`
|
||||
)
|
||||
VALUES
|
||||
(?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
'Y',
|
||||
now(),
|
||||
now(),
|
||||
?);";
|
||||
$query = $this->db_regional->query($sql, [$resulttest, $resultname, $resultflag, $description, $userid]);
|
||||
|
||||
if (!$query) {
|
||||
//echo $this->db_regional->last_query();
|
||||
$this->db_regional->trans_rollback();
|
||||
$result = [
|
||||
"message" => "Data gagal disimpan",
|
||||
"last_query" => $this->db_regional->last_query(),
|
||||
];
|
||||
$this->sys_error_db( $result );
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("last_query" => $this->db_regional->last_query(), "message" => "Berhasil Insert");
|
||||
$this->db_regional->trans_commit();
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deleteresultflag()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$this->db_regional->trans_begin();
|
||||
$resultid = $prm["resultid"];
|
||||
|
||||
|
||||
$sql = "SELECT * FROM m_resultflag
|
||||
WHERE M_ResultFlagID = ?
|
||||
AND M_ResultFlagIsActive= 'Y'";
|
||||
$query = $this->db_regional->query($sql, [$resultid]);
|
||||
|
||||
$rows = $query->result_array();
|
||||
if (!$rows) {
|
||||
$data = $this->sys_ok("Tidak Ada yang Didelete");
|
||||
return $data;
|
||||
}
|
||||
|
||||
$row = $rows[0];
|
||||
|
||||
$message = [
|
||||
"Nat_ID" => $row['M_ResultFlagNat_TestID'],
|
||||
"Nama" => $row['M_ResultFlagResult'],
|
||||
"Flag" => $row['M_ResultFlagFlag']
|
||||
];
|
||||
|
||||
$sql = "UPDATE m_resultflag
|
||||
SET
|
||||
M_ResultFlagIsActive = 'N',
|
||||
M_ResultFlagLasUpdated = NOW(),
|
||||
M_ResultFlagLasUpdatedUserID = ?
|
||||
WHERE M_ResultFlagID = ?
|
||||
AND M_ResultFlagIsActive= 'Y'";
|
||||
$query = $this->db_regional->query($sql, [$userid, $resultid]);
|
||||
|
||||
if (!$query) {
|
||||
$this->db_regional->trans_rollback();
|
||||
$this->sys_error_db("Result Flag Delete | " . $this->db_regional->last_query());
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("last_query" => $this->db_regional->last_query(), "message" => "Berhasil Delete");
|
||||
|
||||
$this->db_regional->trans_commit();
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function updateresultflag()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$this->db_regional->trans_begin();
|
||||
$resultid = $prm["resultid"];
|
||||
$resulttest = $prm["nattestid"];
|
||||
$resultname = $prm["resultname"];
|
||||
$resultflag = $prm["resultflag"];
|
||||
|
||||
|
||||
$sql = "SELECT * FROM m_resultflag
|
||||
WHERE M_ResultFlagID = ?
|
||||
AND M_ResultFlagIsActive= 'Y'";
|
||||
$query = $this->db_regional->query($sql, [$resultid]);
|
||||
|
||||
$rows = $query->result_array();
|
||||
if (!$rows) {
|
||||
$data = $this->sys_ok("Tidak Ada yang Didelete");
|
||||
return $data;
|
||||
}
|
||||
|
||||
$row = $rows[0];
|
||||
|
||||
$message = [
|
||||
"Nat_ID" => $row['M_ResultFlagNat_TestID'],
|
||||
"Nama" => $row['M_ResultFlagResult'],
|
||||
"Flag" => $row['M_ResultFlagFlag']
|
||||
];
|
||||
|
||||
$sql = "UPDATE m_resultflag
|
||||
SET
|
||||
M_ResultFlagNat_TestID = ?,
|
||||
M_ResultFlagResult = ?,
|
||||
M_ResultFlagFlag = ?,
|
||||
M_ResultFlagLasUpdated = NOW()
|
||||
WHERE M_ResultFlagID = ?
|
||||
AND M_ResultFlagIsActive= 'Y'";
|
||||
$query = $this->db_regional->query($sql, [$resulttest,$resultname,$resultflag,$resultid]);
|
||||
|
||||
if (!$query) {
|
||||
$this->db_regional->trans_rollback();
|
||||
$result = [
|
||||
"message" => "Data Gagal Diupdate",
|
||||
"last_query" => $this->db_regional->last_query(),
|
||||
];
|
||||
$this->sys_error_db($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array("last_query" => $this->db_regional->last_query(), "message" => "Berhasil Update");
|
||||
|
||||
$this->db_regional->trans_commit();
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
818
one-api/application/controllers/mockup/masterdata/Schedule.php
Normal file
818
one-api/application/controllers/mockup/masterdata/Schedule.php
Normal file
@@ -0,0 +1,818 @@
|
||||
<?php
|
||||
|
||||
class Schedule extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SCHEDULE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookuptest(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select M_ScheduleTestID as id, T_TestShortName as name, M_ScheduleTestT_TestID as testid
|
||||
from m_scheduletest
|
||||
JOIN t_test ON M_ScheduleTestT_TestID = T_TestID AND T_TestIsActive = 'Y'
|
||||
where
|
||||
M_ScheduleTestM_ScheduleID = {$id} AND M_ScheduleTestIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("m_scheduletest select by schedule");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function lookuppromise(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select M_SchedulePromiseID as id,
|
||||
M_SchedulePromiseDayOfWeek as dayofweek, 'xxx' as dayofweekname,
|
||||
M_SchedulePromiseStartHourMinute as start_hm,
|
||||
M_SchedulePromiseEndHourMinute as end_hm,
|
||||
M_SchedulePromiseDay as xday,
|
||||
M_SchedulePromiseHour as xhour,
|
||||
M_SchedulePromiseMin as xmin,
|
||||
M_SchedulePromiseAtTime as at_time,
|
||||
M_SchedulePromiseFlagAtTime as flagattime,
|
||||
'xxx' as action
|
||||
from m_schedulepromise
|
||||
where
|
||||
M_SchedulePromiseM_ScheduleID = {$id} AND M_SchedulePromiseIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k=>$v){
|
||||
if(intval($v['dayofweek']) == 1){
|
||||
$rows[$k]['dayofweekname'] = 'Minggu';
|
||||
}elseif(intval($v['dayofweek']) == 2){
|
||||
$rows[$k]['dayofweekname'] = 'Senin';
|
||||
}elseif(intval($v['dayofweek']) == 3){
|
||||
$rows[$k]['dayofweekname'] = 'Selasa';
|
||||
}elseif(intval($v['dayofweek']) == 4){
|
||||
$rows[$k]['dayofweekname'] = 'Rabu';
|
||||
}elseif(intval($v['dayofweek']) == 5){
|
||||
$rows[$k]['dayofweekname'] = 'Kamis';
|
||||
}elseif(intval($v['dayofweek']) == 6){
|
||||
$rows[$k]['dayofweekname'] = 'Jumat';
|
||||
}elseif(intval($v['dayofweek']) == 7){
|
||||
$rows[$k]['dayofweekname'] = 'Sabtu';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_scheduletestpromise select by schedule");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function lookuppreschedulepromise(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select M_PreSchedulePromiseID as id,
|
||||
M_PreSchedulePromiseDayOfWeek as dayofweek, 'xxx' as dayofweekname,
|
||||
M_PreSchedulePromiseHour as xhour,
|
||||
'xxx' as action
|
||||
from m_preschedulepromise
|
||||
where
|
||||
M_PreSchedulePromiseM_ScheduleID = {$id} AND M_PreSchedulePromiseIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k=>$v){
|
||||
if(intval($v['dayofweek']) == 1){
|
||||
$rows[$k]['dayofweekname'] = 'Minggu';
|
||||
}elseif(intval($v['dayofweek']) == 2){
|
||||
$rows[$k]['dayofweekname'] = 'Senin';
|
||||
}elseif(intval($v['dayofweek']) == 3){
|
||||
$rows[$k]['dayofweekname'] = 'Selasa';
|
||||
}elseif(intval($v['dayofweek']) == 4){
|
||||
$rows[$k]['dayofweekname'] = 'Rabu';
|
||||
}elseif(intval($v['dayofweek']) == 5){
|
||||
$rows[$k]['dayofweekname'] = 'Kamis';
|
||||
}elseif(intval($v['dayofweek']) == 6){
|
||||
$rows[$k]['dayofweekname'] = 'Jumat';
|
||||
}elseif(intval($v['dayofweek']) == 7){
|
||||
$rows[$k]['dayofweekname'] = 'Sabtu';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_preschedulepromise select by schedule");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from m_schedule
|
||||
where
|
||||
M_ScheduleIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select M_ScheduleID as id, M_ScheduleName as name,
|
||||
M_ScheduleFlagPreSchedule as flagpreschedule,
|
||||
M_SchedulePreScheduleMaxHour as preschedulemaxhour,
|
||||
M_ScheduleName as detail,
|
||||
IF(M_ScheduleFlagPreSchedule = 'Y', 'Pre Schedule', ' - ') as ispreschedule,
|
||||
'xxx' as scheduletests, 'xxx' as schedulepromise, 'xxx' as preschedulepromise
|
||||
from m_schedule
|
||||
where
|
||||
M_ScheduleName LIKE CONCAT('%',?,'%') AND
|
||||
M_ScheduleIsActive = 'Y' $limit";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("m_schedule select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_schedule = $prm['name'];
|
||||
$flagpreschedule = $prm['flagpreschedule'];
|
||||
$preschedulemaxhour = $prm['preschedulemaxhour'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_schedule WHERE M_ScheduleIsActive = 'Y' AND M_ScheduleName = '{$name_schedule}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into m_schedule(
|
||||
M_ScheduleName,
|
||||
M_ScheduleFlagPreSchedule,
|
||||
M_SchedulePreScheduleMaxHour,
|
||||
M_ScheduleCreated,
|
||||
M_ScheduleLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_schedule,
|
||||
$flagpreschedule,
|
||||
$preschedulemaxhour
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_schedule = $prm['id'];
|
||||
$name_schedule = $prm['name'];
|
||||
$flagpreschedule = $prm['flagpreschedule'];
|
||||
$preschedulemaxhour = $prm['preschedulemaxhour'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_schedule WHERE M_ScheduleIsActive = 'Y' AND M_ScheduleName = '{$name_schedule}' AND M_ScheduleID <> {$id_schedule}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "update m_schedule SET
|
||||
M_ScheduleName = ?,
|
||||
M_ScheduleFlagPreSchedule = ?,
|
||||
M_SchedulePreScheduleMaxHour = ?,
|
||||
M_ScheduleLastUpdated = now()
|
||||
where
|
||||
M_ScheduleID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_schedule,
|
||||
$flagpreschedule,
|
||||
$preschedulemaxhour,
|
||||
$id_schedule
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_schedule));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewscheduletest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$scheduleid = $prm['scheduleid'];
|
||||
$testid = $prm['testid'];
|
||||
|
||||
$sql = "insert into m_scheduletest(
|
||||
M_ScheduleTestM_ScheduleID,
|
||||
M_ScheduleTestT_TestID,
|
||||
M_ScheduleTestCreated,
|
||||
M_ScheduleTestLastUpdated
|
||||
)
|
||||
values( ?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$scheduleid,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_scheduletest insert");
|
||||
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 addnewschedulepromise()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$sql = "insert into m_schedulepromise(
|
||||
M_SchedulePromiseM_ScheduleID,
|
||||
M_SchedulePromiseDayOfWeek,
|
||||
M_SchedulePromiseStartHourMinute,
|
||||
M_SchedulePromiseEndHourMinute,
|
||||
M_SchedulePromiseDay,
|
||||
M_SchedulePromiseHour,
|
||||
M_SchedulePromiseMin,
|
||||
M_SchedulePromiseAtTime,
|
||||
M_SchedulePromiseFlagAtTime,
|
||||
M_SchedulePromiseCreated,
|
||||
M_SchedulePromiseLastUpdate
|
||||
)
|
||||
values( ?,?,?,?,?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['scheduleid'],
|
||||
$prm['dayofweek'],
|
||||
$prm['starthm'],
|
||||
$prm['endhm'],
|
||||
$prm['xday'],
|
||||
$prm['xhour'],
|
||||
$prm['xminute'],
|
||||
$prm['attime'],
|
||||
$prm['flagattime']
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$sql = "update m_schedulepromise SET
|
||||
M_SchedulePromiseDayOfWeek = ?,
|
||||
M_SchedulePromiseStartHourMinute = ?,
|
||||
M_SchedulePromiseEndHourMinute = ?,
|
||||
M_SchedulePromiseDay = ?,
|
||||
M_SchedulePromiseHour = ?,
|
||||
M_SchedulePromiseMin = ?,
|
||||
M_SchedulePromiseAtTime = ?,
|
||||
M_SchedulePromiseFlagAtTime = ?,
|
||||
M_SchedulePromiseLastUpdate = now()
|
||||
WHERE
|
||||
M_SchedulePromiseID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['dayofweek'],
|
||||
$prm['starthm'],
|
||||
$prm['endhm'],
|
||||
$prm['xday'],
|
||||
$prm['xhour'],
|
||||
$prm['xminute'],
|
||||
$prm['attime'],
|
||||
$prm['flagattime'],
|
||||
$prm['xid']
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise update");
|
||||
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 deleteschedulepromise()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_schedulepromise SET
|
||||
M_SchedulePromiseIsActive = 'N',
|
||||
M_SchedulePromiseLastUpdate = now()
|
||||
WHERE
|
||||
M_SchedulePromiseID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise 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 addnewpreschedulepromise()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$dayofweek = $prm['dayofweek'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_preschedulepromise WHERE M_PreSchedulePromiseIsActive = 'Y' AND M_PreSchedulePromiseDayOfWeek = '{$dayofweek}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into m_preschedulepromise(
|
||||
M_PreSchedulePromiseM_ScheduleID,
|
||||
M_PreSchedulePromiseDayOfWeek,
|
||||
M_PreSchedulePromiseHour,
|
||||
M_PreSchedulePromiseCreated,
|
||||
M_PreSchedulePromiseLastUpdated
|
||||
)
|
||||
values( ?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['scheduleid'],
|
||||
$prm['dayofweek'],
|
||||
$prm['xhour']
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_preschedulepromise insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$idx = $prm['xid'];
|
||||
$dayofweek = $prm['dayofweek'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_preschedulepromise WHERE M_PreSchedulePromiseIsActive = 'Y' AND M_PreSchedulePromiseDayOfWeek = '{$dayofweek}' AND M_PreSchedulePromiseID <> {$idx}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
if($exist_name == 0){
|
||||
$sql = "update m_preschedulepromise SET
|
||||
M_PreSchedulePromiseDayOfWeek = ?,
|
||||
M_PreSchedulePromiseHour = ?,
|
||||
M_PreSchedulePromiseLastUpdated = now()
|
||||
WHERE
|
||||
M_PreSchedulePromiseID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['dayofweek'],
|
||||
$prm['xhour'],
|
||||
$prm['xid']
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_preschedulepromise update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else {
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deletepreschedulepromise()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_preschedulepromise SET
|
||||
M_PreSchedulePromiseIsActive = 'N',
|
||||
M_PreSchedulePromiseLastUpdated = now()
|
||||
WHERE
|
||||
M_PreSchedulePromiseID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_preschedulepromise 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 deletescheduletest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_scheduletest SET
|
||||
M_ScheduleTestIsActive = 'N',
|
||||
M_ScheduleTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleTestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_scheduletest 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 deleteschedule()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_schedule SET
|
||||
M_ScheduleIsActive = 'N',
|
||||
M_ScheduleLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedule delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_scheduletest SET
|
||||
M_ScheduleTestIsActive = 'N',
|
||||
M_ScheduleTestLastUpdated = now()
|
||||
WHERE
|
||||
M_ScheduleTestM_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_scheduletest delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update m_schedulepromise SET
|
||||
M_SchedulePromiseIsActive = 'N',
|
||||
M_SchedulePromiseLastUpdate = now()
|
||||
WHERE
|
||||
M_SchedulePromiseM_ScheduleID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_schedulepromise 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 searchtest()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$scheduleid = $prm['id'];
|
||||
$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
|
||||
LEFT JOIN m_scheduletest ON M_ScheduleTestT_TestID = T_TestID AND M_ScheduleTestM_ScheduleID = ? AND M_ScheduleTestIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(M_ScheduleTestID) AND
|
||||
|
||||
T_TestIsActive = 'Y'
|
||||
AND T_TestName like ?";
|
||||
$query = $this->db_onedev->query($sql,array($scheduleid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_test count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_TestID as id,
|
||||
T_TestName as name
|
||||
FROM t_test
|
||||
LEFT JOIN m_scheduletest ON M_ScheduleTestT_TestID = T_TestID AND M_ScheduleTestM_ScheduleID = ? AND M_ScheduleTestIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(M_ScheduleTestID) AND
|
||||
T_TestIsActive = 'Y'
|
||||
AND T_TestName like ?
|
||||
ORDER BY T_TestCode ASC
|
||||
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($scheduleid,$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
1029
one-api/application/controllers/mockup/masterdata/Schedulenew.php
Normal file
1029
one-api/application/controllers/mockup/masterdata/Schedulenew.php
Normal file
File diff suppressed because it is too large
Load Diff
756
one-api/application/controllers/mockup/masterdata/Sodoctor.php
Normal file
756
one-api/application/controllers/mockup/masterdata/Sodoctor.php
Normal file
@@ -0,0 +1,756 @@
|
||||
<?php
|
||||
|
||||
class Sodoctor extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SODOCTOR API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookupsodoctor(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select M_DoctorSONat_SubGroupID as id,
|
||||
M_DoctorSOM_DoctorID as doctorid,
|
||||
M_DoctorSONat_SubGroupID as subgroupid,
|
||||
M_DoctorID,
|
||||
CONCAT(Nat_SubGroupName,' ' ,'[ ',Nat_SubGroupCode,' ]') as description,
|
||||
CONCAT(Nat_SubGroupName,' ' ,'[ ',Nat_SubGroupCode,' ]') as Nat_SubGroupNames,
|
||||
M_DoctorName,
|
||||
CONCAT(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) as M_DoctorNames,
|
||||
Nat_SubGroupID,
|
||||
'xxx' as action
|
||||
from m_doctorso
|
||||
JOIN m_doctor ON M_DoctorSOM_DoctorID = M_DoctorID
|
||||
JOIN nat_subgroup ON M_DoctorSONat_SubGroupID = Nat_SubGroupID
|
||||
where
|
||||
M_DoctorSONat_SubGroupID = {$id} AND M_DoctorSOIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = 'LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_subgroup
|
||||
where
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID IN(2,3)";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "SELECT * FROM (select Nat_SubGroupID as id, Nat_SubGroupName as name,
|
||||
CONCAT(Nat_SubGroupName,' ' ,'[ ',Nat_SubGroupCode,' ]') as description
|
||||
from nat_subgroup
|
||||
WHERE Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID IN(2,3)) a
|
||||
where
|
||||
( description LIKE CONCAT('%','{$search}','%')
|
||||
)
|
||||
ORDER BY id ASC $limit";
|
||||
$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("nat_subgroup select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewdoctor()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_doctor = $prm['name'];
|
||||
$address_doctor = $prm['address'];
|
||||
$phone_doctor = $prm['phone'];
|
||||
$email_doctor = $prm['email'];
|
||||
$pic_doctor = $prm['pic'];
|
||||
$doctortypenew_doctor = $prm['doctortypenew'];
|
||||
$doctortype_doctor = $prm['doctortype'];
|
||||
$islabfrom = $prm['islabfrom'];
|
||||
$islabto = $prm['islabto'];
|
||||
$city = $prm['city'];
|
||||
$district = $prm['district'];
|
||||
$kelurahan = $prm['kelurahan'];
|
||||
$doctormindp = $prm['doctormindp'];
|
||||
$doctor = $prm['doctor'];
|
||||
|
||||
if($doctortypenew_doctor != ''){
|
||||
$sql = "insert into m_doctortype(
|
||||
M_DoctorTypeName,
|
||||
M_DoctorTypeCreated,
|
||||
M_DoctorTypeLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$doctortypenew_doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctortype insert");
|
||||
exit;
|
||||
}
|
||||
$doctortypenewid = $this->db_onedev->insert_id();
|
||||
$sqldoctor = "insert into m_doctor(
|
||||
M_DoctorName,
|
||||
M_DoctorNat_CityID,
|
||||
M_DoctorNat_DistrictID,
|
||||
M_DoctorNat_KelurahanID,
|
||||
M_DoctorAddress,
|
||||
M_DoctorPhone,
|
||||
M_DoctorEmail,
|
||||
M_DoctorPIC,
|
||||
M_DoctorM_DoctorTypeID,
|
||||
M_DoctorIsLabFrom,
|
||||
M_DoctorIsLabTo,
|
||||
M_DoctorMinDP,
|
||||
M_DoctorNat_DoctorID,
|
||||
M_DoctorCreated,
|
||||
M_DoctorLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now())";
|
||||
$querydoctor = $this->db_onedev->query($sqldoctor,
|
||||
array(
|
||||
$name_doctor,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_doctor,
|
||||
$phone_doctor,
|
||||
$email_doctor,
|
||||
$pic_doctor,
|
||||
$doctortypenewid,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$doctormindp,
|
||||
$doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$querydoctor) {
|
||||
$this->sys_error_db("m_doctor insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else{
|
||||
$sql = "insert into m_doctor(
|
||||
M_DoctorName,
|
||||
M_DoctorNat_CityID,
|
||||
M_DoctorNat_DistrictID,
|
||||
M_DoctorNat_KelurahanID,
|
||||
M_DoctorAddress,
|
||||
M_DoctorPhone,
|
||||
M_DoctorEmail,
|
||||
M_DoctorPIC,
|
||||
M_DoctorM_DoctorTypeID,
|
||||
M_DoctorIsLabFrom,
|
||||
M_DoctorIsLabTo,
|
||||
M_DoctorMinDP,
|
||||
M_DoctorNat_DoctorID,
|
||||
M_DoctorCreated,
|
||||
M_DoctorLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_doctor,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_doctor,
|
||||
$phone_doctor,
|
||||
$email_doctor,
|
||||
$pic_doctor,
|
||||
$doctortype_doctor,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$doctormindp,
|
||||
$doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctor insert");
|
||||
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 editdoctor()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_doctor = $prm['id'];
|
||||
$name_doctor = $prm['name'];
|
||||
$address_doctor = $prm['address'];
|
||||
$phone_doctor = $prm['phone'];
|
||||
$email_doctor = $prm['email'];
|
||||
$pic_doctor = $prm['pic'];
|
||||
$doctortypenew_doctor = $prm['doctortypenew'];
|
||||
$doctortype_doctor = $prm['doctortype'];
|
||||
$islabfrom = $prm['islabfrom'];
|
||||
$islabto = $prm['islabto'];
|
||||
$city = $prm['city'];
|
||||
$district = $prm['district'];
|
||||
$kelurahan = $prm['kelurahan'];
|
||||
$doctormindp = $prm['doctormindp'];
|
||||
$doctor = $prm['doctor'];
|
||||
|
||||
if($doctortypenew_doctor != ''){
|
||||
$sql = "insert into m_doctortype(
|
||||
M_DoctorTypeName,
|
||||
M_DoctorTypeCreated,
|
||||
M_DoctorTypeLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$doctortypenew_doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctortype insert");
|
||||
exit;
|
||||
}
|
||||
$doctortypenewid = $this->db_onedev->insert_id();
|
||||
$sqldoctor = "update m_doctor SET
|
||||
M_DoctorName = ?,
|
||||
M_DoctorNat_CityID = ?,
|
||||
M_DoctorNat_DistrictID = ?,
|
||||
M_DoctorNat_KelurahanID = ?,
|
||||
M_DoctorAddress = ?,
|
||||
M_DoctorPhone = ?,
|
||||
M_DoctorEmail = ?,
|
||||
M_DoctorPIC = ?,
|
||||
M_DoctorM_DoctorTypeID = ?,
|
||||
M_DoctorIsLabFrom = ?,
|
||||
M_DoctorIsLabTo = ?,
|
||||
M_DoctorMinDP = ?,
|
||||
M_DoctorNat_DoctorID = ?,
|
||||
M_DoctorLastUpdated = now()
|
||||
where
|
||||
M_DoctorID = ?
|
||||
";
|
||||
$querydoctor = $this->db_onedev->query($sqldoctor,
|
||||
array(
|
||||
$name_doctor,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_doctor,
|
||||
$phone_doctor,
|
||||
$email_doctor,
|
||||
$pic_doctor,
|
||||
$doctortypenewid,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$doctormindp,
|
||||
$doctor,
|
||||
$id_doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$querydoctor) {
|
||||
$this->sys_error_db("m_doctor update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_doctor));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "update m_doctor SET
|
||||
M_DoctorName = ?,
|
||||
M_DoctorNat_CityID = ?,
|
||||
M_DoctorNat_DistrictID = ?,
|
||||
M_DoctorNat_KelurahanID = ?,
|
||||
M_DoctorAddress = ?,
|
||||
M_DoctorPhone = ?,
|
||||
M_DoctorEmail = ?,
|
||||
M_DoctorPIC = ?,
|
||||
M_DoctorM_DoctorTypeID = ?,
|
||||
M_DoctorIsLabFrom = ?,
|
||||
M_DoctorIsLabTo = ?,
|
||||
M_DoctorMinDP = ?,
|
||||
M_DoctorNat_DoctorID = ?,
|
||||
M_DoctorLastUpdated = now()
|
||||
where
|
||||
M_DoctorID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_doctor,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_doctor,
|
||||
$phone_doctor,
|
||||
$email_doctor,
|
||||
$pic_doctor,
|
||||
$doctortype_doctor,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$doctormindp,
|
||||
$doctor,
|
||||
$id_doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctor update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_doctor));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewsodoctor()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$doctorid = $prm['mdoctorid'];
|
||||
$subgroupid = $prm['subgrupid'];
|
||||
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$sql = "insert into m_doctorso(
|
||||
M_DoctorSOM_DoctorID,
|
||||
M_DoctorSONat_SubGroupID,
|
||||
M_DoctorSOCreated,
|
||||
M_DoctorSOLastUpdated
|
||||
)
|
||||
values( ?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$doctorid,
|
||||
$subgroupid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctorso insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}else{
|
||||
$doctorid = $prm['mdoctorid'];
|
||||
$sql = "UPDATE m_doctorso SET M_DoctorSOM_DoctorID = '{$doctorid}' WHERE M_DoctorSOID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deletesodoctor()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_doctorso SET
|
||||
M_DoctorSOIsActive = 'N',
|
||||
M_DoctorSOLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorSOID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctorso 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 deletedoctor()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update m_doctor SET
|
||||
M_DoctorIsActive = 'N',
|
||||
M_DoctorLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctor delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE m_doctorso SET
|
||||
M_DoctorSOIsActive = 'N',
|
||||
M_DoctorSOLastUpdated = now()
|
||||
WHERE
|
||||
M_DoctorSOM_DoctorID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_doctorso 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 selectdoctortype(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_doctortype
|
||||
WHERE
|
||||
M_DoctorTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['doctortypes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function selectdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_doctor
|
||||
WHERE
|
||||
Nat_DoctorIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['doctors'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function searchmdoctor(){
|
||||
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 m_doctor
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
AND M_DoctorIsActive = '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("m_doctor count",$this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(M_DoctorPrefix,' ',M_DoctorName,' ',M_DoctorSufix) as M_DoctorNames
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorNames like ?
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
ORDER BY M_DoctorNames 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("m_doctor rows",$this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcity(){
|
||||
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_city
|
||||
WHERE
|
||||
Nat_CityName like ?
|
||||
AND Nat_CityIsActive = '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_city count",$this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM nat_city
|
||||
WHERE
|
||||
Nat_CityName like ?
|
||||
AND Nat_CityIsActive = 'Y'
|
||||
ORDER BY Nat_CityName DESC
|
||||
";
|
||||
$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_city rows",$this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getdistrict(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_district
|
||||
WHERE
|
||||
Nat_DistrictIsActive = 'Y' AND Nat_DistrictNat_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_kelurahan
|
||||
WHERE
|
||||
Nat_KelurahanIsActive = 'Y' AND Nat_KelurahanNat_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
614
one-api/application/controllers/mockup/masterdata/Sotemplate.php
Normal file
614
one-api/application/controllers/mockup/masterdata/Sotemplate.php
Normal file
@@ -0,0 +1,614 @@
|
||||
<?php
|
||||
|
||||
class Sotemplate extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SO TEMPLATE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookuptest(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select So_TestTemplateID as id, T_TestShortName as name, So_TestTemplateT_TestID as testid
|
||||
from so_testtemplate
|
||||
JOIN t_test ON So_TestTemplateT_TestID = T_TestID AND T_TestIsActive = 'Y'
|
||||
where
|
||||
So_TestTemplateSo_TemplateID = {$id} AND So_TestTemplateIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("so_testtemplate select by sotemplate");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function lookupdetail(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select So_TemplateDetailID as id,
|
||||
So_TemplateDetailSo_TemplateID as sotemplateid,
|
||||
So_TemplateDetailM_LangID,
|
||||
M_LangID,
|
||||
M_LangName,
|
||||
So_TemplateDetailName as name,
|
||||
'xxx' as action
|
||||
from so_templatedetail
|
||||
JOIN m_lang ON So_TemplateDetailM_LangID = M_LangID
|
||||
where
|
||||
So_TemplateDetailSo_TemplateID = {$id} AND So_TemplateDetailIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("so_testtemplatedetail select by sotemplate");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from so_template
|
||||
where
|
||||
So_TemplateIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select So_TemplateID as id, So_TemplateName as name,
|
||||
So_TemplateName as detail,
|
||||
'xxx' as sotemplatetests, 'xxx' as sotemplatedetail
|
||||
from so_template
|
||||
where
|
||||
So_TemplateName LIKE CONCAT('%',?,'%') AND
|
||||
So_TemplateIsActive = 'Y' $limit";
|
||||
$sql_param = array($search);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("so_template select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewsotemplate()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_sotemplate = $prm['name'];
|
||||
$query = "SELECT COUNT(*) as exist FROM so_template WHERE So_TemplateIsActive = 'Y' AND So_TemplateName = '{$name_sotemplate}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into so_template(
|
||||
So_TemplateName,
|
||||
So_TemplateCreated,
|
||||
So_TemplateLastUpdated
|
||||
)
|
||||
values( ?, now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_sotemplate
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_template insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editsotemplate()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_sotemplate = $prm['id'];
|
||||
$name_sotemplate = $prm['name'];
|
||||
$query = "SELECT COUNT(*) as exist FROM so_template WHERE So_TemplateIsActive = 'Y' AND So_TemplateName = '{$name_sotemplate}' AND So_TemplateID <> {$id_sotemplate}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "update so_template SET
|
||||
So_TemplateName = ?,
|
||||
So_TemplateLastUpdated = now()
|
||||
where
|
||||
So_TemplateID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_sotemplate,
|
||||
$id_sotemplate
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_template update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_sotemplate));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$result = array ("total" => -1, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewsotemplatetest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$sotemplateid = $prm['sotemplateid'];
|
||||
$testid = $prm['testid'];
|
||||
|
||||
$sql = "insert into so_testtemplate(
|
||||
So_TestTemplateSo_TemplateID,
|
||||
So_TestTemplateT_TestID,
|
||||
So_TestTemplateCreated,
|
||||
So_TestTemplateLastUpdated
|
||||
)
|
||||
values( ?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$sotemplateid,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_testtemplate insert");
|
||||
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 addnewsotemplatedetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$sql = "insert into so_templatedetail(
|
||||
So_TemplateDetailSo_TemplateID,
|
||||
So_TemplateDetailM_LangID,
|
||||
So_TemplateDetailName,
|
||||
So_TemplateDetailCreated,
|
||||
So_TemplateDetailLastUpdate
|
||||
)
|
||||
values( ?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['sotemplateid'],
|
||||
$prm['langid'],
|
||||
$prm['name']
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_templatedetail insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$sql = "update so_templatedetail SET
|
||||
So_TemplateDetailM_LangID = ?,
|
||||
So_TemplateDetailName = ?,
|
||||
So_TemplateDetailLastUpdate = now()
|
||||
WHERE
|
||||
So_TemplateDetailID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['langid'],
|
||||
$prm['name'],
|
||||
$prm['xid']
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_templatedetail update");
|
||||
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 deletesotemplatedetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update so_templatedetail SET
|
||||
So_TemplateDetailIsActive = 'N',
|
||||
So_TemplateDetailLastUpdate = now()
|
||||
WHERE
|
||||
So_TemplateDetailID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_templatedetail 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 deletesotemplatetest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update so_testtemplate SET
|
||||
So_TestTemplateIsActive = 'N',
|
||||
So_TestTemplateLastUpdated = now()
|
||||
WHERE
|
||||
So_TestTemplateID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_testtemplate 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 deletesotemplate()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update so_template SET
|
||||
So_TemplateIsActive = 'N',
|
||||
So_TemplateLastUpdated = now()
|
||||
WHERE
|
||||
So_TemplateID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_template delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update so_testtemplate SET
|
||||
So_TestTemplateIsActive = 'N',
|
||||
So_TestTemplateLastUpdated = now()
|
||||
WHERE
|
||||
So_TestTemplateSo_TemplateID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_testtemplate delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "update so_templatedetail SET
|
||||
So_TemplateDetailIsActive = 'N',
|
||||
So_TemplateDetailLastUpdate = now()
|
||||
WHERE
|
||||
So_TemplateDetailSo_TemplateID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("so_templatedetail 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 searchtest()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$sotemplateid = $prm['id'];
|
||||
$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
|
||||
LEFT JOIN so_testtemplate ON So_TestTemplateT_TestID = T_TestID AND So_TestTemplateSo_TemplateID = ? AND So_TestTemplateIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(So_TestTemplateID) AND
|
||||
|
||||
T_TestIsActive = 'Y'
|
||||
AND T_TestName like ?";
|
||||
$query = $this->db_onedev->query($sql,array($sotemplateid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_test count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_TestID as id,
|
||||
T_TestName as name
|
||||
FROM t_test
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID AND Nat_TestNat_GroupID IN (2,3,4)
|
||||
LEFT JOIN so_testtemplate ON So_TestTemplateT_TestID = T_TestID AND So_TestTemplateSo_TemplateID = ? AND So_TestTemplateIsActive = 'Y'
|
||||
WHERE
|
||||
ISNULL(So_TestTemplateID) AND
|
||||
T_TestIsActive = 'Y'
|
||||
AND T_TestName like ?
|
||||
ORDER BY T_TestCode ASC
|
||||
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($sotemplateid,$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;
|
||||
}
|
||||
}
|
||||
function selectlang(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_lang
|
||||
WHERE
|
||||
M_LangIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['langs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,754 @@
|
||||
<?php
|
||||
|
||||
class Specimenlocal extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SPECIMENLOCAL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookupspecimenlocal(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select T_SpecimenLocalID as id,
|
||||
T_SpecimenLocalNat_TestID as testid,
|
||||
T_SpecimenLocalT_SampleTypeID as sampletypeid,
|
||||
Nat_TestID,
|
||||
CONCAT(T_SampleTypeName,' ' ,'[ ',T_SampleTypeCode,' ]') as description,
|
||||
CONCAT(T_SampleTypeName,' ' ,'[ ',T_SampleTypeCode,' ]') as Nat_TestNames,
|
||||
'xxx' as action
|
||||
from t_specimenlocal
|
||||
JOIN nat_test ON T_SpecimenLocalNat_TestID = Nat_TestID
|
||||
JOIN t_sampletype ON T_SpecimenLocalT_SampleTypeID = T_SampleTypeID
|
||||
where
|
||||
T_SpecimenLocalNat_TestID = {$id} AND T_SpecimenLocalIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = 'ORDER BY Nat_TestCode ASC LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
where
|
||||
Nat_TestIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select Nat_TestID as id, Nat_TestName as name,
|
||||
Nat_SampleTypeName as samplename,
|
||||
CONCAT(Nat_TestName,' ' ,'[ ',Nat_TestCode,' ]') as description
|
||||
from nat_test
|
||||
LEFT JOIN nat_sampletype ON Nat_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
where
|
||||
( Nat_TestName LIKE CONCAT('%','{$search}','%')
|
||||
)AND
|
||||
Nat_TestIsActive = 'Y' $limit";
|
||||
$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("nat_test select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewtest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_test = $prm['name'];
|
||||
$address_test = $prm['address'];
|
||||
$phone_test = $prm['phone'];
|
||||
$email_test = $prm['email'];
|
||||
$pic_test = $prm['pic'];
|
||||
$testtypenew_test = $prm['testtypenew'];
|
||||
$testtype_test = $prm['testtype'];
|
||||
$islabfrom = $prm['islabfrom'];
|
||||
$islabto = $prm['islabto'];
|
||||
$city = $prm['city'];
|
||||
$district = $prm['district'];
|
||||
$kelurahan = $prm['kelurahan'];
|
||||
$testmindp = $prm['testmindp'];
|
||||
$doctor = $prm['doctor'];
|
||||
|
||||
if($testtypenew_test != ''){
|
||||
$sql = "insert into nat_testtype(
|
||||
Nat_TestTypeName,
|
||||
Nat_TestTypeCreated,
|
||||
Nat_TestTypeLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testtypenew_test
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_testtype insert");
|
||||
exit;
|
||||
}
|
||||
$testtypenewid = $this->db_onedev->insert_id();
|
||||
$sqltest = "insert into nat_test(
|
||||
Nat_TestName,
|
||||
Nat_TestNat_CityID,
|
||||
Nat_TestNat_DistrictID,
|
||||
Nat_TestNat_KelurahanID,
|
||||
Nat_TestAddress,
|
||||
Nat_TestPhone,
|
||||
Nat_TestEmail,
|
||||
Nat_TestPIC,
|
||||
Nat_TestNat_TestTypeID,
|
||||
Nat_TestIsLabFrom,
|
||||
Nat_TestIsLabTo,
|
||||
Nat_TestMinDP,
|
||||
Nat_TestNat_DoctorID,
|
||||
Nat_TestCreated,
|
||||
Nat_TestLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now())";
|
||||
$querytest = $this->db_onedev->query($sqltest,
|
||||
array(
|
||||
$name_test,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_test,
|
||||
$phone_test,
|
||||
$email_test,
|
||||
$pic_test,
|
||||
$testtypenewid,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$testmindp,
|
||||
$doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$querytest) {
|
||||
$this->sys_error_db("nat_test insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else{
|
||||
$sql = "insert into nat_test(
|
||||
Nat_TestName,
|
||||
Nat_TestNat_CityID,
|
||||
Nat_TestNat_DistrictID,
|
||||
Nat_TestNat_KelurahanID,
|
||||
Nat_TestAddress,
|
||||
Nat_TestPhone,
|
||||
Nat_TestEmail,
|
||||
Nat_TestPIC,
|
||||
Nat_TestNat_TestTypeID,
|
||||
Nat_TestIsLabFrom,
|
||||
Nat_TestIsLabTo,
|
||||
Nat_TestMinDP,
|
||||
Nat_TestNat_DoctorID,
|
||||
Nat_TestCreated,
|
||||
Nat_TestLastUpdated
|
||||
)
|
||||
values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_test,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_test,
|
||||
$phone_test,
|
||||
$email_test,
|
||||
$pic_test,
|
||||
$testtype_test,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$testmindp,
|
||||
$doctor
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_test insert");
|
||||
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 edittest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_test = $prm['id'];
|
||||
$name_test = $prm['name'];
|
||||
$address_test = $prm['address'];
|
||||
$phone_test = $prm['phone'];
|
||||
$email_test = $prm['email'];
|
||||
$pic_test = $prm['pic'];
|
||||
$testtypenew_test = $prm['testtypenew'];
|
||||
$testtype_test = $prm['testtype'];
|
||||
$islabfrom = $prm['islabfrom'];
|
||||
$islabto = $prm['islabto'];
|
||||
$city = $prm['city'];
|
||||
$district = $prm['district'];
|
||||
$kelurahan = $prm['kelurahan'];
|
||||
$testmindp = $prm['testmindp'];
|
||||
$doctor = $prm['doctor'];
|
||||
|
||||
if($testtypenew_test != ''){
|
||||
$sql = "insert into nat_testtype(
|
||||
Nat_TestTypeName,
|
||||
Nat_TestTypeCreated,
|
||||
Nat_TestTypeLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testtypenew_test
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_testtype insert");
|
||||
exit;
|
||||
}
|
||||
$testtypenewid = $this->db_onedev->insert_id();
|
||||
$sqltest = "update nat_test SET
|
||||
Nat_TestName = ?,
|
||||
Nat_TestNat_CityID = ?,
|
||||
Nat_TestNat_DistrictID = ?,
|
||||
Nat_TestNat_KelurahanID = ?,
|
||||
Nat_TestAddress = ?,
|
||||
Nat_TestPhone = ?,
|
||||
Nat_TestEmail = ?,
|
||||
Nat_TestPIC = ?,
|
||||
Nat_TestNat_TestTypeID = ?,
|
||||
Nat_TestIsLabFrom = ?,
|
||||
Nat_TestIsLabTo = ?,
|
||||
Nat_TestMinDP = ?,
|
||||
Nat_TestNat_DoctorID = ?,
|
||||
Nat_TestLastUpdated = now()
|
||||
where
|
||||
Nat_TestID = ?
|
||||
";
|
||||
$querytest = $this->db_onedev->query($sqltest,
|
||||
array(
|
||||
$name_test,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_test,
|
||||
$phone_test,
|
||||
$email_test,
|
||||
$pic_test,
|
||||
$testtypenewid,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$testmindp,
|
||||
$doctor,
|
||||
$id_test
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$querytest) {
|
||||
$this->sys_error_db("nat_test update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_test));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "update nat_test SET
|
||||
Nat_TestName = ?,
|
||||
Nat_TestNat_CityID = ?,
|
||||
Nat_TestNat_DistrictID = ?,
|
||||
Nat_TestNat_KelurahanID = ?,
|
||||
Nat_TestAddress = ?,
|
||||
Nat_TestPhone = ?,
|
||||
Nat_TestEmail = ?,
|
||||
Nat_TestPIC = ?,
|
||||
Nat_TestNat_TestTypeID = ?,
|
||||
Nat_TestIsLabFrom = ?,
|
||||
Nat_TestIsLabTo = ?,
|
||||
Nat_TestMinDP = ?,
|
||||
Nat_TestNat_DoctorID = ?,
|
||||
Nat_TestLastUpdated = now()
|
||||
where
|
||||
Nat_TestID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_test,
|
||||
$city,
|
||||
$district,
|
||||
$kelurahan,
|
||||
$address_test,
|
||||
$phone_test,
|
||||
$email_test,
|
||||
$pic_test,
|
||||
$testtype_test,
|
||||
$islabfrom,
|
||||
$islabto,
|
||||
$testmindp,
|
||||
$doctor,
|
||||
$id_test
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_test update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_test));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewspecimenlocal()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$testid = $prm['testid'];
|
||||
$sampletypeid = $prm['sampletypeid'];
|
||||
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$sql = "insert into t_specimenlocal(
|
||||
T_SpecimenLocalNat_TestID,
|
||||
T_SpecimenLocalT_SampleTypeID,
|
||||
T_SpecimenLocalCreated,
|
||||
T_SpecimenLocalLastUpdated
|
||||
)
|
||||
values( ?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$testid,
|
||||
$sampletypeid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_specimenlocal insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}else{
|
||||
$sql = "UPDATE t_specimenlocal SET T_SpecimenLocalNat_TestID = '{$testid}' WHERE T_SpecimenLocalID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deletespecimenlocal()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_specimenlocal SET
|
||||
T_SpecimenLocalIsActive = 'N',
|
||||
T_SpecimenLocalLastUpdated = now()
|
||||
WHERE
|
||||
T_SpecimenLocalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_specimenlocal 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 deletetest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_test SET
|
||||
Nat_TestIsActive = 'N',
|
||||
Nat_TestLastUpdated = now()
|
||||
WHERE
|
||||
Nat_TestID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_test delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE t_specimenlocal SET
|
||||
T_SpecimenLocalIsActive = 'N',
|
||||
T_SpecimenLocalLastUpdated = now()
|
||||
WHERE
|
||||
T_SpecimenLocalNat_TestID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_specimenlocal 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 selecttesttype(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['testtypes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function selectdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_doctor
|
||||
WHERE
|
||||
Nat_DoctorIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['doctors'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function searchsampletype(){
|
||||
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_sampletype
|
||||
WHERE
|
||||
T_SampleTypeName like ?
|
||||
AND T_SampleTypeIsActive = '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_sampletype count",$this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(T_SampleTypeName,' ' ,'[ ',T_SampleTypeCode,' ]') as T_SampleTypeNames
|
||||
FROM t_sampletype
|
||||
WHERE T_SampleTypeIsActive = 'Y') a
|
||||
WHERE
|
||||
T_SampleTypeNames like ?
|
||||
AND T_SampleTypeIsActive = 'Y'
|
||||
ORDER BY T_SampleTypeName DESC
|
||||
";
|
||||
$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_sampletype rows",$this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcity(){
|
||||
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_city
|
||||
WHERE
|
||||
Nat_CityName like ?
|
||||
AND Nat_CityIsActive = '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_city count",$this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM nat_city
|
||||
WHERE
|
||||
Nat_CityName like ?
|
||||
AND Nat_CityIsActive = 'Y'
|
||||
ORDER BY Nat_CityName DESC
|
||||
";
|
||||
$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_city rows",$this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getdistrict(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_district
|
||||
WHERE
|
||||
Nat_DistrictIsActive = 'Y' AND Nat_DistrictNat_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM nat_kelurahan
|
||||
WHERE
|
||||
Nat_KelurahanIsActive = 'Y' AND Nat_KelurahanNat_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
658
one-api/application/controllers/mockup/masterdata/Staff.php
Normal file
658
one-api/application/controllers/mockup/masterdata/Staff.php
Normal file
@@ -0,0 +1,658 @@
|
||||
<?php
|
||||
class Staff extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Staff API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$nik = $prm["snik"];
|
||||
$nama = $prm["nama"];
|
||||
$status = $prm["status"];
|
||||
|
||||
// echo $nik;
|
||||
|
||||
$sql_where = "WHERE M_StaffIsCourier = '{$status}' AND M_StaffIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_StaffName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($nik != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_StaffNIK like ? ";
|
||||
$sql_param[] = "%$nik%";
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_StaffIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM m_staff
|
||||
LEFT JOIN m_sex ON M_StaffM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_StaffM_ReligionID = M_ReligionID
|
||||
LEFT JOIN m_branch ON M_StaffM_BranchID = M_BranchID
|
||||
LEFT JOIN m_position ON M_StaffM_PositionID = M_PositionID
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_staff count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
m_staff.*,
|
||||
DATE_FORMAT(M_StaffDOB,'%d-%m-%Y') as M_StaffDOBx,
|
||||
M_StaffM_SexID,
|
||||
M_SexID,
|
||||
m_sexname,
|
||||
M_ReligionID,
|
||||
M_StaffM_ReligionID,
|
||||
M_ReligionName,
|
||||
M_BranchID,
|
||||
M_StaffM_BranchID,
|
||||
M_BranchName,
|
||||
M_StaffM_PositionID,
|
||||
M_PositionID,
|
||||
M_PositionName,
|
||||
M_CityName,
|
||||
M_SubareaName,
|
||||
IF(M_StaffIsCourier = 'Y','YA','TIDAK') as iskurir
|
||||
FROM m_staff
|
||||
LEFT JOIN m_sex ON M_StaffM_SexID = M_SexID
|
||||
LEFT JOIN m_religion ON M_StaffM_ReligionID = M_ReligionID
|
||||
LEFT JOIN m_branch ON M_StaffM_BranchID = M_BranchID
|
||||
LEFT JOIN m_position ON M_StaffM_PositionID = M_PositionID
|
||||
LEFT JOIN m_city ON M_StaffM_CityID = M_CityID
|
||||
LEFT JOIN m_subarea ON M_StaffM_SubareaID = M_SubareaID
|
||||
$sql_where
|
||||
ORDER BY M_StaffName ASC
|
||||
limit 0,20";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['M_StaffID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_branch
|
||||
WHERE
|
||||
M_BranchIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['branchs'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM m_sex
|
||||
WHERE
|
||||
M_SexIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['sexes'] = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM m_religion
|
||||
WHERE
|
||||
M_ReligionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['religions'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *, COUNT(M_StaffID) as used
|
||||
FROM (SELECT m_position.*,M_StaffID
|
||||
FROM
|
||||
m_position
|
||||
LEFT JOIN m_staff ON M_PositionID = M_StaffM_PositionID AND M_StaffIsActive = 'Y'
|
||||
WHERE M_PositionIsActive = 'Y') a
|
||||
GROUP BY M_PositionID
|
||||
";
|
||||
//echo $query;
|
||||
$rows['positions'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function addnewposition()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_position = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "insert into m_position(
|
||||
M_PositionName,
|
||||
M_PositionUserID,
|
||||
M_PositionCreated,
|
||||
M_PositionLastUpdated
|
||||
)
|
||||
values(?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_position,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_position insert");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *, COUNT(M_StaffID) as used
|
||||
FROM (SELECT m_position.*,M_StaffID
|
||||
FROM
|
||||
m_position
|
||||
LEFT JOIN m_staff ON M_PositionID = M_StaffM_PositionID AND M_StaffIsActive = 'Y'
|
||||
WHERE M_PositionIsActive = 'Y') a
|
||||
GROUP BY M_PositionID
|
||||
";
|
||||
//echo $query;
|
||||
$rows['positions'] = $this->db_onedev->query($query)->result_array();
|
||||
$result = array ("total" => 1, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function editposition()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_staff = $prm['id'];
|
||||
$name_staff = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlstaff = "update m_position SET
|
||||
M_PositionName = ?,
|
||||
M_PositionUserID = ?,
|
||||
M_PositionLastUpdated = now()
|
||||
where
|
||||
M_PositionID = ?
|
||||
";
|
||||
$querystaff = $this->db_onedev->query($sqlstaff,
|
||||
array(
|
||||
$name_staff,
|
||||
$userid,
|
||||
$id_staff
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querystaff) {
|
||||
$this->sys_error_db("m_position update");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *, COUNT(M_StaffID) as used
|
||||
FROM (SELECT m_position.*,M_StaffID
|
||||
FROM
|
||||
m_position
|
||||
LEFT JOIN m_staff ON M_PositionID = M_StaffM_PositionID AND M_StaffIsActive = 'Y'
|
||||
WHERE M_PositionIsActive = 'Y') a
|
||||
GROUP BY M_PositionID";
|
||||
//echo $query;
|
||||
$rows['positions'] = $this->db_onedev->query($query)->result_array();
|
||||
$result = array ("total" => 1, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function deleteposition()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_staff = $prm['id'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlstaff = "update m_position SET
|
||||
M_PositionIsActive = 'N',
|
||||
M_PositionUserID = ?,
|
||||
M_PositionLastUpdated = now()
|
||||
where
|
||||
M_PositionID = ?
|
||||
";
|
||||
$querystaff = $this->db_onedev->query($sqlstaff,
|
||||
array(
|
||||
$userid,
|
||||
$id_staff
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querystaff) {
|
||||
$this->sys_error_db("m_position update");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_position
|
||||
WHERE
|
||||
M_PositionIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['positions'] = $this->db_onedev->query($query)->result_array();
|
||||
$result = array ("total" => 1, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function searchcity(){
|
||||
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 m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = '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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getsubarea(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_subarea
|
||||
WHERE
|
||||
M_SubareaIsActive = 'Y' AND M_SubareaM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_StaffDOB']));
|
||||
$iscourier = $prm['M_StaffIsCourier'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE m_staff SET
|
||||
M_StaffM_BranchID = '{$prm['M_StaffM_BranchID']}',
|
||||
M_StaffName = '{$prm['M_StaffName']}',
|
||||
M_StaffDOB = '{$pdob}',
|
||||
M_StaffM_SexID = '{$prm['M_StaffM_SexID']}',
|
||||
M_StaffM_ReligionID = '{$prm['M_StaffM_ReligionID']}',
|
||||
M_StaffAddress = '{$prm['M_StaffAddress']}',
|
||||
M_StaffM_CityID = '{$prm['M_StaffM_CityID']}',
|
||||
M_StaffM_SubareaID = '{$prm['M_StaffM_SubareaID']}',
|
||||
M_StaffHP = '{$prm['M_StaffHP']}',
|
||||
M_StaffPhone = '{$prm['M_StaffPhone']}',
|
||||
M_StaffM_PositionID = '{$prm['M_StaffM_PositionID']}',
|
||||
M_StaffNIK = '{$prm['M_StaffNIK']}',
|
||||
M_StaffBlood = '{$prm['M_StaffBlood']}',
|
||||
M_StaffStudy = '{$prm['M_StaffStudy']}',
|
||||
M_StaffStartDate = '{$prm['M_StaffStartDate']}',
|
||||
M_StaffEndDate = '{$prm['M_StaffEndDate']}',
|
||||
M_StaffTimeWork = '{$prm['M_StaffTimeWork']}',
|
||||
M_StaffTimeWorkSaturday = '{$prm['M_StaffTimeWorkSaturday']}',
|
||||
M_StaffIsCourier = '{$iscourier}',
|
||||
M_StaffUserID = '{$userid}'
|
||||
|
||||
WHERE
|
||||
M_StaffID = '{$prm['M_StaffID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newstaff(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_StaffDOB']));
|
||||
$iscourier = $prm['M_StaffIsCourier'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO m_staff (
|
||||
M_StaffM_BranchID,
|
||||
M_StaffName,
|
||||
M_StaffDOB,
|
||||
M_StaffM_SexID,
|
||||
M_StaffM_ReligionID,
|
||||
M_StaffAddress,
|
||||
M_StaffM_CityID,
|
||||
M_StaffM_SubareaID,
|
||||
M_StaffHP,
|
||||
M_StaffPhone,
|
||||
M_StaffM_PositionID,
|
||||
M_StaffNIK,
|
||||
M_StaffBlood,
|
||||
M_StaffStudy,
|
||||
M_StaffStartDate ,
|
||||
M_StaffEndDate,
|
||||
M_StaffTimeWork,
|
||||
M_StaffTimeWorkSaturday,
|
||||
M_StaffIsCourier,
|
||||
M_StaffUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_StaffM_BranchID']}',
|
||||
'{$prm['M_StaffName']}',
|
||||
'{$pdob}',
|
||||
'{$prm['M_StaffM_SexID']}',
|
||||
'{$prm['M_StaffM_ReligionID']}',
|
||||
'{$prm['M_StaffAddress']}',
|
||||
'{$prm['M_StaffM_CityID']}',
|
||||
'{$prm['M_StaffM_SubareaID']}',
|
||||
'{$prm['M_StaffHP']}',
|
||||
'{$prm['M_StaffPhone']}',
|
||||
'{$prm['M_StaffM_PositionID']}',
|
||||
'{$prm['M_StaffNIK']}',
|
||||
'{$prm['M_StaffBlood']}',
|
||||
'{$prm['M_StaffStudy']}',
|
||||
'{$prm['M_StaffStartDate']}',
|
||||
'{$prm['M_StaffEndDate']}',
|
||||
'{$prm['M_StaffTimeWork']}',
|
||||
'{$prm['M_StaffTimeWorkSaturday']}',
|
||||
'{$iscourier}',
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($rows){
|
||||
if($iscourier == 'Y'){
|
||||
$querycourier ="INSERT INTO m_courier(M_CourierM_StaffID,M_CourierCreated,M_CourierLastUpdated,M_CourierUserID)
|
||||
VALUES('{$last_id}',now(),now(),'{$userid}')
|
||||
";
|
||||
$rows = $this->db_onedev->query($querycourier);
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletestaff(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE m_staff SET
|
||||
M_StaffIsActive = 'N'
|
||||
WHERE
|
||||
M_StaffID = '{$prm['M_StaffID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT m_staffaddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
M_CityID,
|
||||
M_CityName,
|
||||
'' as action
|
||||
FROM m_staffaddress
|
||||
JOIN m_kelurahan ON M_StaffAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
WHERE
|
||||
M_StaffAddressIsActive = 'Y' AND M_StaffAddressM_StaffID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_staffaddress WHERE M_StaffAddressM_StaffID = '{$prm['M_StaffAddressM_StaffID']}' AND M_StaffAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['M_StaffAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM m_staffaddress WHERE M_StaffAddressM_StaffID = '{$prm['M_StaffAddressM_StaffID']}' AND M_StaffAddressNote = 'Utama' AND M_StaffAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['M_StaffAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['M_StaffAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO m_staffaddress (
|
||||
M_StaffAddressM_StaffID,
|
||||
M_StaffAddressNote,
|
||||
M_StaffAddressDescription,
|
||||
M_StaffAddressM_KelurahanID,
|
||||
M_StaffAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_StaffAddressM_StaffID']}',
|
||||
'{$prm['M_StaffAddressNote']}',
|
||||
'{$prm['M_StaffAddressDescription']}',
|
||||
'{$prm['M_StaffAddressM_KelurahanID']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_staffaddress SET
|
||||
M_StaffAddressM_StaffID = '{$prm['M_StaffAddressM_StaffID']}',
|
||||
M_StaffAddressNote = '{$prm['M_StaffAddressNote']}',
|
||||
M_StaffAddressDescription = '{$prm['M_StaffAddressDescription']}',
|
||||
M_StaffAddressM_KelurahanID = '{$prm['M_StaffAddressM_KelurahanID']}'
|
||||
WHERE
|
||||
M_StaffAddressID = '{$prm['M_StaffAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE m_staffaddress SET
|
||||
M_StaffAddressIsActive = 'N'
|
||||
WHERE
|
||||
M_StaffAddressID = '{$prm['M_StaffAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
479
one-api/application/controllers/mockup/masterdata/Station.php
Normal file
479
one-api/application/controllers/mockup/masterdata/Station.php
Normal file
@@ -0,0 +1,479 @@
|
||||
<?php
|
||||
class Station extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "STATION API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookupbahan(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select T_BahanID as id,
|
||||
T_BahanT_SampleStationID as usergroupid,
|
||||
T_BahanCode as code,
|
||||
T_BahanName As name,
|
||||
'xxx' as action
|
||||
from t_bahan
|
||||
join t_samplestation oN T_BahanT_SampleStationID = T_SampleStationID
|
||||
where
|
||||
T_BahanT_SampleStationID = {$id} AND T_BahanIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from t_samplestation
|
||||
where
|
||||
T_SampleStationIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select T_SampleStationID as id,
|
||||
T_SampleStationCode as code,
|
||||
T_SampleStationName as name,
|
||||
T_SampleStationIsNonLab as isnonlab, T_SampleStationName as description , 'xxx' as usergrouptype
|
||||
from t_samplestation
|
||||
where
|
||||
T_SampleStationName LIKE CONCAT('%','{$search}','%') AND
|
||||
T_SampleStationIsActive = 'Y' $limit";
|
||||
$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("t_samplestation select",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewstation()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$name_station = $prm['name'];
|
||||
$code_station = $prm['code'];
|
||||
$isnonlab_station = $prm['isnonlab'];
|
||||
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
//echo $exist_name;
|
||||
if($exist_name == 0 ){
|
||||
$sql = "insert into t_samplestation(
|
||||
T_SampleStationCode,
|
||||
T_SampleStationName,
|
||||
T_SampleStationIsNonLab,
|
||||
T_SampleStationCreated,
|
||||
T_SampleStationLastUpdated
|
||||
)
|
||||
values( ?, ?, ?,now(), now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$name_station,
|
||||
$code_station,
|
||||
$isnonlab_station
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
} else{
|
||||
$errors = array();
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada '));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editstation()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_station = $prm['id'];
|
||||
$code_station = $prm['code'];
|
||||
$name_station = $prm['name'];
|
||||
$isnonlab_station = $prm['isnonlab'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_samplestation WHERE T_SampleStationIsActive = 'Y' AND T_SampleStationName = '{$name_station}'
|
||||
AND T_SampleStationID <> {$id_station} ";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
if($exist_name == 0){
|
||||
|
||||
$sql = "update t_samplestation SET
|
||||
T_SampleStationCode = ?,
|
||||
T_SampleStationName = ?,
|
||||
T_SampleStationIsNonLab = ?,
|
||||
T_SampleStationLastUpdated = now()
|
||||
where
|
||||
T_SampleStationID = ?
|
||||
";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code_station,
|
||||
$name_station,
|
||||
$isnonlab_station,
|
||||
$id_station
|
||||
)
|
||||
);
|
||||
//file_put_contents("/tmp/adi-update-user.sql",$this->db_onedev->last_query());
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_station));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function editbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$bahanid = $prm['xid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
$xstationname = $prm['xstationname'];
|
||||
|
||||
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'
|
||||
and T_BahanID <> $bahanid ";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
|
||||
$sql = "update m_user SET
|
||||
T_BahanCode = ?,
|
||||
T_BahanName = ?,
|
||||
T_BahanT_SampleStationID = ?,
|
||||
T_BahanLastUpdated = now()
|
||||
where T_BahanID = ? ";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$xstationname["T_SampleStationID"],
|
||||
$bahanid
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan update",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $bahanid));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$errors = array();
|
||||
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewbahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$stationid = $prm['stationid'];
|
||||
$code = $prm['code'];
|
||||
$name = $prm['name'];
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}'";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
if($exist_name == 0){
|
||||
$sql = "insert into t_bahan(
|
||||
T_BahanT_SampleStationID,
|
||||
T_BahanCode,
|
||||
T_BahanName,
|
||||
T_BahanCreated,
|
||||
T_BahanLastUpdated
|
||||
)
|
||||
values( ?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$stationid,
|
||||
$code,
|
||||
$name
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan insert",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'Nama sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}else{
|
||||
$query = "SELECT COUNT(*) as exist FROM t_bahan WHERE T_BahanIsActive = 'Y' AND T_BahanName = '{$name}' AND T_BahanID <> {$prm['xid']}";
|
||||
$exist_name = $this->db_onedev->query($query)->row()->exist;
|
||||
//echo $query;
|
||||
|
||||
//echo $query;
|
||||
if($exist_name == 0 ){
|
||||
$sql = "UPDATE t_bahan SET T_BahanName = '{$name}', T_BahanCode = '{$code}' WHERE T_BahanID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
$errors = array();
|
||||
if($exist_name != 0){
|
||||
array_push($errors,array('field'=>'name','msg'=>'name sudah ada yang pakai dong'));
|
||||
}
|
||||
|
||||
$result = array ("total" => -1,"errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function deletebahan()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_bahan SET
|
||||
T_BahanIsActive = 'N',
|
||||
T_BahanLastUpdated = now()
|
||||
WHERE
|
||||
T_BahanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_bahan 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 deleteselect()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_samplestation SET
|
||||
T_SampleStationIsActive = 'N',
|
||||
T_SampleStationLastUpdated = now()
|
||||
WHERE
|
||||
T_SampleStationID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_samplestation delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE m_user SET
|
||||
M_UserIsActive = 'N',
|
||||
M_UserLastUpdated = now()
|
||||
WHERE
|
||||
M_UserM_UserGroupID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_user delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
710
one-api/application/controllers/mockup/masterdata/Test.php
Normal file
710
one-api/application/controllers/mockup/masterdata/Test.php
Normal file
@@ -0,0 +1,710 @@
|
||||
<?php
|
||||
class Test extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Test API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["scode"];
|
||||
$nama = $prm["name"];
|
||||
$prm['current_page'] = isset($prm['current_page'])?$prm['current_page']:1;
|
||||
|
||||
// echo $nik;
|
||||
|
||||
$sql_where = "WHERE T_TestIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_TestName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_TestSasCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_StaffIsActive = 'Y' ";
|
||||
$number_limit = 50;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
LEFT JOIN nat_subsubgroup ON nat_subsubgroupID = Nat_Testnat_subsubgroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$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("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *, T_TestIsNonLab as T_TestIsNonLabID,IF(T_TestIsNonLab = '', 'LAB',T_TestIsNonLab) as T_TestIsNonLabs, T_TestSasCode as db_T_TestSasCode
|
||||
FROM t_test
|
||||
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
LEFT JOIN nat_subsubgroup ON nat_subsubgroupID = Nat_Testnat_subsubgroupID
|
||||
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
$sql_where
|
||||
ORDER BY T_TestSasCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroupes'] = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT *
|
||||
FROM nat_testtype
|
||||
WHERE
|
||||
Nat_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLab"=>"LAB"),array("T_TestIsNonLabID"=>"XRAY","T_TestIsNonLab"=>"XRAY"), array("T_TestIsNonLabID"=>"USG","T_TestIsNonLab"=>"USG"),array("T_TestIsNonLabID"=>"ELECTROMEDIS","T_TestIsNonLab"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getinitdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
|
||||
$query =" SELECT T_TestTypeID as id, T_TestTypeName as name
|
||||
FROM t_testtype
|
||||
WHERE
|
||||
T_TestTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLab"=>"LAB"),array("T_TestIsNonLabID"=>"XRAY","T_TestIsNonLab"=>"XRAY"), array("T_TestIsNonLabID"=>"USG","T_TestIsNonLab"=>"USG"),array("T_TestIsNonLabID"=>"ELECTROMEDIS","T_TestIsNonLab"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
function searchunit(){
|
||||
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_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = '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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_UnitId as id, Nat_UnitName as name
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'
|
||||
ORDER BY Nat_UnitName 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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchsample(){
|
||||
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_sampletype
|
||||
WHERE
|
||||
T_SampleTypeName like ?
|
||||
AND T_SampleTypeIsActive = '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_sampletype count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_SampleTypeID,T_SampleTypeName
|
||||
FROM t_sampletype
|
||||
WHERE
|
||||
T_SampleTypeName like ?
|
||||
AND T_SampleTypeIsActive = 'Y'
|
||||
ORDER BY T_SampleTypeName 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_sampletype rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['T_TestFontSize'] == '')
|
||||
$prm['T_TestFontSize'] = 10;
|
||||
|
||||
$query ="UPDATE t_test SET
|
||||
T_TestSasCode = '{$prm['T_TestSasCode']}',
|
||||
T_TestName = '{$prm['T_TestName']}',
|
||||
T_TestShortName = '{$prm['T_TestShortName']}',
|
||||
T_TestShortNameBarcode = '{$prm['T_TestShortNameBarcode']}',
|
||||
T_TestNat_GroupID = '{$prm['T_TestNat_GroupID']}',
|
||||
T_TestNat_SubgroupID = '{$prm['T_TestNat_SubgroupID']}',
|
||||
T_TestT_SampleTypeID = '{$prm['T_TestT_SampleTypeID']}',
|
||||
T_TestFontSize = '{$prm['T_TestFontSize']}',
|
||||
T_TestFontColor = '{$prm['T_TestFontColor']}',
|
||||
T_TestIsBold = '{$prm['T_TestIsBold']}',
|
||||
T_TestIsItalic = '{$prm['T_TestIsItalic']}',
|
||||
T_TestIsQuantitative = '{$prm['T_TestIsQuantitative']}',
|
||||
T_TestIsDeltaCheck = '{$prm['T_TestIsDeltaCheck']}',
|
||||
T_TestIsResult = '{$prm['T_TestIsResult']}',
|
||||
T_TestIsPrice = '{$prm['T_TestIsPrice']}',
|
||||
T_TestIsPrintResult = '{$prm['T_TestIsPrintResult']}',
|
||||
T_TestIsPrintNota = '{$prm['T_TestIsPrintNota']}',
|
||||
T_TestIsTrendAnalysis = '{$prm['T_TestIsTrendAnalysis']}',
|
||||
T_TestIsWorklist = '{$prm['T_TestIsWorklist']}',
|
||||
T_TestIsNonLab = '{$prm['T_TestIsNonLab']}',
|
||||
T_TestWorklistName = '{$prm['T_TestWorklistName']}',
|
||||
T_TestMaxDiscount = '{$prm['T_TestMaxDiscount']}'
|
||||
WHERE T_TestID = '{$prm['T_TestID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM t_test
|
||||
WHERE T_TestCode = '{$prm['code']}' AND T_TestIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->row()->countx;
|
||||
if($rst > 0)
|
||||
$rtn = 'Y';
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rtn,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdataselected(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['T_TestID'];
|
||||
|
||||
$query =" SELECT
|
||||
T_TestCode as code,
|
||||
T_TestName as name,
|
||||
T_TestShortName as shortname,
|
||||
T_TestShortNameBarcode as codebarcode,
|
||||
'' as xgroup,
|
||||
Nat_GroupID as group_id,
|
||||
Nat_GroupName as group_name,
|
||||
'' as subgroup,
|
||||
Nat_SubGroupID as subgroup_id,
|
||||
Nat_SubGroupName as subgroup_name,
|
||||
'' as type,
|
||||
T_TestT_TestTypeID as type_id,
|
||||
T_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
Nat_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
T_TestIsNonLab as nonlab,
|
||||
T_TestT_SampleTypeID as sample_id,
|
||||
T_SampleTypeName as sample_name,
|
||||
T_TestFontSize as fontsize,
|
||||
T_TestFontColor as fontcolor,
|
||||
T_TestIsBold as flagbold,
|
||||
T_TestIsItalic as flagitalic,
|
||||
T_TestFlagGluc as flaggluc,
|
||||
T_TestIsQuantitative as flagquantitative,
|
||||
T_TestIsDeltaCheck as deltacheck,
|
||||
T_TestIsResult as isresult,
|
||||
T_TestIsPrice as isprice,
|
||||
T_TestIsPrintResult as printresult,
|
||||
T_TestIsPrintNota as printnote,
|
||||
T_TestIsTrendAnalysis as trendanalysis,
|
||||
T_TestIsWorklist as isworklist,
|
||||
T_TestWorklistName as worklistname,
|
||||
T_TestFlagLow as flaglow,
|
||||
T_TestFlagHigh as flaghigh
|
||||
FROM t_test
|
||||
JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
JOIN t_testtype ON T_TestT_TestTypeID = T_TestTypeID
|
||||
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
|
||||
WHERE T_TestID = '{$id}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['xform'] = $this->db_onedev->query($query)->row_array();
|
||||
if($rows['xform']){
|
||||
$rows['xform']['unit'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
|
||||
|
||||
$rows['xform']['sample'] = array();
|
||||
if($rows['xform']['isresult'] == 'Y')
|
||||
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
|
||||
|
||||
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
|
||||
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
|
||||
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
||||
|
||||
|
||||
if($rows['xform']['nonlab'] == '')
|
||||
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
||||
else
|
||||
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
||||
|
||||
unset($rows['xform']['sample_id']);
|
||||
unset($rows['xform']['unit_id']);
|
||||
unset($rows['xform']['group_id']);
|
||||
unset($rows['xform']['subgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaddtest(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rtn = true;
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$codefrom = $prm['codefrom'];
|
||||
$codetoward = $prm['codetoward'];
|
||||
$leng = strlen($codetoward);
|
||||
$code_parent = substr($codetoward, 0,-2);
|
||||
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->existtest;
|
||||
if($xcount == 0){
|
||||
$sql = "
|
||||
select T_TestID ,T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
||||
UNION
|
||||
select T_TestID , T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
||||
";
|
||||
//echo $sql;
|
||||
$toupdate = $this->db_onedev->query($sql)->result();
|
||||
if($toupdate){
|
||||
foreach($toupdate as $k => $v){
|
||||
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
||||
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
|
||||
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestParentT_TestID,
|
||||
T_TestT_TestID,
|
||||
T_TestCode,
|
||||
T_TestSasCode,
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
SELECT
|
||||
{$parentid},
|
||||
T_TestID,
|
||||
T_TestCode,
|
||||
'{$codetoward}',
|
||||
T_TestName,
|
||||
T_TestShortName,
|
||||
T_TestShortNameBarcode,
|
||||
T_TestNat_GroupID,
|
||||
T_TestNat_SubGroupID,
|
||||
T_TestT_SampleTypeID,
|
||||
T_TestFontSize,
|
||||
T_TestFontColor,
|
||||
T_TestIsBold,
|
||||
T_TestIsItalic,
|
||||
T_TestFlagGluc,
|
||||
T_TestIsQuantitative,
|
||||
T_TestIsDeltaCheck,
|
||||
T_TestIsResult,
|
||||
T_TestIsPrice,
|
||||
T_TestIsPrintResult,
|
||||
T_TestIsPrintNota,
|
||||
T_TestIsTrendAnalysis,
|
||||
T_TestIsWorklist,
|
||||
T_TestIsNonLab,
|
||||
T_TestWorklistName,
|
||||
T_TestFlagLow,
|
||||
T_TestFlagHigh,
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM t_test
|
||||
WHERE
|
||||
T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'
|
||||
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
|
||||
$data_parent = $this->db_onedev->query($sql)->row();
|
||||
if($data_parent){
|
||||
$testidparent = $data_parent->T_TestID;
|
||||
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $xcount,
|
||||
"debug"=>$query
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function check_exist_code(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT COUNT(*) as x_count FROM t_test WHERE T_TestSasCode = '{$prm['newcode']}' AND T_TestID <> {$prm['trx']['T_TestID']} AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$x_count = $this->db_onedev->query($sql)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $x_count,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,639 @@
|
||||
<?php
|
||||
class Testconclusion extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Resultentry API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->helper(array('form', 'url'));
|
||||
}
|
||||
|
||||
function getdetails($id){
|
||||
$rows = [];
|
||||
|
||||
$sql = "SELECT * FROM t_testconclusion WHERE T_TestConclusionT_TestID = {$id} AND T_TestConclusionIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
return $rows;
|
||||
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["search"];
|
||||
|
||||
$sql_where = "WHERE T_TestIsResult = 'Y' AND T_TestIsActive = 'Y'";
|
||||
|
||||
//$sql_param = array();
|
||||
if ($search != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( T_TestCode like '%$search%' OR T_TestName like '%$search%' ) ";
|
||||
}
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT t_test.*, '' as details
|
||||
FROM t_test
|
||||
$sql_where
|
||||
GROUP BY T_TestCode
|
||||
ORDER BY T_TestCode ASC
|
||||
limit 0,20";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['details'] = $this->getdetails($v['T_TestID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getordersamples(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$doctorid = $prm['doctorid'];
|
||||
$doctoraddressid = $prm['doctoraddressid'];
|
||||
$sql = "SELECT
|
||||
0 as idx,
|
||||
M_SexName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
T_SampleTypeName as samplename,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_SampleTypeID as sampleid,
|
||||
'Y' as active,
|
||||
'N' as flag_image
|
||||
FROM t_samplingso
|
||||
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_sampletype ON T_SamplingSoT_SampleTypeID = T_SampleTypeID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
WHERE
|
||||
T_SamplingSoM_DoctorID = {$doctorid} AND T_SamplingSoM_DoctorAddressID = {$doctoraddressid} AND T_SamplingSoVerifyFlagWL = 'N' AND T_SamplingSoIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getnormalvalue(){
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$methodeid = $prm['methodeid'];
|
||||
/*$sql = "SELECT
|
||||
0 as idx,
|
||||
M_SexName,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname,
|
||||
T_SampleTypeName as samplename,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_SampleTypeID as sampleid,
|
||||
'Y' as active,
|
||||
'N' as flag_image
|
||||
FROM t_samplingso
|
||||
JOIN t_orderheader ON T_SamplingSoT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_sampletype ON T_SamplingSoT_SampleTypeID = T_SampleTypeID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
WHERE
|
||||
T_SamplingSoM_DoctorID = {$doctorid} AND T_SamplingSoM_DoctorAddressID = {$doctoraddressid} AND T_SamplingSoVerifyFlagWL = 'N' AND T_SamplingSoIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result_array();*/
|
||||
if($methodeid == 1){
|
||||
$rows = array(
|
||||
array(
|
||||
'id'=>1,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">MALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
7th - 14th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">0 - 51</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>2,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">MALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
15th - 24th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">20 - 60</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>3,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">FEMALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
7th - 14th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">0 - 31</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>4,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">FEMALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
15th - 24th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">10 - 60</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if($methodeid == 2){
|
||||
$rows = array(
|
||||
array(
|
||||
'id'=>1,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">MALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
7th - 14th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">10 - 31</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>2,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">MALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
15th - 24th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">20 - 40</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>3,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">FEMALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
7th - 14th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">15 - 41</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
),
|
||||
array(
|
||||
'id'=>4,
|
||||
'normalvalue_description'=>'
|
||||
<span class="flex body-2 font-weight-black">FEMALE</span>
|
||||
<span class="flex title font-weight-thin">[</span>
|
||||
<span class="flex body-2 text-uppercase black--text">
|
||||
15th - 24th
|
||||
</span>
|
||||
<span class="flex title font-weight-thin">]</span>
|
||||
<span class="flex body-2 font-weight-black">30 - 60</span>',
|
||||
'mininclusive'=>'N',
|
||||
'minvalue'=>'0',
|
||||
'maxinclusive'=>'N',
|
||||
'maxvalue'=>'0',
|
||||
'active'=>'Y'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function getgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as title, CONCAT('GROUP : ',Nat_GroupName) as fulltitle, '' as childrens
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y' AND ( Nat_GroupCode = 2 OR Nat_GroupCode = 3 )
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
if($rows['groups']){
|
||||
foreach($rows['groups'] as $k => $v){
|
||||
$childrens = array(array('id'=>0, 'title'=>'Semua', 'fulltitle'=>'Subgroub : Semua'));
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as title, CONCAT('SUBGROUP : ',Nat_SubGroupName) as fulltitle
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupNat_GroupID = {$v['id']} AND Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$xrst = $this->db_onedev->query($query)->result_array();
|
||||
if($xrst){
|
||||
foreach($xrst as $ki => $vi){
|
||||
array_push($childrens,$vi);
|
||||
}
|
||||
}
|
||||
$rows['groups'][$k]['childrens'] = $childrens ;
|
||||
}
|
||||
}
|
||||
$query =" SELECT M_LangID as id, M_LangName as name
|
||||
FROM m_lang
|
||||
WHERE
|
||||
M_LangIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['langs'] = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = array(array('id'=>0, 'title'=>'Semua', 'fulltitle'=>'Subgroub : Semua'));
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as title, CONCAT('SUBGROUP : ',Nat_SubGroupName) as fulltitle
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupNat_GroupID = {$prm['id']} AND Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rst = $this->db_onedev->query($query)->result_array();
|
||||
if($rst){
|
||||
foreach($rst as $k => $v){
|
||||
array_push($rows,$v);
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getstation(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT T_SampleStationID as id, T_SampleStationName as name
|
||||
FROM t_samplestation
|
||||
WHERE
|
||||
T_SampleStationIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
//print_r($statuses);
|
||||
foreach($statuses as $k=>$v){
|
||||
array_push($rows['statuses'],$v);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdoctoraddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT M_DoctorAddressID as id, M_DoctorAddressDescription as name
|
||||
FROM m_doctoraddress
|
||||
WHERE
|
||||
M_DoctorAddressM_DoctorID = {$prm['id']} AND M_DoctorAddressIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$xdate = date('Y-m-d',strtotime($prm["trx_date"]));
|
||||
if($prm['trx_id'] == '0' || $prm['trx_id'] == 0){
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('WLI') as numbering")->row()->numbering;
|
||||
$query ="INSERT INTO so_walklettercourier (
|
||||
So_WalkLetterCourierNumbering,
|
||||
So_WalkLetterCourierDate,
|
||||
So_WalkLetterCourierNote,
|
||||
So_WalkLetterCourierM_StaffID,
|
||||
So_WalkLetterCourierM_DoctorID,
|
||||
So_WalkLetterCourierM_DoctorAddressID,
|
||||
So_WalkLetterCourierCreated,
|
||||
So_WalkLetterCourierUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['trx_note']}',
|
||||
'{$prm['courier']['id']}',
|
||||
'{$prm['doctor']['id']}',
|
||||
'{$prm['doctoraddress']['id']}',
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
}else{
|
||||
$numbering = $this->db_onedev->query("SELECT So_WalkLetterCourierNumbering as numbering FROM so_walklettercourier WHERE So_WalkLetterCourierID = {$prm['trx_id']}")->row()->numbering;
|
||||
$query ="UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierDate = '{$xdate}',
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierM_StaffID = '{$prm['courier']['id']}',
|
||||
So_WalkLetterCourierM_DoctorID = '{$prm['doctor']['id']}',
|
||||
So_WalkLetterCourierM_DoctorAddressID = '{$prm['doctoraddress']['id']}',
|
||||
So_WalkLetterCourierCreated = NOW(),
|
||||
So_WalkLetterCourierUserID = '{$userid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $prm['trx_id'];
|
||||
}
|
||||
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
if($v['active'] === 'Y' && ($v['idx'] == 0 || $v['idx'] == '0')){
|
||||
$query ="INSERT INTO so_walklettercourierdetail (
|
||||
So_WalkLetterCourierDetailSo_WalkLetterCourierID,
|
||||
So_WalkLetterCourierDetailT_OrderHeaderID,
|
||||
So_WalkLetterCourierDetailT_SampleTypeID,
|
||||
So_WalkLetterCourierDetailFlagImage,
|
||||
So_WalkLetterCourierDetailCreated,
|
||||
So_WalkLetterCourierDetailUserID
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['orderid']}',
|
||||
'{$v['sampleid']}',
|
||||
'{$v['flag_image']}',
|
||||
NOW(),
|
||||
'{$userid}'
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['active'] === 'Y' && ($v['idx'] != 0 || $v['idx'] != '0')){
|
||||
$query ="UPDATE so_walklettercourierdetail SET
|
||||
So_WalkLetterCourierDetailSo_WalkLetterCourierID = '{$last_id}',
|
||||
So_WalkLetterCourierDetailT_OrderHeaderID = '{$v['orderid']}',
|
||||
So_WalkLetterCourierDetailT_SampleTypeID = '{$v['sampleid']}',
|
||||
So_WalkLetterCourierDetailFlagImage = '{$v['flag_image']}',
|
||||
So_WalkLetterCourierDetailUserID = '{$userid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierDetailID = {$v['idx']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($v['active'] === 'N' && $v['idx'] != 0){
|
||||
$query ="UPDATE so_walklettercourierdetail SET
|
||||
So_WalkLetterCourierDetailIsActive = 'N',
|
||||
So_WalkLetterCourierDetailUserID = '{$userid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierDetailID = {$v['idx']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function deletetrx(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierIsActive = 'N',
|
||||
So_WalkLetterCourierUserID = '{$userid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx_id']}
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $prm['trx_id'];
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $prm['trx_numbering'],
|
||||
"id" => $prm['trx_id']
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['act'] == 'RELEASEC' || $prm['act'] === 'RCVDOC' ){
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierStatus = '{$prm['act']}',
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
if($prm['act'] === 'DONE'){
|
||||
$details = $prm['details'];
|
||||
$count_n = 0;
|
||||
foreach($details as $k => $v){
|
||||
if($v['flag_image_receive'] === 'N'){
|
||||
$count_n++;
|
||||
}
|
||||
if($v['flag_result_receive'] === 'N'){
|
||||
$count_n++;
|
||||
}
|
||||
$query ="UPDATE so_walklettercourierdetail SET
|
||||
So_WalkLetterCourierDetailFlagReceiveImage = '{$v['flag_image_receive']}',
|
||||
So_WalkLetterCourierDetailFlagReceiveResult = '{$v['flag_result_receive']}',
|
||||
So_WalkLetterCourierDetailUserID = '{$userid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierDetailID = {$v['idx']}
|
||||
";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
$status = 'DONE';
|
||||
if($count_n > 0){
|
||||
$status = 'PARTDONE';
|
||||
}
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierStatus = '{$status}',
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
if($prm['act'] == 'FORCEDONE'){
|
||||
$sql = "UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierNote = '{$prm['trx_note']}',
|
||||
So_WalkLetterCourierStatus = 'DONE',
|
||||
So_WalkLetterCourierUserID = {$userid}
|
||||
WHERE
|
||||
So_WalkLetterCourierID = {$prm['trx']['trx_id']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
|
||||
class Testfavorite extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "TEST FAVORITE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function lookuptest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from t_test
|
||||
where
|
||||
T_TestIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select T_TestID as id,
|
||||
T_TestName as dashboard,
|
||||
CONCAT(T_TestName,' ' ,'[ ',T_TestCode,' ]') as name,
|
||||
T_TestCode as code,
|
||||
T_TestName as description ,
|
||||
'xxx' as usergrouptype
|
||||
from t_test
|
||||
where
|
||||
T_TestName LIKE CONCAT('%','{$search}','%') AND
|
||||
T_TestIsActive = 'Y'
|
||||
union
|
||||
select T_PacketID as id,
|
||||
T_PacketName as dashboard,
|
||||
CONCAT(T_PacketName,' ' ,'[ ',T_PacketSasCode,' ]') as name,
|
||||
T_PacketSasCode as code,
|
||||
T_PacketName as description ,
|
||||
'xxx' as usergrouptype
|
||||
from t_packet
|
||||
where
|
||||
T_PacketName LIKE CONCAT('%','{$search}','%') AND
|
||||
T_PacketIsActive = 'Y'
|
||||
|
||||
|
||||
|
||||
$limit";
|
||||
$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("t_test select");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookupfavorite()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
T_TestID as id,
|
||||
T_TestName as name
|
||||
from t_favorite
|
||||
join t_test on T_FavoriteT_TestID = T_TestID
|
||||
WHERE T_FavoriteIsActive= 'y'
|
||||
|
||||
union
|
||||
SELECT
|
||||
T_PacketID as id,
|
||||
T_PacketName as name
|
||||
from t_favorite
|
||||
join t_packet on T_FavoriteT_PacketID= T_PacketID
|
||||
|
||||
where T_FavoriteIsActive= 'y'
|
||||
|
||||
";
|
||||
$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"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$datas = $prm['datas'];
|
||||
foreach ($datas as $k => $v){
|
||||
foreach ($v['childs'] as $kx => $vx){
|
||||
if($vx['active'] == 'Y'){
|
||||
if(is_null($vx['S_PrivilegeID']) && $vx['status'] == 'Y'){
|
||||
$sql = "INSERT INTO s_privilege (
|
||||
S_PrivilegeM_UserGroupID,
|
||||
S_PrivilegeS_MenuID,
|
||||
S_PrivilegeCreated
|
||||
)
|
||||
VALUES(
|
||||
{$vx['usergroupid']},
|
||||
{$vx['S_MenuID']},
|
||||
NOW()
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
|
||||
if(!is_null($vx['S_PrivilegeID'])){
|
||||
$sql = "UPDATE s_privilege SET
|
||||
S_PrivilegeIsActive = '{$vx['status']}'
|
||||
WHERE
|
||||
S_PrivilegeID = '{$vx['S_PrivilegeID']}'
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
}
|
||||
if($vx['childs']){
|
||||
foreach ($vx['childs'] as $kxz => $vxz){
|
||||
if($vxz['active'] == 'Y'){
|
||||
if(is_null($vxz['S_PrivilegeID']) && $vxz['status'] == 'Y'){
|
||||
$sql = "INSERT INTO s_privilege (
|
||||
S_PrivilegeM_UserGroupID,
|
||||
S_PrivilegeS_MenuID,
|
||||
S_PrivilegeCreated
|
||||
)
|
||||
VALUES(
|
||||
{$vxz['usergroupid']},
|
||||
{$vxz['S_MenuID']},
|
||||
NOW()
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
|
||||
if(!is_null($vxz['S_PrivilegeID'])){
|
||||
$sql = "UPDATE s_privilege SET
|
||||
S_PrivilegeIsActive = '{$vxz['status']}'
|
||||
WHERE
|
||||
S_PrivilegeID = '{$vxz['S_PrivilegeID']}'
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total"=>1,"records" => array());
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deletefavoritetest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update t_favorite SET
|
||||
T_FavoriteIsActive = 'N',
|
||||
T_FavoriteLastUpdated = now()
|
||||
WHERE
|
||||
T_FavoriteID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_favorite delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,482 @@
|
||||
<?php
|
||||
class Testfavorite extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Test Favorite API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$testname = $prm["testname"];
|
||||
$packetname = $prm["packetname"];
|
||||
$status = $prm["status"];
|
||||
|
||||
// echo $testname;
|
||||
|
||||
$sql_where = "WHERE T_FavoriteType = '{$status}' AND T_FavoriteIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($packetname != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_TestName like ? ";
|
||||
$sql_param[] = "%$packetname%";
|
||||
}
|
||||
if ($testname != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_PacketName like ? ";
|
||||
$sql_param[] = "%$testname%";
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " T_FavoriteIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_favorite
|
||||
LEFT JOIN t_test ON T_FavoriteT_TestID = T_TestID
|
||||
LEFT JOIN t_packet ON T_FavoriteT_PacketID = T_PacketID
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("t_favorite count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
t_favorite.*,
|
||||
CASE
|
||||
WHEN T_FavoriteType = 'PX' THEN 'Test'
|
||||
WHEN T_FavoriteType = 'PN' THEN 'Paket Panel'
|
||||
WHEN T_FavoriteType = 'PR' THEN 'Paket Profil' END as T_FavoriteTypeName,
|
||||
T_TestID,
|
||||
T_TestName,
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
IF(T_FavoriteIsPacket = 'Y','YA','TIDAK') as ispacket
|
||||
FROM t_favorite
|
||||
LEFT JOIN t_test ON T_FavoriteT_TestID = T_TestID
|
||||
LEFT JOIN t_packet ON T_FavoriteT_PacketID = T_PacketID
|
||||
$sql_where
|
||||
ORDER BY T_FavoriteID ASC
|
||||
limit 0,$tot_count";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
//$rows[$k]['verification_px'] = $this->add_verification_test($v['T_FavoriteID']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getsexreg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query ="SELECT 'Test' as T_FavoriteTypeName, 'PX' as T_FavoriteType
|
||||
UNION SELECT 'Paket Panel' as T_FavoriteTypeName, 'PN' as T_FavoriteType
|
||||
UNION SELECT 'Paket Profil' as T_FavoriteTypeName, 'PR' as T_FavoriteType
|
||||
";
|
||||
//echo $query;
|
||||
$rows['types'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
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_TestIsPrice = '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_TestIsPrice = 'Y'
|
||||
ORDER BY T_TestName DESC
|
||||
";
|
||||
$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;
|
||||
}
|
||||
}
|
||||
function searchpacket(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
$search = $prm["search"];
|
||||
$tipe = $prm["tipe"];
|
||||
$sql_where = "WHERE T_PacketIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($search != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_PacketName like ? ";
|
||||
$sql_param[] = "%$search%";
|
||||
}
|
||||
if ($tipe != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_PacketType like ? ";
|
||||
$sql_param[] = "%$tipe%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_packet
|
||||
$sql_where";
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("t_packet count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM t_packet
|
||||
$sql_where";
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
|
||||
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_packet rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getsubarea(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_subarea
|
||||
WHERE
|
||||
M_SubareaIsActive = 'Y' AND M_SubareaT_TestID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$ispacket = $prm['T_FavoriteIsPacket'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE t_favorite SET
|
||||
T_FavoriteType = '{$prm['T_FavoriteType']}',
|
||||
T_FavoriteT_TestID = '{$prm['T_FavoriteT_TestID']}',
|
||||
T_FavoriteT_PacketID = '{$prm['T_FavoriteT_PacketID']}',
|
||||
T_FavoriteIsPacket = '{$ispacket}',
|
||||
T_FavoriteUserID = '{$userid}',
|
||||
T_FavoriteLastUpdated = now()
|
||||
|
||||
WHERE
|
||||
T_FavoriteID = '{$prm['T_FavoriteID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newtestfavorite(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$ispacket = $prm['T_FavoriteIsPacket'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO t_favorite(
|
||||
T_FavoriteType,
|
||||
T_FavoriteT_TestID,
|
||||
T_FavoriteT_PacketID,
|
||||
T_FavoriteIsPacket,
|
||||
T_FavoriteUserID,
|
||||
T_FavoriteCreated,
|
||||
T_FavoriteLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['T_FavoriteType']}',
|
||||
'{$prm['T_FavoriteT_TestID']}',
|
||||
'{$prm['T_FavoriteT_PacketID']}',
|
||||
'{$ispacket}',
|
||||
'{$userid}',
|
||||
now(),
|
||||
now()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($rows){
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletetestfavorite(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="UPDATE t_favorite SET
|
||||
T_FavoriteIsActive = 'N'
|
||||
WHERE
|
||||
T_FavoriteID = '{$prm['T_FavoriteID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT t_favoriteaddress.*,
|
||||
M_KelurahanName,
|
||||
M_DistrictID,
|
||||
M_DistrictName,
|
||||
T_TestID,
|
||||
T_TestName,
|
||||
'' as action
|
||||
FROM t_favoriteaddress
|
||||
JOIN m_kelurahan ON T_FavoriteAddressM_KelurahanID = M_KelurahanID
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
JOIN t_test ON M_DistrictT_TestID = T_TestID
|
||||
WHERE
|
||||
T_FavoriteAddressIsActive = 'Y' AND T_FavoriteAddressT_FavoriteID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function savenewaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$count_addrs = $this->db_onedev->query("SELECT COUNT(*) as countx FROM t_favoriteaddress WHERE T_FavoriteAddressT_FavoriteID = '{$prm['T_FavoriteAddressT_FavoriteID']}' AND T_FavoriteAddressIsActive = 'Y'")->row()->countx;
|
||||
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($count_addrs == 0){
|
||||
$prm['T_FavoriteAddressNote'] = 'Utama';
|
||||
}
|
||||
else{
|
||||
$count_addrs_utama = $this->db_onedev->query("SELECT COUNT(*) as countx FROM t_favoriteaddress WHERE T_FavoriteAddressT_FavoriteID = '{$prm['T_FavoriteAddressT_FavoriteID']}' AND T_FavoriteAddressNote = 'Utama' AND T_FavoriteAddressIsActive = 'Y'")->row()->countx;
|
||||
if($count_addrs_utama > 0 && strtolower($prm['T_FavoriteAddressNote']) == 'utama'){
|
||||
$rx = date('YmdHis');
|
||||
$prm['T_FavoriteAddressNote'] = 'Utama_'.$rx;
|
||||
}
|
||||
}
|
||||
$query ="INSERT INTO t_favoriteaddress (
|
||||
T_FavoriteAddressT_FavoriteID,
|
||||
T_FavoriteAddressNote,
|
||||
T_FavoriteAddressDescription,
|
||||
T_FavoriteAddressM_KelurahanID,
|
||||
T_FavoriteAddressCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['T_FavoriteAddressT_FavoriteID']}',
|
||||
'{$prm['T_FavoriteAddressNote']}',
|
||||
'{$prm['T_FavoriteAddressDescription']}',
|
||||
'{$prm['T_FavoriteAddressM_KelurahanID']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE t_favoriteaddress SET
|
||||
T_FavoriteAddressT_FavoriteID = '{$prm['T_FavoriteAddressT_FavoriteID']}',
|
||||
T_FavoriteAddressNote = '{$prm['T_FavoriteAddressNote']}',
|
||||
T_FavoriteAddressDescription = '{$prm['T_FavoriteAddressDescription']}',
|
||||
T_FavoriteAddressM_KelurahanID = '{$prm['T_FavoriteAddressM_KelurahanID']}'
|
||||
WHERE
|
||||
T_FavoriteAddressID = '{$prm['T_FavoriteAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query ="UPDATE t_favoriteaddress SET
|
||||
T_FavoriteAddressIsActive = 'N'
|
||||
WHERE
|
||||
T_FavoriteAddressID = '{$prm['T_FavoriteAddressID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
589
one-api/application/controllers/mockup/masterdata/Testprice.php
Normal file
589
one-api/application/controllers/mockup/masterdata/Testprice.php
Normal file
@@ -0,0 +1,589 @@
|
||||
<?php
|
||||
class Testprice extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Test Price API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$code = $prm["code"];
|
||||
$nama = $prm["nama"];
|
||||
|
||||
// echo $norm;
|
||||
|
||||
$sql_where = "WHERE T_TestIsActive = 'Y' AND T_TestIsPrice = 'Y'";
|
||||
$sql_param = array();
|
||||
if ($code != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_TestCode like ? ";
|
||||
$sql_param[] = "%$code%";
|
||||
}
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " T_TestName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
|
||||
//if ($sql_where != "") $sql_where .= " and ";
|
||||
|
||||
// Order masih dalam status registrasi
|
||||
//$sql_where .= " M_PatientIsActive = 'Y' ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
$sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
$tot_count = 0;
|
||||
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
|
||||
$sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
limit 0,$tot_count";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function searchcompany(){
|
||||
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 m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y' AND M_CompanyIsLabFrom = '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("m_company count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y' AND M_CompanyIsLabFrom = 'Y'
|
||||
ORDER BY M_CompanyName DESC
|
||||
";
|
||||
$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("m_company rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getmou(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouIsActive = 'Y' AND M_MouM_CompanyID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getpricemoureg(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['companys'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$query =" SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['pricemous'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdob = date('Y-m-d',strtotime($prm['M_PatientDOB']));
|
||||
$query ="UPDATE m_patient SET
|
||||
M_PatientM_TitleID = '{$prm['M_PatientM_TitleID']}',
|
||||
M_PatientName = '{$prm['M_PatientName']}',
|
||||
M_PatientDOB = '{$pdob}',
|
||||
M_PatientM_SexID = '{$prm['M_PatientM_SexID']}',
|
||||
M_PatientM_ReligionID = '{$prm['M_PatientM_ReligionID']}',
|
||||
M_PatientEmail = '{$prm['M_PatientEmail']}',
|
||||
M_PatientHP = '{$prm['M_PatientHP']}',
|
||||
M_PatientPhone = '{$prm['M_PatientPhone']}',
|
||||
M_PatientM_IdTypeID = '{$prm['M_PatientM_IdTypeID']}',
|
||||
M_PatientIDNumber = '{$prm['M_PatientIDNumber']}',
|
||||
M_PatientNote = '{$prm['M_PatientNote']}'
|
||||
WHERE
|
||||
M_PatientID = '{$prm['M_PatientID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newreceivereference(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdate = date('Y-m-d',strtotime($prm['sdate']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestM_CompanyID,
|
||||
T_TestM_MouID,
|
||||
T_TestDate,
|
||||
T_TestNote,
|
||||
T_TestUserID,
|
||||
T_TestCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['companyid']}',
|
||||
'{$prm['mouid']}',
|
||||
'{$pdate}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogT_TestID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$last_id}',
|
||||
'1',
|
||||
'{$userid}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $querylog;
|
||||
$insert_new_log = $this->db_onedev->query($querylog);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function sendorder(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$query ="UPDATE t_test SET
|
||||
T_TestIsSent = 'Y',
|
||||
T_TestSentDate = now(),
|
||||
T_TestUserID = '{$userid}'
|
||||
WHERE
|
||||
T_TestID = '{$prm['T_TestID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogT_TestID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$prm['T_TestID']}',
|
||||
'2',
|
||||
'{$userid}',
|
||||
'{$userid}',
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $querylog;
|
||||
$insert_new_log = $this->db_onedev->query($querylog);
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function getpricemou(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT t_price.*,
|
||||
IF(T_PriceIsCito = 'Y','Ya','Tidak') as T_PriceIsCito,
|
||||
T_TestID,
|
||||
T_TestName,
|
||||
M_CompanyID,
|
||||
M_CompanyName,
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
M_MouStartDate,
|
||||
M_MouEndDate,
|
||||
FORMAT(T_PriceTotal,0) as T_PriceTotal,
|
||||
CONCAT(DATE_FORMAT(M_MouStartDate,'%d-%m-%Y'),' s/d ',DATE_FORMAT(M_MouEndDate,'%d-%m-%Y')) as periode,
|
||||
'' as action
|
||||
FROM t_price
|
||||
JOIN t_test ON T_PriceT_TestID = T_TestID
|
||||
JOIN m_company ON T_PriceM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_PriceM_MouID = M_MouID AND (date(now()) BETWEEN M_MouStartDate AND M_MouEndDate) AND M_MouIsActive = 'Y'
|
||||
WHERE
|
||||
T_TestID = ?
|
||||
GROUP BY T_PriceID
|
||||
ORDER BY T_PricePriority ASC
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
if($rows){
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function add_day($testid,$methodeid){
|
||||
$query =" SELECT m_methode_priority.*,IFNULL(M_MethodePriorityNumber,0) as M_MethodePriorityNumber, m_dayofweek.*,IF(M_MethodePriorityID IS NULL,'N','Y') as isday, IFNULL(M_MethodePriorityNat_MethodeID,0) as xid
|
||||
FROM m_dayofweek
|
||||
JOIN t_test ON T_TestID = '{$testid}'
|
||||
JOIN nat_normalvalue ON T_TestID = Nat_NormalValueT_TestID AND Nat_NormalValueNat_MethodeID = '{$methodeid}'
|
||||
JOIN nat_methode ON Nat_NormalValueNat_MethodeID = Nat_MethodeID
|
||||
LEFT JOIN m_methode_priority ON T_TestID = M_MethodePriorityT_TestID AND Nat_MethodeID = M_MethodePriorityNat_MethodeID AND M_DayOfWeekID = M_MethodePriorityM_DayOfWeekID AND M_MethodePriorityIsActive = 'Y'
|
||||
GROUP BY M_DayOfWeekID";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function savenewmethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach($prm['orderdays'] as $k=>$v){
|
||||
$query = "INSERT INTO m_methode_priority (
|
||||
M_MethodePriorityM_MethodePriorityID,
|
||||
M_MethodePriorityT_TestID,
|
||||
M_MethodePriorityT_TestCode,
|
||||
M_MethodePriorityT_TestName,
|
||||
M_MethodePriorityT_TestPrice,
|
||||
M_MethodePriorityT_TestDisc,
|
||||
M_MethodePriorityT_TestDiscRp,
|
||||
M_MethodePriorityT_TestTotal,
|
||||
M_MethodePriorityUserID,
|
||||
M_MethodePriorityCreated,
|
||||
M_MethodePriorityLastUpdated
|
||||
)
|
||||
VALUE(
|
||||
?,?,?,?,?,?,?,?,?, now(),now()
|
||||
)";
|
||||
$insert_new_test = $this->db_onedev->query($query,array(
|
||||
$orderpatient_id,
|
||||
$v['T_TestID'],
|
||||
$v['T_TestCode'],
|
||||
$v['T_TestName'],
|
||||
$v['T_PriceAmount'],
|
||||
$v['T_PriceDisc'],
|
||||
$v['T_PriceDiscRp'],
|
||||
$v['total'],
|
||||
$userid
|
||||
));
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditmethode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$test_id = $prm['M_MethodePriorityT_TestID'];
|
||||
$methode_id = $prm['M_MethodePriorityNat_MethodeID'];
|
||||
$priority = $prm['M_MethodePriorityNumber'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
foreach($prm['orderdays'] as $k=>$v){
|
||||
if(($v['xid'] == 0 || $v['xid'] == '0') && ($v['isday'] === 'Y')){
|
||||
$query = "INSERT INTO m_methode_priority(
|
||||
M_MethodePriorityT_TestID,
|
||||
M_MethodePriorityNat_MethodeID,
|
||||
M_MethodePriorityM_DayOfWeekID,
|
||||
M_MethodePriorityNumber,
|
||||
M_MethodePriorityUserID,
|
||||
M_MethodePriorityCreated,
|
||||
M_MethodePriorityLastUpdated
|
||||
)
|
||||
VALUE(
|
||||
?,?,?,?,?,now(),now()
|
||||
)";
|
||||
$insert_methode = $this->db_onedev->query($query,array(
|
||||
$test_id,
|
||||
$methode_id,
|
||||
$v['M_DayOfWeekID'],
|
||||
$priority,
|
||||
$userid
|
||||
));
|
||||
}elseif($v['xid'] > 0 && $v['isday'] === 'N'){
|
||||
$queryupdate ="UPDATE m_methode_priority SET
|
||||
M_MethodePriorityIsActive = 'N',
|
||||
M_MethodePriorityUserID = '{$userid}',
|
||||
M_MethodePriorityLastUpdated = now()
|
||||
WHERE
|
||||
M_MethodePriorityID = ?
|
||||
";
|
||||
// echo $queryupdate;
|
||||
$update_methode = $this->db_onedev->query($queryupdate,array($v['M_MethodePriorityID'],));
|
||||
// echo $update_methode;
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_methode_priority SET
|
||||
M_MethodePriorityNumber = '{$priority}',
|
||||
M_MethodePriorityUserID = '{$userid}',
|
||||
M_MethodePriorityLastUpdated = now()
|
||||
WHERE
|
||||
M_MethodePriorityID = ?
|
||||
";
|
||||
// echo $queryupdate;
|
||||
$update_methode = $this->db_onedev->query($queryupdate,array($v['M_MethodePriorityID'],));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletepatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE t_receivereferencepatient SET
|
||||
M_MethodePriorityIsActive = 'N',
|
||||
M_MethodePriorityUserID = '{$userid}'
|
||||
WHERE
|
||||
M_MethodePriorityID = '{$prm['M_MethodePriorityID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$query ="UPDATE m_methode_priority SET
|
||||
M_MethodePriorityIsActive = 'N',
|
||||
M_MethodePriorityUserID = '{$userid}'
|
||||
WHERE
|
||||
M_MethodePriorityM_MethodePriorityID = '{$prm['M_MethodePriorityID']}' AND M_MethodePriorityIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function searchtest(){
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
$mou_id = $prm['mouid'];
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_test
|
||||
JOIN t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
||||
WHERE
|
||||
T_TestName like ? AND
|
||||
T_TestIsActive = 'Y'
|
||||
ORDER BY T_TestName ASC";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("test count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT 'Y' as editable, 0 as xid, T_TestID, T_TestCode, T_TestName, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceAmount - ((T_PriceDisc/100) * T_PriceAmount) - T_PriceDiscRp as total,
|
||||
M_CompanyID,'N' as M_CompanyIsBill, 0 as M_CompanyMinDP
|
||||
FROM one_lis_dev.t_test
|
||||
JOIN one_lis_dev.t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
|
||||
JOIN one_lis_dev.m_mou ON M_MouID = '{$mou_id}'
|
||||
JOIN one_lis_dev.m_company ON M_MouM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
T_TestName like ? AND
|
||||
T_TestIsActive = '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("test rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,550 @@
|
||||
<?php
|
||||
|
||||
class Testrequirement extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "TEST REQUIREMENT API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function lookuptest(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$sql = "select Nat_TestRequirementID as id,
|
||||
Nat_TestRequirementNat_RequirementID as requirementid,
|
||||
Nat_TestRequirementNat_TestID as testid,
|
||||
Nat_TestID,
|
||||
Nat_TestName,
|
||||
Nat_TestName as name,
|
||||
'xxx' as action
|
||||
from nat_testrequirement
|
||||
LEFT JOIN nat_test ON Nat_TestRequirementNat_TestID = Nat_TestID
|
||||
where
|
||||
Nat_TestRequirementNat_RequirementID = {$id} AND Nat_TestRequirementIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$sql = "select COUNT(*) as total
|
||||
from nat_requirement
|
||||
where
|
||||
Nat_RequirementIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_onedev->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select Nat_RequirementID as id, Nat_RequirementName as name,Nat_RequirementName as description,
|
||||
'xxx' as test
|
||||
from nat_requirement
|
||||
where
|
||||
( Nat_RequirementName LIKE CONCAT('%','{$search}','%')
|
||||
)AND
|
||||
Nat_RequirementIsActive = 'Y' $limit";
|
||||
$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("nat_requirement select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function addnewrequirement()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name_requirement = $prm['name'];
|
||||
$sqlrequirement = "insert into nat_requirement(
|
||||
Nat_RequirementName
|
||||
Nat_RequirementCreated,
|
||||
Nat_RequirementLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$queryrequirement = $this->db_onedev->query($sqlrequirement,
|
||||
array(
|
||||
$name_requirement
|
||||
)
|
||||
);
|
||||
echo $query;
|
||||
if (!$queryrequirement) {
|
||||
$this->sys_error_db("nat_requirement insert");
|
||||
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 editrequirement()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id_requirement = $prm['id'];
|
||||
$name_requirement = $prm['name'];
|
||||
$sqlrequirement = "update nat_requirement SET
|
||||
Nat_RequirementName = ?,
|
||||
Nat_RequirementLastUpdated = now()
|
||||
where
|
||||
Nat_RequirementID = ?
|
||||
";
|
||||
$queryrequirement = $this->db_onedev->query($sqlrequirement,
|
||||
array(
|
||||
$name_requirement,
|
||||
$id_requirement
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$queryrequirement) {
|
||||
$this->sys_error_db("nat_requirement update");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => $id_requirement));
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function addnewtest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$requirementid = $prm['requirementid'];
|
||||
$testid = $prm['testid'];
|
||||
|
||||
|
||||
if($prm['xid'] == "0" || $prm['xid'] == 0){
|
||||
$sql = "insert into nat_testrequirement(
|
||||
Nat_TestRequirementNat_RequirementID,
|
||||
Nat_TestRequirementNat_TestID,
|
||||
Nat_TestRequirementLastUpdated
|
||||
)
|
||||
values( ?,?,now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$requirementid,
|
||||
$testid
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_testrequirement insert");
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}else{
|
||||
|
||||
$testid = $prm['testid'];
|
||||
$sql = "UPDATE nat_testrequirement SET Nat_TestRequirementNat_TestID = '{$testid}'";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function deletetest()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_testrequirement SET
|
||||
Nat_TestRequirementIsActive = 'N',
|
||||
Nat_TestRequirementLastUpdated = now()
|
||||
WHERE
|
||||
Nat_TestRequirementID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_testrequirement 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 deleterequirement()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "update nat_requirement SET
|
||||
Nat_RequirementIsActive = 'N',
|
||||
Nat_RequirementLastUpdated = now()
|
||||
WHERE
|
||||
Nat_RequirementID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_requirement delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE nat_testrequirement SET
|
||||
Nat_TestRequirementIsActive = 'N',
|
||||
Nat_TestRequirementLastUpdated = now()
|
||||
WHERE
|
||||
Nat_TestRequirementNat_RequirementID = ?
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_testrequirement 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 selectrequirementtype(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_requirementtype
|
||||
WHERE
|
||||
Nat_RequirementTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['requirementtypes'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function selectdoctor(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_doctor
|
||||
WHERE
|
||||
M_DoctorIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['doctors'] = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
function searchdoctor(){
|
||||
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 m_doctor
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
AND M_DoctorIsActive = '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("m_doctor count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT * FROM(SELECT *, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorNames
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorNames like ?
|
||||
AND M_DoctorIsActive = 'Y'
|
||||
ORDER BY M_DoctorName DESC
|
||||
";
|
||||
$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("m_doctor rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcity(){
|
||||
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 m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = '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("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName DESC
|
||||
";
|
||||
$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("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function getdistrict(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictIsActive = 'Y' AND M_DistrictM_CityID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkelurahan(){
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanIsActive = 'Y' AND M_KelurahanM_DistrictID = ?
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query,array($prm['id']))->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
219
one-api/application/controllers/mockup/masterdata/Typefpp.php
Normal file
219
one-api/application/controllers/mockup/masterdata/Typefpp.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
class Typefpp extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
var $load;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db_onedev->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "MASTER Type Fpp";
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$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 m_fpp_type
|
||||
WHERE M_FppTypeIsActive ='Y'
|
||||
AND (M_FppTypeName LIKE ?)";
|
||||
$qry_tot = $this->db_onedev->query($sql_tot, [$search]);
|
||||
$last_qry = $this->db_onedev->last_query();
|
||||
$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->db_onedev->trans_rollback();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("type FPP count error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_FppTypeID,
|
||||
'' as rownumber,
|
||||
M_FppTypeName,
|
||||
M_FppTypeUserID,
|
||||
M_FppTypeCreated
|
||||
FROM m_fpp_type
|
||||
WHERE M_FppTypeIsActive ='Y'
|
||||
AND (M_FppTypeName LIKE ?)
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db_onedev->query($sql, [$search, $number_limit, $number_offset]);;
|
||||
$last_qry = $this->db_onedev->last_query();
|
||||
// echo $last_qry;
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$message = $this->db_onedev->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("type FPP select error", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
|
||||
foreach ($rows as $k => $v) {
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
}
|
||||
$result = array(
|
||||
"total_page" => $tot_page,
|
||||
"total" => $tot_count,
|
||||
"records" => $rows,
|
||||
"last_qry" => $last_qry
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addnewtypefpp()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$xname = $prm['xname'];
|
||||
|
||||
$sql = "INSERT INTO m_fpp_type(
|
||||
M_FppTypeName,
|
||||
M_FppTypeIsActive,
|
||||
M_FppTypeUserID,
|
||||
M_FppTypeCreated,
|
||||
M_FppTypeLastUpdated) VALUES(?,'Y',?,NOW(),NOW())";
|
||||
$qry = $this->db_onedev->query($sql, [$xname, $userid]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("type Fpp insert", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$rst = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($rst);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function updatetypefpp()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$xname = $prm['xname'];
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "UPDATE m_fpp_type SET
|
||||
M_FppTypeName = ?,
|
||||
M_FppTypeUserID = ?,
|
||||
M_FppTypeLastUpdated = NOW()
|
||||
WHERE M_FppTypeID = ?";
|
||||
$qry = $this->db_onedev->query($sql, [
|
||||
$xname,
|
||||
$userid,
|
||||
$id
|
||||
]);
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("type FPP update", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$rst = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($rst);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletetypefpp()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db_onedev->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$id = $prm["id"];
|
||||
|
||||
$sql = "UPDATE m_fpp_type SET
|
||||
M_FppTypeIsActive = 'N',
|
||||
M_FppTypeUserID = ?,
|
||||
M_FppTypeLastUpdated = NOW()
|
||||
WHERE M_FppTypeID = ?";
|
||||
$qry = $this->db_onedev->query($sql, [
|
||||
$userid,
|
||||
$id
|
||||
]);
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("type FPP delete", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db_onedev->trans_commit();
|
||||
$rst = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($rst);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,709 @@
|
||||
<?php
|
||||
class Conclusion extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "NON LAB CONCLUSION API";
|
||||
}
|
||||
|
||||
public 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_conclusion
|
||||
WHERE NonlabConclusionIsActive = 'Y'
|
||||
AND (NonlabConclusionName 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 conclusion count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT NonlabConclusionID,
|
||||
NonlabConclusionName,
|
||||
NonlabConclusionIsActive,
|
||||
NonlabConclusionCreated,
|
||||
NonlabConclusionCreatedUserID
|
||||
FROM nonlab_conclusion
|
||||
WHERE NonlabConclusionIsActive = 'Y'
|
||||
AND (NonlabConclusionName LIKE ?)
|
||||
ORDER BY NonlabConclusionID 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 conclusion", $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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_conclusion(
|
||||
NonlabConclusionName,
|
||||
NonlabConclusionIsActive,
|
||||
NonlabConclusionCreated,
|
||||
NonlabConclusionCreatedUserID,
|
||||
NonlabConclusionLastUpdated,
|
||||
NonlabConclusionLastUpdatedUserID) VALUES(?,'Y',NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_conclusion
|
||||
SET NonlabConclusionName = ?,
|
||||
NonlabConclusionLastUpdated = NOW(),
|
||||
NonlabConclusionLastUpdatedUserID = ?
|
||||
WHERE NonlabConclusionID = ?";
|
||||
$qry = $this->db->query($sql, array($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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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_conclusion
|
||||
SET NonlabConclusionIsActive = 'N',
|
||||
NonlabConclusionDelete = NOW(),
|
||||
NonlabConclusionDeleteUserID = ?
|
||||
WHERE NonlabConclusionID = ?";
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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_conclusion_detail
|
||||
WHERE NonlabConclusionDetailNonlabConclusionID = ?
|
||||
AND NonlabConclusionDetailIsActive = 'Y'
|
||||
AND (NonlabConclusionDetailCode LIKE ? OR NonlabConclusionDetailName 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 conclusion detail count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT NonlabConclusionDetailID,
|
||||
NonlabConclusionDetailNonlabConclusionID,
|
||||
NonlabConclusionDetailCode,
|
||||
NonlabConclusionDetailName,
|
||||
NonlabConclusionDetailIsNormal,
|
||||
NonlabConclusionDetailFlagActive,
|
||||
NonlabConclusionDetaiM_LangID,
|
||||
NonlabConclusionDetailIsActive,
|
||||
NonlabConclusionDetailCreated
|
||||
FROM nonlab_conclusion_detail
|
||||
WHERE NonlabConclusionDetailNonlabConclusionID = ?
|
||||
AND NonlabConclusionDetailIsActive = 'Y'
|
||||
AND (NonlabConclusionDetailCode LIKE ? OR NonlabConclusionDetailName 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 conclusion 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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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"]);
|
||||
}
|
||||
$isnormal = "";
|
||||
if (isset($prm["isnormal"])) {
|
||||
$isnormal = trim($prm["isnormal"]);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO nonlab_conclusion_detail(
|
||||
NonlabConclusionDetailNonlabConclusionID,
|
||||
NonlabConclusionDetailCode,
|
||||
NonlabConclusionDetailName,
|
||||
NonlabConclusionDetailIsNormal,
|
||||
NonlabConclusionDetailIsActive,
|
||||
NonlabConclusionDetailCreated,
|
||||
NonlabConclusionDetailCreatedUserID,
|
||||
NonlabConclusionDetailLastUpdated,
|
||||
NonlabConclusionDetailLastUpdatedUserID) VALUES(?,?,?,?,'Y',NOW(),?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$nonlabid,
|
||||
$code,
|
||||
$name,
|
||||
$isnormal,
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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"]);
|
||||
}
|
||||
$isnormal = "";
|
||||
if (isset($prm["isnormal"])) {
|
||||
$isnormal = trim($prm["isnormal"]);
|
||||
}
|
||||
$id = "";
|
||||
if (isset($prm["id"])) {
|
||||
$id = trim($prm["id"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE nonlab_conclusion_detail SET
|
||||
NonlabConclusionDetailCode = ?,
|
||||
NonlabConclusionDetailName = ?,
|
||||
NonlabConclusionDetailIsNormal = ?,
|
||||
NonlabConclusionDetailLastUpdated = NOW(),
|
||||
NonlabConclusionDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabConclusionDetailID = ?";
|
||||
$qry = $this->db->query($sql, array($code, $name, $isnormal, $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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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'];
|
||||
$conclusionid = $prm['conclusionid'];
|
||||
|
||||
if ($flagstatus == "Y") {
|
||||
$sql = "UPDATE nonlab_conclusion_detail
|
||||
SET NonlabConclusionDetailFlagActive = 'Y',
|
||||
NonlabConclusionDetailLastUpdated = NOW(),
|
||||
NonlabConclusionDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabConclusionDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$conclusionid
|
||||
));
|
||||
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab conclusion 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_conclusion_detail
|
||||
SET NonlabConclusionDetailFlagActive = 'N',
|
||||
NonlabConclusionDetailLastUpdated = NOW(),
|
||||
NonlabConclusionDetailLastUpdatedUserID = ?
|
||||
WHERE NonlabConclusionDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$conclusionid
|
||||
));
|
||||
|
||||
// echo $this->db->last_query();
|
||||
// exit;
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("nonlab conclusion 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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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_conclusion_detail
|
||||
SET NonlabConclusionDetailIsActive = 'N',
|
||||
NonlabConclusionDetailDelete = NOW(),
|
||||
NonlabConclusionDetailDeleteUserID = ?
|
||||
WHERE NonlabConclusionDetailID = ?";
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
public 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 = "%%";
|
||||
}
|
||||
}
|
||||
|
||||
$conclusionid = 0;
|
||||
if (isset($prm['conclusionid'])) {
|
||||
$conclusionid = trim($prm["conclusionid"]);
|
||||
}
|
||||
$status = $prm['status'];
|
||||
$filter = '';
|
||||
if ($status == 'Y') {
|
||||
$filter .= "AND ncm.NonlabConclusionMappingNonlabConclusionID IS NOT NULL ";
|
||||
} else {
|
||||
if ($status == 'N') {
|
||||
$filter .= "AND ncm.NonlabConclusionMappingNonlabConclusionID 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(ncm.NonlabConclusionMappingNonlabConclusionID IS NULL, 'N', 'Y') AS status,
|
||||
ncm.NonlabConclusionMappingNat_TestID,
|
||||
n.Nat_TestCode,
|
||||
n.Nat_TestName,
|
||||
n.Nat_TestShortName
|
||||
FROM
|
||||
nat_test AS n
|
||||
LEFT JOIN
|
||||
nonlab_conclusion_mapping AS ncm
|
||||
ON n.Nat_TestID = ncm.NonlabConclusionMappingNat_TestID
|
||||
AND ncm.NonlabConclusionMappingIsActive = 'Y'
|
||||
LEFT JOIN
|
||||
nonlab_conclusion AS nc
|
||||
ON ncm.NonlabConclusionMappingNonlabConclusionID = nc.NonlabConclusionID
|
||||
AND NonlabConclusionIsActive = '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 (nc.NonlabConclusionID = {$conclusionid} OR nc.NonlabConclusionID 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);
|
||||
}
|
||||
}
|
||||
|
||||
public function saveedittestmap()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$conclusionid = 0;
|
||||
if (isset($prm['conclusionid'])) {
|
||||
$conclusionid = trim($prm["conclusionid"]);
|
||||
}
|
||||
$test_id = 0;
|
||||
if (isset($prm['test_id'])) {
|
||||
$test_id = trim($prm["test_id"]);
|
||||
}
|
||||
|
||||
$status = $prm["status"];
|
||||
|
||||
$sql = "SELECT NonlabConclusionMappingID,
|
||||
NonlabConclusionMappingNonlabConclusionID,
|
||||
NonlabConclusionMappingNat_TestID
|
||||
FROM nonlab_conclusion_mapping
|
||||
WHERE NonlabConclusionMappingNonlabConclusionID = ?
|
||||
AND NonlabConclusionMappingNat_TestID = ?";
|
||||
$qry = $this->db->query($sql, [$conclusionid, $test_id]);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("nonlab template error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($rows) > 0) {
|
||||
$nonlabconclusionmapid = $rows[0]["NonlabConclusionMappingID"];
|
||||
$sql_update = "UPDATE nonlab_conclusion_mapping SET
|
||||
NonlabConclusionMappingLastUpdated = NOW(),
|
||||
NonlabConclusionMappingLastUpdatedUserID = ?,
|
||||
NonlabConclusionMappingDeleted = NOW(),
|
||||
NonlabConclusionMappingIsActive = ?
|
||||
WHERE NonlabConclusionMappingID = ?";
|
||||
$qry_update = $this->db->query($sql_update, [$userid, $status, $nonlabconclusionmapid]);
|
||||
if (!$qry_update) {
|
||||
$this->sys_error_db("map test update", $this->db);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql_insert = "INSERT INTO nonlab_conclusion_mapping(
|
||||
NonlabConclusionMappingNonlabConclusionID,
|
||||
NonlabConclusionMappingNat_TestID,
|
||||
NonlabConclusionMappingCreated,
|
||||
NonlabConclusionMappingCreatedUserID,
|
||||
NonlabConclusionMappingIsActive) VALUES(?,?,NOW(),?,'Y')";
|
||||
$qry_insert = $this->db->query($sql_insert, [$conclusionid, $test_id, $userid]);
|
||||
if (!$qry_insert) {
|
||||
$this->sys_error_db("nonlab_conclusion_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
<?php
|
||||
|
||||
class Fisiktemplate extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$current_method = $this->router->fetch_method();
|
||||
$excluded_methods = ['index'];
|
||||
|
||||
if (!in_array($current_method, $excluded_methods)) {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Fisik Template Api";
|
||||
}
|
||||
|
||||
public function fisikTemplateMappingList()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$fisikname = isset($prm['fisikname']) ? $prm['fisikname'] : '';
|
||||
$current_page = isset($prm['current_page']) ? (int) $prm['current_page'] : 1;
|
||||
$status = isset($prm['status']) ? $prm['status'] : null;
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($current_page - 1) * $number_limit;
|
||||
|
||||
try {
|
||||
$this->db->select('FisikTemplateMappingID');
|
||||
$this->db->from('fisik_template_mapping');
|
||||
$this->db->where('FisikTemplateMappingIsActive', 'Y');
|
||||
$this->db->like('FisikTemplateMappingName', $fisikname);
|
||||
$this->db->group_by('FisikTemplateMappingID');
|
||||
$count_query = $this->db->get();
|
||||
|
||||
if (!$count_query) {
|
||||
$this->sys_error_db("fisik_template_mapping count", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
$tot_count = $count_query->num_rows();
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
|
||||
$this->db->select('FisikTemplateMappingID as id, FisikTemplateMappingID, FisikTemplateMappingName');
|
||||
$this->db->from('fisik_template_mapping');
|
||||
$this->db->where('FisikTemplateMappingIsActive', 'Y');
|
||||
$this->db->like('FisikTemplateMappingName', $fisikname);
|
||||
$this->db->group_by('FisikTemplateMappingID');
|
||||
$this->db->order_by('FisikTemplateMappingName', 'ASC');
|
||||
$this->db->limit($number_limit, $number_offset);
|
||||
$query = $this->db->get();
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fisik_template_mapping select", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$this->sys_ok([
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows
|
||||
]);
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
function addFisikTemplateMapping()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = isset($this->sys_user['M_UserID']) ? $this->sys_user['M_UserID'] : null;
|
||||
$name = isset($prm['name']) ? trim($prm['name']) : '';
|
||||
$nat_test_id = isset($prm['nat_test_id']) ? $prm['nat_test_id'] : null;
|
||||
|
||||
if (empty($name)) {
|
||||
$this->sys_error("Nama fisik tidak boleh kosong.");
|
||||
return;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
try {
|
||||
$insert = $this->db->insert('fisik_template_mapping', [
|
||||
'FisikTemplateMappingName' => $name,
|
||||
'FisikTemplateMappingCreated' => date('Y-m-d H:i:s'),
|
||||
'FisikTemplateMappingCreatedUserID' => $userid,
|
||||
'FisikTemplateMappingLastUpdated' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
if (!$insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("save fisik_template_mapping error", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
$last_id = $this->db->insert_id();
|
||||
|
||||
/*$sql = "UPDATE fisik_map_test_template
|
||||
SET Fisik_MapTestTemplateIsActive = 'N',
|
||||
Fisik_MapTestTemplateDeleted = NOW(),
|
||||
Fisik_MapTestTemplateDeletedUserID = ?
|
||||
WHERE
|
||||
Fisik_MapTestTemplateNat_TestID = ? AND
|
||||
Fisik_MapTestTemplateIsActive = 'Y'";
|
||||
$this->db->query($sql, [$nat_test_id, $userid]);
|
||||
|
||||
$sql = "INSERT INTO fisik_map_test_template (
|
||||
Fisik_MapTestTemplateFisikTemplateMappingID,
|
||||
Fisik_MapTestTemplateNat_TestID,
|
||||
Fisik_MapTestTemplateCreated,
|
||||
Fisik_MapTestTemplateCreatedUserID,
|
||||
Fisik_MapTestTemplateIsActive)
|
||||
VALUES (?, ?, ?, ?, 'Y')";
|
||||
$this->db->query($sql, [$last_id, $nat_test_id, date('Y-m-d H:i:s'), $userid]);*/
|
||||
|
||||
$this->db->trans_commit();
|
||||
|
||||
$this->sys_ok([
|
||||
"total" => 1,
|
||||
"affected_rows" => $this->db->affected_rows()
|
||||
]);
|
||||
} catch (Exception $exc) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error($exc->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function searchNatTest()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = isset($prm['search_nat_test']) ? $prm['search_nat_test'] : '';
|
||||
$filter_status = isset($prm['filter_status']) ? $prm['filter_status'] : null;
|
||||
$q_join = "";
|
||||
$and_isnull = "";
|
||||
$id = isset($prm['id']) ? $prm['id'] : null;
|
||||
if ($id == null) {
|
||||
$this->sys_error("Anda belum memilih template fisik.");
|
||||
exit;
|
||||
}
|
||||
if ($filter_status['value'] == 'Y') {
|
||||
$q_join = "JOIN fisik_map_test_template template_status ON Nat_TestID = template_status.Fisik_MapTestTemplateNat_TestID AND
|
||||
template_status.Fisik_MapTestTemplateFisikTemplateMappingID = ? AND
|
||||
template_status.Fisik_MapTestTemplateIsActive = 'Y'";
|
||||
} else {
|
||||
$q_join = "LEFT JOIN fisik_map_test_template template_status ON Nat_TestID = template_status.Fisik_MapTestTemplateNat_TestID AND
|
||||
template_status.Fisik_MapTestTemplateFisikTemplateMappingID = ? AND
|
||||
template_status.Fisik_MapTestTemplateIsActive = 'Y'
|
||||
LEFT JOIN fisik_map_test_template template_other ON Nat_TestID = template_other.Fisik_MapTestTemplateNat_TestID AND
|
||||
template_other.Fisik_MapTestTemplateIsActive = 'Y'";
|
||||
$and_isnull = "AND template_other.Fisik_MapTestTemplateID IS NULL";
|
||||
}
|
||||
|
||||
try {
|
||||
$sql = "SELECT nat_test.*, IF(template_status.Fisik_MapTestTemplateID IS NOT NULL, 'Y', 'N') AS status
|
||||
FROM nat_test
|
||||
$q_join
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestName LIKE CONCAT('%', ?, '%')
|
||||
AND Nat_TestIsActive = 'Y' $and_isnull
|
||||
ORDER BY Nat_TestName ASC
|
||||
LIMIT 25";
|
||||
$query = $this->db->query($sql, [$id, $search]);
|
||||
// echo $this->db->last_query();
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("nat_test select", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
$this->sys_ok([
|
||||
"total" => count($rows),
|
||||
"records" => $rows
|
||||
]);
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function findFisikTemplate()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$id = isset($prm['id']) ? (int) $prm['id'] : 0;
|
||||
$name = isset($prm['name']) ? $prm['name'] : '';
|
||||
$current_page = isset($prm['current_page']) ? (int) $prm['current_page'] : 1;
|
||||
$status = isset($prm['status']) ? $prm['status'] : null;
|
||||
$q_join = "";
|
||||
$and_isnull = "";
|
||||
if ($status == 'N') {
|
||||
$q_join = "LEFT JOIN fisik_template_mapping_detail template_status ON
|
||||
FisikTemplateID = template_status.FisikTemplateMappingDetailFisikTemplateID AND
|
||||
template_status.FisikTemplateMappingDetailFisikTemplateMappingID = ? AND
|
||||
template_status.FisikTemplateMappingDetailIsActive = 'Y'";
|
||||
$and_isnull = "AND template_status.FisikTemplateMappingDetailID IS NULL";
|
||||
} else {
|
||||
$q_join = "JOIN fisik_template_mapping_detail template_status ON
|
||||
FisikTemplateID = template_status.FisikTemplateMappingDetailFisikTemplateID AND
|
||||
template_status.FisikTemplateMappingDetailFisikTemplateMappingID = ? AND
|
||||
template_status.FisikTemplateMappingDetailIsActive = 'Y'";
|
||||
}
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($current_page - 1) * $number_limit;
|
||||
|
||||
try {
|
||||
$count_sql = "
|
||||
SELECT COUNT(*) AS total FROM (
|
||||
SELECT FisikTemplateID
|
||||
FROM fisik_template
|
||||
$q_join
|
||||
WHERE ( FisikTemplateCode LIKE ?
|
||||
OR FisikTemplateTitle LIKE ? )
|
||||
$and_isnull
|
||||
GROUP BY FisikTemplateID
|
||||
) AS x
|
||||
";
|
||||
|
||||
$count_query = $this->db->query($count_sql, [
|
||||
$id,
|
||||
"%$name%",
|
||||
"%$name%"
|
||||
]);
|
||||
|
||||
if (!$count_query || $count_query->num_rows() == 0) {
|
||||
$this->sys_error_db("fisik_template count", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
$tot_count = $count_query->row()->total;
|
||||
$tot_page = ceil($tot_count / $number_limit);
|
||||
|
||||
$data_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
|
||||
$q_join
|
||||
WHERE FisikTemplateIsActive = 'Y'
|
||||
AND ( FisikTemplateCode LIKE ?
|
||||
OR FisikTemplateTitle LIKE ? )
|
||||
$and_isnull
|
||||
GROUP BY FisikTemplateID
|
||||
ORDER BY FisikTemplateCode ASC
|
||||
LIMIT ? OFFSET ?
|
||||
";
|
||||
|
||||
$query = $this->db->query($data_sql, [
|
||||
$id,
|
||||
"%$name%",
|
||||
"%$name%",
|
||||
$number_limit,
|
||||
$number_offset
|
||||
]);
|
||||
|
||||
//echo $this->db->last_query();
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fisik_template select", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $key => $value) {
|
||||
$rows[$key]['xjson'] = json_decode($value['xjson']);
|
||||
}
|
||||
|
||||
$result = [
|
||||
"total" => $tot_page,
|
||||
"total_filter" => count($rows),
|
||||
"records" => $rows
|
||||
];
|
||||
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function saveAddFisikTemplateMappingDetail()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$mappingdetailid = isset($prm['FisikTemplateMappingDetailID']) ? $prm['FisikTemplateMappingDetailID'] : null;
|
||||
$templatemappingID = isset($prm['templatemappingID']) ? $prm['templatemappingID'] : null;
|
||||
$templateID = isset($prm['FisikTemplateID']) ? $prm['FisikTemplateID'] : null;
|
||||
$status = isset($prm['status']) ? $prm['status'] : null;
|
||||
$userid = isset($this->sys_user["M_UserID"]) ? $this->sys_user["M_UserID"] : null;
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
try {
|
||||
if ($status === 'Y') {
|
||||
$data = [
|
||||
'FisikTemplateMappingDetailFisikTemplateMappingID' => $templatemappingID,
|
||||
'FisikTemplateMappingDetailFisikTemplateID' => $templateID,
|
||||
'FisikTemplateMappingDetailCreated' => date('Y-m-d H:i:s'),
|
||||
'FisikTemplateMappingDetailCreatedUserID' => $userid,
|
||||
'FisikTemplateMappingDetailLastUpdated' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
|
||||
$insert = $this->db->insert('fisik_template_mapping_detail', $data);
|
||||
|
||||
if (!$insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("fisik_template_mapping_detail insert", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
$xid = $this->db->insert_id();
|
||||
} else {
|
||||
$data = [
|
||||
'FisikTemplateMappingDetailIsActive' => 'N',
|
||||
'FisikTemplateMappingDetailLastUpdated' => date('Y-m-d H:i:s'),
|
||||
'FisikTemplateMappingDetailLastUpdatedUserID' => $userid
|
||||
];
|
||||
|
||||
$this->db->where('FisikTemplateMappingDetailID', $mappingdetailid);
|
||||
$update = $this->db->update('fisik_template_mapping_detail', $data);
|
||||
|
||||
if (!$update) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("fisik_template_mapping_detail update", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
$xid = $mappingdetailid;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
|
||||
$this->sys_ok([
|
||||
"total" => 1,
|
||||
"records" => ["xid" => $xid]
|
||||
]);
|
||||
} catch (Exception $exc) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error($exc->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
function addNatTestMapping()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = isset($prm['id']) ? $prm['id'] : null;
|
||||
$nat_test_id = isset($prm['Nat_TestID']) ? $prm['Nat_TestID'] : null;
|
||||
$status = isset($prm['status']) ? $prm['status'] : null;
|
||||
if ($id == null) {
|
||||
$this->sys_error("Anda belum memilih template fisik.");
|
||||
exit;
|
||||
}
|
||||
if ($nat_test_id == null) {
|
||||
$this->sys_error("Anda belum memilih tes nat.");
|
||||
exit;
|
||||
}
|
||||
$userid = isset($this->sys_user["M_UserID"]) ? $this->sys_user["M_UserID"] : null;
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
try {
|
||||
$sql = "UPDATE fisik_map_test_template SET
|
||||
Fisik_MapTestTemplateIsActive = 'N',
|
||||
Fisik_MapTestTemplateDeleted = NOW(),
|
||||
Fisik_MapTestTemplateDeletedUserID = ?
|
||||
WHERE Fisik_MapTestTemplateNat_TestID = ? AND
|
||||
Fisik_MapTestTemplateIsActive = 'Y'";
|
||||
$del_rst = $this->db->query($sql, [$userid, $nat_test_id]);
|
||||
if (!$del_rst) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("fisik_map_test_template update", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($status == 'Y') {
|
||||
$sql = "INSERT INTO fisik_map_test_template (
|
||||
Fisik_MapTestTemplateFisikTemplateMappingID,
|
||||
Fisik_MapTestTemplateNat_TestID,
|
||||
Fisik_MapTestTemplateCreated,
|
||||
Fisik_MapTestTemplateCreatedUserID,
|
||||
Fisik_MapTestTemplateIsActive) VALUES (?, ?, ?, ?, 'Y')";
|
||||
$insert_rst = $this->db->query($sql, [$id, $nat_test_id, date('Y-m-d H:i:s'), $userid]);
|
||||
if (!$insert_rst) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("fisik_map_test_template insert", $this->db);
|
||||
return;
|
||||
}
|
||||
|
||||
$last_id = $this->db->insert_id();
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
|
||||
$this->sys_ok([
|
||||
"total" => 1,
|
||||
"records" => ["xid" => $last_id, "status" => $status, "nat_test_id" => $nat_test_id]
|
||||
]);
|
||||
} catch (Exception $exc) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error($exc->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
class Setupmapkelainan extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
var $load;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("onedev", true);
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "CPONE MD PRICE API";
|
||||
}
|
||||
|
||||
public function getsetup()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$page = $prm["page"];
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
|
||||
$ROW_PER_PAGE = 20;
|
||||
$start_offset = 0;
|
||||
// print_r($prm);
|
||||
|
||||
if (isset($prm["page"])) {
|
||||
if (
|
||||
is_numeric($prm["page"]) && $prm["page"] > 0
|
||||
) {
|
||||
$start_offset = ($page - 1) * $ROW_PER_PAGE;
|
||||
}
|
||||
}
|
||||
$sql = "SELECT COUNT(Mgm_McuID) as total
|
||||
FROM mgm_mcu
|
||||
WHERE Mgm_McuIsActive = 'Y'
|
||||
ORDER BY Mgm_McuStartDate ASC, Mgm_McuEndDate ASC";
|
||||
$qry = $this->db->query($sql, []);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$total = $qry->row_array()['total'];
|
||||
$sql = "SELECT *
|
||||
FROM mgm_mcu
|
||||
WHERE Mgm_McuIsActive = 'Y'
|
||||
AND (Mgm_McuLabel LIKE ? OR Mgm_McuNumber LIKE ?)
|
||||
ORDER BY Mgm_McuStartDate ASC, Mgm_McuEndDate ASC
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $search, $ROW_PER_PAGE, $start_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$data = $qry->result_array();
|
||||
$result = [
|
||||
"records" => $data,
|
||||
"total" => ceil($total / $ROW_PER_PAGE),
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function getdetail()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$page = $prm["page"];
|
||||
$setupid = $prm["setupid"];
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
|
||||
$ROW_PER_PAGE = 20;
|
||||
$start_offset = 0;
|
||||
// print_r($prm);
|
||||
|
||||
if (isset($prm["page"])) {
|
||||
if (
|
||||
is_numeric($prm["page"]) && $prm["page"] > 0
|
||||
) {
|
||||
$start_offset = ($page - 1) * $ROW_PER_PAGE;
|
||||
}
|
||||
}
|
||||
$sql = "SELECT
|
||||
COUNT(Mcu_KelainanGroupSummaryID) as total
|
||||
FROM mcu_kelainangroupsummary
|
||||
LEFT JOIN mcu_mapping_kelainangroupsummary
|
||||
ON Mcu_KelainanGroupSummaryID = Mcu_Mapping_KeliananGroupSummaryMcu_KelainanGroupSummaryID
|
||||
AND Mcu_Mapping_KeliananGroupSummaryIsActive = 'Y'
|
||||
AND Mcu_Mapping_KeliananGroupSummaryMgm_McuID = ?
|
||||
WHERE Mcu_KelainanGroupSummaryIsActive = 'Y'
|
||||
AND Mcu_KelainanGroupSummaryName LIKE ?";
|
||||
$qry = $this->db->query($sql, [$setupid, $search]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$total = $qry->row_array()['total'];
|
||||
|
||||
$sql = "SELECT
|
||||
Mcu_KelainanGroupSummaryID as kelainanGroupSummaryID,
|
||||
Mcu_KelainanGroupSummaryName as kelainanGroupSummaryName,
|
||||
Mcu_Mapping_KeliananGroupSummaryID as mappingID,
|
||||
CASE
|
||||
WHEN Mcu_Mapping_KeliananGroupSummaryID IS NULL THEN 'N'
|
||||
WHEN Mcu_Mapping_KeliananGroupSummaryID IS NOT NULL THEN 'Y'
|
||||
ELSE 'N'
|
||||
END as status
|
||||
FROM mcu_kelainangroupsummary
|
||||
LEFT JOIN mcu_mapping_kelainangroupsummary
|
||||
ON Mcu_KelainanGroupSummaryID = Mcu_Mapping_KeliananGroupSummaryMcu_KelainanGroupSummaryID
|
||||
AND Mcu_Mapping_KeliananGroupSummaryIsActive = 'Y'
|
||||
AND Mcu_Mapping_KeliananGroupSummaryMgm_McuID = ?
|
||||
WHERE Mcu_KelainanGroupSummaryIsActive = 'Y'
|
||||
AND Mcu_KelainanGroupSummaryName LIKE ?
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$setupid, $search, $ROW_PER_PAGE, $start_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$data = $qry->result_array();
|
||||
$result = [
|
||||
"records" => $data,
|
||||
"total" => ceil($total / $ROW_PER_PAGE),
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
public function save()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$prm = $this->sys_input;
|
||||
$data = $prm["data"];
|
||||
$setup = $prm["setup"];
|
||||
// $this->sys_error("Mencapai batas maksimal 10 kelainan group");
|
||||
// exit;
|
||||
$sql = "SELECT Mcu_Mapping_KeliananGroupSummaryID
|
||||
FROM mcu_mapping_kelainangroupsummary
|
||||
WHERE Mcu_Mapping_KeliananGroupSummaryMgm_McuID = ?
|
||||
AND Mcu_Mapping_KeliananGroupSummaryMcu_KelainanGroupSummaryID = ?
|
||||
AND Mcu_Mapping_KeliananGroupSummaryIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql, [$setup['Mgm_McuID'], $data['kelainanGroupSummaryID']]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$total = $qry->result_array();
|
||||
if (count($total) > 0) {
|
||||
$sql = "UPDATE mcu_mapping_kelainangroupsummary
|
||||
SET Mcu_Mapping_KeliananGroupSummaryIsActive = 'N',
|
||||
Mcu_Mapping_KeliananGroupSummaryDeleted = NOW(),
|
||||
Mcu_Mapping_KeliananGroupSummaryDeletedUserID = {$userid}
|
||||
WHERE Mcu_Mapping_KeliananGroupSummaryMgm_McuID = ?
|
||||
AND Mcu_Mapping_KeliananGroupSummaryMcu_KelainanGroupSummaryID = ?";
|
||||
$qry = $this->db->query($sql, [$setup['Mgm_McuID'], $data['kelainanGroupSummaryID']]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$sql = "SELECT
|
||||
COUNT(Mcu_KelainanGroupSummaryID) as total
|
||||
FROM mcu_kelainangroupsummary
|
||||
JOIN mcu_mapping_kelainangroupsummary
|
||||
ON Mcu_KelainanGroupSummaryID = Mcu_Mapping_KeliananGroupSummaryMcu_KelainanGroupSummaryID
|
||||
AND Mcu_Mapping_KeliananGroupSummaryIsActive = 'Y'
|
||||
AND Mcu_Mapping_KeliananGroupSummaryMgm_McuID = ?
|
||||
WHERE Mcu_KelainanGroupSummaryIsActive = 'Y' ";
|
||||
$qry = $this->db->query($sql, [$setup['Mgm_McuID']]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$total = $qry->row_array()['total'];
|
||||
if (intval($total) >= 10) {
|
||||
$this->sys_error("Mencapai batas maksimal 10 kelainan group");
|
||||
exit;
|
||||
}
|
||||
$sql = "INSERT INTO mcu_mapping_kelainangroupsummary(
|
||||
Mcu_Mapping_KeliananGroupSummaryMgm_McuID,
|
||||
Mcu_Mapping_KeliananGroupSummaryMcu_KelainanGroupSummaryID,
|
||||
Mcu_Mapping_KeliananGroupSummaryCreated,
|
||||
Mcu_Mapping_KeliananGroupSummaryCreatedUserID
|
||||
)VALUES(?,?,NOW(),{$userid})
|
||||
";
|
||||
$qry = $this->db->query($sql, [$setup['Mgm_McuID'], $data['kelainanGroupSummaryID']]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$this->sys_ok("OK");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,805 @@
|
||||
<?php
|
||||
class Kelainanlabv2 extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// $cek = $this->db->query("select database() as current_db")->result();
|
||||
// print_r($cek);
|
||||
echo "KELAINAN LAB API";
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$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_total = "SELECT count(*) as total
|
||||
FROM mcu_summarylab
|
||||
JOIN nat_test ON Mcu_SummaryLabNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
JOIN mcu_kelainan ON Mcu_summaryLabMcu_KelainanID = Mcu_KelainanID
|
||||
AND Mcu_KelainanIsActive = 'Y'
|
||||
WHERE Mcu_SummaryLabIsActive = 'Y'
|
||||
AND (CONCAT(Nat_TestCode,' ',Nat_TestName) LIKE ? OR Mcu_KelainanName LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$search, $search]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$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->db->trans_rollback();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("mcu_summarylab count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT Mcu_SummaryLabID,
|
||||
Mcu_SummaryLabNat_TestID,
|
||||
Mcu_SummaryLabNat_TestCode,
|
||||
Mcu_summaryLabMcu_KelainanID,
|
||||
CASE
|
||||
WHEN Mcu_SummaryLabType = '<' THEN 'Kurang dari'
|
||||
WHEN Mcu_SummaryLabType = '>' THEN 'Lebih dari'
|
||||
WHEN Mcu_SummaryLabType = '=' THEN 'Sama dengan'
|
||||
WHEN Mcu_SummaryLabType = '<=' THEN 'Kurang dari sama dengan'
|
||||
WHEN Mcu_SummaryLabType = '>=' THEN 'Lebih dari sama dengan'
|
||||
WHEN Mcu_SummaryLabType = '!=' THEN 'Tidak sama dengan'
|
||||
ELSE ''
|
||||
END as summarylabtype,
|
||||
CASE
|
||||
WHEN Mcu_SummaryLabType = '<' THEN 'KD'
|
||||
WHEN Mcu_SummaryLabType = '>' THEN 'LD'
|
||||
WHEN Mcu_SummaryLabType = '=' THEN 'SD'
|
||||
WHEN Mcu_SummaryLabType = '<=' THEN 'KDSD'
|
||||
WHEN Mcu_SummaryLabType = '>=' THEN 'LDSD'
|
||||
WHEN Mcu_SummaryLabType = '!=' THEN 'TSD'
|
||||
ELSE ''
|
||||
END as summarylabtypecode,
|
||||
Mcu_SummaryLabType,
|
||||
Mcu_SummaryLabIsNormalValue,
|
||||
Mcu_SummaryLabValue,
|
||||
Mcu_SummaryLabWithMethode,
|
||||
Mcu_SummaryLabNat_MethodeID,
|
||||
Nat_TestID,
|
||||
Nat_TestCode,
|
||||
CONCAT(Nat_TestCode,' ',Nat_TestName) AS codeNameTest,
|
||||
Mcu_KelainanID,
|
||||
Mcu_KelainanName,
|
||||
Mcu_FitnessCategoryID,
|
||||
Mcu_FitnessCategoryName,
|
||||
Mcu_FitnessCategoryEng,
|
||||
CONCAT(Mcu_FitnessCategoryName,' ','(',Mcu_FitnessCategoryEng,')') as fitnessname,
|
||||
Mcu_KelainanClasification,
|
||||
'' as rownumber,
|
||||
Mcu_SummaryLabMinInclusive,
|
||||
Mcu_SummaryLabMinValue,
|
||||
Mcu_SummaryLabMaxInclusive,
|
||||
Mcu_SummaryLabMaxValue,
|
||||
Mcu_SummaryLabGender as gender,
|
||||
IF(Mcu_SummaryLabIsRange = 'Y', 'range',IF(Mcu_SummaryLabIsFixValue = 'Y','fixvalue','normalvalue')) as typex,
|
||||
IF(Mcu_SummaryLabIsRange = 'Y', 'Range',IF(Mcu_SummaryLabIsFixValue = 'Y','Nilai Pembanding','Normal Value')) as typexname
|
||||
FROM mcu_summarylab
|
||||
JOIN nat_test ON Mcu_SummaryLabNat_TestID = Nat_TestID
|
||||
AND Nat_TestIsActive = 'Y'
|
||||
JOIN mcu_kelainan ON Mcu_summaryLabMcu_KelainanID = Mcu_KelainanID
|
||||
AND Mcu_KelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_fitness_category ON Mcu_SummaryLabMcu_FitnessCategoryID = Mcu_FitnessCategoryID
|
||||
AND Mcu_FitnessCategoryIsActive = 'Y'
|
||||
WHERE Mcu_SummaryLabIsActive = 'Y'
|
||||
AND (CONCAT(Nat_TestCode,' ',Nat_TestName) LIKE ? OR Mcu_KelainanName LIKE ?)
|
||||
ORDER BY Mcu_SummaryLabID DESC
|
||||
limit ? offset ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$search, $search, $number_limit, $number_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("mcu_summarylab select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = $qry->result_array();
|
||||
foreach ($rows as $k => $v) {
|
||||
$xno = ($k + 1) + $number_offset;
|
||||
$rows[$k]['rownumber'] = $xno;
|
||||
$rows[$k]['Mcu_SummaryLabMinInclusive'] = $v['Mcu_SummaryLabMinInclusive'] == 'N' ? false : true;
|
||||
$rows[$k]['Mcu_SummaryLabMaxInclusive'] = $v['Mcu_SummaryLabMaxInclusive'] == 'N' ? false : true;
|
||||
}
|
||||
|
||||
|
||||
$result = [
|
||||
"total_page" => $tot_page,
|
||||
"total" => $tot_count,
|
||||
"records" => $rows,
|
||||
"last_qry" => $last_qry
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchtest()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$number_limit = 10;
|
||||
$tot_count = 0;
|
||||
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql_search = "SELECT Nat_TestID,
|
||||
Nat_TestCode,
|
||||
CONCAT(Nat_TestCode,' ',Nat_TestName) as codeNameTest
|
||||
FROM nat_test
|
||||
WHERE Nat_TestIsActive = 'Y'
|
||||
AND Nat_TestIsResult = 'Y'
|
||||
AND (CONCAT(Nat_TestCode,' ',Nat_TestName) LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_search = $this->db->query($sql_search, [$search, $number_limit]);
|
||||
if ($qry_search) {
|
||||
$rows = $qry_search->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("nat_test select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => sizeof($rows),
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function newData()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$nat_test = $prm['nat_test'];
|
||||
$kelainan_id = $prm['kelainan']['Mcu_KelainanID'];
|
||||
$fitness_id = $prm['fitness']['Mcu_FitnessCategoryID'];
|
||||
$type = $prm['type']['id'];
|
||||
|
||||
$Mcu_SummaryLabGender = $prm['gender']['id'];
|
||||
$Mcu_SummaryLabType = '';
|
||||
$Mcu_SummaryLabIsNormalValue = 'N';
|
||||
$Mcu_SummaryLabIsFixValue = 'N';
|
||||
$Mcu_SummaryLabValue = '';
|
||||
$Mcu_SummaryLabIsRange = 'N';
|
||||
$Mcu_SummaryLabMinInclusive = 'N';
|
||||
$Mcu_SummaryLabMinValue = 0;
|
||||
$Mcu_SummaryLabMaxInclusive = 'N';
|
||||
$Mcu_SummaryLabMaxValue = 0;
|
||||
if ($type == "range") {
|
||||
$Mcu_SummaryLabIsRange = 'Y';
|
||||
$Mcu_SummaryLabMinInclusive = $prm['min_inclusive'] == true ? 'Y' : 'N';
|
||||
$Mcu_SummaryLabMinValue = $prm['min_value'];
|
||||
$Mcu_SummaryLabMaxInclusive = $prm['max_inclusive'] == true ? 'Y' : 'N';
|
||||
$Mcu_SummaryLabMaxValue = $prm['max_value'];
|
||||
}
|
||||
|
||||
if ($type == "fixvalue") {
|
||||
$Mcu_SummaryLabIsFixValue = "Y";
|
||||
$Mcu_SummaryLabValue = $prm['value_pembanding'];
|
||||
}
|
||||
|
||||
if ($type == "nomalvalue") {
|
||||
$Mcu_SummaryLabIsNormalValue = "Y";
|
||||
}
|
||||
|
||||
if ($type != "range") {
|
||||
switch ($prm['operator_pembanding']['id']) {
|
||||
case "KD":
|
||||
$Mcu_SummaryLabType = '<';
|
||||
break;
|
||||
case "LD":
|
||||
$Mcu_SummaryLabType = '>';
|
||||
break;
|
||||
case "SD":
|
||||
$Mcu_SummaryLabType = '=';
|
||||
break;
|
||||
case "KDSD":
|
||||
$Mcu_SummaryLabType = '<=';
|
||||
break;
|
||||
case "LDSD":
|
||||
$Mcu_SummaryLabType = '>=';
|
||||
break;
|
||||
case "TSD":
|
||||
$Mcu_SummaryLabType = '!=';
|
||||
break;
|
||||
default:
|
||||
$Mcu_SummaryLabType = '';
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO mcu_summarylab (
|
||||
Mcu_SummaryLabNat_TestID,
|
||||
Mcu_SummaryLabNat_TestCode,
|
||||
Mcu_summaryLabMcu_KelainanID,
|
||||
Mcu_SummaryLabMcu_FitnessCategoryID,
|
||||
Mcu_SummaryLabType,
|
||||
Mcu_SummaryLabIsNormalValue,
|
||||
Mcu_SummaryLabIsFixValue,
|
||||
Mcu_SummaryLabIsRange,
|
||||
Mcu_SummaryLabValue,
|
||||
Mcu_SummaryLabGender,
|
||||
Mcu_SummaryLabMinInclusive,
|
||||
Mcu_SummaryLabMinValue,
|
||||
Mcu_SummaryLabMaxInclusive,
|
||||
Mcu_SummaryLabMaxValue,
|
||||
Mcu_SummaryLabCreatedUserID,
|
||||
Mcu_SummaryLabCreated
|
||||
) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())";
|
||||
$qry = $this->db->query($sql, [
|
||||
$nat_test['Nat_TestID'],
|
||||
$nat_test['Nat_TestCode'],
|
||||
$kelainan_id,
|
||||
$fitness_id,
|
||||
$Mcu_SummaryLabType,
|
||||
$Mcu_SummaryLabIsNormalValue,
|
||||
$Mcu_SummaryLabIsFixValue,
|
||||
$Mcu_SummaryLabIsRange,
|
||||
$Mcu_SummaryLabValue,
|
||||
$Mcu_SummaryLabGender,
|
||||
$Mcu_SummaryLabMinInclusive,
|
||||
$Mcu_SummaryLabMinValue,
|
||||
$Mcu_SummaryLabMaxInclusive,
|
||||
$Mcu_SummaryLabMaxValue,
|
||||
$userid
|
||||
]);
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("gagal insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"status" => "OKE"
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function editData()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$xid = $prm['xid'];
|
||||
$nat_test = $prm['nat_test'];
|
||||
$kelainan_id = $prm['kelainan']['Mcu_KelainanID'];
|
||||
$type = $prm['type']['id'];
|
||||
$fitness_id = $prm['fitness']['Mcu_FitnessCategoryID'];
|
||||
//echo $type;
|
||||
//print_r($prm['type']);
|
||||
|
||||
$Mcu_SummaryLabGender = $prm['gender']['id'];
|
||||
$Mcu_SummaryLabType = '';
|
||||
$Mcu_SummaryLabIsNormalValue = 'N';
|
||||
$Mcu_SummaryLabIsFixValue = 'N';
|
||||
$Mcu_SummaryLabValue = '';
|
||||
$Mcu_SummaryLabIsRange = 'N';
|
||||
$Mcu_SummaryLabMinInclusive = 'N';
|
||||
$Mcu_SummaryLabMinValue = 0;
|
||||
$Mcu_SummaryLabMaxInclusive = 'N';
|
||||
$Mcu_SummaryLabMaxValue = 0;
|
||||
if ($type == "range") {
|
||||
$Mcu_SummaryLabIsRange = 'Y';
|
||||
$Mcu_SummaryLabMinInclusive = $prm['min_inclusive'] == true ? 'Y' : 'N';
|
||||
$Mcu_SummaryLabMinValue = $prm['min_value'];
|
||||
$Mcu_SummaryLabMaxInclusive = $prm['max_inclusive'] == true ? 'Y' : 'N';
|
||||
$Mcu_SummaryLabMaxValue = $prm['max_value'];
|
||||
}
|
||||
|
||||
if ($type == "fixvalue") {
|
||||
$Mcu_SummaryLabIsFixValue = "Y";
|
||||
$Mcu_SummaryLabValue = $prm['value_pembanding'];
|
||||
}
|
||||
|
||||
if ($type == "normalvalue") {
|
||||
$Mcu_SummaryLabIsNormalValue = "Y";
|
||||
//echo $Mcu_SummaryLabIsNormalValue;
|
||||
}
|
||||
|
||||
if ($type != "range") {
|
||||
switch ($prm['operator_pembanding']['id']) {
|
||||
case "KD":
|
||||
$Mcu_SummaryLabType = '<';
|
||||
break;
|
||||
case "LD":
|
||||
$Mcu_SummaryLabType = '>';
|
||||
break;
|
||||
case "SD":
|
||||
$Mcu_SummaryLabType = '=';
|
||||
break;
|
||||
case "KDSD":
|
||||
$Mcu_SummaryLabType = '<=';
|
||||
break;
|
||||
case "LDSD":
|
||||
$Mcu_SummaryLabType = '>=';
|
||||
break;
|
||||
case "TSD":
|
||||
$Mcu_SummaryLabType = '!=';
|
||||
break;
|
||||
default:
|
||||
$Mcu_SummaryLabType = '';
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "UPDATE mcu_summarylab SET
|
||||
Mcu_SummaryLabNat_TestID = ?,
|
||||
Mcu_SummaryLabNat_TestCode = ?,
|
||||
Mcu_summaryLabMcu_KelainanID = ?,
|
||||
Mcu_SummaryLabMcu_FitnessCategoryID = ?,
|
||||
Mcu_SummaryLabType = ?,
|
||||
Mcu_SummaryLabIsNormalValue= ?,
|
||||
Mcu_SummaryLabIsFixValue = ?,
|
||||
Mcu_SummaryLabIsRange = ?,
|
||||
Mcu_SummaryLabValue = ?,
|
||||
Mcu_SummaryLabGender = ?,
|
||||
Mcu_SummaryLabMinInclusive = ?,
|
||||
Mcu_SummaryLabMinValue= ?,
|
||||
Mcu_SummaryLabMaxInclusive = ?,
|
||||
Mcu_SummaryLabMaxValue = ?,
|
||||
Mcu_SummaryLabLastUpdatedUserID = ?,
|
||||
Mcu_SummaryLabLastUpdated = NOW()
|
||||
WHERE
|
||||
Mcu_SummaryLabID = ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$nat_test['Nat_TestID'],
|
||||
$nat_test['Nat_TestCode'],
|
||||
$kelainan_id,
|
||||
$fitness_id,
|
||||
$Mcu_SummaryLabType,
|
||||
$Mcu_SummaryLabIsNormalValue,
|
||||
$Mcu_SummaryLabIsFixValue,
|
||||
$Mcu_SummaryLabIsRange,
|
||||
$Mcu_SummaryLabValue,
|
||||
$Mcu_SummaryLabGender,
|
||||
$Mcu_SummaryLabMinInclusive,
|
||||
$Mcu_SummaryLabMinValue,
|
||||
$Mcu_SummaryLabMaxInclusive,
|
||||
$Mcu_SummaryLabMaxValue,
|
||||
$userid,
|
||||
$xid
|
||||
]);
|
||||
//echo $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("gagal update");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"status" => "OKE"
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchkelainan()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$number_limit = 10;
|
||||
$tot_count = 0;
|
||||
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$sql_total = "SELECT count(*) as total
|
||||
FROM mcu_kelainan
|
||||
WHERE Mcu_KelainanIsActive = 'Y'
|
||||
AND (Mcu_KelainanName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_total = $this->db->query($sql_total, [$search, $number_limit]);
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("kelainan count");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_search = "SELECT Mcu_KelainanID,
|
||||
Mcu_KelainanName,
|
||||
Mcu_KelainanClasification
|
||||
FROM mcu_kelainan
|
||||
WHERE Mcu_KelainanIsActive = 'Y'
|
||||
AND (Mcu_KelainanName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_search = $this->db->query($sql_search, [$search, $number_limit]);
|
||||
if ($qry_search) {
|
||||
$rows = $qry_search->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("kelainan select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_count,
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function add()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$testId = "";
|
||||
if (isset($prm["testId"])) {
|
||||
$testId = trim($prm["testId"]);
|
||||
}
|
||||
$kelainanId = "";
|
||||
if (isset($prm["kelainanId"])) {
|
||||
$kelainanId = trim($prm["kelainanId"]);
|
||||
}
|
||||
$testCode = "";
|
||||
if (isset($prm["testCode"])) {
|
||||
$testCode = trim($prm["testCode"]);
|
||||
}
|
||||
$type = "";
|
||||
if (isset($prm["type"])) {
|
||||
$type = trim($prm["type"]);
|
||||
}
|
||||
$normalValue = "";
|
||||
if (isset($prm["normalValue"])) {
|
||||
$normalValue = trim($prm["normalValue"]);
|
||||
}
|
||||
$value = "";
|
||||
if (isset($prm["value"])) {
|
||||
$value = trim($prm["value"]);
|
||||
}
|
||||
$mcufitnessId = 0;
|
||||
if (isset($prm["mcufitnessId"])) {
|
||||
$mcufitnessId = trim($prm["mcufitnessId"]);
|
||||
}
|
||||
|
||||
$sql_exist = "SELECT Mcu_SummaryLabID,
|
||||
Mcu_SummaryLabNat_TestID,
|
||||
Mcu_summaryLabMcu_KelainanID
|
||||
FROM mcu_summarylab
|
||||
WHERE Mcu_SummaryLabIsActive = 'Y'
|
||||
AND Mcu_SummaryLabNat_TestID = ?
|
||||
AND Mcu_summaryLabMcu_KelainanID = ?";
|
||||
$qry_exist = $this->db->query($sql_exist, [$testId, $kelainanId]);
|
||||
if ($qry_exist) {
|
||||
$tot_exist = $qry_exist->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("mcu_summarylab count");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($tot_exist) > 0) {
|
||||
echo json_encode(["status" => "OK", "flag" => true, "msg" => "Tidak bisa disimpan karena ada kelainan yang sama dengan pemeriksaan yang sudah ada, silahkan pilih kelainan lainnya!"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$datatype = "";
|
||||
switch ($type) {
|
||||
case "KD":
|
||||
$datatype = '<';
|
||||
break;
|
||||
case "LD":
|
||||
$datatype = '>';
|
||||
break;
|
||||
case "SD":
|
||||
$datatype = '=';
|
||||
break;
|
||||
case "KDSD":
|
||||
$datatype = '<=';
|
||||
break;
|
||||
case "LDSD":
|
||||
$datatype = '>=';
|
||||
break;
|
||||
case "TSD":
|
||||
$datatype = '!=';
|
||||
break;
|
||||
default:
|
||||
$datatype = '';
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO mcu_summarylab(
|
||||
Mcu_SummaryLabNat_TestID,
|
||||
Mcu_SummaryLabNat_TestCode,
|
||||
Mcu_summaryLabMcu_KelainanID,
|
||||
Mcu_SummaryLabMcu_FitnessCategoryID,
|
||||
Mcu_SummaryLabType,
|
||||
Mcu_SummaryLabIsNormalValue,
|
||||
Mcu_SummaryLabValue,
|
||||
Mcu_SummaryLabIsActive,
|
||||
Mcu_SummaryLabUserID,
|
||||
Mcu_SummaryLabCreated,
|
||||
Mcu_SummaryLabLastUpdated
|
||||
) VALUES(?,?,?,?,?,?,?,'Y',?,NOW(),NOW())";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$testId,
|
||||
$testCode,
|
||||
$kelainanId,
|
||||
$mcufitnessId,
|
||||
$datatype,
|
||||
$normalValue,
|
||||
$value,
|
||||
$userid
|
||||
));
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("save mcu_summarylab 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 edit()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$xid = "";
|
||||
if (isset($prm["xid"])) {
|
||||
$xid = trim($prm["xid"]);
|
||||
}
|
||||
$type = "";
|
||||
if (isset($prm["type"])) {
|
||||
$type = trim($prm["type"]);
|
||||
}
|
||||
$normalValue = "";
|
||||
if (isset($prm["normalValue"])) {
|
||||
$normalValue = trim($prm["normalValue"]);
|
||||
}
|
||||
$value = "";
|
||||
if (isset($prm["value"])) {
|
||||
$value = trim($prm["value"]);
|
||||
}
|
||||
$mcufitnessId = 0;
|
||||
if (isset($prm["mcufitnessId"])) {
|
||||
$mcufitnessId = trim($prm["mcufitnessId"]);
|
||||
}
|
||||
|
||||
$datatype = "";
|
||||
switch ($type) {
|
||||
case "KD":
|
||||
$datatype = '<';
|
||||
break;
|
||||
case "LD":
|
||||
$datatype = '>';
|
||||
break;
|
||||
case "SD":
|
||||
$datatype = '=';
|
||||
break;
|
||||
case "KDSD":
|
||||
$datatype = '<=';
|
||||
break;
|
||||
case "LDSD":
|
||||
$datatype = '>=';
|
||||
break;
|
||||
case "TSD":
|
||||
$datatype = '!=';
|
||||
break;
|
||||
default:
|
||||
$datatype = '';
|
||||
}
|
||||
|
||||
$sql = "UPDATE mcu_summarylab SET
|
||||
Mcu_SummaryLabMcu_FitnessCategoryID = ?,
|
||||
Mcu_SummaryLabType = ?,
|
||||
Mcu_SummaryLabIsNormalValue = ?,
|
||||
Mcu_SummaryLabValue = ?,
|
||||
Mcu_SummaryLabUserID = ?,
|
||||
Mcu_SummaryLabLastUpdated = NOW()
|
||||
WHERE Mcu_SummaryLabID = ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$mcufitnessId,
|
||||
$datatype,
|
||||
$normalValue,
|
||||
$value,
|
||||
$userid,
|
||||
$xid
|
||||
]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("update mcu_summarylab 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);
|
||||
}
|
||||
}
|
||||
|
||||
function deleterow()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$xid = "";
|
||||
if (isset($prm["xid"])) {
|
||||
$xid = trim($prm["xid"]);
|
||||
}
|
||||
|
||||
$sql = "UPDATE mcu_summarylab SET
|
||||
Mcu_SummaryLabIsActive = 'N',
|
||||
Mcu_SummaryLabUserID = ?,
|
||||
Mcu_SummaryLabLastUpdated = NOW()
|
||||
WHERE Mcu_SummaryLabID = ?";
|
||||
$qry = $this->db->query($sql, [
|
||||
$userid,
|
||||
$xid
|
||||
]);
|
||||
if (!$qry) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("delete mcu_summarylab 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);
|
||||
}
|
||||
}
|
||||
|
||||
function getfitness()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql = "SELECT Mcu_FitnessCategoryID,
|
||||
Mcu_FitnessCategoryName,
|
||||
Mcu_FitnessCategoryEng,
|
||||
CONCAT(Mcu_FitnessCategoryName,' ','(',Mcu_FitnessCategoryEng,')') as fitnessname,
|
||||
Mcu_FitnessCategoryLevel
|
||||
FROM mcu_fitness_category
|
||||
WHERE Mcu_FitnessCategoryIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("mcu fitness error", $this->db);
|
||||
}
|
||||
|
||||
$result = array("records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,891 @@
|
||||
<?php
|
||||
|
||||
class Polakelainan extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index()
|
||||
{
|
||||
echo "BRANCH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->db = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookupkelainandetailbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$kelainangroup = $prm['kelainangroup'];
|
||||
$kelainandetail = $prm['kelainandetail'];;
|
||||
$all = $prm['all'];
|
||||
$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 mcu_kelainan
|
||||
JOIN mcu_kelainangroup ON Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID AND Mcu_KelainanGroupIsActive = 'Y'
|
||||
WHERE
|
||||
Mcu_KelainanGroupName LIKE CONCAT('%','{$kelainangroup}','%') AND
|
||||
Mcu_KelainanName LIKE CONCAT('%','{$kelainandetail}','%') AND
|
||||
Mcu_KelainanIsActive = 'Y' GROUP BY Mcu_KelainanID) a";
|
||||
// $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("mcu_kelainan count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Mcu_KelainanID as id,
|
||||
Mcu_KelainanName as name,
|
||||
Mcu_KelainanGroupID,
|
||||
Mcu_KelainanGroupName,
|
||||
mcu_kelainan.*,
|
||||
IF(Mcu_KelainanClasification <> '','Y','N') as isclasification
|
||||
from mcu_kelainan
|
||||
JOIN mcu_kelainangroup ON Mcu_KelainanMcu_KelainanGroupID = Mcu_KelainanGroupID AND Mcu_KelainanGroupIsActive = 'Y'
|
||||
WHERE
|
||||
Mcu_KelainanGroupName LIKE CONCAT('%','{$kelainangroup}','%') AND
|
||||
Mcu_KelainanName LIKE CONCAT('%','{$kelainandetail}','%') AND
|
||||
Mcu_KelainanIsActive = 'Y'
|
||||
GROUP BY Mcu_KelainanID
|
||||
ORDER BY Mcu_KelainanGroupName ASC, Mcu_KelainanName 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("mcu_kelainan 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 lookupkelainangroupbyname()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$kelainangroup = $prm['kelainangroup'];
|
||||
$kelainandetail = $prm['kelainandetail'];
|
||||
$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 mcu_kelainangroup
|
||||
LEFT JOIN mcu_kelainan ON Mcu_KelainanGroupID = Mcu_KelainanMcu_KelainanGroupID AND Mcu_KelainanIsActive = 'Y'
|
||||
where
|
||||
Mcu_KelainanGroupName LIKE CONCAT('%','{$kelainangroup}','%') AND
|
||||
IFNULL(Mcu_KelainanName,'') LIKE CONCAT('%','{$kelainandetail}','%') AND
|
||||
Mcu_KelainanGroupIsActive = 'Y'
|
||||
GROUP BY Mcu_KelainanGroupID) a";
|
||||
$sql_param = array($search);
|
||||
// $total = $this->db->query($sql,$sql_param)->row()->total;
|
||||
$query = $this->db->query($sql);
|
||||
$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("mcu_kelainangroup count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select Mcu_KelainanGroupID as id,
|
||||
Mcu_KelainanGroupName as name,
|
||||
Mcu_KelainanGroupName as namex,
|
||||
mcu_kelainangroup.*
|
||||
from mcu_kelainangroup
|
||||
LEFT JOIN mcu_kelainan ON Mcu_KelainanGroupID = Mcu_KelainanMcu_KelainanGroupID AND Mcu_KelainanIsActive = 'Y'
|
||||
where
|
||||
Mcu_KelainanGroupName LIKE CONCAT('%','{$kelainangroup}','%') AND
|
||||
IFNULL(Mcu_KelainanName,'') LIKE CONCAT('%','{$kelainandetail}','%') AND
|
||||
Mcu_KelainanGroupIsActive = 'Y'
|
||||
GROUP BY Mcu_KelainanGroupID
|
||||
ORDER BY Mcu_KelainanGroupName 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("mcu_kelainangroup 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 addnewkelainangroup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$name = $prm['name'];
|
||||
$sql = "insert into mcu_kelainangroup(
|
||||
Mcu_KelainanGroupName,
|
||||
Mcu_KelainanGroupCreated,
|
||||
Mcu_KelainanGroupLastUpdated
|
||||
)
|
||||
values( ?, now(), now())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$name
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainangroup insert");
|
||||
exit;
|
||||
}
|
||||
$last_id = $this->db->insert_id();
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
$last_id = $this->db->insert_id();
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function editkelainangroup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$name = $prm['name'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sqlcompany = "update mcu_kelainangroup SET
|
||||
Mcu_KelainanGroupName = ?,
|
||||
Mcu_KelainanGroupLastUpdated = now()
|
||||
where
|
||||
Mcu_KelainanGroupID = ?
|
||||
";
|
||||
$querycompany = $this->db->query(
|
||||
$sqlcompany,
|
||||
array(
|
||||
$name,
|
||||
$id
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$querycompany) {
|
||||
$this->sys_error_db("mcu_kelainangroup update");
|
||||
exit;
|
||||
}
|
||||
$result = array("total" => 1, "records" => array("xid" => $id));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
public function addnewkelainandetail()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$kelainangroupid = $prm['kelainangroupid'];
|
||||
$name = $prm['name'];
|
||||
$klasifikasi = $prm['klasifikasi'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if ($kelainangroupid == 0) {
|
||||
$errors = array();
|
||||
if ($kelainangroupid == 0) {
|
||||
array_push($errors, array('field' => 'kelainangroup', 'msg' => 'Grup Kelainan dipilih dulu dong'));
|
||||
}
|
||||
$result = array("total" => -1, "errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
if ($prm['xid'] == 0) {
|
||||
$sql = "insert into mcu_kelainan(
|
||||
Mcu_KelainanMcu_KelainanGroupID,
|
||||
Mcu_KelainanName,
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_KelainanUserID,
|
||||
Mcu_KelainanLastUpdated,
|
||||
Mcu_KelainanCreated)
|
||||
values(?,?,?,?,now(),now())";
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$kelainangroupid,
|
||||
$name,
|
||||
$klasifikasi,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan 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 mcu_kelainan SET Mcu_KelainanMcu_KelainanGroupID = '{$kelainangroupid}',
|
||||
Mcu_KelainanName = '{$name}',
|
||||
Mcu_KelainanClasification = '{$klasifikasi}',
|
||||
Mcu_KelainanUserID = '{$userid}'
|
||||
WHERE Mcu_KelainanID = '{$prm['xid']}'";
|
||||
//echo $sql;
|
||||
$query = $this->db->query($sql);
|
||||
$result = array("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
public function deletekelainangroup()
|
||||
{
|
||||
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 mcu_kelainangroup SET
|
||||
Mcu_KelainanGroupIsActive = 'N',
|
||||
Mcu_KelainanGroupLastUpdated = now()
|
||||
WHERE
|
||||
Mcu_KelainanGroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainangroup delete");
|
||||
exit;
|
||||
}
|
||||
$sql = "update mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N',
|
||||
Mcu_KelainanLastUpdated = now()
|
||||
WHERE
|
||||
Mcu_KelainanMcu_KelainanGroupID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan 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 deletekelainandetail()
|
||||
{
|
||||
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 mcu_kelainan SET
|
||||
Mcu_KelainanIsActive = 'N',
|
||||
Mcu_KelainanLastUpdated = now()
|
||||
WHERE
|
||||
Mcu_KelainanID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db->query(
|
||||
$sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("mcu_kelainan delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
// update ihs number
|
||||
$sql_upt = "UPDATE one_health.organization SET
|
||||
organizationIsActive = 'N',
|
||||
organizationLastUpdated = NOW(),
|
||||
organizationUserID = ?
|
||||
WHERE organizationMcu_KelainanID = ?";
|
||||
$qry_upt = $this->db->query($sql_upt, array(
|
||||
$userid,
|
||||
$prm['id']
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("organization 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 searchkelainangroup()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['tes'] != '') {
|
||||
$q['search'] = "%{$prm['tes']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM mcu_kelainangroup
|
||||
WHERE
|
||||
Mcu_KelainanGroupName like ?
|
||||
AND Mcu_KelainanGroupIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("mcu_kelainangroup count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Mcu_KelainanGroupID, Mcu_KelainanGroupName
|
||||
FROM mcu_kelainangroup
|
||||
WHERE
|
||||
Mcu_KelainanGroupName like ?
|
||||
AND Mcu_KelainanGroupIsActive = 'Y'
|
||||
ORDER BY Mcu_KelainanGroupName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("mcu_kelainangroup rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelainangroupbyname()
|
||||
{
|
||||
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 mcu_kelainangroup
|
||||
WHERE
|
||||
Mcu_KelainanGroupName like ?
|
||||
AND Mcu_KelainanGroupIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("mcu_kelainangroup count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Mcu_KelainanGroupID, Mcu_KelainanGroupName
|
||||
FROM mcu_kelainangroup
|
||||
WHERE
|
||||
Mcu_KelainanGroupName like ?
|
||||
AND Mcu_KelainanGroupIsActive = 'Y'
|
||||
ORDER BY Mcu_KelainanGroupName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("mcu_kelainangroup rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchcity()
|
||||
{
|
||||
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 m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_city count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityName like ?
|
||||
AND M_CityIsActive = 'Y'
|
||||
ORDER BY M_CityName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("m_city rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function searchdistrict()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_district count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictName like ?
|
||||
AND M_DistrictM_CityID = '{$id}'
|
||||
AND M_DistrictIsActive = 'Y'
|
||||
ORDER BY M_DistrictName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("m_district rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchkelurahan()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_district count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_kelurahan
|
||||
WHERE
|
||||
M_KelurahanName like ?
|
||||
AND M_KelurahanM_DistrictID = '{$id}'
|
||||
AND M_KelurahanIsActive = 'Y'
|
||||
ORDER BY M_KelurahanName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("m_district rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchcompany()
|
||||
{
|
||||
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 m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_company count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("m_company rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchmou()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count = 0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '') {
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y' AND M_MouIsReleased = 'Y'";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_mou count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouName like ?
|
||||
AND M_MouM_CompanyID = '{$id}'
|
||||
AND M_MouIsActive = 'Y' AND M_MouIsReleased = 'Y'
|
||||
ORDER BY M_MouName ASC
|
||||
";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("m_mou rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function searchdoctor()
|
||||
{
|
||||
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(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?";
|
||||
$query = $this->db->query($sql, $q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor count", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
|
||||
FROM m_doctor
|
||||
WHERE M_DoctorIsActive = 'Y') a
|
||||
WHERE
|
||||
M_DoctorName like ?
|
||||
GROUP BY M_DoctorID
|
||||
ORDER BY M_DoctorName ASC";
|
||||
$query = $this->db->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$this->sys_error_db("m_doctor rows", $this->db);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
function selectaddressdoctor()
|
||||
{
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$rows = [];
|
||||
$query = "SELECT M_DoctorAddressID,
|
||||
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
|
||||
FROM
|
||||
m_doctoraddress
|
||||
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
|
||||
//echo $query;
|
||||
$rows['addressdoctors'] = $this->db->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows),
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,660 @@
|
||||
<?php
|
||||
class Summaryfisik extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "SUMMARY FISIK API";
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$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_total = "SELECT count(*) as total FROM mcu_fisiksummary
|
||||
LEFT JOIN mcu_kelainan ON Mcu_FisikSummaryMcu_KelainanID = Mcu_KelainanID
|
||||
AND Mcu_KelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_fitness_category ON Mcu_FisikSummaryMcu_FitnessCategoryID = Mcu_FitnessCategoryID
|
||||
AND Mcu_FitnessCategoryIsActive = 'Y'
|
||||
WHERE Mcu_FisikSummaryIsActive = 'Y'
|
||||
AND (Mcu_KelainanName LIKE ? OR CONCAT(Mcu_FitnessCategoryName,' ','(',Mcu_FitnessCategoryEng,')') LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$search, $search]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$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->db->trans_rollback();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("mcu summary fisik count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT Mcu_FisikSummaryID,
|
||||
Mcu_FisikSummaryMcu_KelainanID,
|
||||
Mcu_KelainanID,
|
||||
Mcu_KelainanName,
|
||||
Mcu_KelainanClasification,
|
||||
Mcu_FisikSummaryType,
|
||||
Mcu_FitnessCategoryID,
|
||||
Mcu_FitnessCategoryName,
|
||||
Mcu_FitnessCategoryEng,
|
||||
CONCAT(Mcu_FitnessCategoryName,' ','(',Mcu_FitnessCategoryEng,')') as fitnessname
|
||||
FROM mcu_fisiksummary
|
||||
LEFT JOIN mcu_kelainan ON Mcu_FisikSummaryMcu_KelainanID = Mcu_KelainanID
|
||||
AND Mcu_KelainanIsActive = 'Y'
|
||||
LEFT JOIN mcu_fitness_category ON Mcu_FisikSummaryMcu_FitnessCategoryID = Mcu_FitnessCategoryID
|
||||
AND Mcu_FitnessCategoryIsActive = 'Y'
|
||||
WHERE Mcu_FisikSummaryIsActive = 'Y'
|
||||
AND (Mcu_KelainanName LIKE ? OR CONCAT(Mcu_FitnessCategoryName,' ','(',Mcu_FitnessCategoryEng,')') LIKE ?)
|
||||
LIMIT ? OFFSET ?";
|
||||
|
||||
$qry = $this->db->query($sql, [$search, $search, $number_limit, $number_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("mcu summary fisik select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$result = [
|
||||
"total_page" => $tot_page,
|
||||
"total" => $tot_count,
|
||||
"records" => $rows,
|
||||
"last_qry" => $last_qry
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchkelainan()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$number_limit = 10;
|
||||
$tot_count = 0;
|
||||
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$sql_total = "SELECT count(*) as total
|
||||
FROM mcu_kelainan
|
||||
WHERE Mcu_KelainanIsActive = 'Y'
|
||||
AND (Mcu_KelainanName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_total = $this->db->query($sql_total, [$search, $number_limit]);
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("kelainan count");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_search = "SELECT Mcu_KelainanID,
|
||||
Mcu_KelainanName,
|
||||
Mcu_KelainanClasification
|
||||
FROM mcu_kelainan
|
||||
WHERE Mcu_KelainanIsActive = 'Y'
|
||||
AND (Mcu_KelainanName LIKE ?)
|
||||
LIMIT ?";
|
||||
$qry_search = $this->db->query($sql_search, [$search, $number_limit]);
|
||||
if ($qry_search) {
|
||||
$rows = $qry_search->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("kelainan select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_count,
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function getfitness()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql = "SELECT Mcu_FitnessCategoryID,
|
||||
Mcu_FitnessCategoryName,
|
||||
Mcu_FitnessCategoryEng,
|
||||
CONCAT(Mcu_FitnessCategoryName,' ','(',Mcu_FitnessCategoryEng,')') as fitnessname,
|
||||
Mcu_FitnessCategoryLevel
|
||||
FROM mcu_fitness_category
|
||||
WHERE Mcu_FitnessCategoryIsActive = 'Y'";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
} else {
|
||||
$this->sys_error_db("mcu fitness error", $this->db);
|
||||
}
|
||||
|
||||
$result = array("records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addnewsummaryfisik()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$kelainanId = $prm['kelainanId'];
|
||||
$fitnessId = $prm['fitnessId'];
|
||||
$type = $prm['type'];
|
||||
|
||||
if ($kelainanId == null || $fitnessId == null) {
|
||||
$errors = array();
|
||||
if ($kelainanId == null) {
|
||||
array_push($errors, array('field' => 'Fitness', 'msg' => 'Kelainan dipilih dulu dong'));
|
||||
}
|
||||
if ($fitnessId == null) {
|
||||
array_push($errors, array('field' => 'Fitness', 'msg' => 'Fitness dipilih dulu dong'));
|
||||
}
|
||||
$result = array("total" => -1, "errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
if ($prm['xid'] == 0) {
|
||||
$sql = "INSERT INTO mcu_fisiksummary(
|
||||
Mcu_FisikSummaryMcu_KelainanID,
|
||||
Mcu_FisikSummaryMcu_FitnessCategoryID,
|
||||
Mcu_FisikSummaryType,
|
||||
Mcu_FisikSummaryIsActive,
|
||||
Mcu_FisikSummaryCreated,
|
||||
Mcu_FisikSummaryCreatedUserID) VALUES(?,?,?,'Y',NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$kelainanId,
|
||||
$fitnessId,
|
||||
$type,
|
||||
$userid
|
||||
));
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("mcu fisik summary insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$rst = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function updatesummaryfisik()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$kelainanId = $prm['kelainanId'];
|
||||
$fitnessId = $prm['fitnessId'];
|
||||
$type = $prm['type'];
|
||||
|
||||
if ($kelainanId == null || $fitnessId == null) {
|
||||
$errors = array();
|
||||
if ($kelainanId == null) {
|
||||
array_push($errors, array('field' => 'Fitness', 'msg' => 'Kelainan dipilih dulu dong'));
|
||||
}
|
||||
if ($fitnessId == null) {
|
||||
array_push($errors, array('field' => 'Fitness', 'msg' => 'Fitness dipilih dulu dong'));
|
||||
}
|
||||
$result = array("total" => -1, "errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
if ($prm['xid'] != 0) {
|
||||
$sql = "UPDATE mcu_fisiksummary SET
|
||||
Mcu_FisikSummaryMcu_KelainanID = ?,
|
||||
Mcu_FisikSummaryMcu_FitnessCategoryID = ?,
|
||||
Mcu_FisikSummaryType = ?
|
||||
WHERE Mcu_FisikSummaryID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$kelainanId,
|
||||
$fitnessId,
|
||||
$type,
|
||||
$prm['xid']
|
||||
));
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("mcu fisik summary update", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$rst = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function deletesummaryfisik()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$sql = "UPDATE mcu_fisiksummary SET
|
||||
Mcu_FisikSummaryIsActive = 'N'
|
||||
WHERE Mcu_FisikSummaryID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$prm['id']
|
||||
));
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("fisik summary delete");
|
||||
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 searchdetail()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
$fifiksummaryId = $prm["fifiksummaryId"];
|
||||
|
||||
if ($fifiksummaryId != 0) {
|
||||
$filter = " AND Mcu_FisikSummaryID = $fifiksummaryId";
|
||||
}
|
||||
|
||||
$sql_total = "SELECT count(*) as total
|
||||
FROM mcu_fisiksummarydetail
|
||||
JOIN mcu_fisiksummary ON Mcu_FisikSummaryDetailMcu_FisikSummaryID = Mcu_FisikSummaryID
|
||||
AND Mcu_FisikSummaryIsActive = 'Y'
|
||||
LEFT JOIN fisik_template_code ON Mcu_FisikSummaryDetailCode = FisikTemplateCodeName
|
||||
WHERE Mcu_FisikSummaryDetailIsActive = 'Y'
|
||||
$filter
|
||||
AND (Mcu_FisikSummaryDetailCode LIKE ? OR Mcu_FisikSummaryDetailValue LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$search, $search]);
|
||||
$last_qry = $this->db->last_query();
|
||||
$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->db->trans_rollback();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("mcu summary fisik detail count error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT Mcu_FisikSummaryDetailID,
|
||||
Mcu_FisikSummaryDetailCode,
|
||||
Mcu_FisikSummaryDetailType,
|
||||
Mcu_FisikSummaryDetailValue,
|
||||
FisikTemplateCodeID,
|
||||
FisikTemplateCodeName,
|
||||
FisikTemplateCodeLabel,
|
||||
CONCAT(FisikTemplateCodeLabel,' ','[',FisikTemplateCodeName,']') AS templatecodename
|
||||
FROM mcu_fisiksummarydetail
|
||||
JOIN mcu_fisiksummary ON Mcu_FisikSummaryDetailMcu_FisikSummaryID = Mcu_FisikSummaryID
|
||||
AND Mcu_FisikSummaryIsActive = 'Y'
|
||||
LEFT JOIN fisik_template_code ON Mcu_FisikSummaryDetailCode = FisikTemplateCodeName
|
||||
WHERE Mcu_FisikSummaryDetailIsActive = 'Y'
|
||||
$filter
|
||||
AND (Mcu_FisikSummaryDetailCode LIKE ? OR Mcu_FisikSummaryDetailValue LIKE ?)
|
||||
LIMIT ? OFFSET ?";
|
||||
$qry = $this->db->query($sql, [$search, $search, $number_limit, $number_offset]);
|
||||
$last_qry = $this->db->last_query();
|
||||
if (!$qry) {
|
||||
$message = $this->db->error();
|
||||
$message['last_qry'] = $last_qry;
|
||||
$this->sys_error_db("mcu summary fisik detail select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
$rows = $qry->result_array();
|
||||
$result = [
|
||||
"total_page" => $tot_page,
|
||||
"total" => $tot_count,
|
||||
"records" => $rows,
|
||||
"last_qry" => $last_qry
|
||||
];
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function searchtemplatecode()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$number_limit = 10;
|
||||
$tot_count = 0;
|
||||
|
||||
$search = "";
|
||||
if (isset($prm['search'])) {
|
||||
$search = trim($prm["search"]);
|
||||
if ($search != "") {
|
||||
$search = '%' . $prm['search'] . '%';
|
||||
} else {
|
||||
$search = '%%';
|
||||
}
|
||||
}
|
||||
|
||||
$sql_total = "SELECT count(*) as total
|
||||
FROM fisik_template_code
|
||||
WHERE FisikTemplateCodeIsActive = 'Y'
|
||||
AND (CONCAT(FisikTemplateCodeLabel,' ','[',FisikTemplateCodeName,']') LIKE ?)";
|
||||
$qry_total = $this->db->query($sql_total, [$search]);
|
||||
if ($qry_total) {
|
||||
$tot_count = $qry_total->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("fisik_template_code count");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql_search = "SELECT FisikTemplateCodeID,
|
||||
FisikTemplateCodeName,
|
||||
FisikTemplateCodeLabel,
|
||||
CONCAT(FisikTemplateCodeLabel,' ','[',FisikTemplateCodeName,']') AS templatecodename
|
||||
FROM fisik_template_code
|
||||
WHERE FisikTemplateCodeIsActive = 'Y'
|
||||
AND (CONCAT(FisikTemplateCodeLabel,' ','[',FisikTemplateCodeName,']') LIKE ?)";
|
||||
$qry_search = $this->db->query($sql_search, [$search]);
|
||||
if ($qry_search) {
|
||||
$rows = $qry_search->result_array();
|
||||
} else {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("fisik_template_code select error", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => $tot_count,
|
||||
"total_display" => sizeof($rows),
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function addnewdetail()
|
||||
{
|
||||
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$fisiksummaryId = $prm["fisiksummaryId"];
|
||||
$code = $prm["code"];
|
||||
$type = $prm["type"];
|
||||
$value = $prm["value"];
|
||||
|
||||
if ($fisiksummaryId == 0) {
|
||||
$errors = array();
|
||||
if ($fisiksummaryId == 0) {
|
||||
array_push($errors, array('field' => 'Summary fisik', 'msg' => 'Anda belum memilih summary fisik'));
|
||||
}
|
||||
$result = array("total" => -1, "errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "INSERT INTO mcu_fisiksummarydetail(
|
||||
Mcu_FisikSummaryDetailMcu_FisikSummaryID,
|
||||
Mcu_FisikSummaryDetailCode,
|
||||
Mcu_FisikSummaryDetailType,
|
||||
Mcu_FisikSummaryDetailValue,
|
||||
Mcu_FisikSummaryDetailCreated,
|
||||
Mcu_FisikSummaryDetailUserID) VALUES(?,?,?,?,NOW(),?)";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$fisiksummaryId,
|
||||
$code,
|
||||
$type,
|
||||
$value,
|
||||
$userid
|
||||
));
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("mcu_fisiksummarydetail insert", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$rst = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
} catch (Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function updatedetail()
|
||||
{
|
||||
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$this->db->trans_begin();
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
|
||||
$fisiksummaryId = $prm["fisiksummaryId"];
|
||||
$code = $prm["code"];
|
||||
$type = $prm["type"];
|
||||
$value = $prm["value"];
|
||||
|
||||
if ($fisiksummaryId == 0) {
|
||||
$errors = array();
|
||||
if ($fisiksummaryId == 0) {
|
||||
array_push($errors, array('field' => 'Summary fisik', 'msg' => 'Anda belum memilih summary fisik'));
|
||||
}
|
||||
$result = array("total" => -1, "errors" => $errors, "records" => 0);
|
||||
$this->sys_ok($result);
|
||||
} else {
|
||||
$sql = "UPDATE mcu_fisiksummarydetail SET
|
||||
Mcu_FisikSummaryDetailMcu_FisikSummaryID = ?,
|
||||
Mcu_FisikSummaryDetailCode = ?,
|
||||
Mcu_FisikSummaryDetailType = ?,
|
||||
Mcu_FisikSummaryDetailValue = ?,
|
||||
Mcu_FisikSummaryDetailUserID = ?
|
||||
WHERE Mcu_FisikSummaryDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$fisiksummaryId,
|
||||
$code,
|
||||
$type,
|
||||
$value,
|
||||
$userid,
|
||||
$prm["id"]
|
||||
));
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("mcu_fisiksummarydetail update", $this->db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$rst = array(
|
||||
"total" => 1,
|
||||
"records" => array("xid" => 0)
|
||||
);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
} 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'];
|
||||
|
||||
$sql = "UPDATE mcu_fisiksummarydetail SET
|
||||
Mcu_FisikSummaryDetailIsActive = 'N',
|
||||
Mcu_FisikSummaryDetailUserID = ?
|
||||
WHERE Mcu_FisikSummaryDetailID = ?";
|
||||
$qry = $this->db->query($sql, array(
|
||||
$userid,
|
||||
$prm['id']
|
||||
));
|
||||
|
||||
if (!$qry) {
|
||||
$this->sys_error_db("fisik mcu_fisiksummarydetail delete");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user