Initial import

This commit is contained in:
sas.fajri
2026-04-27 10:26:26 +07:00
commit bf9b9097ee
2388 changed files with 3002242 additions and 0 deletions

View File

@@ -0,0 +1,931 @@
<?php
class Config extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "BRANCH API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function lookuphspricebyname(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$hsprice = $prm['branch'];
$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 one_hs.hs_config
WHERE
HS_ConfigIsActive = 'Y'";
// $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("hs_config count", $this->db_onedev);
exit;
}
$sql = "select HS_ConfigID as id,
one_hs.hs_config.*
from one_hs.hs_config
WHERE
HS_ConfigIsActive = 'Y'
GROUP BY HS_ConfigID
ORDER BY HS_ConfigID DESC
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("hs_config select");
exit;
}
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function lookupregionalbyname()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$regional = $prm['regional'];
$hsprice = $prm['hsprice'];
$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 s_regional
LEFT JOIN one_hs.hs_config ON S_RegionalID = HS_ConfigS_RegionalID AND HS_ConfigIsActive = 'Y'
where
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
IFNULL(HS_ConfigName,'') LIKE CONCAT('%','{$hsprice}','%') AND
S_RegionalIsActive = 'Y'
GROUP BY S_RegionalID) a";
$sql_param = array($search);
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$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("s_regional count", $this->db_onedev);
exit;
}
$sql = "select S_RegionalID as id,
S_RegionalName as name,
S_RegionalName as namex,
s_regional.*
from s_regional
LEFT JOIN one_hs.hs_config ON S_RegionalID = HS_ConfigS_RegionalID AND HS_ConfigIsActive = 'Y'
where
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
IFNULL(HS_ConfigName,'') LIKE CONCAT('%','{$hsprice}','%') AND
S_RegionalIsActive = 'Y'
GROUP BY S_RegionalID
ORDER BY S_RegionalName 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("s_regional select");
exit;
}
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewregional()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$name = $prm['name'];
$sql = "insert into s_regional(
S_RegionalName,
S_RegionalCreated,
S_RegionalLastUpdated
)
values( ?, now(), now())";
$query = $this->db_onedev->query($sql,
array(
$name
)
);
//echo $query;
if (!$query) {
$this->sys_error_db("s_regional insert");
exit;
}
$last_id = $this->db_onedev->insert_id();
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
$last_id = $this->db_onedev->insert_id();
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function editregional()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$id = $prm['id'];
$name = $prm['name'];
$userid = $this->sys_user["M_UserID"];
$sqlcompany = "update s_regional SET
S_RegionalName = ?,
S_RegionalLastUpdated = now()
where
S_RegionalID = ?
";
$querycompany = $this->db_onedev->query($sqlcompany,
array(
$name,
$id
)
);
// echo $query;
if (!$querycompany) {
$this->sys_error_db("s_regional update");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => $id));
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewhsprice()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$sql = $this->db_onedev->query("SELECT M_BranchID as branchid FROM m_branch
WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'")->row();
//echo $this->db_onedev->last_query();
$branchid = $sql->branchid;
$HS_ConfigLat = $prm['lat'];
$HS_ConfigLong = $prm['long'];
$HS_ConfigMaxDistance = $prm['max'];
$HS_ConfigMinOrder = $prm['price'];
$HS_ConfigAPDFee = $prm['apd'];
$HS_ConfigSecondVisitPercent = $prm['visit'];
$userid = $this->sys_user["M_UserID"];
if($prm['xid'] == 0){
$sql = "insert into one_hs.hs_config(
HS_ConfigM_BranchID,
HS_ConfigMinDistance,
HS_ConfigMaxDistance,
HS_ConfigAmount,
HS_ConfigAPDFee,
HS_ConfigSecondVisitPercent,
HS_ConfigCreated,
HS_ConfigLastUpdated,
HS_ConfigUserID)
values($branchid,$HS_ConfigMinDistance,$HS_ConfigMaxDistance,$HS_ConfigAmount,$HS_ConfigAPDFee,$HS_ConfigSecondVisitPercent,now(),now(),$userid)";
$query = $this->db_onedev->query($sql);
if (!$query) {
$this->sys_error_db("hs_config 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 one_hs.hs_config SET HS_ConfigLat = '{$HS_ConfigLat}',
HS_ConfigLong = '{$HS_ConfigLong}',
HS_ConfigMaxDistance = '{$HS_ConfigMaxDistance}',
HS_ConfigMinOrder = '{$HS_ConfigMinOrder}',
HS_ConfigAPDFee = '{$HS_ConfigAPDFee}',
HS_ConfigSecondVisitPercent = '{$HS_ConfigSecondVisitPercent}',
HS_ConfigUserID = '{$userid}',
HS_ConfigLastUpdated = now()
WHERE HS_ConfigID = '{$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 deleteregional()
{
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 s_regional SET
S_RegionalIsActive = 'N',
S_RegionalLastUpdated = now()
WHERE
S_RegionalID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("s_regional delete");
exit;
}
$sql = "update one_hs.hs_config SET
HS_ConfigIsActive = 'N',
HS_ConfigLastUpdated = now()
WHERE
HS_ConfigS_RegionalID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("hs_config 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 deletehsprice()
{
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 one_hs.hs_config SET
HS_ConfigIsActive = 'N',
HS_ConfigLastUpdated = now()
WHERE
HS_ConfigID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("hs_config 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 searchakun(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['tes'] != '')
{
$q['search'] = "%{$prm['tes']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_bank_account
WHERE
M_BankAccountNo like ?
AND M_BankAccountIsActive = '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_bank_account count",$this->db_onedev);
exit;
}
$sql = "
SELECT M_BankAccountID,CONCAT(Nat_BankName, ' [',M_BankAccountNo,'] ') as M_BankAccountNo
FROM m_bank_account
JOIN nat_bank ON Nat_BankID = M_BankAccountNat_BankID
WHERE
CONCAT(Nat_BankName, ' [',M_BankAccountNo,'] ') like ?
AND M_BankAccountIsActive = 'Y'
ORDER BY Nat_BankName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_bank_account rows",$this->db_onedev);
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 searchregionalbyname(){
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 s_regional
WHERE
S_RegionalName like ?
AND S_RegionalIsActive = '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("s_regional count",$this->db_onedev);
exit;
}
$sql = "
SELECT S_RegionalID, S_RegionalName
FROM s_regional
WHERE
S_RegionalName like ?
AND S_RegionalIsActive = 'Y'
ORDER BY S_RegionalName 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("s_regional rows",$this->db_onedev);
exit;
}
}
function searchpaymenttype(){
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_paymenttype
WHERE
M_PaymentTypeName like ?
AND M_PaymentTypeIsActive = '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_subcategory count",$this->db_onedev);
exit;
}
$sql = "
SELECT M_PaymentTypeID, M_PaymentTypeName
FROM m_paymenttype
WHERE
M_PaymentTypeName like ?
AND M_PaymentTypeIsActive = 'Y'
ORDER BY M_PaymentTypeName 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_subcategory rows",$this->db_onedev);
exit;
}
}
function searchdistrict(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_district
WHERE
M_DistrictName like ?
AND M_DistrictT_SubCategoryID = '{$id}'
AND M_DistrictIsActive = '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_district count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_district
WHERE
M_DistrictName like ?
AND M_DistrictT_SubCategoryID = '{$id}'
AND M_DistrictIsActive = 'Y'
ORDER BY M_DistrictName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_district rows",$this->db_onedev);
exit;
}
}
function searchkelurahan(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_kelurahan
WHERE
M_KelurahanName like ?
AND M_KelurahanM_DistrictID = '{$id}'
AND M_KelurahanIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_district count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_kelurahan
WHERE
M_KelurahanName like ?
AND M_KelurahanM_DistrictID = '{$id}'
AND M_KelurahanIsActive = 'Y'
ORDER BY M_KelurahanName ASC
";
$query = $this->db_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_district rows",$this->db_onedev);
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_company count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_company
WHERE
M_CompanyName like ?
AND M_CompanyIsActive = 'Y'
ORDER BY M_CompanyName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_company rows",$this->db_onedev);
exit;
}
}
function searchmou(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_mou
WHERE
M_MouName like ?
AND M_MouM_CompanyID = '{$id}'
AND M_MouIsActive = 'Y'";
$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_mou count",$this->db_onedev);
exit;
}
$sql = "SELECT *
FROM m_mou
WHERE
M_MouName like ?
AND M_MouM_CompanyID = '{$id}'
AND M_MouIsActive = 'Y'
ORDER BY M_MouName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
// echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_mou rows",$this->db_onedev);
exit;
}
}
function searchdoctor(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
FROM m_doctor
WHERE M_DoctorIsActive = 'Y') a
WHERE
M_DoctorName like ?";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_doctor count",$this->db_onedev);
exit;
}
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
FROM m_doctor
WHERE M_DoctorIsActive = 'Y') a
WHERE
M_DoctorName like ?
GROUP BY M_DoctorID
ORDER BY M_DoctorName ASC";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_doctor rows",$this->db_onedev);
exit;
}
}
function selectaddressdoctor(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$rows = [];
$query ="SELECT M_DoctorAddressID,
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
FROM
m_doctoraddress
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
//echo $query;
$rows['addressdoctors'] = $this->db_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);
}
}
}

View File

@@ -0,0 +1,930 @@
<?php
class Mou extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "BRANCH API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function lookuppgbankbyname(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$pgbank = $prm['branch'];
$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 one_hs.hs_mou
JOIN m_mou ON M_MouID = HS_MouM_MouID
WHERE
(M_MouNumber LIKE CONCAT('%','{$pgbank}','%') OR
M_MouName LIKE CONCAT('%','{$pgbank}','%')) AND
HS_MouIsActive = 'Y'";
// $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("one_hs.hs_mou count", $this->db_onedev);
exit;
}
$sql = "select HS_MouID as id,
M_MouID,
CONCAT(M_MouName,' [',M_MouNumber,'] ') M_MouNumber,
M_MouName,
M_CompanyID,
M_CompanyName,
'' as waktuupload,
'' as status,
one_hs.hs_mou.*
from one_hs.hs_mou
JOIN m_mou ON M_MouID = HS_MouM_MouID
JOIN m_company ON M_CompanyID = M_MouM_CompanyID
WHERE
(M_MouNumber LIKE CONCAT('%','{$pgbank}','%') OR
M_MouName LIKE CONCAT('%','{$pgbank}','%')) AND
HS_MouIsActive = 'Y'
GROUP BY HS_MouID
ORDER BY M_MouName 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("one_hs.hs_mou select");
exit;
}
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function lookupregionalbyname()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$regional = $prm['regional'];
$pgbank = $prm['pgbank'];
$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 s_regional
LEFT JOIN one_hs.hs_mou ON S_RegionalID = HS_MouS_RegionalID AND HS_MouIsActive = 'Y'
where
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
IFNULL(HS_MouName,'') LIKE CONCAT('%','{$pgbank}','%') AND
S_RegionalIsActive = 'Y'
GROUP BY S_RegionalID) a";
$sql_param = array($search);
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$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("s_regional count", $this->db_onedev);
exit;
}
$sql = "select S_RegionalID as id,
S_RegionalName as name,
S_RegionalName as namex,
s_regional.*
from s_regional
LEFT JOIN one_hs.hs_mou ON S_RegionalID = HS_MouS_RegionalID AND HS_MouIsActive = 'Y'
where
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
IFNULL(HS_MouName,'') LIKE CONCAT('%','{$pgbank}','%') AND
S_RegionalIsActive = 'Y'
GROUP BY S_RegionalID
ORDER BY S_RegionalName 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("s_regional select");
exit;
}
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewregional()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$name = $prm['name'];
$sql = "insert into s_regional(
S_RegionalName,
S_RegionalCreated,
S_RegionalLastUpdated
)
values( ?, now(), now())";
$query = $this->db_onedev->query($sql,
array(
$name
)
);
//echo $query;
if (!$query) {
$this->sys_error_db("s_regional insert");
exit;
}
$last_id = $this->db_onedev->insert_id();
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
$last_id = $this->db_onedev->insert_id();
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function editregional()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$id = $prm['id'];
$name = $prm['name'];
$userid = $this->sys_user["M_UserID"];
$sqlcompany = "update s_regional SET
S_RegionalName = ?,
S_RegionalLastUpdated = now()
where
S_RegionalID = ?
";
$querycompany = $this->db_onedev->query($sqlcompany,
array(
$name,
$id
)
);
// echo $query;
if (!$querycompany) {
$this->sys_error_db("s_regional update");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => $id));
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewpgbank()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$HS_MouM_MouID = $prm['mouid'];
$userid = $this->sys_user["M_UserID"];
if($prm['xid'] == 0){
$sql = "insert into one_hs.hs_mou(
HS_MouM_MouID,
HS_MouCreated,
HS_MouLastUpdated,
HS_MouUserID)
values(?,now(),now(),?)";
$query = $this->db_onedev->query($sql,
array(
$HS_MouM_MouID,
$userid)
);
if (!$query) {
$this->sys_error_db("one_hs.hs_mou 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 one_hs.hs_mou SET HS_MouStatus = 'N',
HS_MouRetry = HS_MouRetry + 1,
HS_MouUserID = '{$userid}',
HS_MouLastUpdated = now()
WHERE HS_MouID = '{$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 deleteregional()
{
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 s_regional SET
S_RegionalIsActive = 'N',
S_RegionalLastUpdated = now()
WHERE
S_RegionalID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("s_regional delete");
exit;
}
$sql = "update one_hs.hs_mou SET
HS_MouIsActive = 'N',
HS_MouLastUpdated = now()
WHERE
HS_MouS_RegionalID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("one_hs.hs_mou 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 deletepgbank()
{
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 one_hs.hs_mou SET
HS_MouIsActive = 'N',
HS_MouLastUpdated = now()
WHERE
HS_MouID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("one_hs.hs_mou 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 searchakun(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['tes'] != '')
{
$q['search'] = "%{$prm['tes']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_mou
WHERE
M_MouNumber like ?
AND M_MouIsActive = '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_mou count",$this->db_onedev);
exit;
}
$sql = "
SELECT M_MouID,CONCAT(M_MouName, ' [',M_MouNumber,'] ') as M_MouNumber
FROM m_mou
JOIN m_company ON M_CompanyID = M_MouM_CompanyID
WHERE
CONCAT(M_MouName, ' [',M_MouNumber,'] ') like ?
AND M_MouIsActive = 'Y'
ORDER BY M_MouName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_mou rows",$this->db_onedev);
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 searchregionalbyname(){
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 s_regional
WHERE
S_RegionalName like ?
AND S_RegionalIsActive = '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("s_regional count",$this->db_onedev);
exit;
}
$sql = "
SELECT S_RegionalID, S_RegionalName
FROM s_regional
WHERE
S_RegionalName like ?
AND S_RegionalIsActive = 'Y'
ORDER BY S_RegionalName 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("s_regional rows",$this->db_onedev);
exit;
}
}
function searchpaymenttype(){
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_paymenttype
WHERE
M_PaymentTypeName like ?
AND M_PaymentTypeIsActive = '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_subcategory count",$this->db_onedev);
exit;
}
$sql = "
SELECT M_PaymentTypeID, M_PaymentTypeName
FROM m_paymenttype
WHERE
M_PaymentTypeName like ?
AND M_PaymentTypeIsActive = 'Y'
ORDER BY M_PaymentTypeName 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_subcategory rows",$this->db_onedev);
exit;
}
}
function searchdistrict(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_district
WHERE
M_DistrictName like ?
AND M_DistrictT_SubCategoryID = '{$id}'
AND M_DistrictIsActive = '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_district count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_district
WHERE
M_DistrictName like ?
AND M_DistrictT_SubCategoryID = '{$id}'
AND M_DistrictIsActive = 'Y'
ORDER BY M_DistrictName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_district rows",$this->db_onedev);
exit;
}
}
function searchkelurahan(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_kelurahan
WHERE
M_KelurahanName like ?
AND M_KelurahanM_DistrictID = '{$id}'
AND M_KelurahanIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_district count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_kelurahan
WHERE
M_KelurahanName like ?
AND M_KelurahanM_DistrictID = '{$id}'
AND M_KelurahanIsActive = 'Y'
ORDER BY M_KelurahanName ASC
";
$query = $this->db_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_district rows",$this->db_onedev);
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['tes'] != '')
{
$q['search'] = "%{$prm['tes']}%";
}
// 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_company count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_company
WHERE
M_CompanyName like ?
AND M_CompanyIsActive = 'Y'
ORDER BY M_CompanyName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_company rows",$this->db_onedev);
exit;
}
}
function searchmou(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_mou
WHERE
M_MouName like ?
AND M_MouM_CompanyID = '{$id}'
AND M_MouIsActive = 'Y' AND M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now()) AND M_MouIsReleased = '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_mou count",$this->db_onedev);
exit;
}
$sql = "SELECT *
FROM m_mou
WHERE
M_MouName like ?
AND M_MouM_CompanyID = '{$id}'
AND M_MouIsActive = 'Y' AND M_MouIsApproved = 'Y' and M_MouStartDate <= date(now()) and M_MouEndDate >= date(now()) AND M_MouIsReleased = 'Y'
ORDER BY M_MouName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
// echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_mou rows",$this->db_onedev);
exit;
}
}
function searchdoctor(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
FROM m_doctor
WHERE M_DoctorIsActive = 'Y') a
WHERE
M_DoctorName like ?";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_doctor count",$this->db_onedev);
exit;
}
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
FROM m_doctor
WHERE M_DoctorIsActive = 'Y') a
WHERE
M_DoctorName like ?
GROUP BY M_DoctorID
ORDER BY M_DoctorName ASC";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_doctor rows",$this->db_onedev);
exit;
}
}
function selectaddressdoctor(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$rows = [];
$query ="SELECT M_DoctorAddressID,
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
FROM
m_doctoraddress
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
//echo $query;
$rows['addressdoctors'] = $this->db_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);
}
}
}

View File

@@ -0,0 +1,923 @@
<?php
class Price extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "BRANCH API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function lookuphspricebyname(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$hsprice = $prm['branch'];
$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 one_hs.hs_price
WHERE
HS_PriceIsActive = 'Y'";
// $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("hs_price count", $this->db_onedev);
exit;
}
$sql = "select HS_PriceID as id,
one_hs.hs_price.*
from one_hs.hs_price
WHERE
HS_PriceIsActive = 'Y'
GROUP BY HS_PriceID
ORDER BY HS_PriceMinDistance ASC, HS_PriceMaxDistance 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("hs_price select");
exit;
}
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function lookupregionalbyname()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$regional = $prm['regional'];
$hsprice = $prm['hsprice'];
$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 s_regional
LEFT JOIN one_hs.hs_price ON S_RegionalID = HS_PriceS_RegionalID AND HS_PriceIsActive = 'Y'
where
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
IFNULL(HS_PriceName,'') LIKE CONCAT('%','{$hsprice}','%') AND
S_RegionalIsActive = 'Y'
GROUP BY S_RegionalID) a";
$sql_param = array($search);
// $total = $this->db_onedev->query($sql,$sql_param)->row()->total;
$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("s_regional count", $this->db_onedev);
exit;
}
$sql = "select S_RegionalID as id,
S_RegionalName as name,
S_RegionalName as namex,
s_regional.*
from s_regional
LEFT JOIN one_hs.hs_price ON S_RegionalID = HS_PriceS_RegionalID AND HS_PriceIsActive = 'Y'
where
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
IFNULL(HS_PriceName,'') LIKE CONCAT('%','{$hsprice}','%') AND
S_RegionalIsActive = 'Y'
GROUP BY S_RegionalID
ORDER BY S_RegionalName 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("s_regional select");
exit;
}
$result = array ("total" => $tot_page, "total_filter"=>count($rows),"records" => $rows);
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewregional()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$name = $prm['name'];
$sql = "insert into s_regional(
S_RegionalName,
S_RegionalCreated,
S_RegionalLastUpdated
)
values( ?, now(), now())";
$query = $this->db_onedev->query($sql,
array(
$name
)
);
//echo $query;
if (!$query) {
$this->sys_error_db("s_regional insert");
exit;
}
$last_id = $this->db_onedev->insert_id();
$result = array ("total" => 1, "records" => array("xid" => 0));
$this->sys_ok($result);
$last_id = $this->db_onedev->insert_id();
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function editregional()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$id = $prm['id'];
$name = $prm['name'];
$userid = $this->sys_user["M_UserID"];
$sqlcompany = "update s_regional SET
S_RegionalName = ?,
S_RegionalLastUpdated = now()
where
S_RegionalID = ?
";
$querycompany = $this->db_onedev->query($sqlcompany,
array(
$name,
$id
)
);
// echo $query;
if (!$querycompany) {
$this->sys_error_db("s_regional update");
exit;
}
$result = array ("total" => 1, "records" => array("xid" => $id));
$this->sys_ok($result);
} catch(Exception $exc) {
$message = $exc->getMessage();
$this->sys_error($message);
}
}
public function addnewhsprice()
{
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
//# ambil parameter input
$prm = $this->sys_input;
$sql = $this->db_onedev->query("SELECT M_BranchID as branchid FROM m_branch
WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'")->row();
//echo $this->db_onedev->last_query();
$branchid = $sql->branchid;
$HS_PriceMinDistance = $prm['min'];
$HS_PriceMaxDistance = $prm['max'];
$HS_PriceAmount = $prm['price'];
$userid = $this->sys_user["M_UserID"];
if($prm['xid'] == 0){
$sql = "insert into one_hs.hs_price(
HS_PriceM_BranchID,
HS_PriceMinDistance,
HS_PriceMaxDistance,
HS_PriceAmount,
HS_PriceCreated,
HS_PriceLastUpdated,
HS_PriceUserID)
values($branchid,$HS_PriceMinDistance,$HS_PriceMaxDistance,$HS_PriceAmount,now(),now(),$userid)";
$query = $this->db_onedev->query($sql);
if (!$query) {
$this->sys_error_db("hs_price 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 one_hs.hs_price SET HS_PriceMinDistance = '{$HS_PriceMinDistance}',
HS_PriceMaxDistance = '{$HS_PriceMaxDistance}',
HS_PriceAmount = '{$HS_PriceAmount}',
HS_PriceUserID = '{$userid}',
HS_PriceLastUpdated = now()
WHERE HS_PriceID = '{$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 deleteregional()
{
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 s_regional SET
S_RegionalIsActive = 'N',
S_RegionalLastUpdated = now()
WHERE
S_RegionalID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("s_regional delete");
exit;
}
$sql = "update one_hs.hs_price SET
HS_PriceIsActive = 'N',
HS_PriceLastUpdated = now()
WHERE
HS_PriceS_RegionalID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("hs_price 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 deletehsprice()
{
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 one_hs.hs_price SET
HS_PriceIsActive = 'N',
HS_PriceLastUpdated = now()
WHERE
HS_PriceID = ?
";
$query = $this->db_onedev->query($sql,
array(
$prm['id']
)
);
// echo $query;
if (!$query) {
$this->sys_error_db("hs_price 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 searchakun(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['tes'] != '')
{
$q['search'] = "%{$prm['tes']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_bank_account
WHERE
M_BankAccountNo like ?
AND M_BankAccountIsActive = '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_bank_account count",$this->db_onedev);
exit;
}
$sql = "
SELECT M_BankAccountID,CONCAT(Nat_BankName, ' [',M_BankAccountNo,'] ') as M_BankAccountNo
FROM m_bank_account
JOIN nat_bank ON Nat_BankID = M_BankAccountNat_BankID
WHERE
CONCAT(Nat_BankName, ' [',M_BankAccountNo,'] ') like ?
AND M_BankAccountIsActive = 'Y'
ORDER BY Nat_BankName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_bank_account rows",$this->db_onedev);
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 searchregionalbyname(){
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 s_regional
WHERE
S_RegionalName like ?
AND S_RegionalIsActive = '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("s_regional count",$this->db_onedev);
exit;
}
$sql = "
SELECT S_RegionalID, S_RegionalName
FROM s_regional
WHERE
S_RegionalName like ?
AND S_RegionalIsActive = 'Y'
ORDER BY S_RegionalName 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("s_regional rows",$this->db_onedev);
exit;
}
}
function searchpaymenttype(){
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_paymenttype
WHERE
M_PaymentTypeName like ?
AND M_PaymentTypeIsActive = '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_subcategory count",$this->db_onedev);
exit;
}
$sql = "
SELECT M_PaymentTypeID, M_PaymentTypeName
FROM m_paymenttype
WHERE
M_PaymentTypeName like ?
AND M_PaymentTypeIsActive = 'Y'
ORDER BY M_PaymentTypeName 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_subcategory rows",$this->db_onedev);
exit;
}
}
function searchdistrict(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_district
WHERE
M_DistrictName like ?
AND M_DistrictT_SubCategoryID = '{$id}'
AND M_DistrictIsActive = '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_district count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_district
WHERE
M_DistrictName like ?
AND M_DistrictT_SubCategoryID = '{$id}'
AND M_DistrictIsActive = 'Y'
ORDER BY M_DistrictName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_district rows",$this->db_onedev);
exit;
}
}
function searchkelurahan(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_kelurahan
WHERE
M_KelurahanName like ?
AND M_KelurahanM_DistrictID = '{$id}'
AND M_KelurahanIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_district count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_kelurahan
WHERE
M_KelurahanName like ?
AND M_KelurahanM_DistrictID = '{$id}'
AND M_KelurahanIsActive = 'Y'
ORDER BY M_KelurahanName ASC
";
$query = $this->db_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_district rows",$this->db_onedev);
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_company count",$this->db_onedev);
exit;
}
$sql = "
SELECT *
FROM m_company
WHERE
M_CompanyName like ?
AND M_CompanyIsActive = 'Y'
ORDER BY M_CompanyName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_company rows",$this->db_onedev);
exit;
}
}
function searchmou(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM m_mou
WHERE
M_MouName like ?
AND M_MouM_CompanyID = '{$id}'
AND M_MouIsActive = 'Y'";
$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_mou count",$this->db_onedev);
exit;
}
$sql = "SELECT *
FROM m_mou
WHERE
M_MouName like ?
AND M_MouM_CompanyID = '{$id}'
AND M_MouIsActive = 'Y'
ORDER BY M_MouName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
// echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_mou rows",$this->db_onedev);
exit;
}
}
function searchdoctor(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
FROM m_doctor
WHERE M_DoctorIsActive = 'Y') a
WHERE
M_DoctorName like ?";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_doctor count",$this->db_onedev);
exit;
}
$sql = "SELECT * FROM(SELECT M_DoctorID, CONCAT(M_DoctorPrefix, ' ',M_DoctorName) as M_DoctorName
FROM m_doctor
WHERE M_DoctorIsActive = 'Y') a
WHERE
M_DoctorName like ?
GROUP BY M_DoctorID
ORDER BY M_DoctorName ASC";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_doctor rows",$this->db_onedev);
exit;
}
}
function selectaddressdoctor(){
try {
//# cek token valid
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['id'];
$rows = [];
$query ="SELECT M_DoctorAddressID,
CONCAT(M_DoctorAddressNote, ': ',M_DoctorAddressDescription) as M_DoctorAddressNote
FROM
m_doctoraddress
WHERE M_DoctorAddressIsActive = 'Y' AND M_DoctorAddressM_DoctorID = '{$id}'";
//echo $query;
$rows['addressdoctors'] = $this->db_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);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,304 @@
<?php
class Schedule extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Schedule API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
function getschedule(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$idsubcategory = $prm['idsubcategory'];
$query =" SELECT
M_RegDayID,
M_RegDayName,
IFNULL(HS_ScheduleID,0) as HS_ScheduleID,
HS_ScheduleM_RegDayID,
IFNULL(HS_ScheduleLimit,'') as HS_ScheduleLimit,
'xxx' as regtimes,
IFNULL(GROUP_CONCAT(DISTINCT M_RegTimeName ORDER BY M_RegTimeID ASC SEPARATOR ', '),'Belum Ada Settingan Waktu') as M_RegTimeName,
'' as action
FROM m_reg_day
JOIN one_hs.hs_schedule ON HS_ScheduleM_RegDayID = M_RegDayID AND HS_ScheduleIsActive = 'Y'
LEFT JOIN one_hs.hs_scheduledetail ON HS_ScheduleDetailHS_ScheduleID = HS_ScheduleID AND HS_ScheduleDetailIsActive = 'Y'
LEFT JOIN m_reg_time ON M_RegTimeID = HS_ScheduleDetailM_RegTimeID AND M_RegTimeIsActive = 'Y'
WHERE
M_RegDayIsActive = 'Y'
GROUP BY M_RegDayID
ORDER BY M_RegDayID ASC
";
//echo $query;
$rows = $this->db_onedev->query($query)->result_array();
if($rows){
foreach($rows as $k => $v){
$d = $v['M_RegDayID'];
$x = $this->db_onedev->query("select concat( '[', group_concat( json_object('id',IFNULL(HS_ScheduleDetailID,M_RegTimeID), 'timename', M_RegTimeName,'status', IF(IFNULL(HS_ScheduleDetailID,0) = 0 AND M_RegTimeIsDefault = 'N', 'N','Y')) separator ',' ), ']' )
as n FROM
(SELECT HS_ScheduleDetailID,M_RegTimeID,M_RegTimeName,M_RegTimeIsDefault
FROM m_reg_time
JOIN one_hs.hs_schedule ON HS_ScheduleM_RegDayID = $d
JOIN one_hs.hs_scheduledetail ON HS_ScheduleDetailM_RegTimeID = M_RegTimeID AND HS_ScheduleDetailHS_ScheduleID = HS_ScheduleID AND HS_ScheduleDetailIsActive = 'Y'
WHERE M_RegTimeIsActive = 'Y'
GROUP BY M_RegTimeID) a")->row();
$rows[$k]['regtimex'] = json_decode($x->n);
$rows[$k]['regtimes'] = $this->add_regtime($v['M_RegDayID']);
$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_regtime($dayid){
$query =" SELECT one_hs.hs_scheduledetail.*, m_reg_time.*,IF(HS_ScheduleDetailID IS NULL,'N','Y') as isregtime, IFNULL(HS_ScheduleDetailID,0) as xid
FROM m_reg_time
LEFT JOIN one_hs.hs_schedule ON HS_ScheduleM_RegDayID = $dayid AND HS_ScheduleIsActive = 'Y'
LEFT JOIN one_hs.hs_scheduledetail ON HS_ScheduleDetailM_RegTimeID = M_RegTimeID AND HS_ScheduleDetailHS_ScheduleID = HS_ScheduleID AND HS_ScheduleDetailIsActive = 'Y'
WHERE M_RegTimeIsActive = 'Y'
GROUP BY M_RegTimeID";
//echo $query;
$rows = $this->db_onedev->query($query)->result_array();
if(!$rows)
$rows = array();
return $rows;
}
function getday(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rows = [];
$query =" SELECT *
FROM m_reg_day
WHERE
M_RegDayIsActive = 'Y'
";
//echo $query;
$rows['days'] = $this->db_onedev->query($query)->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function getsubcategory(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rows = [];
$query =" SELECT *
FROM t_subcategory
WHERE
T_SubCategoryIsActive = 'Y' AND T_SubCategoryIsSchedule = 'Y'
";
//echo $query;
$rows['subcategorys'] = $this->db_onedev->query($query)->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function savenewmethode(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$userid = $this->sys_user["M_UserID"];
foreach($prm['orderdays'] as $k=>$v){
$query = "INSERT INTO m_methode_priority (
M_MethodePriorityM_MethodePriorityID,
M_MethodePriorityT_TestID,
M_MethodePriorityT_TestCode,
M_MethodePriorityT_TestName,
M_MethodePriorityT_TestPrice,
M_MethodePriorityT_TestDisc,
M_MethodePriorityT_TestDiscRp,
M_MethodePriorityT_TestTotal,
M_MethodePriorityUserID,
M_MethodePriorityCreated,
M_MethodePriorityLastUpdated
)
VALUE(
?,?,?,?,?,?,?,?,?, now(),now()
)";
$insert_new_test = $this->db_onedev->query($query,array(
$orderpatient_id,
$v['T_TestID'],
$v['T_TestCode'],
$v['T_TestName'],
$v['T_PriceAmount'],
$v['T_PriceDisc'],
$v['T_PriceDiscRp'],
$v['total'],
$userid
));
}
$result = array(
"total" => 1 ,
"records" => array('status'=>'OK')
);
$this->sys_ok($result);
exit;
}
function saveeditmethode(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$subcategoryid = $prm['HS_ScheduleT_SubCategoryID'];
$dayid = $prm['HS_ScheduleM_RegDayID'];
$kuota = $prm['HS_ScheduleLimit'];
$userid = $this->sys_user["M_UserID"];
if($prm['xid'] == 0 || $prm['xid'] == '0'){
$query = "INSERT INTO one_hs.hs_schedule(
HS_ScheduleM_RegDayID,
HS_ScheduleT_SubCategoryID,
HS_ScheduleLimit,
HS_ScheduleUserID,
HS_ScheduleCreated,
HS_ScheduleLastUpdated
)
VALUES(?,?,?,?,now(),now())";
$insert_header = $this->db_onedev->query($query,array($dayid,$subcategoryid,$kuota,$userid));
$last_id = $this->db_onedev->insert_id();
foreach($prm['orderregtimes'] as $k=>$v){
if($v['isregtime'] === 'Y'){
$xtime = $v['M_RegTimeID'];
$query = "INSERT INTO one_hs.hs_scheduledetail(
HS_ScheduleDetailHS_ScheduleID,
HS_ScheduleDetailM_RegTimeID,
HS_ScheduleDetailUserID,
HS_ScheduleDetailCreated,
HS_ScheduleDetailLastUpdated
)
VALUES(?,?,?,now(),now())";
$insert_detail = $this->db_onedev->query($query,array($last_id,$xtime,$userid));
}
}
}else{
$queryupdate ="UPDATE one_hs.hs_schedule SET
HS_ScheduleLimit = '{$kuota}',
HS_ScheduleUserID = '{$userid}',
HS_ScheduleLastUpdated = now()
WHERE
HS_ScheduleID = ?";
$update_header = $this->db_onedev->query($queryupdate,array($prm['xid']));
foreach($prm['orderregtimes'] as $k=>$v){
if($v['isregtime'] === 'Y' && $v['xid'] == 0){
$xtime = $v['M_RegTimeID'];
$query = "INSERT INTO one_hs.hs_scheduledetail(
HS_ScheduleDetailHS_ScheduleID,
HS_ScheduleDetailM_RegTimeID,
HS_ScheduleDetailUserID,
HS_ScheduleDetailCreated,
HS_ScheduleDetailLastUpdated
)
VALUES(?,?,?,now(),now())";
$insert_detail = $this->db_onedev->query($query,array($prm['xid'],$xtime,$userid));
}else if($v['isregtime'] === 'N'){
$queryupdate ="UPDATE one_hs.hs_scheduledetail SET
HS_ScheduleDetailIsActive = 'N',
HS_ScheduleDetailUserID = '{$userid}',
HS_ScheduleDetailLastUpdated = now()
WHERE
HS_ScheduleDetailID = ?";
$update_detail = $this->db_onedev->query($queryupdate,array($v['HS_ScheduleDetailID']));
}
}
}
$result = array(
"total" => 1 ,
"records" => array('status'=>'OK')
);
$this->sys_ok($result);
exit;
}
function searchtest(){
$prm = $this->sys_input;
$max_rst = 12;
$tot_count = 0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
$mou_id = $prm['mouid'];
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM t_test
JOIN t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
WHERE
T_TestName like ? AND
T_TestIsActive = 'Y'
ORDER BY T_TestName ASC";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("test count",$this->db_onedev);
exit;
}
$sql = "
SELECT 'Y' as editable, 0 as xid, T_TestID, T_TestCode, T_TestName, T_PriceAmount, T_PriceDisc, T_PriceDiscRp, T_PriceAmount - ((T_PriceDisc/100) * T_PriceAmount) - T_PriceDiscRp as total,
M_CompanyID,'N' as M_CompanyIsBill, 0 as M_CompanyMinDP
FROM one_lis_dev.t_test
JOIN one_lis_dev.t_price ON T_PriceT_TestID = T_TestID AND T_PriceIsCito = 'N' AND T_PriceM_MouID = '{$mou_id}'
JOIN one_lis_dev.m_mou ON M_MouID = '{$mou_id}'
JOIN one_lis_dev.m_company ON M_MouM_CompanyID = M_CompanyID
WHERE
T_TestName like ? AND
T_TestIsActive = 'Y'
ORDER BY T_TestName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("test rows",$this->db_onedev);
exit;
}
}
}

View File

@@ -0,0 +1,866 @@
<?php
class Test extends MY_Controller
{
var $db_onedev;
public function index()
{
echo "Test API";
}
public function __construct()
{
parent::__construct();
$this->db_onedev = $this->load->database("onedev", true);
}
public function search()
{
$prm = $this->sys_input;
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$code = $prm["scode"];
$nama = $prm["name"];
$prm['current_page'] = isset($prm['current_page'])?$prm['current_page']:1;
// echo $nik;
$sql_where = "WHERE T_TestIsActive = 'Y' AND T_TestIsPrice = 'Y' ";
$sql_param = array();
if ($nama != "") {
if ($sql_where != "") {
$sql_where .=" and ";
}
$sql_where .= " T_TestName like ? ";
$sql_param[] = "%$nama%";
}
if ($code != "") {
if ($sql_where != "") {
$sql_where .=" and ";
}
$sql_where .= " T_TestSasCode like ? ";
$sql_param[] = "%$code%";
}
//if ($sql_where != "") $sql_where .= " and ";
// Order masih dalam status registrasi
//$sql_where .= " M_StaffIsActive = 'Y' ";
$number_limit = 50;
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
$sql = "SELECT count(*) as total
FROM t_test
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
LEFT JOIN nat_test ON T_TestNat_TestID = Nat_TestID
LEFT JOIN nat_subsubgroup ON nat_subsubgroupID = Nat_Testnat_subsubgroupID
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
LEFT JOIN one_hs.hs_test ON HS_TestT_TestID = T_TestID AND HS_TestIsActive = 'Y'
$sql_where
";
//echo $sql;
$query = $this->db_onedev->query($sql, $sql_param);
$tot_count = 0;
$tot_page = 0;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
$tot_page = ceil($tot_count/$number_limit);
} else {
$this->sys_error_db("m_doctor count", $this->db_onedev);
exit;
}
$sql = "SELECT *, T_TestIsNonLab as T_TestIsNonLabID,IF(T_TestIsNonLab = '', 'LAB',T_TestIsNonLab) as T_TestIsNonLabs, T_TestSasCode as db_T_TestSasCode,
IF(ISNULL(HS_TestID),'N','Y') as status, IF(HS_TestIsActive = 'N','N',HS_TestIsFavorite) as isfavorite
FROM t_test
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
LEFT JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
LEFT JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
LEFT JOIN nat_test ON T_TestNat_TestID = Nat_TestID
LEFT JOIN nat_subsubgroup ON nat_subsubgroupID = Nat_Testnat_subsubgroupID
LEFT JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
LEFT JOIN one_hs.hs_test ON HS_TestT_TestID = T_TestID AND HS_TestIsActive = 'Y'
$sql_where
ORDER BY T_TestSasCode 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();
//$this->_add_address($rows);
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
$this->sys_ok($result);
exit;
}
function getsexreg(){
$prm = $this->sys_input;
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rows = [];
$query =" SELECT *
FROM nat_group
WHERE
Nat_GroupIsActive = 'Y'
";
//echo $query;
$rows['groups'] = $this->db_onedev->query($query)->result_array();
$query =" SELECT *
FROM nat_subgroup
WHERE
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['groupid']}
";
//echo $query;
$rows['subgroupes'] = $this->db_onedev->query($query)->result_array();
$query =" SELECT *
FROM nat_subsubgroup
WHERE
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupSubGroupID = {$prm['subgroupid']}
";
//echo $query;
$rows['subsubgroupes'] = $this->db_onedev->query($query)->result_array();
$query =" SELECT *
FROM nat_testtype
WHERE
Nat_TestTypeIsActive = 'Y'
";
//echo $query;
$rows['types'] = $this->db_onedev->query($query)->result_array();
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLab"=>"LAB"),array("T_TestIsNonLabID"=>"XRAY","T_TestIsNonLab"=>"XRAY"), array("T_TestIsNonLabID"=>"USG","T_TestIsNonLab"=>"USG"),array("T_TestIsNonLabID"=>"ELECTROMEDIS","T_TestIsNonLab"=>"ELECTROMEDIS"));
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function getsubgroup(){
$prm = $this->sys_input;
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rows = [];
$query =" SELECT *
FROM nat_subgroup
WHERE
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['groupid']}
";
//echo $query;
$rows['subgroupes'] = $this->db_onedev->query($query)->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function getsubsubgroup(){
$prm = $this->sys_input;
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rows = [];
$query =" SELECT *
FROM nat_subsubgroup
WHERE
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupSubGroupID = {$prm['subgroupid']}
";
//echo $query;
$rows['subsubgroupes'] = $this->db_onedev->query($query)->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function getinitdatas(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rows = [];
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
FROM nat_group
WHERE
Nat_GroupIsActive = 'Y'
";
//echo $query;
$rows['groups'] = $this->db_onedev->query($query)->result_array();
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
FROM nat_subgroup
WHERE
Nat_SubGroupIsActive = 'Y'
";
//echo $query;
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
$query =" SELECT T_TestTypeID as id, T_TestTypeName as name
FROM t_testtype
WHERE
T_TestTypeIsActive = 'Y'
";
//echo $query;
$rows['types'] = $this->db_onedev->query($query)->result_array();
$rows['nonlabs'] = array(array("T_TestIsNonLabID"=>"","T_TestIsNonLab"=>"LAB"),array("T_TestIsNonLabID"=>"XRAY","T_TestIsNonLab"=>"XRAY"), array("T_TestIsNonLabID"=>"USG","T_TestIsNonLab"=>"USG"),array("T_TestIsNonLabID"=>"ELECTROMEDIS","T_TestIsNonLab"=>"ELECTROMEDIS"));
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function get_subgroups(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$rows = [];
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
FROM nat_subgroup
WHERE
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
";
//echo $query;
$rows = $this->db_onedev->query($query)->result_array();
$result = array(
"total" => count($rows) ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function getracks(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$rows = [];
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
FROM summary_samplestorage
WHERE
Summary_SampleStorageStatus = 'FILLED'
";
//echo $query;
$filledrows = $this->db_onedev->query($query)->result_array();
$query =" SELECT {$prm['id']} as almariid,
M_RackID as id,
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
M_RackCode as code,
M_RackRows as row,
M_RackColumns as col,
'' as rackcontens
FROM m_rack
WHERE
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
";
//echo $query;
$datarows = $this->db_onedev->query($query)->result_array();
foreach($datarows as $k => $v){
$rows = $v['row'];
$cols = $v['col'];
$rackcontens = array();
for ($x = 1; $x <= $rows; $x++) {
$children = array();
for ($i = 1; $i <= $cols; $i++) {
$content = $x.' x '.$i;
$xrow = $x;
$xcol = $i;
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
}
array_push($rackcontens,$children);
}
$datarows[$k]['rackcontens'] = $rackcontens;
}
$result = array(
"total" => count($datarows) ,
"records" => $datarows,
);
$this->sys_ok($result);
exit;
}
function checkexistfilled($datas,$rackid,$row,$col){
$rtn = 'N';
foreach($datas as $k => $v){
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
$rtn = 'Y';
}
}
return $rtn;
}
function searchunit(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM nat_unit
WHERE
Nat_UnitName like ?
AND Nat_unitIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("m_city count",$this->db_onedev);
exit;
}
$sql = "
SELECT Nat_UnitId as id, Nat_UnitName as name
FROM nat_unit
WHERE
Nat_UnitName like ?
AND Nat_unitIsActive = 'Y'
ORDER BY Nat_UnitName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("m_city rows",$this->db_onedev);
exit;
}
}
function searchsample(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$max_rst = 12;
$tot_count =0;
$q = [
'search' => '%'
];
if ($prm['search'] != '')
{
$q['search'] = "%{$prm['search']}%";
}
// QUERY TOTAL
$sql = "SELECT count(*) as total
FROM t_sampletype
WHERE
T_SampleTypeName like ?
AND T_SampleTypeIsActive = 'Y'";
$query = $this->db_onedev->query($sql,$q['search']);
//echo $query;
if ($query) {
$tot_count = $query->result_array()[0]["total"];
}
else {
$this->sys_error_db("t_sampletype count",$this->db_onedev);
exit;
}
$sql = "
SELECT T_SampleTypeID,T_SampleTypeName
FROM t_sampletype
WHERE
T_SampleTypeName like ?
AND T_SampleTypeIsActive = 'Y'
ORDER BY T_SampleTypeName ASC
";
$query = $this->db_onedev->query($sql, array($q['search']));
if ($query) {
$rows = $query->result_array();
//echo $this->db_onedev->last_query();
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
$this->sys_ok($result);
}
else {
$this->sys_error_db("t_sampletype rows",$this->db_onedev);
exit;
}
}
function save(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$userid = $this->sys_user["M_UserID"];
if($prm['T_TestFontSize'] == '')
$prm['T_TestFontSize'] = 10;
if($prm['T_TestIsPrice'] == 'N')
$prm['T_TestIsPrintNota'] = 'N';
$query ="UPDATE t_test SET
T_TestSasCode = '{$prm['T_TestSasCode']}',
T_TestName = '{$prm['T_TestName']}',
T_TestShortName = '{$prm['T_TestShortName']}',
T_TestShortNameBarcode = '{$prm['T_TestShortNameBarcode']}',
T_TestNat_GroupID = '{$prm['T_TestNat_GroupID']}',
T_TestNat_SubgroupID = '{$prm['T_TestNat_SubgroupID']}',
T_TestT_SampleTypeID = '{$prm['T_TestT_SampleTypeID']}',
T_TestFontSize = '{$prm['T_TestFontSize']}',
T_TestFontColor = '{$prm['T_TestFontColor']}',
T_TestIsBold = '{$prm['T_TestIsBold']}',
T_TestIsItalic = '{$prm['T_TestIsItalic']}',
T_TestIsQuantitative = '{$prm['T_TestIsQuantitative']}',
T_TestIsDeltaCheck = '{$prm['T_TestIsDeltaCheck']}',
T_TestIsResult = '{$prm['T_TestIsResult']}',
T_TestIsPrice = '{$prm['T_TestIsPrice']}',
T_TestIsPrintResult = '{$prm['T_TestIsPrintResult']}',
T_TestIsPrintNota = '{$prm['T_TestIsPrintNota']}',
T_TestIsTrendAnalysis = '{$prm['T_TestIsTrendAnalysis']}',
T_TestIsWorklist = '{$prm['T_TestIsWorklist']}',
T_TestIsNonLab = '{$prm['T_TestIsNonLab']}',
T_TestWorklistName = '{$prm['T_TestWorklistName']}',
T_TestMaxDiscount = '{$prm['T_TestMaxDiscount']}'
WHERE T_TestID = '{$prm['T_TestID']}'
";
//echo $query;
$rows = $this->db_onedev->query($query);
if($rows){
}
$result = array(
"total" => 1 ,
"records" => array('status'=>'OK')
);
$this->sys_ok($result);
exit;
}
function checkcodeexist(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$rtn = 'N';
$query =" SELECT COUNT(*) as countx
FROM t_test
WHERE T_TestCode = '{$prm['code']}' AND T_TestIsActive = 'Y'
";
//echo $query;
$rst = $this->db_onedev->query($query)->row()->countx;
if($rst > 0)
$rtn = 'Y';
$result = array(
"total" => 1 ,
"records" => $rtn,
);
$this->sys_ok($result);
exit;
}
function getdataselected(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$id = $prm['T_TestID'];
$query =" SELECT
T_TestCode as code,
T_TestName as name,
T_TestShortName as shortname,
T_TestShortNameBarcode as codebarcode,
'' as xgroup,
Nat_GroupID as group_id,
Nat_GroupName as group_name,
'' as subgroup,
Nat_SubGroupID as subgroup_id,
Nat_SubGroupName as subgroup_name,
'' as type,
T_TestT_TestTypeID as type_id,
T_TestTypeName as type_name,
'' as unit,
Nat_TestNat_UnitID as unit_id,
Nat_UnitName as unit_name,
'' as sample,
T_TestIsNonLab as nonlab,
T_TestT_SampleTypeID as sample_id,
T_SampleTypeName as sample_name,
T_TestFontSize as fontsize,
T_TestFontColor as fontcolor,
T_TestIsBold as flagbold,
T_TestIsItalic as flagitalic,
T_TestFlagGluc as flaggluc,
T_TestIsQuantitative as flagquantitative,
T_TestIsDeltaCheck as deltacheck,
T_TestIsResult as isresult,
T_TestIsPrice as isprice,
T_TestIsPrintResult as printresult,
T_TestIsPrintNota as printnote,
T_TestIsTrendAnalysis as trendanalysis,
T_TestIsWorklist as isworklist,
'N' as islongresult,
T_TestWorklistName as worklistname,
T_TestFlagLow as flaglow,
T_TestFlagHigh as flaghigh
FROM t_test
JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
JOIN t_testtype ON T_TestT_TestTypeID = T_TestTypeID
LEFT JOIN t_sampletype ON T_TestT_SampleTypeID = T_SampleTypeID
LEFT JOIN nat_unit ON Nat_TestNat_UnitID = Nat_UnitID
WHERE T_TestID = '{$id}'
";
//echo $query;
$rows['xform'] = $this->db_onedev->query($query)->row_array();
if($rows['xform']){
$rows['xform']['unit'] = array();
if($rows['xform']['isresult'] == 'Y')
$rows['xform']['unit'] = array('id'=>$rows['xform']['unit_id'],'name'=>$rows['xform']['unit_name']);
$rows['xform']['sample'] = array();
if($rows['xform']['isresult'] == 'Y')
$rows['xform']['sample'] = array('id'=>$rows['xform']['sample_id'],'name'=>$rows['xform']['sample_name']);
$rows['xform']['xgroup'] = array('id'=>$rows['xform']['group_id'],'name'=>$rows['xform']['group_name']);
$rows['xform']['subgroup'] = array('id'=>$rows['xform']['subgroup_id'],'name'=>$rows['xform']['subgroup_name']);
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
if($rows['xform']['nonlab'] == '')
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
else
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
unset($rows['xform']['sample_id']);
unset($rows['xform']['unit_id']);
unset($rows['xform']['group_id']);
unset($rows['xform']['subgroup_id']);
unset($rows['xform']['sample_name']);
unset($rows['xform']['unit_name']);
unset($rows['xform']['group_name']);
unset($rows['xform']['subgroup_name']);
}
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
//echo $sql;
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
$result = array(
"total" => 1 ,
"records" => $rows,
);
$this->sys_ok($result);
exit;
}
function doaddtest(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$rtn = true;
$prm = $this->sys_input;
$userid = $this->sys_user["M_UserID"];
$codefrom = $prm['codefrom'];
$codetoward = $prm['codetoward'];
$leng = strlen($codetoward);
$code_parent = substr($codetoward, 0,-2);
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
//echo $sql;
$xcount = $this->db_onedev->query($sql)->row()->existtest;
if($xcount == 0){
$sql = "
select T_TestID ,T_TestSasCode,
case
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
else
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
end as NewCode,
T_TestName
from
t_test
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
UNION
select T_TestID , T_TestSasCode,
case
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
else
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
end as NewCode,
T_TestName
from
t_test
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
";
//echo $sql;
$toupdate = $this->db_onedev->query($sql)->result();
if($toupdate){
foreach($toupdate as $k => $v){
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
$this->db_onedev->query($sql);
}
}
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
$query ="INSERT INTO t_test (
T_TestParentT_TestID,
T_TestT_TestID,
T_TestCode,
T_TestSasCode,
T_TestName,
T_TestShortName,
T_TestShortNameBarcode,
T_TestNat_GroupID,
T_TestNat_SubGroupID,
T_TestT_SampleTypeID,
T_TestFontSize,
T_TestFontColor,
T_TestIsBold,
T_TestIsItalic,
T_TestFlagGluc,
T_TestIsQuantitative,
T_TestIsDeltaCheck,
T_TestIsResult,
T_TestIsPrice,
T_TestIsPrintResult,
T_TestIsPrintNota,
T_TestIsTrendAnalysis,
T_TestIsWorklist,
T_TestIsNonLab,
T_TestWorklistName,
T_TestFlagLow,
T_TestFlagHigh,
T_TestUserID,
T_TestCreated
)
SELECT
{$parentid},
T_TestID,
T_TestCode,
'{$codetoward}',
T_TestName,
T_TestShortName,
T_TestShortNameBarcode,
T_TestNat_GroupID,
T_TestNat_SubGroupID,
T_TestT_SampleTypeID,
T_TestFontSize,
T_TestFontColor,
T_TestIsBold,
T_TestIsItalic,
T_TestFlagGluc,
T_TestIsQuantitative,
T_TestIsDeltaCheck,
T_TestIsResult,
T_TestIsPrice,
T_TestIsPrintResult,
T_TestIsPrintNota,
T_TestIsTrendAnalysis,
T_TestIsWorklist,
T_TestIsNonLab,
T_TestWorklistName,
T_TestFlagLow,
T_TestFlagHigh,
{$userid},
NOW()
FROM t_test
WHERE
T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'
";
//echo $query;
$this->db_onedev->query($query);
$sql = "SELECT T_TestID FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y' LIMIT 1";
$data_parent = $this->db_onedev->query($sql)->row();
if($data_parent){
$testidparent = $data_parent->T_TestID;
$sql = "UPDATE t_test SET T_TestIsParent = 'Y' WHERE T_TestID = {$testidparent}";
$this->db_onedev->query($sql);
}
}
$result = array(
"total" => 1 ,
"records" => $xcount,
"debug"=>$query
);
$this->sys_ok($result);
exit;
}
function check_exist_code(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$sql = "SELECT COUNT(*) as x_count FROM t_test WHERE T_TestSasCode = '{$prm['newcode']}' AND T_TestID <> {$prm['trx']['T_TestID']} AND T_TestIsActive = 'Y'";
//echo $sql;
$x_count = $this->db_onedev->query($sql)->row();
$result = array(
"total" => 1 ,
"records" => $x_count,
);
$this->sys_ok($result);
exit;
}
function checkedhs(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$userid = $this->sys_user["M_UserID"];
$sql = "SELECT * FROM `m_branch` WHERE `M_BranchIsDefault` = 'Y' LIMIT 1";
$data_cabang = $this->db_onedev->query($sql)->row_array();
foreach($prm['test'] as $k => $v){
if($v['status'] == 'Y'){
$sql = "INSERT INTO one_hs.hs_test (
HS_TestM_BranchID,
HS_TestT_TestID,
HS_TestUserID,
HS_TestCreated
)
VALUES (
{$data_cabang['M_BranchID']},
{$v['T_TestID']},
{$userid},
NOW()
)
ON DUPLICATE KEY UPDATE HS_TestIsActive = 'Y', HS_TestUserID = {$userid}";
}
else{
$sql = "UPDATE one_hs.hs_test
SET HS_TestIsActive = 'N', HS_TestIsFavorite = 'N', HS_TestUserID = {$userid}
WHERE
HS_TestM_BranchID = {$data_cabang['M_BranchID']} AND
HS_TestT_TestID = {$v['T_TestID']}";
}
//echo $sql;
$this->db_onedev->query($sql);
}
$result = array(
"total" => 1 ,
"records" => array()
);
$this->sys_ok($result);
exit;
}
function checkedfavorite(){
if (! $this->isLogin) {
$this->sys_error("Invalid Token");
exit;
}
$prm = $this->sys_input;
$userid = $this->sys_user["M_UserID"];
$sql = "SELECT * FROM `m_branch` WHERE `M_BranchIsDefault` = 'Y' LIMIT 1";
$data_cabang = $this->db_onedev->query($sql)->row_array();
$sqlfav = "SELECT count(HS_TestID) as total FROM one_hs.hs_test WHERE HS_TestIsActive = 'Y' AND HS_TestIsFavorite = 'Y'";
$data_fav = $this->db_onedev->query($sqlfav)->row_array();
foreach($prm['test'] as $k => $v){
if($v['isfavorite'] == 'Y'){
if($data_fav['total'] > 5){
$this->sys_error("Tidak boleh melebihi 6");
exit;
}else{
$sql = "UPDATE one_hs.hs_test
SET HS_TestIsFavorite = 'Y', HS_TestUserID = {$userid}
WHERE
HS_TestM_BranchID = {$data_cabang['M_BranchID']} AND
HS_TestT_TestID = {$v['T_TestID']}";
}
}
else{
$sql = "UPDATE one_hs.hs_test
SET HS_TestIsFavorite = 'N', HS_TestUserID = {$userid}
WHERE
HS_TestM_BranchID = {$data_cabang['M_BranchID']} AND
HS_TestT_TestID = {$v['T_TestID']}";
}
//echo $sql;
$this->db_onedev->query($sql);
}
$result = array(
"total" => 1 ,
"records" => array()
);
$this->sys_ok($result);
exit;
}
}