Flatten mockup repo
This commit is contained in:
169
application/controllers/mockup/kapus/fkapus/Box.php
Normal file
169
application/controllers/mockup/kapus/fkapus/Box.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
class Box extends MY_Controller
|
||||
{
|
||||
var $db_onedev;
|
||||
public function index()
|
||||
{
|
||||
echo "REF RECEIVE SAMPLE API";
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_onedev = $this->load->database("onedev", true);
|
||||
$this->load->library("Kapus");
|
||||
}
|
||||
|
||||
function selected_box1()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$barcode = $prm['barcode'];
|
||||
$sql = "SELECT *,
|
||||
ROUND(sysKaPusPct,0) as kapus
|
||||
from sys_kapus ";
|
||||
// echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db( $this->db_onedev->last_query() );
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function selected_box2()
|
||||
{
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$barcode = $prm['barcode'];
|
||||
$sql = "SELECT *,
|
||||
FORMAT(sysFKapusSumAmount,0) as kapus,
|
||||
FORMAT(sysFKapusSumTotal,0) as kascabang,
|
||||
ROUND(sysFKapusSumTargetPct,0) as target,
|
||||
sysFKapusSumActualPct as actual,
|
||||
DATE_FORMAT(sysFKapusSumDate,'%d-%m-%Y') as tanggal
|
||||
from sys_f_kapus_sum
|
||||
WHERE sysFKapusSumID = $id";
|
||||
// echo $sql;
|
||||
$query = $this->db_onedev->query($sql);
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
} else {
|
||||
$this->sys_error_db( $this->db_onedev->last_query() );
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
function updategenerate(){
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$id = $prm["id"];
|
||||
$tanggal = $prm["tanggal"];
|
||||
$sysKaPusPct = $prm["sysKaPusPct"];
|
||||
$sql = "update sys_kapus
|
||||
set sysKaPusPct = '{$sysKaPusPct}'";
|
||||
$qry = $this->db_onedev->query($sql);
|
||||
//generate
|
||||
$rst = $this->kapus->calc($tanggal,$userid);
|
||||
if ($rst["status"] != "OK" ) {
|
||||
$this->sys_error($rst["message"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->clean_mysqli_connection($this->db_onedev->conn_id);
|
||||
$sqlkapus = "SELECT *,
|
||||
sysFKapusSumID as id,
|
||||
FORMAT(sysFKapusSumAmount,0) as kapus,
|
||||
FORMAT(sysFKapusSumTotal,0) as kascabang,
|
||||
ROUND(sysFKapusSumTargetPct,0) as target,
|
||||
sysFKapusSumActualPct as actual,
|
||||
DATE_FORMAT(sysFKapusSumDate,'%d-%m-%Y') as tanggal
|
||||
from sys_f_kapus_sum
|
||||
WHERE sysFKapusSumID = $id";
|
||||
$querykapus = $this->db_onedev->query($sqlkapus);
|
||||
$rows = $querykapus->result_array();
|
||||
$result = array ("total" => count($rows), "records" => $rows, "message" =>$rst["message"]);
|
||||
$this->sys_ok($result);
|
||||
exit;
|
||||
}
|
||||
function konfirmasi(){
|
||||
try {
|
||||
//# cek token valid
|
||||
if (! $this->isLogin) {
|
||||
$this->sys_error("Invalid Token");
|
||||
exit;
|
||||
}
|
||||
$prm = $this->sys_input;
|
||||
$id = $prm['id'];
|
||||
$userid = $this->sys_user["M_UserID"];
|
||||
$this->db_onedev->trans_start();
|
||||
$sql = "update sys_f_kapus_sum set sysFKapusSumIsPosted = 'Y',sysFKapusSumUserID = '{$userid}' where sysFKapusSumID = ?";
|
||||
$query = $this->db_onedev->query($sql, array($id));
|
||||
if ($query) {
|
||||
$sql_u = "update t_orderheaderaddon
|
||||
set T_OrderHeaderAddOnIsKapus = 'Y'
|
||||
where T_OrderHeaderAddOnT_OrderHeaderID in (
|
||||
select sysFKapusT_OrderHeaderID
|
||||
from sys_f_kapus
|
||||
where sysFKapusSysFKapusSumID = ?
|
||||
and sysFKapusIsActive = 'Y'
|
||||
)";
|
||||
$qry = $this->db_onedev->query($sql_u,array($id));
|
||||
if (! $qry) {
|
||||
$this->sys_error_db( $this->db_onedev->last_query() );
|
||||
exit;
|
||||
}
|
||||
$sqlkapus = "SELECT *,
|
||||
sysFKapusSumID as id,
|
||||
FORMAT(sysFKapusSumAmount,0) as kapus,
|
||||
FORMAT(sysFKapusSumTotal,0) as kascabang,
|
||||
ROUND(sysFKapusSumTargetPct,0) as target,
|
||||
sysFKapusSumActualPct as actual,
|
||||
DATE_FORMAT(sysFKapusSumDate,'%d-%m-%Y') as tanggal
|
||||
from sys_f_kapus_sum
|
||||
WHERE sysFKapusSumID = $id";
|
||||
$querykapus = $this->db_onedev->query($sqlkapus);
|
||||
$rows = $querykapus->result_array();
|
||||
} else {
|
||||
$this->sys_error_db( $this->db_onedev->last_query() );
|
||||
exit;
|
||||
}
|
||||
$result = array ("total" => count($rows), "records" => $rows);
|
||||
$this->sys_ok($result);
|
||||
$this->db_onedev->trans_complete();
|
||||
} catch(Exception $exc) {
|
||||
$message = $exc->getMessage();
|
||||
$this->sys_error($message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user