Flatten mockup repo
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Ri_header extends MY_Controller
|
||||
{
|
||||
var $db_smartone;
|
||||
|
||||
public function index()
|
||||
{
|
||||
echo "RI Header API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db_smartone = $this->load->database("onedev", true);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$max_rst = 10;
|
||||
|
||||
$sdate = $prm["sdate"];
|
||||
$edate = $prm["edate"];
|
||||
$nolab = '%' . $prm["nolab"] . '%';
|
||||
$search = '%' . $prm["search"] . '%';
|
||||
$page = $prm['page'];
|
||||
|
||||
if ($page == null)
|
||||
$page = 1;
|
||||
|
||||
$offset = ($page - 1) * $max_rst;
|
||||
|
||||
// QUERY TOTAL
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM t_orderrefint
|
||||
JOIN m_branch ON T_OrderRefIntDestM_BranchID = M_BranchID
|
||||
JOIN m_statusref ON T_OrderRefIntM_StatusRefID = M_StatusRefID
|
||||
WHERE T_OrderRefIntIsActive = 'Y'
|
||||
AND T_OrderRefIntDate = ?";
|
||||
$query = $this->db_smartone->query($sql, [$sdate]);
|
||||
|
||||
if ($query) {
|
||||
$tot_count = $query->result_array()[0]["total"];
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("re count", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT T_OrderRefIntID, T_OrderRefIntDate, T_OrderRefIntNumber, M_BranchID, M_BranchName,
|
||||
M_StatusRefName T_OrderRefIntStatus, M_StatusRefCode
|
||||
FROM t_orderrefint
|
||||
JOIN m_branch ON T_OrderRefIntDestM_BranchID = M_BranchID
|
||||
JOIN m_statusref ON T_OrderRefIntM_StatusRefID = M_StatusRefID
|
||||
WHERE T_OrderRefIntIsActive = 'Y'
|
||||
AND T_OrderRefIntDate = ?
|
||||
limit {$offset}, {$max_rst}";
|
||||
$query = $this->db_smartone->query($sql, [$sdate]);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->result_array();
|
||||
|
||||
$result = array("total" => $tot_count, "total_page" => ceil($tot_count/$max_rst), "cur_page" => $page, "records" => $rows, "total_display" => sizeof($rows), "q" => $this->db_smartone->last_query());
|
||||
$this->sys_ok($result);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("RI Header rows", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function confirm()
|
||||
{
|
||||
$prm = $this->sys_input;
|
||||
$ref_id = $prm['ref_id'];
|
||||
|
||||
$sql = "CALL sp_process_refinternal_confirm(?)";
|
||||
$query = $this->db_smartone->query($sql, [$ref_id]);
|
||||
|
||||
if ($query) {
|
||||
$rows = $query->row();
|
||||
$this->sys_ok($rows);
|
||||
}
|
||||
else {
|
||||
$this->sys_error_db("REF INTERNAL CONFIRM", $this->db_smartone);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user