235 lines
7.6 KiB
PHP
235 lines
7.6 KiB
PHP
<?php
|
|
|
|
class Mike extends MY_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/mike
|
|
function index()
|
|
{
|
|
echo json_encode(["status" => "OK", "message" => ""]);
|
|
}
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/mike/upload_request/100
|
|
function upload_request($mouID)
|
|
{
|
|
echo json_encode(["status" => "OK", "message" => "mcuID : $mouID"]);
|
|
}
|
|
function check_agreement($mouID)
|
|
{
|
|
echo json_encode(["status" => "OK", "message" => "mcuID : $mouID"]);
|
|
}
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/mike/test_get_lang
|
|
function test_get_lang()
|
|
{
|
|
$sql = "select * from m_lang where M_LangIsActive ='Y'";
|
|
//1. bikin query
|
|
$qry = $this->db->query($sql);
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
// ini message db yang eror
|
|
"message" => $this->db->error(),
|
|
// ini message query yang eror --> jgn ada di product
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
echo json_encode(["status" => "OK", "data" => $rows]);
|
|
}
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/mike/test_wrong_sql
|
|
function test_wrong_sql()
|
|
{
|
|
$sql = "select * from xm_lang where M_LangIsActive ='Y'";
|
|
//1. bikin query
|
|
$qry = $this->db->query($sql);
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
// ini message db yang eror
|
|
"message" => $this->db->error(),
|
|
// ini message query yang eror --> jgn ada di product
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
echo json_encode(["status" => "OK", "data" => $rows]);
|
|
}
|
|
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/mike/test_city1
|
|
function test_city1()
|
|
{
|
|
$param = $this->sys_input;
|
|
$is_active = $param["active"];
|
|
$search = "%" . $param["search"] . "%";
|
|
|
|
$sql = "select * from m_city where M_CityIsActive = ?
|
|
and M_CityName like ? ";
|
|
//1. bikin query
|
|
$qry = $this->db->query($sql, [$is_active, $search]);
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
"message" => $this->db->error(),
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
echo json_encode(["status" => "OK", "data" => $rows]);
|
|
}
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/mike/test_m_lang
|
|
function test_m_lang()
|
|
{
|
|
// ambil user dari token
|
|
$user = $this->sys_user;
|
|
$param = $this->sys_input;
|
|
// start transaction
|
|
$this->db->trans_start();
|
|
|
|
$sql = "insert into m_lang(M_LangCode,M_LangName,M_LangIsActive)
|
|
values (?,?,?)";
|
|
$qry = $this->db->query($sql, [$param["code"], $param["bahasa"], $param["active"]]);
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
"message" => $this->db->error(),
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
// rollback jika ada error
|
|
$this->db->trans_rollback();
|
|
exit;
|
|
}
|
|
// insert tbl c
|
|
// commit
|
|
$last_query = $this->db->last_query();
|
|
$xid = $this->db->insert_id();
|
|
$this->db->trans_commit();
|
|
echo json_encode([
|
|
"status" => "OK", "message" => "Last ID : $xid ",
|
|
"sql" => $last_query
|
|
]);
|
|
}
|
|
|
|
// https://devone.aplikasi.web.id/one-api/training/mike/test_soft_deleteLang
|
|
function test_soft_deleteLang()
|
|
{
|
|
// ambil user dari token
|
|
$user = $this->sys_user;
|
|
$userID = $user["M_UserID"];
|
|
$param = $this->sys_input;
|
|
// start transaction
|
|
$this->db->trans_start();
|
|
|
|
$sql = "update m_lang set M_LangIsActive = 'N' where M_LangID = ? and M_LangCode = ?";
|
|
|
|
$qry = $this->db->query($sql, [$param["id"], $param["code"]]);
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
"message" => $this->db->error(),
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
// rollback jika ada error
|
|
$this->db->trans_rollback();
|
|
exit;
|
|
}
|
|
// insert tbl c
|
|
// commit
|
|
$last_query = $this->db->last_query();
|
|
$this->db->trans_commit();
|
|
echo json_encode([
|
|
"status" => "OK", "message" => "Last ID : {$param["id"]} ",
|
|
"sql" => $last_query
|
|
]);
|
|
}
|
|
|
|
// select data dari f_bill_issue
|
|
// join f_bill, m_mou, m_company, m_branch (M_BranchIsActive = 'Y' & M_BranchIsDefault = 'Y')
|
|
// pastikan M_MouIsActive = 'H'
|
|
// Data yang dibutuhkan M_BranchID, M_BranchCode, M_BranchName,F_BillNo, M_MouID, M_MouName, M_MouNumber, M_CompanyID, M_CompanyNumber, M_MouLastUpdated (untuk info tanggal terholdnya)
|
|
|
|
|
|
function test_1()
|
|
{
|
|
$is_active = $param["active"];
|
|
$search = "%" . $param["search"] . "%";
|
|
|
|
$sql = "select * from f_bill_issue where M_CityIsActive = ?
|
|
and M_CityName like ? ";
|
|
|
|
//1. bikin query
|
|
$qry = $this->db->query($sql, [$is_active, $search]);
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
"message" => $this->db->error(),
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
echo json_encode(["status" => "OK", "data" => $rows]);
|
|
}
|
|
|
|
public function request_hold($mouid, $billid)
|
|
{
|
|
echo json_encode(["status" => "OK", "message" => "Request HOLD on : $mouid, $billid"]);
|
|
|
|
$sql = "
|
|
SELECT
|
|
m_mou.M_MouID,
|
|
m_mou.M_MouNumber,
|
|
m_mou.M_MouName,
|
|
m_mou.M_MouLastUpdated,
|
|
f_bill.F_BillNo,
|
|
m_company.M_CompanyID,
|
|
m_company.M_CompanyNumber,
|
|
m_branch.M_BranchID,
|
|
m_branch.M_BranchCode,
|
|
m_branch.M_BranchName
|
|
FROM f_bill_issue
|
|
JOIN m_mou ON f_bill_issue.F_BillIssueM_MouID=m_mou.M_MouID
|
|
AND m_mou.M_MouIsActive = 'H' AND m_mou.M_MouID= ?
|
|
JOIN f_bill ON f_bill_issue.F_BillIssueF_BillID=f_bill.F_BillID AND f_bill.F_BillID= ?
|
|
JOIN m_company ON f_bill_issue.F_BillIssueM_CompanyID=m_company.M_CompanyID
|
|
JOIN m_branch ON m_branch.M_BranchIsDefault = 'Y' AND m_branch.M_BranchIsActive = 'Y'
|
|
";
|
|
$qry = $this->db->query($sql, array($mouid, $billid));
|
|
|
|
if (!$qry) {
|
|
echo json_encode(
|
|
[
|
|
"status" => "ERR",
|
|
"message" => $this->db->error(),
|
|
"sql" => $this->db->last_query()
|
|
]
|
|
);
|
|
exit;
|
|
}
|
|
$rows = $qry->result_array();
|
|
echo json_encode(["status" => "OK", "data" => $rows]);
|
|
}
|
|
}
|