Compare commits
15 Commits
c125289b92
...
c83c42698a
| Author | SHA1 | Date | |
|---|---|---|---|
| c83c42698a | |||
| 009aff7d44 | |||
| 6dbe0e400b | |||
| 0ea56f09fa | |||
| a6412c9688 | |||
| bcb553ea56 | |||
| 2874fab71d | |||
| 752c372c2f | |||
| 7e88cf247b | |||
| 7af9fb2ca4 | |||
| 77fc97e964 | |||
| 834f23f26e | |||
| dc88589c78 | |||
| 3871a680dd | |||
| 9c87e9ce25 |
@@ -236,6 +236,17 @@ Content-Type: application/json
|
|||||||
"poID": 1
|
"poID": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###
|
||||||
|
// update approval PO — verifikasi manager (level 1)
|
||||||
|
POST https://{{host}}/mockup/purchase/order/PurchaseOrderAset/updateApprovalPO/
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"token": {{token}},
|
||||||
|
"poID": 1,
|
||||||
|
"approvelevel": "1"
|
||||||
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
// get data kontrak po asset
|
// get data kontrak po asset
|
||||||
POST https://{{host}}/mockup/purchase/order/PurchaseOrderAset/getDataKontrakPoAset/
|
POST https://{{host}}/mockup/purchase/order/PurchaseOrderAset/getDataKontrakPoAset/
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class PurchaseOrderAset extends MY_Controller
|
class PurchaseOrderAset extends MY_Controller {
|
||||||
{
|
|
||||||
var $db;
|
var $db;
|
||||||
public function index()
|
public function index() {
|
||||||
{
|
|
||||||
echo "Purchase Order Aset API";
|
echo "Purchase Order Aset API";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,45 +12,40 @@ class PurchaseOrderAset extends MY_Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
## QUERY ##
|
## QUERY ##
|
||||||
public function getListSupplier()
|
public function getListSupplier() {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
if (!$this->isLogin) {
|
if (!$this->isLogin) {
|
||||||
throw new Exception('Invalid token');
|
$this->sys_error("invalid token");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
SupplierID,
|
SupplierID,
|
||||||
SupplierName
|
SupplierName
|
||||||
FROM supplier
|
FROM supplier
|
||||||
WHERE SupplierIsActive = 'Y'";
|
WHERE SupplierIsActive = 'Y'";
|
||||||
$que = $this->db->query($sql, []);
|
$que = $this->db->query($sql, []);
|
||||||
if (!$que) {
|
if (!$que) {
|
||||||
throw new Exception('failed to query list supplier', 1);
|
$this->sys_error_db("[Error] get data supplier");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $que->result_array();
|
$data = $que->result_array();
|
||||||
$this->sys_ok($data);
|
$this->sys_ok($data);
|
||||||
} catch (Exception $exc) {
|
} catch (Exception $exc) {
|
||||||
$msg = '[Error] ' . $exc->getMessage();
|
$this->sys_error($exc->getMessage());
|
||||||
$code = $exc->getCode();
|
|
||||||
if ($code == 0) {
|
|
||||||
$this->sys_error($msg);
|
|
||||||
} else {
|
|
||||||
$this->sys_error_db($msg);
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getListCabang()
|
public function getListCabang() {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
if (!$this->isLogin) {
|
if (!$this->isLogin) {
|
||||||
throw new Exception('Invalid token');
|
$this->sys_error("invalid token");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->sys_user;
|
$user = $this->sys_user;
|
||||||
|
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
M_BranchID,
|
M_BranchID,
|
||||||
M_BranchCode,
|
M_BranchCode,
|
||||||
@@ -62,28 +55,22 @@ class PurchaseOrderAset extends MY_Controller
|
|||||||
AND M_BranchS_RegionalID = ?";
|
AND M_BranchS_RegionalID = ?";
|
||||||
$que = $this->db->query($sql, [$user['S_RegionalID']]);
|
$que = $this->db->query($sql, [$user['S_RegionalID']]);
|
||||||
if (!$que) {
|
if (!$que) {
|
||||||
throw new Exception('failed to query list cabang', 1);
|
$this->sys_error_db("[Error] failed get list cabang");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
$data = $que->result_array();
|
|
||||||
|
|
||||||
|
$data = $que->result_array();
|
||||||
$this->sys_ok($data);
|
$this->sys_ok($data);
|
||||||
} catch (Exception $exc) {
|
} catch (Exception $exc) {
|
||||||
$msg = '[Error] ' . $exc->getMessage();
|
$this->sys_error($exc->getMessage());
|
||||||
$code = $exc->getCode();
|
|
||||||
if ($code == 0) {
|
|
||||||
$this->sys_error($msg);
|
|
||||||
} else {
|
|
||||||
$this->sys_error_db($msg);
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchRequestAset()
|
public function searchRequestAset() {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
if (!$this->isLogin) {
|
if (!$this->isLogin) {
|
||||||
throw new Exception('Invalid token');
|
$this->sys_error("invalid token");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$para = $this->sys_input;
|
$para = $this->sys_input;
|
||||||
@@ -100,70 +87,67 @@ class PurchaseOrderAset extends MY_Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
PurchaseRequestID,
|
PurchaseRequestID,
|
||||||
PurchaseRequestNumber,
|
PurchaseRequestNumber,
|
||||||
PurchaseRequestDetailID,
|
PurchaseRequestDetailID,
|
||||||
PurchaseRequestFlagID,
|
PurchaseRequestFlagID,
|
||||||
PurchaseRequestFlagM_BranchCode AS BranchCode,
|
PurchaseRequestFlagM_BranchCode AS BranchCode,
|
||||||
PurchaseRequestItemCategoryID AS ItemCategoryID,
|
PurchaseRequestItemCategoryID AS ItemCategoryID,
|
||||||
PurchaseRequestFlagQtyRest - PurchaseRequestFlagQtyProses AS UnprocessFlagQty,
|
PurchaseRequestFlagQtyRest - PurchaseRequestFlagQtyProses AS UnprocessFlagQty,
|
||||||
PurchaseRequestDetailQty AS RequestQty,
|
PurchaseRequestDetailQty AS RequestQty,
|
||||||
PurchaseRequestDetailQty AS OriginalQty,
|
PurchaseRequestDetailQty AS OriginalQty,
|
||||||
M_BranchName,
|
M_BranchName,
|
||||||
M_ItemID,
|
M_ItemID,
|
||||||
M_ItemCode,
|
M_ItemCode,
|
||||||
M_ItemDesc,
|
M_ItemDesc,
|
||||||
ItemUnitID,
|
ItemUnitID,
|
||||||
ItemUnitName,
|
ItemUnitName,
|
||||||
SupplierPricePrice as SupplierPrice
|
SupplierPricePrice as SupplierPrice
|
||||||
FROM purchase_request
|
FROM purchase_request
|
||||||
JOIN purchase_request_detail ON PurchaseRequestDetailPurchaseRequestID = PurchaseRequestID
|
JOIN purchase_request_detail ON PurchaseRequestDetailPurchaseRequestID = PurchaseRequestID
|
||||||
AND PurchaseRequestDetailIsActive = 'Y'
|
AND PurchaseRequestDetailIsActive = 'Y'
|
||||||
AND PurchaseRequestM_BranchCode = ?
|
AND PurchaseRequestM_BranchCode = ?
|
||||||
AND PurchaseRequestItemCategoryID = '3' -- id category item asset
|
AND PurchaseRequestItemCategoryID = '3' -- id category item asset
|
||||||
AND PurchaseRequestNumber LIKE ?
|
AND PurchaseRequestNumber LIKE ?
|
||||||
JOIN purchase_request_flag ON PurchaseRequestFlagPurchaseRequestDetailID = PurchaseRequestDetailID
|
JOIN purchase_request_flag ON PurchaseRequestFlagPurchaseRequestDetailID = PurchaseRequestDetailID
|
||||||
AND PurchaseRequestFlagStatus = 'PO'
|
AND PurchaseRequestFlagStatus = 'PO'
|
||||||
AND PurchaseRequestFlagIsActive = 'Y'
|
AND PurchaseRequestFlagIsActive = 'Y'
|
||||||
JOIN m_item ON M_ItemID = PurchaseRequestDetailM_ItemID
|
JOIN m_item ON M_ItemID = PurchaseRequestDetailM_ItemID
|
||||||
JOIN itemunit ON ItemUnitID = PurchaseRequestDetailItemUnitID
|
JOIN itemunit ON ItemUnitID = PurchaseRequestDetailItemUnitID
|
||||||
JOIN supplier_price ON SupplierPriceSupplierID = ?
|
JOIN supplier_price ON SupplierPriceSupplierID = ?
|
||||||
AND SupplierPriceM_ItemID = M_ItemID
|
AND SupplierPriceM_ItemID = M_ItemID
|
||||||
AND SupplierPriceItemUnitID = ItemUnitID
|
AND SupplierPriceItemUnitID = ItemUnitID
|
||||||
AND SupplierPriceIsActive = 'Y'
|
AND SupplierPriceIsActive = 'Y'
|
||||||
JOIN m_branch ON M_BranchCode = PurchaseRequestFlagM_BranchCode
|
JOIN m_branch ON M_BranchCode = PurchaseRequestFlagM_BranchCode
|
||||||
AND M_BranchIsActive = 'Y'
|
AND M_BranchIsActive = 'Y'
|
||||||
WHERE NOT EXISTS (
|
WHERE NOT EXISTS (
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM purchase_order_detail
|
FROM purchase_order_detail
|
||||||
JOIN purchase_order ON PurchaseOrderDetailPurchaseOrderID = PurchaseOrderID
|
JOIN purchase_order ON PurchaseOrderDetailPurchaseOrderID = PurchaseOrderID
|
||||||
AND PurchaseOrderStatus = 'Approved'
|
AND PurchaseOrderStatus = 'Approved'
|
||||||
AND PurchaseOrderIsActive = 'Y'
|
AND PurchaseOrderIsActive = 'Y'
|
||||||
AND PurchaseOrderDetailIsActive = 'Y'
|
AND PurchaseOrderDetailIsActive = 'Y'
|
||||||
WHERE PurchaseOrderDetailPurchaseRequestDetailID = PurchaseRequestDetailID
|
WHERE PurchaseOrderDetailPurchaseRequestDetailID = PurchaseRequestDetailID
|
||||||
)";
|
)";
|
||||||
|
|
||||||
$sql_data = $sql . " LIMIT ? OFFSET ? ";
|
$sql_data = $sql . " LIMIT ? OFFSET ? ";
|
||||||
$que_data = $this->db->query($sql_data, [
|
$que_data = $this->db->query($sql_data, [
|
||||||
$para['branchcode'],
|
$para['branchcode'], $keyword, $para['supplierID'],
|
||||||
$keyword,
|
$limit, $offset
|
||||||
$para['supplierID'],
|
|
||||||
$limit,
|
|
||||||
$offset
|
|
||||||
]);
|
]);
|
||||||
if (!$que_data) {
|
if (!$que_data) {
|
||||||
throw new Exception('failed to query data request order aset', 1);
|
$this->sys_error_db("[Error] get daftar request data");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
$data = $que_data->result_array();
|
$data = $que_data->result_array();
|
||||||
|
|
||||||
$sql_total = "SELECT COUNT(*) AS total FROM ($sql) AS x";
|
$sql_total = "SELECT COUNT(*) AS total FROM ($sql) AS x";
|
||||||
$que_total = $this->db->query($sql_total, [
|
$que_total = $this->db->query($sql_total, [
|
||||||
$para['branchcode'],
|
$para['branchcode'], $keyword, $para['supplierID']
|
||||||
$keyword,
|
|
||||||
$para['supplierID']
|
|
||||||
]);
|
]);
|
||||||
if (!$que_total) {
|
if (!$que_total) {
|
||||||
throw new Exception('failed to query total request order aset', 1);
|
$this->sys_error_db("[Error] get total request aset");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
$total = $que_total->row_array()['total'];
|
$total = $que_total->row_array()['total'];
|
||||||
|
|
||||||
@@ -174,14 +158,7 @@ class PurchaseOrderAset extends MY_Controller
|
|||||||
|
|
||||||
$this->sys_ok($out);
|
$this->sys_ok($out);
|
||||||
} catch (Exception $exc) {
|
} catch (Exception $exc) {
|
||||||
$msg = '[Error] ' . $exc->getMessage();
|
$this->sys_error($exc->getMessage());
|
||||||
$code = $exc->getCode();
|
|
||||||
if ($code == 0) {
|
|
||||||
$this->sys_error($msg);
|
|
||||||
} else {
|
|
||||||
$this->sys_error_db($msg);
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1125,33 +1102,91 @@ class PurchaseOrderAset extends MY_Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateApprovalPO() {
|
||||||
|
try {
|
||||||
|
if (!$this->isLogin) {
|
||||||
|
$this->sys_error("invalid token");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->trans_begin();
|
||||||
|
$para = $this->sys_input;
|
||||||
|
$user = $this->sys_user;
|
||||||
|
$approvelevel = $para['approvelevel'];
|
||||||
|
|
||||||
|
/* request purchase order */
|
||||||
|
if ($approvelevel == '0') {
|
||||||
|
$sql = "UPDATE purchase_order SET
|
||||||
|
PurchaseOrderStatus = 'Pending',
|
||||||
|
PurchaseOrderLastUpdated = NOW()
|
||||||
|
WHERE PurchaseOrderID = ?
|
||||||
|
AND PurchaseOrderIsActive = 'Y'";
|
||||||
|
$que = $this->db->query($sql, [$para['poID']]);
|
||||||
|
if (!$que) {
|
||||||
|
$this->db->trans_rollback();
|
||||||
|
$this->sys_error_db("[Error] failed update table purchase order request");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* verifikasi oleh manager */
|
||||||
|
if ($approvelevel == '1') {
|
||||||
|
$sql = "UPDATE purchase_order SET
|
||||||
|
PurchaseOrderApprovedManagerUserID = ?,
|
||||||
|
PurchaseOrderLastUpdated = NOW()
|
||||||
|
WHERE PurchaseOrderID = ?
|
||||||
|
AND PurchaseOrderIsActive = 'Y'";
|
||||||
|
$que = $this->db->query($sql, [$user['M_UserID'], $para['poID']]);
|
||||||
|
if (!$que) {
|
||||||
|
$this->db->trans_rollback();
|
||||||
|
$this->sys_error_db("[Error] failed update table purchase order verif");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* approval oleh kepala regional */
|
||||||
|
if ($approvelevel == '2') {
|
||||||
|
$sql = "UPDATE purchase_order SET
|
||||||
|
PurchaseOrderStatus = 'Approved',
|
||||||
|
PurchaseOrderLastUpdated = NOW(),
|
||||||
|
PurchaseOrderApprovedUserID = ?
|
||||||
|
WHERE PurchaseOrderID = ?
|
||||||
|
AND PurchaseOrderIsActive = 'Y'";
|
||||||
|
$que = $this->db->query($sql, [$user['M_UserID'], $para['poID']]);
|
||||||
|
if (!$que) {
|
||||||
|
$this->db->trans_rollback();
|
||||||
|
$this->sys_error_db("[Error] failed update table purchase order approve");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->trans_commit();
|
||||||
|
$this->sys_ok("[Success] success update status PO Asset");
|
||||||
|
} catch (Exception $exc) {
|
||||||
|
$msg = $exc->getMessage();
|
||||||
|
$this->sys_error($msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getUserApproveLevel() {
|
public function getUserApproveLevel() {
|
||||||
try {
|
try {
|
||||||
if (!$this->isLogin) {
|
if (!$this->isLogin) {
|
||||||
throw new Exception('Invalid token');
|
$this->sys_error("invalid token");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->sys_user;
|
$user = $this->sys_user;
|
||||||
$sql = "SELECT M_UserM_ApproveLevelID
|
$sql = "SELECT M_UserM_ApproveLevelID FROM m_user
|
||||||
FROM m_user
|
WHERE M_UserIsActive = 'Y' AND M_UserID = ? ";
|
||||||
WHERE M_UserIsActive = 'Y'
|
|
||||||
AND M_UserID = ? ";
|
|
||||||
$que = $this->db->query($sql, [$user['M_UserID']]);
|
$que = $this->db->query($sql, [$user['M_UserID']]);
|
||||||
if (!$que) {
|
if (!$que) {
|
||||||
throw new Exception('failed to query approval level', 1);
|
$this->sys_error_db("[Error] failed get approval level user");
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
$data = $que->row_array();
|
$data = $que->row_array();
|
||||||
|
|
||||||
$this->sys_ok($data);
|
$this->sys_ok($data);
|
||||||
} catch (Exception $exc) {
|
} catch (Exception $exc) {
|
||||||
$msg = '[Error] ' . $exc->getMessage();
|
$this->sys_error($exc->getMessage());
|
||||||
$code = $exc->getCode();
|
|
||||||
if ($code == 0) {
|
|
||||||
$this->sys_error($msg);
|
|
||||||
} else {
|
|
||||||
$this->sys_error_db($msg);
|
|
||||||
}
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user