Initial import
This commit is contained in:
196
one-api/application/controllers/mockup/antrione/Counter.php
Normal file
196
one-api/application/controllers/mockup/antrione/Counter.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
class Counter extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
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,
|
||||
$ip,
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
210
one-api/application/controllers/mockup/antrione/Numbering.php
Normal file
210
one-api/application/controllers/mockup/antrione/Numbering.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
class Numbering extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
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 numbering
|
||||
where
|
||||
numberingIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_antrione->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select *
|
||||
from numbering
|
||||
join service ON numberingServiceID = ServiceID
|
||||
where
|
||||
numberingIsActive = '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("numbering 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;
|
||||
$serviceid = $prm['serviceid'];
|
||||
$prefix = $prm['prefix'];
|
||||
$prefixdate = $prm['prefixdate'];
|
||||
$digit = $prm['digit'];
|
||||
$sufix = $prm['sufix'];
|
||||
$counter = $prm['counter'];
|
||||
$reset = $prm['reset'];
|
||||
|
||||
$sql = "insert into numbering(
|
||||
numberingServiceID,
|
||||
numberingPrefix,
|
||||
numberingPrefixDate,
|
||||
numberingDigit,
|
||||
numberingSufix,
|
||||
numberingCounter,
|
||||
numberingReset
|
||||
)
|
||||
values( ?,?,?,?,?,?,?)";
|
||||
$query = $this->db_antrione->query($sql,
|
||||
array(
|
||||
$serviceid,
|
||||
$prefix,
|
||||
$prefixdate,
|
||||
$digit,
|
||||
$sufix,
|
||||
$counter,
|
||||
$reset
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("numbering 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 update()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
/*if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}*/
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$serviceid = $prm['serviceid'];
|
||||
$prefix = $prm['prefix'];
|
||||
$prefixdate = $prm['prefixdate'];
|
||||
$digit = $prm['digit'];
|
||||
$sufix = $prm['sufix'];
|
||||
$counter = $prm['counter'];
|
||||
$reset = $prm['reset'];
|
||||
|
||||
$sql = "update numbering set
|
||||
numberingServiceID = ?,
|
||||
numberingPrefix = ?,
|
||||
numberingPrefixDate = ?,
|
||||
numberingDigit = ?,
|
||||
numberingSufix = ?,
|
||||
numberingCounter = ?,
|
||||
numberingReset = ?
|
||||
where numberingID = ?
|
||||
";
|
||||
$query = $this->db_antrione->query($sql,
|
||||
array(
|
||||
$serviceid,
|
||||
$prefix,
|
||||
$prefixdate,
|
||||
$digit,
|
||||
$sufix,
|
||||
$counter,
|
||||
$reset,
|
||||
$id
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("numbering 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 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 numbering set
|
||||
numberingIsActive = 'N'
|
||||
where numberingID = ?
|
||||
";
|
||||
$query = $this->db_antrione->query($sql,
|
||||
array(
|
||||
$id
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("numbering delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
201
one-api/application/controllers/mockup/antrione/Service.php
Normal file
201
one-api/application/controllers/mockup/antrione/Service.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
class Service extends MY_Controller
|
||||
{
|
||||
var $db_antrione;
|
||||
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 service
|
||||
where
|
||||
serviceIsActive = 'Y'";
|
||||
$sql_param = array($search);
|
||||
$total = $this->db_antrione->query($sql,$sql_param)->row()->total;
|
||||
|
||||
|
||||
$sql = "select *
|
||||
from service
|
||||
where
|
||||
serviceIsActive = '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("m_schedule select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array ("total" => $total, "total_filter"=>count($rows),"records" => $rows,
|
||||
"ownIP" => $_SERVER["REMOTE_ADDR"] );
|
||||
$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'];
|
||||
$name = $prm['name'];
|
||||
$priority = $prm['priority'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM service WHERE serviceIsActive = 'Y' AND serviceCode = '{$code}'";
|
||||
$exist_code = $this->db_antrione->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0){
|
||||
$sql = "insert into service(
|
||||
serviceCode,
|
||||
serviceName,
|
||||
servicePriority
|
||||
)
|
||||
values( ?,?,?)";
|
||||
$query = $this->db_antrione->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$priority
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("service 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'];
|
||||
$name = $prm['name'];
|
||||
$priority = $prm['priority'];
|
||||
|
||||
$query = "SELECT COUNT(*) as exist FROM service WHERE serviceIsActive = 'Y' AND serviceCode = '{$code}' AND serviceID <> {$id}";
|
||||
//echo $query;
|
||||
$exist_code = $this->db_antrione->query($query)->row()->exist;
|
||||
|
||||
if($exist_code == 0){
|
||||
$sql = "update service set
|
||||
serviceCode = ?,
|
||||
serviceName = ?,
|
||||
servicePriority = ?
|
||||
where serviceID = ?
|
||||
";
|
||||
$query = $this->db_antrione->query($sql,
|
||||
array(
|
||||
$code,
|
||||
$name,
|
||||
$priority,
|
||||
$id
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("service 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 service set
|
||||
serviceIsActive = 'N'
|
||||
where serviceID = ?
|
||||
";
|
||||
$query = $this->db_antrione->query($sql,
|
||||
array(
|
||||
$id
|
||||
)
|
||||
);
|
||||
//echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("service 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/bill/Register.php
Normal file
714
one-api/application/controllers/mockup/bill/Register.php
Normal file
@@ -0,0 +1,714 @@
|
||||
<?php
|
||||
class Register extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Register 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"];
|
||||
$status = $prm["status"];
|
||||
|
||||
$sql_where = "WHERE F_BillIsActive = 'Y' AND F_BillIsLunas = '{$status}'";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_CompanyName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($norm != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " F_BillNo like ? ";
|
||||
$sql_param[] = "%$norm%";
|
||||
}
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM f_bill
|
||||
LEFT JOIN m_mou ON F_BillM_MouID = M_MouID
|
||||
left join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
$sql_where
|
||||
";
|
||||
$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("f_bill count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
F_BillID,
|
||||
F_BillNo,
|
||||
F_BillM_MouID,
|
||||
M_MouID,
|
||||
IF(F_BillM_MouID = 0, 'Semua',M_MouName) as M_MouName,
|
||||
F_BillDueDateDay,
|
||||
DATE_FORMAT(F_BillDueDate,'%d/%m/%Y') as F_BillDueDate ,
|
||||
DATE_FORMAT(F_BillDueDate,'%Y-%m-%d') as sdate,
|
||||
F_BillTotal,
|
||||
F_BillUnpaid,
|
||||
F_BillReceive ,
|
||||
F_BillIsLunas ,
|
||||
F_BillIsClosed ,
|
||||
DATE_FORMAT(F_BillCreated,'%d/%m/%Y') as F_BillCreated,
|
||||
F_BillUserID ,
|
||||
F_BillNote,
|
||||
M_CompanyID,
|
||||
M_CompanyName
|
||||
|
||||
FROM f_bill
|
||||
LEFT JOIN m_mou ON F_BillM_MouID = M_MouID
|
||||
left join m_company on F_BillM_CompanyID = M_CompanyID
|
||||
$sql_where
|
||||
ORDER BY F_BillNo DESC
|
||||
limit 0,$tot_count ";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$x = $this->db_onedev->query("
|
||||
select count(*) as tot
|
||||
FROM f_bill_detail
|
||||
where F_BillDetailF_BillID = '{$v['F_BillID']}'")->row();
|
||||
if($x->tot == 0 ) {
|
||||
$rows[$k]['haveDetail'] = "N";
|
||||
} else {
|
||||
$rows[$k]['haveDetail'] = "Y";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$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 0 as M_MouID, 'Semua' as M_MouName
|
||||
UNION
|
||||
SELECT M_MouID, M_MouName
|
||||
FROM m_mou
|
||||
WHERE
|
||||
M_MouIsActive = 'Y' AND M_MouIsBill = '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 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();
|
||||
|
||||
$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 f_bill (
|
||||
F_BillNo,
|
||||
F_BillM_CompanyID,
|
||||
F_BillM_MouID,
|
||||
F_BillDueDateDay,
|
||||
F_BillDueDate,
|
||||
F_BillNote,
|
||||
F_BillUserID,
|
||||
F_BillCreated
|
||||
)
|
||||
VALUES(
|
||||
`fn_numbering`('BL'),
|
||||
'{$prm['companyid']}',
|
||||
'{$prm['mouid']}',
|
||||
'{$prm['day']}',
|
||||
'{$pdate}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
|
||||
|
||||
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
$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 editbill(){
|
||||
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 ="UPDATE f_bill SET
|
||||
F_BillDueDateDay = '{$prm['day']}',
|
||||
F_BillDueDate = '{$pdate}',
|
||||
F_BillNote = '{$prm['note']}',
|
||||
F_BillUserID = '{$userid}',
|
||||
F_BillCreated = now()
|
||||
WHERE F_BillID = '{$prm['id']}'
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $prm['id'];
|
||||
|
||||
$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_receivereferenceheader SET
|
||||
T_ReceiveReferenceHeaderIsSent = 'Y',
|
||||
T_ReceiveReferenceHeaderSentDate = now(),
|
||||
T_ReceiveReferenceHeaderUserID = '{$userid}'
|
||||
WHERE
|
||||
T_ReceiveReferenceHeaderID = '{$prm['T_ReceiveReferenceHeaderID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogT_ReceiveReferenceHeaderID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$prm['T_ReceiveReferenceHeaderID']}',
|
||||
'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 save_patient() {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$sql = "insert into f_bill_detail(F_BillDetailF_BillID, F_BillDetailT_OrderHeaderID,
|
||||
F_BillDetailTotal, F_BillDetailUnpaid) values(?,?,?,?)";
|
||||
$billID = $prm["billID"];
|
||||
// print_r($prm);
|
||||
exit;
|
||||
foreach($prm["patients"] as $p) {
|
||||
$orderID = $p["T_OrderHeaderID"];
|
||||
$total = $p["total"];
|
||||
$this->db_onedev->query($sql,array($billID, $orderID, $total, $total));
|
||||
}
|
||||
$result = "Pasien saved";
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
function getpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$billID = $prm["id"];
|
||||
$mouID = $prm["mouid"];
|
||||
$sql = "select count(*) tot from f_bill_detail where F_BillDetailF_BillID=?";
|
||||
$rst = $this->db_onedev->query($sql,array($billID))->row();
|
||||
if ($rst->tot > 0 ) {
|
||||
$sql = "select
|
||||
M_CompanyID, M_CompanyName,
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
concat(M_TitleName,'. ',M_PatientName) as pasienname,
|
||||
T_OrderHeaderTotal as total,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d/%m/%Y') as T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
'' as tes,
|
||||
'xxx' as tests,
|
||||
'' as action,
|
||||
T_OrderHeaderID
|
||||
FROM f_bill_detail
|
||||
join t_orderheader ON F_BillDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
join m_patient on M_PatientID = T_OrderHeaderM_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
left join m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
WHERE
|
||||
F_BillDetailIsActive = 'Y' and F_BillDetailF_BillID = '{$billID}'
|
||||
GROUP BY F_BillDetailID
|
||||
order by F_BillDetailID asc";
|
||||
} else {
|
||||
$sql = "select
|
||||
M_CompanyID, M_CompanyName,
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
concat(M_TitleName,'. ',M_PatientName) as pasienname,
|
||||
T_OrderHeaderTotal as total,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d/%m/%Y') as T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
'' as tes,
|
||||
'xxx' as tests,
|
||||
'' as action,
|
||||
T_OrderHeaderID
|
||||
FROM t_orderheader
|
||||
join f_bill on F_BillID = '{$billID}'
|
||||
left join m_company ON F_BillM_CompanyID = M_CompanyID
|
||||
LEFT JOIN f_bill_detail ON T_OrderHeaderID = F_BillDetailT_OrderHeaderID AND F_BillDetailIsActive = 'Y'
|
||||
LEFT JOIN f_payment ON T_OrderHeaderID = F_PaymentT_OrderHeaderID AND F_PaymentIsActive = 'Y'
|
||||
join m_patient on M_PatientID = T_OrderHeaderM_PatientID
|
||||
join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_mou ON T_OrderHeaderM_MouID = M_MouID AND M_MouIsBill = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderIsActive = 'Y' AND
|
||||
T_OrderHeaderM_CompanyID = M_CompanyID AND
|
||||
($mouID = 0 OR($mouID > 0 AND T_OrderHeaderM_MouID = $mouID)) AND
|
||||
F_BillDetailID IS NULL AND F_PaymentID IS NULL
|
||||
order by T_OrderHeaderDate asc, T_OrderHeaderID asc";
|
||||
|
||||
}
|
||||
//echo $sql;
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
$rows = array();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function add_test($orderid){
|
||||
$query =" SELECT t_receivereferencetest.*, t_test.*,'Y' as editable, T_ReceiveReferenceTestT_TestID as xid,
|
||||
T_ReceiveReferenceTestT_TestPrice as T_PriceAmount,
|
||||
T_ReceiveReferenceTestT_TestDisc as T_PriceDisc,
|
||||
T_ReceiveReferenceTestT_TestDiscRp as T_PriceDiscRp,
|
||||
T_ReceiveReferenceTestT_TestTotal as total
|
||||
FROM t_receivereferencetest
|
||||
JOIN t_receivereferencepatient ON T_ReceiveReferenceTestT_ReceiveReferencePatientID = T_ReceiveReferencePatientID
|
||||
JOIN t_receivereferenceheader ON T_ReceiveReferencePatientT_ReceiveReferenceHeaderID = T_ReceiveReferenceHeaderID
|
||||
JOIN t_test ON T_ReceiveReferenceTestT_TestID = T_TestID
|
||||
WHERE
|
||||
T_ReceiveReferenceTestT_ReceiveReferencePatientID = {$orderid} AND T_ReceiveReferenceTestIsActive = 'Y'
|
||||
GROUP BY T_ReceiveReferenceTestID";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function savenewpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$billID = $prm['billID'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach($prm['patients'] as $k=>$v){
|
||||
$query = "INSERT INTO f_bill_detail
|
||||
(F_BillDetailF_BillID,
|
||||
F_BillDetailT_OrderHeaderID,
|
||||
F_BillDetailTotal,
|
||||
F_BillDetailUnpaid,
|
||||
F_BillDetailUserID,
|
||||
F_BillDetailCreated,
|
||||
F_BillDetailLastUpdated)
|
||||
VALUE(
|
||||
?,?,?,?,?,now(),now()
|
||||
)";
|
||||
$insert_new_test = $this->db_onedev->query($query,array(
|
||||
$billID,
|
||||
$v['T_OrderHeaderID'],
|
||||
$v['total'],
|
||||
$v['total'],
|
||||
$userid
|
||||
));
|
||||
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm['T_ReceiveReferencePatientID'];
|
||||
$pdob = date('Y-m-d',strtotime($prm['T_ReceiveReferencePatientDOB']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE t_receivereferencepatient SET
|
||||
T_ReceiveReferencePatientT_ReceiveReferenceHeaderID = '{$prm['T_ReceiveReferencePatientT_ReceiveReferenceHeaderID']}',
|
||||
T_ReceiveReferencePatientNoRef = '{$prm['T_ReceiveReferencePatientNoRef']}',
|
||||
T_ReceiveReferencePatientName = '{$prm['T_ReceiveReferencePatientName']}',
|
||||
T_ReceiveReferencePatientDOB = '{$pdob}',
|
||||
T_ReceiveReferencePatientM_SexID = '{$prm['T_ReceiveReferencePatientM_SexID']}',
|
||||
T_ReceiveReferencePatientTotal = '{$prm['T_ReceiveReferencePatientTotal']}',
|
||||
T_ReceiveReferencePatientDPPercent = '{$prm['T_ReceiveReferencePatientDPPercent']}',
|
||||
T_ReceiveReferencePatientDPAmount = '{$prm['T_ReceiveReferencePatientDPAmount']}',
|
||||
T_ReceiveReferencePatientUserID = '{$userid}'
|
||||
WHERE
|
||||
T_ReceiveReferencePatientID = '{$prm['T_ReceiveReferencePatientID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
foreach($prm['ordertests'] as $k=>$v){
|
||||
if($v['xid'] == 0 || $v['xid'] == '0'){
|
||||
$query = "INSERT INTO t_receivereferencetest (
|
||||
T_ReceiveReferenceTestT_ReceiveReferencePatientID,
|
||||
T_ReceiveReferenceTestT_TestID,
|
||||
T_ReceiveReferenceTestT_TestCode,
|
||||
T_ReceiveReferenceTestT_TestName,
|
||||
T_ReceiveReferenceTestT_TestPrice,
|
||||
T_ReceiveReferenceTestUserID,
|
||||
T_ReceiveReferenceTestCreated,
|
||||
T_ReceiveReferenceTestLastUpdated
|
||||
)
|
||||
VALUE(
|
||||
?,?,?,?,?,?,now(),now()
|
||||
)";
|
||||
$insert_new_test = $this->db_onedev->query($query,array(
|
||||
$order_id,
|
||||
$v['T_TestID'],
|
||||
$v['T_TestCode'],
|
||||
$v['T_TestName'],
|
||||
$v['total'],
|
||||
$userid
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(isset($prm['deleted_ordertests'])){
|
||||
foreach($prm['deleted_ordertests'] as $i=>$del){
|
||||
|
||||
$query = "UPDATE t_receivereferencetest SET
|
||||
T_ReceiveReferenceTestIsActive = 'N',
|
||||
T_ReceiveReferenceTestUserID = '{$userid}',
|
||||
T_ReceiveReferenceTestLastUpdated = now()
|
||||
WHERE
|
||||
T_ReceiveReferenceTestID = ?
|
||||
";
|
||||
$delete_exist_test = $this->db_onedev->query($query,array($del['T_ReceiveReferenceTestID'],));
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function deletebill(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE f_bill SET
|
||||
F_BillIsActive = 'N',
|
||||
F_BillUserID = '{$userid}'
|
||||
WHERE
|
||||
F_BillID = '{$prm['id']}'";
|
||||
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$query ="UPDATE f_bill_detail SET
|
||||
F_BillDetailIsActive = 'N',
|
||||
F_BillDetailUserID = '{$userid}'
|
||||
WHERE
|
||||
F_BillDetailF_BillID = '{$prm['id']}'";
|
||||
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$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 f_bill_detail SET
|
||||
F_BillDetailIsActive = 'N',
|
||||
F_BillDetailUserID = '{$userid}'
|
||||
WHERE
|
||||
F_BillDetailID = '{$prm['F_BillDetailID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
//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.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_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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
681
one-api/application/controllers/mockup/bill/Register0.php
Normal file
681
one-api/application/controllers/mockup/bill/Register0.php
Normal file
@@ -0,0 +1,681 @@
|
||||
<?php
|
||||
class Register extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Register 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 F_BillIsActive = 'Y' ";
|
||||
$sql_param = array();
|
||||
if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_CompanyName like ? ";
|
||||
$sql_param[] = "%$nama%";
|
||||
}
|
||||
if ($norm != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " F_BillNo 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 f_bill
|
||||
LEFT JOIN m_mou ON F_BillM_MouID = M_MouID
|
||||
left join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
$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("f_bill count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
F_BillID,
|
||||
F_BillNo,
|
||||
M_MouName ,
|
||||
DATE_FORMAT(F_BillDueDate,'%d/%m/%Y') as F_BillDueDate ,
|
||||
F_BillTotal,
|
||||
F_BillReceive ,
|
||||
F_BillIsLunas ,
|
||||
F_BillIsClosed ,
|
||||
DATE_FORMAT(F_BillCreated,'%d/%m/%Y') as F_BillCreated,
|
||||
F_BillUserID ,
|
||||
F_BillNote,
|
||||
M_CompanyName
|
||||
|
||||
FROM f_bill
|
||||
LEFT JOIN m_mou ON F_BillM_MouID = M_MouID
|
||||
left join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
$sql_where
|
||||
ORDER BY F_BillNo DESC
|
||||
limit 0,20";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$x = $this->db_onedev->query("
|
||||
|
||||
select
|
||||
F_BillID,
|
||||
F_BillNo,
|
||||
M_MouName ,
|
||||
DATE_FORMAT(F_BillDueDate,'%d/%m/%Y') as F_BillDueDate ,
|
||||
F_BillTotal,
|
||||
F_BillReceive ,
|
||||
F_BillIsLunas ,
|
||||
F_BillIsClosed ,
|
||||
DATE_FORMAT(F_BillCreated,'%d/%m/%Y') as F_BillCreated,
|
||||
F_BillUserID ,
|
||||
F_BillNote,
|
||||
M_CompanyName
|
||||
|
||||
FROM f_bill
|
||||
LEFT JOIN m_mou ON F_BillM_MouID = M_MouID
|
||||
left join m_company on M_MouM_CompanyID = M_CompanyID
|
||||
|
||||
WHERE F_BillID = '{$v['F_BillID']}' ")->row();
|
||||
$rows[$k]['statuss'] = json_decode($x->n);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$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 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();
|
||||
|
||||
$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 f_bill (
|
||||
F_BillNo,
|
||||
F_BillM_CompanyID,
|
||||
F_BillM_MouID,
|
||||
F_BillDueDate,
|
||||
F_BillNote,
|
||||
F_BillTotal,
|
||||
F_BillUserID,
|
||||
F_BillCreated
|
||||
)
|
||||
VALUES(
|
||||
`fn_numbering`('BL'),
|
||||
'{$prm['companyid']}',
|
||||
'{$prm['mouid']}',
|
||||
'{$pdate}',
|
||||
'{$prm['note']}',
|
||||
`fn_get_total_bill`({$prm['mouid']}),
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
|
||||
|
||||
|
||||
";
|
||||
// echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
|
||||
$querylog ="INSERT INTO f_bill_detail (
|
||||
F_BillDetailF_BillID,
|
||||
F_BillDetailT_OrderHeaderID,
|
||||
F_BillDetailUserID,
|
||||
F_BillDetailCreated,
|
||||
F_BillDetailLastUpdated
|
||||
)
|
||||
select $last_id,T_OrderHeaderID,$userid,NOW(),NOW()
|
||||
from t_orderheader
|
||||
left join f_payment on T_OrderHeaderID = F_PaymentT_OrderHeaderID
|
||||
and T_OrderHeaderM_MouID = '{$prm['mouid']}'
|
||||
where T_OrderHeaderIsActive = 'Y' and F_PaymentID is null and T_OrderHeaderID not in (
|
||||
select F_BillDetailT_OrderHeaderID from f_bill_detail where F_BillDetailIsActive = 'Y'
|
||||
)
|
||||
|
||||
|
||||
";
|
||||
$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_receivereferenceheader SET
|
||||
T_ReceiveReferenceHeaderIsSent = 'Y',
|
||||
T_ReceiveReferenceHeaderSentDate = now(),
|
||||
T_ReceiveReferenceHeaderUserID = '{$userid}'
|
||||
WHERE
|
||||
T_ReceiveReferenceHeaderID = '{$prm['T_ReceiveReferenceHeaderID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$querylog ="INSERT INTO g_receivereferenceheaderstatuslog (
|
||||
G_ReceiveReferenceHeaderStatusLogDate,
|
||||
G_ReceiveReferenceHeaderStatusLogT_ReceiveReferenceHeaderID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_StatusReferenceID,
|
||||
G_ReceiveReferenceHeaderStatusLogM_UserID,
|
||||
G_ReceiveReferenceHeaderStatusLogUserID,
|
||||
G_ReceiveReferenceHeaderStatusLogCreated,
|
||||
G_ReceiveReferenceHeaderStatusLogLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$prm['T_ReceiveReferenceHeaderID']}',
|
||||
'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 getpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT f_bill_detail.*,
|
||||
concat(M_TitleName,'. ',M_PatientName) as pasienname,
|
||||
T_OrderHeaderTotal as total,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d/%m/%Y') as T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
'' as tes,
|
||||
'xxx' as tests,
|
||||
'' as action
|
||||
FROM f_bill_detail
|
||||
join f_bill on F_BillDetailF_BillID = F_BillID
|
||||
JOIN t_orderheader ON F_BillDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
left join m_title on M_PatientM_TitleID = M_TitleID
|
||||
|
||||
|
||||
WHERE
|
||||
F_BillDetailIsActive = 'Y' AND F_BillDetailF_BillID = ?
|
||||
|
||||
";
|
||||
//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 f_bill_detail.*,
|
||||
concat(M_TitleName,'. ',M_PatientName) as pasienname,
|
||||
T_OrderHeaderTotal as total,
|
||||
DATE_FORMAT(T_OrderHeaderDate,'%d/%m/%Y') as T_OrderHeaderDate,
|
||||
T_OrderHeaderLabNumber,
|
||||
'' as tes,
|
||||
'xxx' as tests,
|
||||
'' as action
|
||||
FROM f_bill_detail
|
||||
join f_bill on F_BillDetailF_BillID = F_BillID
|
||||
JOIN t_orderheader ON F_BillDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
left join m_title on M_PatientM_TitleID = M_TitleID
|
||||
|
||||
WHERE
|
||||
F_BillDetailF_BillID = '{$v['F_BillID']}' AND F_BillDetailIsActive = 'Y'")->row();
|
||||
$rows[$k]['tesx'] = json_decode($x->n);
|
||||
$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 t_receivereferencetest.*, t_test.*,'Y' as editable, T_ReceiveReferenceTestT_TestID as xid,
|
||||
T_ReceiveReferenceTestT_TestPrice as T_PriceAmount,
|
||||
T_ReceiveReferenceTestT_TestDisc as T_PriceDisc,
|
||||
T_ReceiveReferenceTestT_TestDiscRp as T_PriceDiscRp,
|
||||
T_ReceiveReferenceTestT_TestTotal as total
|
||||
FROM t_receivereferencetest
|
||||
JOIN t_receivereferencepatient ON T_ReceiveReferenceTestT_ReceiveReferencePatientID = T_ReceiveReferencePatientID
|
||||
JOIN t_receivereferenceheader ON T_ReceiveReferencePatientT_ReceiveReferenceHeaderID = T_ReceiveReferenceHeaderID
|
||||
JOIN t_test ON T_ReceiveReferenceTestT_TestID = T_TestID
|
||||
WHERE
|
||||
T_ReceiveReferenceTestT_ReceiveReferencePatientID = {$orderid} AND T_ReceiveReferenceTestIsActive = 'Y'
|
||||
GROUP BY T_ReceiveReferenceTestID";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function savenewpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$pdob = date('Y-m-d',strtotime($prm['T_ReceiveReferencePatientDOB']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="INSERT INTO t_receivereferencepatient (
|
||||
T_ReceiveReferencePatientT_ReceiveReferenceHeaderID,
|
||||
T_ReceiveReferencePatientNoRef,
|
||||
T_ReceiveReferencePatientName,
|
||||
T_ReceiveReferencePatientDOB,
|
||||
T_ReceiveReferencePatientM_SexID,
|
||||
T_ReceiveReferencePatientUserID,
|
||||
T_ReceiveReferencePatientTotal,
|
||||
T_ReceiveReferencePatientDPPercent,
|
||||
T_ReceiveReferencePatientDPAmount,
|
||||
T_ReceiveReferencePatientCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['T_ReceiveReferencePatientT_ReceiveReferenceHeaderID']}',
|
||||
'{$prm['T_ReceiveReferencePatientNoRef']}',
|
||||
'{$prm['T_ReceiveReferencePatientName']}',
|
||||
'{$pdob}',
|
||||
'{$prm['T_ReceiveReferencePatientM_SexID']}',
|
||||
'{$userid}',
|
||||
'{$prm['T_ReceiveReferencePatientTotal']}',
|
||||
'{$prm['T_ReceiveReferencePatientDPPercent']}',
|
||||
'{$prm['T_ReceiveReferencePatientDPAmount']}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$orderpatient_id = $this->db_onedev->insert_id();
|
||||
foreach($prm['ordertests'] as $k=>$v){
|
||||
$query = "INSERT INTO t_receivereferencetest (
|
||||
T_ReceiveReferenceTestT_ReceiveReferencePatientID,
|
||||
T_ReceiveReferenceTestT_TestID,
|
||||
T_ReceiveReferenceTestT_TestCode,
|
||||
T_ReceiveReferenceTestT_TestName,
|
||||
T_ReceiveReferenceTestT_TestPrice,
|
||||
T_ReceiveReferenceTestT_TestDisc,
|
||||
T_ReceiveReferenceTestT_TestDiscRp,
|
||||
T_ReceiveReferenceTestT_TestTotal,
|
||||
T_ReceiveReferenceTestUserID,
|
||||
T_ReceiveReferenceTestCreated,
|
||||
T_ReceiveReferenceTestLastUpdated
|
||||
)
|
||||
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 saveeditpatient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$order_id = $prm['T_ReceiveReferencePatientID'];
|
||||
$pdob = date('Y-m-d',strtotime($prm['T_ReceiveReferencePatientDOB']));
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query ="UPDATE t_receivereferencepatient SET
|
||||
T_ReceiveReferencePatientT_ReceiveReferenceHeaderID = '{$prm['T_ReceiveReferencePatientT_ReceiveReferenceHeaderID']}',
|
||||
T_ReceiveReferencePatientNoRef = '{$prm['T_ReceiveReferencePatientNoRef']}',
|
||||
T_ReceiveReferencePatientName = '{$prm['T_ReceiveReferencePatientName']}',
|
||||
T_ReceiveReferencePatientDOB = '{$pdob}',
|
||||
T_ReceiveReferencePatientM_SexID = '{$prm['T_ReceiveReferencePatientM_SexID']}',
|
||||
T_ReceiveReferencePatientTotal = '{$prm['T_ReceiveReferencePatientTotal']}',
|
||||
T_ReceiveReferencePatientDPPercent = '{$prm['T_ReceiveReferencePatientDPPercent']}',
|
||||
T_ReceiveReferencePatientDPAmount = '{$prm['T_ReceiveReferencePatientDPAmount']}',
|
||||
T_ReceiveReferencePatientUserID = '{$userid}'
|
||||
WHERE
|
||||
T_ReceiveReferencePatientID = '{$prm['T_ReceiveReferencePatientID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
foreach($prm['ordertests'] as $k=>$v){
|
||||
if($v['xid'] == 0 || $v['xid'] == '0'){
|
||||
$query = "INSERT INTO t_receivereferencetest (
|
||||
T_ReceiveReferenceTestT_ReceiveReferencePatientID,
|
||||
T_ReceiveReferenceTestT_TestID,
|
||||
T_ReceiveReferenceTestT_TestCode,
|
||||
T_ReceiveReferenceTestT_TestName,
|
||||
T_ReceiveReferenceTestT_TestPrice,
|
||||
T_ReceiveReferenceTestUserID,
|
||||
T_ReceiveReferenceTestCreated,
|
||||
T_ReceiveReferenceTestLastUpdated
|
||||
)
|
||||
VALUE(
|
||||
?,?,?,?,?,?,now(),now()
|
||||
)";
|
||||
$insert_new_test = $this->db_onedev->query($query,array(
|
||||
$order_id,
|
||||
$v['T_TestID'],
|
||||
$v['T_TestCode'],
|
||||
$v['T_TestName'],
|
||||
$v['total'],
|
||||
$userid
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(isset($prm['deleted_ordertests'])){
|
||||
foreach($prm['deleted_ordertests'] as $i=>$del){
|
||||
|
||||
$query = "UPDATE t_receivereferencetest SET
|
||||
T_ReceiveReferenceTestIsActive = 'N',
|
||||
T_ReceiveReferenceTestUserID = '{$userid}',
|
||||
T_ReceiveReferenceTestLastUpdated = now()
|
||||
WHERE
|
||||
T_ReceiveReferenceTestID = ?
|
||||
";
|
||||
$delete_exist_test = $this->db_onedev->query($query,array($del['T_ReceiveReferenceTestID'],));
|
||||
}
|
||||
}
|
||||
$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 f_bill_detail SET
|
||||
F_BillDetailIsActive = 'N',
|
||||
F_BillDetailUserID = '{$userid}'
|
||||
WHERE
|
||||
F_BillDetailID = '{$prm['F_BillDetailID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
//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.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_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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
188
one-api/application/controllers/mockup/billpayment/Bill.php
Normal file
188
one-api/application/controllers/mockup/billpayment/Bill.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
class Bill extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Bill API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function add_notes($orderid){
|
||||
$sql = " SELECT F_BillPaymentF_BillID as note_order_id,
|
||||
F_BillPaymentID as note_id,
|
||||
F_BillPaymentDate as note_date,
|
||||
F_BillPaymentNumber as note_number,
|
||||
GROUP_CONCAT(DISTINCT M_PaymentTypeName separator ' , ') as paymenttypes_name,
|
||||
SUM(F_BillPaymentDetailAmount) as note_amount,
|
||||
M_UserUsername as note_user,
|
||||
F_BillPaymentDetailIsActive as note_active,
|
||||
'xxx' as tests,
|
||||
'N' as show_detail
|
||||
FROM f_bill_payment
|
||||
JOIN f_bill_payment_detail ON F_BillPaymentDetailF_BillPaymentID = F_BillPaymentID
|
||||
JOIN m_paymenttype ON F_BillPaymentM_PaymentTypeID = M_PaymentTypeID
|
||||
LEFT JOIN m_user ON F_BillPaymentUserID = M_UserID
|
||||
WHERE
|
||||
F_BillPaymentF_BillID = {$orderid}
|
||||
GROUP BY F_BillPaymentID";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['tests'] = $this->add_tests($v['note_id']);
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("get notes", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function add_tagihans($orderid){
|
||||
$sql = " SELECT F_BillID as tagihan_id,
|
||||
T_OrderHeaderLabNumber as tagihan_number,
|
||||
F_BillDetailTotal as tagihan_total,
|
||||
F_BillDetailUnpaid as tagihan_tagihan,
|
||||
0 as tagihan_bayar,
|
||||
DATE_FORMAT(F_BillDueDate,'%d-%m-%Y') as tagihan_duedate,
|
||||
F_BillDetailIsActive as tagihan_active,
|
||||
'N' as show_detail,
|
||||
F_BillDetailID,
|
||||
F_BillDetailT_OrderHeaderID
|
||||
FROM f_bill
|
||||
JOIN f_bill_detail ON F_BillDetailF_BillID = F_BillID AND F_BillDetailIsActive = 'Y' AND F_BillDetailUnpaid > 0
|
||||
JOIN t_orderheader ON F_BillDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
WHERE
|
||||
F_BillID = {$orderid}
|
||||
GROUP BY F_BillDetailID";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
return $rows;
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("get notes", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function add_tests($orderid){
|
||||
$sql = " SELECT F_BillPaymentF_BillID as note_order_id,
|
||||
F_BillPaymentID as note_id,
|
||||
F_BillPaymentDate as note_date,
|
||||
F_BillPaymentNumber as note_number,
|
||||
GROUP_CONCAT(M_PaymentTypeName separator ' , ') as paymenttypes_name,
|
||||
SUM(F_BillPaymentDetailAmount) as note_amount,
|
||||
M_UserUsername as note_user,
|
||||
F_BillPaymentDetailIsActive as note_active,
|
||||
T_OrderHeaderLabNumber,
|
||||
F_BillDetailTotal,
|
||||
F_BillPaymentDetailAmount
|
||||
FROM f_bill_payment
|
||||
JOIN f_bill_payment_detail ON F_BillPaymentDetailF_BillPaymentID = F_BillPaymentID
|
||||
LEFT JOIN f_bill ON F_BillPaymentDetailF_BillID = F_BillID
|
||||
LEFT JOIN f_bill_detail ON F_BillPaymentDetailF_BillDetailID = F_BillDetailID
|
||||
LEFT JOIN t_orderheader ON F_BillDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_paymenttype ON F_BillPaymentM_PaymentTypeID = M_PaymentTypeID
|
||||
LEFT JOIN m_user ON F_BillPaymentDetailUserID = M_UserID
|
||||
WHERE
|
||||
F_BillPaymentID = {$orderid}
|
||||
GROUP BY F_BillPaymentDetailID";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
}
|
||||
return $rows;
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("get notes", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function search()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$company = $prm["company"];
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$where = "(F_BillIsActive = 'Y'AND F_BillTotal > 0 AND F_BillIsLunas = '{$status}' AND (F_BillNo LIKE '%{$search}%' OR F_BillPaymentNumber LIKE '%{$search}%') AND M_CompanyName LIKE '%{$company}%')";
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM f_bill
|
||||
LEFT JOIN f_bill_payment ON F_BillID = F_BillPaymentF_BillID AND F_BillPaymentIsActive = 'Y'
|
||||
LEFT JOIN m_company ON F_BillM_CompanyID = M_CompanyID
|
||||
LEFT JOIN m_mou ON F_BillM_MouID = M_MouID
|
||||
WHERE
|
||||
$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("f_bill count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT f_bill.*, f_bill_payment.*,
|
||||
M_CompanyName,
|
||||
M_MouName,
|
||||
IFNULL(F_BillTotal,0) as totalbill,
|
||||
IFNULL(F_BillTotal - F_BillUnpaid,0) as paid,
|
||||
IFNULL(F_BillUnpaid,0) as unpaid,
|
||||
F_BillIsLunas as flaglunas,
|
||||
GROUP_CONCAT(F_BillPaymentNumber SEPARATOR ', ') as F_BillPaymentNumber,
|
||||
SUM(F_BillPaymentAmount) as F_BillPaymentAmount,
|
||||
DATE_FORMAT(F_BillPaymentDate,'%d-%m-%Y') as F_BillPaymentDate,
|
||||
'' as notes,
|
||||
'' as tagihans
|
||||
FROM f_bill
|
||||
LEFT JOIN f_bill_payment ON F_BillID = F_BillPaymentF_BillID AND F_BillPaymentIsActive = 'Y'
|
||||
LEFT JOIN m_company ON F_BillM_CompanyID = M_CompanyID
|
||||
LEFT JOIN m_mou ON F_BillM_MouID = M_MouID
|
||||
WHERE
|
||||
$where
|
||||
GROUP BY F_BillID
|
||||
ORDER BY F_BillID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['notes'] = $this->add_notes($v['F_BillID']);
|
||||
$rows[$k]['tagihans'] = $this->add_tagihans($v['F_BillID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
604
one-api/application/controllers/mockup/billpayment/Payment.php
Normal file
604
one-api/application/controllers/mockup/billpayment/Payment.php
Normal file
@@ -0,0 +1,604 @@
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookup_type()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
'N' as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
'' as selected_card,
|
||||
'' as selected_edc,
|
||||
'' as selected_account,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'TRANSFER' THEN 'No. Rekening'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['selected_card'] = array('id'=>0,'name'=>'');
|
||||
$rows[$k]['selected_edc'] = array('id'=>0,'name'=>'');
|
||||
$rows[$k]['selected_account'] = array('id'=>0,'name'=>'');
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function selectpaymenttype(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM m_paymenttype
|
||||
WHERE
|
||||
M_PaymentTypeIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['paymenttypes'] = $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 selectbank(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT *
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC
|
||||
";
|
||||
//echo $query;
|
||||
$rows['banks'] = $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 selectaccount(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT M_BankAccountID as M_BankAccountID, CONCAT(Nat_BankCode,' (',M_BankAccountNo,')') as M_BankAccountName
|
||||
FROM m_bank_account
|
||||
JOIN nat_bank ON M_BankAccountNat_BankID = Nat_BankID
|
||||
WHERE
|
||||
M_BankAccountIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC";
|
||||
//echo $query;
|
||||
$rows['accounts'] = $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 lookup_banks()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT Nat_BankID as id, Nat_BankCode as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookup_accounts()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT M_BankAccountID as id, CONCAT(Nat_BankCode,' (',M_BankAccountNo,')') as name
|
||||
FROM m_bank_account
|
||||
JOIN nat_bank ON M_BankAccountNat_BankID = Nat_BankID
|
||||
WHERE
|
||||
M_BankAccountIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function searchcard(){
|
||||
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
|
||||
if($prm['search'] != ''){
|
||||
$sql = "
|
||||
SELECT count(*) as total
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankName like ?
|
||||
AND Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
else{
|
||||
$sql = "
|
||||
SELECT count(*) as total
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
$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;
|
||||
}
|
||||
if($prm['search'] != ''){
|
||||
$sql = "
|
||||
SELECT Nat_BankID as id, Nat_BankName as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankName like ?
|
||||
AND Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
else{
|
||||
$sql = "
|
||||
SELECT Nat_BankID as id, Nat_BankName as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName 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 pay()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$payments = $prm['payments'];
|
||||
//$xnumber = $this->db_onedev->query("SELECT `fn_numbering`('PAY') as numberx")->row()->numberx;
|
||||
$sql = "INSERT INTO f_bill_payment
|
||||
(F_BillPaymentF_BillID,F_BillPaymentDate,F_BillPaymentCreated,F_BillPaymentUserID)
|
||||
VALUES (?,CURDATE(),NOW(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid, $xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_bill_payment insert");
|
||||
exit;
|
||||
}
|
||||
$headerid = $this->db_onedev->insert_id();
|
||||
//echo $headerid;
|
||||
|
||||
foreach($payments as $k => $v){
|
||||
if($v['chex']){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
if($v['code'] == 'CASH'){
|
||||
$actual = $v['leftvalue'];
|
||||
$change = $v['rightvalue'];
|
||||
if($actual > 0){
|
||||
$amount = intval($v['leftvalue']) - intval($v['rightvalue']);
|
||||
}
|
||||
else{
|
||||
$amount = $actual;
|
||||
}
|
||||
|
||||
$sql = "CALL `sp_bill_payment_add_cash`(".$orderid.",".$amount.",".$amount.",".$headerid.",".$v['id'].",".$xuserid.")";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_bill_payment_detail cash insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
if(intval($v['leftvalue']) > 0){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
$selected_card = 0;
|
||||
$selected_edc = 0;
|
||||
$selected_account = 0;
|
||||
if($v['code'] == 'DEBIT' || $v['code'] == 'CREDIT' || $v['code'] == 'TRANSFER'){
|
||||
$selected_card = $v['selected_card']['id'];
|
||||
$selected_edc = $v['selected_edc']['id'];
|
||||
$selected_account = $v['selected_account']['id'];
|
||||
}
|
||||
$sql = "CALL `sp_bill_payment_add_noncash`(".$orderid.",".$amount.",".$amount.",".$headerid.",".$v['id'].",".$xuserid.",".$selected_card.",".$selected_edc.",".$selected_account.")";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_bill_payment_detail non cash insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
IF(M_PaymentTypeCode = 'CASH','Y','N') as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'TRANSFER' THEN 'Nomor Rekening'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$xdata = $this->db_onedev->query("SELECT F_BillPaymentID as idx, F_BillPaymentNumber as numberx FROM f_bill_payment WHERE F_BillPaymentID = {$headerid}")->row();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => array('types'=>$rows,'data'=>$xdata)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function paymanual()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$amount = $prm['amount'];
|
||||
$paymenttype = $prm['paymenttype'];
|
||||
if($prm['paymenttype'] == 1 || $prm['paymenttype'] == 5){
|
||||
$card = 0;
|
||||
$edc = 0;
|
||||
$account = 0;
|
||||
}elseif($prm['paymenttype'] == 4){
|
||||
$card = 0;
|
||||
$edc = 0;
|
||||
$account = $prm['account'];
|
||||
}else{
|
||||
$card = $prm['card'];
|
||||
$edc = $prm['edc'];
|
||||
$account = 0;
|
||||
}
|
||||
$voucher = $prm['voucher'];
|
||||
$bills = $prm['bills'];
|
||||
//$xnumber = $this->db_onedev->query("SELECT `fn_numbering`('PAY') as numberx")->row()->numberx;
|
||||
$sql = "INSERT INTO f_bill_payment
|
||||
(F_BillPaymentF_BillID,
|
||||
F_BillPaymentDate,
|
||||
F_BillPaymentAmount,
|
||||
F_BillPaymentM_PaymentTypeID,
|
||||
F_BillPaymentEDCNat_BankID,
|
||||
F_BillPaymentCardNat_BankID,
|
||||
F_BillPaymentM_BankAccountID,
|
||||
F_BillPaymentVoucherNumber,
|
||||
F_BillPaymentCreated,
|
||||
F_BillPaymentUserID)
|
||||
VALUES (?,
|
||||
CURDATE(),
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
NOW(),
|
||||
?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid,
|
||||
$amount,
|
||||
$paymenttype,
|
||||
$edc,
|
||||
$card,
|
||||
$account,
|
||||
$voucher,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
$headerid = $this->db_onedev->insert_id();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_bill_payment insert");
|
||||
exit;
|
||||
} else{
|
||||
$sqlbill = "UPDATE f_bill SET
|
||||
F_BillUnpaid = F_BillUnpaid - $amount,
|
||||
F_BillIsLunas = IF(F_BillUnpaid = 0,'Y','N')
|
||||
WHERE F_BillID = $orderid";
|
||||
$querybill = $this->db_onedev->query($sqlbill);
|
||||
|
||||
}
|
||||
|
||||
//echo $headerid;
|
||||
|
||||
foreach($bills as $k => $v){
|
||||
if($v['tagihan_bayar'] > 0){
|
||||
$F_BillDetailID = $v['F_BillDetailID'];
|
||||
$tagihan_bayar = $v['tagihan_bayar'];
|
||||
$F_BillDetailT_OrderHeaderID = $v['F_BillDetailT_OrderHeaderID'];
|
||||
$sql = "INSERT INTO f_bill_payment_detail(
|
||||
F_BillPaymentDetailF_BillPaymentID,
|
||||
F_BillPaymentDetailF_BillID,
|
||||
F_BillPaymentDetailF_BillDetailID,
|
||||
F_BillPaymentDetailAmount,
|
||||
F_BillPaymentDetailUserID,
|
||||
F_BillPaymentDetailCreated,
|
||||
F_BillPaymentDetailLastUpdated)
|
||||
VALUES(
|
||||
$headerid,
|
||||
$orderid,
|
||||
$F_BillDetailID,
|
||||
$tagihan_bayar,
|
||||
$xuserid,
|
||||
now(),
|
||||
now())";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$billpaymentdetailid = $this->db_onedev->insert_id();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_bill_payment_detail cash insert");
|
||||
exit;
|
||||
}else{
|
||||
$sqlbilldetail = "UPDATE f_bill_detail SET
|
||||
F_BillDetailUnpaid = F_BillDetailUnpaid - $tagihan_bayar
|
||||
WHERE F_BillDetailID = $F_BillDetailID";
|
||||
$querybilldetail = $this->db_onedev->query($sqlbilldetail);
|
||||
|
||||
$sqlpayment = "INSERT INTO f_payment
|
||||
(F_PaymentT_OrderHeaderID,
|
||||
F_PaymentDate,
|
||||
F_PaymentTotal,
|
||||
F_PaymentCreated,
|
||||
F_PaymentLastUpdated,
|
||||
F_PaymentM_UserID)
|
||||
VALUES(
|
||||
$F_BillDetailT_OrderHeaderID,
|
||||
now(),
|
||||
$tagihan_bayar,
|
||||
now(),
|
||||
now(),
|
||||
$xuserid)";
|
||||
$querypayment = $this->db_onedev->query($sqlpayment);
|
||||
$paymentid = $this->db_onedev->insert_id();
|
||||
$sqlpaymentdetail = "INSERT INTO f_paymentdetail
|
||||
(F_PaymentDetailF_PaymentID,
|
||||
F_PaymentDetailM_PaymentTypeID,
|
||||
F_PaymentDetailAmount,
|
||||
F_PaymentDetailActual,
|
||||
F_PaymentDetailChange,
|
||||
F_PaymentDetailEDCNat_BankID,
|
||||
F_PaymentDetailCardNat_BankID,
|
||||
F_PaymentDetailM_BankAccountID,
|
||||
F_PaymentDetailCreated,
|
||||
F_PaymentDetailLastUpdated,
|
||||
F_PaymentDetailUserID)
|
||||
VALUES(
|
||||
$paymentid,
|
||||
$paymenttype,
|
||||
$tagihan_bayar,
|
||||
$tagihan_bayar,
|
||||
0,
|
||||
$edc,
|
||||
$card,
|
||||
$account,
|
||||
now(),
|
||||
now(),
|
||||
$xuserid)";
|
||||
//echo $sqlpaymentdetail;
|
||||
$querypaymentdetail = $this->db_onedev->query($sqlpaymentdetail);
|
||||
|
||||
$sqleditbillpaymentdetail = "UPDATE f_bill_payment_detail SET
|
||||
F_BillPaymentDetailF_PaymentID = $paymentid
|
||||
WHERE F_BillPaymentDetailID = $billpaymentdetailid";
|
||||
$queryeditbillpaymentdetail = $this->db_onedev->query($sqleditbillpaymentdetail);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$xdata = $this->db_onedev->query("SELECT F_BillPaymentID as idx, F_BillPaymentNumber as numberx FROM f_bill_payment WHERE F_BillPaymentID = {$headerid}")->row();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => array('data'=>$xdata)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function delete_note()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$prmnota = $prm['nota'];
|
||||
$catatan = $prm['catatan'];
|
||||
$sql = "UPDATE f_bill_payment SET F_BillPaymentIsActive = 'N', F_BillPaymentNote = '{$catatan}' WHERE F_BillPaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_bill_payment delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE f_bill_payment_detail SET F_BillPaymentDetailIsActive = 'N' WHERE F_BillPaymentDetailF_BillPaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_bill_payment_detail delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('prm'=>$prm)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
213
one-api/application/controllers/mockup/clinic/fo/Area.php
Normal file
213
one-api/application/controllers/mockup/clinic/fo/Area.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
class Area extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "AREA API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search_province()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$src = "%";
|
||||
|
||||
if ($prm['search'])
|
||||
$src = "%{$prm['search']}%";
|
||||
|
||||
$max_rst = 40;
|
||||
$tot_count =0;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_province
|
||||
where M_ProvinceName LIKE ?
|
||||
and M_ProvinceIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, array($src));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_province count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_ProvinceID, M_ProvinceName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default
|
||||
from m_province
|
||||
left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_provinceid = M_ProvinceID
|
||||
where M_ProvinceName LIKE ?
|
||||
and M_ProvinceIsActive = 'Y'
|
||||
order by M_ProvinceName
|
||||
limit 0, {$max_rst}
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, array($src));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_province rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_city()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$src = "%";
|
||||
|
||||
if ($prm['search'])
|
||||
$src = "%{$prm['search']}%";
|
||||
|
||||
$max_rst = 40;
|
||||
$tot_count =0;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_city
|
||||
where M_CityName LIKE ?
|
||||
and M_CityIsActive = 'Y'
|
||||
and M_CityM_ProvinceID = ?";
|
||||
$query = $this->db_smartone->query($sql, array($src, $prm['province_id']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_CityID, M_CityName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default
|
||||
from m_city
|
||||
left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_cityid = M_CityID
|
||||
where M_CityName LIKE ?
|
||||
and M_CityIsActive = 'Y'
|
||||
and M_CityM_ProvinceID = ?
|
||||
order by M_CityName
|
||||
limit 0, {$max_rst}
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, array($src, $prm['province_id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_district()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$src = "%";
|
||||
|
||||
if ($prm['search'])
|
||||
$src = "%{$prm['search']}%";
|
||||
|
||||
$max_rst = 40;
|
||||
$tot_count =0;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_district
|
||||
where M_DistrictName LIKE ?
|
||||
and M_DistrictIsActive = 'Y'
|
||||
and M_DistrictM_CityID = ?";
|
||||
$query = $this->db_smartone->query($sql, array($src, $prm['city_id']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_DistrictID, M_DistrictName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default
|
||||
from m_district
|
||||
left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_districtid = M_DistrictID
|
||||
where M_DistrictName LIKE ?
|
||||
and M_DistrictIsActive = 'Y'
|
||||
and M_DistrictM_CityID = ?
|
||||
order by M_DistrictName
|
||||
-- limit 0, {$max_rst}
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, array($src, $prm['city_id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_district rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_kelurahan()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$src = "%";
|
||||
|
||||
if ($prm['search'])
|
||||
$src = "%{$prm['search']}%";
|
||||
|
||||
$max_rst = 40;
|
||||
$tot_count =0;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_kelurahan
|
||||
where M_KelurahanName LIKE ?
|
||||
and M_KelurahanIsActive = 'Y'
|
||||
and M_KelurahanM_DistrictID = ?";
|
||||
$query = $this->db_smartone->query($sql, array($src, $prm['district_id']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_kelurahan count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_KelurahanID, M_KelurahanName, IF(Conf_DefaultID IS NULL, 'N', 'Y') is_default
|
||||
from m_kelurahan
|
||||
left join conf_default on conf_defaultisactive = 'Y' and conf_defaultm_kelurahanid = M_KelurahanID
|
||||
where M_KelurahanName LIKE ?
|
||||
and M_KelurahanIsActive = 'Y'
|
||||
and M_KelurahanM_DistrictID = ?
|
||||
order by M_KelurahanName
|
||||
limit 0, {$max_rst}
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, array($src, $prm['district_id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_kelurahan rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
one-api/application/controllers/mockup/clinic/fo/Conf.php
Normal file
36
one-api/application/controllers/mockup/clinic/fo/Conf.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class Conf extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "CONF API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$tot_count = 1;
|
||||
|
||||
$sql = "SELECT * FROM conf_clinic";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("CONF rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
class Diagnose extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Diagnose API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("clinicdev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 25;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_diagnose
|
||||
where M_DiagnoseIsActive = 'Y'
|
||||
and M_DiagnoseName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_diagnose count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_DiagnoseID, M_DiagnoseName
|
||||
from m_diagnose
|
||||
where M_DiagnoseIsActive = 'Y'
|
||||
and M_DiagnoseName like ?
|
||||
limit {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_diagnose rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
78
one-api/application/controllers/mockup/clinic/fo/Doctor.php
Normal file
78
one-api/application/controllers/mockup/clinic/fo/Doctor.php
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Doctor extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_doctor
|
||||
JOIN m_doctorpj ON M_DoctorID = M_DoctorPJM_DoctorID and M_DoctorIsActive = 'Y'
|
||||
where M_DoctorIsActive = 'Y'
|
||||
and M_DoctorPJIsClinic = 'Y'
|
||||
and M_DoctorName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_DoctorID, M_DoctorIsDefault, M_DoctorIsPJ,
|
||||
concat(IFNULL(M_DoctorPrefix, ''),' ',M_DoctorName, ' ', IFNULL(M_DoctorSufix, '')) as M_DoctorName,
|
||||
IFNULL( concat('[', group_concat(JSON_OBJECT('M_DoctorAddressDescription', M_DoctorAddressDescription, 'M_DoctorAddressID', M_DoctorAddressID) SEPARATOR ','), ']'), '[]') as address
|
||||
from m_doctor
|
||||
JOIN m_doctorpj ON M_DoctorID = M_DoctorPJM_DoctorID and M_DoctorIsActive = 'Y'
|
||||
left join m_doctoraddress on M_DoctorAddressIsActive = 'Y'
|
||||
and M_DoctorAddressM_DoctorID = M_DoctorID
|
||||
where M_DoctorPJIsActive = 'Y'
|
||||
and M_DoctorIsClinic = 'Y'
|
||||
and concat(IFNULL(M_DoctorPrefix, ''),' ',M_DoctorName, ' ', IFNULL(M_DoctorSufix, '')) like ?
|
||||
group by M_DoctorID";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['address'] = json_decode($v['address']);
|
||||
|
||||
$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_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
67
one-api/application/controllers/mockup/clinic/fo/Gcs.php
Normal file
67
one-api/application/controllers/mockup/clinic/fo/Gcs.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
class Gcs extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "GCS API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("clinicdev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 25;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_gcs
|
||||
where M_GcsIsActive = 'Y'
|
||||
and M_GcsName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_gcs count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_GcsID, M_GcsName
|
||||
from m_gcs
|
||||
where M_GcsIsActive = 'Y'
|
||||
and M_GcsName like ?
|
||||
limit {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_gcs rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
67
one-api/application/controllers/mockup/clinic/fo/Order.php
Normal file
67
one-api/application/controllers/mockup/clinic/fo/Order.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
class Order extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "ORDER API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("clinicdev", true);
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['header']['complaint'] = str_replace(PHP_EOL, '<br>', $prm['header']['complaint']);
|
||||
$header_json = json_encode($prm['header']);
|
||||
$payment_json = json_encode($prm['payment']);
|
||||
|
||||
$uid = $this->sys_user['M_UserID'];
|
||||
$sql = "CALL sp_clinic_fo_save('{$prm['order_id']}', '{$header_json}', '{$payment_json}', '{$uid}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
|
||||
// if ($rst->status == "OK")
|
||||
// {
|
||||
// // persiapkan curl
|
||||
// $ch = curl_init();
|
||||
|
||||
// // set url
|
||||
// curl_setopt($ch, CURLOPT_URL, "http://anggrek.aplikasi.web.id:9090/ticket/KLINIK");
|
||||
|
||||
// // return the transfer as a string
|
||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
// // $output contains the output string
|
||||
// $output = json_decode(curl_exec($ch));
|
||||
|
||||
// // tutup curl
|
||||
// curl_close($ch);
|
||||
|
||||
// // menampilkan hasil curl
|
||||
// // echo $output;
|
||||
// if ($output != null)
|
||||
// if ($output->status == "OK")
|
||||
// $rst->data->queue = $output->data[0]->number;
|
||||
// }
|
||||
|
||||
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
264
one-api/application/controllers/mockup/clinic/fo/Patient.php
Normal file
264
one-api/application/controllers/mockup/clinic/fo/Patient.php
Normal file
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
/*
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'noreg' => '%',
|
||||
'name' => '%',
|
||||
'hp' => '%',
|
||||
'dob' => '%',
|
||||
'address' => '%'
|
||||
];
|
||||
|
||||
if ($prm['noreg'] != '')
|
||||
$q['noreg'] = "%{$prm['noreg']}%";
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$e = explode('+', $prm['search']);
|
||||
if (isset($e[0]))
|
||||
$q['name'] = "%{$e[0]}%";
|
||||
if (isset($e[1]))
|
||||
$q['hp'] = "%{$e[1]}%";
|
||||
if (isset($e[2]))
|
||||
$q['dob'] = "%{$e[2]}%";
|
||||
if (isset($e[3]))
|
||||
$q['address'] = "%{$e[3]}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct m_patientid) total
|
||||
from
|
||||
m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID and M_PatientAddressIsActive = 'Y'
|
||||
where M_PatientNoReg like ?
|
||||
and M_PatientName LIKE ?
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and ((DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL)
|
||||
and M_PatientAddressDescription LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['noreg'], $q['name'], $q['hp'], $q['dob'], $q['address']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
M_PatientName M_PatientRealName, M_TitleID, M_TitleName, M_SexID, M_SexName,
|
||||
M_PatientHP, M_PatientPOB, M_PatientDOB, M_PatientNote,
|
||||
concat(M_PatientAddressDescription, '\n\n', m_kelurahanname, ', ', m_districtname,
|
||||
'\n', m_cityname, ', ', m_provincename) as M_PatientAddress,
|
||||
M_PatientAddressDescription, M_PatientM_IdTypeID, M_PatientIDNumber,
|
||||
IFNULL(M_PatientNote, '') M_PatientNote, M_PatientPhoto, IF(M_PatientPhone IS NULL OR M_PatientPhone = '', M_PatientHP, M_PatientPhone) hp,
|
||||
fn_fo_patient_visit(M_PatientID) info,
|
||||
M_KelurahanID, M_DistrictID, M_CityID, M_ProvinceID, M_PatientM_ReligionID,
|
||||
IFNULL(M_ReligionName, '-') M_ReligionName
|
||||
from
|
||||
m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_sex on M_PatientM_SexID = M_SexID
|
||||
join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID and M_PatientAddressIsActive = 'Y'
|
||||
left join m_kelurahan on m_patientaddressm_kelurahanid = m_kelurahanid
|
||||
left join m_district on m_kelurahanm_districtid = m_districtid
|
||||
left join m_city on m_districtm_cityid = m_cityid
|
||||
left join m_province on m_citym_provinceid = m_provinceid
|
||||
left join m_religion on m_patientm_religionid = m_religionid
|
||||
where M_PatientNoReg like ?
|
||||
and M_PatientName LIKE ?
|
||||
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and ((DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL)
|
||||
and M_PatientAddressDescription LIKE ?
|
||||
group by m_patientid
|
||||
limit 0,{$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['noreg'], $q['name'], $q['hp'], $q['dob'], $q['address']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['info'] = json_decode($v['info']);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows), "query" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function add_new()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['M_PatientDOB'] = date('Y-m-d', strtotime($prm['M_PatientDOB']));
|
||||
$ptn = [
|
||||
'M_PatientName' => $prm['M_PatientName'],
|
||||
'M_PatientM_TitleID' => $prm['M_PatientM_TitleID'],
|
||||
'M_PatientSuffix' => $prm['M_PatientSuffix'],
|
||||
'M_PatientM_SexID' => $prm['M_PatientM_SexID'],
|
||||
'M_PatientM_ReligionID' => $prm['M_PatientM_ReligionID'],
|
||||
'M_PatientDOB' => $prm['M_PatientDOB'],
|
||||
'M_PatientPOB' => $prm['M_PatientPOB'],
|
||||
'M_PatientHP' => $prm['M_PatientHP'],
|
||||
'M_PatientPhone' => $prm['M_PatientPhone'],
|
||||
'M_PatientEmail' => $prm['M_PatientEmail'],
|
||||
'M_PatientM_IdTypeID' => $prm['M_PatientM_IdTypeID'],
|
||||
'M_PatientIDNumber' => $prm['M_PatientIDNumber'],
|
||||
'M_PatientNote' => $prm['M_PatientNote']
|
||||
];
|
||||
$this->db_smartone->insert('m_patient', $ptn);
|
||||
|
||||
$err = $this->db_smartone->error();
|
||||
if ( $err['message'] != "" )
|
||||
{
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $this->db_smartone->insert_id();
|
||||
|
||||
// LOG FO
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADD', '{$ptn}', '0')");
|
||||
|
||||
// save address
|
||||
$add = [
|
||||
'M_PatientAddressM_PatientID' => $id,
|
||||
'M_PatientAddressDescription' => $prm['M_PatientAddressDescription'],
|
||||
'M_PatientAddressM_KelurahanID' => $prm['M_PatientAddressM_KelurahanID']
|
||||
];
|
||||
$this->db_smartone->insert('m_patientaddress', $add);
|
||||
|
||||
// LOG FO
|
||||
$add = json_encode($add);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADDRESS.ADD', '{$add}', '0')");
|
||||
|
||||
// get
|
||||
$r = $this->db_smartone->where('M_PatientID', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
$rst = array("id" => $id, 'noreg'=>$r->M_PatientNoReg);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
|
||||
function edit()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['M_PatientDOB'] = date('Y-m-d', strtotime($prm['M_PatientDOB']));
|
||||
|
||||
$this->db_smartone->set('M_PatientName', $prm['M_PatientName'])
|
||||
->set('M_PatientM_TitleID', $prm['M_PatientM_TitleID'])
|
||||
->set('M_PatientSuffix', $prm['M_PatientSuffix'])
|
||||
->set('M_PatientM_SexID', $prm['M_PatientM_SexID'])
|
||||
->set('M_PatientM_ReligionID', $prm['M_PatientM_ReligionID'])
|
||||
->set('M_PatientDOB', $prm['M_PatientDOB'])
|
||||
->set('M_PatientPOB', $prm['M_PatientPOB'])
|
||||
->set('M_PatientHP', $prm['M_PatientHP'])
|
||||
->set('M_PatientPhone', $prm['M_PatientPhone'])
|
||||
->set('M_PatientEmail', $prm['M_PatientEmail'])
|
||||
->set('M_PatientM_IdTypeID', $prm['M_PatientM_IdTypeID'])
|
||||
->set('M_PatientIDNumber', $prm['M_PatientIDNumber'])
|
||||
->set('M_PatientNote', $prm['M_PatientNote'])
|
||||
->where('M_PatientID', $prm['id'])
|
||||
->update('m_patient');
|
||||
|
||||
$err = $this->db_smartone->error();
|
||||
if ( $err['message'] != "" )
|
||||
{
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $prm['id'];
|
||||
|
||||
// LOG FO
|
||||
unset($prm['token']);
|
||||
$ptn = json_encode($prm);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.EDIT', '{$ptn}', '{$this->sys_user['M_UserID']}')");
|
||||
|
||||
// save address
|
||||
// $add = [
|
||||
// 'M_PatientAddressM_PatientID' => $id,
|
||||
// 'M_PatientAddressDescription' => $prm['M_PatientAddressDescription'],
|
||||
// 'M_PatientAddressM_KelurahanID' => $prm['M_PatientAddressM_KelurahanID']
|
||||
// ];
|
||||
// $this->db_smartone->insert('m_patientaddress', $add);
|
||||
|
||||
// LOG FO
|
||||
// $add = json_encode($add);
|
||||
// $this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADDRESS.ADD', '{$add}', '0')");
|
||||
|
||||
// get
|
||||
$r = $this->db_smartone->where('M_PatientID', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
$rst = array("id" => $id, 'noreg'=>$r->M_PatientNoReg);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
|
||||
public function search_idtype()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_IdTypeID, M_IdTypeName
|
||||
FROM m_idtype
|
||||
WHERE M_IdTypeIsActive = 'Y'
|
||||
ORDER BY M_IdTypeName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_idtype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
217
one-api/application/controllers/mockup/clinic/fo/Payment.php
Normal file
217
one-api/application/controllers/mockup/clinic/fo/Payment.php
Normal file
@@ -0,0 +1,217 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Payment API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("clinicdev", true);
|
||||
}
|
||||
|
||||
public function get_order() {
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$rst = ["order_header"=>[], "order_detail"=>[]];
|
||||
|
||||
$sql = "
|
||||
select T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumber as order_no,
|
||||
T_OrderHeaderDate as order_date,
|
||||
T_OrderHeaderSubTotal as order_subtotal,
|
||||
T_OrderHeaderRounding as order_rounding,
|
||||
T_OrderHeaderTotal as order_total,
|
||||
M_PatientName as patient_name,
|
||||
M_PatientNoReg as patient_mr,
|
||||
M_MouName as order_mou,
|
||||
M_CompanyName as order_company
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
where T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = (array) $query->row();
|
||||
$rst['order_header'] = $rows;
|
||||
// $result = array("status" => "OK" , "data" => $rst);
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// { n:1, d_id:1, t_id:1, t_name:'SGOT', t_price:80000, t_disctotal:7000, t_total:73000 },
|
||||
// { n:2, d_id:2, t_id:2, t_name:'SGPT', t_price:75000, t_disctotal:8000, t_total:67000 }
|
||||
// T_OrderDetailPrice double [0]
|
||||
// T_OrderDetailPriceForDisc double [0]
|
||||
// T_OrderDetailDisc double [0]
|
||||
// T_OrderDetailDiscAmount double [0]
|
||||
// T_OrderDetailTotal
|
||||
|
||||
$sql = "
|
||||
select T_OrderDetailID as d_id,
|
||||
T_OrderDetailT_TestID as t_id,
|
||||
T_OrderDetailT_TestName as t_name,
|
||||
T_OrderDetailPrice as t_price,
|
||||
T_OrderDetailDiscTotal as t_disctotal,
|
||||
T_OrderDetailTotal as t_total
|
||||
from t_orderdetail
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_ORderDetailIsActive = 'Y'";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rst['order_detail'] = $rows;
|
||||
|
||||
$result = array("status" => "OK" , "data" => $rst);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 100;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_paymenttype count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_PaymentTypeID payment_type_id, M_PaymentTypeName payment_type_name, M_PaymentTypeCode payment_type_code,
|
||||
0 payment_amount, '' payment_note, 'Nomor Kartu' payment_note_label, 'N' payment_enable,
|
||||
0 payment_change, 0 payment_actual, 0 payment_card_id, 0 payment_edc_id, 0 payment_account_id
|
||||
from m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v) {
|
||||
|
||||
if ($v['payment_type_code'] == 'CASH')
|
||||
$v['payment_note_label'] = 'Kembali';
|
||||
if ($v['payment_type_code'] == 'VOUCHER')
|
||||
$v['payment_note_label'] = 'Nomor Voucher';
|
||||
|
||||
$rows[$k] = $v;
|
||||
}
|
||||
|
||||
$result = $rows;
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_paymenttype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$payment_json = json_encode($prm['payments']);
|
||||
|
||||
$sql = "CALL sp_fo_payment('{$prm['order_id']}', '{$payment_json}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save payment", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function log_nota()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$dblog = $this->load->database('onelog', true);
|
||||
|
||||
$p = $this->db_smartone->where('c_orderheaderid', $prm['order_id'])
|
||||
->get('c_orderheader')
|
||||
->row();
|
||||
|
||||
$uid = $this->sys_user['M_UserID'];
|
||||
$q = $dblog->set("Log_ClinicUserID", $uid)
|
||||
->set("Log_ClinicJson", json_encode(["order_id"=>$prm['order_id'], "patient_id"=>$p->C_OrderHeaderM_PatientID]))
|
||||
->set("Log_ClinicCode", "CLINIC.PRINT.RECEIPT")
|
||||
->insert('log_clinic');
|
||||
|
||||
if ($q) {
|
||||
$id = $dblog->insert_id();
|
||||
$this->sys_ok($id);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("LOG Nota",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_bank()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT Nat_BankID, Nat_BankName
|
||||
FROM nat_bank ORDER BY Nat_BankName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows, "total"=>sizeof($rows)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("NAT BANK",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
144
one-api/application/controllers/mockup/clinic/fo/Photo.php
Normal file
144
one-api/application/controllers/mockup/clinic/fo/Photo.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Photo extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Photo API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->load->library('ImageManipulator');
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
|
||||
$home_dir = "/home/one/Web/";
|
||||
$target_dir = $home_dir . "one-media/one-photo/patient/" . date("Y") . "/";
|
||||
|
||||
$y = $this->regenerateOldPhoto($home_dir, $inp['id']);
|
||||
|
||||
// get patient mr
|
||||
$p = $this->db_smartone->select("M_PatientNoReg")
|
||||
->where("M_PatientID", $inp['id'])
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
if (!file_exists($target_dir)) {
|
||||
mkdir($target_dir, 0755, true);
|
||||
}
|
||||
|
||||
$target_path = $target_dir . $p->M_PatientNoReg . ".jpg";
|
||||
$this->base64_to_jpeg($inp['data'], $target_path);
|
||||
|
||||
// CROP Image
|
||||
$im = new ImageManipulator($target_path);
|
||||
$w = $im->getWidth();
|
||||
$h = $im->getHeight();
|
||||
|
||||
$mw = ceil(3 * $h / 4);
|
||||
if ($w <= $mw)
|
||||
{
|
||||
$x1 = 0;
|
||||
$y1 = 0;
|
||||
$x2 = $w;
|
||||
$y2 = $h;
|
||||
}
|
||||
else
|
||||
{
|
||||
$x1 = floor(($w - $mw) / 2);
|
||||
$y1 = 0;
|
||||
$x2 = ceil($w - (($w - $mw) / 2));
|
||||
$y2 = $h;
|
||||
}
|
||||
|
||||
$im->crop($x1, $y1, $x2, $y2); // takes care of out of boundary conditions automatically
|
||||
$im->save($target_path);
|
||||
|
||||
$x = $this->generateThumbnail($target_path, 75, 100);
|
||||
|
||||
// Save to DB
|
||||
$this->db_smartone->set("M_PatientPhoto", "/" . str_replace($home_dir, "", $target_path))
|
||||
->set("M_PatientPhotoThumb", "/" . str_replace($home_dir, "", $x))
|
||||
->set('M_PatientPhotoCounter', '`M_PatientPhotoCounter` + 1', false)
|
||||
->where('M_PatientID', $inp['id'])
|
||||
->update('m_patient');
|
||||
|
||||
// LOGGING
|
||||
$code = $y ? "PHOTO.PATIENT.EDIT" : "PHOTO.PATIENT.ADD";
|
||||
$one_log = $this->load->database('onelog', true);
|
||||
$one_log->set('Log_PhotoCode', $code)
|
||||
->set('Log_PhotoM_PatientID', $inp['id'])
|
||||
->set('Log_PhotoUrl', $y ? $y : "/" . str_replace($home_dir, "", $target_path))
|
||||
->insert('log_photo');
|
||||
|
||||
$this->sys_ok(["rename"=>$y, "patient_id"=>$inp['id'], "patient_mr"=>$p->M_PatientNoReg, "photo_url"=>"http://" . $_SERVER['SERVER_NAME'] . "/" . str_replace($home_dir, "", $target_path) . "?d=" . date("YmdHis")]);
|
||||
}
|
||||
|
||||
function base64_to_jpeg($base64_string, $output_file) {
|
||||
// open the output file for writing
|
||||
$ifp = fopen( $output_file, 'wb' );
|
||||
|
||||
// split the string on commas
|
||||
// $data[ 0 ] == "data:image/png;base64"
|
||||
// $data[ 1 ] == <actual base64 string>
|
||||
$data = explode( ',', $base64_string );
|
||||
|
||||
// we could add validation here with ensuring count( $data ) > 1
|
||||
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
|
||||
|
||||
// clean up the file resource
|
||||
fclose( $ifp );
|
||||
|
||||
return $output_file;
|
||||
}
|
||||
|
||||
function generateThumbnail($img, $width, $height, $quality = 90)
|
||||
{
|
||||
if (is_file($img)) {
|
||||
$imagick = new Imagick(realpath($img));
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->thumbnailImage($width, $height, false, false);
|
||||
$filename_no_ext = reset(explode('.', $img));
|
||||
if (file_put_contents($filename_no_ext . '_thumb' . '.jpg', $imagick) === false) {
|
||||
throw new Exception("Could not put contents.");
|
||||
}
|
||||
return $filename_no_ext . '_thumb' . '.jpg';
|
||||
}
|
||||
else {
|
||||
throw new Exception("No valid image provided with {$img}.");
|
||||
}
|
||||
}
|
||||
|
||||
function regenerateOldPhoto($home_dir, $id)
|
||||
{
|
||||
$r = $this->db_smartone->select('m_patientphoto, m_patientphotocounter', false)
|
||||
->where('m_patientid', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
if ($r->m_patientphoto != null && $r->m_patientphotocounter > 0) {
|
||||
$full_path = substr_replace($home_dir ,"", -1) . $r->m_patientphoto;
|
||||
$path_parts = pathinfo($full_path);
|
||||
|
||||
$rename = $path_parts['dirname'] . '/' . $path_parts['filename'] . '-' . $r->m_patientphotocounter . '.' . $path_parts['extension'];
|
||||
rename($full_path, $rename);
|
||||
// echo $path_parts['dirname'], "\n";
|
||||
// echo $path_parts['extension'], "\n";
|
||||
// echo $path_parts['filename'], "\n";
|
||||
|
||||
return "/" . str_replace($home_dir, "", $rename);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
409
one-api/application/controllers/mockup/clinic/fo/Px.php
Normal file
409
one-api/application/controllers/mockup/clinic/fo/Px.php
Normal file
@@ -0,0 +1,409 @@
|
||||
<?php
|
||||
//diberi tambahan pembeda IsFromPanel
|
||||
//utk contoh kasus yg ndak bisa di delete
|
||||
//sementara profile di ambilkan dari panel juga dengan IsFromPanel = N
|
||||
class Px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Px API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function profile() {
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
$sql = "select count(distinct T_TestPanelID) total
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ? ";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_testpanel count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ?
|
||||
limit 0,20";
|
||||
$query = $this->db_smartone->query($sql,$sql_param);
|
||||
$xrows = $query->result_array();
|
||||
$a_tpid = "-1";
|
||||
foreach($xrows as $r) {
|
||||
$a_tpid .= "," . $r["T_TestPanelID"];
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID,T_TestPanelName,
|
||||
T_TestID,T_TestName, 'N' IsFromPanel, T_TestRequirement,
|
||||
t_testprice.*
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
where
|
||||
T_TestPanelID in ( $a_tpid ) ";
|
||||
$query = $this->db_smartone->query($sql,array($mouCompanyID));
|
||||
$xrows = $query->result_array();
|
||||
$rows = array();
|
||||
$prev_tpanel_id = 0;
|
||||
foreach($xrows as $r) {
|
||||
$tpanel_id = $r["T_TestPanelID"];
|
||||
if ($tpanel_id != $prev_tpanel_id) {
|
||||
$rows[] = array(
|
||||
"T_TestPanelID" => $r["T_TestPanelID"],
|
||||
"T_TestPanelName" => $r["T_TestPanelName"],
|
||||
"test" => array()
|
||||
);
|
||||
}
|
||||
$idx = count($rows) - 1;
|
||||
$rows[$idx]["test"][] = $r;
|
||||
$prev_tpanel_id = $tpanel_id;
|
||||
}
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function panel() {
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
$sql = "select count(distinct T_TestPanelID) total
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ? ";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_testpanel count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ?
|
||||
limit 0,20";
|
||||
$query = $this->db_smartone->query($sql,$sql_param);
|
||||
$xrows = $query->result_array();
|
||||
$a_tpid = "-1";
|
||||
foreach($xrows as $r) {
|
||||
$a_tpid .= "," . $r["T_TestPanelID"];
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID,T_TestPanelName,
|
||||
T_TestID,T_TestName, 'Y' IsFromPanel,T_TestRequirement,
|
||||
t_testprice.*
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
where
|
||||
T_TestPanelID in ( $a_tpid )
|
||||
order by T_TestPanelID";
|
||||
$query = $this->db_smartone->query($sql,array($mouCompanyID));
|
||||
$xrows = $query->result_array();
|
||||
$rows = array();
|
||||
$prev_tpanel_id = 0;
|
||||
foreach($xrows as $r) {
|
||||
$tpanel_id = $r["T_TestPanelID"];
|
||||
if ($tpanel_id != $prev_tpanel_id) {
|
||||
$rows[] = array(
|
||||
"T_TestPanelID" => $r["T_TestPanelID"],
|
||||
"T_TestPanelName" => $r["T_TestPanelName"],
|
||||
"test" => array()
|
||||
);
|
||||
}
|
||||
$idx = count($rows) - 1;
|
||||
$rows[$idx]["test"][] = $r;
|
||||
$prev_tpanel_id = $tpanel_id;
|
||||
}
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_old()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
|
||||
$sql_param = array("%$search%");
|
||||
$sql = "select count(distinct T_TestID) total
|
||||
from
|
||||
t_test
|
||||
|
||||
where
|
||||
T_TestIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
AND T_TestName like ? ";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_company count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select distinct T_TestID,T_TestName, 'N' IsFromPanel, T_TestRequirement
|
||||
from
|
||||
t_test
|
||||
where
|
||||
T_TestIsActive = 'Y'
|
||||
AND T_TestIsPrice = 'Y'
|
||||
AND T_TestName like ?
|
||||
limit 0,20
|
||||
";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_count_v2(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["data"];
|
||||
} else {
|
||||
$this->sys_error_db("PX count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($prm['order_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byorder_v2(?, ?)", [$prm['order_id'], $mouCompanyID]);
|
||||
else if ($search == "")
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_favorite_v2(?, ?)", $sql_param);
|
||||
else
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_v2(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
// echo $this->db_smartone->last_query();
|
||||
// $query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$id_to_remove = [];
|
||||
|
||||
// var_dump($rows);
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['requirement'] = [];
|
||||
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$v['T_TestID']}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['requirement'] = json_decode($x->x);
|
||||
|
||||
$rows[$k]['nat_test'] = json_decode($v['nat_test']);
|
||||
$rows[$k]['child_test'] = json_decode($v['child_test']);
|
||||
|
||||
// IF PROFILE
|
||||
if ($v['px_type'] == "PR" || $v['px_type'] == "PXR") {
|
||||
|
||||
if ($v['T_TestID'] == null)
|
||||
{
|
||||
$id_to_remove[] = $k;
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
foreach ($rows[$k]['child_test'] as $l => $w) {
|
||||
$rows[$k]['child_test'][$l]->requirement = [];
|
||||
$rows[$k]['child_test'][$l]->nat_test = json_decode($w->nat_test);
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$w->T_TestID}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['child_test'][$l]->requirement = json_decode($x->x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE INDEXES
|
||||
|
||||
foreach ($id_to_remove as $l => $w)
|
||||
{ $x = $w - $l; array_splice($rows, $x, 1); }
|
||||
|
||||
$result = array("total" => $tot_count, "records" => (array) $rows, "query" => $sqlx, "query2" => $sqly );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_count(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["data"];
|
||||
} else {
|
||||
$this->sys_error_db("PX count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($prm['order_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byorder(?, ?)", [$prm['order_id'], $mouCompanyID]);
|
||||
else if ($search == "")
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_favorite(?, ?)", $sql_param);
|
||||
else
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
// echo $this->db_smartone->last_query();
|
||||
// $query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$id_to_remove = [];
|
||||
|
||||
// var_dump($rows);
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['requirement'] = [];
|
||||
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$v['T_TestID']}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['requirement'] = json_decode($x->x);
|
||||
|
||||
$rows[$k]['nat_test'] = json_decode($v['nat_test']);
|
||||
$rows[$k]['child_test'] = json_decode($v['child_test']);
|
||||
|
||||
// IF PROFILE
|
||||
if ($v['px_type'] == "PR" || $v['px_type'] == "PXR") {
|
||||
|
||||
if ($v['T_TestID'] == null)
|
||||
{
|
||||
$id_to_remove[] = $k;
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
foreach ($rows[$k]['child_test'] as $l => $w) {
|
||||
$rows[$k]['child_test'][$l]->requirement = [];
|
||||
$rows[$k]['child_test'][$l]->nat_test = json_decode($w->nat_test);
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$w->T_TestID}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['child_test'][$l]->requirement = json_decode($x->x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE INDEXES
|
||||
|
||||
foreach ($id_to_remove as $l => $w)
|
||||
{ $x = $w - $l; array_splice($rows, $x, 1); }
|
||||
|
||||
$result = array("total" => $tot_count, "records" => (array) $rows, "query" => $sqlx, "query2" => $sqly );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_price()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$r = [];
|
||||
|
||||
$sql_param = array($prm['test_id'], date('Y-m-d'), $prm['cito'], $prm['mou_id']);
|
||||
$sql = "select fn_price(?, ?, ?, ?) as price";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query) {
|
||||
$r = $query->result_array()[0];
|
||||
$r = json_decode($r['price']);
|
||||
$this->sys_ok($r);
|
||||
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("get price", $this->db_smartone);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
class Religion extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Religion API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 25;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_religion
|
||||
where M_ReligionIsActive = 'Y'
|
||||
and M_ReligionName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_religion count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_ReligionID, M_ReligionName
|
||||
from m_religion
|
||||
where M_ReligionIsActive = 'Y'
|
||||
and M_ReligionName like ?
|
||||
limit {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_religion rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
72
one-api/application/controllers/mockup/clinic/fo/Sex.php
Normal file
72
one-api/application/controllers/mockup/clinic/fo/Sex.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
class Sex extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Sex API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 25;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_sex
|
||||
where M_SexIsActive = 'Y'
|
||||
and M_SexName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_sex count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_SexID, M_SexName, concat('[', group_concat(json_object('M_TitleID', M_TitleID, 'M_TitleName', M_TitleName) separator ','), ']') as title
|
||||
from m_sex
|
||||
left join m_title on m_titlem_sexid = m_sexid and m_titleisactive = 'Y'
|
||||
where M_SexIsActive = 'Y'
|
||||
and M_SexName like ?
|
||||
group by m_sexid
|
||||
limit {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['title'] = json_decode($v['title']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_sex rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
71
one-api/application/controllers/mockup/clinic/fo/Title.php
Normal file
71
one-api/application/controllers/mockup/clinic/fo/Title.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
class Title extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Title API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 25;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%',
|
||||
'sex_id' => 0
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
|
||||
if ($prm['sex_id'] != '')
|
||||
$q['sex_id'] = $prm['sex_id'];
|
||||
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_title
|
||||
where M_TitleIsActive = 'Y'
|
||||
and M_TitleName like ?
|
||||
and ((M_TitleM_SexID = {$q['sex_id']} and {$q['sex_id']} <> 0) or {$q['sex_id']} = 0)";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_sex count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_SexID, M_SexName
|
||||
from m_sex
|
||||
where M_SexIsActive = 'Y'
|
||||
and M_SexName like ?
|
||||
limit {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_sex rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
135
one-api/application/controllers/mockup/clinic/poly/Order.php
Normal file
135
one-api/application/controllers/mockup/clinic/poly/Order.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
class Order extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "ORDER API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("clinicdev", true);
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['header']['complaint'] = str_replace(PHP_EOL, '<br>', $prm['header']['complaint']);
|
||||
$prm['header']['suggestion'] = str_replace(PHP_EOL, '<br>', $prm['header']['suggestion']);
|
||||
$header_json = json_encode($prm['header']);
|
||||
$header_json = str_replace("\\", "\\\\", "$header_json");
|
||||
$lab_json = json_encode($prm['lab']);
|
||||
$med_json = json_encode($prm['med']);
|
||||
|
||||
$server = "http";
|
||||
$uid = $this->sys_user['M_UserID'];
|
||||
$sql = "CALL sp_clinic_poly_save('{$prm['order_id']}', '{$header_json}', '{$med_json}', '{$lab_json}', '{$uid}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
|
||||
if ($rst->data->is_lab == "Y" && $rst->status == "OK")
|
||||
{
|
||||
// persiapkan curl
|
||||
$ch = curl_init();
|
||||
|
||||
// set url
|
||||
global $_SERVER;
|
||||
$current_host = $_SERVER["SERVER_ADDR"];
|
||||
if ($server == "https")
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_URL, "{$server}://{$current_host}:9090/ticket/UMUM");
|
||||
//file_put_contents("/xtmp/url", "{$server}://{$current_host}:9090/ticket/UMUM" );
|
||||
// return the transfer as a string
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
// $output contains the output string
|
||||
$output = json_decode(curl_exec($ch));
|
||||
|
||||
// tutup curl
|
||||
curl_close($ch);
|
||||
|
||||
// menampilkan hasil curl
|
||||
// echo $output;
|
||||
if ($output != null)
|
||||
if ($output->status == "OK") {
|
||||
$rst->data->queue = $output->data[0]->number;
|
||||
$x = json_encode($output->data[0]);
|
||||
|
||||
$sql = "CALL sp_clinic_fo_labqueue('{$rst->data->id}', '{$rst->data->queue}', '{$x}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function process()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_clinic_poly_process('{$prm['order_id']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function get_one()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select *
|
||||
from c_orderheader
|
||||
where C_OrderHeaderID = ?";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row();
|
||||
$rows->C_OrderHeaderQueueJSON = json_decode($rows->C_OrderHeaderQueueJSON);
|
||||
|
||||
$result = $rows;
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient get",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function clean_mysqli_connection( $dbc )
|
||||
{
|
||||
while( mysqli_more_results($dbc) )
|
||||
{
|
||||
if(mysqli_next_result($dbc))
|
||||
{
|
||||
$result = mysqli_use_result($dbc);
|
||||
|
||||
unset($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
127
one-api/application/controllers/mockup/clinic/poly/Patient.php
Normal file
127
one-api/application/controllers/mockup/clinic/poly/Patient.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/*
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("clinicdev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'nolab' => '%',
|
||||
'noreg' => '%',
|
||||
'name' => '%',
|
||||
'hp' => '%',
|
||||
'dob' => '%',
|
||||
'address' => '%',
|
||||
'status' => 0
|
||||
];
|
||||
|
||||
if ($prm['noreg'] != '')
|
||||
$q['noreg'] = "%{$prm['noreg']}%";
|
||||
|
||||
if ($prm['nolab'] != '')
|
||||
$q['nolab'] = "%{$prm['nolab']}%";
|
||||
|
||||
if ($prm['status'] != '')
|
||||
$q['status'] = $prm['status'];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$e = explode('+', $prm['search']);
|
||||
if (isset($e[0]))
|
||||
$q['name'] = "%{$e[0]}%";
|
||||
if (isset($e[1]))
|
||||
$q['hp'] = "%{$e[1]}%";
|
||||
if (isset($e[2]))
|
||||
$q['dob'] = "%{$e[2]}%";
|
||||
if (isset($e[3]))
|
||||
$q['address'] = "%{$e[3]}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from c_orderheader
|
||||
join one.m_patient on c_orderheaderm_patientid = m_patientid
|
||||
join one.m_title on M_PatientM_TitleID = M_TitleID
|
||||
where C_OrderHeaderNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
and M_PatientHP LIKE ?
|
||||
and M_PatientDOB LIKE ?
|
||||
and C_OrderHeaderIsActive = 'Y'
|
||||
and ((C_OrderHeaderM_StatusID = ? and ? <> 0) or C_OrderHeaderM_StatusID = 0)";
|
||||
$query = $this->db_smartone->query($sql, array($q['nolab'], $q['name'], $q['hp'], $q['dob'], $q['status'], $q['status']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// set locales
|
||||
$this->db_smartone->query("SET @@lc_time_names = 'id_ID'");
|
||||
|
||||
$sql = "select M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
M_PatientHP, M_PatientDOB, M_PatientNote, 'X' as M_PatientAddress,
|
||||
M_PatientNote, C_OrderHeaderID, C_OrderHeaderNumber, M_StatusCode,
|
||||
C_OrderHeaderM_PatientAge, C_OrderHeaderComplaint, C_OrderHeaderIsLab, C_OrderHeaderIsReceipt,
|
||||
C_OrderHeaderDate, dayname(C_OrderHeaderDate) `day`
|
||||
from c_orderheader
|
||||
join one.m_patient on c_orderheaderm_patientid = m_patientid
|
||||
join one.m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_status on c_orderheaderm_statusid = m_statusid
|
||||
where C_OrderHeaderNumber like ?
|
||||
and M_PatientName LIKE ?
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and M_PatientDOB LIKE ?
|
||||
and C_OrderHeaderIsActive = 'Y'
|
||||
and ((C_OrderHeaderM_StatusID = ? and ? <> 0) or C_OrderHeaderM_StatusID = 0)
|
||||
limit 0,{$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['nolab'], $q['name'], $q['hp'], $q['dob'], $q['status'], $q['status']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
class Status extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "STATUS API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("clinicdev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 25;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_status
|
||||
where M_StatusIsActive = 'Y'
|
||||
and M_StatusName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_status count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_StatusID, M_StatusName
|
||||
from m_status
|
||||
where M_StatusIsActive = 'Y'
|
||||
and M_StatusName like ?
|
||||
limit {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
// $rows = $rows;
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_status rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/*
|
||||
### Auth API
|
||||
- Functions
|
||||
- login x
|
||||
- logout
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Auth extends MY_Controller {
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "AUTH API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function isLogin() {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
} else {
|
||||
$prm = $this->sys_input;
|
||||
$data = array(
|
||||
"user" => $this->sys_user
|
||||
);
|
||||
$this->sys_ok($data);
|
||||
}
|
||||
}
|
||||
function login() {
|
||||
$prm = $this->sys_input;
|
||||
try {
|
||||
//existing password enc
|
||||
$sm_password = md5($this->one_salt . $prm["password"] .
|
||||
$this->one_salt);
|
||||
$query = $this->db_onedev->query("select M_UserID, M_UserUsername,
|
||||
M_UserGroupDashboard
|
||||
from m_user
|
||||
join m_usergroup on m_userm_usergroupid = m_usergroupid
|
||||
|
||||
where M_UserUsername=? and M_UserPassword=?
|
||||
and M_UserIsActive = 'Y'
|
||||
",array($prm["username"], $sm_password));
|
||||
echo $query;
|
||||
if (!$query) {
|
||||
$message = $this->db_onedev->error();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
$rows = $query->result_array();
|
||||
if (count($rows) > 0 ) {
|
||||
$user = $rows[0];
|
||||
$user['M_UserGroupDashboard'] = "https://{$_SERVER['SERVER_NAME']}/{$user['M_UserGroupDashboard']}";
|
||||
$token = JWT::encode($user,$this->SECRET_KEY);
|
||||
$data = array(
|
||||
"user" => $user,
|
||||
"token" => $token
|
||||
);
|
||||
|
||||
$query = $this->db_onedev->query("update m_user SET M_UserIsLoggedIn = 'Y', M_UserLastAccess = now() WHERE M_UserID = ?
|
||||
",array($user['M_UserID']));
|
||||
if (!$query) {
|
||||
$message = $this->db_onedev->error();
|
||||
$this->sys_error($message);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->sys_ok($data);
|
||||
exit;
|
||||
}
|
||||
$this->sys_error_db("Invalid UserName / Password");
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function logout() {
|
||||
$this->sys_error("ok");
|
||||
}
|
||||
}
|
||||
?>
|
||||
134
one-api/application/controllers/mockup/closecashier/Close.php
Normal file
134
one-api/application/controllers/mockup/closecashier/Close.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
class Close 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 add_notes($orderid){
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$startdate = $prm['startdate'] . " 00:00:01";
|
||||
$enddate = $prm['enddate'] . " 23:59:59";
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$where = " ( F_PaymentKasirDate BETWEEN '{$startdate}' AND '{$enddate}' ) AND ";
|
||||
if($search != '')
|
||||
$where = "( F_PaymentKasirNumber LIKE '%{$search}%') AND ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM f_payment_kasir
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND (F_PaymentKasirIsReceived = 'N' )) OR ('{$status}' = 'Y' AND F_PaymentKasirIsReceived = 'Y') )";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT F_PaymentKasirID ,
|
||||
F_PaymentKasirNumber ,
|
||||
date_format(F_PaymentKasirDate,'%d-%m-%Y %T') as F_PaymentKasirDate ,
|
||||
F_PaymentKasirCreated ,
|
||||
F_PaymentKasirLastUpdated ,M_StaffName,
|
||||
if(F_PaymentKasirIsReceived = 'N','Belum Diterima' ,'Sudah diterima') as F_PaymentKasirIsReceived ,
|
||||
F_PaymentKasirIsActive
|
||||
|
||||
FROM f_payment_kasir
|
||||
JOIN m_user on F_PaymentKasirUserID = M_UserID
|
||||
join m_staff on M_UserM_StaffID = M_StaffID
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND (F_PaymentKasirIsReceived = 'N' )) OR ('{$status}' = 'Y' AND F_PaymentKasirIsReceived = 'Y') )
|
||||
|
||||
ORDER BY F_PaymentKasirID asc
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['notes'] = $this->add_notes($v['F_PaymentKasirID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
public function save()
|
||||
{
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$puserid = $prm['pUserID'];
|
||||
|
||||
$sql = "CALL sp_fo_send_to_cashier({$puserid})";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
if ($query) {
|
||||
|
||||
|
||||
$result = array();
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("payment save rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function savetutup()
|
||||
{
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$ppaymentkasirid = $prm['pPaymentKasirID'];
|
||||
$puserid = $prm['pUserID'];
|
||||
|
||||
$sql = "CALL sp_fo_received_cashier('{$ppaymentkasirid}','{$puserid}')";
|
||||
//$sql = "CALL sp_fo_send_to_cashier({$puserid})";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
if ($query) {
|
||||
|
||||
|
||||
$result = array();
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("payment savetutup rows", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<?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 add_notes($orderid){
|
||||
$sql = " SELECT F_PaymentT_OrderHeaderID as note_order_id,
|
||||
F_PaymentID as note_id,
|
||||
F_PaymentDate as note_date,
|
||||
F_PaymentNumber as note_number,
|
||||
GROUP_CONCAT(M_PaymentTypeName separator ' , ') as paymenttypes_name,
|
||||
SUM(F_PaymentDetailAmount) as note_amount,
|
||||
M_UserUsername as note_user,
|
||||
F_PaymentDetailIsActive as note_active
|
||||
FROM f_payment
|
||||
JOIN f_paymentdetail ON F_PaymentDetailF_PaymentID = F_PaymentID
|
||||
JOIN m_paymenttype ON F_PaymentDetailM_PaymentTypeID = M_PaymentTypeID
|
||||
LEFT JOIN m_user ON F_PaymentDetailUserID = M_UserID
|
||||
WHERE
|
||||
F_PaymentT_OrderHeaderID = {$orderid}
|
||||
GROUP BY F_PaymentID";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
return $rows;
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("get notes", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$startdate = $prm['startdate'] . " 00:00:01";
|
||||
$enddate = $prm['enddate'] . " 23:59:59";
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$where = " ( T_OrderHeaderDate BETWEEN '{$startdate}' AND '{$enddate}' ) AND ";
|
||||
if($search != '')
|
||||
$where = "( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_orderheader
|
||||
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
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') )";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
$janji = T_OrderPromiseDateTime;
|
||||
$janji_hasil = Date_format($janji, "d-m-Y H:i:s");
|
||||
|
||||
$sql = "SELECT t_orderheader.*,T_OrderHeaderIsCito as cito,
|
||||
M_PatientNoReg,
|
||||
concat(M_TitleName,'. ',M_PatientName) as M_PatientName,
|
||||
M_TitleName,
|
||||
M_CompanyName,
|
||||
M_MouName,
|
||||
T_OrderHeaderTotal as totalbill,
|
||||
IFNULL(Last_StatusPaymentPaid,0) as paid,
|
||||
IFNULL(Last_StatusPaymentUnpaid,T_OrderHeaderTotal)as unpaid,
|
||||
Last_StatusPaymentIsLunas as flaglunas,
|
||||
'' as notes,
|
||||
M_MouMinDP as mindp_percent,
|
||||
GROUP_CONCAT(distinct concat(T_OrderDetailT_TestName,'^',T_OrderDetailIsCito) SEPARATOR ',') as test ,
|
||||
fn_report_promise_list(T_OrderHeaderID) as janji,
|
||||
(M_MouMinDP/100) * T_OrderHeaderTotal as mindp_amount,
|
||||
case
|
||||
when Last_StatusPaymentPaid = '0' then 'BELUM BAYAR'
|
||||
when Last_StatusPaymentIsLunas = 'Y' then 'LUNAS'
|
||||
when Last_StatusPaymentIsLunas = 'N' then 'BELUM LUNAS' ELSE '' END as status,
|
||||
GROUP_CONCAT(distinct M_DeliveryName SEPARATOR ' , ') as delivery
|
||||
|
||||
FROM t_orderheader
|
||||
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
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
|
||||
JOIN t_orderdetail on T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y' aND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
join t_orderpromise on T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND T_OrderPromiseIsActive = 'Y'
|
||||
join t_orderdelivery on T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID AND T_OrderDeliveryIsActive = 'Y'
|
||||
join m_delivery on T_OrderDeliveryM_DeliveryID = M_DeliveryID AND M_DeliveryIsActive = 'Y'
|
||||
|
||||
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') )
|
||||
group by T_OrderHeaderID
|
||||
ORDER BY `fn_get_cito`(T_OrderHeaderID),T_OrderPromiseDateTime asc
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['notes'] = $this->add_notes($v['T_OrderHeaderID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
201
one-api/application/controllers/mockup/courier/Done.php
Normal file
201
one-api/application/controllers/mockup/courier/Done.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
class Done 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;
|
||||
}
|
||||
|
||||
$nolab = $prm["nolab"];
|
||||
$groupid = $prm["groupid"];
|
||||
//$subgroupid = $prm["subgroupid"];
|
||||
$join_group = '';
|
||||
if($groupid != '0'){
|
||||
$join_group = "JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID AND Nat_GroupID = {$groupid}";
|
||||
}
|
||||
/*$join_subgroup = '';
|
||||
if($subgroupid != 0){
|
||||
$join_group = "JOIN nat_subgroup ON T_TestNat_SubgroupID = Nat_SubgroupID AND Nat_SubgroupID = {$subgroupid}";
|
||||
}*/
|
||||
|
||||
if(!isset($prm['current_page']))
|
||||
$prm['current_page'] = 1;
|
||||
|
||||
$sql_where = "WHERE Result_CourierStatus = 'S' AND JSON_CONTAINS(Result_COurierIds,T_OrderDetailID)";
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
//$sql_param = array();
|
||||
if ($nolab != "" ) {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( T_OrderHeaderLabNumber like '%$nolab%' OR M_PatientName like '%$nolab%' )";
|
||||
}
|
||||
|
||||
/*if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like '%$nama%' ";
|
||||
}*/
|
||||
|
||||
$sql = "SELECT Result_CourierID as xid,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderLabNumber as ordernumber,
|
||||
UPPER(CONCAT(M_TitleName,' ',M_PatientName)) as patient_fullname,
|
||||
Result_CourierT_TestName as test_name,
|
||||
'N' as chex
|
||||
FROM result_courier
|
||||
join t_orderheader ON Result_CourierT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND JSON_CONTAINS(Result_CourierIds, T_OrderDetailID)
|
||||
$join_group
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
$sql_where
|
||||
GROUP BY Result_CourierID
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
|
||||
$result = array("total" => count($rst), "records" => $rows, "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkerajaan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//$rst = array(array('id'=>0,'name'=>'Semua'));
|
||||
|
||||
$sql = "SELECT 0 as id, 'Semua' as name UNION SELECT Nat_GroupID as id, Nat_GroupName as name FROM nat_group WHERE Nat_GroupIsActive = 'Y'";
|
||||
$rst_db = $this->db_onedev->query($sql)->result_array();
|
||||
//$c = array_combine($rst,$rst_db);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rst_db
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function dosend(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$selected = $prm['selected'];
|
||||
|
||||
foreach($selected as $k => $v){
|
||||
$sql = "UPDATE result_frontoffice SET Result_FrontOfficeStatus = 'R' WHERE Result_FrontOfficeID = {$v['xid']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function sendemail(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$rows = array();
|
||||
$ids = "(".$prm['ids'].")";
|
||||
$sql = "UPDATE result_sendemail SET Result_SendEmailStatus = 'S', Result_SendEmailUserID = {$userid} WHERE Result_SendEmailID IN {$ids}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
$sql = "SELECT * FROM result_sendemail WHERE Result_SendEmailID IN {$ids}";
|
||||
$dt_rst = $this->db_onedev->query($sql)->result_array();
|
||||
foreach($dt_rst as $k => $v){
|
||||
$dt_log = json_encode($v);
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function updateemail(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$rows = array();
|
||||
$id = $prm['id'];
|
||||
$sql = "UPDATE t_orderdelivery SET T_OrderDeliveryDestination = '{$prm['edited_email']}', T_OrderDeliveryUserID = {$userid} WHERE T_OrderDeliveryID = {$id}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array ("total" => 0, "records" => array());
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
963
one-api/application/controllers/mockup/courier/Patient.php
Normal file
963
one-api/application/controllers/mockup/courier/Patient.php
Normal file
@@ -0,0 +1,963 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
|
||||
function add_verifications_label($orderid){
|
||||
$query = " SELECT Result_VerificationsID as id,
|
||||
IFNULL(Result_VerificationsValueID,0) as xid,
|
||||
IFNULL(Result_VerificationsValueCheck,'N') as chex,
|
||||
IF(ISNULL(Result_VerificationsValueID),'',Result_VerificationsValueNote) as note,
|
||||
Result_VerificationsLabel as label
|
||||
FROM result_verifications
|
||||
LEFT JOIN result_verifications_value ON Result_VerificationsValueResult_VerificationsID = Result_VerificationsID AND
|
||||
Result_VerificationsValueSo_ResultEntryID = $orderid
|
||||
WHERE
|
||||
Result_VerificationIsActive = 'Y'
|
||||
GROUP BY Result_VerificationsID
|
||||
";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$nolab = $prm["nolab"];
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$datepromise = $prm["startdate"];
|
||||
$filter = " AND Result_SendCourierStatus = '{$status}'";
|
||||
$having = "HAVING not_ready_count = 0";
|
||||
if($status == 'X'){
|
||||
$filter = " AND ISNULL(Result_SendCourierID)";
|
||||
$having = "HAVING not_ready_count > 0";
|
||||
}
|
||||
|
||||
$filter_courier = '';
|
||||
if($status == 'P' && isset($prm['selected_courier'])){
|
||||
if(intval($prm['selected_courier']) != 0){
|
||||
$filter_courier = " AND M_CourierID = {$prm['selected_courier']}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!isset($prm['current_page']))
|
||||
$prm['current_page'] = 1;
|
||||
|
||||
$sql_where = "WHERE T_OrderDetailIsActive = 'Y' ";
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
//$sql_param = array();
|
||||
if ($nolab != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( T_OrderHeaderLabNumber like '%$nolab%' AND M_PatientName like '%$nolab%' ) ";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) as total
|
||||
FROM (
|
||||
SELECT T_OrderHeaderID,
|
||||
T_OrderPromiseID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderIsCito as iscito,
|
||||
M_CompanyName,
|
||||
T_OrderPromiseDateTime,
|
||||
T_OrderHeaderLabNumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
M_PatientHP as patient_hp,
|
||||
M_PatientPhotoThumb as photo,
|
||||
fn_fo_check_status_not_ready_courier(T_OrderHeaderID,T_OrderPromiseID) as not_ready_count
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdelivery ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = 2 AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseDateTime < '{$datepromise} 23:59:59'
|
||||
LEFT JOIN result_sendcourier ON Result_SendCourierT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_SendCourierIds,T_OrderDetailID)
|
||||
LEFT JOIN result_courierspk_detail ON Result_CourierSPKDetailT_OrderDeliveryID = T_OrderDeliveryID AND
|
||||
Result_CourierSPKDetailT_OrderPromiseID = T_OrderPromiseID AND Result_CourierSPKDetailIsActive = 'Y' AND
|
||||
Result_CourierSPKDetailStatus = 'O'
|
||||
LEFT JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
||||
LEFT JOIN m_courier ON Result_CourierSPKM_CourierID = M_CourierID $filter_courier
|
||||
$sql_where $filter
|
||||
GROUP BY T_OrderHeaderID, T_OrderPromiseID, T_OrderDeliveryID
|
||||
$having
|
||||
)x";
|
||||
// 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("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT Result_SendCourierID as trx_id,
|
||||
GROUP_CONCAT(IFNULL(Result_SendCourierID,0) separator ',') as ids,
|
||||
T_OrderHeaderID,
|
||||
T_OrderPromiseID,
|
||||
T_OrderDeliveryID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderIsCito as iscito,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(T_OrderPromiseDateTime,'%d-%m-%Y %H:%i') as date_promise,
|
||||
T_OrderHeaderLabNumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
M_PatientHP as patient_hp,
|
||||
M_PatientPhotoThumb as photo,
|
||||
IFNULL(Result_SendCourierStatus,'X') as status,
|
||||
fn_fo_check_status_not_ready_courier(T_OrderHeaderID,T_OrderPromiseID) as not_ready_count,
|
||||
Last_StatusPaymentIsLunas as status_lunas,
|
||||
M_MouIsBill as status_bill,
|
||||
'N' as chex,
|
||||
IFNULL(M_StaffName,'Belum ditentukan') as staff_name
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdelivery ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = 2 AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseDateTime < '{$datepromise} 23:59:59'
|
||||
LEFT JOIN result_sendcourier ON Result_SendCourierT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_SendCourierIds,T_OrderDetailID)
|
||||
LEFT JOIN result_courierspk_detail ON Result_CourierSPKDetailT_OrderDeliveryID = T_OrderDeliveryID AND
|
||||
Result_CourierSPKDetailT_OrderPromiseID = T_OrderPromiseID AND Result_CourierSPKDetailIsActive = 'Y' AND
|
||||
Result_CourierSPKDetailForceDone = 'N'
|
||||
LEFT JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
||||
LEFT JOIN m_courier ON Result_CourierSPKM_CourierID = M_CourierID $filter_courier
|
||||
LEFT JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
$sql_where $filter
|
||||
GROUP BY T_OrderHeaderID, T_OrderPromiseID, T_OrderDeliveryID
|
||||
$having
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['chex'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function getcourier()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nolab = $prm["nolab"];
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$datepromise = $prm["startdate"];
|
||||
$filter = " AND Result_SendCourierStatus = '{$status}'";
|
||||
$having = "HAVING not_ready_count = 0";
|
||||
if($status == 'X'){
|
||||
$filter = " AND ISNULL(Result_SendCourierID)";
|
||||
$having = "HAVING not_ready_count > 0";
|
||||
}
|
||||
|
||||
$sql_where = "WHERE T_OrderDetailIsActive = 'Y' ";
|
||||
|
||||
$sql = " SELECT 0 as id, 'Semua' as staff_name, 0 as not_ready_count
|
||||
UNION
|
||||
SELECT M_CourierID as id,
|
||||
M_StaffName as staff_name,
|
||||
fn_fo_check_status_not_ready_courier(T_OrderHeaderID,T_OrderPromiseID) as not_ready_count
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdelivery ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = 2 AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseDateTime < '{$datepromise} 23:59:59'
|
||||
JOIN result_sendcourier ON Result_SendCourierT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_SendCourierIds,T_OrderDetailID)
|
||||
JOIN result_courierspk_detail ON Result_CourierSPKDetailT_OrderDeliveryID = T_OrderDeliveryID AND
|
||||
Result_CourierSPKDetailT_OrderPromiseID = T_OrderPromiseID AND Result_CourierSPKDetailIsActive = 'Y' AND
|
||||
Result_CourierSPKDetailStatus = 'O'
|
||||
JOIN result_courierspk ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
||||
JOIN m_courier ON Result_CourierSPKM_CourierID = M_CourierID
|
||||
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
$sql_where $filter
|
||||
GROUP BY M_CourierID
|
||||
$having";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
$xprm = $this->sys_input;
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
//# ambil parameter input
|
||||
|
||||
//print_r($xprm);
|
||||
$prm = $xprm['patient'];
|
||||
$xstatus = $xprm['act'];
|
||||
$fostatusid = 3;
|
||||
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
||||
$id = $prm['T_OrderHeaderID'];
|
||||
echo $xstatus;
|
||||
if($xstatus == 'N'){
|
||||
$fostatusid = 4;
|
||||
$fologcode = 'FO.VERIFICATION.REJECT';
|
||||
}else{
|
||||
|
||||
$this->save_barcode_new($id);
|
||||
}
|
||||
|
||||
|
||||
//print_r($prm);
|
||||
$xverificationnote = $prm['verification_note'];
|
||||
//echo $xverificationnote;
|
||||
|
||||
$sql = "update t_orderheader
|
||||
set
|
||||
T_OrderHeaderVerificationNote = '{$xverificationnote}'
|
||||
where
|
||||
T_OrderHeaderID = $id";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
|
||||
/*$xverification_patient = $this->saveverifications($id,$prm['verification_patient'],'PATIENT',$xuserid);
|
||||
$xverification_doctor = $this->saveverifications($id,$prm['verification_doctor'],'DOCTOR',$xuserid);
|
||||
$xverification_companymou = $this->saveverifications($id,$prm['verification_companymou'],'COMPANY',$xuserid);
|
||||
$xverification_payment = $this->saveverifications($id,$prm['verification_payment'],'PAYMENT',$xuserid);
|
||||
$xverification_info = $this->saveverifications($id,$prm['verification_info'],'INFO',$xuserid);
|
||||
|
||||
$xverification_delivery = $this->saveverification_delivery($id,$prm['verification_delivery'],$xuserid);
|
||||
$xverification_px = $this->saveverification_px($id,$prm['verification_px'],$xuserid);*/
|
||||
|
||||
$sql = "insert into fo_status(
|
||||
Fo_StatusDate,
|
||||
Fo_StatusT_OrderHeaderID,
|
||||
Fo_StatusM_StatusID,
|
||||
Fo_StatusM_UserID,
|
||||
Fo_StatusCreated,
|
||||
Fo_StatusUpdated)
|
||||
values( now(), ?, ?, ?, now(),now())";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$fostatusid,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_status insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $id;
|
||||
/*$data_log['verification_patient'] = $prm['verification_patient'];
|
||||
$data_log['verification_doctor'] = $prm['verification_doctor'];
|
||||
$data_log['verification_companymou'] = $prm['verification_companymou'];
|
||||
$data_log['verification_payment'] = $prm['verification_payment'];
|
||||
$data_log['verification_info'] = $prm['verification_info'];
|
||||
$data_log['verification_px'] = $prm['verification_px'];
|
||||
$data_log['verification_delivery'] = $prm['verification_delivery'];*/
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($xstatus == 'Y'){
|
||||
$msg = 'Verifikasi berhasil dilakukan';
|
||||
}
|
||||
else{
|
||||
$msg = 'Tolak Verifikasi berhasil dilakukan';
|
||||
$sql = "INSERT INTO t_ordermessage (
|
||||
T_OrderMessageT_OrderHeaderID,
|
||||
T_OrderMessageType,
|
||||
T_OrderMessageMessage,
|
||||
T_OrderMessageFromUserID,
|
||||
T_OrderMessageCreated,
|
||||
T_OrderMessageLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
{$id},
|
||||
'FO.VERIFICATION.REJECT',
|
||||
'{$xverificationnote}',
|
||||
{$xuserid},
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.t_ordermessage insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows = array('message'=>$msg);
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function save_barcode_new($orderid){
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
|
||||
$query =" SELECT T_SampleTypeID as id,
|
||||
T_SampleTypeName as name,
|
||||
'' as children
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$orderid}
|
||||
GROUP BY T_SampleTypeID
|
||||
";
|
||||
//echo $query ;
|
||||
$barcodes = $this->db_onedev->query($query)->result();
|
||||
foreach($barcodes as $k => $v){
|
||||
$query = "SELECT T_SampleTypeID as id, IFNULL(T_BarcodeLabID,0) as xid,
|
||||
IF(ISNULL(T_BarcodeLabID),'Y',T_BarcodeLabIsActive) as chex,
|
||||
T_TestName as testname,
|
||||
T_SampleTypeName as samplename,
|
||||
IF(ISNULL(T_BarcodeLabID),CONCAT(T_OrderHeaderLabNumber,'.',T_SampleTypeID,'.',1),T_BarcodeLabBarcode) as barcodenumber
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderid} AND T_SampleTypeID = {$v->id}
|
||||
GROUP BY T_BarcodeLabID ";
|
||||
$v->children = $this->db_onedev->query($query)->result_array();
|
||||
//$v->children = $barcode_data;
|
||||
foreach($v->children as $ki => $vi){
|
||||
if($vi['chex'] == 'N')
|
||||
$v->children[$ki]['chex'] = false;
|
||||
else
|
||||
$v->children[$ki]['chex'] = true;
|
||||
$sql = "insert into t_barcodelab(
|
||||
T_BarcodeLabT_OrderHeaderID,
|
||||
T_BarcodeLabBarcode,
|
||||
T_BarcodeLabT_SampleTypeID,
|
||||
T_BarcodeLabCreated,
|
||||
T_BarcodeLabLastUpdated,
|
||||
T_BarcodeLabUserID)
|
||||
values( ?, ?, ?, now(),now(),?)";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid,
|
||||
$v->children[$ki]['barcodenumber'],
|
||||
$v->children[$ki]['id'],
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_barcodelab insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//insert log
|
||||
$supplies = array();
|
||||
$query =" SELECT M_SuppliesID as id,
|
||||
IFNULL(T_OrderSuppliesID,0) as xid,
|
||||
IF(ISNULL(T_OrderSuppliesID),'N',T_OrderSuppliesIsActive) as chex,
|
||||
IFNULL(T_OrderSuppliesQty,1) as qty,
|
||||
M_SuppliesName as name,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as lastupdated,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as tx_lastupdated
|
||||
FROM m_supplies
|
||||
JOIN t_ordersupplies ON T_OrderSuppliesT_OrderHeaderID = $orderid AND T_OrderSuppliesM_SuppliesID = M_SuppliesID
|
||||
WHERE
|
||||
M_SuppliesIsActive = 'Y'
|
||||
";
|
||||
//echo $query ;
|
||||
$supplies = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
foreach($supplies as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$supplies[$k]['chex'] = false;
|
||||
else
|
||||
$supplies[$k]['chex'] = true;
|
||||
}
|
||||
|
||||
$dt_log = array('orderid'=>$orderid,'supplies'=>$supplies,'barcode'=>$barcodes);
|
||||
$fologcode = 'FO.Verification.BarcodeSupplies';
|
||||
$json_dt_log = json_encode($dt_log);
|
||||
$sql = "insert into one_log.log_supplies_barcode(
|
||||
Log_SuppliesBarcodeDate,
|
||||
Log_SuppliesBarcodeCode,
|
||||
Log_SuppliesBarcodeJson,
|
||||
Log_SuppliesBarcodeUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.log_supplies_barcode insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function saveverifications($id,$verifications,$type,$userid)
|
||||
{
|
||||
try {
|
||||
//$xverificationtypeid = $this->db_onedev->query("SELECT * FROM fo_verificationtype WHERE Fo_VerificationTypeGroup = '{$type}' AND Fo_VerificationTypeIsActive = 'Y'")->row()->Fo_VericationTypeID;
|
||||
//echo $xverificationtypeid;
|
||||
//print_r($verifications);
|
||||
foreach($verifications as $k => $v){
|
||||
//print_r($v);
|
||||
if(intval($v['xid']) == 0){
|
||||
$sql = "insert into fo_verification(
|
||||
Fo_VerificationT_OrderHeaderID,
|
||||
Fo_VerificationFo_VericationTypeID,
|
||||
Fo_VerificationIsOK,
|
||||
Fo_VerificationReason,
|
||||
Fo_VerificationCreated,
|
||||
Fo_VerificationLastUpdated,
|
||||
Fo_VerificationUserID)
|
||||
values( ?, ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['id'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_verification insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveverification_delivery($id,$deliveries,$userid)
|
||||
{
|
||||
try {
|
||||
foreach($deliveries as $k => $v){
|
||||
if($v['id'] === 0){
|
||||
$sql = "insert into fo_verification_delivery_add(
|
||||
Fo_VerificationDeliveryAddT_OrderHeaderID,
|
||||
Fo_VerificationDeliveryAddM_DeliveryID,
|
||||
Fo_VerificationDeliveryAddM_DeliveryTypeID,
|
||||
Fo_VerificationDeliveryAddDestination,
|
||||
Fo_VerificationDeliveryAddAddressID,
|
||||
Fo_VerificationDeliveryAddM_KelurahanID,
|
||||
Fo_VerificationDeliveryAddOK,
|
||||
Fo_VerificationDeliveryAddReason,
|
||||
Fo_VerificationDeliveryAddCreated,
|
||||
Fo_VerificationDeliveryAddLastUpdated,
|
||||
Fo_VerificationDeliveryAddUserID)
|
||||
values( ?, ?, ?, ?,?,?,?,?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['deliveryid'],
|
||||
$v['typedeliveryid'],
|
||||
$v['destination'],
|
||||
$v['addressid'],
|
||||
$v['vilageid'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("fo_verification_delivery_add insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
}else{
|
||||
$sql = "insert into fo_verification_delivery(
|
||||
Fo_VerificationDeliveryT_OrderHeaderID,
|
||||
Fo_VerificationDeliveryT_OrderDeliveryID,
|
||||
Fo_VerificationDeliveryIsOK,
|
||||
Fo_VerificationDeliveryReason,
|
||||
Fo_VerificationDeliveryCreated,
|
||||
Fo_VerificationDeliveryLastUpdated,
|
||||
Fo_VerificationDeliveryUserID)
|
||||
values( ?, ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['id'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("fo_verification_delivery insert");
|
||||
exit;
|
||||
}
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function lookup_barcodes()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$sql = "SELECT T_BarcodeLabID as id, 'barcode' as type,T_BarcodeLabID,T_BarcodeLabBarcode, T_BarcodeLabCounter, T_SampleTypeName, 'N' as chex
|
||||
FROM t_barcodelab
|
||||
JOIN t_sampletype ON T_BarcodeLabT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
T_BarcodeLabT_OrderHeaderID = {$prm['ohid']} AND T_BarcodeLabIsActive = 'Y'
|
||||
UNION
|
||||
SELECT T_OrderHeaderID as id, 'formulir' as type, 0,T_OrderHeaderLabNumber as T_BarcodeLabBarcode, 1, 'Formulir' as T_SampleTypeName, 'N' as chex
|
||||
FROM t_orderheader
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['ohid']}
|
||||
";
|
||||
//echo $sql;
|
||||
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveverification_px($id,$pxs,$userid)
|
||||
{
|
||||
try {
|
||||
foreach($pxs as $k => $v){
|
||||
|
||||
if(intval($v['id']) == 0){
|
||||
$cxh = $v['chex'] == true ?'Y':'N';
|
||||
$sql = "insert into fo_verification_test_add(
|
||||
Fo_VerificationTestAddT_OrderHeaderID,
|
||||
Fo_VerificationTestAddT_TestID,
|
||||
Fo_VerificationTestAddBruto,
|
||||
Fo_VerificationTestAddDiscount,
|
||||
Fo_VerificationTestAddTotal,
|
||||
Fo_VerificationTestAddIsOK,
|
||||
Fo_VerificationTestAddIsCito,
|
||||
Fo_VerificationTestAddCreated,
|
||||
Fo_VerificationTestAddLastUpdated,
|
||||
Fo_VerificationTestAddUserID)
|
||||
values( $id, {$v['pxid']}, {$v['bruto']}, {$v['discount']},{$v['total']},'{$cxh}','{$v['flagcito']}',now(),now(),{$userid})";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_verification_test_add insert");
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$sql = "insert into fo_verification_test(
|
||||
Fo_VerificationTestT_OrderHeaderID,
|
||||
Fo_VerificationTestT_OrderDetailID,
|
||||
Fo_VerificationTestIsOK,
|
||||
Fo_VerificationTestReason,
|
||||
Fo_VerificationTestCreated,
|
||||
Fo_VerificationTestLastUpdated,
|
||||
Fo_VerificationTestUserID)
|
||||
values( ?, ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['id'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_verification_test insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function verify(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$xstatus = $prm['act'];
|
||||
if($xstatus == 'Y'){
|
||||
$msg = "Berhasil melakukan verifikasi";
|
||||
$query =" INSERT INTO result_verifications_value (
|
||||
Result_VerificationsValueSo_ResultEntryID,
|
||||
Result_VerificationsValueResult_VerificationsID,
|
||||
Result_VerificationsValueCheck,
|
||||
Result_VerificationsValueNote,
|
||||
Result_VerificationsValueUserID,
|
||||
Result_VerificationsValueCreated
|
||||
)
|
||||
SELECT {$prm['trx_id']},
|
||||
Result_VerificationsID,
|
||||
'Y',
|
||||
'',
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM result_verifications
|
||||
WHERE
|
||||
Result_VerificationIsActive = 'Y'
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Result_VerificationsValueCheck = 'Y',
|
||||
Result_VerificationsValueNote = '',
|
||||
Result_VerificationsValueUserID = {$userid},
|
||||
Result_VerificationsValueLastUpdated = NOW()
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "UPDATE so_resultentry SET So_ResultEntryStatus = 'VAL2' , So_ResultEntryValidation2 = 'Y' WHERE So_ResultEntryID = {$prm['trx_id']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
else{
|
||||
$msg = "Tolak untuk perbaikan";
|
||||
$verifications = $prm['verifications'];
|
||||
foreach($verifications as $k => $v){
|
||||
$chx = $v['chex'] == true ?'Y':'N';
|
||||
$query =" INSERT INTO result_verifications_value (
|
||||
Result_VerificationsValueSo_ResultEntryID,
|
||||
Result_VerificationsValueResult_VerificationsID,
|
||||
Result_VerificationsValueCheck,
|
||||
Result_VerificationsValueNote,
|
||||
Result_VerificationsValueUserID,
|
||||
Result_VerificationsValueCreated
|
||||
)
|
||||
values( {$prm['trx_id']},
|
||||
{$v['id']},
|
||||
'{$chx}',
|
||||
'{$v['note']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Result_VerificationsValueCheck = '{$chx}',
|
||||
Result_VerificationsValueNote = '{$v['note']}',
|
||||
Result_VerificationsValueUserID = {$userid},
|
||||
Result_VerificationsValueLastUpdated = NOW()
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 0, "records" => array('status'=>'OK','message'=>$msg));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function getstatuspergroup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$rows = array();
|
||||
|
||||
$sql =" SELECT Last_StatusPaymentBillTotal as total_bill,
|
||||
Last_StatusPaymentPaid as paid,
|
||||
Last_StatusPaymentUnpaid as unpaid,
|
||||
Last_StatusPaymentIsLunas as status
|
||||
FROM last_statuspayment
|
||||
WHERE
|
||||
Last_StatusPaymentT_OrderHeaderID = {$prm['T_OrderHeaderID']} ";
|
||||
$rows['info_bill'] = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
|
||||
$sql =" SELECT T_OrderDeliveryID as id,
|
||||
IFNULL(Fo_VerificationDeliveryID,0) as xid,
|
||||
M_DeliveryTypeCode as code,
|
||||
IF(ISNULL(Fo_VerificationDeliveryID),'N',Fo_VerificationDeliveryIsOK) as chex,
|
||||
M_DeliveryID as deliveryid,
|
||||
M_DeliveryTypeID as typedeliveryid,
|
||||
T_OrderDeliveryM_KelurahanID as vilageid,
|
||||
IF(ISNULL(Fo_VerificationDeliveryID),'',Fo_VerificationDeliveryReason) as note,
|
||||
'reguler' as type,
|
||||
CASE
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 1 THEN M_DeliveryName
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN CONCAT(M_DeliveryName)
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN CONCAT(M_DeliveryName)
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 ) THEN CONCAT(M_DeliveryName)
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 ) THEN CONCAT(M_DeliveryName)
|
||||
ELSE
|
||||
CONCAT(M_DeliveryName)
|
||||
END as label,
|
||||
CASE
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 1 THEN ''
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN M_DoctorAddressDescription
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN M_PatientAddressDescription
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 ) THEN M_DoctorHP
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 ) THEN M_PatientHP
|
||||
ELSE
|
||||
T_OrderDeliveryDestination
|
||||
END as destination,
|
||||
CASE
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN M_DoctorAddressID
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN M_PatientAddressID
|
||||
ELSE
|
||||
0
|
||||
END as addressid
|
||||
FROM t_orderdelivery
|
||||
JOIN t_orderheader ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_delivery ON T_OrderDeliveryM_DeliveryID = M_DeliveryID
|
||||
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
LEFT JOIN m_doctoraddress ON T_OrderDeliveryAddressID = M_DoctorAddressID AND T_OrderDeliveryM_DeliveryID = 4
|
||||
LEFT JOIN m_patientaddress ON T_OrderDeliveryAddressID = M_PatientAddressID AND T_OrderDeliveryM_DeliveryID = 2
|
||||
LEFT JOIN fo_verification_delivery ON Fo_VerificationDeliveryT_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID AND Fo_VerificationDeliveryIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID AND ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 )
|
||||
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 )
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND T_OrderDeliveryID = {$prm['T_OrderDeliveryID']} AND T_OrderDeliveryIsActive = 'Y'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
|
||||
";
|
||||
//echo $query ;
|
||||
$rows['info_deliveries'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "
|
||||
SELECT T_OrderHeaderID,
|
||||
T_OrderPromiseID,
|
||||
T_OrderPromiseDateTime,
|
||||
T_OrderHeaderLabNumber,
|
||||
UPPER(DocumentationGroupName) as DocumentationGroupName,
|
||||
GROUP_CONCAT(DISTINCT CONCAT(T_TestName,'^',IFNULL(Result_SendCourierStatus,'X'))) as status_test_name,
|
||||
GROUP_CONCAT(IFNULL(Result_SendCourierStatus,'X')) as status,
|
||||
'' as status_pergroup,
|
||||
'' as details
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
LEFT JOIN result_sendcourier ON Result_SendCourierT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_SendCourierIds,T_OrderDetailID)
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['T_OrderHeaderID']} AND T_OrderPromiseID = {$prm['T_OrderPromiseID']} AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY DocumentationGroupID
|
||||
|
||||
";
|
||||
|
||||
$rows['info_test'] = $this->db_onedev->query($sql)->result_array();
|
||||
if($rows['info_test']){
|
||||
foreach($rows['info_test'] as $k => $v){
|
||||
$rows['info_test'][$k]['status_pergroup'] = 'R';
|
||||
$x_arr = explode(',',$v['status']);
|
||||
if(in_array('X',$x_arr)){
|
||||
$rows['info_test'][$k]['status_pergroup'] = 'X';
|
||||
}
|
||||
if($v['DocumentationGroupName'] != 'LAB'){
|
||||
|
||||
$z_arr = explode(',',$v['status_test_name']);
|
||||
$for_details = array();
|
||||
foreach($z_arr as $i => $val){
|
||||
$xx_arr = explode('^',$val);
|
||||
array_push($for_details,array('testname'=>$xx_arr[0],'status'=>$xx_arr[1]));
|
||||
}
|
||||
$rows['info_test'][$k]['details'] = $for_details;
|
||||
}
|
||||
else{
|
||||
$rows['info_test'][$k]['DocumentationGroupName'] = 'Laboratorium';
|
||||
$rows['info_test'][$k]['details'] = array(array('testname'=>'Pemeriksaan Laboratorium','status'=>$rows['info_test'][$k]['status_pergroup']));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function receivedbycourier(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$datas = $prm['selected'];
|
||||
foreach($datas as $k => $v){
|
||||
$sql = "SELECT result_sendcourier.*
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseID = {$v['T_OrderPromiseID']}
|
||||
JOIN result_sendcourier ON Result_SendCourierT_OrderHeaderID = {$v['T_OrderHeaderID']} AND Result_SendCourierStatus = 'P' AND
|
||||
JSON_CONTAINS(Result_SendCourierIds,T_OrderDetailID)
|
||||
JOIN t_orderdelivery ON T_OrderDetailT_OrderHeaderID = Result_SendCourierT_OrderHeaderID AND T_OrderDeliveryID = {$v['T_OrderDeliveryID']}";
|
||||
//echo $sql;
|
||||
$data_going_save = $this->db_onedev->query($sql)->result_array();
|
||||
foreach($data_going_save as $i => $val){
|
||||
$sql = "UPDATE result_sendcourier SET Result_SendCourierStatus = 'S', Result_SendCourierUserID = {$userid}
|
||||
WHERE
|
||||
Result_SendCourierID = {$val['Result_SendCourierID']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
$sql = "UPDATE result_courierspk_detail SET Result_CourierSPKDetailStatus = 'S', Result_CourierSPKDetailsUserID = {$userid}
|
||||
WHERE
|
||||
Result_CourierSPKDetailT_OrderDeliveryID = {$v['T_OrderDeliveryID']} AND
|
||||
Result_CourierSPKDetailT_OrderPromiseID = {$v['T_OrderPromiseID']}
|
||||
";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
$result = array ("total" => 0, "records" => array('status'=>'OK','message'=>''));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
201
one-api/application/controllers/mockup/email/Done.php
Normal file
201
one-api/application/controllers/mockup/email/Done.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
class Done 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;
|
||||
}
|
||||
|
||||
$nolab = $prm["nolab"];
|
||||
$groupid = $prm["groupid"];
|
||||
//$subgroupid = $prm["subgroupid"];
|
||||
$join_group = '';
|
||||
if($groupid != '0'){
|
||||
$join_group = "JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID AND Nat_GroupID = {$groupid}";
|
||||
}
|
||||
/*$join_subgroup = '';
|
||||
if($subgroupid != 0){
|
||||
$join_group = "JOIN nat_subgroup ON T_TestNat_SubgroupID = Nat_SubgroupID AND Nat_SubgroupID = {$subgroupid}";
|
||||
}*/
|
||||
|
||||
if(!isset($prm['current_page']))
|
||||
$prm['current_page'] = 1;
|
||||
|
||||
$sql_where = "WHERE Result_FrontOfficeStatus = 'S' AND JSON_CONTAINS(Result_FrontOfficeIds,T_OrderDetailID)";
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
//$sql_param = array();
|
||||
if ($nolab != "" ) {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( T_OrderHeaderLabNumber like '%$nolab%' OR M_PatientName like '%$nolab%' )";
|
||||
}
|
||||
|
||||
/*if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like '%$nama%' ";
|
||||
}*/
|
||||
|
||||
$sql = "SELECT Result_FrontOfficeID as xid,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderLabNumber as ordernumber,
|
||||
UPPER(CONCAT(M_TitleName,' ',M_PatientName)) as patient_fullname,
|
||||
Result_FrontOfficeTestName as test_name,
|
||||
'N' as chex
|
||||
FROM result_frontoffice
|
||||
join t_orderheader ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND JSON_CONTAINS(Result_FrontOfficeIds, T_OrderDetailID)
|
||||
$join_group
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
$sql_where
|
||||
GROUP BY Result_FrontOfficeID
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
|
||||
$result = array("total" => count($rst), "records" => $rows, "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkerajaan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//$rst = array(array('id'=>0,'name'=>'Semua'));
|
||||
|
||||
$sql = "SELECT 0 as id, 'Semua' as name UNION SELECT Nat_GroupID as id, Nat_GroupName as name FROM nat_group WHERE Nat_GroupIsActive = 'Y'";
|
||||
$rst_db = $this->db_onedev->query($sql)->result_array();
|
||||
//$c = array_combine($rst,$rst_db);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rst_db
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function dosend(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$selected = $prm['selected'];
|
||||
|
||||
foreach($selected as $k => $v){
|
||||
$sql = "UPDATE result_frontoffice SET Result_FrontOfficeStatus = 'R' WHERE Result_FrontOfficeID = {$v['xid']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function sendemail(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$rows = array();
|
||||
$ids = "(".$prm['ids'].")";
|
||||
$sql = "UPDATE result_sendemail SET Result_SendEmailStatus = 'S', Result_SendEmailUserID = {$userid} WHERE Result_SendEmailID IN {$ids}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
$sql = "SELECT * FROM result_sendemail WHERE Result_SendEmailID IN {$ids}";
|
||||
$dt_rst = $this->db_onedev->query($sql)->result_array();
|
||||
foreach($dt_rst as $k => $v){
|
||||
$dt_log = json_encode($v);
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function updateemail(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$rows = array();
|
||||
$id = $prm['id'];
|
||||
$sql = "UPDATE t_orderdelivery SET T_OrderDeliveryDestination = '{$prm['edited_email']}', T_OrderDeliveryUserID = {$userid} WHERE T_OrderDeliveryID = {$id}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array ("total" => 0, "records" => array());
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
848
one-api/application/controllers/mockup/email/Patient.php
Normal file
848
one-api/application/controllers/mockup/email/Patient.php
Normal file
@@ -0,0 +1,848 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
|
||||
function add_verifications_label($orderid){
|
||||
$query = " SELECT Result_VerificationsID as id,
|
||||
IFNULL(Result_VerificationsValueID,0) as xid,
|
||||
IFNULL(Result_VerificationsValueCheck,'N') as chex,
|
||||
IF(ISNULL(Result_VerificationsValueID),'',Result_VerificationsValueNote) as note,
|
||||
Result_VerificationsLabel as label
|
||||
FROM result_verifications
|
||||
LEFT JOIN result_verifications_value ON Result_VerificationsValueResult_VerificationsID = Result_VerificationsID AND
|
||||
Result_VerificationsValueSo_ResultEntryID = $orderid
|
||||
WHERE
|
||||
Result_VerificationIsActive = 'Y'
|
||||
GROUP BY Result_VerificationsID
|
||||
";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nolab = $prm["nolab"];
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$datepromise = $prm["startdate"];
|
||||
$filter = " AND Result_SendEmailStatus = '{$status}'";
|
||||
$having = "HAVING not_ready_count = 0";
|
||||
if($status == 'X'){
|
||||
$filter = " AND ISNULL(Result_SendEmailID)";
|
||||
$having = "HAVING not_ready_count > 0";
|
||||
}
|
||||
if($status == 'P')
|
||||
$filter .= " AND Result_SendEmailActionBy = 'MANUAL'";
|
||||
|
||||
|
||||
if(!isset($prm['current_page']))
|
||||
$prm['current_page'] = 1;
|
||||
|
||||
$sql_where = "WHERE T_OrderDetailIsActive = 'Y' ";
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
//$sql_param = array();
|
||||
if ($nolab != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( T_OrderHeaderLabNumber like '%$nolab%' AND M_PatientName like '%$nolab%' ) ";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) as total
|
||||
FROM (
|
||||
SELECT T_OrderHeaderID,
|
||||
T_OrderPromiseID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderIsCito as iscito,
|
||||
M_CompanyName,
|
||||
T_OrderPromiseDateTime,
|
||||
T_OrderHeaderLabNumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
M_PatientHP as patient_hp,
|
||||
M_PatientPhotoThumb as photo,
|
||||
fn_fo_check_status_not_ready_email(T_OrderHeaderID,T_OrderPromiseID) as not_ready_count
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdelivery ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = 3 AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseDateTime < '{$datepromise} 23:59:59'
|
||||
LEFT JOIN result_sendemail ON Result_SendEmailT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_SendEmailIds,T_OrderDetailID)
|
||||
$sql_where $filter
|
||||
GROUP BY T_OrderHeaderID, T_OrderPromiseID, T_OrderDeliveryID
|
||||
$having
|
||||
)x";
|
||||
//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("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT GROUP_CONCAT(IFNULL(Result_SendEmailID,0) separator ',') as ids,
|
||||
T_OrderHeaderID,
|
||||
T_OrderPromiseID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderIsCito as iscito,
|
||||
M_CompanyName,
|
||||
DATE_FORMAT(T_OrderPromiseDateTime,'%d-%m-%Y %H:%i') as date_promise,
|
||||
T_OrderHeaderLabNumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
M_PatientHP as patient_hp,
|
||||
M_PatientPhotoThumb as photo,
|
||||
IFNULL(Result_SendEmailStatus,'X') as status,
|
||||
fn_fo_check_status_not_ready_email(T_OrderHeaderID,T_OrderPromiseID) as not_ready_count,
|
||||
Last_StatusPaymentIsLunas as status_lunas,
|
||||
M_MouIsBill as status_bill
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdelivery ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderDeliveryM_DeliveryTypeID = 3 AND
|
||||
T_OrderDeliveryIsActive = 'Y'
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseDateTime < '{$datepromise} 23:59:59'
|
||||
LEFT JOIN result_sendemail ON Result_SendEmailT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_SendEmailIds,T_OrderDetailID)
|
||||
$sql_where $filter
|
||||
GROUP BY T_OrderHeaderID, T_OrderPromiseID, T_OrderDeliveryID
|
||||
$having
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($rows){
|
||||
/*foreach($rows as $k => $v){
|
||||
$rows[$k]['verifications'] = $this->add_verifications_label($v['trx_id']);
|
||||
}*/
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
$xprm = $this->sys_input;
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
//# ambil parameter input
|
||||
|
||||
//print_r($xprm);
|
||||
$prm = $xprm['patient'];
|
||||
$xstatus = $xprm['act'];
|
||||
$fostatusid = 3;
|
||||
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
||||
$id = $prm['T_OrderHeaderID'];
|
||||
echo $xstatus;
|
||||
if($xstatus == 'N'){
|
||||
$fostatusid = 4;
|
||||
$fologcode = 'FO.VERIFICATION.REJECT';
|
||||
}else{
|
||||
|
||||
$this->save_barcode_new($id);
|
||||
}
|
||||
|
||||
|
||||
//print_r($prm);
|
||||
$xverificationnote = $prm['verification_note'];
|
||||
//echo $xverificationnote;
|
||||
|
||||
$sql = "update t_orderheader
|
||||
set
|
||||
T_OrderHeaderVerificationNote = '{$xverificationnote}'
|
||||
where
|
||||
T_OrderHeaderID = $id";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
|
||||
/*$xverification_patient = $this->saveverifications($id,$prm['verification_patient'],'PATIENT',$xuserid);
|
||||
$xverification_doctor = $this->saveverifications($id,$prm['verification_doctor'],'DOCTOR',$xuserid);
|
||||
$xverification_companymou = $this->saveverifications($id,$prm['verification_companymou'],'COMPANY',$xuserid);
|
||||
$xverification_payment = $this->saveverifications($id,$prm['verification_payment'],'PAYMENT',$xuserid);
|
||||
$xverification_info = $this->saveverifications($id,$prm['verification_info'],'INFO',$xuserid);
|
||||
|
||||
$xverification_delivery = $this->saveverification_delivery($id,$prm['verification_delivery'],$xuserid);
|
||||
$xverification_px = $this->saveverification_px($id,$prm['verification_px'],$xuserid);*/
|
||||
|
||||
$sql = "insert into fo_status(
|
||||
Fo_StatusDate,
|
||||
Fo_StatusT_OrderHeaderID,
|
||||
Fo_StatusM_StatusID,
|
||||
Fo_StatusM_UserID,
|
||||
Fo_StatusCreated,
|
||||
Fo_StatusUpdated)
|
||||
values( now(), ?, ?, ?, now(),now())";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$fostatusid,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_status insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $id;
|
||||
/*$data_log['verification_patient'] = $prm['verification_patient'];
|
||||
$data_log['verification_doctor'] = $prm['verification_doctor'];
|
||||
$data_log['verification_companymou'] = $prm['verification_companymou'];
|
||||
$data_log['verification_payment'] = $prm['verification_payment'];
|
||||
$data_log['verification_info'] = $prm['verification_info'];
|
||||
$data_log['verification_px'] = $prm['verification_px'];
|
||||
$data_log['verification_delivery'] = $prm['verification_delivery'];*/
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($xstatus == 'Y'){
|
||||
$msg = 'Verifikasi berhasil dilakukan';
|
||||
}
|
||||
else{
|
||||
$msg = 'Tolak Verifikasi berhasil dilakukan';
|
||||
$sql = "INSERT INTO t_ordermessage (
|
||||
T_OrderMessageT_OrderHeaderID,
|
||||
T_OrderMessageType,
|
||||
T_OrderMessageMessage,
|
||||
T_OrderMessageFromUserID,
|
||||
T_OrderMessageCreated,
|
||||
T_OrderMessageLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
{$id},
|
||||
'FO.VERIFICATION.REJECT',
|
||||
'{$xverificationnote}',
|
||||
{$xuserid},
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.t_ordermessage insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows = array('message'=>$msg);
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function save_barcode_new($orderid){
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
|
||||
$query =" SELECT T_SampleTypeID as id,
|
||||
T_SampleTypeName as name,
|
||||
'' as children
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$orderid}
|
||||
GROUP BY T_SampleTypeID
|
||||
";
|
||||
//echo $query ;
|
||||
$barcodes = $this->db_onedev->query($query)->result();
|
||||
foreach($barcodes as $k => $v){
|
||||
$query = "SELECT T_SampleTypeID as id, IFNULL(T_BarcodeLabID,0) as xid,
|
||||
IF(ISNULL(T_BarcodeLabID),'Y',T_BarcodeLabIsActive) as chex,
|
||||
T_TestName as testname,
|
||||
T_SampleTypeName as samplename,
|
||||
IF(ISNULL(T_BarcodeLabID),CONCAT(T_OrderHeaderLabNumber,'.',T_SampleTypeID,'.',1),T_BarcodeLabBarcode) as barcodenumber
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderid} AND T_SampleTypeID = {$v->id}
|
||||
GROUP BY T_BarcodeLabID ";
|
||||
$v->children = $this->db_onedev->query($query)->result_array();
|
||||
//$v->children = $barcode_data;
|
||||
foreach($v->children as $ki => $vi){
|
||||
if($vi['chex'] == 'N')
|
||||
$v->children[$ki]['chex'] = false;
|
||||
else
|
||||
$v->children[$ki]['chex'] = true;
|
||||
$sql = "insert into t_barcodelab(
|
||||
T_BarcodeLabT_OrderHeaderID,
|
||||
T_BarcodeLabBarcode,
|
||||
T_BarcodeLabT_SampleTypeID,
|
||||
T_BarcodeLabCreated,
|
||||
T_BarcodeLabLastUpdated,
|
||||
T_BarcodeLabUserID)
|
||||
values( ?, ?, ?, now(),now(),?)";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid,
|
||||
$v->children[$ki]['barcodenumber'],
|
||||
$v->children[$ki]['id'],
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_barcodelab insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//insert log
|
||||
$supplies = array();
|
||||
$query =" SELECT M_SuppliesID as id,
|
||||
IFNULL(T_OrderSuppliesID,0) as xid,
|
||||
IF(ISNULL(T_OrderSuppliesID),'N',T_OrderSuppliesIsActive) as chex,
|
||||
IFNULL(T_OrderSuppliesQty,1) as qty,
|
||||
M_SuppliesName as name,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as lastupdated,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as tx_lastupdated
|
||||
FROM m_supplies
|
||||
JOIN t_ordersupplies ON T_OrderSuppliesT_OrderHeaderID = $orderid AND T_OrderSuppliesM_SuppliesID = M_SuppliesID
|
||||
WHERE
|
||||
M_SuppliesIsActive = 'Y'
|
||||
";
|
||||
//echo $query ;
|
||||
$supplies = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
foreach($supplies as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$supplies[$k]['chex'] = false;
|
||||
else
|
||||
$supplies[$k]['chex'] = true;
|
||||
}
|
||||
|
||||
$dt_log = array('orderid'=>$orderid,'supplies'=>$supplies,'barcode'=>$barcodes);
|
||||
$fologcode = 'FO.Verification.BarcodeSupplies';
|
||||
$json_dt_log = json_encode($dt_log);
|
||||
$sql = "insert into one_log.log_supplies_barcode(
|
||||
Log_SuppliesBarcodeDate,
|
||||
Log_SuppliesBarcodeCode,
|
||||
Log_SuppliesBarcodeJson,
|
||||
Log_SuppliesBarcodeUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.log_supplies_barcode insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function saveverifications($id,$verifications,$type,$userid)
|
||||
{
|
||||
try {
|
||||
//$xverificationtypeid = $this->db_onedev->query("SELECT * FROM fo_verificationtype WHERE Fo_VerificationTypeGroup = '{$type}' AND Fo_VerificationTypeIsActive = 'Y'")->row()->Fo_VericationTypeID;
|
||||
//echo $xverificationtypeid;
|
||||
//print_r($verifications);
|
||||
foreach($verifications as $k => $v){
|
||||
//print_r($v);
|
||||
if(intval($v['xid']) == 0){
|
||||
$sql = "insert into fo_verification(
|
||||
Fo_VerificationT_OrderHeaderID,
|
||||
Fo_VerificationFo_VericationTypeID,
|
||||
Fo_VerificationIsOK,
|
||||
Fo_VerificationReason,
|
||||
Fo_VerificationCreated,
|
||||
Fo_VerificationLastUpdated,
|
||||
Fo_VerificationUserID)
|
||||
values( ?, ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['id'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_verification insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveverification_delivery($id,$deliveries,$userid)
|
||||
{
|
||||
try {
|
||||
foreach($deliveries as $k => $v){
|
||||
if($v['id'] === 0){
|
||||
$sql = "insert into fo_verification_delivery_add(
|
||||
Fo_VerificationDeliveryAddT_OrderHeaderID,
|
||||
Fo_VerificationDeliveryAddM_DeliveryID,
|
||||
Fo_VerificationDeliveryAddM_DeliveryTypeID,
|
||||
Fo_VerificationDeliveryAddDestination,
|
||||
Fo_VerificationDeliveryAddAddressID,
|
||||
Fo_VerificationDeliveryAddM_KelurahanID,
|
||||
Fo_VerificationDeliveryAddOK,
|
||||
Fo_VerificationDeliveryAddReason,
|
||||
Fo_VerificationDeliveryAddCreated,
|
||||
Fo_VerificationDeliveryAddLastUpdated,
|
||||
Fo_VerificationDeliveryAddUserID)
|
||||
values( ?, ?, ?, ?,?,?,?,?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['deliveryid'],
|
||||
$v['typedeliveryid'],
|
||||
$v['destination'],
|
||||
$v['addressid'],
|
||||
$v['vilageid'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("fo_verification_delivery_add insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
}else{
|
||||
$sql = "insert into fo_verification_delivery(
|
||||
Fo_VerificationDeliveryT_OrderHeaderID,
|
||||
Fo_VerificationDeliveryT_OrderDeliveryID,
|
||||
Fo_VerificationDeliveryIsOK,
|
||||
Fo_VerificationDeliveryReason,
|
||||
Fo_VerificationDeliveryCreated,
|
||||
Fo_VerificationDeliveryLastUpdated,
|
||||
Fo_VerificationDeliveryUserID)
|
||||
values( ?, ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['id'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("fo_verification_delivery insert");
|
||||
exit;
|
||||
}
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function lookup_barcodes()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$sql = "SELECT T_BarcodeLabID as id, 'barcode' as type,T_BarcodeLabID,T_BarcodeLabBarcode, T_BarcodeLabCounter, T_SampleTypeName, 'N' as chex
|
||||
FROM t_barcodelab
|
||||
JOIN t_sampletype ON T_BarcodeLabT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
T_BarcodeLabT_OrderHeaderID = {$prm['ohid']} AND T_BarcodeLabIsActive = 'Y'
|
||||
UNION
|
||||
SELECT T_OrderHeaderID as id, 'formulir' as type, 0,T_OrderHeaderLabNumber as T_BarcodeLabBarcode, 1, 'Formulir' as T_SampleTypeName, 'N' as chex
|
||||
FROM t_orderheader
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['ohid']}
|
||||
";
|
||||
//echo $sql;
|
||||
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveverification_px($id,$pxs,$userid)
|
||||
{
|
||||
try {
|
||||
foreach($pxs as $k => $v){
|
||||
|
||||
if(intval($v['id']) == 0){
|
||||
$cxh = $v['chex'] == true ?'Y':'N';
|
||||
$sql = "insert into fo_verification_test_add(
|
||||
Fo_VerificationTestAddT_OrderHeaderID,
|
||||
Fo_VerificationTestAddT_TestID,
|
||||
Fo_VerificationTestAddBruto,
|
||||
Fo_VerificationTestAddDiscount,
|
||||
Fo_VerificationTestAddTotal,
|
||||
Fo_VerificationTestAddIsOK,
|
||||
Fo_VerificationTestAddIsCito,
|
||||
Fo_VerificationTestAddCreated,
|
||||
Fo_VerificationTestAddLastUpdated,
|
||||
Fo_VerificationTestAddUserID)
|
||||
values( $id, {$v['pxid']}, {$v['bruto']}, {$v['discount']},{$v['total']},'{$cxh}','{$v['flagcito']}',now(),now(),{$userid})";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_verification_test_add insert");
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$sql = "insert into fo_verification_test(
|
||||
Fo_VerificationTestT_OrderHeaderID,
|
||||
Fo_VerificationTestT_OrderDetailID,
|
||||
Fo_VerificationTestIsOK,
|
||||
Fo_VerificationTestReason,
|
||||
Fo_VerificationTestCreated,
|
||||
Fo_VerificationTestLastUpdated,
|
||||
Fo_VerificationTestUserID)
|
||||
values( ?, ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['id'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_verification_test insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function verify(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$xstatus = $prm['act'];
|
||||
if($xstatus == 'Y'){
|
||||
$msg = "Berhasil melakukan verifikasi";
|
||||
$query =" INSERT INTO result_verifications_value (
|
||||
Result_VerificationsValueSo_ResultEntryID,
|
||||
Result_VerificationsValueResult_VerificationsID,
|
||||
Result_VerificationsValueCheck,
|
||||
Result_VerificationsValueNote,
|
||||
Result_VerificationsValueUserID,
|
||||
Result_VerificationsValueCreated
|
||||
)
|
||||
SELECT {$prm['trx_id']},
|
||||
Result_VerificationsID,
|
||||
'Y',
|
||||
'',
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM result_verifications
|
||||
WHERE
|
||||
Result_VerificationIsActive = 'Y'
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Result_VerificationsValueCheck = 'Y',
|
||||
Result_VerificationsValueNote = '',
|
||||
Result_VerificationsValueUserID = {$userid},
|
||||
Result_VerificationsValueLastUpdated = NOW()
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "UPDATE so_resultentry SET So_ResultEntryStatus = 'VAL2' , So_ResultEntryValidation2 = 'Y' WHERE So_ResultEntryID = {$prm['trx_id']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
else{
|
||||
$msg = "Tolak untuk perbaikan";
|
||||
$verifications = $prm['verifications'];
|
||||
foreach($verifications as $k => $v){
|
||||
$chx = $v['chex'] == true ?'Y':'N';
|
||||
$query =" INSERT INTO result_verifications_value (
|
||||
Result_VerificationsValueSo_ResultEntryID,
|
||||
Result_VerificationsValueResult_VerificationsID,
|
||||
Result_VerificationsValueCheck,
|
||||
Result_VerificationsValueNote,
|
||||
Result_VerificationsValueUserID,
|
||||
Result_VerificationsValueCreated
|
||||
)
|
||||
values( {$prm['trx_id']},
|
||||
{$v['id']},
|
||||
'{$chx}',
|
||||
'{$v['note']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Result_VerificationsValueCheck = '{$chx}',
|
||||
Result_VerificationsValueNote = '{$v['note']}',
|
||||
Result_VerificationsValueUserID = {$userid},
|
||||
Result_VerificationsValueLastUpdated = NOW()
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 0, "records" => array('status'=>'OK','message'=>$msg));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function getstatuspergroup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$rows = array();
|
||||
|
||||
$sql =" SELECT Last_StatusPaymentBillTotal as total_bill,
|
||||
Last_StatusPaymentPaid as paid,
|
||||
Last_StatusPaymentUnpaid as unpaid,
|
||||
Last_StatusPaymentIsLunas as status
|
||||
FROM last_statuspayment
|
||||
WHERE
|
||||
Last_StatusPaymentT_OrderHeaderID = {$prm['T_OrderHeaderID']} ";
|
||||
$rows['info_bill'] = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
|
||||
$sql =" SELECT T_OrderDeliveryID as id,
|
||||
IFNULL(Fo_VerificationDeliveryID,0) as xid,
|
||||
M_DeliveryTypeCode as code,
|
||||
IF(ISNULL(Fo_VerificationDeliveryID),'N',Fo_VerificationDeliveryIsOK) as chex,
|
||||
M_DeliveryID as deliveryid,
|
||||
M_DeliveryTypeID as typedeliveryid,
|
||||
T_OrderDeliveryM_KelurahanID as vilageid,
|
||||
IF(ISNULL(Fo_VerificationDeliveryID),'',Fo_VerificationDeliveryReason) as note,
|
||||
'reguler' as type,
|
||||
CASE
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 1 THEN M_DeliveryName
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN CONCAT(M_DeliveryName)
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN CONCAT(M_DeliveryName)
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 ) THEN CONCAT(M_DeliveryName)
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 ) THEN CONCAT(M_DeliveryName)
|
||||
ELSE
|
||||
CONCAT(M_DeliveryName)
|
||||
END as label,
|
||||
CASE
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 1 THEN ''
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN M_DoctorAddressDescription
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN M_PatientAddressDescription
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 ) THEN M_DoctorHP
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 ) THEN M_PatientHP
|
||||
ELSE
|
||||
T_OrderDeliveryDestination
|
||||
END as destination,
|
||||
CASE
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN M_DoctorAddressID
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN M_PatientAddressID
|
||||
ELSE
|
||||
0
|
||||
END as addressid
|
||||
FROM t_orderdelivery
|
||||
JOIN t_orderheader ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_delivery ON T_OrderDeliveryM_DeliveryID = M_DeliveryID
|
||||
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
LEFT JOIN m_doctoraddress ON T_OrderDeliveryAddressID = M_DoctorAddressID AND T_OrderDeliveryM_DeliveryID = 4
|
||||
LEFT JOIN m_patientaddress ON T_OrderDeliveryAddressID = M_PatientAddressID AND T_OrderDeliveryM_DeliveryID = 2
|
||||
LEFT JOIN fo_verification_delivery ON Fo_VerificationDeliveryT_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID AND Fo_VerificationDeliveryIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID AND ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 )
|
||||
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 )
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND T_OrderDeliveryIsActive = 'Y'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
|
||||
";
|
||||
//echo $query ;
|
||||
$rows['info_deliveries'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "
|
||||
SELECT T_OrderHeaderID,
|
||||
T_OrderPromiseID,
|
||||
T_OrderPromiseDateTime,
|
||||
T_OrderHeaderLabNumber,
|
||||
UPPER(DocumentationGroupName) as DocumentationGroupName,
|
||||
GROUP_CONCAT(CONCAT(T_TestName,'^',IFNULL(Result_SendEmailStatus,'X'))) as status_test_name,
|
||||
GROUP_CONCAT(IFNULL(Result_SendEmailStatus,'X')) as status,
|
||||
'' as status_pergroup,
|
||||
'' as details
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
LEFT JOIN result_sendemail ON Result_SendEmailT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_SendEmailIds,T_OrderDetailID)
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['T_OrderHeaderID']} AND T_OrderPromiseID = {$prm['T_OrderPromiseID']} AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY DocumentationGroupID
|
||||
|
||||
";
|
||||
|
||||
$rows['info_test'] = $this->db_onedev->query($sql)->result_array();
|
||||
if($rows['info_test']){
|
||||
foreach($rows['info_test'] as $k => $v){
|
||||
$rows['info_test'][$k]['status_pergroup'] = 'R';
|
||||
$x_arr = explode(',',$v['status']);
|
||||
if(in_array('X',$x_arr)){
|
||||
$rows['info_test'][$k]['status_pergroup'] = 'X';
|
||||
}
|
||||
if($v['DocumentationGroupName'] != 'LAB'){
|
||||
|
||||
$z_arr = explode(',',$v['status_test_name']);
|
||||
$for_details = array();
|
||||
foreach($z_arr as $i => $val){
|
||||
$xx_arr = explode('^',$val);
|
||||
array_push($for_details,array('testname'=>$xx_arr[0],'status'=>$xx_arr[1]));
|
||||
}
|
||||
$rows['info_test'][$k]['details'] = $for_details;
|
||||
}
|
||||
else{
|
||||
$rows['info_test'][$k]['DocumentationGroupName'] = 'Laboratorium';
|
||||
$rows['info_test'][$k]['details'] = array(array('testname'=>'Pemeriksaan Laboratorium','status'=>$rows['info_test'][$k]['status_pergroup']));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
128
one-api/application/controllers/mockup/fo/cashier/Patient.php
Normal file
128
one-api/application/controllers/mockup/fo/cashier/Patient.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?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 add_notes($orderid){
|
||||
$sql = " SELECT F_PaymentT_OrderHeaderID as note_order_id,
|
||||
F_PaymentID as note_id,
|
||||
F_PaymentDate as note_date,
|
||||
F_PaymentNumber as note_number,
|
||||
GROUP_CONCAT(M_PaymentTypeName separator ' , ') as paymenttypes_name,
|
||||
SUM(F_PaymentDetailAmount) as note_amount,
|
||||
M_UserUsername as note_user,
|
||||
F_PaymentDetailIsActive as note_active
|
||||
FROM f_payment
|
||||
JOIN f_paymentdetail ON F_PaymentDetailF_PaymentID = F_PaymentID
|
||||
JOIN m_paymenttype ON F_PaymentDetailM_PaymentTypeID = M_PaymentTypeID
|
||||
LEFT JOIN m_user ON F_PaymentDetailUserID = M_UserID
|
||||
WHERE
|
||||
F_PaymentT_OrderHeaderID = {$orderid}
|
||||
GROUP BY F_PaymentID";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
return $rows;
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("get notes", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$startdate = $prm['startdate'] . " 00:00:01";
|
||||
$enddate = $prm['enddate'] . " 23:59:59";
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$where = " ( T_OrderHeaderDate BETWEEN '{$startdate}' AND '{$enddate}' ) AND ";
|
||||
if($search != '')
|
||||
$where = "( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND ";
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_orderheader
|
||||
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
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') )";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT t_orderheader.*,
|
||||
M_PatientNoReg,
|
||||
M_PatientName,
|
||||
M_TitleName,
|
||||
M_CompanyName,
|
||||
M_MouName,
|
||||
T_OrderHeaderTotal as totalbill,
|
||||
IFNULL(Last_StatusPaymentPaid,0) as paid,
|
||||
IFNULL(Last_StatusPaymentUnpaid,T_OrderHeaderTotal)as unpaid,
|
||||
Last_StatusPaymentIsLunas as flaglunas,
|
||||
'' as notes,
|
||||
M_MouMinDP as mindp_percent,
|
||||
(M_MouMinDP/100) * T_OrderHeaderTotal as mindp_amount
|
||||
FROM t_orderheader
|
||||
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
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') )
|
||||
ORDER BY T_OrderHeaderID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['notes'] = $this->add_notes($v['T_OrderHeaderID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
244
one-api/application/controllers/mockup/fo/cashier/Payment.php
Normal file
244
one-api/application/controllers/mockup/fo/cashier/Payment.php
Normal file
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookup_type()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
IF(M_PaymentTypeCode = 'CASH','Y','N') as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function pay()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$payments = $prm['payments'];
|
||||
//$xnumber = $this->db_onedev->query("SELECT `fn_numbering`('PAY') as numberx")->row()->numberx;
|
||||
$sql = "INSERT INTO f_payment(F_PaymentT_OrderHeaderID,F_PaymentDate,F_PaymentCreated,F_PaymentM_UserID) VALUES (?,CURDATE(),NOW(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid, $xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_payment insert");
|
||||
exit;
|
||||
}
|
||||
$headerid = $this->db_onedev->insert_id();
|
||||
|
||||
foreach($payments as $k => $v){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
if($v['code'] == 'CASH'){
|
||||
$actual = $v['leftvalue'];
|
||||
$change = $v['rightvalue'];
|
||||
if($actual > 0){
|
||||
$amount = intval($v['leftvalue']) - intval($v['rightvalue']);
|
||||
}
|
||||
else{
|
||||
$amount = $actual;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO f_paymentdetail(
|
||||
F_PaymentDetailF_PaymentID,
|
||||
F_PaymentDetailM_PaymentTypeID,
|
||||
F_PaymentDetailAmount,
|
||||
F_PaymentDetailActual,
|
||||
F_PaymentDetailChange,
|
||||
F_PaymentDetailCreated,
|
||||
F_PaymentDetailLastUpdated,
|
||||
F_PaymentDetailUserID)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now(),
|
||||
?
|
||||
)";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$headerid,
|
||||
$v['id'],
|
||||
$amount,
|
||||
$actual,
|
||||
$change,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail cash insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
if(intval($v['leftvalue']) > 0){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
$sql = "INSERT INTO f_paymentdetail(
|
||||
F_PaymentDetailF_PaymentID,
|
||||
F_PaymentDetailM_PaymentTypeID,
|
||||
F_PaymentDetailAmount,
|
||||
F_PaymentDetailActual,
|
||||
F_PaymentDetailChange,
|
||||
F_PaymentDetailCreated,
|
||||
F_PaymentDetailLastUpdated,
|
||||
F_PaymentDetailUserID)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now(),
|
||||
?
|
||||
)";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$headerid,
|
||||
$v['id'],
|
||||
$amount,
|
||||
$actual,
|
||||
$change,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail non cash insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
IF(M_PaymentTypeCode = 'CASH','Y','N') as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$xdata = $this->db_onedev->query("SELECT F_PaymentID as idx, F_PaymentNumber as numberx FROM f_payment WHERE F_PaymentID = {$headerid}")->row();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => array('types'=>$rows,'data'=>$xdata)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function delete_note()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$prmnota = $prm['nota'];
|
||||
$catatan = $prm['catatan'];
|
||||
$sql = "UPDATE f_payment SET F_PaymentIsActive = 'N', F_PaymentNote = '{$catatan}' WHERE F_PaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_payment delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE f_paymentdetail SET F_PaymentDetailIsActive = 'N' WHERE F_PaymentDetailF_PaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('prm'=>$prm)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?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 add_notes($orderid){
|
||||
$sql = " SELECT F_PaymentT_OrderHeaderID as note_order_id,
|
||||
F_PaymentID as note_id,
|
||||
F_PaymentDate as note_date,
|
||||
F_PaymentNumber as note_number,
|
||||
GROUP_CONCAT(M_PaymentTypeName separator ' , ') as paymenttypes_name,
|
||||
SUM(F_PaymentDetailAmount) as note_amount,
|
||||
M_UserUsername as note_user,
|
||||
F_PaymentDetailIsActive as note_active
|
||||
FROM f_payment
|
||||
JOIN f_paymentdetail ON F_PaymentDetailF_PaymentID = F_PaymentID
|
||||
JOIN m_paymenttype ON F_PaymentDetailM_PaymentTypeID = M_PaymentTypeID
|
||||
LEFT JOIN m_user ON F_PaymentDetailUserID = M_UserID
|
||||
WHERE
|
||||
F_PaymentT_OrderHeaderID = {$orderid}
|
||||
GROUP BY F_PaymentID";
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
return $rows;
|
||||
|
||||
} else {
|
||||
$this->sys_error_db("get notes", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$startdate = $prm['startdate'] . " 00:00:01";
|
||||
$enddate = $prm['enddate'] . " 23:59:59";
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$where = " ( T_OrderHeaderDate BETWEEN '{$startdate}' AND '{$enddate}' ) AND ";
|
||||
if($search != ''){
|
||||
$where = "( M_PatientName LIKE '%{$search}%' OR T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND ";
|
||||
if(strlen($search) == 9){
|
||||
$where = "T_OrderHeaderLabNumber = '{$search}' AND ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_orderheader
|
||||
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
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') )";
|
||||
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT t_orderheader.*,
|
||||
M_PatientNoReg,
|
||||
CONCAT(M_TitleName,'. ',M_PatientName) as M_PatientName,
|
||||
M_TitleName,
|
||||
M_CompanyName,
|
||||
M_MouName,
|
||||
T_OrderHeaderTotal as totalbill,
|
||||
IFNULL(Last_StatusPaymentPaid,0) as paid,
|
||||
(T_OrderHeaderTotal + fn_fo_chasier_get_admin_charge(T_OrderHeaderID) )- ifnull(fn_fo_chasier_get_total_payment(T_OrderHeaderID),0) as unpaid,
|
||||
Last_StatusPaymentIsLunas as flaglunas,
|
||||
'' as notes,
|
||||
M_MouMinDP as mindp_percent,
|
||||
(M_MouMinDP/100) * T_OrderHeaderTotal as mindp_amount
|
||||
FROM t_orderheader
|
||||
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
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
LEFT JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID AND Last_StatusPaymentIsActive = 'Y'
|
||||
WHERE
|
||||
$where
|
||||
( ('{$status}' = 'N' AND (Last_StatusPaymentIsLunas = 'N' OR Last_StatusPaymentID IS NULL)) OR ('{$status}' = 'Y' AND Last_StatusPaymentIsLunas = 'Y') )
|
||||
ORDER BY T_OrderHeaderID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['notes'] = $this->add_notes($v['T_OrderHeaderID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function lookup_type()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
'N' as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
'' as selected_card,
|
||||
'' as selected_edc,
|
||||
'' as selected_account,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'TRANSFER' THEN 'No. Rekening'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['selected_card'] = array('id'=>0,'name'=>'');
|
||||
$rows[$k]['selected_edc'] = array('id'=>0,'name'=>'');
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookup_banks()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT Nat_BankID as id, Nat_BankCode as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function lookup_accounts()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT M_BankAccountID as id, CONCAT(Nat_BankCode,' (',M_BankAccountNo,')') as name
|
||||
FROM m_bank_account
|
||||
JOIN nat_bank ON M_BankAccountNat_BankID = Nat_BankID
|
||||
WHERE
|
||||
M_BankAccountIsActive = 'Y'
|
||||
ORDER BY Nat_BankCode DESC";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function searchcard(){
|
||||
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
|
||||
if($prm['search'] != ''){
|
||||
$sql = "
|
||||
SELECT count(*) as total
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankName like ?
|
||||
AND Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
else{
|
||||
$sql = "
|
||||
SELECT count(*) as total
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
$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;
|
||||
}
|
||||
if($prm['search'] != ''){
|
||||
$sql = "
|
||||
SELECT Nat_BankID as id, Nat_BankName as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankName like ?
|
||||
AND Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName DESC
|
||||
";
|
||||
}
|
||||
else{
|
||||
$sql = "
|
||||
SELECT Nat_BankID as id, Nat_BankName as name
|
||||
FROM nat_bank
|
||||
WHERE
|
||||
Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName 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 pay()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$payments = $prm['payments'];
|
||||
//$xnumber = $this->db_onedev->query("SELECT `fn_numbering`('PAY') as numberx")->row()->numberx;
|
||||
$sql = "INSERT INTO f_payment(F_PaymentT_OrderHeaderID,F_PaymentDate,F_PaymentCreated,F_PaymentM_UserID) VALUES (?,CURDATE(),NOW(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid, $xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_payment insert");
|
||||
exit;
|
||||
}
|
||||
$headerid = $this->db_onedev->insert_id();
|
||||
|
||||
foreach($payments as $k => $v){
|
||||
if($v['chex']){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
if($v['code'] == 'CASH'){
|
||||
$actual = $v['leftvalue'];
|
||||
$change = $v['rightvalue'];
|
||||
if($actual > 0){
|
||||
$amount = intval($v['leftvalue']) - intval($v['rightvalue']);
|
||||
}
|
||||
else{
|
||||
$amount = $actual;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO f_paymentdetail(
|
||||
F_PaymentDetailF_PaymentID,
|
||||
F_PaymentDetailM_PaymentTypeID,
|
||||
F_PaymentDetailAmount,
|
||||
F_PaymentDetailActual,
|
||||
F_PaymentDetailChange,
|
||||
F_PaymentDetailCreated,
|
||||
F_PaymentDetailLastUpdated,
|
||||
F_PaymentDetailUserID)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now(),
|
||||
?
|
||||
)";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$headerid,
|
||||
$v['id'],
|
||||
$amount,
|
||||
$actual,
|
||||
$change,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail cash insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
if(intval($v['leftvalue']) > 0){
|
||||
$actual = 0;
|
||||
$change = 0;
|
||||
$amount = $v['leftvalue'];
|
||||
$selected_card = 0;
|
||||
$selected_edc = 0;
|
||||
$selected_account = 0;
|
||||
if($v['code'] == 'DEBIT' || $v['code'] == 'CREDIT' || $v['code'] == 'TRANSFER'){
|
||||
$selected_card = $v['selected_card']['id'];
|
||||
$selected_edc = $v['selected_edc']['id'];
|
||||
$selected_account = $v['selected_account']['id'];
|
||||
}
|
||||
$sql = "INSERT INTO f_paymentdetail(
|
||||
F_PaymentDetailF_PaymentID,
|
||||
F_PaymentDetailM_PaymentTypeID,
|
||||
F_PaymentDetailAmount,
|
||||
F_PaymentDetailActual,
|
||||
F_PaymentDetailChange,
|
||||
F_PaymentDetailCardNat_BankID,
|
||||
F_PaymentDetailEDCNat_BankID,
|
||||
F_PaymentDetailM_BankAccountID,
|
||||
F_PaymentDetailCreated,
|
||||
F_PaymentDetailLastUpdated,
|
||||
F_PaymentDetailUserID)
|
||||
VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
now(),
|
||||
now(),
|
||||
?
|
||||
)";
|
||||
//echo $sql;
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$headerid,
|
||||
$v['id'],
|
||||
$amount,
|
||||
$actual,
|
||||
$change,
|
||||
$selected_card,
|
||||
$selected_edc,
|
||||
$selected_account,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail non cash insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query = "SELECT M_PaymentTypeID as id,
|
||||
M_PaymentTypeCode as code,
|
||||
IF(M_PaymentTypeCode = 'CASH','Y','N') as chex,
|
||||
M_PaymentTypeName as chexlabel,
|
||||
'Jumlah' as leftlabel,
|
||||
CASE
|
||||
WHEN M_PaymentTypeCode = 'CASH' THEN 'Kembali'
|
||||
WHEN M_PaymentTypeCode = 'DEBIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'CREDIT' THEN 'Nomor Kartu'
|
||||
WHEN M_PaymentTypeCode = 'TRANSFER' THEN 'Nomor Rekening'
|
||||
ELSE 'Nomor Voucher'
|
||||
END as rightlabel,
|
||||
0 as leftvalue,
|
||||
0 as rightvalue
|
||||
FROM m_paymenttype WHERE M_PaymentTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
$xdata = $this->db_onedev->query("SELECT F_PaymentID as idx, F_PaymentNumber as numberx FROM f_payment WHERE F_PaymentID = {$headerid}")->row();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => array('payments'=>$payments,'types'=>$rows,'data'=>$xdata)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function delete_note()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$prmnota = $prm['nota'];
|
||||
$catatan = $prm['catatan'];
|
||||
$sql = "UPDATE f_payment SET F_PaymentIsActive = 'N', F_PaymentNote = '{$catatan}' WHERE F_PaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_payment delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE f_paymentdetail SET F_PaymentDetailIsActive = 'N' WHERE F_PaymentDetailF_PaymentID = {$prmnota['note_id']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("f_paymentdetail delete");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('prm'=>$prm)
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,893 @@
|
||||
<?php
|
||||
class Promisenotok extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Samplingcall API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$search = $prm["nolab"];
|
||||
$sql_where = "WHERE ( T_OrderHeaderLabNumber LIKE CONCAT('%','{$search}','%') OR M_PatientName LIKE CONCAT('%','{$search}','%')) AND T_OrderHeaderIsActive = 'Y'";
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
CONCAT(M_TitleName,'. ',M_PatientName) as patient_fullname,
|
||||
fn_fo_promise_not_ok(T_OrderHeaderID) as status
|
||||
FROM t_orderheader
|
||||
JOIN t_orderheaderaddon ON T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
$sql_where
|
||||
HAVING status = 'Y'
|
||||
|
||||
) a
|
||||
";
|
||||
//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("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
CONCAT(M_TitleName,'. ',M_PatientName) as patient_fullname,
|
||||
fn_fo_promise_not_ok(T_OrderHeaderID) as status
|
||||
FROM t_orderheader
|
||||
JOIN t_orderheaderaddon ON T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
$sql_where
|
||||
HAVING status = 'Y'
|
||||
ORDER BY T_OrderHeaderID ASC";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//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 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_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;
|
||||
}
|
||||
$rows = array('id'=>0,'name'=>'Semua');
|
||||
$sql = "
|
||||
SELECT M_CompanyID as id, M_CompanyName as name
|
||||
FROM m_company
|
||||
WHERE
|
||||
M_CompanyName like ?
|
||||
AND M_CompanyIsActive = 'Y'
|
||||
ORDER BY M_CompanyName DESC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
array_push($rows,array('id'=>0,'name'=>'Semua'));
|
||||
//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 fajribagus(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getstationstatus(){
|
||||
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' AND T_SampleStationIsNonLab = ''
|
||||
";
|
||||
//echo $query;
|
||||
$rows['stations'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['statuses'] = array(array('id'=>'NEW','name'=>'New'),array('id'=>'DONE','name'=>'Done'));
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function search_staff(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT M_StaffID as id, M_StaffName as name, M_StaffCode as code, M_UserID as userid
|
||||
FROM m_staff
|
||||
JOIN m_user ON M_UserM_StaffID = M_StaffID AND M_UserIsActive = 'Y'
|
||||
WHERE
|
||||
M_StaffIsActive = 'Y' AND M_StaffCode = '{$prm['search']}' LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->row_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function gettests(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT T_OrderDetailID as id,
|
||||
T_OrderDetailT_TestName as testname,
|
||||
T_OrderDetailT_TestCode as testcode,
|
||||
T_OrderDetailT_TestSasCode as sascode
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderDetailIsActive = 'Y' AND
|
||||
LENGTH(T_OrderDetailT_TestSasCode) = 8
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['orderid']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function savenewpromise(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$newpromise = $prm['newpromise'];
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
//print_r($newpromise);
|
||||
foreach($newpromise as $k => $v){
|
||||
$xdatetime = date('Y-m-d H:i',strtotime($v['promisedate'].' '.$v['promisetime']));
|
||||
$xid = 0;
|
||||
$sql = "SELECT * FROM t_orderpromise WHERE T_OrderPromiseT_OrderHeaderID = {$prm['orderid']} AND DATE_FORMAT(T_OrderPromiseDateTime,'%Y-%m-%d %H:%i') = '{$xdatetime}' AND T_OrderPromiseIsActive = 'Y' LIMIT 1";
|
||||
//echo $sql;
|
||||
$sql_xid = $this->db_onedev->query($sql)->row();
|
||||
if($sql_xid){
|
||||
$xid = $sql_xid->T_OrderPromiseID;
|
||||
}
|
||||
//echo $xid;
|
||||
if($xid == 0){
|
||||
$sql = "INSERT INTO t_orderpromise (
|
||||
T_OrderPromiseT_OrderHeaderID,
|
||||
T_OrderPromiseDateTime
|
||||
)VALUES(
|
||||
{$prm['orderid']},
|
||||
'{$xdatetime}'
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
$xid = $this->db_onedev->insert_id();
|
||||
}
|
||||
$sql = "UPDATE t_orderdetail SET T_OrderDetailT_OrderPromiseID = {$xid} WHERE T_OrderDetailID = '{$v['id']}' ";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $sql;
|
||||
}
|
||||
$fologcode = 'FO.P3KPROMISE';
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $prm['orderid'];
|
||||
$data_log['new_promise'] = $newpromise;
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $prm
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function getdatapromises(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$rows = array();
|
||||
if(isset($prm['act']) && $prm['act'] == 'save'){
|
||||
$newpromise = $prm['newpromise'];
|
||||
foreach($newpromise as $k => $v){
|
||||
$xdatetime = date('Y-m-d H:i:s',strtotime($v['promisedate'].' '.$v['promisetime']));
|
||||
$xid = 0;
|
||||
$sql_xid = $this->db_onedev->query("SELECT * FROM t_orderpromise WHERE T_OrderPromiseT_OrderHeaderID = {$prm['orderid']} AND T_OrderPromiseDateTime = '{$xdatetime}' AND T_OrderPromiseIsActive = 'Y'")->row();
|
||||
if($sql_xid){
|
||||
$xid = $sql_xid->T_OrderPromiseID;
|
||||
}
|
||||
if($xid == 0){
|
||||
$sql = "INSERT INTO t_orderpromise (
|
||||
T_OrderPromiseT_OrderHeaderID,
|
||||
T_OrderPromiseDateTime
|
||||
)VALUES(
|
||||
{$prm['orderid']},
|
||||
'{$xdatetime}'
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
else{
|
||||
$sql = "UPDATE t_orderpromise SET T_OrderPromiseT_OrderHeaderID = {$prm['orderid']}, T_OrderPromiseDateTime = '{$xdatetime}' ";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
$rows = array();
|
||||
$query =" SELECT 0 as id,
|
||||
GROUP_CONCAT(CONCAT(T_OrderDetailID,'-',T_OrderDetailT_TestName) separator ',') as testname,
|
||||
'' as arr_test,
|
||||
DATE_FORMAT(T_OrderPromiseDateTime,'%d%m%Y %H%i') as promisedatetime,
|
||||
DATE_FORMAT(T_OrderPromiseDateTime,'%d%m%Y') as promisedate,
|
||||
DATE_FORMAT(T_OrderPromiseDateTime,'%H%i') as promisetime
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderDetailIsActive = 'Y' and T_OrderDetailT_TestIsResult = 'Y'
|
||||
JOIN t_orderpromise ON T_OrderPromiseT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['orderid']}
|
||||
GROUP BY T_OrderPromiseID
|
||||
";
|
||||
//echo $query;
|
||||
$rows['ok'] = $this->db_onedev->query($query)->result_array();
|
||||
if($rows['ok']){
|
||||
foreach($rows['ok'] as $k => $v){
|
||||
//echo $v{'testname'};
|
||||
$arr_x = array();
|
||||
$expl_x_1 = explode(",",$v['testname']);
|
||||
//print_r($exp_x_1);
|
||||
foreach($expl_x_1 as $i=>$j){
|
||||
$expl_x_2 = explode("-",$j);
|
||||
//print_r($expl_x_2);
|
||||
array_push($arr_x,array('id'=>$expl_x_2[0],'name'=>$expl_x_2[1]));
|
||||
}
|
||||
$rows['ok'][$k]['arr_test'] = $arr_x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$query ="
|
||||
SELECT
|
||||
T_OrderDetailID as id,
|
||||
CONCAT(T_OrderDetailID,'-',T_OrderDetailT_TestName) as testname,
|
||||
'' as arr_test,
|
||||
DATE_FORMAT(fn_fo_p3k_promise(T_OrderHeaderID),'%d%m%Y %H%i') as promisedatetime,
|
||||
DATE_FORMAT(fn_fo_p3k_promise(T_OrderHeaderID),'%d%m%Y') as promisedate,
|
||||
DATE_FORMAT(fn_fo_p3k_promise(T_OrderHeaderID),'%H%i') as promisetime
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderDetailIsActive = 'Y' and T_OrderDetailT_TestIsResult = 'Y' AND T_OrderDetailT_OrderPromiseID = 0
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['orderid']}
|
||||
GROUP BY T_OrderDetailID
|
||||
";
|
||||
//echo $query;
|
||||
$rows['notok'] = $this->db_onedev->query($query)->result_array();
|
||||
if($rows['notok']){
|
||||
foreach($rows['notok'] as $k => $v){
|
||||
//echo $v{'testname'};
|
||||
$arr_x = array();
|
||||
$expl_x_1 = explode(",",$v['testname']);
|
||||
//print_r($exp_x_1);
|
||||
foreach($expl_x_1 as $i=>$j){
|
||||
$expl_x_2 = explode("-",$j);
|
||||
//print_r($expl_x_2);
|
||||
array_push($arr_x,array('id'=>$expl_x_2[0],'name'=>$expl_x_2[1]));
|
||||
}
|
||||
$rows['notok'][$k]['arr_test'] = $arr_x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function search_patient(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = '%'.$prm["search"].'%';
|
||||
$stationid = $prm["stationid"];
|
||||
$statusid = $prm["statusid"];
|
||||
$patients = $prm["patients"];
|
||||
$where_status = '';
|
||||
if($statusid === 'NEW'){
|
||||
$where_status = "AND (ISNULL(T_SamplingQueueLastStatusID) OR T_SamplingQueueLastStatusT_SamplingQueueStatusID <> 5 )";
|
||||
}
|
||||
else{
|
||||
$where_status = "AND T_SamplingQueueLastStatusT_SamplingQueueStatusID = 5";
|
||||
}
|
||||
|
||||
// echo $norm;
|
||||
//$where_status = " AND {$where_status}";
|
||||
|
||||
$sql_where = "WHERE T_OrderHeaderLabNumber LIKE '{$search}' AND T_OrderHeaderIsActive = 'Y' {$where_status}";
|
||||
$rows = [];
|
||||
$query = "SELECT t_orderheader.*,m_patient.*, IFNULL(M_PatientPhoto,'') as M_PatientPhotoThumb,
|
||||
M_SexName, M_TitleName, CONCAT(M_TitleName,' ',M_PatientName) as patient_fullname, M_CompanyName,
|
||||
IF(ISNULL(T_SamplingQueueLastStatusID), 'New',T_SamplingQueueStatusName) as status, DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as patient_dob,
|
||||
IF(ISNULL(T_SamplingQueueLastStatusID), 0,T_SamplingQueueLastStatusT_SamplingQueueStatusID) as statusid, T_SampleStationID, T_SampleTypeID,
|
||||
{$stationid} as stationid,
|
||||
fn_global_check_is_cito(T_OrderHeaderID) as iscito
|
||||
FROM t_orderheader
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
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
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$stationid} AND T_SampleStationIsNonLab = ''
|
||||
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID AND ( Last_StatusM_StatusID = 3 OR Last_StatusM_StatusID = 5 )
|
||||
LEFT JOIN t_sampling_queue_last_status ON
|
||||
T_SamplingQueueLastStatusT_SampleStationID = T_SampleStationID AND
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID
|
||||
LEFT JOIN t_ordersamplereq ON T_OrderSampleReqT_SampleStationID = T_SampleStationID AND T_OrderSampleReqT_OrderSampleID
|
||||
$sql_where
|
||||
GROUP BY T_OrderHeaderID
|
||||
ORDER BY T_OrderHeaderID DESC
|
||||
limit 1";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
/*function getrequirements($prm){
|
||||
|
||||
|
||||
$query =" SELECT Nat_RequirementID as id,
|
||||
Nat_RequirementName as name, '{$prm['status']}' as status,
|
||||
if(ISNULL(T_SamplingSoRequirementID),'N', if(json_contains(T_SamplingSoRequirementRequirements,Nat_RequirementID),'Y','N') ) as chex,
|
||||
Nat_RequirementPositionNat_PositionID as positionid
|
||||
FROM nat_requirement
|
||||
JOIN nat_testrequirement ON Nat_TestRequirementNat_RequirementID = Nat_RequirementID
|
||||
JOIN nat_requirementposition ON Nat_RequirementPositionNat_RequirementID = Nat_RequirementID AND Nat_RequirementPositionNat_PositionID = 8 AND
|
||||
Nat_RequirementPositionIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestRequirementNat_TestID
|
||||
LEFT JOIN t_samplingso_requirement ON T_SamplingSoRequirementT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_SamplingSoRequirementT_SampletypeID = {$prm['sampletypeid']} AND T_SamplingSoRequirementNat_PositionID = Nat_RequirementPositionNat_PositionID
|
||||
WHERE
|
||||
Nat_TestRequirementIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
return $rows;
|
||||
}*/
|
||||
|
||||
function getrequirements($prm){
|
||||
|
||||
$rows = array();
|
||||
$query = "
|
||||
SELECT Nat_RequirementID as id,
|
||||
Nat_RequirementName as name, 'P' as status,
|
||||
if(ISNULL(T_OrderSampleReqID),'N', if(json_contains(T_OrderSampleReqs,Nat_RequirementID),'Y','N') ) as chex,
|
||||
Nat_RequirementPositionNat_PositionID as positionid
|
||||
FROM nat_requirement
|
||||
JOIN nat_testrequirement ON Nat_TestRequirementNat_RequirementID = Nat_RequirementID
|
||||
JOIN nat_requirementposition ON Nat_RequirementPositionNat_RequirementID = Nat_RequirementID AND Nat_RequirementPositionNat_PositionID = 2 AND
|
||||
Nat_RequirementPositionIsActive = 'Y'
|
||||
JOIN t_test ON T_TestNat_TestID = Nat_TestRequirementNat_TestID
|
||||
JOIN t_barcodelab ON T_barcodeLabT_OrderHeaderID = {$prm['orderid']} AND T_BarcodeLabT_SampleTypeID = {$prm['sampletypeid']}
|
||||
JOIN t_ordersample ON T_OrderSampleT_OrderHeaderID = {$prm['orderid']} AND T_OrderSampleT_SampleTypeID = {$prm['sampletypeid']} AND
|
||||
T_OrderSampleT_BarcodeLabID = T_BarcodeLabID AND T_OrderSampleIsActive = 'Y'
|
||||
LEFT JOIN t_ordersamplereq ON T_OrderSampleReqT_OrderSampleID = T_OrderSampleID AND T_OrderSampleReqT_OrderHeaderID = {$prm['orderid']} AND
|
||||
T_OrderSampleReqNat_PositionID = Nat_RequirementPositionNat_PositionID
|
||||
WHERE
|
||||
Nat_TestRequirementIsActive = 'Y'
|
||||
GROUP BY nat_requirementID
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
function saverequirement(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query = " INSERT INTO t_samplingso_requirement (
|
||||
T_SamplingSoRequirementT_OrderHeaderID,
|
||||
T_SamplingSoRequirementT_SampleStationID,
|
||||
T_SamplingSoRequirementT_SampletypeID,
|
||||
T_SamplingSoRequirementStatus,
|
||||
T_SamplingSoRequirementRequirements,
|
||||
T_SamplingSoRequirementNote,
|
||||
T_SamplingSoRequirementNat_PositionID,
|
||||
T_SamplingSoRequirementUserID,
|
||||
T_SamplingSoRequirementCreated
|
||||
)VALUES(
|
||||
{$prm['T_OrderHeaderID']},
|
||||
{$prm['stationid']},
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
'N',
|
||||
|
||||
)";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaction(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rst_data = array('status'=>'OK');
|
||||
$status_call = array('status'=>'OK','data'=>array());
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($prm['staff']['id'] != 0 || $prm['staff']['id'] != '0' ){
|
||||
$userid = $prm['staff']['userid'];
|
||||
}
|
||||
|
||||
if($prm['act'] == 'call'){
|
||||
$sql = "SELECT if(fn_sampling_available_call({$prm['id']},{$prm['stationid']})=0,'Y','N') as status_call";
|
||||
$sql = "SELECT T_SamplingQueueLastStatusID, T_SamplingQueueStatusName, T_SampleStationName
|
||||
FROM t_sampling_queue_last_status
|
||||
JOIN t_sampling_queue_status ON T_SamplingQueueLastStatusT_SamplingQueueStatusID = T_SamplingQueueStatusID
|
||||
JOIN t_samplestation ON T_SampleStationID = T_SamplingQueueLastStatusT_SampleStationID
|
||||
WHERE
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID = {$prm['id']} AND
|
||||
T_SamplingQueueLastStatusT_SampleStationID <> {$prm['stationid']} AND
|
||||
T_SamplingQueueLastStatusT_SamplingQueueStatusID IN (1,3) LIMIT 1";
|
||||
$data_status_call = $this->db_onedev->query($sql)->row_array();
|
||||
if($data_status_call){
|
||||
$status_call = array('status'=>'NOTCALL','data'=>$data_status_call);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$next_status = $prm['statusnextid'];
|
||||
if($prm['act'] == 'process'){
|
||||
$sql = "SELECT T_OrderDetailID, T_OrderHeaderID,T_OrderDetailID as id,
|
||||
T_BarcodeLabID,
|
||||
T_BarcodeLabBarcode,
|
||||
T_OrderDetailT_TestCode,
|
||||
T_OrderDetailT_TestName,
|
||||
T_SampleTypeID,
|
||||
T_SampleTypeName,
|
||||
T_BahanName
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderHeaderID AND T_BarcodeLabT_SampleTypeID = T_SampleTypeID
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$prm['stationid']}
|
||||
LEFT JOIN t_ordersample ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID AND T_OrderSampleT_BarcodeLabID = T_BarcodeLabID AND
|
||||
T_OrderSampleT_SampleTypeID = T_SampleTypeID AND
|
||||
T_OrderSampleReceive = 'N' AND T_OrderSampleIsActive = 'Y'
|
||||
LEFT JOIN t_ordersamplereq ON T_OrderSampleReqT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderSampleReqT_OrderSampleID = T_OrderSampleID AND
|
||||
T_OrderSampleReqNat_PositionID = 2 AND
|
||||
T_OrderSampleReqT_SampleStationID = T_SampleStationID AND
|
||||
T_OrderSampleReqIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['id']} AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY T_SampleTypeID";
|
||||
//echo $sql;
|
||||
$rows_all_sample = $this->db_onedev->query($sql)->result();
|
||||
if($rows_all_sample){
|
||||
foreach($rows_all_sample as $k => $v){
|
||||
$sql = "INSERT INTO t_ordersample (
|
||||
T_OrderSampleT_OrderHeaderID,
|
||||
T_OrderSampleT_SampleTypeID,
|
||||
T_OrderSampleT_BarcodeLabID,
|
||||
T_OrderSampleCreated,
|
||||
T_OrderSampleUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['id']},
|
||||
{$v->T_SampleTypeID},
|
||||
{$v->T_BarcodeLabID},
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_OrderSampleSampling = 'Y',
|
||||
T_OrderSampleSamplingDate = CURDATE(),
|
||||
T_OrderSampleSamplingTime = CURTIME(),
|
||||
T_OrderSampleSamplingUserID = {$userid},
|
||||
T_OrderSampleIsActive = 'Y',
|
||||
T_OrderSampleUserID = {$userid}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] == 'samplingdone'){
|
||||
|
||||
$sql = "INSERT INTO t_ordersample (
|
||||
T_OrderSampleT_OrderHeaderID,
|
||||
T_OrderSampleT_SampleTypeID,
|
||||
T_OrderSampleT_BarcodeLabID,
|
||||
T_OrderSampleCreated,
|
||||
T_OrderSampleUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['sample']['T_OrderHeaderID']},
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
{$prm['sample']['T_BarcodeLabID']},
|
||||
NOW(),
|
||||
{$userid}
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
T_OrderSampleReceiveDate = CURDATE(),
|
||||
T_OrderSampleReceiveTime = CURTIME(),
|
||||
T_OrderSampleReceiveUserID = {$userid},
|
||||
T_OrderSampleReceive = 'Y',
|
||||
T_OrderSampleIsActive = 'Y',
|
||||
T_OrderSampleUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$sql = "SELECT * FROM t_ordersample
|
||||
WHERE T_OrderSampleT_BarcodeLabID = {$prm['sample']['T_BarcodeLabID']} AND T_OrderSampleIsActive = 'Y'
|
||||
ORDER BY T_OrderSampleID DESC LIMIT 1";
|
||||
$dt_sampleorder = $this->db_onedev->query($sql)->row();
|
||||
|
||||
$sql = "SELECT * FROM t_sampletype WHERE T_SampleTypeID = {$prm['sample']['T_SampleTypeID']}";
|
||||
$dt_sampletype = $this->db_onedev->query($sql)->row();
|
||||
//echo $dt_sampleorder->T_OrderSampleReceiveDate;
|
||||
//echo $dt_sampleorder->T_OrderSampleReceiveTime;
|
||||
$readytime = date('Y-m-d H:i:s',strtotime($dt_sampleorder->T_OrderSampleReceiveDate.' '.$dt_sampleorder->T_OrderSampleReceiveTime));
|
||||
//echo $readytime;
|
||||
if($dt_sampletype->T_SampleTypeAgingOnHold == 'Y'){
|
||||
$readytime = date('Y-m-d H:i:s',strtotime("+{$dt_sampletype->T_SampleTypeAgingOnHoldTime} minutes",strtotime($dt_sampleorder->T_OrderSampleReceiveDate.' '.$dt_sampleorder->T_OrderSampleReceiveTime)));
|
||||
//echo $readytime;
|
||||
}
|
||||
//echo $readytime;
|
||||
$sql = "UPDATE t_ordersample
|
||||
SET T_OrderSampleReadyToProcessDateTime = '{$readytime}'
|
||||
WHERE
|
||||
T_OrderSampleT_BarcodeLabID = {$prm['sample']['T_BarcodeLabID']} AND T_OrderSampleIsActive = 'Y' ";
|
||||
$this->db_onedev->query($sql);
|
||||
//echo $sql;
|
||||
$xreq = $prm['sample']['requirements'];
|
||||
$arr_requirements = array();
|
||||
foreach($xreq as $k=>$v){
|
||||
if($v['chex'] == 'Y')
|
||||
array_push($arr_requirements,$v['id']);
|
||||
}
|
||||
$requirements = '['.join(',',$arr_requirements).']';
|
||||
|
||||
$sql = "INSERT INTO t_ordersamplereq(
|
||||
T_OrderSampleReqT_OrderHeaderID,
|
||||
T_OrderSampleReqT_SampleStationID,
|
||||
T_OrderSampleReqT_OrderSampleID,
|
||||
T_OrderSampleReqNat_PositionID,
|
||||
T_OrderSampleReqStatus,
|
||||
T_OrderSampleReqs,
|
||||
T_OrderSampleReqUserID,
|
||||
T_OrderSampleReqCreated
|
||||
)
|
||||
VALUES(
|
||||
{$prm['sample']['T_OrderHeaderID']},
|
||||
{$prm['stationid']},
|
||||
{$prm['sample']['T_OrderSampleID']},
|
||||
{$prm['sample']['requirements'][0]['positionid']},
|
||||
'{$prm['sample']['requirement_status']}',
|
||||
'{$requirements}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)ON DUPLICATE KEY UPDATE
|
||||
T_OrderSampleReqStatus = '{$prm['sample']['requirement_status']}',
|
||||
T_OrderSampleReqs = '{$requirements}',
|
||||
T_OrderSampleReqUserID = {$userid}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$sql = "SELECT count(*) as xcount
|
||||
FROM (SELECT *
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID AND T_OrderDetailIsActive = 'Y'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderHeaderID AND T_BarcodeLabT_SampleTypeID = T_SampleTypeID
|
||||
JOIN t_bahan ON T_SampleTypeT_BahanID = T_BahanID
|
||||
JOIN t_samplestation ON T_BahanT_SampleStationID = T_SampleStationID AND T_SampleStationID = {$prm['stationid']}
|
||||
LEFT JOIN t_ordersample ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID AND
|
||||
T_OrderSampleT_SampleTypeID = T_SampleTypeID AND
|
||||
T_OrderSampleT_BarcodeLabID = T_BarcodeLabID AND
|
||||
T_OrderSampleIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['id']} AND T_OrderSampleT_SampleTypeID <> {$prm['sample']['T_SampleTypeID']} AND
|
||||
T_OrderSampleReceive = 'N' AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY T_BarcodeLabID ) xx";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->xcount;
|
||||
$rst_data = array('status'=>'PARTIAL');
|
||||
if($xcount == 0){
|
||||
$next_status = 5;
|
||||
$rst_data = array('status'=>'OK');
|
||||
}
|
||||
}
|
||||
|
||||
if($prm['act'] !== 'samplingprocess' && $status_call['status'] == 'OK'){
|
||||
$dt_json = json_encode(array('T_SampleStationID'=>$prm['stationid'],'T_OrderHeaderID'=>$prm['id'],'T_SamplingQueueStatusID'=>$next_status));
|
||||
$query = "INSERT INTO one_log.log_sampling_queue (Log_SamplingQueueDate,Log_SamplingQueueJSON,Log_SamplingQueueUserID)
|
||||
VALUES(NOW(),'{$dt_json}',{$userid})";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
$sql = "SELECT *
|
||||
FROM t_sampling_queue_last_status
|
||||
WHERE
|
||||
T_SamplingQueueLastStatusT_SampleStationID = {$prm['stationid']} AND
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID = {$prm['id']} AND
|
||||
T_SamplingQueueLastStatusIsActive = 'Y'";
|
||||
$data_last = $this->db_onedev->query($sql)->row();
|
||||
|
||||
$query = "INSERT INTO t_sampling_queue_last_status (
|
||||
T_SamplingQueueLastStatusT_SampleStationID,
|
||||
T_SamplingQueueLastStatusT_OrderHeaderID,
|
||||
T_SamplingQueueLastStatusT_SamplingQueueStatusID,
|
||||
T_SamplingQueueLastStatusUserID)
|
||||
VALUES(
|
||||
{$prm['stationid']},
|
||||
{$prm['id']},
|
||||
{$next_status},
|
||||
{$userid}) ON DUPLICATE KEY UPDATE T_SamplingQueueLastStatusT_SamplingQueueStatusID = {$next_status}";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($status_call['status'] == 'NOTCALL'){
|
||||
$rst_data = $status_call;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rst_data
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
function addnewlabel(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rst_data = array('status'=>'OK');
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$exp_barcode = explode(".",$prm["sample"]["T_BarcodeLabBarcode"]);
|
||||
$new_counter = intval($exp_barcode[2])+1;
|
||||
$new_label = $exp_barcode[0].".".$exp_barcode[1].".".$new_counter ;
|
||||
$sql = "INSERT INTO t_barcodelab (
|
||||
T_BarcodeLabT_OrderHeaderID ,
|
||||
T_BarcodeLabBarcode,
|
||||
T_BarcodeLabT_SampleTypeID,
|
||||
T_BarcodeLabUserID
|
||||
)
|
||||
VALUES(
|
||||
{$prm['sample']['T_OrderHeaderID']},
|
||||
'{$new_label}',
|
||||
{$prm['sample']['T_SampleTypeID']},
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rst_data
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdatanoterequirement(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rst_data = array();
|
||||
$prm = $this->sys_input;
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT 'fo registration' as position,GROUP_CONCAT(DISTINCT Nat_RequirementName separator ',') as requirements
|
||||
FROM t_orderheader
|
||||
JOIN t_orderreq ON T_OrderReqT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN nat_requirement ON json_contains(T_OrderReqs,Nat_RequirementID)
|
||||
WHERE T_OrderHeaderID = {$prm['T_OrderHeaderID']}
|
||||
GROUP BY T_OrderHeaderID";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql)->row_array();
|
||||
if($query){
|
||||
array_push($rst_data,$query);
|
||||
}
|
||||
|
||||
$sql = "SELECT 'fo verifikasi' as position, GROUP_CONCAT(DISTINCT Fo_VerificationsLabelName separator ',') as requirements
|
||||
FROM fo_verificationsvalue
|
||||
JOIN fo_verificationslabel ON Fo_VerificationsValueFo_VerificationsLabelID = Fo_VerificationsLabelID
|
||||
WHERE
|
||||
Fo_VerificationsValueCheck = 'N' AND
|
||||
Fo_VerificationsValueT_OrderHeaderID = {$prm['T_OrderHeaderID']}
|
||||
GROUP BY Fo_VerificationsValueT_OrderHeaderID
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql)->row_array();
|
||||
if($query){
|
||||
array_push($rst_data,$query);
|
||||
}
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rst_data
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenotesampling(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rst_data = array();
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE t_orderheader SET T_OrderHeaderSamplingNote = '{$prm['sampling_note']}' WHERE T_OrderHeaderID = {$prm['T_OrderHeaderID']}";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rst_data
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"php":"7.0.33-0ubuntu0.16.04.1","version":"2.14.2","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"Patient.php":3362798707}}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
class Bank extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Bank API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select Nat_BankID, Nat_BankName
|
||||
from nat_bank
|
||||
where Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => 0, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("BANK rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_account()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select M_BankAccountID, CONCAT(Nat_BankCode, ' no ', M_BankAccountNo) M_BankAccountNo
|
||||
from nat_bank
|
||||
JOIN m_bank_account ON M_BankAccountNat_BankID = Nat_BankID AND M_BankAccountIsActive = 'Y'
|
||||
where Nat_BankIsActive = 'Y'
|
||||
ORDER BY Nat_BankName";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => 0, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("BANK rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Company API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_mou(&$companies) {
|
||||
if (count($companies) == 0) {
|
||||
return;
|
||||
}
|
||||
$company_list= "-1";
|
||||
foreach($companies as $idx => $c) {
|
||||
$company_list .= ", " . $c["M_PatientTypeID"];
|
||||
if (! isset($companies[$idx]["mou"])) $companies[$idx]["mou"] = array();
|
||||
}
|
||||
$sql = "select *
|
||||
from
|
||||
m_moucompany
|
||||
where M_MouCompanyM_PatientTypeID in ( $company_list )
|
||||
and ( M_MouCompanyStartDate <= now() and M_MouCompanyEndDate >= now() )
|
||||
and M_MouCompanyIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows= $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$patientTypeID= $r["M_MouCompanyM_PatientTypeID"];
|
||||
foreach($companies as $idx => $c) {
|
||||
if($c["M_PatientTypeID"] == $patientTypeID) {
|
||||
$companies[$idx]["mou"][] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_moucompany mou",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now()) AND M_MouIsReleased = 'Y'
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$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, 'M_MouNote', M_MouNote, 'M_MouIsBill', M_MouIsBill, 'M_MouEmail', M_MouEmail, 'M_MouIsDefault', M_MouIsDefault, 'M_MouEmailIsDefault', M_MouEmailIsDefault, 'delivery_email_code', `fn_fo_delivery_code`('MOU', 'EMAIL', '0')) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now()) AND M_MouIsReleased = 'Y'
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName like ?
|
||||
group by m_companyid";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$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_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_default()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_MouID, M_MouM_CompanyID FROM m_mou
|
||||
JOIN m_company ON M_CompanyID = M_MouM_CompanyID ANd M_CompanyIsDefault = 'Y' ANd M_CompanyIsActive = 'Y'
|
||||
WHERE M_MouIsActive = 'Y' ANd M_MouIsDefault = 'Y' AND M_MouIsApproved = 'Y' AND M_MouIsReleased = 'Y'
|
||||
AND M_MouStartDate <= date(now()) AND M_MouEndDate >= date(now())";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
$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, 'M_MouNote', M_MouNote, 'M_MouIsBill', M_MouIsBill, 'M_MouEmail', M_MouEmail, 'M_MouIsDefault', M_MouIsDefault, 'M_MouEmailIsDefault', M_MouEmailIsDefault, 'delivery_email_code', `fn_fo_delivery_code`('MOU', 'EMAIL', '0')) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now()) AND M_MouIsReleased = 'Y'
|
||||
where M_CompanyID = ?
|
||||
group by m_companyid";
|
||||
$query = $this->db_smartone->query($sql, array($rows->M_MouM_CompanyID));
|
||||
$rows2 = $query->result_array();
|
||||
|
||||
foreach ($rows2 as $k => $v)
|
||||
$rows2[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => 1, "records" => $rows2, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("m_company rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$sql_param = array("%$search%");
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patienttype count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select M_PatientTypeID, M_PatientTypeName
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'
|
||||
limit 0,10";
|
||||
$query = $this->db_smartone->query($sql,$sql_param);
|
||||
$rows = $query->result_array();
|
||||
$this->_add_mou($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
class Delivery extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$q = [
|
||||
"patient_id" => 0,
|
||||
"doctor_id" => 0,
|
||||
"mou_id" => 0
|
||||
];
|
||||
|
||||
if (isset($prm['patient_id']))
|
||||
$q["patient_id"] = $prm['patient_id'];
|
||||
if (isset($prm['doctor_id']))
|
||||
$q["doctor_id"] = $prm['doctor_id'];
|
||||
if (isset($prm['mou_id']))
|
||||
$q["mou_id"] = $prm['mou_id'];
|
||||
|
||||
$sql = "CALL sp_fo_delivery_address('', '{$q['patient_id']}', '{$q['doctor_id']}', '{$q['mou_id']}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows= $query->row();
|
||||
$data = json_decode($rows->x);
|
||||
|
||||
$result = array("records" => $data);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("delivery address",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $rows = array();
|
||||
// $rows[] = array("id" =>1, "name" => "Ambil Sendiri", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>2, "name" => "Kirim ke dokter", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>3, "name" => "Kirim ke email pasien", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>4, "name" => "Kirim ke email dokter", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>5, "name" => "Kirim ke alamat utama pasien", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>6, "name" => "Kirim ke alamat utama dokter", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>7, "name" => "Kirim ke rekanan");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
class Doctor extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_address(&$doc) {
|
||||
if (count($doc) == "0") {
|
||||
return;
|
||||
}
|
||||
$doc_ids = "-1";
|
||||
foreach($doc as $idx => $d ) {
|
||||
$doc_ids .= "," . $d["M_DoctorID"];
|
||||
$doc[$idx]["address"] = array();
|
||||
}
|
||||
$sql = "select M_DoctorAddressID,M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressDesc
|
||||
from
|
||||
m_doctoraddress
|
||||
where
|
||||
M_DoctorAddressM_DoctorID in ( $doc_ids )
|
||||
and M_DoctorAddressIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$doctorID= $r["M_DoctorAddressM_DoctorID"];
|
||||
foreach($doc as $idx => $d) {
|
||||
if($d["M_DoctorID"] == $doctorID) {
|
||||
$doc[$idx]["address"][] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function search_pj() {
|
||||
//sipe : M_DoctorPjIsDefault diganti ke M_DoctorPjIsDefaultPJ
|
||||
$sql = "select M_DoctorID, fn_global_doctor_name(M_DoctorID) M_DoctorName, M_DoctorPjIsDefaultPj M_DoctorIsDefaultPJ
|
||||
from m_doctor
|
||||
join m_doctorpj on M_DoctorPJM_DoctorID = M_DoctorID and M_DoctorPjIsactive = 'Y'
|
||||
and M_DoctorPjIsPJ = 'Y'
|
||||
where M_DoctorIsActive = 'Y' and
|
||||
( M_DoctorPJID is not null ) ";
|
||||
$query = $this->db_smartone->query($sql, array("%$search%"));
|
||||
$rows = $query->result_array();
|
||||
$result = array("total" => count($rows) , "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_doctor
|
||||
where M_DoctorIsActive = 'Y'
|
||||
and M_DoctorName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_DoctorID, M_DoctorIsDefault, IF(M_DoctorPJID IS NULL, 'Y', 'N') M_DoctorIsPJ,
|
||||
fn_global_doctor_name(M_DoctorID) as M_DoctorName, fn_fo_delivery_code('DOCTOR', 'EMAIL', 0) as delivery_email_code,
|
||||
IF(M_DoctorEmail IS NULL OR M_DoctorEmail = '', 'N', M_DoctorEmailIsDefault) email_default,
|
||||
IFNULL( concat('[', group_concat(JSON_OBJECT('M_DoctorAddressDescription', M_DoctorAddressDescription, 'M_DoctorAddressID', M_DoctorAddressID, 'delivery_default', M_DoctorAddressDeliveryDefault, 'delivery_code', fn_fo_delivery_code('DOCTOR', 'ADDRESS', M_DoctorAddressID)) SEPARATOR ','), ']'), '[]') as address,
|
||||
M_DoctorNote
|
||||
from m_doctor
|
||||
left join m_doctoraddress on M_DoctorAddressIsActive = 'Y'
|
||||
and M_DoctorAddressM_DoctorID = M_DoctorID
|
||||
left join m_doctorpj on M_DoctorPJM_DoctorID = M_DoctorID and M_DoctorPjIsactive = 'Y'
|
||||
where M_DoctorIsActive = 'Y'
|
||||
and concat(IFNULL(M_DoctorPrefix, ''),' ',M_DoctorName, ' ', IFNULL(M_DoctorSufix, '')) like ?
|
||||
group by M_DoctorID
|
||||
limit 100";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['address'] = json_decode($v['address']);
|
||||
|
||||
$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_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_doctor
|
||||
join (
|
||||
select distinct M_DoctorAddressM_DoctorID
|
||||
from m_doctoraddress
|
||||
where M_DoctorAddressIsActive = 'Y'
|
||||
) ma on M_DoctorID = M_DoctorAddressM_DoctorID
|
||||
where M_DoctorIsActive = 'Y' and M_DoctorName like ? ";
|
||||
$query = $this->db_smartone->query($sql, array("%$search%"));
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select M_DoctorID,M_DoctorName
|
||||
from
|
||||
m_doctor
|
||||
join (
|
||||
select distinct M_DoctorAddressM_DoctorID
|
||||
from m_doctoraddress
|
||||
where M_DoctorAddressIsActive = 'Y'
|
||||
) ma on M_DoctorID = M_DoctorAddressM_DoctorID
|
||||
where M_DoctorIsActive = 'Y' and M_DoctorName like ?
|
||||
limit 0,10";
|
||||
$query = $this->db_smartone->query($sql, array("%$search%"));
|
||||
$rows = $query->result_array();
|
||||
$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$prm = $prm['data'];
|
||||
|
||||
$q = [
|
||||
'name' => isset($prm['name']) ? $prm['name'] : '',
|
||||
'prefix1' => isset($prm['prefix1']) ? $prm['prefix1'] : '',
|
||||
'prefix2' => isset($prm['prefix2']) ? $prm['prefix2'] : '',
|
||||
'sufix1' => isset($prm['sufix1']) ? $prm['sufix1'] : '',
|
||||
'sufix2' => isset($prm['sufix2']) ? $prm['sufix2'] : '',
|
||||
'sufix3' => isset($prm['sufix3']) ? $prm['sufix3'] : '',
|
||||
'sex' => isset($prm['sex']) ? $prm['sex'] : '0',
|
||||
'hp' => isset($prm['hp']) ? $prm['hp'] : '',
|
||||
'note' => isset($prm['note']) ? $prm['note'] : '',
|
||||
'address' => isset($prm['address']) ? $prm['address'] : '',
|
||||
'province' => isset($prm['province']) ? $prm['province'] : '',
|
||||
'city' => isset($prm['city']) ? $prm['city'] : '',
|
||||
'district' => isset($prm['district']) ? $prm['district'] : '',
|
||||
'village' => isset($prm['village']) ? $prm['village'] : ''
|
||||
];
|
||||
|
||||
$sql = "INSERT INTO m_doctor(M_DoctorPrefix,
|
||||
M_DoctorPrefix2,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorSufix2,
|
||||
M_DoctorSufix3,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorHP,
|
||||
M_DoctorNote)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$q['prefix1'], $q['prefix2'], $q['name'], $q['sufix1'], $q['sufix2'], $q['sufix3'], $q['sex'], $q['hp'], $q['note']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$id = $this->db_smartone->insert_id();
|
||||
|
||||
$sql = "INSERT INTO m_doctoraddress(M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressNote,
|
||||
M_DoctorAddressDescription,
|
||||
M_DoctorAddressM_KelurahanID)
|
||||
VALUES(?, 'Utama', ?, ?)";
|
||||
$query = $this->db_smartone->query($sql, [$id, $q['address'], $q['village']]);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$result = $this->get_one($id);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sys_error_db("DOCTOR SAVE", $this->db_smartone);
|
||||
}
|
||||
|
||||
private function get_one($id)
|
||||
{
|
||||
$sql = "SELECT M_DoctorID, M_DoctorIsDefault, 'N' M_DoctorIsPJ,
|
||||
fn_global_doctor_name(M_DoctorID) as M_DoctorName, M_DoctorName M_DoctorRealName,
|
||||
IFNULL( concat('[', group_concat(JSON_OBJECT('M_DoctorAddressDescription', M_DoctorAddressDescription, 'M_DoctorAddressID', M_DoctorAddressID) SEPARATOR ','), ']'), '[]') as address
|
||||
FROM m_doctor
|
||||
LEFT JOIN m_doctoraddress ON M_DoctorAddressM_DoctorID = M_DoctorID AND M_DoctorAddressIsActive = 'Y'
|
||||
WHERE M_DoctorID = ?";
|
||||
$query = $this->db_smartone->query($sql, $id);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$row = $query->result_array();
|
||||
foreach ($row as $k => $v)
|
||||
$row[$k]['address'] = json_decode($v['address']);
|
||||
|
||||
$result = array("total" => 1, "records" => $row, "total_display" => 1);
|
||||
return $result;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
class History extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "History API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT T_OrderHeaderID, T_OrderHeaderDate, T_OrderHeaderLabNumber,
|
||||
GROUP_CONCAT(T_OrderDetailT_TestName SEPARATOR ', ') T_TestName
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
AND T_OrderDetailIsActive = 'Y'
|
||||
AND T_OrderDetailT_TestIsPrice = 'Y'
|
||||
WHERE T_OrderHeaderM_PatientID = ?
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
GROUP BY T_OrderHeaderID
|
||||
ORDER BY T_OrderHeaderDate DESC
|
||||
LIMIT 5";
|
||||
$query = $this->db_onedev->query($sql, [$prm['patient_id']]);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Patient History count", $this->db_onedev);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
class Language extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_lang
|
||||
where M_LangIsActive = 'Y'
|
||||
and M_LangName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_lang count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_LangID as id, M_LangName as name
|
||||
from m_lang
|
||||
where M_LangIsActive = 'Y'
|
||||
and M_LangName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows_ = [];
|
||||
$si = [["is_si" => "N", "si_text" => ""], ["is_si" => "Y", "si_text" => "(SI)"]];
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
foreach ($si as $l => $w)
|
||||
{
|
||||
$v['is_si'] = $w['is_si'];
|
||||
$v['name'] .= $w['si_text'] == '' ? '' : ' ' . $w['si_text'];
|
||||
$v['key'] = $v['id'] . '-' . $v['is_si'];
|
||||
$rows_[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$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_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$rows = array();
|
||||
$rows[] = array("id" =>"ID", "name" => "Bahasa Indonesia");
|
||||
$rows[] = array("id" =>"EN", "name" => "Bahasa Inggris");
|
||||
$rows[] = array("id" =>"CH", "name" => "Bahasa Mandarin");
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
117
one-api/application/controllers/mockup/fo/registration/Order.php
Normal file
117
one-api/application/controllers/mockup/fo/registration/Order.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
class Order extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "ORDER API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$hdr = $prm['header'];
|
||||
$header_json = addslashes(str_replace('\n', '\\\n', json_encode($hdr)));
|
||||
$detail_json = str_replace('\n', '\\\n', json_encode($prm['detail']));
|
||||
$delivery_json = addslashes(str_replace('\n', '\\\n', json_encode($prm['delivery'])));
|
||||
|
||||
$req_json = json_encode($prm['req']);
|
||||
|
||||
$sql = "CALL sp_fo_register_save('{$prm['order_id']}', '{$header_json}', '{$delivery_json}', '{$detail_json}', '{$req_json}', '{$this->sys_user['M_UserID']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
$x = preg_match("/janji hasi/", $rst->message);
|
||||
if ($x)
|
||||
$rst->message = "Masih ada pemeriksaan yang BELUM DISET JANJI HASILNYA !";
|
||||
$rst->message = ["text"=>$rst->message, "query"=>$this->db_smartone->last_query()];
|
||||
// pe : add broadcast notification
|
||||
$this->broadcast("fo-register");
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function load_from_clinic()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_fo_clinic_load('{$prm['queue']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
if ($rst->status == "OK")
|
||||
{
|
||||
$rst->data = json_decode($rst->data);
|
||||
|
||||
$rst->data->doctor->address = $rst->data->doctor_address;
|
||||
unset($rst->data->doctor_address);
|
||||
|
||||
$rst->data->company->mou = [$rst->data->mou];
|
||||
unset($rst->data->mou);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error("Tidak ada order");
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function load()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_fo_register_load('{$prm['id']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
if ($rst->status == "OK")
|
||||
{
|
||||
$rst->data = json_decode($rst->data);
|
||||
|
||||
$rst->data->doctor->address = $rst->data->doctor_address;
|
||||
unset($rst->data->doctor_address);
|
||||
|
||||
$rst->data->company->mou = [$rst->data->mou];
|
||||
unset($rst->data->mou);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error("Tidak ada order");
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
<?php
|
||||
/*
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_address(&$pat) {
|
||||
if (count($pat) == "0") {
|
||||
return array();
|
||||
}
|
||||
foreach($pat as $idx => $p ) {
|
||||
$pat[$idx]["address"] = array($p["M_PatientAddress"]);
|
||||
}
|
||||
$this->_add_history($pat);
|
||||
}
|
||||
function _add_history(&$pat) {
|
||||
$pat_list = "-1";
|
||||
foreach($pat as $idx => $p) {
|
||||
$pat_list .= ", " . $p["M_PatientID"];
|
||||
if (! isset($pat[$idx]["history"])) $pat[$idx]["history"] = array();
|
||||
}
|
||||
$sql = "select T_OrderHeaderM_PatientID,T_OrderHeaderLabNumber,T_OrderHeaderDate,
|
||||
concat(T_OrderDetailT_TestName) T_TestName
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderdetail on
|
||||
T_OrderHeaderID = T_OrderDetailID and
|
||||
T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderM_PatientID in ( $pat_list )
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
order by T_OrderHeaderM_PatientID,T_OrderHeaderLabNumber";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows= $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$patientID = $r["T_OrderHeaderM_PatientID"];
|
||||
foreach($pat as $idx => $p) {
|
||||
if($p["M_PatientID"] == $patientID) {
|
||||
$pat[$idx]["history"][] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_patient history",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'noreg' => '%',
|
||||
'name' => '%',
|
||||
'hp' => '%',
|
||||
'dob' => '%',
|
||||
'address' => '%'
|
||||
];
|
||||
|
||||
if ($prm['noreg'] != '')
|
||||
$q['noreg'] = "%{$prm['noreg']}%";
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$e = explode('+', $prm['search']);
|
||||
if (isset($e[0]))
|
||||
$q['name'] = "%{$e[0]}%";
|
||||
if (isset($e[1]))
|
||||
$q['hp'] = "%{$e[1]}%";
|
||||
if (isset($e[2]))
|
||||
$q['dob'] = "%{$e[2]}%";
|
||||
if (isset($e[3]))
|
||||
$q['address'] = "%{$e[3]}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct m_patientid) total
|
||||
from
|
||||
m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID and M_PatientAddressIsActive = 'Y'
|
||||
where M_PatientNoReg like ?
|
||||
and M_PatientName LIKE ?
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and ((DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL)
|
||||
and M_PatientAddressDescription LIKE ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['noreg'], $q['name'], $q['hp'], $q['dob'], $q['address']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
M_PatientName M_PatientRealName, M_TitleID, M_TitleName, M_SexID, M_SexName,
|
||||
M_PatientHP, M_PatientPOB, M_PatientDOB, M_PatientNote,
|
||||
concat(M_PatientAddressDescription, '\n\n', m_kelurahanname, ', ', m_districtname,
|
||||
'\n', m_cityname, ', ', m_provincename) as M_PatientAddress,
|
||||
M_PatientAddressDescription, M_PatientM_IdTypeID, M_PatientIDNumber,
|
||||
IFNULL(M_PatientNote, '') M_PatientNote, M_PatientPhoto, IF(M_PatientPhone IS NULL OR M_PatientPhone = '', M_PatientHP, M_PatientPhone) hp,
|
||||
fn_fo_patient_visit(M_PatientID) info,
|
||||
M_KelurahanID, M_DistrictID, M_CityID, M_ProvinceID, M_PatientM_ReligionID,
|
||||
IFNULL(M_ReligionName, '-') M_ReligionName
|
||||
from
|
||||
m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
join m_sex on M_PatientM_SexID = M_SexID
|
||||
join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID and M_PatientAddressIsActive = 'Y'
|
||||
left join m_kelurahan on m_patientaddressm_kelurahanid = m_kelurahanid
|
||||
left join m_district on m_kelurahanm_districtid = m_districtid
|
||||
left join m_city on m_districtm_cityid = m_cityid
|
||||
left join m_province on m_citym_provinceid = m_provinceid
|
||||
left join m_religion on m_patientm_religionid = m_religionid
|
||||
where M_PatientNoReg like ?
|
||||
and M_PatientName LIKE ?
|
||||
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and ((DATE_FORMAT(M_PatientDOB, '%d-%m-%Y') LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL)
|
||||
and M_PatientAddressDescription LIKE ?
|
||||
group by m_patientid
|
||||
limit 0,{$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['noreg'], $q['name'], $q['hp'], $q['dob'], $q['address']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['info'] = json_decode($v['info']);
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function add_new()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['M_PatientDOB'] = date('Y-m-d', strtotime($prm['M_PatientDOB']));
|
||||
|
||||
//sipe
|
||||
$M_IdTypeID = 0;
|
||||
if( $prm['M_PatientM_IdTypeID'] > 0 ) {
|
||||
$M_IdTypeID = $prm['M_PatientM_IdTypeID'];
|
||||
}
|
||||
$ptn = [
|
||||
'M_PatientName' => $prm['M_PatientName'],
|
||||
'M_PatientM_TitleID' => $prm['M_PatientM_TitleID'],
|
||||
'M_PatientSuffix' => $prm['M_PatientSuffix'],
|
||||
'M_PatientM_SexID' => $prm['M_PatientM_SexID'],
|
||||
'M_PatientM_ReligionID' => $prm['M_PatientM_ReligionID'],
|
||||
'M_PatientDOB' => $prm['M_PatientDOB'],
|
||||
'M_PatientPOB' => $prm['M_PatientPOB'],
|
||||
'M_PatientHP' => $prm['M_PatientHP'],
|
||||
'M_PatientPhone' => $prm['M_PatientPhone'],
|
||||
'M_PatientEmail' => $prm['M_PatientEmail'],
|
||||
'M_PatientM_IdTypeID' => $M_IdTypeID ,
|
||||
'M_PatientIDNumber' => $prm['M_PatientIDNumber'],
|
||||
'M_PatientNote' => $prm['M_PatientNote']
|
||||
];
|
||||
$this->db_smartone->insert('m_patient', $ptn);
|
||||
|
||||
$err = $this->db_smartone->error();
|
||||
if ( $err['message'] != "" )
|
||||
{
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $this->db_smartone->insert_id();
|
||||
|
||||
// LOG FO
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADD', '{$ptn}', '0')");
|
||||
|
||||
// save address
|
||||
$add = [
|
||||
'M_PatientAddressM_PatientID' => $id,
|
||||
'M_PatientAddressDescription' => $prm['M_PatientAddressDescription'],
|
||||
'M_PatientAddressM_KelurahanID' => $prm['M_PatientAddressM_KelurahanID']
|
||||
];
|
||||
$this->db_smartone->insert('m_patientaddress', $add);
|
||||
|
||||
// LOG FO
|
||||
$add = json_encode($add);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADDRESS.ADD', '{$add}', '0')");
|
||||
|
||||
// get
|
||||
$r = $this->db_smartone->where('M_PatientID', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
$rst = array("id" => $id, 'noreg'=>$r->M_PatientNoReg);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
|
||||
function edit()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['M_PatientDOB'] = date('Y-m-d', strtotime($prm['M_PatientDOB']));
|
||||
|
||||
$this->db_smartone->set('M_PatientName', $prm['M_PatientName'])
|
||||
->set('M_PatientM_TitleID', $prm['M_PatientM_TitleID'])
|
||||
->set('M_PatientSuffix', $prm['M_PatientSuffix'])
|
||||
->set('M_PatientM_SexID', $prm['M_PatientM_SexID'])
|
||||
->set('M_PatientM_ReligionID', $prm['M_PatientM_ReligionID'])
|
||||
->set('M_PatientDOB', $prm['M_PatientDOB'])
|
||||
->set('M_PatientPOB', $prm['M_PatientPOB'])
|
||||
->set('M_PatientHP', $prm['M_PatientHP'])
|
||||
->set('M_PatientPhone', $prm['M_PatientPhone'])
|
||||
->set('M_PatientEmail', $prm['M_PatientEmail'])
|
||||
->set('M_PatientM_IdTypeID', $prm['M_PatientM_IdTypeID'])
|
||||
->set('M_PatientIDNumber', $prm['M_PatientIDNumber'])
|
||||
->set('M_PatientNote', $prm['M_PatientNote'])
|
||||
->where('M_PatientID', $prm['id'])
|
||||
->update('m_patient');
|
||||
|
||||
$err = $this->db_smartone->error();
|
||||
if ( $err['message'] != "" )
|
||||
{
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $prm['id'];
|
||||
|
||||
// LOG FO
|
||||
unset($prm['token']);
|
||||
$ptn = json_encode($prm);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.EDIT', '{$ptn}', '{$this->sys_user['M_UserID']}')");
|
||||
|
||||
// save address
|
||||
// $add = [
|
||||
// 'M_PatientAddressM_PatientID' => $id,
|
||||
// 'M_PatientAddressDescription' => $prm['M_PatientAddressDescription'],
|
||||
// 'M_PatientAddressM_KelurahanID' => $prm['M_PatientAddressM_KelurahanID']
|
||||
// ];
|
||||
$this->db_smartone->set('M_PatientAddressM_KelurahanID', $prm['M_PatientAddressM_KelurahanID'])
|
||||
->set('M_PatientAddressDescription', $prm['M_PatientAddressDescription'])
|
||||
->where('M_PatientAddressM_PatientID', $id)
|
||||
->where('M_PatientAddressNote', 'Utama')
|
||||
->where('M_PatientAddressIsactive', 'Y')
|
||||
->update('m_patientaddress');
|
||||
|
||||
// LOG FO
|
||||
$add = $this->db_smartone->last_query();
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADDRESS.EDIT', '{$add}', '0')");
|
||||
|
||||
// get
|
||||
$r = $this->db_smartone->where('M_PatientID', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
$rst = array("id" => $id, 'noreg'=>$r->M_PatientNoReg);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
|
||||
public function search_idtype()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_IdTypeID, M_IdTypeName
|
||||
FROM m_idtype
|
||||
WHERE M_IdTypeIsActive = 'Y'
|
||||
ORDER BY M_IdTypeName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_idtype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Patientaddress extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function get_all()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select M_PatientAddressID, M_PatientAddressNote,
|
||||
M_PatientAddressDescription, M_KelurahanName as M_KelurahanName
|
||||
from m_patientaddress
|
||||
left join m_kelurahan on m_patientaddressm_kelurahanid = m_kelurahanid
|
||||
where m_patientaddressm_patientid = ?";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['patient_id']));
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("status" => "OK", "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function get_order() {
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$rst = ["order_header"=>[], "order_detail"=>[], "order_delivery"=>[]];
|
||||
|
||||
$sql = "
|
||||
select T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumber as order_no,
|
||||
T_OrderHeaderDate as order_date,
|
||||
T_OrderHeaderSubTotal as order_subtotal,
|
||||
T_OrderHeaderRounding as order_rounding,
|
||||
T_OrderHeaderTotal as order_total,
|
||||
concat(if(M_TitleID is null, '', concat(M_TitleName, ' ')), M_PatientName) as patient_name,
|
||||
M_PatientNoReg as patient_mr,
|
||||
M_MouName as order_mou,
|
||||
M_CompanyName as order_company,
|
||||
fn_global_doctor_name(da.M_DoctorID) doctor_sender,
|
||||
fn_global_doctor_name(db.M_DoctorID) doctor_pj,
|
||||
fn_global_doctor_address(aa.M_DoctorAddressID, 1) doctor_sender_address,
|
||||
M_MouIsBill M_CompanyIsBill, M_MouMinDP M_CompanyMinDP,
|
||||
M_MouIsAgingOnHold M_CompanyIsAgingOnHold, M_MouIsAgingOnHoldNote M_CompanyIsAgingOnHoldNote
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join m_doctor da on T_OrderHeaderSenderM_DoctorID = da.M_DoctorID
|
||||
join m_doctoraddress aa on T_OrderHeaderSenderM_DoctorAddressID = aa.M_DoctorAddressID
|
||||
join m_doctor db on T_OrderHeaderSenderM_DoctorID = db.M_DoctorID
|
||||
left join m_title on m_patientm_titleid = m_titleid
|
||||
where T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = (array) $query->row();
|
||||
$rst['order_header'] = $rows;
|
||||
// $result = array("status" => "OK" , "data" => $rst);
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "CALL sp_fo_payment_get_delivery('{$prm['id']}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row();
|
||||
$rst['order_delivery'] = json_decode($rows->delivery);
|
||||
// $result = array("status" => "OK" , "data" => $rst);
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress delivery ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// { n:1, d_id:1, t_id:1, t_name:'SGOT', t_price:80000, t_disctotal:7000, t_total:73000 },
|
||||
// { n:2, d_id:2, t_id:2, t_name:'SGPT', t_price:75000, t_disctotal:8000, t_total:67000 }
|
||||
// T_OrderDetailPrice double [0]
|
||||
// T_OrderDetailPriceForDisc double [0]
|
||||
// T_OrderDetailDisc double [0]
|
||||
// T_OrderDetailDiscAmount double [0]
|
||||
// T_OrderDetailTotal
|
||||
|
||||
$sql = "
|
||||
select T_OrderDetailID as d_id,
|
||||
T_OrderDetailT_TestID as t_id,
|
||||
IFNULL(T_OrderDetailT_TestName, T_PacketName) as t_name,
|
||||
T_OrderDetailPrice as t_price,
|
||||
T_OrderDetailDiscTotal as t_disctotal,
|
||||
T_OrderDetailTotal as t_total
|
||||
from t_orderdetail
|
||||
join t_orderdetailaddon on T_OrderDetailAddOnT_OrderDetailID = T_OrderDetailID
|
||||
left join t_test on t_orderdetailt_testid = t_testid
|
||||
left join t_packet on t_orderdetailaddonispacket = 'Y' and t_orderdetailaddont_packetid = t_packetid
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_ORderDetailIsActive = 'Y'
|
||||
and ((T_ORderDetailAddOnIsPacket = 'N' AND T_TestIsPrintNota = 'Y' AND T_OrderDetailT_TestIsPanelChildren = 'N')
|
||||
OR (T_OrderDetailT_TestIsPanelChildren = 'Y' AND T_OrderDetailT_TestIsPanelChildrenPrintNota = 'Y')
|
||||
OR (T_ORderDetailAddOnIsPacket = 'Y' AND T_PacketIsNOta = 'Y'))";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rst['order_detail'] = $rows;
|
||||
|
||||
$result = array("status" => "OK" , "data" => $rst);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 100;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_paymenttype count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_PaymentTypeID payment_type_id, M_PaymentTypeName payment_type_name, M_PaymentTypeCode payment_type_code,
|
||||
0 payment_amount, '' payment_note, 'Nomor Kartu' payment_note_label, 'N' payment_enable,
|
||||
0 payment_change, 0 payment_actual, 0 payment_card_id, 0 payment_edc_id, 0 payment_account_id
|
||||
from m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v) {
|
||||
|
||||
if ($v['payment_type_code'] == 'CASH')
|
||||
$v['payment_note_label'] = 'Kembali';
|
||||
if ($v['payment_type_code'] == 'VOUCHER')
|
||||
$v['payment_note_label'] = 'Nomor Voucher';
|
||||
|
||||
$rows[$k] = $v;
|
||||
}
|
||||
|
||||
$result = $rows;
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_paymenttype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$payment_json = json_encode($prm['payments']);
|
||||
|
||||
$sql = "CALL sp_fo_payment('{$prm['order_id']}', '{$payment_json}', '{$this->sys_user['M_UserID']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save payment", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_bank()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT Nat_BankID, Nat_BankName
|
||||
FROM nat_bank ORDER BY Nat_BankName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows, "total"=>sizeof($rows)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("NAT BANK",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
143
one-api/application/controllers/mockup/fo/registration/Photo.php
Normal file
143
one-api/application/controllers/mockup/fo/registration/Photo.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Photo extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Photo API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->load->library('ImageManipulator');
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
|
||||
$home_dir = "/home/one/project/one/";
|
||||
$target_dir = $home_dir . "one-media/one-photo/patient/" . date("Y") . "/";
|
||||
$y = $this->regenerateOldPhoto($home_dir, $inp['id']);
|
||||
|
||||
// get patient mr
|
||||
$p = $this->db_smartone->select("M_PatientNoReg")
|
||||
->where("M_PatientID", $inp['id'])
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
if (!file_exists($target_dir)) {
|
||||
mkdir($target_dir, 0755, true);
|
||||
}
|
||||
|
||||
$target_path = $target_dir . $p->M_PatientNoReg . ".jpg";
|
||||
$this->base64_to_jpeg($inp['data'], $target_path);
|
||||
|
||||
// CROP Image
|
||||
$im = new ImageManipulator($target_path);
|
||||
$w = $im->getWidth();
|
||||
$h = $im->getHeight();
|
||||
|
||||
$mw = ceil(3 * $h / 4);
|
||||
if ($w <= $mw)
|
||||
{
|
||||
$x1 = 0;
|
||||
$y1 = 0;
|
||||
$x2 = $w;
|
||||
$y2 = $h;
|
||||
}
|
||||
else
|
||||
{
|
||||
$x1 = floor(($w - $mw) / 2);
|
||||
$y1 = 0;
|
||||
$x2 = ceil($w - (($w - $mw) / 2));
|
||||
$y2 = $h;
|
||||
}
|
||||
|
||||
$im->crop($x1, $y1, $x2, $y2); // takes care of out of boundary conditions automatically
|
||||
$im->save($target_path);
|
||||
|
||||
$x = $this->generateThumbnail($target_path, 75, 100);
|
||||
|
||||
// Save to DB
|
||||
$this->db_smartone->set("M_PatientPhoto", "/" . str_replace($home_dir, "", $target_path))
|
||||
->set("M_PatientPhotoThumb", "/" . str_replace($home_dir, "", $x))
|
||||
->set('M_PatientPhotoCounter', '`M_PatientPhotoCounter` + 1', false)
|
||||
->where('M_PatientID', $inp['id'])
|
||||
->update('m_patient');
|
||||
|
||||
// LOGGING
|
||||
$code = $y ? "PHOTO.PATIENT.EDIT" : "PHOTO.PATIENT.ADD";
|
||||
$one_log = $this->load->database('onelog', true);
|
||||
$one_log->set('Log_PhotoCode', $code)
|
||||
->set('Log_PhotoM_PatientID', $inp['id'])
|
||||
->set('Log_PhotoUrl', $y ? $y : "/" . str_replace($home_dir, "", $target_path))
|
||||
->insert('log_photo');
|
||||
|
||||
$this->sys_ok(["rename"=>$y, "patient_id"=>$inp['id'], "patient_mr"=>$p->M_PatientNoReg, "photo_url"=>"http://" . $_SERVER['SERVER_NAME'] . "/" . str_replace($home_dir, "", $target_path) . "?d=" . date("YmdHis")]);
|
||||
}
|
||||
|
||||
function base64_to_jpeg($base64_string, $output_file) {
|
||||
// open the output file for writing
|
||||
$ifp = fopen( $output_file, 'wb' );
|
||||
|
||||
// split the string on commas
|
||||
// $data[ 0 ] == "data:image/png;base64"
|
||||
// $data[ 1 ] == <actual base64 string>
|
||||
$data = explode( ',', $base64_string );
|
||||
|
||||
// we could add validation here with ensuring count( $data ) > 1
|
||||
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
|
||||
|
||||
// clean up the file resource
|
||||
fclose( $ifp );
|
||||
|
||||
return $output_file;
|
||||
}
|
||||
|
||||
function generateThumbnail($img, $width, $height, $quality = 90)
|
||||
{
|
||||
if (is_file($img)) {
|
||||
$imagick = new Imagick(realpath($img));
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->thumbnailImage($width, $height, false, false);
|
||||
$filename_no_ext = reset(explode('.', $img));
|
||||
if (file_put_contents($filename_no_ext . '_thumb' . '.jpg', $imagick) === false) {
|
||||
throw new Exception("Could not put contents.");
|
||||
}
|
||||
return $filename_no_ext . '_thumb' . '.jpg';
|
||||
}
|
||||
else {
|
||||
throw new Exception("No valid image provided with {$img}.");
|
||||
}
|
||||
}
|
||||
|
||||
function regenerateOldPhoto($home_dir, $id)
|
||||
{
|
||||
$r = $this->db_smartone->select('m_patientphoto, m_patientphotocounter', false)
|
||||
->where('m_patientid', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
if ($r->m_patientphoto != null && $r->m_patientphotocounter > 0) {
|
||||
$full_path = substr_replace($home_dir ,"", -1) . $r->m_patientphoto;
|
||||
$path_parts = pathinfo($full_path);
|
||||
|
||||
$rename = $path_parts['dirname'] . '/' . $path_parts['filename'] . '-' . $r->m_patientphotocounter . '.' . $path_parts['extension'];
|
||||
rename($full_path, $rename);
|
||||
// echo $path_parts['dirname'], "\n";
|
||||
// echo $path_parts['extension'], "\n";
|
||||
// echo $path_parts['filename'], "\n";
|
||||
|
||||
return "/" . str_replace($home_dir, "", $rename);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
421
one-api/application/controllers/mockup/fo/registration/Px.php
Normal file
421
one-api/application/controllers/mockup/fo/registration/Px.php
Normal file
@@ -0,0 +1,421 @@
|
||||
<?php
|
||||
//diberi tambahan pembeda IsFromPanel
|
||||
//utk contoh kasus yg ndak bisa di delete
|
||||
//sementara profile di ambilkan dari panel juga dengan IsFromPanel = N
|
||||
class Px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Px API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_ref_test(&$rows) {
|
||||
$ids = "-1";
|
||||
foreach($rows as $idx => $r) {
|
||||
$ids .= "," . $r["T_TestID"];
|
||||
if (! $rows[$idx]["ref_test"] ) $rows[$idx]["ref_test"] == array();
|
||||
}
|
||||
$sql="select T_TestID,T_RefTestName, T_TestName
|
||||
from
|
||||
t_reftest
|
||||
join t_test on T_RefTestID = T_TestT_RefTestID
|
||||
and T_RefTestIsActive = 'Y'
|
||||
where T_TestID in ( $ids )";
|
||||
|
||||
|
||||
}
|
||||
public function profile()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mou_id = $prm["mou_id"];
|
||||
$max_rst = 8;
|
||||
|
||||
$sql_param = array("%$search%");
|
||||
$sql = "select count(distinct T_ProfileID) total
|
||||
from t_profile
|
||||
join t_profiledetail on t_profileid = t_profiledetailt_profileid
|
||||
and t_profiledetailisactive = 'Y'
|
||||
where t_profilename like ?";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->row()->total;
|
||||
} else {
|
||||
$this->sys_error_db("Test Profile count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_ProfileID, T_ProfileName, CONCAT('[', GROUP_CONCAT( JSON_OBJECT('T_TestID', T_TestID, 'T_TestName', T_TestName, 'T_TestRequirement', T_TestRequirement) SEPARATOR ','), ']') detail
|
||||
from t_profile
|
||||
join t_profiledetail on t_profileid = t_profiledetailt_profileid
|
||||
and t_profiledetailisactive = 'Y'
|
||||
join t_test on t_profiledetailt_testid = t_testid
|
||||
where t_profilename like ?
|
||||
group by t_profileid
|
||||
limit 0, $max_rst";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $r)
|
||||
{
|
||||
$err = 0;
|
||||
$detail = json_decode($r['detail']);
|
||||
foreach ($detail as $l => $w)
|
||||
{
|
||||
$sql_param = array($w->T_TestID, date('Y-m-d'), 'N', $mou_id);
|
||||
$sql = "select fn_price(?, ?, ?, ?) as price";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$price = json_decode($query->row()->price);
|
||||
|
||||
$detail[$l]->T_PriceAmount = $price->test_price;
|
||||
$detail[$l]->T_PriceDisc = $price->test_disc;
|
||||
$detail[$l]->T_PriceDiscRp = $price->test_discrp;
|
||||
$detail[$l]->T_PriceID = $price->price_id;
|
||||
$detail[$l]->T_PriceIsCito = "N";
|
||||
$detail[$l]->T_PriceM_CompanyID = $price->company_id;
|
||||
$detail[$l]->T_PriceM_MouID = $price->mou_id;
|
||||
$detail[$l]->T_PriceOther = $price->test_other;
|
||||
$detail[$l]->T_PriceSubTotal = $price->test_subtotal;
|
||||
$detail[$l]->T_PriceT_TestID = $price->test_id;
|
||||
$detail[$l]->T_PriceTotal = $price->test_total;
|
||||
|
||||
if ($price->test_price == 0)
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
|
||||
$rows[$k]['detail'] = $detail;
|
||||
$rows[$k]['err'] = $err;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function panel() {
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
$sql = "select count(distinct T_TestPanelID) total
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ? ";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_testpanel count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ?
|
||||
limit 0,20";
|
||||
$query = $this->db_smartone->query($sql,$sql_param);
|
||||
$xrows = $query->result_array();
|
||||
$a_tpid = "-1";
|
||||
foreach($xrows as $r) {
|
||||
$a_tpid .= "," . $r["T_TestPanelID"];
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID,T_TestPanelName,
|
||||
T_TestID,T_TestName, 'Y' IsFromPanel,T_TestRequirement,
|
||||
t_testprice.*
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
where
|
||||
T_TestPanelID in ( $a_tpid )
|
||||
order by T_TestPanelID";
|
||||
$query = $this->db_smartone->query($sql,array($mouCompanyID));
|
||||
$xrows = $query->result_array();
|
||||
$rows = array();
|
||||
$prev_tpanel_id = 0;
|
||||
foreach($xrows as $r) {
|
||||
$tpanel_id = $r["T_TestPanelID"];
|
||||
if ($tpanel_id != $prev_tpanel_id) {
|
||||
$rows[] = array(
|
||||
"T_TestPanelID" => $r["T_TestPanelID"],
|
||||
"T_TestPanelName" => $r["T_TestPanelName"],
|
||||
"test" => array()
|
||||
);
|
||||
}
|
||||
$idx = count($rows) - 1;
|
||||
$rows[$idx]["test"][] = $r;
|
||||
$prev_tpanel_id = $tpanel_id;
|
||||
}
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_v2()
|
||||
{
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_count_v2(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["data"];
|
||||
} else {
|
||||
$this->sys_error_db("PX count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($prm['order_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byorder_v2(?, ?)", [$prm['order_id'], $mouCompanyID]);
|
||||
else if (isset($prm['clinic_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byclinic(?, ?)", [$prm['clinic_id'], $mouCompanyID]);
|
||||
else if ($search == "")
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_favorite_v2(?, ?)", $sql_param);
|
||||
else
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_v2(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
// echo $this->db_smartone->last_query();
|
||||
// $query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$id_to_remove = [];
|
||||
|
||||
// var_dump($rows);
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['requirement'] = [];
|
||||
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$v['T_TestID']}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['requirement'] = json_decode($x->x);
|
||||
|
||||
$rows[$k]['nat_test'] = json_decode($v['nat_test']);
|
||||
$rows[$k]['child_test'] = json_decode($v['child_test']);
|
||||
|
||||
// IF PROFILE
|
||||
if ($v['px_type'] == "PR" || $v['px_type'] == "PXR") {
|
||||
|
||||
if ($v['T_TestID'] == null)
|
||||
{
|
||||
$id_to_remove[] = $k;
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
foreach ($rows[$k]['child_test'] as $l => $w) {
|
||||
$rows[$k]['child_test'][$l]->requirement = [];
|
||||
$rows[$k]['child_test'][$l]->nat_test = json_decode($w->nat_test);
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$w->T_TestID}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['child_test'][$l]->requirement = json_decode($x->x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE INDEXES
|
||||
|
||||
foreach ($id_to_remove as $l => $w)
|
||||
{ $x = $w - $l; array_splice($rows, $x, 1); }
|
||||
|
||||
$result = array("total" => $tot_count, "records" => (array) $rows, "query" => $sqlx, "query2" => $sqly );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_count(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["data"];
|
||||
} else {
|
||||
$this->sys_error_db("PX count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($prm['order_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byorder(?, ?)", [$prm['order_id'], $mouCompanyID]);
|
||||
else if (isset($prm['clinic_id']))
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_byclinic(?, ?)", [$prm['clinic_id'], $mouCompanyID]);
|
||||
else if ($search == "")
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search_favorite(?, ?)", $sql_param);
|
||||
else
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
// echo $this->db_smartone->last_query();
|
||||
// $query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$id_to_remove = [];
|
||||
|
||||
// var_dump($rows);
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['requirement'] = [];
|
||||
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$v['T_TestID']}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['requirement'] = json_decode($x->x);
|
||||
|
||||
$rows[$k]['nat_test'] = json_decode($v['nat_test']);
|
||||
$rows[$k]['child_test'] = json_decode($v['child_test']);
|
||||
|
||||
// IF PROFILE
|
||||
if ($v['px_type'] == "PR" || $v['px_type'] == "PXR") {
|
||||
|
||||
if ($v['T_TestID'] == null)
|
||||
{
|
||||
$id_to_remove[] = $k;
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
foreach ($rows[$k]['child_test'] as $l => $w) {
|
||||
$rows[$k]['child_test'][$l]->requirement = [];
|
||||
$rows[$k]['child_test'][$l]->nat_test = json_decode($w->nat_test);
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$w->T_TestID}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['child_test'][$l]->requirement = json_decode($x->x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE INDEXES
|
||||
|
||||
foreach ($id_to_remove as $l => $w)
|
||||
{ $x = $w - $l; array_splice($rows, $x, 1); }
|
||||
|
||||
$result = array("total" => $tot_count, "records" => (array) $rows, "query" => $sqlx, "query2" => $sqly );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_price()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$r = [];
|
||||
|
||||
$sql_param = array($prm['test_id'], date('Y-m-d'), $prm['cito'], $prm['mou_id']);
|
||||
$sql = "select fn_price(?, ?, ?, ?) as price";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query) {
|
||||
$r = $query->result_array()[0];
|
||||
$r = json_decode($r['price']);
|
||||
$this->sys_ok($r);
|
||||
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("get price", $this->db_smartone);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function get_appx_schedule()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$r = [];
|
||||
|
||||
$sql_param = array($prm['test_ids'], $prm['panel_ids']);
|
||||
$sql = "select fn_fo_find_promise_by_px(?, ?) as x";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query) {
|
||||
$r = $query->result_array()[0];
|
||||
$r = $r['x'];
|
||||
$this->sys_ok($r);
|
||||
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("get schedule", $this->db_smartone);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_cito()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT Nat_CitoID, Nat_CitoName, Nat_CitoIsDefault
|
||||
FROM nat_cito WHERE Nat_CitoIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$this->sys_ok(["records"=>$rows]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->sys_error_db("CITO", $this->db_smartone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
class Order extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "ORDER MCU API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
function load()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_fo_register_load_mcu('{$this->sys_user['M_UserID']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
if ($rst->status == "OK")
|
||||
{
|
||||
$rst->data = json_decode($rst->data);
|
||||
$this->sys_ok($rst->data);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error("Tidak ada order");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("Tidak ada order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function load_pxs()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID);
|
||||
|
||||
$tot_count = 0;
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_load_mcu(?, ?)", [$prm['order_id'], $mouCompanyID]);
|
||||
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
// echo $this->db_smartone->last_query();
|
||||
// $query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
|
||||
// var_dump($rows);
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['requirement'] = [];
|
||||
$id_to_remove = [];
|
||||
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$v['T_TestID']}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['requirement'] = json_decode($x->x);
|
||||
|
||||
$rows[$k]['nat_test'] = json_decode($v['nat_test']);
|
||||
$rows[$k]['child_test'] = json_decode($v['child_test']);
|
||||
|
||||
// IF PROFILE
|
||||
if ($v['px_type'] == "PR" || $v['px_type'] == "PXR")
|
||||
{
|
||||
|
||||
if ($v['T_TestID'] == null)
|
||||
{
|
||||
$id_to_remove[] = $k;
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
foreach ($rows[$k]['child_test'] as $l => $w)
|
||||
{
|
||||
$rows[$k]['child_test'][$l]->requirement = [];
|
||||
$rows[$k]['child_test'][$l]->nat_test = json_decode($w->nat_test);
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$w->T_TestID}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['child_test'][$l]->requirement = json_decode($x->x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE INDEXES
|
||||
foreach ($id_to_remove as $l => $w)
|
||||
{ $x = $w - $l; array_splice($rows, $x, 1); }
|
||||
|
||||
$result = array("total" => $tot_count, "records" => (array) $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function load_doctor()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 1;
|
||||
$tot_count = 0;
|
||||
|
||||
$sql = "select M_DoctorID, M_DoctorIsDefault, IF(M_DoctorPJID IS NULL, 'Y', 'N') M_DoctorIsPJ,
|
||||
fn_global_doctor_name(M_DoctorID) as M_DoctorName, fn_fo_delivery_code('DOCTOR', 'EMAIL', 0) as delivery_email_code,
|
||||
IF(M_DoctorEmail IS NULL OR M_DoctorEmail = '', 'N', M_DoctorEmailIsDefault) email_default,
|
||||
IFNULL( concat('[', group_concat(JSON_OBJECT('M_DoctorAddressDescription', M_DoctorAddressDescription, 'M_DoctorAddressID', M_DoctorAddressID, 'delivery_default', M_DoctorAddressDeliveryDefault, 'delivery_code', fn_fo_delivery_code('DOCTOR', 'ADDRESS', M_DoctorAddressID)) SEPARATOR ','), ']'), '[]') as address
|
||||
from m_doctor
|
||||
left join m_doctoraddress on M_DoctorAddressIsActive = 'Y'
|
||||
and M_DoctorAddressM_DoctorID = M_DoctorID
|
||||
left join m_doctorpj on M_DoctorPJM_DoctorID = M_DoctorID and M_DoctorPjIsactive = 'Y'
|
||||
where M_DoctorIsActive = 'Y' AND M_DoctorIsDefaultMcu = 'Y'
|
||||
group by M_DoctorID
|
||||
limit 1";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$tot_count = 1;
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['address'] = json_decode($v['address']);
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("DOCTOR MCU rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"php":"7.0.33-0ubuntu0.16.04.1","version":"2.14.2","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"Patient.php":3362798707}}
|
||||
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
class Company extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Company API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_mou(&$companies) {
|
||||
if (count($companies) == 0) {
|
||||
return;
|
||||
}
|
||||
$company_list= "-1";
|
||||
foreach($companies as $idx => $c) {
|
||||
$company_list .= ", " . $c["M_PatientTypeID"];
|
||||
if (! isset($companies[$idx]["mou"])) $companies[$idx]["mou"] = array();
|
||||
}
|
||||
$sql = "select *
|
||||
from
|
||||
m_moucompany
|
||||
where M_MouCompanyM_PatientTypeID in ( $company_list )
|
||||
and ( M_MouCompanyStartDate <= now() and M_MouCompanyEndDate >= now() )
|
||||
and M_MouCompanyIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows= $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$patientTypeID= $r["M_MouCompanyM_PatientTypeID"];
|
||||
foreach($companies as $idx => $c) {
|
||||
if($c["M_PatientTypeID"] == $patientTypeID) {
|
||||
$companies[$idx]["mou"][] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_moucompany mou",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_company
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$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
|
||||
left join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyIsActive = 'Y'
|
||||
and M_CompanyName like ?
|
||||
group by m_companyid";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$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_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_default()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_MouID, M_MouM_CompanyID FROM m_mou
|
||||
WHERE M_MouIsActive = 'Y' ANd M_MouIsDefault = 'Y' AND M_MouIsApproved = 'Y'
|
||||
AND M_MouStartDate <= date(now()) AND M_MouEndDate >= date(now())";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->row();
|
||||
$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, 'M_MouIsDefault', M_MouIsDefault) ), ']'), '[]') as mou
|
||||
from m_company
|
||||
join m_mou on M_MouM_CompanyID = M_CompanyID and M_MouIsActive = 'Y'
|
||||
and M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now())
|
||||
where M_CompanyID = ?
|
||||
group by m_companyid";
|
||||
$query = $this->db_smartone->query($sql, array($rows->M_MouM_CompanyID));
|
||||
$rows2 = $query->result_array();
|
||||
|
||||
foreach ($rows2 as $k => $v)
|
||||
$rows2[$k]['mou'] = json_decode($v['mou']);
|
||||
|
||||
$result = array("total" => 1, "records" => $rows2, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("m_company rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$sql_param = array("%$search%");
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patienttype count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select M_PatientTypeID, M_PatientTypeName
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'
|
||||
limit 0,10";
|
||||
$query = $this->db_smartone->query($sql,$sql_param);
|
||||
$rows = $query->result_array();
|
||||
$this->_add_mou($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
class Delivery extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$q = [
|
||||
"patient_id" => 0,
|
||||
"doctor_id" => 0
|
||||
];
|
||||
|
||||
if (isset($prm['patient_id']))
|
||||
$q["patient_id"] = $prm['patient_id'];
|
||||
if (isset($prm['doctor_id']))
|
||||
$q["doctor_id"] = $prm['doctor_id'];
|
||||
|
||||
$sql = "CALL sp_fo_delivery_address('', '{$q['patient_id']}', '{$q['doctor_id']}', '')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows= $query->row();
|
||||
$data = json_decode($rows->x);
|
||||
|
||||
$result = array("records" => $data);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("delivery address",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// $rows = array();
|
||||
// $rows[] = array("id" =>1, "name" => "Ambil Sendiri", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>2, "name" => "Kirim ke dokter", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>3, "name" => "Kirim ke email pasien", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>4, "name" => "Kirim ke email dokter", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>5, "name" => "Kirim ke alamat utama pasien", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>6, "name" => "Kirim ke alamat utama dokter", "selected" => false, "note" => "");
|
||||
// $rows[] = array("id" =>7, "name" => "Kirim ke rekanan");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Doctor extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_address(&$doc) {
|
||||
if (count($doc) == "0") {
|
||||
return;
|
||||
}
|
||||
$doc_ids = "-1";
|
||||
foreach($doc as $idx => $d ) {
|
||||
$doc_ids .= "," . $d["M_DoctorID"];
|
||||
$doc[$idx]["address"] = array();
|
||||
}
|
||||
$sql = "select M_DoctorAddressID,M_DoctorAddressM_DoctorID,
|
||||
M_DoctorAddressDesc
|
||||
from
|
||||
m_doctoraddress
|
||||
where
|
||||
M_DoctorAddressM_DoctorID in ( $doc_ids )
|
||||
and M_DoctorAddressIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$doctorID= $r["M_DoctorAddressM_DoctorID"];
|
||||
foreach($doc as $idx => $d) {
|
||||
if($d["M_DoctorID"] == $doctorID) {
|
||||
$doc[$idx]["address"][] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function search_pj() {
|
||||
$sql = "select M_DoctorID,M_DoctorName,M_DoctorIsDefaultPJ
|
||||
from
|
||||
m_doctor
|
||||
where M_DoctorIsActive = 'Y' and
|
||||
( M_DoctorIsPJ = 'Y' or M_DoctorIsDefaultPJ ='Y' ) ";
|
||||
$query = $this->db_smartone->query($sql, array("%$search%"));
|
||||
$rows = $query->result_array();
|
||||
$result = array("total" => count($rows) , "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_doctor
|
||||
where M_DoctorIsActive = 'Y'
|
||||
and M_DoctorName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_DoctorID, M_DoctorIsDefault, M_DoctorIsPJ,
|
||||
concat(IFNULL(M_DoctorPrefix, ''),' ',M_DoctorName, ' ', IFNULL(M_DoctorSufix, '')) as M_DoctorName,
|
||||
IFNULL( concat('[', group_concat(JSON_OBJECT('M_DoctorAddressDescription', M_DoctorAddressDescription, 'M_DoctorAddressID', M_DoctorAddressID) SEPARATOR ','), ']'), '[]') as address
|
||||
from m_doctor
|
||||
left join m_doctoraddress on M_DoctorAddressIsActive = 'Y'
|
||||
and M_DoctorAddressM_DoctorID = M_DoctorID
|
||||
where M_DoctorIsActive = 'Y'
|
||||
and concat(IFNULL(M_DoctorPrefix, ''),' ',M_DoctorName, ' ', IFNULL(M_DoctorSufix, '')) like ?
|
||||
group by M_DoctorID";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v)
|
||||
$rows[$k]['address'] = json_decode($v['address']);
|
||||
|
||||
$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_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function getdefaultdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "SELECT m_doctor.*, '' as address FROM m_doctor
|
||||
WHERE M_DoctorIsDefaultMcu = 'Y' AND M_DoctorIsActive = 'Y' LIMIT 1";
|
||||
$row = $this->db_onedev->query($sql)->row();
|
||||
|
||||
$sql = "SELECT * FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = $row->M_DoctorID AND M_DoctorAddressIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$row->address = $this->db_onedev->query($sql)->result();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $row,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_doctor
|
||||
join (
|
||||
select distinct M_DoctorAddressM_DoctorID
|
||||
from m_doctoraddress
|
||||
where M_DoctorAddressIsActive = 'Y'
|
||||
) ma on M_DoctorID = M_DoctorAddressM_DoctorID
|
||||
where M_DoctorIsActive = 'Y' and M_DoctorName like ? ";
|
||||
$query = $this->db_smartone->query($sql, array("%$search%"));
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patient count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select M_DoctorID,M_DoctorName
|
||||
from
|
||||
m_doctor
|
||||
join (
|
||||
select distinct M_DoctorAddressM_DoctorID
|
||||
from m_doctoraddress
|
||||
where M_DoctorAddressIsActive = 'Y'
|
||||
) ma on M_DoctorID = M_DoctorAddressM_DoctorID
|
||||
where M_DoctorIsActive = 'Y' and M_DoctorName like ?
|
||||
limit 0,10";
|
||||
$query = $this->db_smartone->query($sql, array("%$search%"));
|
||||
$rows = $query->result_array();
|
||||
$this->_add_address($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
class Language extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_lang
|
||||
where M_LangIsActive = 'Y'
|
||||
and M_LangName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_lang count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_LangID as id, M_LangName as name
|
||||
from m_lang
|
||||
where M_LangIsActive = 'Y'
|
||||
and M_LangName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rows_ = [];
|
||||
$si = [["is_si" => "N", "si_text" => ""], ["is_si" => "Y", "si_text" => "(SI)"]];
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
foreach ($si as $l => $w)
|
||||
{
|
||||
$v['is_si'] = $w['is_si'];
|
||||
$v['name'] .= $w['si_text'] == '' ? '' : ' ' . $w['si_text'];
|
||||
$v['key'] = $v['id'] . '-' . $v['is_si'];
|
||||
$rows_[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$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_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$rows = array();
|
||||
$rows[] = array("id" =>"ID", "name" => "Bahasa Indonesia");
|
||||
$rows[] = array("id" =>"EN", "name" => "Bahasa Inggris");
|
||||
$rows[] = array("id" =>"CH", "name" => "Bahasa Mandarin");
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
class Order extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "ORDER API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$hdr = $prm['header'];
|
||||
$header_json = json_encode($hdr);
|
||||
$detail_json = json_encode($prm['detail']);
|
||||
$delivery_json = json_encode($prm['delivery']);
|
||||
$req_json = json_encode($prm['req']);
|
||||
|
||||
$sql = "CALL sp_fo_register_save('{$prm['order_id']}', '{$header_json}', '{$delivery_json}', '{$detail_json}', '{$req_json}', '{$this->sys_user['M_UserID']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function load_from_clinic()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_fo_clinic_load('{$prm['queue']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
if ($rst->status == "OK")
|
||||
{
|
||||
$rst->data = json_decode($rst->data);
|
||||
|
||||
$rst->data->doctor->address = $rst->data->doctor_address;
|
||||
unset($rst->data->doctor_address);
|
||||
|
||||
$rst->data->company->mou = [$rst->data->mou];
|
||||
unset($rst->data->mou);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error("Tidak ada order");
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function load()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "CALL sp_fo_register_load('{$prm['id']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
if ($rst->status == "OK")
|
||||
{
|
||||
$rst->data = json_decode($rst->data);
|
||||
|
||||
$rst->data->doctor->address = $rst->data->doctor_address;
|
||||
unset($rst->data->doctor_address);
|
||||
|
||||
$rst->data->company->mou = [$rst->data->mou];
|
||||
unset($rst->data->mou);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error("Tidak ada order");
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save order", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,470 @@
|
||||
<?php
|
||||
/*
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Patient extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_address(&$pat) {
|
||||
if (count($pat) == "0") {
|
||||
return array();
|
||||
}
|
||||
foreach($pat as $idx => $p ) {
|
||||
$pat[$idx]["address"] = array($p["M_PatientAddress"]);
|
||||
}
|
||||
$this->_add_history($pat);
|
||||
}
|
||||
function _add_history(&$pat) {
|
||||
$pat_list = "-1";
|
||||
foreach($pat as $idx => $p) {
|
||||
$pat_list .= ", " . $p["M_PatientID"];
|
||||
if (! isset($pat[$idx]["history"])) $pat[$idx]["history"] = array();
|
||||
}
|
||||
$sql = "select T_OrderHeaderM_PatientID,T_OrderHeaderLabNumber,T_OrderHeaderDate,
|
||||
concat(T_OrderDetailT_TestName) T_TestName
|
||||
from
|
||||
t_orderheader
|
||||
join t_orderdetail on
|
||||
T_OrderHeaderID = T_OrderDetailID and
|
||||
T_OrderHeaderIsActive = 'Y' and T_OrderDetailIsActive = 'Y'
|
||||
and T_OrderHeaderM_PatientID in ( $pat_list )
|
||||
join t_test on T_OrderDetailT_TestID = T_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
order by T_OrderHeaderM_PatientID,T_OrderHeaderLabNumber";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
if ($query) {
|
||||
$rows= $query->result_array();
|
||||
foreach($rows as $r) {
|
||||
$patientID = $r["T_OrderHeaderM_PatientID"];
|
||||
foreach($pat as $idx => $p) {
|
||||
if($p["M_PatientID"] == $patientID) {
|
||||
$pat[$idx]["history"][] = $r;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("m_patient history",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'noreg' => '%',
|
||||
'name' => '%',
|
||||
'hp' => '%',
|
||||
'dob' => '%',
|
||||
'address' => '%'
|
||||
];
|
||||
|
||||
if ($prm['noreg'] != '')
|
||||
$q['noreg'] = "%{$prm['noreg']}%";
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$e = explode('+', $prm['search']);
|
||||
if (isset($e[0]))
|
||||
$q['name'] = "%{$e[0]}%";
|
||||
if (isset($e[1]))
|
||||
$q['hp'] = "%{$e[1]}%";
|
||||
if (isset($e[2]))
|
||||
$q['dob'] = "%{$e[2]}%";
|
||||
if (isset($e[3]))
|
||||
$q['address'] = "%{$e[3]}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(distinct m_patientid) total
|
||||
from
|
||||
m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
where M_PatientNoReg like ?
|
||||
and M_PatientName LIKE ?
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and ((M_PatientDOB LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL)";
|
||||
$query = $this->db_smartone->query($sql, array($q['noreg'], $q['name'], $q['hp'], $q['dob']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
M_PatientHP, M_PatientDOB, M_PatientNote,
|
||||
concat(M_PatientAddressDescription, '\n\n', m_kelurahanname, ', ', m_districtname,
|
||||
'\n', m_cityname, ', ', m_provincename) as M_PatientAddress,
|
||||
M_PatientNote, M_PatientPhoto
|
||||
from
|
||||
m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID and M_PatientAddressIsActive = 'Y'
|
||||
left join m_kelurahan on m_patientaddressm_kelurahanid = m_kelurahanid
|
||||
left join m_district on m_kelurahanm_districtid = m_districtid
|
||||
left join m_city on m_districtm_cityid = m_cityid
|
||||
left join m_province on m_citym_provinceid = m_provinceid
|
||||
where M_PatientNoReg like ?
|
||||
and M_PatientName LIKE ?
|
||||
|
||||
and ((M_PatientHP LIKE ? and M_PatientHP IS NOT NULL) OR M_PatientHP IS NULL)
|
||||
and ((M_PatientDOB LIKE ? and M_PatientDOB IS NOT NULL) OR M_PatientDOB IS NULL)
|
||||
group by m_patientid
|
||||
limit 0,{$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, array($q['noreg'], $q['name'], $q['hp'], $q['dob']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function searchdoctor()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_doctor
|
||||
where M_DoctorIsActive = 'Y'
|
||||
and M_DoctorName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_DoctorID as id,
|
||||
concat(IFNULL(M_DoctorPrefix, ''),' ',M_DoctorName, ' ', IFNULL(M_DoctorSufix, '')) as name,
|
||||
'' as address
|
||||
from m_doctor
|
||||
left join m_doctoraddress on M_DoctorAddressIsActive = 'Y'
|
||||
and M_DoctorAddressM_DoctorID = M_DoctorID
|
||||
where M_DoctorIsActive = 'Y'
|
||||
and concat(IFNULL(M_DoctorPrefix, ''),' ',M_DoctorName, ' ', IFNULL(M_DoctorSufix, '')) like ?
|
||||
group by M_DoctorID";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach ($rows as $k => $v){
|
||||
$sql = "SELECT * FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = {$v['id']} AND M_DoctorAddressIsActive = 'Y'";
|
||||
$rows[$k]['address'] = $this->db_onedev->query($sql)->result();
|
||||
}
|
||||
|
||||
|
||||
$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_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function add_new()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$prm['M_PatientDOB'] = date('Y-m-d', strtotime($prm['M_PatientDOB']));
|
||||
$ptn = [
|
||||
'M_PatientName' => $prm['M_PatientName'],
|
||||
'M_PatientM_TitleID' => $prm['M_PatientM_TitleID'],
|
||||
'M_PatientSuffix' => $prm['M_PatientSuffix'],
|
||||
'M_PatientM_SexID' => $prm['M_PatientM_SexID'],
|
||||
'M_PatientM_ReligionID' => $prm['M_PatientM_ReligionID'],
|
||||
'M_PatientDOB' => $prm['M_PatientDOB'],
|
||||
'M_PatientHP' => $prm['M_PatientHP'],
|
||||
'M_PatientPhone' => $prm['M_PatientPhone'],
|
||||
'M_PatientEmail' => $prm['M_PatientEmail'],
|
||||
'M_PatientM_IdTypeID' => $prm['M_PatientM_IdTypeID'],
|
||||
'M_PatientIDNumber' => $prm['M_PatientIDNumber'],
|
||||
'M_PatientNote' => $prm['M_PatientNote']
|
||||
];
|
||||
$this->db_smartone->insert('m_patient', $ptn);
|
||||
|
||||
$err = $this->db_smartone->error();
|
||||
if ( $err['message'] != "" )
|
||||
{
|
||||
$this->sys_error_db("m_patient rows", $this->db_smartone);
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $this->db_smartone->insert_id();
|
||||
|
||||
// LOG FO
|
||||
$ptn = json_encode($ptn);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADD', '{$ptn}', '0')");
|
||||
|
||||
// save address
|
||||
$add = [
|
||||
'M_PatientAddressM_PatientID' => $id,
|
||||
'M_PatientAddressDescription' => $prm['M_PatientAddressDescription'],
|
||||
'M_PatientAddressM_KelurahanID' => $prm['M_PatientAddressM_KelurahanID']
|
||||
];
|
||||
$this->db_smartone->insert('m_patientaddress', $add);
|
||||
|
||||
// LOG FO
|
||||
$add = json_encode($add);
|
||||
$this->db_smartone->query("CALL one_log.log_me('FO', 'FO.PATIENT.ADDRESS.ADD', '{$add}', '0')");
|
||||
|
||||
// get
|
||||
$r = $this->db_smartone->where('M_PatientID', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
$rst = array("id" => $id, 'noreg'=>$r->M_PatientNoReg);
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
// public function search_()
|
||||
// {
|
||||
// $prm = $this->sys_input;
|
||||
|
||||
// $noreg = $prm["noreg"];
|
||||
// $search = $prm["search"];
|
||||
// //prioritas pada noreg
|
||||
// if ($noreg != "") {
|
||||
// $noreg = "%$noreg%";
|
||||
// $sql = "select count(*) total
|
||||
// from
|
||||
// m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
// where M_PatientNoReg like ?";
|
||||
// $query = $this->db_smartone->query($sql, array($noreg));
|
||||
|
||||
// $tot_count =0;
|
||||
// if ($query) {
|
||||
// $tot_count = $query->result_array()[0]["total"];
|
||||
// } else {
|
||||
// $this->sys_error_db("m_patient count",$this->db_smartone);
|
||||
// exit;
|
||||
// }
|
||||
// $sql = "select M_PatientID, M_PatientNoReg,
|
||||
// concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
// M_PatientHP, M_PatientDOB, M_PatientNote, M_PatientAddress
|
||||
// from
|
||||
// m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
// where M_PatientNoReg like ?
|
||||
// limit 0,10";
|
||||
// $query = $this->db_smartone->query($sql, array($noreg));
|
||||
// $rows = $query->result_array();
|
||||
// $this->_add_address($rows);
|
||||
// $result = array("total" => $tot_count, "records" => $rows);
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
// }
|
||||
// //parse query
|
||||
// $nama = $dob = $hp = $alamat = "";
|
||||
// try {
|
||||
// list($nama, $hp, $dob,$alamat) = explode("+", $search);
|
||||
// } catch(Exception $e) {
|
||||
// }
|
||||
// $sql_where = "";
|
||||
// $sql_param = array();
|
||||
// if ($nama != "") {
|
||||
// if ($sql_where != "") {
|
||||
// $sql_where .=" and ";
|
||||
// }
|
||||
// $sql_where .= " M_PatientName like ? ";
|
||||
// $sql_param[] = "%$nama%";
|
||||
// }
|
||||
// if ($dob != "") {
|
||||
// if ($sql_where != "") {
|
||||
// $sql_where .=" and ";
|
||||
// }
|
||||
// $sql_where .= " M_PatientDOB like ? ";
|
||||
// $sql_param[] = "%$dob%";
|
||||
// }
|
||||
// if ($hp != "") {
|
||||
// if ($sql_where != "") {
|
||||
// $sql_where .=" and ";
|
||||
// }
|
||||
// $sql_where .= " M_PatientHp like ? ";
|
||||
// $sql_param[] = "%$hp%";
|
||||
// }
|
||||
// if ($alamat != "") {
|
||||
// if ($sql_where != "") {
|
||||
// $sql_where .=" and ";
|
||||
// }
|
||||
// $sql_where .= " M_PatientAddress like ?";
|
||||
// $sql_param[] = "%$alamat%";
|
||||
// }
|
||||
// if ($sql_where != "") {
|
||||
// $sql_where = "where $sql_where";
|
||||
// }
|
||||
|
||||
// $sql = "select count(*) total
|
||||
// from
|
||||
// m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
// $sql_where";
|
||||
// $query = $this->db_smartone->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_smartone);
|
||||
// exit;
|
||||
// }
|
||||
// $sql = "select M_PatientID, M_PatientNoReg,
|
||||
// concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
// M_PatientHP, M_PatientDOB, M_PatientAddress,M_PatientNote
|
||||
// from
|
||||
// m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
// $sql_where
|
||||
// limit 0,10";
|
||||
// $query = $this->db_smartone->query($sql, $sql_param);
|
||||
// $rows = $query->result_array();
|
||||
// $this->_add_address($rows);
|
||||
// $result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_smartone->last_query());
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
// }
|
||||
|
||||
public function search_idtype()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "SELECT M_IdTypeID, M_IdTypeName
|
||||
FROM m_idtype
|
||||
WHERE M_IdTypeIsActive = 'Y'
|
||||
ORDER BY M_IdTypeName ASC";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_idtype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getdefaultdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "SELECT M_DoctorID as id, concat(IFNULL(M_DoctorPrefix, ''),' ',M_DoctorName, ' ', IFNULL(M_DoctorSufix, '')) as name, '' as address FROM m_doctor
|
||||
WHERE M_DoctorIsDefaultMcu = 'Y' AND M_DoctorIsActive = 'Y' LIMIT 1";
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT * FROM m_doctoraddress WHERE M_DoctorAddressM_DoctorID = {$rows[0]['id']} AND M_DoctorAddressIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows[0]['address'] = $this->db_onedev->query($sql)->result();
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getdatapatient()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select M_PatientID, M_PatientNoReg,
|
||||
concat(M_TitleName,' ',M_PatientName) M_PatientName,
|
||||
M_PatientHP, M_PatientDOB, M_PatientNote,
|
||||
concat(M_PatientAddressDescription, '\n\n', m_kelurahanname, ', ', m_districtname,
|
||||
'\n', m_cityname, ', ', m_provincename) as M_PatientAddress,
|
||||
M_PatientNote, M_PatientPhoto
|
||||
from
|
||||
m_patient join m_title on M_PatientM_TitleID = M_TitleID
|
||||
left join m_patientaddress on M_PatientAddressM_PatientID = M_PatientID and M_PatientAddressIsActive = 'Y' AND M_PatientAddressNote = 'Utama'
|
||||
left join m_kelurahan on m_patientaddressm_kelurahanid = m_kelurahanid
|
||||
left join m_district on m_kelurahanm_districtid = m_districtid
|
||||
left join m_city on m_districtm_cityid = m_cityid
|
||||
left join m_province on m_citym_provinceid = m_provinceid
|
||||
join mcu_preregister_details ON Mcu_PreregisterDetailsM_PatientID = M_PatientID AND
|
||||
Mcu_PreregisterDetailsIsActive = 'Y' AND Mcu_PreregisterDetailsIsRegistered = 'N' AND
|
||||
( Mcu_PreregisterDetailsFlagAction = 'R') AND
|
||||
Mcu_PreregisterDetailsByUserID = {$xuserid}
|
||||
where
|
||||
M_PatientIsActive = 'Y'
|
||||
LIMIT 1";
|
||||
//echo $sql;
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row_array();
|
||||
|
||||
$result = array("records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_idtype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*
|
||||
template function {
|
||||
$this->sys_debug();
|
||||
try {
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
class Patientaddress extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Patient API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function get_all()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$sql = "select M_PatientAddressID, M_PatientAddressNote,
|
||||
M_PatientAddressDescription, M_KelurahanName as M_KelurahanName
|
||||
from m_patientaddress
|
||||
left join m_kelurahan on m_patientaddressm_kelurahanid = m_kelurahanid
|
||||
where m_patientaddressm_patientid = ?";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['patient_id']));
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("status" => "OK", "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
|
||||
<?php
|
||||
|
||||
class Payment extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Doctor API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function get_order() {
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$rst = ["order_header"=>[], "order_detail"=>[], "order_delivery"=>[]];
|
||||
|
||||
$sql = "
|
||||
select T_OrderHeaderID as order_id,
|
||||
T_OrderHeaderLabNumber as order_no,
|
||||
T_OrderHeaderDate as order_date,
|
||||
T_OrderHeaderSubTotal as order_subtotal,
|
||||
T_OrderHeaderRounding as order_rounding,
|
||||
T_OrderHeaderTotal as order_total,
|
||||
concat(if(M_TitleID is null, '', concat(M_TitleName, ' ')), M_PatientName) as patient_name,
|
||||
M_PatientNoReg as patient_mr,
|
||||
M_MouName as order_mou,
|
||||
M_CompanyName as order_company,
|
||||
fn_global_doctor_name(da.M_DoctorID) doctor_sender,
|
||||
fn_global_doctor_name(db.M_DoctorID) doctor_pj,
|
||||
fn_global_doctor_address(aa.M_DoctorAddressID, 1) doctor_sender_address,
|
||||
M_MouIsBill M_CompanyIsBill, M_MouMinDP M_CompanyMinDP,
|
||||
M_MouIsAgingOnHold M_CompanyIsAgingOnHold, M_MouIsAgingOnHoldNote M_CompanyIsAgingOnHoldNote
|
||||
from t_orderheader
|
||||
join m_patient on T_OrderHeaderM_PatientID = M_PatientID
|
||||
join m_company on T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
join m_mou on T_OrderHeaderM_MouID = M_MouID
|
||||
join m_doctor da on T_OrderHeaderSenderM_DoctorID = da.M_DoctorID
|
||||
join m_doctoraddress aa on T_OrderHeaderSenderM_DoctorAddressID = aa.M_DoctorAddressID
|
||||
join m_doctor db on T_OrderHeaderSenderM_DoctorID = db.M_DoctorID
|
||||
left join m_title on m_patientm_titleid = m_titleid
|
||||
where T_OrderHeaderID = ?";
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = (array) $query->row();
|
||||
$rst['order_header'] = $rows;
|
||||
// $result = array("status" => "OK" , "data" => $rst);
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "CALL sp_fo_payment_get_delivery('{$prm['id']}')";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row();
|
||||
$rst['order_delivery'] = json_decode($rows->delivery);
|
||||
// $result = array("status" => "OK" , "data" => $rst);
|
||||
// $this->sys_ok($result);
|
||||
// exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress delivery ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
// { n:1, d_id:1, t_id:1, t_name:'SGOT', t_price:80000, t_disctotal:7000, t_total:73000 },
|
||||
// { n:2, d_id:2, t_id:2, t_name:'SGPT', t_price:75000, t_disctotal:8000, t_total:67000 }
|
||||
// T_OrderDetailPrice double [0]
|
||||
// T_OrderDetailPriceForDisc double [0]
|
||||
// T_OrderDetailDisc double [0]
|
||||
// T_OrderDetailDiscAmount double [0]
|
||||
// T_OrderDetailTotal
|
||||
|
||||
$sql = "
|
||||
select T_OrderDetailID as d_id,
|
||||
T_OrderDetailT_TestID as t_id,
|
||||
IFNULL(T_OrderDetailT_TestName, T_PacketName) as t_name,
|
||||
T_OrderDetailPrice as t_price,
|
||||
T_OrderDetailDiscTotal as t_disctotal,
|
||||
T_OrderDetailTotal as t_total
|
||||
from t_orderdetail
|
||||
join t_orderdetailaddon on T_OrderDetailAddOnT_OrderDetailID = T_OrderDetailID
|
||||
left join t_test on t_orderdetailt_testid = t_testid
|
||||
left join t_packet on t_orderdetailaddonispacket = 'Y' and t_orderdetailaddont_packetid = t_packetid
|
||||
where T_OrderDetailT_OrderHeaderID = ?
|
||||
and T_ORderDetailIsActive = 'Y'
|
||||
and ((T_ORderDetailAddOnIsPacket = 'N' AND T_TestIsPrintNota = 'Y' AND T_OrderDetailT_TestIsPanelChildren = 'N')
|
||||
OR (T_OrderDetailT_TestIsPanelChildren = 'Y' AND T_OrderDetailT_TestIsPanelChildrenPrintNota = 'Y')
|
||||
OR (T_ORderDetailAddOnIsPacket = 'Y' AND T_PacketIsNOta = 'Y'))";
|
||||
|
||||
$query = $this->db_smartone->query($sql, array($prm['id']));
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
$rst['order_detail'] = $rows;
|
||||
|
||||
$result = array("status" => "OK" , "data" => $rst);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("m_doctoraddress ", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 100;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_paymenttype count",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_PaymentTypeID payment_type_id, M_PaymentTypeName payment_type_name, M_PaymentTypeCode payment_type_code,
|
||||
0 payment_amount, '' payment_note, 'Nomor Kartu' payment_note_label, 'N' payment_enable,
|
||||
0 payment_change, 0 payment_actual
|
||||
from m_paymenttype
|
||||
where M_PaymentTypeIsActive = 'Y'
|
||||
and M_PaymentTypeName like ?";
|
||||
$query = $this->db_smartone->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $v) {
|
||||
|
||||
if ($v['payment_type_code'] == 'CASH')
|
||||
$v['payment_note_label'] = 'Kembali';
|
||||
if ($v['payment_type_code'] == 'VOUCHER')
|
||||
$v['payment_note_label'] = 'Nomor Voucher';
|
||||
|
||||
$rows[$k] = $v;
|
||||
}
|
||||
|
||||
$result = $rows;
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_paymenttype rows",$this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$payment_json = json_encode($prm['payments']);
|
||||
|
||||
$sql = "CALL sp_fo_payment('{$prm['order_id']}', '{$payment_json}', '{$this->sys_user['M_UserID']}');";
|
||||
$query = $this->db_smartone->query($sql);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$rst = $query->row();
|
||||
$rst->data = json_decode($rst->data);
|
||||
echo json_encode($rst);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sys_error_db("save payment", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Photo extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Photo API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
$this->load->library('ImageManipulator');
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$inp = $this->sys_input;
|
||||
|
||||
$home_dir = "/home/one/Web/";
|
||||
$target_dir = $home_dir . "one-media/one-photo/patient/" . date("Y") . "/";
|
||||
|
||||
$y = $this->regenerateOldPhoto($home_dir, $inp['id']);
|
||||
|
||||
// get patient mr
|
||||
$p = $this->db_smartone->select("M_PatientNoReg")
|
||||
->where("M_PatientID", $inp['id'])
|
||||
->get('m_patient')
|
||||
->row();
|
||||
|
||||
if (!file_exists($target_dir)) {
|
||||
mkdir($target_dir, 0755, true);
|
||||
}
|
||||
|
||||
$target_path = $target_dir . $p->M_PatientNoReg . ".jpg";
|
||||
$this->base64_to_jpeg($inp['data'], $target_path);
|
||||
|
||||
// CROP Image
|
||||
$im = new ImageManipulator($target_path);
|
||||
$w = $im->getWidth();
|
||||
$h = $im->getHeight();
|
||||
|
||||
$mw = ceil(3 * $h / 4);
|
||||
if ($w <= $mw)
|
||||
{
|
||||
$x1 = 0;
|
||||
$y1 = 0;
|
||||
$x2 = $w;
|
||||
$y2 = $h;
|
||||
}
|
||||
else
|
||||
{
|
||||
$x1 = floor(($w - $mw) / 2);
|
||||
$y1 = 0;
|
||||
$x2 = ceil($w - (($w - $mw) / 2));
|
||||
$y2 = $h;
|
||||
}
|
||||
|
||||
$im->crop($x1, $y1, $x2, $y2); // takes care of out of boundary conditions automatically
|
||||
$im->save($target_path);
|
||||
|
||||
$x = $this->generateThumbnail($target_path, 75, 100);
|
||||
|
||||
// Save to DB
|
||||
$this->db_smartone->set("M_PatientPhoto", "/" . str_replace($home_dir, "", $target_path))
|
||||
->set("M_PatientPhotoThumb", "/" . str_replace($home_dir, "", $x))
|
||||
->set('M_PatientPhotoCounter', '`M_PatientPhotoCounter` + 1', false)
|
||||
->where('M_PatientID', $inp['id'])
|
||||
->update('m_patient');
|
||||
|
||||
// LOGGING
|
||||
$code = $y ? "PHOTO.PATIENT.EDIT" : "PHOTO.PATIENT.ADD";
|
||||
$one_log = $this->load->database('onelog', true);
|
||||
$one_log->set('Log_PhotoCode', $code)
|
||||
->set('Log_PhotoM_PatientID', $inp['id'])
|
||||
->set('Log_PhotoUrl', $y ? $y : "/" . str_replace($home_dir, "", $target_path))
|
||||
->insert('log_photo');
|
||||
|
||||
$this->sys_ok(["rename"=>$y, "patient_id"=>$inp['id'], "patient_mr"=>$p->M_PatientNoReg, "photo_url"=>"http://" . $_SERVER['SERVER_NAME'] . "/" . str_replace($home_dir, "", $target_path) . "?d=" . date("YmdHis")]);
|
||||
}
|
||||
|
||||
function base64_to_jpeg($base64_string, $output_file) {
|
||||
// open the output file for writing
|
||||
$ifp = fopen( $output_file, 'wb' );
|
||||
|
||||
// split the string on commas
|
||||
// $data[ 0 ] == "data:image/png;base64"
|
||||
// $data[ 1 ] == <actual base64 string>
|
||||
$data = explode( ',', $base64_string );
|
||||
|
||||
// we could add validation here with ensuring count( $data ) > 1
|
||||
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
|
||||
|
||||
// clean up the file resource
|
||||
fclose( $ifp );
|
||||
|
||||
return $output_file;
|
||||
}
|
||||
|
||||
function generateThumbnail($img, $width, $height, $quality = 90)
|
||||
{
|
||||
if (is_file($img)) {
|
||||
$imagick = new Imagick(realpath($img));
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->thumbnailImage($width, $height, false, false);
|
||||
$filename_no_ext = reset(explode('.', $img));
|
||||
if (file_put_contents($filename_no_ext . '_thumb' . '.jpg', $imagick) === false) {
|
||||
throw new Exception("Could not put contents.");
|
||||
}
|
||||
return $filename_no_ext . '_thumb' . '.jpg';
|
||||
}
|
||||
else {
|
||||
throw new Exception("No valid image provided with {$img}.");
|
||||
}
|
||||
}
|
||||
|
||||
function regenerateOldPhoto($home_dir, $id)
|
||||
{
|
||||
$r = $this->db_smartone->select('m_patientphoto, m_patientphotocounter', false)
|
||||
->where('m_patientid', $id)
|
||||
->get('m_patient')
|
||||
->row();
|
||||
if ($r->m_patientphoto != null && $r->m_patientphotocounter > 0) {
|
||||
$full_path = substr_replace($home_dir ,"", -1) . $r->m_patientphoto;
|
||||
$path_parts = pathinfo($full_path);
|
||||
|
||||
$rename = $path_parts['dirname'] . '/' . $path_parts['filename'] . '-' . $r->m_patientphotocounter . '.' . $path_parts['extension'];
|
||||
rename($full_path, $rename);
|
||||
// echo $path_parts['dirname'], "\n";
|
||||
// echo $path_parts['extension'], "\n";
|
||||
// echo $path_parts['filename'], "\n";
|
||||
|
||||
return "/" . str_replace($home_dir, "", $rename);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
//diberi tambahan pembeda IsFromPanel
|
||||
//utk contoh kasus yg ndak bisa di delete
|
||||
//sementara profile di ambilkan dari panel juga dengan IsFromPanel = N
|
||||
class Px extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "Px API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
function _add_ref_test(&$rows) {
|
||||
$ids = "-1";
|
||||
foreach($rows as $idx => $r) {
|
||||
$ids .= "," . $r["T_TestID"];
|
||||
if (! $rows[$idx]["ref_test"] ) $rows[$idx]["ref_test"] == array();
|
||||
}
|
||||
$sql="select T_TestID,T_RefTestName, T_TestName
|
||||
from
|
||||
t_reftest
|
||||
join t_test on T_RefTestID = T_TestT_RefTestID
|
||||
and T_RefTestIsActive = 'Y'
|
||||
where T_TestID in ( $ids )";
|
||||
|
||||
|
||||
}
|
||||
public function profile()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mou_id = $prm["mou_id"];
|
||||
$max_rst = 8;
|
||||
|
||||
$sql_param = array("%$search%");
|
||||
$sql = "select count(distinct T_ProfileID) total
|
||||
from t_profile
|
||||
join t_profiledetail on t_profileid = t_profiledetailt_profileid
|
||||
and t_profiledetailisactive = 'Y'
|
||||
where t_profilename like ?";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->row()->total;
|
||||
} else {
|
||||
$this->sys_error_db("Test Profile count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_ProfileID, T_ProfileName, CONCAT('[', GROUP_CONCAT( JSON_OBJECT('T_TestID', T_TestID, 'T_TestName', T_TestName, 'T_TestRequirement', T_TestRequirement) SEPARATOR ','), ']') detail
|
||||
from t_profile
|
||||
join t_profiledetail on t_profileid = t_profiledetailt_profileid
|
||||
and t_profiledetailisactive = 'Y'
|
||||
join t_test on t_profiledetailt_testid = t_testid
|
||||
where t_profilename like ?
|
||||
group by t_profileid
|
||||
limit 0, $max_rst";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$rows = $query->result_array();
|
||||
|
||||
foreach($rows as $k => $r)
|
||||
{
|
||||
$err = 0;
|
||||
$detail = json_decode($r['detail']);
|
||||
foreach ($detail as $l => $w)
|
||||
{
|
||||
$sql_param = array($w->T_TestID, date('Y-m-d'), 'N', $mou_id);
|
||||
$sql = "select fn_price(?, ?, ?, ?) as price";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query)
|
||||
{
|
||||
$price = json_decode($query->row()->price);
|
||||
|
||||
$detail[$l]->T_PriceAmount = $price->test_price;
|
||||
$detail[$l]->T_PriceDisc = $price->test_disc;
|
||||
$detail[$l]->T_PriceDiscRp = $price->test_discrp;
|
||||
$detail[$l]->T_PriceID = $price->price_id;
|
||||
$detail[$l]->T_PriceIsCito = "N";
|
||||
$detail[$l]->T_PriceM_CompanyID = $price->company_id;
|
||||
$detail[$l]->T_PriceM_MouID = $price->mou_id;
|
||||
$detail[$l]->T_PriceOther = $price->test_other;
|
||||
$detail[$l]->T_PriceSubTotal = $price->test_subtotal;
|
||||
$detail[$l]->T_PriceT_TestID = $price->test_id;
|
||||
$detail[$l]->T_PriceTotal = $price->test_total;
|
||||
|
||||
if ($price->test_price == 0)
|
||||
$err++;
|
||||
}
|
||||
}
|
||||
|
||||
$rows[$k]['detail'] = $detail;
|
||||
$rows[$k]['err'] = $err;
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function panel() {
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
$sql = "select count(distinct T_TestPanelID) total
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ? ";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_testpanel count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
where
|
||||
T_TestPanelName like ?
|
||||
limit 0,20";
|
||||
$query = $this->db_smartone->query($sql,$sql_param);
|
||||
$xrows = $query->result_array();
|
||||
$a_tpid = "-1";
|
||||
foreach($xrows as $r) {
|
||||
$a_tpid .= "," . $r["T_TestPanelID"];
|
||||
}
|
||||
$sql = "select distinct T_TestPanelID,T_TestPanelName,
|
||||
T_TestID,T_TestName, 'Y' IsFromPanel,T_TestRequirement,
|
||||
t_testprice.*
|
||||
from
|
||||
t_testpanel
|
||||
join t_testpaneldetail on T_TestPanelID = T_TestPanelDetailT_TestPanelID
|
||||
and T_TestPanelIsActive = 'Y' and T_TestPanelDetailIsActive = 'Y'
|
||||
join t_test on T_TestPanelDetailT_TestID = T_TestID
|
||||
and T_TestIsActive = 'Y'
|
||||
join t_testprice on T_TestID = T_TestPriceT_TestID
|
||||
and T_TestIsPrice = 'Y'
|
||||
and T_TestPriceM_MouCompanyID = ?
|
||||
and T_TestPriceIsActive = 'Y'
|
||||
where
|
||||
T_TestPanelID in ( $a_tpid )
|
||||
order by T_TestPanelID";
|
||||
$query = $this->db_smartone->query($sql,array($mouCompanyID));
|
||||
$xrows = $query->result_array();
|
||||
$rows = array();
|
||||
$prev_tpanel_id = 0;
|
||||
foreach($xrows as $r) {
|
||||
$tpanel_id = $r["T_TestPanelID"];
|
||||
if ($tpanel_id != $prev_tpanel_id) {
|
||||
$rows[] = array(
|
||||
"T_TestPanelID" => $r["T_TestPanelID"],
|
||||
"T_TestPanelName" => $r["T_TestPanelName"],
|
||||
"test" => array()
|
||||
);
|
||||
}
|
||||
$idx = count($rows) - 1;
|
||||
$rows[$idx]["test"][] = $r;
|
||||
$prev_tpanel_id = $tpanel_id;
|
||||
}
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$mouCompanyID = $prm["mouCompanyID"];
|
||||
|
||||
$sql_param = array($mouCompanyID, "%$search%");
|
||||
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_count(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
|
||||
$tot_count = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["data"];
|
||||
} else {
|
||||
$this->sys_error_db("PX count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$query = $this->db_smartone->query("CALL sp_fo_px_search(?, ?)", $sql_param);
|
||||
$this->clean_mysqli_connection($this->db_smartone->conn_id);
|
||||
// echo $this->db_smartone->last_query();
|
||||
// $query = $this->db_smartone->query($sql);
|
||||
if ($query)
|
||||
{
|
||||
$rows = $query->result_array();
|
||||
$id_to_remove = [];
|
||||
|
||||
// var_dump($rows);
|
||||
foreach ($rows as $k => $v)
|
||||
{
|
||||
$rows[$k]['requirement'] = [];
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$v['T_TestID']}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['requirement'] = json_decode($x->x);
|
||||
|
||||
$rows[$k]['nat_test'] = json_decode($v['nat_test']);
|
||||
$rows[$k]['child_test'] = json_decode($v['child_test']);
|
||||
|
||||
// IF PROFILE
|
||||
if ($v['px_type'] == "PR" || $v['px_type'] == "PXR") {
|
||||
|
||||
if ($v['T_TestID'] == null)
|
||||
{
|
||||
$id_to_remove[] = $k;
|
||||
continue;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
foreach ($rows[$k]['child_test'] as $l => $w) {
|
||||
$rows[$k]['child_test'][$l]->requirement = [];
|
||||
$rows[$k]['child_test'][$l]->nat_test = json_decode($w->nat_test);
|
||||
$x = $this->db_smartone->query("SELECT fn_fo_requirement_get('{$w->Nat_TestID}') x")
|
||||
->row();
|
||||
if ($x->x != null)
|
||||
$rows[$k]['child_test'][$l]->requirement = json_decode($x->x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// REMOVE INDEXES
|
||||
|
||||
foreach ($id_to_remove as $l => $w)
|
||||
{ $x = $w - $l; array_splice($rows, $x, 1); }
|
||||
|
||||
$result = array("total" => $tot_count, "records" => (array) $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_price()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$r = [];
|
||||
|
||||
$sql_param = array($prm['test_id'], date('Y-m-d'), $prm['cito'], $prm['mou_id']);
|
||||
$sql = "select fn_price(?, ?, ?, ?) as price";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query) {
|
||||
$r = $query->result_array()[0];
|
||||
$r = json_decode($r['price']);
|
||||
$this->sys_ok($r);
|
||||
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("get price", $this->db_smartone);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function get_appx_schedule()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$r = [];
|
||||
|
||||
$sql_param = array($prm['test_ids']);
|
||||
$sql = "select fn_fo_find_promise_by_px(?) as x";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
|
||||
if ($query) {
|
||||
$r = $query->result_array()[0];
|
||||
$r = $r['x'];
|
||||
$this->sys_ok($r);
|
||||
|
||||
exit;
|
||||
} else {
|
||||
$this->sys_error_db("get schedule", $this->db_smartone);
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
237
one-api/application/controllers/mockup/fo/result/Done.php
Normal file
237
one-api/application/controllers/mockup/fo/result/Done.php
Normal file
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
class Done 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;
|
||||
}
|
||||
|
||||
$nolab = $prm["nolab"];
|
||||
$groupid = $prm["groupid"];
|
||||
//$subgroupid = $prm["subgroupid"];
|
||||
$join_group = '';
|
||||
if($groupid != '0'){
|
||||
$join_group = "JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID AND Nat_GroupID = {$groupid}";
|
||||
}
|
||||
/*$join_subgroup = '';
|
||||
if($subgroupid != 0){
|
||||
$join_group = "JOIN nat_subgroup ON T_TestNat_SubgroupID = Nat_SubgroupID AND Nat_SubgroupID = {$subgroupid}";
|
||||
}*/
|
||||
|
||||
if(!isset($prm['current_page']))
|
||||
$prm['current_page'] = 1;
|
||||
|
||||
$sql_where = "WHERE Result_FrontOfficeStatus = 'S' AND JSON_CONTAINS(Result_FrontOfficeIds,T_OrderDetailID)";
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
//$sql_param = array();
|
||||
if ($nolab != "" ) {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( T_OrderHeaderLabNumber like '%$nolab%' OR M_PatientName like '%$nolab%' )";
|
||||
}
|
||||
|
||||
/*if ($nama != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " M_PatientName like '%$nama%' ";
|
||||
}*/
|
||||
|
||||
$sql = "SELECT Result_FrontOfficeID as xid,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderLabNumber as ordernumber,
|
||||
UPPER(CONCAT(M_TitleName,' ',M_PatientName)) as patient_fullname,
|
||||
Result_FrontOfficeTestName as test_name,
|
||||
'N' as chex
|
||||
FROM result_frontoffice
|
||||
join t_orderheader ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND JSON_CONTAINS(Result_FrontOfficeIds, T_OrderDetailID)
|
||||
$join_group
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
$sql_where
|
||||
GROUP BY Result_FrontOfficeID
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
|
||||
$result = array("total" => count($rst), "records" => $rows, "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getkerajaan(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//$rst = array(array('id'=>0,'name'=>'Semua'));
|
||||
|
||||
$sql = "SELECT 0 as id, 'Semua' as name UNION SELECT Nat_GroupID as id, Nat_GroupName as name FROM nat_group WHERE Nat_GroupIsActive = 'Y'";
|
||||
$rst_db = $this->db_onedev->query($sql)->result_array();
|
||||
//$c = array_combine($rst,$rst_db);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rst_db
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function dosend(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$selected = $prm['selected'];
|
||||
|
||||
foreach($selected as $k => $v){
|
||||
$sql = "UPDATE result_frontoffice SET Result_FrontOfficeStatus = 'R' WHERE Result_FrontOfficeID = {$v['xid']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function savereceiver(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$rows = array();
|
||||
$sql = "INSERT INTO result_receive (
|
||||
Result_ReceiveT_OrderHeaderID,
|
||||
Result_ReceiveT_OrderPromiseID,
|
||||
Result_ReceiveType,
|
||||
Result_ReceiveTypeReceiver,
|
||||
Result_ReceiveName,
|
||||
Result_ReceiveHp,
|
||||
Result_ReceiveInfo,
|
||||
Result_ReceiveDateTime,
|
||||
Result_ReceiveUserID
|
||||
)VALUES(
|
||||
{$prm['patient']['T_OrderHeaderID']},
|
||||
{$prm['patient']['T_OrderPromiseID']},
|
||||
'OFFICE',
|
||||
'{$prm['selected_receiver_type']['id']}',
|
||||
'{$prm['receiver']['name']}',
|
||||
'{$prm['receiver']['hp']}',
|
||||
'{$prm['receiver']['info']}',
|
||||
NOW(),
|
||||
{$userid}
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Result_ReceiveTypeReceiver = '{$prm['selected_receiver_type']['id']}',
|
||||
Result_ReceiveName = '{$prm['receiver']['name']}',
|
||||
Result_ReceiveInfo = '{$prm['receiver']['info']}',
|
||||
Result_ReceiveDateTime = NOW(),
|
||||
Result_ReceiveUserID = {$userid},
|
||||
Result_ReceiveIsActive = 'Y'
|
||||
";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$sql = "UPDATE result_sendemail SET Result_SendEmailStatus = 'S', Result_SendEmailUserID = {$userid}
|
||||
WHERE Result_SendEmailT_OrderHeaderID = {$prm['patient']['T_OrderHeaderID']} AND
|
||||
Result_SendEmailStatus = 'P' AND Result_SendEmailActionBy = 'FO'";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
$sql = "SELECT * FROM result_sendemail
|
||||
WHERE Result_SendEmailT_OrderHeaderID = {$prm['patient']['T_OrderHeaderID']} AND
|
||||
Result_SendEmailStatus = 'P' AND Result_SendEmailActionBy = 'FO'";
|
||||
$dt_rst = $this->db_onedev->query($sql)->result_array();
|
||||
foreach($dt_rst as $k => $v){
|
||||
$dt_log = json_encode($v);
|
||||
$sql = "INSERT INTO one_log.log_resultsendemail (
|
||||
Log_ResultSendEmailDatetime,
|
||||
Log_ResultSendEmailJson,
|
||||
Log_ResultSendEmailUserID
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$dt_log}',
|
||||
{$userid}
|
||||
)";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateemail(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user['M_UserID'];
|
||||
$rows = array();
|
||||
$id = $prm['id'];
|
||||
$sql = "UPDATE t_orderdelivery SET T_OrderDeliveryDestination = '{$prm['edited_email']}', T_OrderDeliveryUserID = {$userid} WHERE T_OrderDeliveryID = {$id}";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array ("total" => 0, "records" => array());
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
867
one-api/application/controllers/mockup/fo/result/Patient.php
Normal file
867
one-api/application/controllers/mockup/fo/result/Patient.php
Normal file
@@ -0,0 +1,867 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
|
||||
function add_verifications_label($orderid){
|
||||
$query = " SELECT Result_VerificationsID as id,
|
||||
IFNULL(Result_VerificationsValueID,0) as xid,
|
||||
IFNULL(Result_VerificationsValueCheck,'N') as chex,
|
||||
IF(ISNULL(Result_VerificationsValueID),'',Result_VerificationsValueNote) as note,
|
||||
Result_VerificationsLabel as label
|
||||
FROM result_verifications
|
||||
LEFT JOIN result_verifications_value ON Result_VerificationsValueResult_VerificationsID = Result_VerificationsID AND
|
||||
Result_VerificationsValueSo_ResultEntryID = $orderid
|
||||
WHERE
|
||||
Result_VerificationIsActive = 'Y'
|
||||
GROUP BY Result_VerificationsID
|
||||
";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$nolab = $prm["nolab"];
|
||||
$nama = $prm["name"];
|
||||
$status = $prm["status"];
|
||||
$datepromise = $prm["startdate"];
|
||||
$having = '';
|
||||
if($status == 'R'){
|
||||
$having = 'HAVING all_test_status = 0';
|
||||
}
|
||||
if($status == 'X'){
|
||||
$having = 'HAVING all_test_status > 0';
|
||||
}
|
||||
$absolut_join = 'left';
|
||||
$insull = ' AND ISNULL(Result_ReceiveID)';
|
||||
$orderby = 'ORDER BY iscito DESC, T_OrderHeaderID ASC';
|
||||
$donelimit = '';
|
||||
if($status == 'D'){
|
||||
$having = '';
|
||||
$insull = '';
|
||||
$absolut_join = '';
|
||||
$orderby = 'ORDER BY iscito DESC, T_OrderHeaderID DESC';
|
||||
$donelimit = " AND DATE(Result_ReceiveDateTime ) >= DATE_ADD(CONCAT(CURDATE(),' 23:59:59'), INTERVAL -1 WEEK)";
|
||||
}
|
||||
|
||||
if(!isset($prm['current_page']))
|
||||
$prm['current_page'] = 1;
|
||||
|
||||
$sql_where = "WHERE T_OrderDetailIsActive = 'Y' ";
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
//$sql_param = array();
|
||||
if ($nolab != "") {
|
||||
if ($sql_where != "") {
|
||||
$sql_where .=" and ";
|
||||
}
|
||||
$sql_where .= " ( T_OrderHeaderLabNumber like '%$nolab%' AND M_PatientName like '%$nolab%' ) ";
|
||||
//$prm['current_page'] = 1;
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) as total FROM (
|
||||
SELECT T_OrderHeaderID,
|
||||
T_OrderPromiseID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderIsCito as iscito,
|
||||
T_OrderPromiseDateTime,
|
||||
T_OrderHeaderLabNumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
M_PatientHP as patient_hp,
|
||||
M_PatientPhotoThumb as photo,
|
||||
M_CompanyName,
|
||||
Last_StatusPaymentIsLunas as status_lunas,
|
||||
M_MouIsBill as status_bill,
|
||||
fn_fo_check_status_ready_handover(T_OrderHeaderID,T_OrderPromiseID) as all_test_status
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseDateTime < '{$datepromise} 23:59:59'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
LEFT JOIN result_frontoffice ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_FrontOfficeIds,T_OrderDetailID)
|
||||
$absolut_join JOIN result_receive ON Result_ReceiveT_OrderHeaderID = T_OrderHeaderID AND Result_ReceiveT_OrderPromiseID = T_OrderPromiseID
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y' $insull $donelimit
|
||||
GROUP BY T_OrderHeaderID, T_OrderPromiseID
|
||||
$having
|
||||
) xz";
|
||||
//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("m_doctor count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_OrderHeaderID,
|
||||
T_OrderPromiseID,
|
||||
T_OrderHeaderDate,
|
||||
T_OrderHeaderIsCito as iscito,
|
||||
T_OrderPromiseDateTime,
|
||||
T_OrderHeaderLabNumber,
|
||||
CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patient_fullname,
|
||||
M_PatientHP as patient_hp,
|
||||
M_PatientPhotoThumb as photo,
|
||||
DATE_FORMAT(T_OrderPromiseDateTime,'%d-%m-%Y %H:%i') as date_promise,
|
||||
M_CompanyName,
|
||||
'{$status}' as status,
|
||||
Last_StatusPaymentIsLunas as status_lunas,
|
||||
M_MouIsBill as status_bill,
|
||||
fn_fo_check_status_ready_handover(T_OrderHeaderID,T_OrderPromiseID) as all_test_status,
|
||||
Result_ReceiveName as receiver,
|
||||
M_StaffName as staff_name,
|
||||
DATE_FORMAT(T_OrderPromiseDateTime,'%d-%m-%Y %H:%i') as date_received
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
JOIN last_statuspayment ON Last_StatusPaymentT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID AND T_OrderPromiseDateTime < '{$datepromise} 23:59:59'
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
LEFT JOIN result_frontoffice ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_FrontOfficeIds,T_OrderDetailID)
|
||||
$absolut_join JOIN result_receive ON Result_ReceiveT_OrderHeaderID = T_OrderHeaderID AND Result_ReceiveT_OrderPromiseID = T_OrderPromiseID
|
||||
LEFT JOIN m_user ON Result_ReceiveUserID = M_UserID
|
||||
LEFT JOIN m_staff ON M_UserM_StaffID = M_StaffID
|
||||
WHERE
|
||||
T_OrderDetailIsActive = 'Y' $insull $donelimit
|
||||
GROUP BY T_OrderHeaderID, T_OrderPromiseID
|
||||
$having
|
||||
$orderby
|
||||
limit $number_limit offset $number_offset";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
if($rows){
|
||||
/*foreach($rows as $k => $v){
|
||||
$rows[$k]['verifications'] = $this->add_verifications_label($v['trx_id']);
|
||||
}*/
|
||||
}
|
||||
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> '');
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
$xprm = $this->sys_input;
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
//# ambil parameter input
|
||||
|
||||
//print_r($xprm);
|
||||
$prm = $xprm['patient'];
|
||||
$xstatus = $xprm['act'];
|
||||
$fostatusid = 3;
|
||||
$fologcode = 'FO.VERIFICATION.CONFIRM';
|
||||
$id = $prm['T_OrderHeaderID'];
|
||||
echo $xstatus;
|
||||
if($xstatus == 'N'){
|
||||
$fostatusid = 4;
|
||||
$fologcode = 'FO.VERIFICATION.REJECT';
|
||||
}else{
|
||||
|
||||
$this->save_barcode_new($id);
|
||||
}
|
||||
|
||||
|
||||
//print_r($prm);
|
||||
$xverificationnote = $prm['verification_note'];
|
||||
//echo $xverificationnote;
|
||||
|
||||
$sql = "update t_orderheader
|
||||
set
|
||||
T_OrderHeaderVerificationNote = '{$xverificationnote}'
|
||||
where
|
||||
T_OrderHeaderID = $id";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
|
||||
/*$xverification_patient = $this->saveverifications($id,$prm['verification_patient'],'PATIENT',$xuserid);
|
||||
$xverification_doctor = $this->saveverifications($id,$prm['verification_doctor'],'DOCTOR',$xuserid);
|
||||
$xverification_companymou = $this->saveverifications($id,$prm['verification_companymou'],'COMPANY',$xuserid);
|
||||
$xverification_payment = $this->saveverifications($id,$prm['verification_payment'],'PAYMENT',$xuserid);
|
||||
$xverification_info = $this->saveverifications($id,$prm['verification_info'],'INFO',$xuserid);
|
||||
|
||||
$xverification_delivery = $this->saveverification_delivery($id,$prm['verification_delivery'],$xuserid);
|
||||
$xverification_px = $this->saveverification_px($id,$prm['verification_px'],$xuserid);*/
|
||||
|
||||
$sql = "insert into fo_status(
|
||||
Fo_StatusDate,
|
||||
Fo_StatusT_OrderHeaderID,
|
||||
Fo_StatusM_StatusID,
|
||||
Fo_StatusM_UserID,
|
||||
Fo_StatusCreated,
|
||||
Fo_StatusUpdated)
|
||||
values( now(), ?, ?, ?, now(),now())";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$fostatusid,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_status insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$data_log = array();
|
||||
$data_log['orderid'] = $id;
|
||||
/*$data_log['verification_patient'] = $prm['verification_patient'];
|
||||
$data_log['verification_doctor'] = $prm['verification_doctor'];
|
||||
$data_log['verification_companymou'] = $prm['verification_companymou'];
|
||||
$data_log['verification_payment'] = $prm['verification_payment'];
|
||||
$data_log['verification_info'] = $prm['verification_info'];
|
||||
$data_log['verification_px'] = $prm['verification_px'];
|
||||
$data_log['verification_delivery'] = $prm['verification_delivery'];*/
|
||||
|
||||
$json_dt_log = json_encode($data_log);
|
||||
$sql = "insert into one_log.log_fo(
|
||||
Log_FoDate,
|
||||
Log_FoCode,
|
||||
Log_FoJson,
|
||||
Log_FoUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.fo_log insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($xstatus == 'Y'){
|
||||
$msg = 'Verifikasi berhasil dilakukan';
|
||||
}
|
||||
else{
|
||||
$msg = 'Tolak Verifikasi berhasil dilakukan';
|
||||
$sql = "INSERT INTO t_ordermessage (
|
||||
T_OrderMessageT_OrderHeaderID,
|
||||
T_OrderMessageType,
|
||||
T_OrderMessageMessage,
|
||||
T_OrderMessageFromUserID,
|
||||
T_OrderMessageCreated,
|
||||
T_OrderMessageLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
{$id},
|
||||
'FO.VERIFICATION.REJECT',
|
||||
'{$xverificationnote}',
|
||||
{$xuserid},
|
||||
NOW(),
|
||||
NOW()
|
||||
)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.t_ordermessage insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$rows = array('message'=>$msg);
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function save_barcode_new($orderid){
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
|
||||
$query =" SELECT T_SampleTypeID as id,
|
||||
T_SampleTypeName as name,
|
||||
'' as children
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$orderid}
|
||||
GROUP BY T_SampleTypeID
|
||||
";
|
||||
//echo $query ;
|
||||
$barcodes = $this->db_onedev->query($query)->result();
|
||||
foreach($barcodes as $k => $v){
|
||||
$query = "SELECT T_SampleTypeID as id, IFNULL(T_BarcodeLabID,0) as xid,
|
||||
IF(ISNULL(T_BarcodeLabID),'Y',T_BarcodeLabIsActive) as chex,
|
||||
T_TestName as testname,
|
||||
T_SampleTypeName as samplename,
|
||||
IF(ISNULL(T_BarcodeLabID),CONCAT(T_OrderHeaderLabNumber,'.',T_SampleTypeID,'.',1),T_BarcodeLabBarcode) as barcodenumber
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderid} AND T_SampleTypeID = {$v->id}
|
||||
GROUP BY T_BarcodeLabID ";
|
||||
$v->children = $this->db_onedev->query($query)->result_array();
|
||||
//$v->children = $barcode_data;
|
||||
foreach($v->children as $ki => $vi){
|
||||
if($vi['chex'] == 'N')
|
||||
$v->children[$ki]['chex'] = false;
|
||||
else
|
||||
$v->children[$ki]['chex'] = true;
|
||||
$sql = "insert into t_barcodelab(
|
||||
T_BarcodeLabT_OrderHeaderID,
|
||||
T_BarcodeLabBarcode,
|
||||
T_BarcodeLabT_SampleTypeID,
|
||||
T_BarcodeLabCreated,
|
||||
T_BarcodeLabLastUpdated,
|
||||
T_BarcodeLabUserID)
|
||||
values( ?, ?, ?, now(),now(),?)";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid,
|
||||
$v->children[$ki]['barcodenumber'],
|
||||
$v->children[$ki]['id'],
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
// echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_barcodelab insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//insert log
|
||||
$supplies = array();
|
||||
$query =" SELECT M_SuppliesID as id,
|
||||
IFNULL(T_OrderSuppliesID,0) as xid,
|
||||
IF(ISNULL(T_OrderSuppliesID),'N',T_OrderSuppliesIsActive) as chex,
|
||||
IFNULL(T_OrderSuppliesQty,1) as qty,
|
||||
M_SuppliesName as name,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as lastupdated,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as tx_lastupdated
|
||||
FROM m_supplies
|
||||
JOIN t_ordersupplies ON T_OrderSuppliesT_OrderHeaderID = $orderid AND T_OrderSuppliesM_SuppliesID = M_SuppliesID
|
||||
WHERE
|
||||
M_SuppliesIsActive = 'Y'
|
||||
";
|
||||
//echo $query ;
|
||||
$supplies = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
foreach($supplies as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$supplies[$k]['chex'] = false;
|
||||
else
|
||||
$supplies[$k]['chex'] = true;
|
||||
}
|
||||
|
||||
$dt_log = array('orderid'=>$orderid,'supplies'=>$supplies,'barcode'=>$barcodes);
|
||||
$fologcode = 'FO.Verification.BarcodeSupplies';
|
||||
$json_dt_log = json_encode($dt_log);
|
||||
$sql = "insert into one_log.log_supplies_barcode(
|
||||
Log_SuppliesBarcodeDate,
|
||||
Log_SuppliesBarcodeCode,
|
||||
Log_SuppliesBarcodeJson,
|
||||
Log_SuppliesBarcodeUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.log_supplies_barcode insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function saveverifications($id,$verifications,$type,$userid)
|
||||
{
|
||||
try {
|
||||
//$xverificationtypeid = $this->db_onedev->query("SELECT * FROM fo_verificationtype WHERE Fo_VerificationTypeGroup = '{$type}' AND Fo_VerificationTypeIsActive = 'Y'")->row()->Fo_VericationTypeID;
|
||||
//echo $xverificationtypeid;
|
||||
//print_r($verifications);
|
||||
foreach($verifications as $k => $v){
|
||||
//print_r($v);
|
||||
if(intval($v['xid']) == 0){
|
||||
$sql = "insert into fo_verification(
|
||||
Fo_VerificationT_OrderHeaderID,
|
||||
Fo_VerificationFo_VericationTypeID,
|
||||
Fo_VerificationIsOK,
|
||||
Fo_VerificationReason,
|
||||
Fo_VerificationCreated,
|
||||
Fo_VerificationLastUpdated,
|
||||
Fo_VerificationUserID)
|
||||
values( ?, ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['id'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_verification insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveverification_delivery($id,$deliveries,$userid)
|
||||
{
|
||||
try {
|
||||
foreach($deliveries as $k => $v){
|
||||
if($v['id'] === 0){
|
||||
$sql = "insert into fo_verification_delivery_add(
|
||||
Fo_VerificationDeliveryAddT_OrderHeaderID,
|
||||
Fo_VerificationDeliveryAddM_DeliveryID,
|
||||
Fo_VerificationDeliveryAddM_DeliveryTypeID,
|
||||
Fo_VerificationDeliveryAddDestination,
|
||||
Fo_VerificationDeliveryAddAddressID,
|
||||
Fo_VerificationDeliveryAddM_KelurahanID,
|
||||
Fo_VerificationDeliveryAddOK,
|
||||
Fo_VerificationDeliveryAddReason,
|
||||
Fo_VerificationDeliveryAddCreated,
|
||||
Fo_VerificationDeliveryAddLastUpdated,
|
||||
Fo_VerificationDeliveryAddUserID)
|
||||
values( ?, ?, ?, ?,?,?,?,?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['deliveryid'],
|
||||
$v['typedeliveryid'],
|
||||
$v['destination'],
|
||||
$v['addressid'],
|
||||
$v['vilageid'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("fo_verification_delivery_add insert");
|
||||
exit;
|
||||
}
|
||||
|
||||
}else{
|
||||
$sql = "insert into fo_verification_delivery(
|
||||
Fo_VerificationDeliveryT_OrderHeaderID,
|
||||
Fo_VerificationDeliveryT_OrderDeliveryID,
|
||||
Fo_VerificationDeliveryIsOK,
|
||||
Fo_VerificationDeliveryReason,
|
||||
Fo_VerificationDeliveryCreated,
|
||||
Fo_VerificationDeliveryLastUpdated,
|
||||
Fo_VerificationDeliveryUserID)
|
||||
values( ?, ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['id'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
echo $this->db_onedev->last_query();
|
||||
$this->sys_error_db("fo_verification_delivery insert");
|
||||
exit;
|
||||
}
|
||||
//echo $this->db_onedev->last_query();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function lookup_barcodes()
|
||||
{
|
||||
try {
|
||||
$prm = $this->sys_input;
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$sql = "SELECT T_BarcodeLabID as id, 'barcode' as type,T_BarcodeLabID,T_BarcodeLabBarcode, T_BarcodeLabCounter, T_SampleTypeName, 'N' as chex
|
||||
FROM t_barcodelab
|
||||
JOIN t_sampletype ON T_BarcodeLabT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
T_BarcodeLabT_OrderHeaderID = {$prm['ohid']} AND T_BarcodeLabIsActive = 'Y'
|
||||
UNION
|
||||
SELECT T_OrderHeaderID as id, 'formulir' as type, 0,T_OrderHeaderLabNumber as T_BarcodeLabBarcode, 1, 'Formulir' as T_SampleTypeName, 'N' as chex
|
||||
FROM t_orderheader
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['ohid']}
|
||||
";
|
||||
//echo $sql;
|
||||
|
||||
$rows = $this->db_onedev->query($sql)->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows[$k]['chex'] = false;
|
||||
else
|
||||
$rows[$k]['chex'] = true;
|
||||
}
|
||||
}
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function saveverification_px($id,$pxs,$userid)
|
||||
{
|
||||
try {
|
||||
foreach($pxs as $k => $v){
|
||||
|
||||
if(intval($v['id']) == 0){
|
||||
$cxh = $v['chex'] == true ?'Y':'N';
|
||||
$sql = "insert into fo_verification_test_add(
|
||||
Fo_VerificationTestAddT_OrderHeaderID,
|
||||
Fo_VerificationTestAddT_TestID,
|
||||
Fo_VerificationTestAddBruto,
|
||||
Fo_VerificationTestAddDiscount,
|
||||
Fo_VerificationTestAddTotal,
|
||||
Fo_VerificationTestAddIsOK,
|
||||
Fo_VerificationTestAddIsCito,
|
||||
Fo_VerificationTestAddCreated,
|
||||
Fo_VerificationTestAddLastUpdated,
|
||||
Fo_VerificationTestAddUserID)
|
||||
values( $id, {$v['pxid']}, {$v['bruto']}, {$v['discount']},{$v['total']},'{$cxh}','{$v['flagcito']}',now(),now(),{$userid})";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_verification_test_add insert");
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$sql = "insert into fo_verification_test(
|
||||
Fo_VerificationTestT_OrderHeaderID,
|
||||
Fo_VerificationTestT_OrderDetailID,
|
||||
Fo_VerificationTestIsOK,
|
||||
Fo_VerificationTestReason,
|
||||
Fo_VerificationTestCreated,
|
||||
Fo_VerificationTestLastUpdated,
|
||||
Fo_VerificationTestUserID)
|
||||
values( ?, ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$id,
|
||||
$v['id'],
|
||||
$v['chex'] == true ?'Y':'N',
|
||||
$v['note'],
|
||||
$userid
|
||||
)
|
||||
);
|
||||
//echo $this->db_onedev->last_query();
|
||||
if (!$query) {
|
||||
$this->sys_error_db("fo_verification_test insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
function verify(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$xstatus = $prm['act'];
|
||||
if($xstatus == 'Y'){
|
||||
$msg = "Berhasil melakukan verifikasi";
|
||||
$query =" INSERT INTO result_verifications_value (
|
||||
Result_VerificationsValueSo_ResultEntryID,
|
||||
Result_VerificationsValueResult_VerificationsID,
|
||||
Result_VerificationsValueCheck,
|
||||
Result_VerificationsValueNote,
|
||||
Result_VerificationsValueUserID,
|
||||
Result_VerificationsValueCreated
|
||||
)
|
||||
SELECT {$prm['trx_id']},
|
||||
Result_VerificationsID,
|
||||
'Y',
|
||||
'',
|
||||
{$userid},
|
||||
NOW()
|
||||
FROM result_verifications
|
||||
WHERE
|
||||
Result_VerificationIsActive = 'Y'
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Result_VerificationsValueCheck = 'Y',
|
||||
Result_VerificationsValueNote = '',
|
||||
Result_VerificationsValueUserID = {$userid},
|
||||
Result_VerificationsValueLastUpdated = NOW()
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
$sql = "UPDATE so_resultentry SET So_ResultEntryStatus = 'VAL2' , So_ResultEntryValidation2 = 'Y' WHERE So_ResultEntryID = {$prm['trx_id']}";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
else{
|
||||
$msg = "Tolak untuk perbaikan";
|
||||
$verifications = $prm['verifications'];
|
||||
foreach($verifications as $k => $v){
|
||||
$chx = $v['chex'] == true ?'Y':'N';
|
||||
$query =" INSERT INTO result_verifications_value (
|
||||
Result_VerificationsValueSo_ResultEntryID,
|
||||
Result_VerificationsValueResult_VerificationsID,
|
||||
Result_VerificationsValueCheck,
|
||||
Result_VerificationsValueNote,
|
||||
Result_VerificationsValueUserID,
|
||||
Result_VerificationsValueCreated
|
||||
)
|
||||
values( {$prm['trx_id']},
|
||||
{$v['id']},
|
||||
'{$chx}',
|
||||
'{$v['note']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
Result_VerificationsValueCheck = '{$chx}',
|
||||
Result_VerificationsValueNote = '{$v['note']}',
|
||||
Result_VerificationsValueUserID = {$userid},
|
||||
Result_VerificationsValueLastUpdated = NOW()
|
||||
";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array ("total" => 0, "records" => array('status'=>'OK','message'=>$msg));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
|
||||
public function getstatuspergroup()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$rows = array();
|
||||
|
||||
$sql =" SELECT Last_StatusPaymentBillTotal as total_bill,
|
||||
Last_StatusPaymentPaid as paid,
|
||||
Last_StatusPaymentUnpaid as unpaid,
|
||||
Last_StatusPaymentIsLunas as status
|
||||
FROM last_statuspayment
|
||||
WHERE
|
||||
Last_StatusPaymentT_OrderHeaderID = {$prm['T_OrderHeaderID']} ";
|
||||
$rows['info_bill'] = $this->db_onedev->query($sql)->row_array();
|
||||
|
||||
|
||||
$sql =" SELECT T_OrderDeliveryID as id,
|
||||
IFNULL(Fo_VerificationDeliveryID,0) as xid,
|
||||
M_DeliveryTypeCode as code,
|
||||
IF(ISNULL(Fo_VerificationDeliveryID),'N',Fo_VerificationDeliveryIsOK) as chex,
|
||||
M_DeliveryID as deliveryid,
|
||||
M_DeliveryTypeID as typedeliveryid,
|
||||
T_OrderDeliveryM_KelurahanID as vilageid,
|
||||
IF(ISNULL(Fo_VerificationDeliveryID),'',Fo_VerificationDeliveryReason) as note,
|
||||
'reguler' as type,
|
||||
CASE
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 1 THEN M_DeliveryName
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN CONCAT(M_DeliveryName)
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN CONCAT(M_DeliveryName)
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 ) THEN CONCAT(M_DeliveryName)
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 ) THEN CONCAT(M_DeliveryName)
|
||||
ELSE
|
||||
CONCAT(M_DeliveryName)
|
||||
END as label,
|
||||
CASE
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 1 THEN ''
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN M_DoctorAddressDescription
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN M_PatientAddressDescription
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 ) THEN M_DoctorHP
|
||||
WHEN ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 ) THEN M_PatientHP
|
||||
ELSE
|
||||
T_OrderDeliveryDestination
|
||||
END as destination,
|
||||
CASE
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 4 THEN M_DoctorAddressID
|
||||
WHEN T_OrderDeliveryM_DeliveryID = 2 THEN M_PatientAddressID
|
||||
ELSE
|
||||
0
|
||||
END as addressid
|
||||
FROM t_orderdelivery
|
||||
JOIN t_orderheader ON T_OrderDeliveryT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_delivery ON T_OrderDeliveryM_DeliveryID = M_DeliveryID
|
||||
JOIN m_deliverytype ON T_OrderDeliveryM_DeliveryTypeID = M_DeliveryTypeID
|
||||
LEFT JOIN m_doctoraddress ON T_OrderDeliveryAddressID = M_DoctorAddressID AND T_OrderDeliveryM_DeliveryID = 4
|
||||
LEFT JOIN m_patientaddress ON T_OrderDeliveryAddressID = M_PatientAddressID AND T_OrderDeliveryM_DeliveryID = 2
|
||||
LEFT JOIN fo_verification_delivery ON Fo_VerificationDeliveryT_OrderHeaderID = T_OrderDeliveryT_OrderHeaderID AND Fo_VerificationDeliveryIsActive = 'Y'
|
||||
LEFT JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID AND ( T_OrderDeliveryM_DeliveryID = 7 OR T_OrderDeliveryM_DeliveryID = 9 )
|
||||
LEFT JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID AND ( T_OrderDeliveryM_DeliveryID = 6 OR T_OrderDeliveryM_DeliveryID = 8 )
|
||||
WHERE
|
||||
T_OrderDeliveryT_OrderHeaderID = {$prm['T_OrderHeaderID']} AND T_OrderDeliveryIsActive = 'Y'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
|
||||
";
|
||||
//echo $query ;
|
||||
$rows['info_deliveries'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "
|
||||
SELECT T_OrderHeaderID,
|
||||
T_OrderPromiseID,
|
||||
T_OrderPromiseDateTime,
|
||||
T_OrderHeaderLabNumber,
|
||||
UPPER(DocumentationGroupName) as DocumentationGroupName,
|
||||
GROUP_CONCAT(CONCAT(T_TestName,'^',IFNULL(Result_FrontOfficeStatus,'X'))) as status_test_name,
|
||||
GROUP_CONCAT(IFNULL(Result_FrontOfficeStatus,'X')) as status,
|
||||
'' as status_pergroup,
|
||||
'' as details
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_orderpromise ON T_OrderDetailT_OrderPromiseID = T_OrderPromiseID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID AND T_TestIsResult = 'Y'
|
||||
LEFT JOIN result_frontoffice ON Result_FrontOfficeT_OrderHeaderID = T_OrderHeaderID AND
|
||||
JSON_CONTAINS(Result_FrontOfficeIds,T_OrderDetailID)
|
||||
JOIN documentation_group_detail ON DocumentationGroupDetailNat_SubGroupID = T_TestNat_SubGroupID
|
||||
JOIN documentation_group ON DocumentationGroupDetailDocumentationGroupID = DocumentationGroupID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$prm['T_OrderHeaderID']} AND T_OrderPromiseID = {$prm['T_OrderPromiseID']} AND T_OrderDetailIsActive = 'Y'
|
||||
GROUP BY DocumentationGroupID
|
||||
|
||||
";
|
||||
|
||||
$rows['info_test'] = $this->db_onedev->query($sql)->result_array();
|
||||
if($rows['info_test']){
|
||||
foreach($rows['info_test'] as $k => $v){
|
||||
$rows['info_test'][$k]['status_pergroup'] = 'R';
|
||||
$x_arr = explode(',',$v['status']);
|
||||
if(in_array('X',$x_arr)){
|
||||
$rows['info_test'][$k]['status_pergroup'] = 'X';
|
||||
}
|
||||
if($v['DocumentationGroupName'] != 'LAB'){
|
||||
|
||||
$z_arr = explode(',',$v['status_test_name']);
|
||||
$for_details = array();
|
||||
foreach($z_arr as $i => $val){
|
||||
$xx_arr = explode('^',$val);
|
||||
array_push($for_details,array('testname'=>$xx_arr[0],'status'=>$xx_arr[1]));
|
||||
}
|
||||
$rows['info_test'][$k]['details'] = $for_details;
|
||||
}
|
||||
else{
|
||||
$rows['info_test'][$k]['DocumentationGroupName'] = 'Laboratorium';
|
||||
$rows['info_test'][$k]['details'] = array(array('testname'=>'Pemeriksaan Laboratorium','status'=>$rows['info_test'][$k]['status_pergroup']));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$result = array ("total" => 0, "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
<?php
|
||||
class Done 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search = $prm["search"];
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql_where = "WHERE (T_OrderHeaderDate BETWEEN CONCAT('{$start_date}',' ','00:00:00') AND CONCAT('{$end_date}',' ','23:59:59')) AND T_OrderHeaderIsActive = 'Y'";
|
||||
if($search != ''){
|
||||
$sql_where = "WHERE (T_OrderHeaderLabNumber LIKE '%{$search}%' OR M_PatientName LIKE '%{$search}%' ) AND T_OrderHeaderIsActive = 'Y'";
|
||||
}
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM(
|
||||
SELECT
|
||||
T_OrderHeaderID,
|
||||
fn_fo_verification_last_status(T_OrderHeaderID,3) as check_status,
|
||||
fn_fo_verification_status_done(T_OrderHeaderID) as check_status_spv
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_status ON Last_StatusM_StatusID = M_StatusID
|
||||
LEFT JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressNote = 'utama'
|
||||
LEFT JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
LEFT JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
LEFT JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID
|
||||
JOIN m_doctoraddress ON T_OrderHeaderSenderM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
$sql_where
|
||||
HAVING check_status > 0 OR check_status_spv > 0
|
||||
ORDER BY T_OrderHeaderID ASC
|
||||
) x
|
||||
";
|
||||
//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
|
||||
M_PatientNoReg,
|
||||
fn_fo_verification_get_paid(T_OrderHeaderID) as paid,
|
||||
T_OrderHeaderTotal,
|
||||
M_MouIsBill,
|
||||
IF(M_MouIsBill = 'N','Tidak ditagihkan','Ditagihkan') as texttagihan,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as M_PatientName,
|
||||
M_PatientHP,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
||||
M_PatientAddressDescription as M_PatientAddress,
|
||||
M_CityName as CityUtama,
|
||||
M_PatientNote,
|
||||
M_PatientHP,
|
||||
M_DoctorHP,
|
||||
T_OrderHeaderID as ohid,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderDate,
|
||||
IF(M_StatusID = 2,'Baru',IF(M_StatusID = 3,'Verified','Ditolak')) as M_StatusName,
|
||||
T_OrderHeaderID, M_SexName,
|
||||
M_CompanyName,
|
||||
T_OrderHeaderM_CompanyID,
|
||||
T_OrderHeaderM_MouID,
|
||||
CONCAT(M_MouName,' ( ',DATE_FORMAT(M_MouStartDate,'%d-%m-%Y') ,' s/d ' , DATE_FORMAT(M_MouEndDate,'%d-%m-%Y'),' )') as mou,
|
||||
M_DoctorName,
|
||||
M_DoctorAddressDescription as M_DoctorAddress,
|
||||
T_OrderHeaderVerificationNote as verification_note,
|
||||
fn_fo_verification_last_status(T_OrderHeaderID,3) as check_status,
|
||||
fn_fo_verification_status_done(T_OrderHeaderID) as check_status_spv,
|
||||
T_OrderHeaderDate as orderdate
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_status ON Last_StatusM_StatusID = M_StatusID
|
||||
LEFT JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressNote = 'utama'
|
||||
LEFT JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
LEFT JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
LEFT JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID
|
||||
JOIN m_doctoraddress ON T_OrderHeaderSenderM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
$sql_where
|
||||
HAVING check_status > 0 OR check_status_spv > 0
|
||||
ORDER BY T_OrderHeaderID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$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 getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//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 save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
245
one-api/application/controllers/mockup/fo/supervisor/Patient.php
Normal file
245
one-api/application/controllers/mockup/fo/supervisor/Patient.php
Normal file
@@ -0,0 +1,245 @@
|
||||
<?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 add_notes_bckp($orderid){
|
||||
$rst = array();
|
||||
$sql = "SELECT Fo_VerificationTypeLabelCorrection as label,
|
||||
Fo_VerificationReason as reason,
|
||||
Fo_VerificationTypeGroup as xgroup,
|
||||
Fo_VerificationTypeName as xname,
|
||||
'N' as chex
|
||||
FROM fo_verification
|
||||
JOIN fo_verificationtype ON Fo_VerificationFo_VericationTypeID = Fo_VericationTypeID
|
||||
WHERE
|
||||
Fo_VerificationIsOK = 'N' AND Fo_VerificationT_OrderHeaderID = {$orderid}";
|
||||
$other = $this->db_onedev->query($sql)->result_array();
|
||||
if($other){
|
||||
foreach($other as $k => $v){
|
||||
array_push($rst,$v);
|
||||
}
|
||||
}
|
||||
$sql = "
|
||||
SELECT
|
||||
IF(SUM(label) > 0, 'Perubahan pemeriksaan','') as label,
|
||||
GROUP_CONCAT(reason separator ',') as reason,
|
||||
'TEST' as xgroup,
|
||||
'ORDER.TEST' as xname,
|
||||
'N' as chex
|
||||
FROM (
|
||||
SELECT COUNT(*) as label,
|
||||
GROUP_CONCAT(CONCAT(T_OrderDetailT_TestName,'(-)') separator ',') as reason,
|
||||
Fo_VerificationTestT_OrderHeaderID as orderid
|
||||
FROM fo_verification_test
|
||||
JOIN t_orderdetail ON Fo_VerificationTestT_OrderDetailID = T_OrderDetailID
|
||||
WHERE
|
||||
Fo_VerificationTestT_OrderHeaderID = {$orderid} AND Fo_VerificationTestIsOK = 'N'
|
||||
GROUP BY Fo_VerificationTestT_OrderHeaderID
|
||||
UNION
|
||||
SELECT COUNT(*) as label,
|
||||
GROUP_CONCAT(CONCAT(T_TestName,'(+)') separator ',') as reason,
|
||||
Fo_VerificationTestAddT_OrderHeaderID as orderid
|
||||
FROM fo_verification_test_add
|
||||
JOIN t_test ON Fo_VerificationTestAddT_TestID = T_TestID
|
||||
WHERE
|
||||
Fo_VerificationTestAddT_OrderHeaderID = {$orderid} AND Fo_VerificationTestAddIsActive = 'Y'
|
||||
GROUP BY Fo_VerificationTestAddT_OrderHeaderID
|
||||
) a GROUP BY orderid
|
||||
";
|
||||
$tests = $this->db_onedev->query($sql)->result_array();
|
||||
if($tests){
|
||||
foreach($tests as $k => $v){
|
||||
array_push($rst,$v);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*) as xc
|
||||
FROM fo_verification_delivery_add
|
||||
WHERE
|
||||
Fo_VerificationDeliveryAddIsActive = 'Y' AND Fo_VerificationDeliveryAddT_OrderHeaderID = {$orderid} ";
|
||||
$delivery = $this->db_onedev->query($sql)->row();
|
||||
if($delivery->xc > 0){
|
||||
$xv = array('label'=>'Perubahan pengiriman hasil','reason'=>'Silahkan check perubahan pengiriman hasil','xgroup'=>'DELIVERY','xname'=>'ORDER.DELIVERY','chex'=>'N');
|
||||
array_push($rst,$xv);
|
||||
}
|
||||
|
||||
return $rst;
|
||||
}
|
||||
|
||||
public function add_notes($orderid){
|
||||
$rst = array();
|
||||
$sql = "SELECT Fo_VerificationsLabelName as label,
|
||||
Fo_VerificationsValueNote as reason,
|
||||
Fo_VerificationsLabelButton as button
|
||||
FROM fo_verificationsvalue
|
||||
JOIN fo_verificationslabel ON Fo_VerificationsValueFo_VerificationsLabelID = Fo_VerificationsLabelID
|
||||
WHERE
|
||||
Fo_VerificationsValueCheck = 'N' AND Fo_VerificationsValueT_OrderHeaderID = {$orderid}";
|
||||
$other = $this->db_onedev->query($sql)->result_array();
|
||||
if($other){
|
||||
foreach($other as $k => $v){
|
||||
array_push($rst,$v);
|
||||
}
|
||||
}
|
||||
return $rst;
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$status = $prm["status"];
|
||||
|
||||
|
||||
if($status == 'N'){
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_orderheader
|
||||
JOIN t_ordermessage ON T_OrderMessageT_OrderHeaderID = T_OrderHeaderID
|
||||
WHERE
|
||||
( T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND
|
||||
T_OrderMessageDone <> 'Y' AND T_OrderMessageIsActive = 'Y'
|
||||
ORDER BY T_OrderHeaderID ASC";
|
||||
}else if($status == 'Y'){
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_orderheader
|
||||
JOIN t_ordermessage ON T_OrderMessageT_OrderHeaderID = T_OrderHeaderID AND T_OrderMessageIsActive = 'Y'
|
||||
WHERE
|
||||
( T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND
|
||||
T_OrderMessageDone = 'Y'
|
||||
ORDER BY T_OrderHeaderID DESC LIMIT 100";
|
||||
}else{
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_orderheader
|
||||
WHERE
|
||||
( T_OrderHeaderLabNumber LIKE '%{$search}%' )";
|
||||
}
|
||||
//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_patient count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
if($status == 'N'){
|
||||
$sql = "SELECT T_OrderMessageID as xid,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderID as orderdate,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
M_PatientNoReg as patient_noreg,
|
||||
T_OrderMessageType as message_type,
|
||||
T_OrderMessageMessage as message,
|
||||
T_OrderMessageID as message_id,
|
||||
fn_fo_supervisor_delivery_verification_done(T_OrderHeaderID) as donedelivery,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patientname,
|
||||
CASE
|
||||
WHEN T_OrderMessageType = 'FO.VERIFICATION.REJECT' THEN 'Fo Verification'
|
||||
WHEN T_OrderMessageType = 'FO.Supervisor.Sampling' THEN 'Sampling'
|
||||
ELSE 'Other'
|
||||
END as type,
|
||||
CASE
|
||||
WHEN T_OrderMessageRead = 'N' AND T_OrderMessageDone = 'N' THEN 'Baru'
|
||||
WHEN T_OrderMessageRead = 'Y' AND T_OrderMessageDone = 'N' THEN 'Telah dibaca'
|
||||
WHEN T_OrderMessageRead = 'Y' AND T_OrderMessageDone = 'P' THEN 'Sedang dikerjakan'
|
||||
END as status
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_ordermessage ON T_OrderMessageT_OrderHeaderID = T_OrderHeaderID
|
||||
WHERE
|
||||
( T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND
|
||||
T_OrderMessageType = 'FO.VERIFICATION.REJECT' AND
|
||||
T_OrderMessageDone <> 'Y' AND T_OrderMessageIsActive = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
ORDER BY T_OrderHeaderID ASC";
|
||||
}else if($status == 'Y'){
|
||||
$sql = "SELECT T_OrderMessageID as xid,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderID as orderdate,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
M_PatientNoReg as patient_noreg,
|
||||
T_OrderMessageType as message_type,
|
||||
T_OrderMessageMessage as message,
|
||||
T_OrderMessageID as message_id,
|
||||
fn_fo_supervisor_delivery_verification_done(T_OrderHeaderID) as donedelivery,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patientname,
|
||||
CASE
|
||||
WHEN T_OrderMessageType = 'FO.VERIFICATION.REJECT' THEN 'Fo Verification'
|
||||
WHEN T_OrderMessageType = 'FO.Supervisor.Sampling' THEN 'Sampling'
|
||||
ELSE 'Other'
|
||||
END as type,
|
||||
'Selesai' as status
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
JOIN t_ordermessage ON T_OrderMessageT_OrderHeaderID = T_OrderHeaderID AND T_OrderMessageIsActive = 'Y'
|
||||
WHERE
|
||||
( T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND
|
||||
T_OrderMessageType = 'FO.VERIFICATION.REJECT' AND
|
||||
T_OrderMessageDone = 'Y'
|
||||
AND T_OrderHeaderIsActive = 'Y'
|
||||
ORDER BY T_OrderHeaderID DESC LIMIT 20";
|
||||
}else{
|
||||
$sql = "SELECT -1 as xid,
|
||||
T_OrderHeaderID as orderid,
|
||||
T_OrderHeaderID as orderdate,
|
||||
T_OrderHeaderLabNumber as labnumber,
|
||||
M_PatientNoReg as patient_noreg,
|
||||
'adhoc' as message_type,
|
||||
'' as message,
|
||||
0 as message_id,
|
||||
fn_fo_supervisor_delivery_verification_done(T_OrderHeaderID) as donedelivery,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as patientname,
|
||||
'adhoc' as type,
|
||||
T_OrderHeaderAddOnPatientMcu as patient_mcu
|
||||
FROM t_orderheader
|
||||
LEFT JOIN t_orderheaderaddon ON T_OrderHeaderAddOnT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE
|
||||
( T_OrderHeaderLabNumber LIKE '%{$search}%' ) AND T_OrderHeaderIsActive = 'Y'
|
||||
ORDER BY T_OrderHeaderID DESC LIMIT 20";
|
||||
}
|
||||
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
foreach($rows as $k => $v){
|
||||
if($status == 'N' || $status == 'Y'){
|
||||
$rows[$k]['notes'] = $this->add_notes($v['orderid']);
|
||||
}
|
||||
else{
|
||||
$rows[$k]['notes'] = array();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
2846
one-api/application/controllers/mockup/fo/supervisor/Supervisor.php
Normal file
2846
one-api/application/controllers/mockup/fo/supervisor/Supervisor.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
class Delivery extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function lookup()
|
||||
{
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$query = " SELECT M_DeliveryID as id,
|
||||
M_DeliveryTypeID as typeid,
|
||||
M_DeliveryTypeCode as type,
|
||||
M_DeliverySource as source,
|
||||
M_DeliveryName as name
|
||||
FROM
|
||||
m_deliverytype
|
||||
JOIN m_delivery ON M_DeliveryM_DeliveryTypeID = M_DeliveryTypeID AND M_DeliveryIsActive = 'Y'
|
||||
WHERE
|
||||
M_DeliveryTypeIsActive = 'Y'";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
339
one-api/application/controllers/mockup/fo/verification/Done.php
Normal file
339
one-api/application/controllers/mockup/fo/verification/Done.php
Normal file
@@ -0,0 +1,339 @@
|
||||
<?php
|
||||
class Done 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;
|
||||
}
|
||||
|
||||
$start_date = $prm["startdate"];
|
||||
$end_date = $prm["enddate"];
|
||||
$search = $prm["search"];
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql_where = "WHERE (T_OrderHeaderDate BETWEEN CONCAT('{$start_date}',' ','00:00:00') AND CONCAT('{$end_date}',' ','23:59:59')) AND T_OrderHeaderIsActive = 'Y'";
|
||||
if($search != ''){
|
||||
$sql_where = "WHERE (T_OrderHeaderLabNumber LIKE '%{$search}%' OR M_PatientName LIKE '%{$search}%' ) AND T_OrderHeaderIsActive = 'Y'";
|
||||
}
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM(
|
||||
SELECT
|
||||
T_OrderHeaderID,
|
||||
fn_fo_verification_last_status(T_OrderHeaderID,3) as check_status,
|
||||
fn_fo_verification_status_done(T_OrderHeaderID) as check_status_spv
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
LEFT JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN m_status ON Last_StatusM_StatusID = M_StatusID
|
||||
LEFT JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressNote = 'utama'
|
||||
LEFT JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
LEFT JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
LEFT JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID
|
||||
JOIN m_doctoraddress ON T_OrderHeaderSenderM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
$sql_where
|
||||
HAVING check_status > 0 OR check_status_spv > 0
|
||||
ORDER BY T_OrderHeaderID ASC
|
||||
) x
|
||||
";
|
||||
//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
|
||||
M_PatientNoReg,
|
||||
fn_fo_verification_get_paid(T_OrderHeaderID) as paid,
|
||||
T_OrderHeaderTotal,
|
||||
M_MouIsBill,
|
||||
IF(M_MouIsBill = 'N','Tidak ditagihkan','Ditagihkan') as texttagihan,
|
||||
CONCAT(M_TitleName,' ',M_PatientName) as M_PatientName,
|
||||
M_PatientHP,
|
||||
T_OrderHeaderM_PatientAge,
|
||||
DATE_FORMAT(M_PatientDOB,'%d-%m-%Y') as M_PatientDOB,
|
||||
M_PatientAddressDescription as M_PatientAddress,
|
||||
M_CityName as CityUtama,
|
||||
M_PatientNote,
|
||||
M_PatientHP,
|
||||
M_DoctorHP,
|
||||
T_OrderHeaderID as ohid,
|
||||
T_OrderHeaderLabNumber,
|
||||
T_OrderHeaderDate,
|
||||
IF(M_StatusID = 2,'Baru',IF(M_StatusID = 3,'Verified','Ditolak')) as M_StatusName,
|
||||
T_OrderHeaderID, M_SexName,
|
||||
M_CompanyName,
|
||||
T_OrderHeaderM_CompanyID,
|
||||
T_OrderHeaderM_MouID,
|
||||
CONCAT(M_MouName,' ( ',DATE_FORMAT(M_MouStartDate,'%d-%m-%Y') ,' s/d ' , DATE_FORMAT(M_MouEndDate,'%d-%m-%Y'),' )') as mou,
|
||||
M_DoctorName,
|
||||
M_DoctorAddressDescription as M_DoctorAddress,
|
||||
T_OrderHeaderVerificationNote as verification_note,
|
||||
fn_fo_verification_last_status(T_OrderHeaderID,3) as check_status,
|
||||
fn_fo_verification_status_done(T_OrderHeaderID) as check_status_spv,
|
||||
T_OrderHeaderDate as orderdate
|
||||
FROM t_orderheader
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
LEFT JOIN last_status ON Last_StatusT_OrderHeaderID = T_OrderHeaderID
|
||||
LEFT JOIN m_status ON Last_StatusM_StatusID = M_StatusID
|
||||
LEFT JOIN m_patientaddress ON M_PatientAddressM_PatientID = M_PatientID AND M_PatientAddressNote = 'utama'
|
||||
LEFT JOIN m_kelurahan ON M_PatientAddressM_KelurahanID = M_KelurahanID
|
||||
LEFT JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID
|
||||
LEFT JOIN m_city ON M_DistrictM_CityID = M_CityID
|
||||
JOIN m_sex ON M_PatientM_SexID = M_SexID
|
||||
JOIN m_doctor ON T_OrderHeaderSenderM_DoctorID = M_DoctorID
|
||||
JOIN m_doctoraddress ON T_OrderHeaderSenderM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_company ON T_OrderHeaderM_CompanyID = M_CompanyID
|
||||
JOIN m_mou ON T_OrderHeaderM_MouID = M_MouID
|
||||
$sql_where
|
||||
HAVING check_status > 0 OR check_status_spv > 0
|
||||
ORDER BY T_OrderHeaderID ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $sql;
|
||||
//echo $this->db_onedev->last_query();
|
||||
$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 getalmaries(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT M_AlmariID as id, CONCAT('[ ',M_AlmariCode,' ] ', M_AlmariName) as name, M_AlmariCode as code
|
||||
FROM m_almari
|
||||
WHERE
|
||||
M_AlmariIsActive = 'Y'
|
||||
";
|
||||
//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 save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('SS') as numbering")->row()->numbering;
|
||||
$xdate = date('Y-m-d',strtotime($prm["date"]));
|
||||
$query ="INSERT INTO t_samplestorage (
|
||||
T_SampleStorageNumbering,
|
||||
T_SampleStorageDate,
|
||||
T_SampleStorageTime,
|
||||
T_SampleStorageNote,
|
||||
T_SampleStorageUserID,
|
||||
T_SampleStorageCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$xdate}',
|
||||
'{$prm['time']}',
|
||||
'{$prm['note']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$saveheader = $this->db_onedev->query($query);
|
||||
$last_id = $this->db_onedev->insert_id();
|
||||
if($saveheader){
|
||||
foreach($prm['details'] as $k => $v){
|
||||
$query ="INSERT INTO t_samplestorage_detail (
|
||||
T_SampleStorageDetailT_SampleStorageID,
|
||||
T_SampleStorageDetailT_OrderSampleID,
|
||||
T_SampleStorageDetailBarcode,
|
||||
T_SampleStorageDetailM_AlmariID,
|
||||
T_SampleStorageDetailM_RackID,
|
||||
T_SampleStorageDetailRowPosition,
|
||||
T_SampleStorageDetailColumnPosition,
|
||||
T_SampleStorageDetailUserID,
|
||||
T_SampleStorageDetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$last_id}',
|
||||
'{$v['ordersampleid']}',
|
||||
'{$v['barcode']}',
|
||||
'{$v['almari']['id']}',
|
||||
'{$v['rack']['id']}',
|
||||
'{$v['row']}',
|
||||
'{$v['col']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$savedetail = $this->db_onedev->query($query);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_samplestorage WHERE T_SampleStorageID = {$last_id}";
|
||||
$data_log_header = $this->db_onedev->query($sql)->result();
|
||||
$sql = "SELECT * FROM t_samplestorage_detail WHERE T_SampleStorageDetailT_SampleStorageID = {$last_id}";
|
||||
$data_log_details = $this->db_onedev->query($sql)->result();
|
||||
|
||||
$data_log = json_encode(array('header'=>$data_log_header,'details'=>$data_log_details));
|
||||
$sql = "INSERT INTO one_log.log_samplestorage (
|
||||
Log_SampleStorageCode,
|
||||
Log_SampleStorageDate,
|
||||
Log_SampleStorageJSON,
|
||||
Log_SampleStorageUserID
|
||||
)
|
||||
VALUES(
|
||||
'CREATED.SAVE',
|
||||
CURDATE(),
|
||||
'{$data_log}',
|
||||
{$userid}
|
||||
)";
|
||||
//echo $sql;
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $numbering,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkbarcode(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$datarows = [];
|
||||
$query =" SELECT CONCAT(IFNULL(M_TitleName,''),' ',M_PatientName) as patientname, T_OrderSampleID
|
||||
FROM t_ordersample
|
||||
JOIN t_orderheader ON T_OrderSampleT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN m_patient ON T_OrderHeaderM_PatientID = M_PatientID
|
||||
LEFT JOIN m_title ON M_PatientM_TitleID = M_TitleID
|
||||
WHERE T_OrderSampleBarcode = '{$prm['barcode']}' AND T_OrderSampleIsActive = 'Y' ORDER BY T_OrderSampleID DESC LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->row();
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
1284
one-api/application/controllers/mockup/fo/verification/Patient.php
Normal file
1284
one-api/application/controllers/mockup/fo/verification/Patient.php
Normal file
File diff suppressed because it is too large
Load Diff
133
one-api/application/controllers/mockup/fo/verification/Px.php
Normal file
133
one-api/application/controllers/mockup/fo/verification/Px.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
class Px extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Px API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
$orderdate = $prm['orderdate'];
|
||||
$cito = $prm['cito'] == true ?'Y':'N';
|
||||
$mouid = $prm['mouid'];
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM t_price
|
||||
JOIN t_test ON T_PriceT_TestID = T_TestID
|
||||
JOIN m_mou ON M_MouID = T_PriceM_MouID
|
||||
AND M_MouStartDate <= ?
|
||||
AND M_MouEndDate >= ?
|
||||
WHERE
|
||||
|
||||
T_PriceIsCito = ?
|
||||
AND T_PriceM_MouID = ?
|
||||
AND T_TestName like ?
|
||||
|
||||
AND T_PriceIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,array($orderdate,$orderdate,$cito,$mouid,$q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_patient count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT T_PriceT_TestID as id,
|
||||
T_TestCode as pxcode,
|
||||
T_TestName as pxname,
|
||||
T_TestIsResult as isresult,
|
||||
T_PriceAmount as bruto,
|
||||
T_PriceDisc as discount,
|
||||
T_PriceDiscRp as discountrp,
|
||||
((T_PriceDisc / 100) * T_PriceAmount) - T_PriceDiscRp as discounttotal,
|
||||
( T_PriceAmount - ((T_PriceDisc / 100) * T_PriceAmount) - T_PriceDiscRp ) as total,
|
||||
T_PriceIsCito as flagcito
|
||||
FROM t_price
|
||||
JOIN t_test ON T_PriceT_TestID = T_TestID
|
||||
JOIN m_mou ON M_MouID = T_PriceM_MouID
|
||||
AND M_MouStartDate <= ?
|
||||
AND M_MouEndDate >= ?
|
||||
WHERE
|
||||
|
||||
T_PriceIsCito = ?
|
||||
AND T_PriceM_MouID = ?
|
||||
AND T_TestName like ?
|
||||
|
||||
AND T_PriceIsActive = 'Y'
|
||||
ORDER BY T_PricePriority DESC
|
||||
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($orderdate,$orderdate,$cito,$mouid,$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;
|
||||
}
|
||||
}
|
||||
|
||||
public function search_()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm["search"];
|
||||
$sql_param = array("%$search%");
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'";
|
||||
$query = $this->db_smartone->query($sql, $sql_param);
|
||||
$tot_count =0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
} else {
|
||||
$this->sys_error_db("m_patienttype count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
$sql = "select M_PatientTypeID, M_PatientTypeName
|
||||
from
|
||||
m_patienttype
|
||||
where
|
||||
M_PatientTypeName like ? and
|
||||
M_PatientTypeIsActive = 'Y'
|
||||
limit 0,10";
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
$rows = $query->result_array();
|
||||
$this->_add_mou($rows);
|
||||
$result = array("total" => $tot_count, "records" => $rows );
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class Status extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
public function lookup()
|
||||
{
|
||||
$status = array(
|
||||
array("id"=>2,"code"=>"FO.Verification","name" => "Baru" ),
|
||||
array("id"=>3,"code"=>"FO.Verification.Confirm","name" => "Verified"),
|
||||
array("id"=>4,"code"=>"FO.Verification.Reject","name" => "Ditolak")
|
||||
);
|
||||
$result = array(
|
||||
"total" => count($status) ,
|
||||
"records" => $status,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
class Supplies extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$xuserid = $this->sys_user['M_UserID'];
|
||||
$prm = $this->sys_input;
|
||||
$orderid = $prm['orderid'];
|
||||
$supplies = $prm['supplies'];
|
||||
$barcodes = $prm['barcode'];
|
||||
$dt_log = array('orderid'=>$orderid,'supplies'=>$supplies,'barcode'=>$barcode);
|
||||
$fologcode = 'FO.Verification.BarcodeSupplies';
|
||||
$json_dt_log = json_encode($dt_log);
|
||||
$sql = "insert into one_log.log_supplies_barcode(
|
||||
Log_SuppliesBarcodeDate,
|
||||
Log_SuppliesBarcodeCode,
|
||||
Log_SuppliesBarcodeJson,
|
||||
Log_SuppliesBarcodeUserID)
|
||||
values( now(), ?, ?, ?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$fologcode,
|
||||
$json_dt_log,
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
|
||||
if (!$query) {
|
||||
$this->sys_error_db("one_log.log_supplies_barcode insert");
|
||||
exit;
|
||||
}
|
||||
//print_r($supplies);
|
||||
foreach($supplies as $k => $v){
|
||||
if(intval($v['xid']) == 0 && $v['chex'] == true){
|
||||
$sql = "insert into t_ordersupplies(
|
||||
T_OrderSuppliesT_OrderHeaderID,
|
||||
T_OrderSuppliesM_SuppliesID,
|
||||
T_OrderSuppliesQty,
|
||||
T_OrderSuppliesCreated,
|
||||
T_OrderSuppliesLastUpdated,
|
||||
T_OrderSuppliesUserID)
|
||||
values( ?, ?, ?, now(),now(),?)";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid,
|
||||
$v['id'],
|
||||
$v['qty'],
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_ordersupplies insert");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if(intval($v['xid']) > 0 && $v['chex'] == true){
|
||||
$sql = "update t_ordersupplies
|
||||
set
|
||||
T_OrderSuppliesQty = {$v['qty']},
|
||||
T_OrderSuppliesLastUpdated = now(),
|
||||
T_OrderSuppliesUserID = {$xuserid}
|
||||
where
|
||||
T_OrderSuppliesID = ?
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$v['xid']
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_ordersupplies update");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if(intval($v['xid']) > 0 && $v['chex'] == false){
|
||||
$sql = "update t_ordersupplies
|
||||
set
|
||||
T_OrderSuppliesIsActive = 'N' ,
|
||||
T_OrderSuppliesLastUpdated = now(),
|
||||
T_OrderSuppliesUserID = $xuserid
|
||||
where
|
||||
T_OrderSuppliesID = ?
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$v['xid']
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_ordersupplies update");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "UPDATE t_barcodelab SET T_BarcodeLabIsActive = 'N' WHERE T_BarcodeLabT_OrderHeaderID = {$orderid}";
|
||||
$updatex = $this->db_onedev->query($sql);
|
||||
|
||||
foreach($barcodes as $i => $barcode){
|
||||
$children = $barcode['children'];
|
||||
foreach($children as $k => $v){
|
||||
if(intval($v['xid']) == 0){
|
||||
$sql = "insert into t_barcodelab(
|
||||
T_BarcodeLabT_OrderHeaderID,
|
||||
T_BarcodeLabBarcode,
|
||||
T_BarcodeLabT_SampleTypeID,
|
||||
T_BarcodeLabCreated,
|
||||
T_BarcodeLabLastUpdated,
|
||||
T_BarcodeLabUserID)
|
||||
values( ?, ?, ?, now(),now(),?)";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$orderid,
|
||||
$v['barcodenumber'],
|
||||
$v['id'],
|
||||
$xuserid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_barcodelab insert");
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$sql = "UPDATE t_barcodelab SET T_BarcodeLabIsActive = 'Y' WHERE T_BarcodeLabID = {$v['xid']} ";
|
||||
$updatex = $this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sql = "select M_SuppliesID as id,
|
||||
IFNULL(T_OrderSuppliesID,0) as xid,
|
||||
IF(ISNULL(T_OrderSuppliesID),'N',T_OrderSuppliesIsActive) as chex,
|
||||
IFNULL(T_OrderSuppliesQty,1) as qty,
|
||||
M_SuppliesName as name,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as lastupdated,
|
||||
IF(ISNULL(T_OrderSuppliesID),NOW(),T_OrderSuppliesLastUpdated) as tx_lastupdated
|
||||
from m_supplies
|
||||
left join t_ordersupplies ON
|
||||
T_OrderSuppliesT_OrderHeaderID = ? AND
|
||||
T_OrderSuppliesM_SuppliesID = M_SuppliesID
|
||||
WHERE
|
||||
M_SuppliesIsActive = 'Y'";
|
||||
$sql_param = array($orderid);
|
||||
$query = $this->db_onedev->query($sql,$sql_param);
|
||||
if ($query) {
|
||||
$rows_supplies = $query->result_array();
|
||||
foreach($rows_supplies as $k => $v){
|
||||
if($v['chex'] == 'N')
|
||||
$rows_supplies[$k]['chex'] = false;
|
||||
else
|
||||
$rows_supplies[$k]['chex'] = true;
|
||||
}
|
||||
} else {
|
||||
$this->sys_error_db("t_ordersupplies select");
|
||||
exit;
|
||||
}
|
||||
|
||||
$query =" SELECT T_SampleTypeID as id,
|
||||
T_SampleTypeName as name,
|
||||
'' as children
|
||||
FROM t_orderheader
|
||||
JOIN t_orderdetail ON T_OrderDetailT_OrderHeaderID = T_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
WHERE
|
||||
T_OrderHeaderID = {$orderid}
|
||||
GROUP BY T_SampleTypeID
|
||||
";
|
||||
// echo $query ;
|
||||
$rows_barcode = $this->db_onedev->query($query)->result();
|
||||
foreach($rows_barcode as $k => $v){
|
||||
$query = "SELECT T_SampleTypeID as id, IFNULL(T_BarcodeLabID,0) as xid,
|
||||
IF(ISNULL(T_BarcodeLabID),'Y',T_BarcodeLabIsActive) as chex,
|
||||
T_TestName as testname,
|
||||
T_SampleTypeName as samplename,
|
||||
IF(ISNULL(T_BarcodeLabID),CONCAT(T_OrderHeaderLabNumber,'.',T_SampleTypeID,'.',1),T_BarcodeLabBarcode) as barcodenumber
|
||||
FROM t_orderdetail
|
||||
JOIN t_orderheader ON T_OrderHeaderID = T_OrderDetailT_OrderHeaderID
|
||||
JOIN t_test ON T_OrderDetailT_TestID = T_TestID
|
||||
JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
|
||||
LEFT JOIN t_barcodelab ON T_BarcodeLabT_OrderHeaderID = T_OrderDetailT_OrderHeaderID AND
|
||||
T_BarcodeLabT_SampleTypeID = T_TestT_SampleTypeID AND T_BarcodeLabIsActive = 'Y'
|
||||
WHERE
|
||||
T_OrderDetailT_OrderHeaderID = {$orderid} AND T_SampleTypeID = {$v->id}
|
||||
GROUP BY T_BarcodeLabID ";
|
||||
$v->children = $this->db_onedev->query($query)->result_array();
|
||||
foreach($v->children as $ki => $vi){
|
||||
if($vi['chex'] == 'N')
|
||||
$v->children[$ki]['chex'] = false;
|
||||
else
|
||||
$v->children[$ki]['chex'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = array ("total" => count($rows), "records" => array('supplies'=>$rows_supplies,'barcode'=>$rows_barcode));
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class Verificationdoctor extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
public function index()
|
||||
{
|
||||
echo "API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("smartone", true);
|
||||
}
|
||||
public function lookup()
|
||||
{
|
||||
$verification_doctor= array(
|
||||
array('id'=>1,'check'=>true,'note'=>'','label'=>'Nama dokter sudah sesuai'),
|
||||
array('id'=>2,'check'=>true,'note'=>'','label'=>'Alamat dokter sudah sesuai')
|
||||
);
|
||||
$result = array(
|
||||
"records" => $verification_doctor
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
class Vilage extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Vilage API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "select count(*) total
|
||||
from
|
||||
m_kelurahan
|
||||
where M_KelurahanIsActive = 'Y'
|
||||
and M_KelurahanName like ?";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_count = 4;
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_kelurahan count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select M_KelurahanID as id, M_KelurahanName as name
|
||||
from m_kelurahan
|
||||
where M_KelurahanIsActive = 'Y'
|
||||
and M_KelurahanName like ?";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_kelurahan rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
180
one-api/application/controllers/mockup/home-service/Status.php
Normal file
180
one-api/application/controllers/mockup/home-service/Status.php
Normal file
@@ -0,0 +1,180 @@
|
||||
<?php
|
||||
|
||||
class Status extends CI_Controller {
|
||||
function hari() {
|
||||
$dow = date("N");
|
||||
switch($dow) {
|
||||
case 1 :
|
||||
return "Senin";
|
||||
case 2 :
|
||||
return "Selasa";
|
||||
case 3 :
|
||||
return "Rabu";
|
||||
case 4 :
|
||||
return "Kamis";
|
||||
case 5 :
|
||||
return "Jum'at";
|
||||
case 6 :
|
||||
return "Sabtu";
|
||||
case 7 :
|
||||
return "Minggu";
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
function bulan() {
|
||||
$mo = date("n");
|
||||
switch($mo) {
|
||||
case 1 :
|
||||
return "Januari";
|
||||
case 2 :
|
||||
return "Februari";
|
||||
case 3 :
|
||||
return "Maret";
|
||||
case 4 :
|
||||
return "April";
|
||||
case 5 :
|
||||
return "Mei";
|
||||
case 6 :
|
||||
return "Juni";
|
||||
case 7 :
|
||||
return "Juli";
|
||||
case 8 :
|
||||
return "Agustus";
|
||||
case 9 :
|
||||
return "September";
|
||||
case 10 :
|
||||
return "Oktober";
|
||||
case 11 :
|
||||
return "November";
|
||||
case 12 :
|
||||
return "Desember";
|
||||
}
|
||||
}
|
||||
function index() {
|
||||
global $dummy_order;
|
||||
$month = $this->bulan();
|
||||
$tanggal = date("d") . " $month " . date("Y");
|
||||
$arr = array(
|
||||
"info" => array(
|
||||
"username" => "Budi Wisono",
|
||||
"area" => "Bandung Barat",
|
||||
"hari" => $this->hari(),
|
||||
"tanggal" =>$tanggal,
|
||||
"last_updated" => date("Y-m-d H:i:s")
|
||||
),
|
||||
"status" => array(
|
||||
"order" => 3,
|
||||
"visited"=> 2,
|
||||
"served" => 1,
|
||||
"canceled" => 1
|
||||
),
|
||||
"order" => $dummy_order
|
||||
);
|
||||
echo json_encode($arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$dummy_order = array(
|
||||
array (
|
||||
"date" => date("Y-m-d 10:00:00"),
|
||||
"pasien"=> array(
|
||||
"name" => "Bpk. Budi Santoso",
|
||||
"dob" => "1970-03-04",
|
||||
"sex" => "M"
|
||||
),
|
||||
"test" => array (
|
||||
array(
|
||||
"testID" => 10,
|
||||
"testName" => "SGOT",
|
||||
"testBruto" => 100000,
|
||||
"testDiscount" => 3000,
|
||||
"testSubTotal" => 97000,
|
||||
),
|
||||
array(
|
||||
"testID" => 12,
|
||||
"testName" => "SGPT",
|
||||
"testBruto" => 120000,
|
||||
"testDiscount" => 5000,
|
||||
"testSubTotal" => 115000,
|
||||
),
|
||||
array(
|
||||
"testID" => 15,
|
||||
"testName" => "Glucose",
|
||||
"testBruto" => 80000,
|
||||
"testDiscount" => 5000,
|
||||
"testSubTotal" => 75000,
|
||||
)
|
||||
),
|
||||
"address" => "Jl. Teuku Umar No 20",
|
||||
"phone" => "08781234321",
|
||||
"geo" => array("lat" => -6.867826, "lang" => 107.620409),
|
||||
"area" => "Bandung Utara"
|
||||
),
|
||||
array (
|
||||
"date" => date("Y-m-d 12:00:00"),
|
||||
"pasien"=> array(
|
||||
"name" => "Ibu. Siti Nuryanti",
|
||||
"dob" => "1975-06-04",
|
||||
"sex" => "F"
|
||||
),
|
||||
"test" => array (
|
||||
array(
|
||||
"testID" => 20,
|
||||
"testName" => "HBsAg",
|
||||
"testBruto" => 100000,
|
||||
"testDiscount" => 3000,
|
||||
"testSubTotal" => 97000,
|
||||
),
|
||||
array(
|
||||
"testID" => 12,
|
||||
"testName" => "SGPT",
|
||||
"testBruto" => 120000,
|
||||
"testDiscount" => 5000,
|
||||
"testSubTotal" => 115000,
|
||||
),
|
||||
array(
|
||||
"testID" => 25,
|
||||
"testName" => "GGT",
|
||||
"testBruto" => 80000,
|
||||
"testDiscount" => 5000,
|
||||
"testSubTotal" => 75000,
|
||||
)
|
||||
),
|
||||
"address" => "Jl. Teuku Umar No 20",
|
||||
"address" => "Jl. Tubagus Ismail V No 2",
|
||||
"phone" => "08784534321",
|
||||
"geo" => array("lat" => -6.884176, "lang" => 107.621268 ),
|
||||
"area" => "Bandung Utara"
|
||||
),
|
||||
array (
|
||||
"date" => date("Y-m-d 13:00:00"),
|
||||
"pasien"=> array(
|
||||
"name" => "Bp. Dudi Nugraha",
|
||||
"dob" => "1964-06-04",
|
||||
"sex" => "M"
|
||||
),
|
||||
"test" => array (
|
||||
array(
|
||||
"testID" => 20,
|
||||
"testName" => "HBsAg",
|
||||
"testBruto" => 100000,
|
||||
"testDiscount" => 3000,
|
||||
"testSubTotal" => 97000,
|
||||
),
|
||||
array(
|
||||
"testID" => 12,
|
||||
"testName" => "SGPT",
|
||||
"testBruto" => 120000,
|
||||
"testDiscount" => 5000,
|
||||
"testSubTotal" => 115000,
|
||||
),
|
||||
),
|
||||
"address" => "Jl. Terusan Ciheulang BAru No 7",
|
||||
"phone" => "0878000321",
|
||||
"geo" => array("lat" => -6.887279, "lang" => 107.619938 ),
|
||||
"area" => "Bandung Utara"
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
|
||||
class Injectprice extends MY_Controller
|
||||
{
|
||||
var $db_regional;
|
||||
var $load;
|
||||
var $db;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_regional = $this->load->database("regional", true);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "Inject Patient";
|
||||
}
|
||||
public function getTest()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$sql = "SELECT T_TestSasCode as TEST_CODE, T_TestName as TEST_NAME, '' as HARGA, 0 as DISKON_PERSEN, 0 as DISKON_RUPIAH, 0 as TOTAL
|
||||
FROM t_test
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
WHERE
|
||||
T_TestIsActive = 'Y' AND
|
||||
T_TestIsPrice = 'Y' AND Nat_TestTypeName <> 'Profile'
|
||||
ORDER BY T_TestSasCode ASC";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Error get company");
|
||||
exit;
|
||||
}
|
||||
$rst = $query->result_array();
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
public function getCompany()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = '';
|
||||
if (isset($prm['search'])) {
|
||||
$search = $prm['search'];
|
||||
}
|
||||
$sql = "SELECT * FROM m_company WHERE M_CompanyIsActive = 'Y'
|
||||
AND M_CompanyName LIKE '%$search%' LIMIT 50";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Error get company");
|
||||
exit;
|
||||
}
|
||||
$rst = $query->result_array();
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
public function getMou()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$search = '';
|
||||
if (isset($prm['search'])) {
|
||||
$search = $prm['search'];
|
||||
}
|
||||
$companyid = $prm['companyid'];
|
||||
$sql = "SELECT * FROM m_mou WHERE M_MouIsActive = 'Y' AND M_MouIsVerified = 'N'
|
||||
AND M_MouM_CompanyID = $companyid
|
||||
AND M_MouName LIKE '%$search%' LIMIT 50";
|
||||
$query = $this->db->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("Error get mou");
|
||||
exit;
|
||||
}
|
||||
$rst = $query->result_array();
|
||||
$this->sys_ok($rst);
|
||||
}
|
||||
public function inject()
|
||||
{
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
|
||||
/** ✅ VALIDASI AGREEMENT (MOU) */
|
||||
if (
|
||||
!isset($prm['mou']) ||
|
||||
empty($prm['mou']) ||
|
||||
!isset($prm['mou']['M_MouID']) ||
|
||||
empty($prm['mou']['M_MouID'])
|
||||
) {
|
||||
$this->sys_error("Belum pilih Agreement");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$company = $prm['company'];
|
||||
$mou = $prm['mou'];
|
||||
$data = $prm['data'];
|
||||
|
||||
$companyID = $company['M_CompanyID'];
|
||||
$mouID = $mou['M_MouID'];
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
/** 1️⃣ Nonaktifkan data lama */
|
||||
$sqlUpdate = "
|
||||
UPDATE t_price
|
||||
SET T_PriceIsActive = 'N'
|
||||
WHERE T_PriceM_CompanyID = ?
|
||||
AND T_PriceM_MouID = ?
|
||||
AND T_PriceIsActive = 'Y'
|
||||
";
|
||||
|
||||
$this->db->query($sqlUpdate, [$companyID, $mouID]);
|
||||
|
||||
/** 2️⃣ Insert data baru */
|
||||
foreach ($data as $row) {
|
||||
|
||||
$sqlTest = "
|
||||
SELECT T_TestID
|
||||
FROM t_test
|
||||
WHERE T_TestSasCode = ?
|
||||
";
|
||||
$test = $this->db->query($sqlTest, [$row['TEST_CODE']])->row();
|
||||
|
||||
if (!$test) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error("Test code tidak ditemukan : ".$row['TEST_CODE']);
|
||||
exit;
|
||||
}
|
||||
if($row['HARGA'] !== ''){
|
||||
$sqlInsert = "
|
||||
INSERT INTO t_price (
|
||||
T_PriceT_TestID,
|
||||
T_PriceIsCito,
|
||||
T_PriceM_CompanyID,
|
||||
T_PriceM_MouID,
|
||||
T_PricePriority,
|
||||
T_PriceAmount,
|
||||
T_PriceDisc,
|
||||
T_PriceDiscRp,
|
||||
T_PriceSubTotal,
|
||||
T_PriceOther,
|
||||
T_PriceTotal,
|
||||
T_PriceUserID,
|
||||
T_PriceIsActive
|
||||
) VALUES (
|
||||
?,'N',?,?,'0',?,?,?,?,'0',?,?,'Y'
|
||||
)
|
||||
";
|
||||
|
||||
$query = $this->db->query($sqlInsert, [
|
||||
$test->T_TestID,
|
||||
$companyID,
|
||||
$mouID,
|
||||
$row['HARGA'],
|
||||
$row['DISKON_PERSEN'],
|
||||
$row['DISKON_RUPIAH'],
|
||||
$row['TOTAL'],
|
||||
$row['TOTAL'],
|
||||
$userid
|
||||
]);
|
||||
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Error insert price");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sqlInsertCito = "
|
||||
INSERT INTO t_price (
|
||||
T_PriceT_TestID,
|
||||
T_PriceIsCito,
|
||||
T_PriceM_CompanyID,
|
||||
T_PriceM_MouID,
|
||||
T_PricePriority,
|
||||
T_PriceAmount,
|
||||
T_PriceDisc,
|
||||
T_PriceDiscRp,
|
||||
T_PriceSubTotal,
|
||||
T_PriceOther,
|
||||
T_PriceTotal,
|
||||
T_PriceUserID,
|
||||
T_PriceIsActive
|
||||
) VALUES (
|
||||
?,'Y',?,?,'0',?,?,?,?,'0',?,?,'Y'
|
||||
)
|
||||
";
|
||||
|
||||
$queryCito = $this->db->query($sqlInsertCito, [
|
||||
$test->T_TestID,
|
||||
$companyID,
|
||||
$mouID,
|
||||
$row['HARGA'],
|
||||
$row['DISKON_PERSEN'],
|
||||
$row['DISKON_RUPIAH'],
|
||||
$row['TOTAL'],
|
||||
$row['TOTAL'],
|
||||
$userid
|
||||
]);
|
||||
|
||||
if (!$queryCito) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("Error insert price");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("Success");
|
||||
}
|
||||
|
||||
}
|
||||
856
one-api/application/controllers/mockup/management/Courier.php
Normal file
856
one-api/application/controllers/mockup/management/Courier.php
Normal file
@@ -0,0 +1,856 @@
|
||||
<?php
|
||||
class Courier extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Management Courier 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;
|
||||
}
|
||||
|
||||
$xdate = $prm["xdate"];
|
||||
$city = $prm["city"];
|
||||
$district = $prm["district"];
|
||||
$kelurahan = $prm["kelurahan"];
|
||||
$status = $prm["status"];
|
||||
|
||||
$filter_city = '';
|
||||
$filter_district = '';
|
||||
$filter_kelurahan = '';
|
||||
if($district['id'] == 'all' && $kelurahan['id'] == 'all'){
|
||||
$filter_city = "AND M_CityID = {$city['id']}";
|
||||
}
|
||||
|
||||
if($district['id'] != 'all' && $kelurahan['id'] == 'all'){
|
||||
$filter_district = "AND M_DistrictID = {$district['id']}";
|
||||
}
|
||||
|
||||
if($kelurahan['id'] != 'all'){
|
||||
$filter_kelurahan = "AND M_KelurahanID = {$kelurahan['id']}";
|
||||
}
|
||||
|
||||
$having = "";
|
||||
if($status != 'A'){
|
||||
$having = "HAVING status = '{$prm['status']}'";
|
||||
}
|
||||
|
||||
// echo $norm;
|
||||
|
||||
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM (
|
||||
SELECT xid, xnumber, xdate, courier_id, courier_name, kelurahanid, districtid, cityid, xtype_name, xtype_code,
|
||||
GROUP_CONCAT(DISTINCT M_DistrictName separator ' , ') as districts,
|
||||
GROUP_CONCAT(DISTINCT M_KelurahanName separator ' , ') as kelurahans,
|
||||
IF(ISNULL(Management_CourierID),'N','Y') as status
|
||||
FROM (
|
||||
SELECT So_WalkLetterCourierID as xid,
|
||||
So_WalkLetterCourierNumbering as xnumber,
|
||||
DATE_FORMAT(So_WalkLetterCourierDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_KelurahanID as kelurahanid,
|
||||
M_DistrictID as districtid,
|
||||
M_CityID as cityid,
|
||||
'KIRIM IMAGE' as xtype_name,
|
||||
'SI' as xtype_code
|
||||
FROM so_walklettercourier
|
||||
JOIN m_staff ON So_WalkLetterCourierM_StaffID = M_StaffID
|
||||
JOIN m_courier ON M_COurierM_StaffID = M_StaffID
|
||||
JOIN m_doctoraddress ON So_WalkLetterCourierM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
So_WalkLetterCourierIsActive = 'Y' AND So_WalkLetterCourierDate = '{$xdate}'
|
||||
UNION
|
||||
SELECT Courier_AdHocID as xid,
|
||||
Courier_AdHocNumbering as xnumber,
|
||||
DATE_FORMAT(Courier_AdHocDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_KelurahanID as kelurahanid,
|
||||
M_DistrictID as districtid,
|
||||
M_CityID as cityid,
|
||||
Courier_AdHocTaskLabel as xtype_name,
|
||||
'AC' as xtype_code
|
||||
FROM courier_adhoc
|
||||
JOIN m_courier ON Courier_AdHocM_CourierID = M_CourierID
|
||||
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
JOIN m_kelurahan ON Courier_AdHocM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
Courier_AdHocIsActive = 'Y' AND Courier_AdHocDate = '{$xdate}'
|
||||
UNION
|
||||
SELECT So_WalkLetterResultID as xid,
|
||||
So_WalkLetterResultNumbering as xnumber,
|
||||
DATE_FORMAT(So_WalkLetterResultDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_KelurahanID as kelurahanid,
|
||||
M_DistrictID as districtid,
|
||||
M_CityID as cityid,
|
||||
'KIRIM HASIL DOKTER' as xtype_name,
|
||||
'SR' as xtype_code
|
||||
FROM so_walkletterresult
|
||||
JOIN m_staff ON So_WalkLetterResultM_StaffID = M_StaffID
|
||||
JOIN m_courier ON M_COurierM_StaffID = M_StaffID
|
||||
JOIN m_doctoraddress ON So_WalkLetterResultM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
So_WalkLetterResultIsActive = 'Y' AND So_WalkLetterResultDate = '{$xdate}'
|
||||
UNION
|
||||
SELECT Result_CourierSPKID as xid,
|
||||
Result_CourierSPKNumbering as xnumber,
|
||||
DATE_FORMAT(Result_CourierSPKDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_KelurahanID as kelurahanid,
|
||||
M_DistrictID as districtid,
|
||||
M_CityID as cityid,
|
||||
'PENGIRIMAN HASIL' as xtype_name,
|
||||
'DR' as xtype_code
|
||||
FROM result_courierspk
|
||||
JOIN result_courierspk_detail ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
||||
JOIN m_courier ON Result_CourierSPKM_CourierID = M_CourierID
|
||||
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
JOIN t_orderdelivery ON Result_CourierSPKDetailT_OrderDeliveryID = T_OrderDeliveryID
|
||||
JOIN m_kelurahan ON T_OrderDeliveryM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
Result_CourierSPKIsActive = 'Y' AND Result_CourierSPKDate = '{$xdate}'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
UNION
|
||||
SELECT
|
||||
T_ReceiverefDistributCourierID as xid,
|
||||
T_ReceiverefDistributCourierNumber as xnumber,
|
||||
DATE_FORMAT(T_ReceiverefDistributCourierDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_CompanyM_KelurahanID as kelurahanid,
|
||||
M_CompanyM_DistrictID as districtid,
|
||||
M_CompanyM_CityID as cityid,
|
||||
'RUJUKAN EKSTERNAL' as xtype_name,
|
||||
'EL' as xtype_code
|
||||
FROM t_receiverefdistributcourier
|
||||
JOIN t_receiverefdistributcourierdetail ON T_ReceiverefDistributCourierID = T_ReceiverefDistributCourierDetailT_ReceiverefDistributCourierID AND T_ReceiverefDistributCourierDetailIsActive = 'Y'
|
||||
JOIN t_receivereferencedelivery ON T_ReceiverefDistributCourierDetailT_ReceiveReferenceDeliveryID = T_ReceiveReferenceDeliveryID
|
||||
JOIN m_company ON T_ReceiveReferenceDeliveryM_CompanyID = M_CompanyID
|
||||
JOIN m_staff ON T_ReceiverefDistributCourierM_StaffID = M_StaffID
|
||||
JOIN m_courier ON M_COurierM_StaffID = M_StaffID
|
||||
JOIN m_kelurahan ON M_CompanyM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_CompanyM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_CompanyM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
T_ReceiverefDistributCourierIsActive = 'Y' AND T_ReceiverefDistributCourierDate = '{$xdate}'
|
||||
)x
|
||||
JOIN m_district ON M_DistrictID = x.districtid
|
||||
JOIN m_kelurahan ON M_KelurahanID = x.kelurahanid
|
||||
LEFT JOIN management_courier ON Management_CourierReffNumbering = xnumber AND Management_CourierReffID = xid AND Management_CourierIsActive = 'Y'
|
||||
GROUP BY xnumber
|
||||
$having
|
||||
) cc
|
||||
";
|
||||
//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 xid, xnumber, xdate, courier_id, courier_name, kelurahanid, districtid, cityid, xtype_name, xtype_code,
|
||||
GROUP_CONCAT(DISTINCT M_DistrictName separator ' , ') as districts,
|
||||
GROUP_CONCAT(DISTINCT M_KelurahanName separator ' , ') as kelurahans,
|
||||
IF(ISNULL(Management_CourierID),'N','Y') as status
|
||||
FROM (
|
||||
SELECT So_WalkLetterCourierID as xid,
|
||||
So_WalkLetterCourierNumbering as xnumber,
|
||||
DATE_FORMAT(So_WalkLetterCourierDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_KelurahanID as kelurahanid,
|
||||
M_DistrictID as districtid,
|
||||
M_CityID as cityid,
|
||||
'KIRIM IMAGE' as xtype_name,
|
||||
'SI' as xtype_code
|
||||
FROM so_walklettercourier
|
||||
JOIN m_staff ON So_WalkLetterCourierM_StaffID = M_StaffID
|
||||
JOIN m_courier ON M_COurierM_StaffID = M_StaffID
|
||||
JOIN m_doctoraddress ON So_WalkLetterCourierM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
So_WalkLetterCourierIsActive = 'Y' AND So_WalkLetterCourierDate = '{$xdate}'
|
||||
UNION
|
||||
SELECT Courier_AdHocID as xid,
|
||||
Courier_AdHocNumbering as xnumber,
|
||||
DATE_FORMAT(Courier_AdHocDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_KelurahanID as kelurahanid,
|
||||
M_DistrictID as districtid,
|
||||
M_CityID as cityid,
|
||||
Courier_AdHocTaskLabel as xtype_name,
|
||||
'AC' as xtype_code
|
||||
FROM courier_adhoc
|
||||
JOIN m_courier ON Courier_AdHocM_CourierID = M_CourierID
|
||||
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
JOIN m_kelurahan ON Courier_AdHocM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
Courier_AdHocIsActive = 'Y' AND Courier_AdHocDate = '{$xdate}'
|
||||
UNION
|
||||
SELECT So_WalkLetterResultID as xid,
|
||||
So_WalkLetterResultNumbering as xnumber,
|
||||
DATE_FORMAT(So_WalkLetterResultDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_KelurahanID as kelurahanid,
|
||||
M_DistrictID as districtid,
|
||||
M_CityID as cityid,
|
||||
'KIRIM HASIL DOKTER' as xtype_name,
|
||||
'SR' as xtype_code
|
||||
FROM so_walkletterresult
|
||||
JOIN m_staff ON So_WalkLetterResultM_StaffID = M_StaffID
|
||||
JOIN m_courier ON M_COurierM_StaffID = M_StaffID
|
||||
JOIN m_doctoraddress ON So_WalkLetterResultM_DoctorAddressID = M_DoctorAddressID
|
||||
JOIN m_kelurahan ON M_DoctorAddressM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
So_WalkLetterResultIsActive = 'Y' AND So_WalkLetterResultDate = '{$xdate}'
|
||||
UNION
|
||||
SELECT Result_CourierSPKID as xid,
|
||||
Result_CourierSPKNumbering as xnumber,
|
||||
DATE_FORMAT(Result_CourierSPKDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_KelurahanID as kelurahanid,
|
||||
M_DistrictID as districtid,
|
||||
M_CityID as cityid,
|
||||
'PENGIRIMAN HASIL' as xtype_name,
|
||||
'DR' as xtype_code
|
||||
FROM result_courierspk
|
||||
JOIN result_courierspk_detail ON Result_CourierSPKDetailResult_CourierSPKID = Result_CourierSPKID
|
||||
JOIN m_courier ON Result_CourierSPKM_CourierID = M_CourierID
|
||||
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
JOIN t_orderdelivery ON Result_CourierSPKDetailT_OrderDeliveryID = T_OrderDeliveryID
|
||||
JOIN m_kelurahan ON T_OrderDeliveryM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_KelurahanM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_DistrictM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
Result_CourierSPKIsActive = 'Y' AND Result_CourierSPKDate = '{$xdate}'
|
||||
GROUP BY T_OrderDeliveryID
|
||||
UNION
|
||||
SELECT
|
||||
T_ReceiverefDistributCourierID as xid,
|
||||
T_ReceiverefDistributCourierNumber as xnumber,
|
||||
DATE_FORMAT(T_ReceiverefDistributCourierDate,'%d-%m-%Y') as xdate,
|
||||
M_CourierID as courier_id,
|
||||
M_StaffName as courier_name,
|
||||
M_CompanyM_KelurahanID as kelurahanid,
|
||||
M_CompanyM_DistrictID as districtid,
|
||||
M_CompanyM_CityID as cityid,
|
||||
'RUJUKAN EKSTERNAL' as xtype_name,
|
||||
'EL' as xtype_code
|
||||
FROM t_receiverefdistributcourier
|
||||
JOIN t_receiverefdistributcourierdetail ON T_ReceiverefDistributCourierID = T_ReceiverefDistributCourierDetailT_ReceiverefDistributCourierID AND T_ReceiverefDistributCourierDetailIsActive = 'Y'
|
||||
JOIN t_receivereferencedelivery ON T_ReceiverefDistributCourierDetailT_ReceiveReferenceDeliveryID = T_ReceiveReferenceDeliveryID
|
||||
JOIN m_company ON T_ReceiveReferenceDeliveryM_CompanyID = M_CompanyID
|
||||
JOIN m_staff ON T_ReceiverefDistributCourierM_StaffID = M_StaffID
|
||||
JOIN m_courier ON M_COurierM_StaffID = M_StaffID
|
||||
JOIN m_kelurahan ON M_CompanyM_KelurahanID = M_KelurahanID $filter_kelurahan
|
||||
JOIN m_district ON M_CompanyM_DistrictID = M_DistrictID $filter_district
|
||||
JOIN m_city ON M_CompanyM_CityID = M_CityID $filter_city
|
||||
WHERE
|
||||
T_ReceiverefDistributCourierIsActive = 'Y' AND T_ReceiverefDistributCourierDate = '{$xdate}'
|
||||
)x
|
||||
JOIN m_district ON M_DistrictID = x.districtid
|
||||
JOIN m_kelurahan ON M_KelurahanID = x.kelurahanid
|
||||
LEFT JOIN management_courier ON Management_CourierReffNumbering = xnumber AND Management_CourierReffID = xid AND Management_CourierIsActive = 'Y'
|
||||
GROUP BY xnumber
|
||||
$having
|
||||
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 getinitdata(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query =" SELECT M_CityID as id, M_CityName as name
|
||||
FROM m_city
|
||||
WHERE
|
||||
M_CityIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['cities'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['cities_form'] = $rows['cities'];
|
||||
array_push($rows['cities'],array('id'=>'all','name'=>'Semua Kecamatan'));
|
||||
$query =" SELECT M_CityID as id, M_CityName as name
|
||||
FROM m_city
|
||||
JOIN m_branch ON M_BranchM_CityID = M_CityID AND M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'
|
||||
WHERE
|
||||
M_CityIsActive = 'Y' LIMIT 1
|
||||
";
|
||||
//echo $query;
|
||||
$rows['selected_city'] = $this->db_onedev->query($query)->row_array();
|
||||
$query =" SELECT M_DistrictID as id, M_DistrictName as name
|
||||
FROM m_district
|
||||
WHERE
|
||||
M_DistrictM_CityID = {$rows['selected_city']['id']} AND M_DistrictIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['districts'] = $this->db_onedev->query($query)->result_array();
|
||||
$rows['districts_form'] = $rows['districts'];
|
||||
array_push($rows['districts'],array('id'=>'all','name'=>'Semua Kecamatan'));
|
||||
$rows['selected_district'] = array('id'=>'all','name'=>'Semua Kecamatan');
|
||||
$rows['kelurahans'] = array(array('id'=>'all','name'=>'Semua Kelurahan'));
|
||||
$rows['selected_kelurahan'] = array('id'=>'all','name'=>'Semua Kelurahan');
|
||||
$query =" SELECT M_CourierID as id, M_StaffName as name
|
||||
FROM m_courier
|
||||
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
WHERE
|
||||
M_StaffIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['couriers'] = $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 M_KelurahanID as id, M_KelurahanName as name
|
||||
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;
|
||||
$query ="UPDATE m_doctor SET
|
||||
M_DoctorPrefix = '{$prm['M_DoctorPrefix']}',
|
||||
M_DoctorName = '{$prm['M_DoctorName']}',
|
||||
M_DoctorSufix = '{$prm['M_DoctorSufix']}',
|
||||
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_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']}'
|
||||
WHERE
|
||||
M_DoctorID = '{$prm['M_DoctorID']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function newdoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query ="INSERT INTO m_doctor (
|
||||
M_DoctorPrefix,
|
||||
M_DoctorName,
|
||||
M_DoctorSufix,
|
||||
M_DoctorM_SexID,
|
||||
M_DoctorM_ReligionID,
|
||||
M_DoctorEmail,
|
||||
M_DoctorHP,
|
||||
M_DoctorPhone,
|
||||
M_DoctorIsMarketingConfirm,
|
||||
M_DoctorIsPJ,
|
||||
M_DoctorIsDefaultPJ,
|
||||
M_DoctorIsClinic,
|
||||
M_DoctorIsDefault,
|
||||
M_DoctorCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['M_DoctorPrefix']}',
|
||||
'{$prm['M_DoctorName']}',
|
||||
'{$prm['M_DoctorSufix']}',
|
||||
'{$prm['M_DoctorM_SexID']}',
|
||||
'{$prm['M_DoctorM_ReligionID']}',
|
||||
'{$prm['M_DoctorEmail']}',
|
||||
'{$prm['M_DoctorHP']}',
|
||||
'{$prm['M_DoctorPhone']}',
|
||||
'{$prm['M_DoctorIsMarketingConfirm']}',
|
||||
'{$prm['M_DoctorIsPJ']}',
|
||||
'{$prm['M_DoctorIsDefaultPJ']}',
|
||||
'{$prm['M_DoctorIsClinic']}',
|
||||
'{$prm['M_DoctorIsDefault']}',
|
||||
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 dochangecourier(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
if($prm['xtype_code'] === 'AC'){
|
||||
$query ="UPDATE courier_adhoc SET
|
||||
Courier_AdHocM_CourierID = '{$prm['courier_change']['id']}'
|
||||
WHERE
|
||||
Courier_AdHocID = '{$prm['xid']}' AND Courier_AdHocNumbering = '{$prm['xnumber']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($prm['xtype_code'] === 'SI'){
|
||||
$query = " SELECT *
|
||||
FROM m_courier
|
||||
WHERE
|
||||
M_CourierID = '{$prm['courier_change']['id']}'";
|
||||
$m_staffid = $this->db_onedev->query($query)->row()->M_CourierM_StaffID;
|
||||
$query ="UPDATE so_walklettercourier SET
|
||||
So_WalkLetterCourierM_StaffID = '{$m_staffid}'
|
||||
WHERE
|
||||
So_WalkLetterCourierID = '{$prm['xid']}' AND So_WalkLetterCourierNumbering = '{$prm['xnumber']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($prm['xtype_code'] === 'SR'){
|
||||
$query = " SELECT *
|
||||
FROM m_courier
|
||||
WHERE
|
||||
M_CourierID = '{$prm['courier_change']['id']}'";
|
||||
$m_staffid = $this->db_onedev->query($query)->row()->M_CourierM_StaffID;
|
||||
$query ="UPDATE so_walkletterresult SET
|
||||
So_WalkLetterResultM_StaffID = '{$m_staffid}'
|
||||
WHERE
|
||||
So_WalkLetterResultID = '{$prm['xid']}' AND So_WalkLetterResultNumbering = '{$prm['xnumber']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($prm['xtype_code'] === 'DR'){
|
||||
$query ="UPDATE result_courierspk SET
|
||||
Result_CourierSPKM_CourierID = '{$prm['courier_change']['id']}'
|
||||
WHERE
|
||||
Result_CourierSPKID = '{$prm['xid']}' AND Result_CourierSPKNumbering = '{$prm['xnumber']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
if($prm['xtype_code'] === 'EL'){
|
||||
//echo $prm['courier_change']['id'];
|
||||
$query = " SELECT *
|
||||
FROM m_courier
|
||||
WHERE
|
||||
M_CourierID = '{$prm['courier_change']['id']}'";
|
||||
//echo $query;
|
||||
$m_staffid = $this->db_onedev->query($query)->row()->M_CourierM_StaffID;
|
||||
//echo $m_staffid;
|
||||
$query ="UPDATE t_receiverefdistributcourier SET
|
||||
T_ReceiverefDistributCourierM_StaffID = '{$m_staffid}'
|
||||
WHERE
|
||||
T_ReceiverefDistributCourierID = '{$prm['xid']}' AND T_ReceiverefDistributCourierNumber = '{$prm['xnumber']}'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deletedoctor(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$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')
|
||||
);
|
||||
$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 savenewtask(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$numbering = $this->db_onedev->query("SELECT fn_numbering('AC') as numbering")->row()->numbering;
|
||||
$query ="INSERT INTO courier_adhoc (
|
||||
Courier_AdHocNumbering,
|
||||
Courier_AdHocDate,
|
||||
Courier_AdHocTime,
|
||||
Courier_AdHocM_CourierID,
|
||||
Courier_AdHocTaskLabel,
|
||||
Courier_AdHocTaskNote,
|
||||
Courier_AdHocM_KelurahanID,
|
||||
Courier_AdHocUserID,
|
||||
Courier_AdHocCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$numbering}',
|
||||
'{$prm['xdate']}',
|
||||
'{$prm['xtime']}',
|
||||
'{$prm['courier']['id']}',
|
||||
'{$prm['xlabel']}',
|
||||
'{$prm['xnote']}',
|
||||
'{$prm['kelurahan']['id']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getcourier(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$query =" SELECT M_CourierID as id, M_StaffName as name
|
||||
FROM m_courier
|
||||
JOIN m_staff ON M_CourierM_StaffID = M_StaffID
|
||||
WHERE
|
||||
M_StaffIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function saveeditaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$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')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function deleteaddress(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$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')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function approve(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
|
||||
$query = " INSERT management_courier (
|
||||
Management_CourierDate,
|
||||
Management_CourierType,
|
||||
Management_CourierReffID,
|
||||
Management_CourierReffNumbering,
|
||||
Management_CourierUserID,
|
||||
Management_CourierCreated
|
||||
)
|
||||
VALUES(
|
||||
NOW(),
|
||||
'{$prm['xtype_code']}',
|
||||
'{$prm['xid']}',
|
||||
'{$prm['xnumber']}',
|
||||
'{$userid}',
|
||||
NOW()
|
||||
)";
|
||||
//echo $query;
|
||||
$this->db_onedev->query($query);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK')
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user