Initial import
This commit is contained in:
168
application/controllers/regonline/Generateorder.php
Normal file
168
application/controllers/regonline/Generateorder.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
class Generateorder extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "CONTROL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function lookuptransaction(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$sdate = $prm['sdate'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from t_onlinetx
|
||||
LEFT JOIN t_onlineorder ON T_OnlineOrderT_OnlineTxID = T_OnlineTxID AND T_OnlineOrderIsActive = 'Y'
|
||||
LEFT JOIN t_orderheader ON T_OrderHeaderID = T_OnlineOrderT_OrderHeaderID
|
||||
where
|
||||
T_OnlineTxIsActive = 'Y' AND T_OnlineTxIsProcess <> 'Y' AND
|
||||
(T_OnlineTxNumbering LIKE CONCAT('%','{$search}','%') OR
|
||||
T_OrderHeaderLabNumber LIKE CONCAT('%','{$search}','%') OR
|
||||
T_OnlineTxBookingQrCode LIKE CONCAT('%','{$search}','%')) AND
|
||||
T_OrderHeaderID IS NULL AND DATE_FORMAT(STR_TO_DATE(LEFT(T_OnlineTxBookingDate , 10), '%d-%m-%Y'), '%Y-%m-%d') >= '2021-12-13' AND
|
||||
date(T_OnlineTxDate) >= '2021-12-13'";
|
||||
// $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("t_onlinetx count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select T_OnlineTxID as id,
|
||||
T_OnlineTxNumbering,
|
||||
T_OrderHeaderLabNumber,
|
||||
LEFT(T_OnlineTxBookingDate , 16) as tanggal,
|
||||
DATE_FORMAT(STR_TO_DATE(LEFT(T_OnlineTxBookingDate , 10), '%d-%m-%Y'), '%Y-%m-%d') as xdate,
|
||||
IF(DATE_FORMAT(STR_TO_DATE(LEFT(T_OnlineTxBookingDate, 10), '%d-%m-%Y'), '%Y-%m-%d') <= date(now()) , 'N','Y') as ishide,
|
||||
T_OnlineTxBookingDate,
|
||||
T_OnlineTxBookingQrCode,
|
||||
T_OnlineTxBookingName as M_PatientName
|
||||
from t_onlinetx
|
||||
LEFT JOIN t_onlineorder ON T_OnlineOrderT_OnlineTxID = T_OnlineTxID AND T_OnlineOrderIsActive = 'Y'
|
||||
LEFT JOIN t_orderheader ON T_OrderHeaderID = T_OnlineOrderT_OrderHeaderID
|
||||
where
|
||||
T_OnlineTxIsActive = 'Y' AND T_OnlineTxIsProcess <> 'Y' AND
|
||||
(T_OnlineTxNumbering LIKE CONCAT('%','{$search}','%') OR
|
||||
T_OrderHeaderLabNumber LIKE CONCAT('%','{$search}','%') OR
|
||||
T_OnlineTxBookingQrCode LIKE CONCAT('%','{$search}','%')) AND
|
||||
T_OrderHeaderID IS NULL AND
|
||||
DATE_FORMAT(STR_TO_DATE(LEFT(T_OnlineTxBookingDate , 10), '%d-%m-%Y'), '%Y-%m-%d') >= '2021-12-13' AND
|
||||
date(T_OnlineTxDate) >= '2021-12-13'
|
||||
GROUP BY T_OnlineTxID
|
||||
ORDER BY T_OnlineTxBookingDate 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("t_onlinetx 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 fix()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$nomor = md5($prm['nomor']);
|
||||
$sql = $this->db_onedev->query("SELECT M_BranchIPAddress as branch_ip_address FROM m_branch WHERE M_BranchIsDefault = 'Y'")->row();
|
||||
$branch_ip_address = $sql->branch_ip_address;
|
||||
$param = array (
|
||||
"id" => $id,
|
||||
"nomor" => $nomor);
|
||||
$j_param = json_encode($param);
|
||||
$url = "http://$branch_ip_address/one-api/fix/pramitalabku/generate_order/".$id;
|
||||
$post_rst = $this->post($url);
|
||||
// echo "to $url \nresponse : $post_rst\n";
|
||||
$j_rst = json_decode($post_rst,true);
|
||||
$xstatus = $j_rst["status"];
|
||||
$xpesan = $j_rst["message"];
|
||||
|
||||
$result = array ("total" => 1, "records" => array("xid" => 0),"pesan"=>$post_rst);
|
||||
$this->sys_ok($result);
|
||||
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function post($url) {
|
||||
//$data = $data;
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
//echo "RST : $result ";
|
||||
return $result;
|
||||
}
|
||||
function postold($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 12);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
if (curl_errno($ch)){
|
||||
return json_encode( array("status" => "ERR",
|
||||
"message" => curl_error($ch)) );
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
476
application/controllers/regonline/Kuota.php
Normal file
476
application/controllers/regonline/Kuota.php
Normal file
@@ -0,0 +1,476 @@
|
||||
<?php
|
||||
class Kuota extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Kuota API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function getkuota(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$query =" SELECT
|
||||
IFNULL(M_RegKuotaID,0) as M_RegKuotaID,
|
||||
IFNULL(M_RegKuotaReguler,'') as M_RegKuotaReguler,
|
||||
IFNULL(M_RegKuotaCito,'') as M_RegKuotaCito,
|
||||
IFNULL(M_RegKuotaCito1Day,'') as M_RegKuotaCito1Day,
|
||||
IFNULL(M_RegKuotaCito2Day,'') as M_RegKuotaCito2Day,
|
||||
IFNULL(M_RegKuotaIsWork,'N') as M_RegKuotaIsWork,
|
||||
'xxx' as regtimes,
|
||||
'xxx' as regtimesreguler,
|
||||
'' as action
|
||||
FROM m_reg_kuota";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if($rows){
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['regtimes'] = $this->add_regtime();
|
||||
$rows[$k]['regtimesreguler'] = $this->add_regtimereguler();
|
||||
$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>';
|
||||
|
||||
}
|
||||
}else{
|
||||
$starDate = new DateTime(date('Y-m-d'));
|
||||
for ($i=0; $i < 15; $i++) {
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
if($i == 0){
|
||||
$label = 'Hari Ini';
|
||||
}else if($i == 1){
|
||||
$label = 'H+1';
|
||||
}else if($i == 2){
|
||||
$label = 'H+2';
|
||||
}else if($i == 3){
|
||||
$label = 'H+3';
|
||||
}else if($i == 4){
|
||||
$label = 'H+4';
|
||||
}else if($i == 5){
|
||||
$label = 'H+5';
|
||||
}else if($i == 6){
|
||||
$label = 'H+6';
|
||||
}else if($i == 7){
|
||||
$label = 'H+7';
|
||||
}else if($i == 8){
|
||||
$label = 'H+8';
|
||||
}else if($i == 9){
|
||||
$label = 'H+9';
|
||||
}else if($i == 10){
|
||||
$label = 'H+10';
|
||||
}else if($i == 11){
|
||||
$label = 'H+11';
|
||||
}else if($i == 12){
|
||||
$label = 'H+12';
|
||||
}else if($i == 13){
|
||||
$label = 'H+13';
|
||||
}else if($i == 14){
|
||||
$label = 'H+14';
|
||||
}
|
||||
if($exist_date == 0){
|
||||
$queryinsertlog = "INSERT INTO m_reg_kuota_log
|
||||
(M_RegKuotaLogDate,M_RegKuotaLogReguler,M_RegKuotaLogCito,M_RegKuotaLogLabel,M_RegKuotaLogUserID,M_RegKuotaLogCreated,M_RegKuotaLogLastUpdated
|
||||
) VALUES ('".date_format($starDate, 'Y-m-d')."',0,0,'{$label}',3,now(),now());";
|
||||
$insert_log = $this->db_onedev->query($queryinsertlog);
|
||||
}
|
||||
$starDate = date_add($starDate, date_interval_create_from_date_string('1 days'));
|
||||
}
|
||||
$endDate = date_add($starDate, date_interval_create_from_date_string('14 days'));
|
||||
$rows[$k]['regtimes'] = $this->add_regtime();
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function add_regtime(){
|
||||
$starDate = new DateTime(date('Y-m-d'));
|
||||
for ($i=0; $i < 15; $i++) {
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
$querycito = "SELECT M_RegKuotaCito as cito FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y'";
|
||||
$cito = $this->db_onedev->query($querycito)->row()->cito;
|
||||
$queryreguler = "SELECT M_RegKuotaReguler as reguler FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y'";
|
||||
$reguler = $this->db_onedev->query($queryreguler)->row()->reguler;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($i == 0){
|
||||
$label = 'Hari Ini';
|
||||
}else if($i == 1){
|
||||
$label = 'H+1';
|
||||
}else if($i == 2){
|
||||
$label = 'H+2';
|
||||
}else if($i == 3){
|
||||
$label = 'H+3';
|
||||
}else if($i == 4){
|
||||
$label = 'H+4';
|
||||
}else if($i == 5){
|
||||
$label = 'H+5';
|
||||
}else if($i == 6){
|
||||
$label = 'H+6';
|
||||
}else if($i == 7){
|
||||
$label = 'H+7';
|
||||
}else if($i == 8){
|
||||
$label = 'H+8';
|
||||
}else if($i == 9){
|
||||
$label = 'H+9';
|
||||
}else if($i == 10){
|
||||
$label = 'H+10';
|
||||
}else if($i == 11){
|
||||
$label = 'H+11';
|
||||
}else if($i == 12){
|
||||
$label = 'H+12';
|
||||
}else if($i == 13){
|
||||
$label = 'H+13';
|
||||
}else if($i == 14){
|
||||
$label = 'H+14';
|
||||
};
|
||||
if($exist_date == 0){
|
||||
$queryinsertlog = "INSERT INTO m_reg_kuota_log
|
||||
(M_RegKuotaLogDate,M_RegKuotaLogReguler,M_RegKuotaLogCito,M_RegKuotaLogLabel,M_RegKuotaLogUserID,M_RegKuotaLogCreated,M_RegKuotaLogLastUpdated
|
||||
) VALUES ('".date_format($starDate, 'Y-m-d')."',$reguler,$cito,'{$label}',3,now(),now());";
|
||||
$insert_log = $this->db_onedev->query($queryinsertlog);
|
||||
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_reg_kuota_log SET
|
||||
M_RegKuotaLogLabel = '{$label}',
|
||||
M_RegKuotaLogUserID = '{$userid}',
|
||||
M_RegKuotaLogLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$update_detail = $this->db_onedev->query($queryupdate);
|
||||
|
||||
}
|
||||
$starDate = date_add($starDate, date_interval_create_from_date_string('1 days'));
|
||||
}
|
||||
$endDate = date_add($starDate, date_interval_create_from_date_string('14 days'));
|
||||
|
||||
$query ="SELECT IFNULL(M_RegKuotaLogID,0) as xid, M_RegKuotaLogDate , M_RegKuotaLogCito,M_RegKuotaLogLabel
|
||||
FROM m_reg_kuota_log
|
||||
WHERE M_RegKuotaLogIsActive = 'Y' AND
|
||||
M_RegKuotaLogDate BETWEEN date(now()) AND date(now()) + INTERVAL 14 DAY
|
||||
GROUP BY M_RegKuotaLogDate";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
function add_regtimereguler(){
|
||||
$starDate = new DateTime(date('Y-m-d'));
|
||||
for ($i=0; $i < 15; $i++) {
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
$querycito = "SELECT M_RegKuotaCito as cito FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y'";
|
||||
$cito = $this->db_onedev->query($querycito)->row()->cito;
|
||||
$queryreguler = "SELECT M_RegKuotaReguler as reguler FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y'";
|
||||
$reguler = $this->db_onedev->query($queryreguler)->row()->reguler;
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($i == 0){
|
||||
$label = 'Hari Ini';
|
||||
}else if($i == 1){
|
||||
$label = 'H+1';
|
||||
}else if($i == 2){
|
||||
$label = 'H+2';
|
||||
}else if($i == 3){
|
||||
$label = 'H+3';
|
||||
}else if($i == 4){
|
||||
$label = 'H+4';
|
||||
}else if($i == 5){
|
||||
$label = 'H+5';
|
||||
}else if($i == 6){
|
||||
$label = 'H+6';
|
||||
}else if($i == 7){
|
||||
$label = 'H+7';
|
||||
}else if($i == 8){
|
||||
$label = 'H+8';
|
||||
}else if($i == 9){
|
||||
$label = 'H+9';
|
||||
}else if($i == 10){
|
||||
$label = 'H+10';
|
||||
}else if($i == 11){
|
||||
$label = 'H+11';
|
||||
}else if($i == 12){
|
||||
$label = 'H+12';
|
||||
}else if($i == 13){
|
||||
$label = 'H+13';
|
||||
}else if($i == 14){
|
||||
$label = 'H+14';
|
||||
}
|
||||
if($exist_date == 0){
|
||||
$queryinsertlog = "INSERT INTO m_reg_kuota_log
|
||||
(M_RegKuotaLogDate,M_RegKuotaLogReguler,M_RegKuotaLogCito,M_RegKuotaLogLabel,M_RegKuotaLogUserID,M_RegKuotaLogCreated,M_RegKuotaLogLastUpdated
|
||||
) VALUES ('".date_format($starDate, 'Y-m-d')."',$reguler,$cito,'{$label}',3,now(),now());";
|
||||
$insert_log = $this->db_onedev->query($queryinsertlog);
|
||||
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_reg_kuota_log SET
|
||||
M_RegKuotaLogLabel = '{$label}',
|
||||
M_RegKuotaLogUserID = '{$userid}',
|
||||
M_RegKuotaLogLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$update_detail = $this->db_onedev->query($queryupdate);
|
||||
|
||||
}
|
||||
$starDate = date_add($starDate, date_interval_create_from_date_string('1 days'));
|
||||
}
|
||||
$endDate = date_add($starDate, date_interval_create_from_date_string('14 days'));
|
||||
|
||||
$query ="SELECT IFNULL(M_RegKuotaLogID,0) as xid, M_RegKuotaLogDate , M_RegKuotaLogReguler,M_RegKuotaLogLabel
|
||||
FROM m_reg_kuota_log
|
||||
WHERE M_RegKuotaLogIsActive = 'Y' AND
|
||||
M_RegKuotaLogDate BETWEEN date(now()) AND date(now()) + INTERVAL 14 DAY
|
||||
GROUP BY M_RegKuotaLogDate";
|
||||
//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
|
||||
JOIN t_category ON T_CategoryID = T_SubCategoryT_CategoryID AND T_CategoryName LIKE '%covid%'
|
||||
WHERE
|
||||
T_SubCategoryIsActive = '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;
|
||||
$M_RegKuotaReguler = $prm['M_RegKuotaReguler'];
|
||||
$M_RegKuotaCito = $prm['M_RegKuotaCito'];
|
||||
$M_RegKuotaCito1Day = $prm['M_RegKuotaCito1Day'];
|
||||
$M_RegKuotaCito2Day = $prm['M_RegKuotaCito2Day'];
|
||||
$M_RegKuotaIsWork = $prm['M_RegKuotaIsWork'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$queryupdate ="UPDATE m_reg_kuota SET
|
||||
M_RegKuotaReguler = '{$M_RegKuotaReguler}',
|
||||
M_RegKuotaCito = '{$M_RegKuotaCito}',
|
||||
M_RegKuotaCito1Day = '{$M_RegKuotaCito1Day}',
|
||||
M_RegKuotaCito2Day = '{$M_RegKuotaCito2Day}',
|
||||
M_RegKuotaIsWork = '{$M_RegKuotaIsWork}',
|
||||
M_RegKuotaUserID = '{$userid}',
|
||||
M_RegKuotaLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaID = ?";
|
||||
$update_header = $this->db_onedev->query($queryupdate,array($prm['xid']));
|
||||
foreach($prm['orderregtimes'] as $k=>$v){
|
||||
$tanggal = $v['M_RegKuotaLogDate'];
|
||||
$cito = $v['M_RegKuotaLogCito'];
|
||||
$label = $v['M_RegKuotaLogLabel'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogDate = '{$tanggal}'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
if($v['xid'] == 0 && $exist_date == 0 ){
|
||||
$query = "INSERT INTO m_reg_kuota_log(
|
||||
M_RegKuotaLogDate,
|
||||
M_RegKuotaLogCito,
|
||||
M_RegKuotaLogLabel,
|
||||
M_RegKuotaLogUserID,
|
||||
M_RegKuotaLogCreated,
|
||||
M_RegKuotaLogLastUpdated
|
||||
)
|
||||
VALUES(?,?,?,?,now(),now())";
|
||||
$insert_detail = $this->db_onedev->query($query,array($tanggal,$cito,$label,$userid));
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_reg_kuota_log SET
|
||||
M_RegKuotaLogCito = $cito,
|
||||
M_RegKuotaLogUserID = '{$userid}',
|
||||
M_RegKuotaLogLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaLogID = ?";
|
||||
$update_detail = $this->db_onedev->query($queryupdate,array($v['xid']));
|
||||
}
|
||||
}
|
||||
foreach($prm['orderregtimesreguler'] as $k=>$v){
|
||||
$tanggal = $v['M_RegKuotaLogDate'];
|
||||
$reguler = $v['M_RegKuotaLogReguler'];
|
||||
$label = $v['M_RegKuotaLogLabel'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogDate = '{$tanggal}'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
if($v['xid'] == 0 && $exist_date == 0 ){
|
||||
$query = "INSERT INTO m_reg_kuota_log(
|
||||
M_RegKuotaLogDate,
|
||||
M_RegKuotaLogReguler,
|
||||
M_RegKuotaLogLabel,
|
||||
M_RegKuotaLogUserID,
|
||||
M_RegKuotaLogCreated,
|
||||
M_RegKuotaLogLastUpdated
|
||||
)
|
||||
VALUES(?,?,?,?,now(),now())";
|
||||
$insert_detail = $this->db_onedev->query($query,array($tanggal,$reguler,$label,$userid));
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_reg_kuota_log SET
|
||||
M_RegKuotaLogReguler = $reguler,
|
||||
M_RegKuotaLogUserID = '{$userid}',
|
||||
M_RegKuotaLogLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaLogID = ?";
|
||||
$update_detail = $this->db_onedev->query($queryupdate,array($v['xid']));
|
||||
}
|
||||
}
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
547
application/controllers/regonline/Kuota2.php
Normal file
547
application/controllers/regonline/Kuota2.php
Normal file
@@ -0,0 +1,547 @@
|
||||
<?php
|
||||
class Kuota2 extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "Kuota API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
function getkuota(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$idsubcategory = $prm['idsubcategory'];
|
||||
$query = "SELECT COUNT(*) as exist_kuota FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y' AND M_RegKuotaT_SubCategoryID = $idsubcategory";
|
||||
$exist_kuota = $this->db_onedev->query($query)->row()->exist_kuota;
|
||||
if($exist_kuota != 0){
|
||||
$query =" SELECT
|
||||
IFNULL(M_RegKuotaID,0) as M_RegKuotaID,
|
||||
IFNULL(M_RegKuotaReguler,'') as M_RegKuotaReguler,
|
||||
IFNULL(M_RegKuotaCito,'') as M_RegKuotaCito,
|
||||
IFNULL(M_RegKuotaCito1Day,'') as M_RegKuotaCito1Day,
|
||||
IFNULL(M_RegKuotaCito2Day,'') as M_RegKuotaCito2Day,
|
||||
IFNULL(M_RegKuotaIsWork,'N') as M_RegKuotaIsWork,
|
||||
'xxx' as regtimes,
|
||||
'xxx' as regtimesreguler,
|
||||
'' as action
|
||||
FROM m_reg_kuota
|
||||
WHERE M_RegKuotaT_SubCategoryID = $idsubcategory
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
}else{
|
||||
$query ="SELECT
|
||||
0 as M_RegKuotaID,
|
||||
0 as M_RegKuotaReguler,
|
||||
0 as M_RegKuotaCito,
|
||||
'' as M_RegKuotaCito1Day,
|
||||
'' as M_RegKuotaCito2Day,
|
||||
'N' as M_RegKuotaIsWork,
|
||||
'xxx' as regtimes,
|
||||
'xxx' as regtimesreguler,
|
||||
'' as action";
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
}
|
||||
if($rows){
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['regtimes'] = $this->add_regtime($idsubcategory);
|
||||
$rows[$k]['regtimesreguler'] = $this->add_regtimereguler($idsubcategory);
|
||||
$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>';
|
||||
|
||||
}
|
||||
}else{
|
||||
$starDate = new DateTime(date('Y-m-d'));
|
||||
for ($i=0; $i < 15; $i++) {
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogT_SubCategoryID = $idsubcategory AND M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
if($i == 0){
|
||||
$label = 'Hari Ini';
|
||||
}else if($i == 1){
|
||||
$label = 'H+1';
|
||||
}else if($i == 2){
|
||||
$label = 'H+2';
|
||||
}else if($i == 3){
|
||||
$label = 'H+3';
|
||||
}else if($i == 4){
|
||||
$label = 'H+4';
|
||||
}else if($i == 5){
|
||||
$label = 'H+5';
|
||||
}else if($i == 6){
|
||||
$label = 'H+6';
|
||||
}else if($i == 7){
|
||||
$label = 'H+7';
|
||||
}else if($i == 8){
|
||||
$label = 'H+8';
|
||||
}else if($i == 9){
|
||||
$label = 'H+9';
|
||||
}else if($i == 10){
|
||||
$label = 'H+10';
|
||||
}else if($i == 11){
|
||||
$label = 'H+11';
|
||||
}else if($i == 12){
|
||||
$label = 'H+12';
|
||||
}else if($i == 13){
|
||||
$label = 'H+13';
|
||||
}else if($i == 14){
|
||||
$label = 'H+14';
|
||||
}
|
||||
if($exist_date == 0){
|
||||
$queryinsertlog = "INSERT INTO m_reg_kuota_log
|
||||
(M_RegKuotaLogT_SubCategoryID,M_RegKuotaLogDate,M_RegKuotaLogReguler,M_RegKuotaLogCito,M_RegKuotaLogLabel,M_RegKuotaLogUserID,M_RegKuotaLogCreated,M_RegKuotaLogLastUpdated
|
||||
) VALUES ($idsubcategory,'".date_format($starDate, 'Y-m-d')."',0,0,'{$label}',3,now(),now());";
|
||||
$insert_log = $this->db_onedev->query($queryinsertlog);
|
||||
}
|
||||
$starDate = date_add($starDate, date_interval_create_from_date_string('1 days'));
|
||||
}
|
||||
$endDate = date_add($starDate, date_interval_create_from_date_string('14 days'));
|
||||
$rows[$k]['regtimes'] = $this->add_regtime($idsubcategory);
|
||||
|
||||
|
||||
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function add_regtime($idsubcategory){
|
||||
$starDate = new DateTime(date('Y-m-d'));
|
||||
for ($i=0; $i < 15; $i++) {
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogT_SubCategoryID = $idsubcategory AND M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
|
||||
|
||||
$querycito = "SELECT M_RegKuotaCito as cito FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y' AND M_RegKuotaT_SubCategoryID = $idsubcategory";
|
||||
$cito = $this->db_onedev->query($querycito)->row()->cito;
|
||||
if (is_null($cito)) {
|
||||
$cito = 0;
|
||||
}else {
|
||||
$cito = $this->db_onedev->query($querycito)->row()->cito;
|
||||
}
|
||||
|
||||
$queryreguler = "SELECT M_RegKuotaReguler as reguler FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y' AND M_RegKuotaT_SubCategoryID = $idsubcategory";
|
||||
$reguler = $this->db_onedev->query($queryreguler)->row()->reguler;
|
||||
if (is_null($reguler)) {
|
||||
$reguler = 0;
|
||||
}else {
|
||||
$reguler = $this->db_onedev->query($queryreguler)->row()->reguler;
|
||||
}
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($i == 0){
|
||||
$label = 'Hari Ini';
|
||||
}else if($i == 1){
|
||||
$label = 'H+1';
|
||||
}else if($i == 2){
|
||||
$label = 'H+2';
|
||||
}else if($i == 3){
|
||||
$label = 'H+3';
|
||||
}else if($i == 4){
|
||||
$label = 'H+4';
|
||||
}else if($i == 5){
|
||||
$label = 'H+5';
|
||||
}else if($i == 6){
|
||||
$label = 'H+6';
|
||||
}else if($i == 7){
|
||||
$label = 'H+7';
|
||||
}else if($i == 8){
|
||||
$label = 'H+8';
|
||||
}else if($i == 9){
|
||||
$label = 'H+9';
|
||||
}else if($i == 10){
|
||||
$label = 'H+10';
|
||||
}else if($i == 11){
|
||||
$label = 'H+11';
|
||||
}else if($i == 12){
|
||||
$label = 'H+12';
|
||||
}else if($i == 13){
|
||||
$label = 'H+13';
|
||||
}else if($i == 14){
|
||||
$label = 'H+14';
|
||||
};
|
||||
if($exist_date == 0){
|
||||
$queryinsertlog = "INSERT INTO m_reg_kuota_log
|
||||
(M_RegKuotaLogT_SubCategoryID,M_RegKuotaLogDate,M_RegKuotaLogReguler,M_RegKuotaLogCito,M_RegKuotaLogLabel,M_RegKuotaLogUserID,M_RegKuotaLogCreated,M_RegKuotaLogLastUpdated
|
||||
) VALUES ($idsubcategory,'".date_format($starDate, 'Y-m-d')."',$reguler,$cito,'{$label}',3,now(),now());";
|
||||
$insert_log = $this->db_onedev->query($queryinsertlog);
|
||||
//echo $this->db_onedev->last_query();
|
||||
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_reg_kuota_log SET
|
||||
M_RegKuotaLogLabel = '{$label}',
|
||||
M_RegKuotaLogUserID = '{$userid}',
|
||||
M_RegKuotaLogLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaLogT_SubCategoryID = $idsubcategory AND
|
||||
M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$update_detail = $this->db_onedev->query($queryupdate);
|
||||
|
||||
}
|
||||
$starDate = date_add($starDate, date_interval_create_from_date_string('1 days'));
|
||||
}
|
||||
$endDate = date_add($starDate, date_interval_create_from_date_string('14 days'));
|
||||
|
||||
$query ="SELECT IFNULL(M_RegKuotaLogID,0) as xid, M_RegKuotaLogDate , M_RegKuotaLogCito,M_RegKuotaLogLabel,M_RegKuotaLogT_SubCategoryID
|
||||
FROM m_reg_kuota_log
|
||||
WHERE M_RegKuotaLogIsActive = 'Y' AND
|
||||
M_RegKuotaLogT_SubCategoryID = $idsubcategory AND
|
||||
M_RegKuotaLogDate BETWEEN date(now()) AND date(now()) + INTERVAL 14 DAY
|
||||
GROUP BY M_RegKuotaLogDate";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}
|
||||
function add_regtimereguler($idsubcategory){
|
||||
$starDate = new DateTime(date('Y-m-d'));
|
||||
for ($i=0; $i < 15; $i++) {
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogT_SubCategoryID = $idsubcategory AND M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
$querycito = "SELECT M_RegKuotaCito as cito FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y' AND M_RegKuotaT_SubCategoryID = $idsubcategory";
|
||||
$cito = $this->db_onedev->query($querycito)->row()->cito;
|
||||
$queryreguler = "SELECT M_RegKuotaReguler as reguler FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y' AND M_RegKuotaT_SubCategoryID = $idsubcategory";
|
||||
$reguler = $this->db_onedev->query($queryreguler)->row()->reguler;
|
||||
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($i == 0){
|
||||
$label = 'Hari Ini';
|
||||
}else if($i == 1){
|
||||
$label = 'H+1';
|
||||
}else if($i == 2){
|
||||
$label = 'H+2';
|
||||
}else if($i == 3){
|
||||
$label = 'H+3';
|
||||
}else if($i == 4){
|
||||
$label = 'H+4';
|
||||
}else if($i == 5){
|
||||
$label = 'H+5';
|
||||
}else if($i == 6){
|
||||
$label = 'H+6';
|
||||
}else if($i == 7){
|
||||
$label = 'H+7';
|
||||
}else if($i == 8){
|
||||
$label = 'H+8';
|
||||
}else if($i == 9){
|
||||
$label = 'H+9';
|
||||
}else if($i == 10){
|
||||
$label = 'H+10';
|
||||
}else if($i == 11){
|
||||
$label = 'H+11';
|
||||
}else if($i == 12){
|
||||
$label = 'H+12';
|
||||
}else if($i == 13){
|
||||
$label = 'H+13';
|
||||
}else if($i == 14){
|
||||
$label = 'H+14';
|
||||
}
|
||||
if($exist_date == 0){
|
||||
$queryinsertlog = "INSERT INTO m_reg_kuota_log
|
||||
(M_RegKuotaLogT_SubCategoryID,M_RegKuotaLogDate,M_RegKuotaLogReguler,M_RegKuotaLogCito,M_RegKuotaLogLabel,M_RegKuotaLogUserID,M_RegKuotaLogCreated,M_RegKuotaLogLastUpdated
|
||||
) VALUES ($idsubcategory,'".date_format($starDate, 'Y-m-d')."',$reguler,$cito,'{$label}',3,now(),now());";
|
||||
$insert_log = $this->db_onedev->query($queryinsertlog);
|
||||
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_reg_kuota_log SET
|
||||
M_RegKuotaLogLabel = '{$label}',
|
||||
M_RegKuotaLogUserID = '{$userid}',
|
||||
M_RegKuotaLogLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaLogT_SubCategoryID = $idsubcategory AND
|
||||
M_RegKuotaLogDate = '".date_format($starDate, 'Y-m-d')."'";
|
||||
$update_detail = $this->db_onedev->query($queryupdate);
|
||||
|
||||
}
|
||||
$starDate = date_add($starDate, date_interval_create_from_date_string('1 days'));
|
||||
}
|
||||
$endDate = date_add($starDate, date_interval_create_from_date_string('14 days'));
|
||||
|
||||
$query ="SELECT IFNULL(M_RegKuotaLogID,0) as xid, M_RegKuotaLogDate , M_RegKuotaLogReguler,M_RegKuotaLogLabel
|
||||
FROM m_reg_kuota_log
|
||||
WHERE M_RegKuotaLogIsActive = 'Y' AND
|
||||
M_RegKuotaLogT_SubCategoryID = $idsubcategory AND
|
||||
M_RegKuotaLogDate BETWEEN date(now()) AND date(now()) + INTERVAL 14 DAY
|
||||
GROUP BY M_RegKuotaLogDate";
|
||||
//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_SubCategoryIsKuota = '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;
|
||||
$M_RegKuotaReguler = $prm['M_RegKuotaReguler'];
|
||||
$M_RegKuotaCito = $prm['M_RegKuotaCito'];
|
||||
$M_RegKuotaCito1Day = $prm['M_RegKuotaCito1Day'];
|
||||
$M_RegKuotaCito2Day = $prm['M_RegKuotaCito2Day'];
|
||||
$M_RegKuotaIsWork = $prm['M_RegKuotaIsWork'];
|
||||
$M_RegKuotaT_SubCategoryID = $prm['M_RegKuotaT_SubCategoryID'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "SELECT COUNT(*) as exist_kuota FROM m_reg_kuota WHERE M_RegKuotaIsActive = 'Y' AND M_RegKuotaT_SubCategoryID = $M_RegKuotaT_SubCategoryID";
|
||||
$exist_kuota = $this->db_onedev->query($query)->row()->exist_kuota;
|
||||
|
||||
if($exist_kuota != 0){
|
||||
$queryupdate ="UPDATE m_reg_kuota SET
|
||||
M_RegKuotaT_SubCategoryID = '{$M_RegKuotaT_SubCategoryID}',
|
||||
M_RegKuotaReguler = '{$M_RegKuotaReguler}',
|
||||
M_RegKuotaCito = '{$M_RegKuotaCito}',
|
||||
M_RegKuotaCito1Day = '{$M_RegKuotaCito1Day}',
|
||||
M_RegKuotaCito2Day = '{$M_RegKuotaCito2Day}',
|
||||
M_RegKuotaIsWork = '{$M_RegKuotaIsWork}',
|
||||
M_RegKuotaUserID = '{$userid}',
|
||||
M_RegKuotaLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaID = ?";
|
||||
$update_header = $this->db_onedev->query($queryupdate,array($prm['xid']));
|
||||
}else{
|
||||
$queryupdate ="INSERT m_reg_kuota
|
||||
(M_RegKuotaT_SubCategoryID,
|
||||
M_RegKuotaReguler,
|
||||
M_RegKuotaCito,
|
||||
M_RegKuotaCito1Day,
|
||||
M_RegKuotaCito2Day,
|
||||
M_RegKuotaIsWork,
|
||||
M_RegKuotaUserID,
|
||||
M_RegKuotaCreated)
|
||||
VALUES('{$M_RegKuotaT_SubCategoryID}',
|
||||
'{$M_RegKuotaReguler}',
|
||||
'{$M_RegKuotaCito}',
|
||||
'{$M_RegKuotaCito1Day}',
|
||||
'{$M_RegKuotaCito2Day}',
|
||||
'{$M_RegKuotaIsWork}',
|
||||
'{$userid}',
|
||||
now()
|
||||
)";
|
||||
$update_header = $this->db_onedev->query($queryupdate);
|
||||
}
|
||||
|
||||
foreach($prm['orderregtimes'] as $k=>$v){
|
||||
$tanggal = $v['M_RegKuotaLogDate'];
|
||||
$cito = $v['M_RegKuotaLogCito'];
|
||||
$label = $v['M_RegKuotaLogLabel'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogDate = '{$tanggal}'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
if($v['xid'] == 0 && $exist_date == 0 ){
|
||||
$query = "INSERT INTO m_reg_kuota_log(
|
||||
M_RegKuotaLogT_SubCategoryID,
|
||||
M_RegKuotaLogDate,
|
||||
M_RegKuotaLogCito,
|
||||
M_RegKuotaLogLabel,
|
||||
M_RegKuotaLogUserID,
|
||||
M_RegKuotaLogCreated,
|
||||
M_RegKuotaLogLastUpdated
|
||||
)
|
||||
VALUES(?,?,?,?,?,now(),now())";
|
||||
$insert_detail = $this->db_onedev->query($query,array($M_RegKuotaT_SubCategoryID,$tanggal,$cito,$label,$userid));
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_reg_kuota_log SET
|
||||
M_RegKuotaLogCito = $cito,
|
||||
M_RegKuotaLogUserID = '{$userid}',
|
||||
M_RegKuotaLogLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaLogID = ?";
|
||||
$update_detail = $this->db_onedev->query($queryupdate,array($v['xid']));
|
||||
}
|
||||
}
|
||||
foreach($prm['orderregtimesreguler'] as $k=>$v){
|
||||
$tanggal = $v['M_RegKuotaLogDate'];
|
||||
$reguler = $v['M_RegKuotaLogReguler'];
|
||||
$label = $v['M_RegKuotaLogLabel'];
|
||||
$query = "SELECT COUNT(*) as exist FROM m_reg_kuota_log WHERE M_RegKuotaLogIsActive = 'Y' AND M_RegKuotaLogDate = '{$tanggal}'";
|
||||
$exist_date = $this->db_onedev->query($query)->row()->exist;
|
||||
if($v['xid'] == 0 && $exist_date == 0 ){
|
||||
$query = "INSERT INTO m_reg_kuota_log(
|
||||
M_RegKuotaT_SubCategoryID,
|
||||
M_RegKuotaLogDate,
|
||||
M_RegKuotaLogReguler,
|
||||
M_RegKuotaLogLabel,
|
||||
M_RegKuotaLogUserID,
|
||||
M_RegKuotaLogCreated,
|
||||
M_RegKuotaLogLastUpdated
|
||||
)
|
||||
VALUES(?,?,?,?,?,now(),now())";
|
||||
$insert_detail = $this->db_onedev->query($query,array($M_RegKuotaT_SubCategoryID,$tanggal,$reguler,$label,$userid));
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_reg_kuota_log SET
|
||||
M_RegKuotaLogReguler = $reguler,
|
||||
M_RegKuotaLogUserID = '{$userid}',
|
||||
M_RegKuotaLogLastUpdated = now()
|
||||
WHERE
|
||||
M_RegKuotaLogID = ?";
|
||||
$update_detail = $this->db_onedev->query($queryupdate,array($v['xid']));
|
||||
}
|
||||
}
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
61
application/controllers/regonline/Logmulti.php
Normal file
61
application/controllers/regonline/Logmulti.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
class Logmulti extends MY_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
function show() {
|
||||
$prm = $this->sys_input;
|
||||
$logfile = $prm['status'];
|
||||
|
||||
$fp = file_get_contents("/xtmp/{$logfile}.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -1000);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
function read_log()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$logfile = $prm['status'];
|
||||
$fp = fopen("/xtmp/{$logfile}.log", 'r');
|
||||
$pos = -1; // Skip final new line character (Set to -1 if not present)
|
||||
|
||||
$lines = array();
|
||||
$currentLine = '';
|
||||
$idx = 0;
|
||||
$msg = "<pre>";
|
||||
while (-1 !== fseek($fp, $pos, SEEK_END)) {
|
||||
$char = fgetc($fp);
|
||||
if (PHP_EOL == $char) {
|
||||
$msg .= $currentLine;
|
||||
echo $msg;
|
||||
$currentLine = '';
|
||||
} else {
|
||||
$currentLine = $char . $currentLine;
|
||||
}
|
||||
$pos--;
|
||||
$idx++;
|
||||
if ($idx > 1000) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$msg .= "</pre>";
|
||||
return $msg;
|
||||
}
|
||||
function index()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$logfile = $prm['status'];
|
||||
|
||||
$fp = file_get_contents("/xtmp/{$logfile}.log");
|
||||
$arr = explode("\n", $fp);
|
||||
$arr = array_slice($arr, -500);
|
||||
$arr = array_reverse($arr);
|
||||
$msg = implode("\n", $arr);
|
||||
echo "<pre>$msg</pre>";
|
||||
}
|
||||
}
|
||||
938
application/controllers/regonline/Pgbank.php
Normal file
938
application/controllers/regonline/Pgbank.php
Normal file
@@ -0,0 +1,938 @@
|
||||
<?php
|
||||
|
||||
class Pgbank 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 pg_bank
|
||||
JOIN m_bank_account ON M_BankAccountID = pgBankM_BankAccountID
|
||||
JOIN nat_bank ON Nat_BankID = M_BankAccountNat_BankID
|
||||
JOIN m_paymenttype ON M_PaymentTypeID = pgBankM_PaymentTypeID
|
||||
WHERE
|
||||
(M_BankAccountNo LIKE CONCAT('%','{$pgbank}','%') OR
|
||||
Nat_BankName LIKE CONCAT('%','{$pgbank}','%')) AND
|
||||
pgBankIsActive = '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("pg_bank count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select pgBankID as id,
|
||||
M_BankAccountID,
|
||||
CONCAT(Nat_BankName,' [',M_BankAccountNo,'] ') M_BankAccountNo,
|
||||
Nat_BankName,
|
||||
M_PaymentTypeID,
|
||||
M_PaymentTypeName,
|
||||
pg_bank.*
|
||||
from pg_bank
|
||||
JOIN m_bank_account ON M_BankAccountID = pgBankM_BankAccountID
|
||||
JOIN nat_bank ON Nat_BankID = M_BankAccountNat_BankID
|
||||
JOIN m_paymenttype ON M_PaymentTypeID = pgBankM_PaymentTypeID
|
||||
WHERE
|
||||
(M_BankAccountNo LIKE CONCAT('%','{$pgbank}','%') OR
|
||||
Nat_BankName LIKE CONCAT('%','{$pgbank}','%')) AND
|
||||
pgBankIsActive = 'Y'
|
||||
GROUP BY pgBankID
|
||||
ORDER BY Nat_BankName 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("pg_bank 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 pg_bank ON S_RegionalID = pgBankS_RegionalID AND pgBankIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(pgBankName,'') 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 pg_bank ON S_RegionalID = pgBankS_RegionalID AND pgBankIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(pgBankName,'') 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;
|
||||
$pgBankM_BankAccountID = $prm['akunid'];
|
||||
$pgBankMerchantCode = $prm['code'];
|
||||
$pgBankM_PaymentTypeID = $prm['paymenttypeid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$sql = "insert into pg_bank(
|
||||
pgBankM_BankAccountID,
|
||||
pgBankMerchantCode,
|
||||
pgBankM_PaymentTypeID,
|
||||
pgBankCreated,
|
||||
pgBankLastUpdated,
|
||||
pgBankUserID)
|
||||
values(?,?,?,now(),now(),?)";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$pgBankM_BankAccountID,
|
||||
$pgBankMerchantCode,
|
||||
$pgBankM_PaymentTypeID,
|
||||
$userid)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("pg_bank 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 pg_bank SET pgBankM_BankAccountID = '{$pgBankM_BankAccountID}',
|
||||
pgBankMerchantCode = '{$pgBankMerchantCode}',
|
||||
pgBankM_PaymentTypeID = '{$pgBankM_PaymentTypeID}',
|
||||
pgBankUserID = '{$userid}',
|
||||
pgBankLastUpdated = now()
|
||||
WHERE pgBankID = '{$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 pg_bank SET
|
||||
pgBankIsActive = 'N',
|
||||
pgBankLastUpdated = now()
|
||||
WHERE
|
||||
pgBankS_RegionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("pg_bank 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 pg_bank SET
|
||||
pgBankIsActive = 'N',
|
||||
pgBankLastUpdated = now()
|
||||
WHERE
|
||||
pgBankID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("pg_bank 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
42
application/controllers/regonline/Report.php
Normal file
42
application/controllers/regonline/Report.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
class Report 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){
|
||||
}
|
||||
|
||||
function getdataselect(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
|
||||
$query ="
|
||||
SELECT 0 as M_BranchID, 'Semua' as M_BranchName
|
||||
UNION
|
||||
SELECT M_BranchID, M_BranchName
|
||||
FROM m_branch
|
||||
WHERE
|
||||
M_BranchIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['branchs'] = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
42
application/controllers/regonline/Reportstatus.php
Normal file
42
application/controllers/regonline/Reportstatus.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
class Reportstatus 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){
|
||||
}
|
||||
|
||||
function getdataselect(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
|
||||
$query ="
|
||||
SELECT 0 as M_BranchID, 'Semua' as M_BranchName
|
||||
UNION
|
||||
SELECT M_BranchID, M_BranchName
|
||||
FROM m_branch
|
||||
WHERE
|
||||
M_BranchIsActive = 'Y'";
|
||||
//echo $query;
|
||||
$rows['branchs'] = $this->db_onedev->query($query)->result_array();
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
307
application/controllers/regonline/Schedule.php
Normal file
307
application/controllers/regonline/Schedule.php
Normal file
@@ -0,0 +1,307 @@
|
||||
<?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(M_RegScheduleID,0) as M_RegScheduleID,
|
||||
M_RegScheduleM_RegDayID,
|
||||
IFNULL(M_RegScheduleLimit,'') as M_RegScheduleLimit,
|
||||
T_SubCategoryID,
|
||||
T_SubCategoryName,
|
||||
'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 m_reg_schedule ON M_RegScheduleM_RegDayID = M_RegDayID AND M_RegScheduleT_SubCategoryID = $idsubcategory AND M_RegScheduleIsActive = 'Y'
|
||||
LEFT JOIN t_subcategory ON T_SubCategoryID = $idsubcategory
|
||||
LEFT JOIN m_reg_scheduledetail ON M_RegScheduleDetailM_RegScheduleID = M_RegScheduleID AND M_RegScheduleDetailIsActive = 'Y'
|
||||
LEFT JOIN m_reg_time ON M_RegTimeID = M_RegScheduleDetailM_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(M_RegScheduleDetailID,M_RegTimeID), 'timename', M_RegTimeName,'status', IF(IFNULL(M_RegScheduleDetailID,0) = 0 AND M_RegTimeIsDefault = 'N', 'N','Y')) separator ',' ), ']' )
|
||||
as n FROM
|
||||
(SELECT M_RegScheduleDetailID,M_RegTimeID,M_RegTimeName,M_RegTimeIsDefault
|
||||
FROM m_reg_time
|
||||
JOIN m_reg_schedule ON M_RegScheduleM_RegDayID = $d AND M_RegScheduleT_SubCategoryID = $idsubcategory
|
||||
JOIN m_reg_scheduledetail ON M_RegScheduleDetailM_RegTimeID = M_RegTimeID AND M_RegScheduleDetailM_RegScheduleID = M_RegScheduleID AND M_RegScheduleDetailIsActive = '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'],$idsubcategory);
|
||||
$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,$idsubcategory){
|
||||
$query =" SELECT m_reg_scheduledetail.*, m_reg_time.*,IF(M_RegScheduleDetailID IS NULL,'N','Y') as isregtime, IFNULL(M_RegScheduleDetailID,0) as xid
|
||||
FROM m_reg_time
|
||||
LEFT JOIN m_reg_schedule ON M_RegScheduleM_RegDayID = $dayid AND M_RegScheduleT_SubCategoryID = $idsubcategory AND M_RegScheduleIsActive = 'Y'
|
||||
LEFT JOIN m_reg_scheduledetail ON M_RegScheduleDetailM_RegTimeID = M_RegTimeID AND M_RegScheduleDetailM_RegScheduleID = M_RegScheduleID AND M_RegScheduleDetailIsActive = '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['M_RegScheduleT_SubCategoryID'];
|
||||
$dayid = $prm['M_RegScheduleM_RegDayID'];
|
||||
$kuota = $prm['M_RegScheduleLimit'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($prm['xid'] == 0 || $prm['xid'] == '0'){
|
||||
$query = "INSERT INTO m_reg_schedule(
|
||||
M_RegScheduleM_RegDayID,
|
||||
M_RegScheduleT_SubCategoryID,
|
||||
M_RegScheduleLimit,
|
||||
M_RegScheduleUserID,
|
||||
M_RegScheduleCreated,
|
||||
M_RegScheduleLastUpdated
|
||||
)
|
||||
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 m_reg_scheduledetail(
|
||||
M_RegScheduleDetailM_RegScheduleID,
|
||||
M_RegScheduleDetailM_RegTimeID,
|
||||
M_RegScheduleDetailUserID,
|
||||
M_RegScheduleDetailCreated,
|
||||
M_RegScheduleDetailLastUpdated
|
||||
)
|
||||
VALUES(?,?,?,now(),now())";
|
||||
$insert_detail = $this->db_onedev->query($query,array($last_id,$xtime,$userid));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$queryupdate ="UPDATE m_reg_schedule SET
|
||||
M_RegScheduleLimit = '{$kuota}',
|
||||
M_RegScheduleUserID = '{$userid}',
|
||||
M_RegScheduleLastUpdated = now()
|
||||
WHERE
|
||||
M_RegScheduleID = ?";
|
||||
$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 m_reg_scheduledetail(
|
||||
M_RegScheduleDetailM_RegScheduleID,
|
||||
M_RegScheduleDetailM_RegTimeID,
|
||||
M_RegScheduleDetailUserID,
|
||||
M_RegScheduleDetailCreated,
|
||||
M_RegScheduleDetailLastUpdated
|
||||
)
|
||||
VALUES(?,?,?,now(),now())";
|
||||
$insert_detail = $this->db_onedev->query($query,array($prm['xid'],$xtime,$userid));
|
||||
}else if($v['isregtime'] === 'N'){
|
||||
$queryupdate ="UPDATE m_reg_scheduledetail SET
|
||||
M_RegScheduleDetailIsActive = 'N',
|
||||
M_RegScheduleDetailUserID = '{$userid}',
|
||||
M_RegScheduleDetailLastUpdated = now()
|
||||
WHERE
|
||||
M_RegScheduleDetailID = ?";
|
||||
$update_detail = $this->db_onedev->query($queryupdate,array($v['M_RegScheduleDetailID']));
|
||||
}
|
||||
}
|
||||
}
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
179
application/controllers/regonline/Sendtransaction.php
Normal file
179
application/controllers/regonline/Sendtransaction.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
class Sendtransaction extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "CONTROL API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
function lookuptransaction(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$search = $prm['search'];
|
||||
$all = $prm['all'];
|
||||
$sdate = $prm['sdate'];
|
||||
$limit = '';
|
||||
if($all == 'N'){
|
||||
$limit = ' LIMIT 10';
|
||||
}
|
||||
$number_limit = 10;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql = "select COUNT(*) as total
|
||||
from f_reg_sendtransaction
|
||||
JOIN m_user ON F_RegSendTransactionUserID = M_UserID AND M_UserIsActive = 'Y'
|
||||
where
|
||||
(F_RegSendTransactionNoTransaction LIKE CONCAT('%','{$search}','%') OR
|
||||
F_RegSendTransactionNoRef LIKE CONCAT('%','{$search}','%')) AND
|
||||
date(F_RegSendTransactionCreated) = '{$sdate}'";
|
||||
// $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("f_reg_sendtransaction count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select F_RegSendTransactionID as id,
|
||||
DATE_FORMAT(F_RegSendTransactionCreated,'%d-%m-%Y') as tanggal,
|
||||
f_reg_sendtransaction.*,
|
||||
M_UserUsername
|
||||
from f_reg_sendtransaction
|
||||
JOIN m_user ON F_RegSendTransactionUserID = M_UserID AND M_UserIsActive = 'Y'
|
||||
where
|
||||
(F_RegSendTransactionNoTransaction LIKE CONCAT('%','{$search}','%') OR
|
||||
F_RegSendTransactionNoRef LIKE CONCAT('%','{$search}','%')) AND
|
||||
date(F_RegSendTransactionCreated) = '{$sdate}'
|
||||
GROUP BY F_RegSendTransactionID
|
||||
ORDER BY F_RegSendTransactionID 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("f_reg_sendtransaction 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 addnewtransaction()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$notransaction = $prm['notransaction'];
|
||||
$noref = $prm['noref'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$username = $this->sys_user["M_UserUsername"];
|
||||
$token = $prm['token'];
|
||||
$sql = $this->db_onedev->query("SELECT M_BranchCode as branchcode FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y' AND M_BranchIsDefault = 'Y'")->row();
|
||||
$branchcode = $sql->branchcode;
|
||||
$param = array (
|
||||
"username" => $username,
|
||||
"branchCode" => $branchcode,
|
||||
"transactionNo" => $notransaction,
|
||||
"RefNo" => $noref,
|
||||
"token" => $token
|
||||
);
|
||||
$j_param = json_encode($param);
|
||||
$url = "https://mobile.pramita.co.id/one-api/fix/tx_force";
|
||||
$post_rst = $this->post($url,$j_param);
|
||||
$j_rst = json_decode($post_rst,true);
|
||||
$xstatus = $j_rst["status"];
|
||||
$xpesan = $j_rst["message"];
|
||||
$query = "INSERT INTO f_reg_sendtransaction (
|
||||
F_RegSendTransactionNoTransaction,
|
||||
F_RegSendTransactionNoRef,
|
||||
F_RegSendTransactionStatus,
|
||||
F_RegSendTransactionMessage,
|
||||
F_RegSendTransactionUserID,
|
||||
F_RegSendTransactionCreated,
|
||||
F_RegSendTransactionLastUpdated
|
||||
)
|
||||
VALUES(
|
||||
?,?,?,?,?,now(),now()
|
||||
)";
|
||||
$insert_new_test = $this->db_onedev->query($query,array(
|
||||
$notransaction,
|
||||
$noref,
|
||||
$xstatus,
|
||||
$xpesan,
|
||||
$userid
|
||||
));
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_user 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);
|
||||
}
|
||||
}
|
||||
function post($url,$data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 12);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($data))
|
||||
);
|
||||
$result = curl_exec($ch);
|
||||
if (curl_errno($ch)){
|
||||
return json_encode( array("status" => "ERR",
|
||||
"message" => curl_error($ch)) );
|
||||
}
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
376
application/controllers/regonline/Subcategory.php
Normal file
376
application/controllers/regonline/Subcategory.php
Normal file
@@ -0,0 +1,376 @@
|
||||
<?php
|
||||
class Subcategory
|
||||
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 IFNULL(T_SubCategoryID,0) as id,
|
||||
T_SubCategoryID,
|
||||
T_SubCategoryName,
|
||||
T_SubCategoryT_CategoryID,
|
||||
T_CategoryID,
|
||||
T_CategoryName,
|
||||
T_SubCategoryIsPCR,
|
||||
T_SubCategoryIsSchedule,
|
||||
T_SubCategoryIsKuota,
|
||||
IF(T_SubCategoryIsPCR = 'Y','Ya','Tidak') as ispcr,
|
||||
IF(T_SubCategoryIsSchedule = 'Y','Ya','Tidak') as isschedule,
|
||||
IF(T_SubCategoryIsKuota = 'Y','Ya','Tidak') as iskuota
|
||||
FROM t_subcategory
|
||||
LEFT JOIN t_category ON T_CategoryID = T_SubCategoryT_CategoryID
|
||||
WHERE
|
||||
T_SubCategoryIsActive = 'Y'
|
||||
GROUP BY T_SubCategoryID
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => count($rows), "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function search_listing()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT IFNULL(T_SubCategoryID,0) as id,
|
||||
T_SubCategoryID,
|
||||
T_SubCategoryName,
|
||||
T_SubCategoryT_CategoryID,
|
||||
T_CategoryID,
|
||||
T_CategoryName,
|
||||
T_SubCategoryIsPCR,
|
||||
T_SubCategoryIsSchedule,
|
||||
T_SubCategoryIsKuota,
|
||||
IF(T_SubCategoryIsPCR = 'Y','Ya','Tidak') as ispcr,
|
||||
IF(T_SubCategoryIsSchedule = 'Y','Ya','Tidak') as isschedule,
|
||||
IF(T_SubCategoryIsKuota = 'Y','Ya','Tidak') as iskuota
|
||||
FROM t_subcategory
|
||||
LEFT JOIN t_category ON T_CategoryID = T_SubCategoryT_CategoryID
|
||||
WHERE
|
||||
T_SubCategoryIsActive = '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 selectcategory(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query ="SELECT *
|
||||
FROM t_category
|
||||
WHERE
|
||||
T_CategoryIsActive = 'Y'
|
||||
ORDER BY T_CategoryName asc";
|
||||
//echo $query;
|
||||
$rows['categorys'] = $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 save(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$T_SubCategoryName = $prm['name'];
|
||||
$T_SubCategoryIsPCR = $prm['ispcr'];
|
||||
$T_SubCategoryIsSchedule = $prm['isschedule'];
|
||||
$T_SubCategoryIsKuota = $prm['iskuota'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$query = "SELECT COUNT(*) as exist FROM t_subcategory WHERE T_SubCategoryIsActive = 'Y' AND T_SubCategoryName = '{$T_SubCategoryName}' AND T_SubCategoryT_CategoryID = '{$T_SubCategoryT_CategoryID}'";
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
if($exist_code == 0){
|
||||
$sql = "insert into t_subcategory(
|
||||
T_SubCategoryName,
|
||||
T_SubCategoryIsPCR,
|
||||
T_SubCategoryIsSchedule,
|
||||
T_SubCategoryIsKuota,
|
||||
T_SubCategoryUserID,
|
||||
T_SubCategoryLastUpdate,
|
||||
T_SubCategoryCreated)
|
||||
values(?,?,?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$T_SubCategoryName,
|
||||
$T_SubCategoryIsPCR,
|
||||
$T_SubCategoryIsSchedule,
|
||||
$T_SubCategoryIsKuota,
|
||||
$userid)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_subcategory 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{
|
||||
$errors = array();
|
||||
if($exist_code != 0){
|
||||
array_push($errors,array('field'=>'code','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_subcategory WHERE T_SubCategoryIsActive = 'Y' AND T_SubCategoryName = '{$T_SubCategoryName}' AND T_SubCategoryT_CategoryID = '{$T_SubCategoryT_CategoryID}' AND T_SubCategoryID <> {$prm['xid']}";
|
||||
//echo $query;
|
||||
$exist_code = $this->db_onedev->query($query)->row()->exist;
|
||||
// echo $exist_code;
|
||||
if($exist_code == 0){
|
||||
$sql = "UPDATE t_subcategory SET
|
||||
T_SubCategoryName = '{$T_SubCategoryName}',
|
||||
T_SubCategoryIsPCR = '{$T_SubCategoryIsPCR}',
|
||||
T_SubCategoryIsSchedule = '{$T_SubCategoryIsSchedule}',
|
||||
T_SubCategoryIsKuota = '{$T_SubCategoryIsKuota}',
|
||||
T_SubCategoryUserID = '{$userid}'
|
||||
WHERE T_SubCategoryID = '{$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'=>'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 delete()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['xid'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$sql = "update t_subcategory SET
|
||||
T_SubCategoryIsActive = 'N',
|
||||
T_SubCategoryUserID = $userid,
|
||||
T_SubCategoryLastUpdate = now()
|
||||
WHERE
|
||||
T_SubCategoryID = $id";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("t_subcategory delete");
|
||||
exit;
|
||||
}
|
||||
$sqltest = "update t_subcategory_test SET
|
||||
T_SubcategoryTestIsActive = 'N',
|
||||
T_SubcategoryTestUserID = $userid,
|
||||
T_SubcategoryTestLastUpdated = now()
|
||||
WHERE
|
||||
T_SubcategoryTestT_SubcategoryID = $id";
|
||||
|
||||
$querytest = $this->db_onedev->query($sqltest);
|
||||
// echo $query;
|
||||
if (!$querytest) {
|
||||
$this->sys_error_db("t_subcategory_test 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 savejpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = "insert into t_subcategory(
|
||||
T_SubCategoryName,
|
||||
T_SubCategoryUserID,
|
||||
T_SubCategoryCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$prm['value']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
)";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savelistingjpagroup(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$query = " UPDATE t_subcategory SET
|
||||
T_SubCategoryName = '{$prm['name']}',
|
||||
T_SubCategoryIsActive = '{$prm['status']}',
|
||||
T_SubCategoryUserID = {$userid}
|
||||
WHERE
|
||||
T_SubCategoryID = {$prm['id']}
|
||||
";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function savealljpadetail(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$details = $prm['details'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
foreach($details as $k => $v){
|
||||
$query = "insert into t_subcategory(
|
||||
Nat_JPADetailNat_JPAID,
|
||||
Nat_JPADetailT_SubCategoryID,
|
||||
Nat_JPADetailDiscount,
|
||||
Nat_JPADetailUserID,
|
||||
Nat_JPADetailCreated
|
||||
)
|
||||
VALUES(
|
||||
'{$v['Nat_JpaID']}',
|
||||
'{$v['T_SubCategoryID']}',
|
||||
'{$v['Nat_JPADetailDiscount']}',
|
||||
{$userid},
|
||||
NOW()
|
||||
) ON DUPLICATE KEY UPDATE
|
||||
Nat_JPADetailDiscount = {$v['Nat_JPADetailDiscount']},
|
||||
Nat_JPADetailUserID = {$userid}";
|
||||
|
||||
//echo $query;
|
||||
$action = $this->db_onedev->query($query);
|
||||
}
|
||||
|
||||
|
||||
if($action){
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array(),
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
else{
|
||||
$this->sys_error_db($this->db_onedev->last_query(), $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
684
application/controllers/regonline/Subcategorytest.php
Normal file
684
application/controllers/regonline/Subcategorytest.php
Normal file
@@ -0,0 +1,684 @@
|
||||
<?php
|
||||
class subcategorytest extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "SampleStorage API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$join_sql = 'LEFT ';
|
||||
$status = $prm["status"];
|
||||
$jpagroup = $prm["jpagroup"];
|
||||
$search_code = $prm['code'];
|
||||
$search_name = $prm['name'];
|
||||
|
||||
$number_limit = 20;
|
||||
$number_offset = ($prm['current_page'] - 1) * $number_limit ;
|
||||
$sql_where = '';
|
||||
if($search_code != '' || $search_name != ''){
|
||||
$sql_where .= ' AND (';
|
||||
if($search_code != ''){
|
||||
$sql_where .= " T_TestCode LIKE CONCAT('{$search_code}','%') ";
|
||||
}
|
||||
|
||||
if($search_name != ''){
|
||||
if($search_code != '')
|
||||
$sql_where .= ' AND ';
|
||||
|
||||
$sql_where .= " T_TestName LIKE CONCAT('%','{$search_name}','%') ";
|
||||
}
|
||||
|
||||
$sql_where .= ')';
|
||||
}
|
||||
|
||||
$where_status = " AND T_SubcategoryTestT_SubcategoryID = {$jpagroup} ";
|
||||
|
||||
if($status == 'Y'){
|
||||
$join_sql = '';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$sql_param = array($start_date,$end_date);
|
||||
|
||||
|
||||
$sql = " SELECT count(*) as total
|
||||
FROM t_test
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
$join_sql JOIN t_subcategory_test ON T_SubcategoryTestT_TestID = T_TestID $where_status AND T_SubcategoryTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y' AND T_TestIsPrice = 'Y' $sql_where
|
||||
";
|
||||
//echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
|
||||
$tot_count = 0;
|
||||
$tot_page = 0;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
$tot_page = ceil($tot_count/$number_limit);
|
||||
} else {
|
||||
$this->sys_error_db("t_samplestorage count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT t_test.*, IF(ISNULL(T_SubcategoryTestID),'N','Y') as status
|
||||
FROM t_test
|
||||
JOIN nat_test ON T_TestNat_TestID = Nat_TestID
|
||||
JOIN nat_testtype ON Nat_TestNat_TestTypeID = Nat_TestTypeID
|
||||
$join_sql JOIN t_subcategory_test ON T_SubcategoryTestT_TestID = T_TestID
|
||||
|
||||
$where_status AND T_SubcategoryTestIsActive = 'Y'
|
||||
WHERE T_TestIsActive = 'Y' AND T_TestIsPrice = 'Y' $sql_where
|
||||
ORDER BY T_TestCode ASC
|
||||
limit $number_limit offset $number_offset";
|
||||
|
||||
$query = $this->db_onedev->query($sql);
|
||||
//echo $this->db_onedev->last_query();
|
||||
$rows = $query->result_array();
|
||||
if($rows){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//$this->_add_address($rows);
|
||||
$result = array("total" => $tot_page, "records" => $rows, "sql"=> $this->db_onedev->last_query());
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function getinitdatas(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_GroupID as id, Nat_GroupName as name
|
||||
FROM nat_group
|
||||
WHERE
|
||||
Nat_GroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['groups'] = $this->db_onedev->query($query)->result_array();
|
||||
/*$query =" SELECT Nat_SubGroupID as id, CONCAT('[ ',Nat_SubGroupCode,' ] ', Nat_SubGroupName) as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$rows['subgroups'] = $this->db_onedev->query($query)->result_array();*/
|
||||
$query =" SELECT 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("id"=>"","name"=>"LAB"),array("id"=>"XRAY","name"=>"XRAY"), array("id"=>"USG","name"=>"USG"),array("id"=>"ELECTROMEDIS","name"=>"ELECTROMEDIS"));
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubGroupID as id, Nat_SubGroupName as name
|
||||
FROM nat_subgroup
|
||||
WHERE
|
||||
Nat_SubGroupIsActive = 'Y' AND Nat_SubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function get_subsubgroups(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name
|
||||
FROM nat_subsubgroup
|
||||
WHERE
|
||||
Nat_SubSubGroupIsActive = 'Y' AND Nat_SubSubGroupNat_GroupID = {$prm['id']}
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function getracks(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rows = [];
|
||||
$query =" SELECT Summary_SampleStorageM_AlmariID as almarid, Summary_SampleStorageM_RackID as rackid , Summary_SampleStorageRowPosition as row, Summary_SampleStorageColPosition as col
|
||||
FROM summary_samplestorage
|
||||
WHERE
|
||||
Summary_SampleStorageStatus = 'FILLED'
|
||||
";
|
||||
//echo $query;
|
||||
$filledrows = $this->db_onedev->query($query)->result_array();
|
||||
$query =" SELECT {$prm['id']} as almariid,
|
||||
M_RackID as id,
|
||||
CONCAT(M_RackCode,' ( ',M_RackRows,' x ',M_RackColumns,' )') as name,
|
||||
M_RackCode as code,
|
||||
M_RackRows as row,
|
||||
M_RackColumns as col,
|
||||
'' as rackcontens
|
||||
FROM m_rack
|
||||
WHERE
|
||||
M_RackM_AlmariID = {$prm['id']} AND M_RackIsActive = 'Y'
|
||||
";
|
||||
//echo $query;
|
||||
$datarows = $this->db_onedev->query($query)->result_array();
|
||||
foreach($datarows as $k => $v){
|
||||
$rows = $v['row'];
|
||||
$cols = $v['col'];
|
||||
$rackcontens = array();
|
||||
for ($x = 1; $x <= $rows; $x++) {
|
||||
$children = array();
|
||||
for ($i = 1; $i <= $cols; $i++) {
|
||||
$content = $x.' x '.$i;
|
||||
$xrow = $x;
|
||||
$xcol = $i;
|
||||
$status = $this->checkexistfilled($filledrows, $v['id'],$xrow,$xcol);
|
||||
array_push($children,array('content'=>$content,'row'=>$xrow,'col'=>$xcol,'status'=>$status,'selected'=>'N'));
|
||||
}
|
||||
array_push($rackcontens,$children);
|
||||
}
|
||||
$datarows[$k]['rackcontens'] = $rackcontens;
|
||||
}
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => count($datarows) ,
|
||||
"records" => $datarows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkexistfilled($datas,$rackid,$row,$col){
|
||||
$rtn = 'N';
|
||||
foreach($datas as $k => $v){
|
||||
if($v['rackid'] == $rackid && $v['row'] == $row && $v['col'] == $col){
|
||||
$rtn = 'Y';
|
||||
}
|
||||
}
|
||||
return $rtn;
|
||||
}
|
||||
|
||||
|
||||
function searchunit(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_UnitId as id, Nat_UnitName as name
|
||||
FROM nat_unit
|
||||
WHERE
|
||||
Nat_UnitName like ?
|
||||
AND Nat_unitIsActive = 'Y'
|
||||
ORDER BY Nat_UnitName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function searchsample(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$max_rst = 12;
|
||||
$tot_count =0;
|
||||
|
||||
$q = [
|
||||
'search' => '%'
|
||||
];
|
||||
|
||||
if ($prm['search'] != '')
|
||||
{
|
||||
$q['search'] = "%{$prm['search']}%";
|
||||
}
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT count(*) as total
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'";
|
||||
$query = $this->db_onedev->query($sql,$q['search']);
|
||||
//echo $query;
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT Nat_SampleTypeID as id, Nat_SampleTypeName as name
|
||||
FROM nat_sampletype
|
||||
WHERE
|
||||
Nat_SampleTypeName like ?
|
||||
AND Nat_SampleTypeIsActive = 'Y'
|
||||
ORDER BY Nat_SampleTypeName ASC
|
||||
";
|
||||
$query = $this->db_onedev->query($sql, array($q['search']));
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
//echo $this->db_onedev->last_query();
|
||||
$result = array("total" => $tot_count, "records" => $rows, "total_display" => sizeof($rows));
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("m_city rows",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function save(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
|
||||
$sql = "INSERT INTO t_subcategory_test (
|
||||
T_SubcategoryTestT_SubcategoryID,
|
||||
T_SubcategoryTestT_TestID,
|
||||
T_SubcategoryTestUserID,
|
||||
T_SubcategoryTestCreated
|
||||
)
|
||||
VALUES(
|
||||
{$prm['jpagroupid']},
|
||||
{$prm['T_TestID']},
|
||||
{$userid},
|
||||
NOW()
|
||||
)
|
||||
on duplicate key update
|
||||
T_SubcategoryTestIsActive = '{$prm['status']}',
|
||||
T_SubcategoryTestUserID = {$userid}";
|
||||
$this->db_onedev->query($sql);
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => array('status'=>'OK'),
|
||||
"numbering" => $data_log_header,
|
||||
"id" => $last_id
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
function checkcodeexist(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$rtn = 'N';
|
||||
$query =" SELECT COUNT(*) as countx
|
||||
FROM 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 subsubgroup,
|
||||
Nat_SubSubGroupID as subsubgroup_id,
|
||||
Nat_SubSubGroupName as subsubgroup_name,
|
||||
|
||||
'' as type,
|
||||
T_TestT_TestTypeID as type_id,
|
||||
T_TestTypeName as type_name,
|
||||
'' as unit,
|
||||
T_TestNat_UnitID as unit_id,
|
||||
Nat_UnitName as unit_name,
|
||||
'' as sample,
|
||||
T_TestIsNonLab as nonlab,
|
||||
T_TestNat_SampleTypeID as sample_id,
|
||||
Nat_SampleTypeName as sample_name,
|
||||
T_TestFontSize as fontsize,
|
||||
T_TestFontColor as fontcolor,
|
||||
T_TestIsBold as flagbold,
|
||||
T_TestIsItalic as flagitalic,
|
||||
T_TestFlagGluc as flaggluc,
|
||||
T_TestIsQuantitative as flagquantitative,
|
||||
T_TestIsDeltaCheck as deltacheck,
|
||||
T_TestIsResult as isresult,
|
||||
T_TestIsPrice as isprice,
|
||||
T_TestIsPrintResult as printresult,
|
||||
T_TestIsPrintNota as printnote,
|
||||
T_TestIsTrendAnalysis as trendanalysis,
|
||||
T_TestIsWorklist as isworklist,
|
||||
T_TestWorklistName as worklistname,
|
||||
T_TestFlagLow as flaglow,
|
||||
T_TestFlagHigh as flaghigh
|
||||
FROM t_test
|
||||
JOIN nat_group ON T_TestNat_GroupID = Nat_GroupID
|
||||
JOIN nat_subgroup ON T_TestNat_SubGroupID = Nat_SubGroupID
|
||||
LEFT JOIN nat_subsubgroup ON T_TestNat_SubSubGroupID = Nat_SubSubGroupID
|
||||
JOIN t_testtype ON T_TestT_TestTypeID = T_TestTypeID
|
||||
LEFT JOIN nat_sampletype ON T_TestNat_SampleTypeID = Nat_SampleTypeID
|
||||
LEFT JOIN nat_unit ON T_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']['subsubgroup'] = array('id'=>$rows['xform']['subsubgroup_id'],'name'=>$rows['xform']['subsubgroup_name']);
|
||||
$rows['xform']['type'] = array('id'=>$rows['xform']['type_id'],'name'=>$rows['xform']['type_name']);
|
||||
|
||||
|
||||
if($rows['xform']['nonlab'] == '')
|
||||
$rows['xform']['nonlab'] = array('id'=>'','name'=>'LAB');
|
||||
else
|
||||
$rows['xform']['nonlab'] = array('id'=>$rows['xform']['nonlab'],'name'=>$rows['xform']['nonlab']);
|
||||
|
||||
unset($rows['xform']['sample_id']);
|
||||
unset($rows['xform']['unit_id']);
|
||||
unset($rows['xform']['group_id']);
|
||||
unset($rows['xform']['subgroup_id']);
|
||||
unset($rows['xform']['subsubgroup_id']);
|
||||
unset($rows['xform']['sample_name']);
|
||||
unset($rows['xform']['unit_name']);
|
||||
unset($rows['xform']['group_name']);
|
||||
unset($rows['xform']['subgroup_name']);
|
||||
unset($rows['xform']['subsubgroup_name']);
|
||||
}
|
||||
|
||||
$sql = "SELECT Nat_SubGroupID as id, Nat_SubGroupName as name FROM nat_subgroup WHERE Nat_SubGroupNat_GroupID = {$prm['Nat_GroupID']} AND Nat_SubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
$sql = "SELECT Nat_SubSubGroupID as id, Nat_SubSubGroupName as name FROM nat_subsubgroup WHERE Nat_SubSubGroupSubGroupID = {$prm['Nat_SubGroupID']} AND Nat_SubSubGroupIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$rows['subsubgroups'] = $this->db_onedev->query($sql)->result_array();
|
||||
|
||||
|
||||
$result = array(
|
||||
"total" => 1 ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
function doaddtest(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rtn = true;
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$codefrom = $prm['codefrom'];
|
||||
$codetoward = $prm['codetoward'];
|
||||
$leng = strlen($codetoward);
|
||||
$code_parent = substr($codetoward, 0,-2);
|
||||
$sql = "SELECT count(*) as existtest FROM t_test WHERE T_TestSasCode LIKE '{$code_parent}%' AND T_TestCode = '{$codefrom}' AND T_TestIsActive = 'Y'";
|
||||
//echo $sql;
|
||||
$xcount = $this->db_onedev->query($sql)->row()->existtest;
|
||||
if($xcount == 0){
|
||||
$sql = "
|
||||
select T_TestID ,T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 2 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where T_TestSasCode like '{$code_parent}%' AND length(T_TestSasCode) = {$leng} AND T_TestSasCode >= '{$codetoward}'
|
||||
UNION
|
||||
select T_TestID , T_TestSasCode,
|
||||
case
|
||||
when length(T_TestSasCode) = {$leng} then T_TestSasCode + 1
|
||||
else
|
||||
concat( substr(T_TestSasCode,1,{$leng}) + 1 , substr(T_TestSasCode, {$leng} +1) )
|
||||
end as NewCode,
|
||||
T_TestName
|
||||
from
|
||||
t_test
|
||||
where ( T_TestSasCode like '{$code_parent}%' AND T_TestSasCode > '{$codetoward}' ) OR T_TestSasCode = '{$codetoward}'
|
||||
";
|
||||
//echo $sql;
|
||||
$toupdate = $this->db_onedev->query($sql)->result();
|
||||
if($toupdate){
|
||||
foreach($toupdate as $k => $v){
|
||||
$sql = "UPDATE t_test SET T_TestSasCode = '{$v->NewCode}' WHERE T_TestID = {$v->T_TestID} ";
|
||||
$this->db_onedev->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM t_test WHERE T_TestSasCode = '{$code_parent}' AND T_TestIsActive = 'Y'";
|
||||
$parentid = $this->db_onedev->query($sql)->row()->T_TestID;
|
||||
|
||||
$query ="INSERT INTO t_test (
|
||||
T_TestParentT_TestID,
|
||||
T_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_TestNat_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;
|
||||
}
|
||||
}
|
||||
926
application/controllers/regonline/Upload.php
Normal file
926
application/controllers/regonline/Upload.php
Normal file
@@ -0,0 +1,926 @@
|
||||
<?php
|
||||
|
||||
class Upload 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 lookupuploadbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$upload = $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 s_regonline_upload
|
||||
JOIN m_user ON M_UserID = S_RegOnlineUploadUserID
|
||||
JOIN m_staff ON M_StaffID = M_UserM_StaffID
|
||||
WHERE
|
||||
(M_StaffName LIKE CONCAT('%','{$upload}','%')) AND
|
||||
S_RegOnlineUploadIsActive = '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("pg_bank count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select S_RegOnlineUploadID as id,
|
||||
M_UserID,
|
||||
M_StaffID,
|
||||
M_StaffName,
|
||||
IF(S_RegOnlineUploadIsSent = 'N', 'Konfirmasi Upload','Data Telah Terupload') as status,
|
||||
DATE_FORMAT(S_RegOnlineUploadCreated,'%d-%m-%Y %h:%i:%s') as tglkonfirmasi,
|
||||
IF(S_RegOnlineUploadIsSent = 'N','-',DATE_FORMAT(S_RegOnlineUploadSentDate,'%d-%m-%Y %h:%i:%s')) as tglupload,
|
||||
s_regonline_upload.*
|
||||
from s_regonline_upload
|
||||
JOIN m_user ON M_UserID = S_RegOnlineUploadUserID
|
||||
JOIN m_staff ON M_StaffID = M_UserM_StaffID
|
||||
WHERE
|
||||
(M_StaffName LIKE CONCAT('%','{$upload}','%')) AND
|
||||
S_RegOnlineUploadIsActive = 'Y'
|
||||
GROUP BY S_RegOnlineUploadID
|
||||
ORDER BY S_RegOnlineUploadID 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("pg_bank 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'];
|
||||
$upload = $prm['upload'];
|
||||
$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 s_regonline_upload ON S_RegionalID = S_RegOnlineUploadS_RegionalID AND S_RegOnlineUploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(S_RegOnlineUploadName,'') LIKE CONCAT('%','{$upload}','%') 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 s_regonline_upload ON S_RegionalID = S_RegOnlineUploadS_RegionalID AND S_RegOnlineUploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(S_RegOnlineUploadName,'') LIKE CONCAT('%','{$upload}','%') 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 addnewupload()
|
||||
{
|
||||
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"];
|
||||
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$sql = "insert into s_regonline_upload(
|
||||
S_RegOnlineUploadDate,
|
||||
S_RegOnlineUploadUserID,
|
||||
S_RegOnlineUploadCreated,
|
||||
S_RegOnlineUploadLastUpdated)
|
||||
values(date(now()),?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array($userid)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("pg_bank 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 s_regonline_upload SET S_RegOnlineUploadUserID = '{$S_RegOnlineUploadUserID}',
|
||||
S_RegOnlineUploadMerchantCode = '{$S_RegOnlineUploadMerchantCode}',
|
||||
S_RegOnlineUploadM_PaymentTypeID = '{$S_RegOnlineUploadM_PaymentTypeID}',
|
||||
S_RegOnlineUploadUserID = '{$userid}',
|
||||
S_RegOnlineUploadLastUpdated = now()
|
||||
WHERE S_RegOnlineUploadID = '{$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 s_regonline_upload SET
|
||||
S_RegOnlineUploadIsActive = 'N',
|
||||
S_RegOnlineUploadLastUpdated = now()
|
||||
WHERE
|
||||
S_RegOnlineUploadS_RegionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("pg_bank 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 deleteupload()
|
||||
{
|
||||
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_regonline_upload SET
|
||||
S_RegOnlineUploadIsActive = 'N',
|
||||
S_RegOnlineUploadLastUpdated = now()
|
||||
WHERE
|
||||
S_RegOnlineUploadID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("pg_bank 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_user
|
||||
WHERE
|
||||
M_UserNo like ?
|
||||
AND M_UserIsActive = '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_user count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_UserID,CONCAT(M_StaffName, ' [',M_UserNo,'] ') as M_UserNo
|
||||
FROM m_user
|
||||
|
||||
JOIN m_staff ON M_StaffID = M_UserM_StaffID
|
||||
WHERE
|
||||
CONCAT(M_StaffName, ' [',M_UserNo,'] ') like ?
|
||||
AND M_UserIsActive = 'Y'
|
||||
ORDER BY M_StaffName 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_user 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
953
application/controllers/regonline/Uploadv2.php
Normal file
953
application/controllers/regonline/Uploadv2.php
Normal file
@@ -0,0 +1,953 @@
|
||||
<?php
|
||||
|
||||
class Uploadv2 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 lookupuploadbyname(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$prm = $this->sys_input;
|
||||
$upload = $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 s_regonline_upload
|
||||
JOIN m_user ON M_UserID = S_RegOnlineUploadUserID
|
||||
JOIN m_staff ON M_StaffID = M_UserM_StaffID
|
||||
WHERE
|
||||
(M_StaffName LIKE CONCAT('%','{$upload}','%')) AND
|
||||
S_RegOnlineUploadIsActive = '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("pg_bank count", $this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "select S_RegOnlineUploadID as id,
|
||||
M_UserID,
|
||||
M_StaffID,
|
||||
M_StaffName,
|
||||
IF(S_RegOnlineUploadIsSent = 'N', 'Konfirmasi Upload','Data Telah Terupload') as status,
|
||||
DATE_FORMAT(S_RegOnlineUploadCreated,'%d-%m-%Y %h:%i:%s') as tglkonfirmasi,
|
||||
IF(S_RegOnlineUploadIsSent = 'N','-',DATE_FORMAT(S_RegOnlineUploadSentDate,'%d-%m-%Y %h:%i:%s')) as tglupload,
|
||||
s_regonline_upload.*
|
||||
from s_regonline_upload
|
||||
JOIN m_user ON M_UserID = S_RegOnlineUploadUserID
|
||||
JOIN m_staff ON M_StaffID = M_UserM_StaffID
|
||||
WHERE
|
||||
(M_StaffName LIKE CONCAT('%','{$upload}','%')) AND
|
||||
S_RegOnlineUploadIsActive = 'Y'
|
||||
GROUP BY S_RegOnlineUploadID
|
||||
ORDER BY S_RegOnlineUploadID 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("pg_bank 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'];
|
||||
$upload = $prm['upload'];
|
||||
$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 s_regonline_upload ON S_RegionalID = S_RegOnlineUploadS_RegionalID AND S_RegOnlineUploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(S_RegOnlineUploadName,'') LIKE CONCAT('%','{$upload}','%') 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 s_regonline_upload ON S_RegionalID = S_RegOnlineUploadS_RegionalID AND S_RegOnlineUploadIsActive = 'Y'
|
||||
where
|
||||
S_RegionalName LIKE CONCAT('%','{$regional}','%') AND
|
||||
IFNULL(S_RegOnlineUploadName,'') LIKE CONCAT('%','{$upload}','%') 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 addnewupload()
|
||||
{
|
||||
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"];
|
||||
|
||||
|
||||
if($prm['xid'] == 0){
|
||||
$sql = "insert into s_regonline_upload(
|
||||
S_RegOnlineUploadDate,
|
||||
S_RegOnlineUploadUserID,
|
||||
S_RegOnlineUploadCreated,
|
||||
S_RegOnlineUploadLastUpdated)
|
||||
values(date(now()),?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array($userid)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("pg_bank 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 s_regonline_upload SET S_RegOnlineUploadUserID = '{$S_RegOnlineUploadUserID}',
|
||||
S_RegOnlineUploadMerchantCode = '{$S_RegOnlineUploadMerchantCode}',
|
||||
S_RegOnlineUploadM_PaymentTypeID = '{$S_RegOnlineUploadM_PaymentTypeID}',
|
||||
S_RegOnlineUploadUserID = '{$userid}',
|
||||
S_RegOnlineUploadLastUpdated = now()
|
||||
WHERE S_RegOnlineUploadID = '{$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 s_regonline_upload SET
|
||||
S_RegOnlineUploadIsActive = 'N',
|
||||
S_RegOnlineUploadLastUpdated = now()
|
||||
WHERE
|
||||
S_RegOnlineUploadS_RegionalID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("pg_bank 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 deleteupload()
|
||||
{
|
||||
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_regonline_upload SET
|
||||
S_RegOnlineUploadIsActive = 'N',
|
||||
S_RegOnlineUploadLastUpdated = now()
|
||||
WHERE
|
||||
S_RegOnlineUploadID = ?
|
||||
|
||||
";
|
||||
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$prm['id']
|
||||
)
|
||||
);
|
||||
// echo $query;
|
||||
if (!$query) {
|
||||
$this->sys_error_db("pg_bank 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_user
|
||||
WHERE
|
||||
M_UserNo like ?
|
||||
AND M_UserIsActive = '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_user count",$this->db_onedev);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT M_UserID,CONCAT(M_StaffName, ' [',M_UserNo,'] ') as M_UserNo
|
||||
FROM m_user
|
||||
|
||||
JOIN m_staff ON M_StaffID = M_UserM_StaffID
|
||||
WHERE
|
||||
CONCAT(M_StaffName, ' [',M_UserNo,'] ') like ?
|
||||
AND M_UserIsActive = 'Y'
|
||||
ORDER BY M_StaffName 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_user 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 gettestnotsell(){
|
||||
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$rows = [];
|
||||
$query ="CALL `sp_mobile_check_test_not_sell`()";
|
||||
//echo $query;
|
||||
$rows['testnotsell'] = $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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
374
application/controllers/regonline/Worksale.php
Normal file
374
application/controllers/regonline/Worksale.php
Normal file
@@ -0,0 +1,374 @@
|
||||
<?php
|
||||
class Worksale 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;
|
||||
|
||||
$query =" SELECT IFNULL(M_RegPacketWorkID,0) as M_RegPacketWorkID,
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
T_PacketSasCode,
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
IF(IFNULL(M_RegPacketWorkID,0) > 0 , 'Y', 'N') as status,
|
||||
'xxx' as regtimes,
|
||||
'' as action
|
||||
FROM
|
||||
m_mou
|
||||
JOIN t_packet ON T_PacketM_MouID = M_MouID AND T_PacketIsActive = 'Y'
|
||||
LEFT JOIN m_reg_packetwork ON M_RegPacketWorkT_PacketID = T_PacketID AND M_RegPacketWorkIsActive = 'Y'
|
||||
WHERE
|
||||
M_MouIsOnline = 'Y' AND M_MouIsReleased = 'Y' AND M_MouIsActive = 'Y'
|
||||
GROUP BY T_PacketName
|
||||
ORDER BY T_PacketName ASC
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->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 getsale(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query =" SELECT IFNULL(M_RegPacketSaleID,0) as M_RegPacketSaleID,
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
T_PacketSasCode,
|
||||
IF(IFNULL(M_RegPacketSaleID,0) > 0 , 'Y', 'N') as status,
|
||||
'xxx' as regtimes,
|
||||
'' as action
|
||||
FROM
|
||||
m_mou
|
||||
JOIN t_packet ON T_PacketM_MouID = M_MouID AND T_PacketIsActive = 'Y'
|
||||
LEFT JOIN m_reg_packetsale ON M_RegPacketSaleT_PacketID = T_PacketID AND M_RegPacketSaleIsActive = 'Y'
|
||||
WHERE
|
||||
M_MouIsOnline = 'Y' AND M_MouIsReleased = 'Y' AND M_MouIsActive = 'Y'
|
||||
GROUP BY T_PacketName
|
||||
ORDER BY T_PacketName ASC
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if($rows){
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
$rows[$k]['action'] = '<v-icon color="error" @click="deleteAddress(props.item)">delete</v-icon>';
|
||||
$rows[$k]['action'] .= '<v-icon color="primary" @click="deleteAddress(props.item)">edit</v-icon>';
|
||||
|
||||
}
|
||||
}
|
||||
$result = array(
|
||||
"total" => count($rows) ,
|
||||
"records" => $rows,
|
||||
);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function add_regtime($tanggal, $branchid){
|
||||
$query =" SELECT m_reg_packetwork.*,
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
T_PacketCode,
|
||||
20 as jumlah,
|
||||
'CITO' as tipe
|
||||
FROM
|
||||
m_reg_kuota_branch
|
||||
LEFT JOIN t_packet ON T_PacketCode = M_RegKuotaT_PacketCode AND T_PacketIsActive = 'Y'
|
||||
LEFT JOIN m_reg_packetwork ON M_RegPacketWorkT_PacketID = T_PacketID AND M_RegPacketWorkDate = '{$tanggal}' AND M_RegPacketWorkIsActive = 'Y'
|
||||
WHERE
|
||||
M_RegKuotaIsActive = 'Y' AND M_RegKuotaIsWork = 'Y' AND M_RegKuotaT_PacketID = '{$branchid}'
|
||||
GROUP BY T_PacketID
|
||||
|
||||
UNION SELECT m_reg_packetwork.*,
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
T_PacketCode,
|
||||
30 as jumlah,
|
||||
'REGULER' as tipe
|
||||
FROM
|
||||
m_reg_kuota_branch
|
||||
LEFT JOIN t_packet ON T_PacketCode = M_RegKuotaT_PacketCode AND T_PacketIsActive = 'Y'
|
||||
LEFT JOIN m_reg_packetwork ON M_RegPacketWorkT_PacketID = T_PacketID AND M_RegPacketWorkDate = '{$tanggal}' AND M_RegPacketWorkIsActive = 'Y'
|
||||
WHERE
|
||||
M_RegKuotaIsActive = 'Y' AND M_RegKuotaIsWork = 'Y' AND M_RegKuotaT_PacketID = '{$branchid}'
|
||||
GROUP BY T_PacketID";
|
||||
//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
|
||||
JOIN t_category ON T_CategoryID = T_SubCategoryT_CategoryID AND T_CategoryName LIKE '%covid%'
|
||||
WHERE
|
||||
T_SubCategoryIsActive = '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 savenewwork(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$mouid = $prm['mouid'];
|
||||
$packetid = $prm['packetid'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into m_reg_packetwork(
|
||||
M_RegPacketWorkM_MouID,
|
||||
M_RegPacketWorkT_PacketID,
|
||||
M_RegPacketWorkUserID,
|
||||
M_RegPacketWorkCreated,
|
||||
M_RegPacketWorkLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$mouid,
|
||||
$packetid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetwork 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 m_reg_packetwork SET
|
||||
M_RegPacketWorkIsActive = 'N',
|
||||
M_RegPacketWorkUserID = ?,
|
||||
M_RegPacketWorkLastUpdated = now()
|
||||
WHERE M_RegPacketWorkID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$id
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetwork 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 savenewsale(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$mouid = $prm['mouid'];
|
||||
$packetid = $prm['packetid'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into m_reg_packetsale(
|
||||
M_RegPacketSaleM_MouID,
|
||||
M_RegPacketSaleT_PacketID,
|
||||
M_RegPacketSaleUserID,
|
||||
M_RegPacketSaleCreated,
|
||||
M_RegPacketSaleLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$mouid,
|
||||
$packetid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetsale 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 m_reg_packetsale SET
|
||||
M_RegPacketSaleIsActive = 'N',
|
||||
M_RegPacketSaleUserID = ?,
|
||||
M_RegPacketSaleLastUpdated = now()
|
||||
WHERE M_RegPacketSaleID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$id
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetsale 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 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
492
application/controllers/regonline/Worksalev2.php
Normal file
492
application/controllers/regonline/Worksalev2.php
Normal file
@@ -0,0 +1,492 @@
|
||||
<?php
|
||||
class Worksalev2 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;
|
||||
|
||||
$query =" SELECT IFNULL(M_RegPacketWorkID,0) as M_RegPacketWorkID,
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
T_PacketSasCode,
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
IF(IFNULL(M_RegPacketWorkID,0) > 0 , 'Y', 'N') as status,
|
||||
'xxx' as regtimes,
|
||||
'' as action
|
||||
FROM
|
||||
m_mou
|
||||
JOIN t_packet ON T_PacketM_MouID = M_MouID AND T_PacketIsActive = 'Y'
|
||||
LEFT JOIN m_reg_packetwork ON M_RegPacketWorkT_PacketID = T_PacketID AND M_RegPacketWorkIsActive = 'Y'
|
||||
WHERE
|
||||
M_MouIsOnline = 'Y' AND M_MouIsReleased = 'Y' AND M_MouIsActive = 'Y'
|
||||
GROUP BY T_PacketName
|
||||
ORDER BY T_PacketName ASC
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->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 getsale(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
|
||||
$query =" SELECT IFNULL(M_RegPacketSaleID,0) as M_RegPacketSaleID,
|
||||
T_PacketID,
|
||||
T_PacketName,
|
||||
M_MouID,
|
||||
M_MouName,
|
||||
T_PacketSasCode,
|
||||
IF(IFNULL(M_RegPacketSaleID,0) > 0 , 'Y', 'N') as status,
|
||||
IF(IFNULL(M_RegPacketWorkID,0) > 0 , 'Y', 'N') as iswork,
|
||||
'xxx' as regtimes,
|
||||
'' as action
|
||||
FROM
|
||||
m_mou
|
||||
JOIN t_packet ON T_PacketM_MouID = M_MouID AND T_PacketIsActive = 'Y'
|
||||
LEFT JOIN m_reg_packetsale ON M_RegPacketSaleT_PacketID = T_PacketID AND M_RegPacketSaleIsActive = 'Y'
|
||||
LEFT jOIN m_reg_packetwork ON M_RegPacketWorkT_PacketID = T_PacketID AND M_RegPacketWorkIsActive = 'Y'
|
||||
WHERE
|
||||
M_MouIsOnline = 'Y' AND M_MouIsReleased = 'Y' AND M_MouIsActive = 'Y'
|
||||
GROUP BY T_PacketName
|
||||
ORDER BY T_PacketName ASC
|
||||
";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if($rows){
|
||||
|
||||
foreach($rows as $k => $v){
|
||||
$packetname = $v['T_PacketName'];
|
||||
$mouid = $v['M_MouID'];
|
||||
$regpacketsaleid = $v['M_RegPacketSaleID'];
|
||||
$iswork = $v['iswork'];
|
||||
|
||||
$sql = $this->db_onedev->query("SELECT
|
||||
CASE
|
||||
WHEN SUM(x) = 1 THEN 'N'
|
||||
WHEN SUM(x) = 2 THEN 'Y'
|
||||
WHEN SUM(x) > 2 THEN 'A'
|
||||
END as regulercito
|
||||
FROM(SELECT IF(T_PacketIsCito = 'N',1,2) as x, T_PacketName FROM t_packet
|
||||
WHERE T_PacketM_MouID = $mouid AND T_PacketName = '{$packetname}' AND T_PacketIsActive = 'Y') a
|
||||
GROUP BY T_PacketName")->row();
|
||||
$regulercito = $sql->regulercito;
|
||||
|
||||
|
||||
$x = $this->db_onedev->query("select concat( '[', group_concat( json_object('id',IFNULL(M_RegPacketSaleOptionID,T_ResultOptionID),'M_RegPacketSaleID',$regpacketsaleid, 'resultoptionid', T_ResultOptionID,'resultoption', T_ResultOptionName,
|
||||
'regulercito', '{$regulercito}',
|
||||
'iswork',IF('{$iswork}' = 'N' AND T_ResultOptionName = 'Same Day','N','Y'),'isactive',CASE
|
||||
WHEN '{$regulercito}' = 'A' THEN 'Y'
|
||||
WHEN '{$regulercito}' = 'N' AND T_ResultOptionIsCito = 'N' THEN 'Y'
|
||||
WHEN '{$regulercito}' = 'N' AND T_ResultOptionIsCito = 'Y' THEN 'N'
|
||||
WHEN '{$regulercito}' = 'Y' AND T_ResultOptionIsCito = 'N' THEN 'N'
|
||||
WHEN '{$regulercito}' = 'Y' AND T_ResultOptionIsCito = 'Y' THEN 'Y'
|
||||
END ,'status', IF(IFNULL(M_RegPacketSaleOptionID,0) = '0', 'N','Y')) ORDER BY T_ResultOptionID ASC separator ','), ']' ) as n FROM
|
||||
(SELECT M_RegPacketSaleOptionID,T_ResultOptionID,T_ResultOptionName,T_ResultOptionIsCito
|
||||
FROM
|
||||
t_resultoption
|
||||
JOIN t_packet ON T_PacketName = '{$packetname}' AND T_PacketM_MouID = $mouid
|
||||
LEFT JOIN m_reg_packetsaleoption ON M_RegPacketSaleOptionM_RegPacketSaleID = $regpacketsaleid AND M_RegPacketSaleOptionT_ResultOptionID = T_ResultOptionID AND M_RegPacketSaleOptionIsActive = 'Y'
|
||||
WHERE
|
||||
T_ResultOptionIsActive = 'Y' GROUP BY T_ResultOptionID ORDER BY T_ResultOptionID ASC) a")->row();
|
||||
$rows[$k]['regtimex'] = json_decode($x->n);
|
||||
$rows[$k]['regtimes'] = $this->add_resultoption($v['T_PacketName'],$v['M_MouID'],$v['M_RegPacketSaleID']);
|
||||
$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_resultoption($packetname, $mouid, $regpacketsaleid){
|
||||
$queryexist = "SELECT COUNT(*) as exist FROM m_reg_packetsaleoption WHERE M_RegPacketSaleOptionIsActive = 'Y' AND M_RegPacketSaleOptionM_RegPacketSaleID = $regpacketsaleid";
|
||||
$exist_detail = $this->db_onedev->query($queryexist)->row()->exist_detail;
|
||||
if($exist_detail == 0){
|
||||
$query =" SELECT IFNULL(M_RegPacketSaleOptionID,0) as M_RegPacketSaleOptionID,
|
||||
IFNULL(M_RegPacketSaleOptionT_ResultOptionID,T_ResultOptionID) as M_RegPacketSaleOptionT_ResultOptionID,
|
||||
IFNULL(M_RegPacketSaleOptionM_RegPacketSaleID, $regpacketsaleid) as M_RegPacketSaleOptionM_RegPacketSaleID,
|
||||
t_resultoption.*,
|
||||
T_PacketIsCito,
|
||||
IF(M_RegPacketSaleOptionID IS NULL,'N','Y') as isregtime,
|
||||
IF(T_PacketIsCito = T_ResultOptionIsCito,'Y','N') as isshow,
|
||||
IFNULL(M_RegPacketSaleOptionID,0) as xid
|
||||
|
||||
FROM
|
||||
t_resultoption
|
||||
JOIN t_packet ON T_PacketName = '{$packetname}' AND T_PacketM_MouID = $mouid
|
||||
LEFT JOIN m_reg_packetsaleoption ON M_RegPacketSaleOptionM_RegPacketSaleID = $regpacketsaleid AND M_RegPacketSaleOptionT_ResultOptionID = T_ResultOptionID AND M_RegPacketSaleOptionIsActive = 'Y'
|
||||
WHERE
|
||||
T_ResultOptionIsActive = 'Y' GROUP BY T_ResultOptionID";
|
||||
//echo $query;
|
||||
$rows = $this->db_onedev->query($query)->result_array();
|
||||
if(!$rows)
|
||||
$rows = array();
|
||||
return $rows;
|
||||
}else{
|
||||
/*
|
||||
$query =" SELECT IFNULL(M_RegPacketSaleOptionID,0) as M_RegPacketSaleOptionID,
|
||||
IFNULL(M_RegPacketSaleOptionT_ResultOptionID,T_ResultOptionID) as ,M_RegPacketSaleOptionT_ResultOptionID,
|
||||
IFNULL(M_RegPacketSaleOptionM_RegPacketSaleID, $,
|
||||
t_resultoption.*,
|
||||
IF(M_RegPacketSaleOptionID IS NULL,'N','Y') as isregtime,
|
||||
IFNULL(M_RegPacketSaleOption,0) as xid
|
||||
|
||||
FROM
|
||||
t_resultoption
|
||||
LEFT JOIN t_packet ON M_RegPacketSaleOptionT_ResultOptionID = T_ResultOptionID AND T_PacketIsActive = 'Y'
|
||||
LEFT JOIN m_reg_packetwork ON M_RegPacketWorkT_PacketID = T_PacketID AND M_RegPacketWorkDate = '{$tanggal}' AND M_RegPacketWorkIsActive = 'Y'
|
||||
WHERE
|
||||
M_RegKuotaIsActive = 'Y' AND M_RegKuotaIsWork = 'Y' AND M_RegKuotaT_PacketID = '{$branchid}'
|
||||
GROUP BY T_PacketName";
|
||||
//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
|
||||
JOIN t_category ON T_CategoryID = T_SubCategoryT_CategoryID AND T_CategoryName LIKE '%covid%'
|
||||
WHERE
|
||||
T_SubCategoryIsActive = '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 savenewwork(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$mouid = $prm['mouid'];
|
||||
$packetid = $prm['packetid'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into m_reg_packetwork(
|
||||
M_RegPacketWorkM_MouID,
|
||||
M_RegPacketWorkT_PacketID,
|
||||
M_RegPacketWorkUserID,
|
||||
M_RegPacketWorkCreated,
|
||||
M_RegPacketWorkLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$mouid,
|
||||
$packetid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetwork 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 m_reg_packetwork SET
|
||||
M_RegPacketWorkIsActive = 'N',
|
||||
M_RegPacketWorkUserID = ?,
|
||||
M_RegPacketWorkLastUpdated = now()
|
||||
WHERE M_RegPacketWorkID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$id
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetwork 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 savenewsale(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$mouid = $prm['mouid'];
|
||||
$packetid = $prm['packetid'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into m_reg_packetsale(
|
||||
M_RegPacketSaleM_MouID,
|
||||
M_RegPacketSaleT_PacketID,
|
||||
M_RegPacketSaleUserID,
|
||||
M_RegPacketSaleCreated,
|
||||
M_RegPacketSaleLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$mouid,
|
||||
$packetid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetsale 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 m_reg_packetsale SET
|
||||
M_RegPacketSaleIsActive = 'N',
|
||||
M_RegPacketSaleUserID = ?,
|
||||
M_RegPacketSaleLastUpdated = now()
|
||||
WHERE M_RegPacketSaleID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$id
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetsale 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 savenewsaleoption(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
|
||||
//# ambil parameter input
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$regpacketsaleid = $prm['regpacketsalesid'];
|
||||
$resultoptionid = $prm['resultoptionid'];
|
||||
$status = $prm['status'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
if($status == 'Y'){
|
||||
$sql = "insert into m_reg_packetsaleoption(
|
||||
M_RegPacketSaleOptionM_RegPacketSaleID,
|
||||
M_RegPacketSaleOptionT_ResultOptionID,
|
||||
M_RegPacketSaleOptionUserID,
|
||||
M_RegPacketSaleOptionCreated,
|
||||
M_RegPacketSaleOptionLastUpdated
|
||||
)
|
||||
values(?,?,?,now(),now())";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$regpacketsaleid,
|
||||
$resultoptionid,
|
||||
$userid
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetsaleoption 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 m_reg_packetsaleoption SET
|
||||
M_RegPacketSaleOptionIsActive = 'N',
|
||||
M_RegPacketSaleOptionUserID = ?,
|
||||
M_RegPacketSaleOptionLastUpdated = now()
|
||||
WHERE M_RegPacketSaleOptionID = ?";
|
||||
$query = $this->db_onedev->query($sql,
|
||||
array(
|
||||
$userid,
|
||||
$id
|
||||
)
|
||||
);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("m_reg_packetsaleoption 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 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user