Compare commits
5 Commits
po-asset-c
...
b7a00bc242
| Author | SHA1 | Date | |
|---|---|---|---|
| b7a00bc242 | |||
| 13af691645 | |||
| 775a390bcb | |||
| 0d1dcb1b5e | |||
| 22719de06f |
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
class PurchaseOrderAset extends MY_Controller {
|
||||
class PurchaseOrderAset extends MY_Controller
|
||||
{
|
||||
var $db;
|
||||
public function index() {
|
||||
public function index()
|
||||
{
|
||||
echo "Purchase Order Aset API";
|
||||
}
|
||||
|
||||
@@ -12,40 +14,45 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
## QUERY ##
|
||||
public function getListSupplier() {
|
||||
public function getListSupplier()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
throw new Exception('Invalid token');
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
SupplierID,
|
||||
SupplierName
|
||||
FROM supplier
|
||||
WHERE SupplierIsActive = 'Y'";
|
||||
SupplierID,
|
||||
SupplierName
|
||||
FROM supplier
|
||||
WHERE SupplierIsActive = 'Y'";
|
||||
$que = $this->db->query($sql, []);
|
||||
if (!$que) {
|
||||
$this->sys_error_db("[Error] get data supplier");
|
||||
exit;
|
||||
throw new Exception('failed to query list supplier', 1);
|
||||
}
|
||||
|
||||
$data = $que->result_array();
|
||||
$this->sys_ok($data);
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
$msg = '[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 {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
throw new Exception('Invalid token');
|
||||
}
|
||||
|
||||
$user = $this->sys_user;
|
||||
|
||||
$sql = "SELECT
|
||||
M_BranchID,
|
||||
M_BranchCode,
|
||||
@@ -55,22 +62,28 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
AND M_BranchS_RegionalID = ?";
|
||||
$que = $this->db->query($sql, [$user['S_RegionalID']]);
|
||||
if (!$que) {
|
||||
$this->sys_error_db("[Error] failed get list cabang");
|
||||
exit;
|
||||
throw new Exception('failed to query list cabang', 1);
|
||||
}
|
||||
|
||||
$data = $que->result_array();
|
||||
|
||||
$this->sys_ok($data);
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
$msg = '[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 {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
throw new Exception('Invalid token');
|
||||
}
|
||||
|
||||
$para = $this->sys_input;
|
||||
@@ -87,67 +100,70 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
$sql = "SELECT
|
||||
PurchaseRequestID,
|
||||
PurchaseRequestNumber,
|
||||
PurchaseRequestDetailID,
|
||||
PurchaseRequestFlagID,
|
||||
PurchaseRequestFlagM_BranchCode AS BranchCode,
|
||||
PurchaseRequestItemCategoryID AS ItemCategoryID,
|
||||
PurchaseRequestFlagQtyRest - PurchaseRequestFlagQtyProses AS UnprocessFlagQty,
|
||||
PurchaseRequestDetailQty AS RequestQty,
|
||||
PurchaseRequestDetailQty AS OriginalQty,
|
||||
M_BranchName,
|
||||
M_ItemID,
|
||||
M_ItemCode,
|
||||
M_ItemDesc,
|
||||
ItemUnitID,
|
||||
ItemUnitName,
|
||||
SupplierPricePrice as SupplierPrice
|
||||
FROM purchase_request
|
||||
JOIN purchase_request_detail ON PurchaseRequestDetailPurchaseRequestID = PurchaseRequestID
|
||||
AND PurchaseRequestDetailIsActive = 'Y'
|
||||
AND PurchaseRequestM_BranchCode = ?
|
||||
AND PurchaseRequestItemCategoryID = '3' -- id category item asset
|
||||
AND PurchaseRequestNumber LIKE ?
|
||||
JOIN purchase_request_flag ON PurchaseRequestFlagPurchaseRequestDetailID = PurchaseRequestDetailID
|
||||
AND PurchaseRequestFlagStatus = 'PO'
|
||||
AND PurchaseRequestFlagIsActive = 'Y'
|
||||
JOIN m_item ON M_ItemID = PurchaseRequestDetailM_ItemID
|
||||
JOIN itemunit ON ItemUnitID = PurchaseRequestDetailItemUnitID
|
||||
JOIN supplier_price ON SupplierPriceSupplierID = ?
|
||||
AND SupplierPriceM_ItemID = M_ItemID
|
||||
AND SupplierPriceItemUnitID = ItemUnitID
|
||||
AND SupplierPriceIsActive = 'Y'
|
||||
JOIN m_branch ON M_BranchCode = PurchaseRequestFlagM_BranchCode
|
||||
AND M_BranchIsActive = 'Y'
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM purchase_order_detail
|
||||
JOIN purchase_order ON PurchaseOrderDetailPurchaseOrderID = PurchaseOrderID
|
||||
AND PurchaseOrderStatus = 'Approved'
|
||||
AND PurchaseOrderIsActive = 'Y'
|
||||
AND PurchaseOrderDetailIsActive = 'Y'
|
||||
WHERE PurchaseOrderDetailPurchaseRequestDetailID = PurchaseRequestDetailID
|
||||
)";
|
||||
PurchaseRequestID,
|
||||
PurchaseRequestNumber,
|
||||
PurchaseRequestDetailID,
|
||||
PurchaseRequestFlagID,
|
||||
PurchaseRequestFlagM_BranchCode AS BranchCode,
|
||||
PurchaseRequestItemCategoryID AS ItemCategoryID,
|
||||
PurchaseRequestFlagQtyRest - PurchaseRequestFlagQtyProses AS UnprocessFlagQty,
|
||||
PurchaseRequestDetailQty AS RequestQty,
|
||||
PurchaseRequestDetailQty AS OriginalQty,
|
||||
M_BranchName,
|
||||
M_ItemID,
|
||||
M_ItemCode,
|
||||
M_ItemDesc,
|
||||
ItemUnitID,
|
||||
ItemUnitName,
|
||||
SupplierPricePrice as SupplierPrice
|
||||
FROM purchase_request
|
||||
JOIN purchase_request_detail ON PurchaseRequestDetailPurchaseRequestID = PurchaseRequestID
|
||||
AND PurchaseRequestDetailIsActive = 'Y'
|
||||
AND PurchaseRequestM_BranchCode = ?
|
||||
AND PurchaseRequestItemCategoryID = '3' -- id category item asset
|
||||
AND PurchaseRequestNumber LIKE ?
|
||||
JOIN purchase_request_flag ON PurchaseRequestFlagPurchaseRequestDetailID = PurchaseRequestDetailID
|
||||
AND PurchaseRequestFlagStatus = 'PO'
|
||||
AND PurchaseRequestFlagIsActive = 'Y'
|
||||
JOIN m_item ON M_ItemID = PurchaseRequestDetailM_ItemID
|
||||
JOIN itemunit ON ItemUnitID = PurchaseRequestDetailItemUnitID
|
||||
JOIN supplier_price ON SupplierPriceSupplierID = ?
|
||||
AND SupplierPriceM_ItemID = M_ItemID
|
||||
AND SupplierPriceItemUnitID = ItemUnitID
|
||||
AND SupplierPriceIsActive = 'Y'
|
||||
JOIN m_branch ON M_BranchCode = PurchaseRequestFlagM_BranchCode
|
||||
AND M_BranchIsActive = 'Y'
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM purchase_order_detail
|
||||
JOIN purchase_order ON PurchaseOrderDetailPurchaseOrderID = PurchaseOrderID
|
||||
AND PurchaseOrderStatus = 'Approved'
|
||||
AND PurchaseOrderIsActive = 'Y'
|
||||
AND PurchaseOrderDetailIsActive = 'Y'
|
||||
WHERE PurchaseOrderDetailPurchaseRequestDetailID = PurchaseRequestDetailID
|
||||
)";
|
||||
|
||||
$sql_data = $sql . " LIMIT ? OFFSET ? ";
|
||||
$que_data = $this->db->query($sql_data, [
|
||||
$para['branchcode'], $keyword, $para['supplierID'],
|
||||
$limit, $offset
|
||||
$para['branchcode'],
|
||||
$keyword,
|
||||
$para['supplierID'],
|
||||
$limit,
|
||||
$offset
|
||||
]);
|
||||
if (!$que_data) {
|
||||
$this->sys_error_db("[Error] get daftar request data");
|
||||
exit;
|
||||
throw new Exception('failed to query data request order aset', 1);
|
||||
}
|
||||
$data = $que_data->result_array();
|
||||
|
||||
$sql_total = "SELECT COUNT(*) AS total FROM ($sql) AS x";
|
||||
$que_total = $this->db->query($sql_total, [
|
||||
$para['branchcode'], $keyword, $para['supplierID']
|
||||
$para['branchcode'],
|
||||
$keyword,
|
||||
$para['supplierID']
|
||||
]);
|
||||
if (!$que_total) {
|
||||
$this->sys_error_db("[Error] get total request aset");
|
||||
exit;
|
||||
throw new Exception('failed to query total request order aset', 1);
|
||||
}
|
||||
$total = $que_total->row_array()['total'];
|
||||
|
||||
@@ -158,29 +174,64 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
|
||||
$this->sys_ok($out);
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
$msg = '[Error] ' . $exc->getMessage();
|
||||
$code = $exc->getCode();
|
||||
if ($code == 0) {
|
||||
$this->sys_error($msg);
|
||||
} else {
|
||||
$this->sys_error_db($msg);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserApproveLevel() {
|
||||
public function getUserApproveLevel()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
throw new Exception('Invalid token');
|
||||
}
|
||||
|
||||
$user = $this->sys_user;
|
||||
$sql = "SELECT M_UserM_ApproveLevelID FROM m_user
|
||||
WHERE M_UserIsActive = 'Y' AND M_UserID = ? ";
|
||||
$sql = "SELECT M_UserM_ApproveLevelID
|
||||
FROM m_user
|
||||
WHERE M_UserIsActive = 'Y'
|
||||
AND M_UserID = ? ";
|
||||
$que = $this->db->query($sql, [$user['M_UserID']]);
|
||||
if (!$que) {
|
||||
$this->sys_error_db("[Error] failed get approval level user");
|
||||
exit;
|
||||
throw new Exception('failed to query approval level', 1);
|
||||
}
|
||||
$data = $que->row_array();
|
||||
|
||||
$this->sys_ok($data);
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
$msg = '[Error] ' . $exc->getMessage();
|
||||
$code = $exc->getCode();
|
||||
if ($code == 0) {
|
||||
$this->sys_error($msg);
|
||||
} else {
|
||||
$this->sys_error_db($msg);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
## MUTATIONS ##
|
||||
public function insertPurchaseOrderAsset()
|
||||
{
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
throw new Exception('Invalid token');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$msg = '[Error] ' . $e->getMessage();
|
||||
$code = $e->getCode();
|
||||
if ($code == 0) {
|
||||
$this->sys_error($msg);
|
||||
} else {
|
||||
$this->sys_error_db($msg);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1514,23 +1514,23 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
# GET DATA RO #
|
||||
$json_ro_before = $this->getDataROPO($ROID);
|
||||
$sql_ro = "SELECT
|
||||
receive_order_po.*,
|
||||
DATE_FORMAT(ReceiveOrderPoIDate, '%d-%m-%Y') AS formatedDate,
|
||||
CASE
|
||||
WHEN WarehouseType = 'B'
|
||||
THEN CONCAT(WarehouseCode,' ', WarehouseName, ' - ', M_BranchName)
|
||||
WHEN WarehouseType = 'R'
|
||||
THEN CONCAT(WarehouseCode,' ', WarehouseName, ' - ', S_RegionalName)
|
||||
ELSE ''
|
||||
END WarehouseName,
|
||||
WarehouseID
|
||||
FROM receive_order_po
|
||||
JOIN warehouse ON ReceiveOrderPoWarehouseID = WarehouseID
|
||||
JOIN s_regional ON WarehouseS_RegionalID = S_RegionalID
|
||||
AND S_RegionalIsActive = 'Y'
|
||||
LEFT JOIN m_branch ON WarehouseM_BranchID = M_BranchID
|
||||
AND M_BranchIsActive = 'Y'
|
||||
WHERE ReceiveOrderPoID = ?";
|
||||
receive_order_po.*,
|
||||
DATE_FORMAT(ReceiveOrderPoIDate, '%d-%m-%Y') AS formatedDate,
|
||||
CASE
|
||||
WHEN WarehouseType = 'B'
|
||||
THEN CONCAT(WarehouseCode,' ', WarehouseName, ' - ', M_BranchName)
|
||||
WHEN WarehouseType = 'R'
|
||||
THEN CONCAT(WarehouseCode,' ', WarehouseName, ' - ', S_RegionalName)
|
||||
ELSE ''
|
||||
END WarehouseName,
|
||||
WarehouseID
|
||||
FROM receive_order_po
|
||||
JOIN warehouse ON ReceiveOrderPoWarehouseID = WarehouseID
|
||||
JOIN s_regional ON WarehouseS_RegionalID = S_RegionalID
|
||||
AND S_RegionalIsActive = 'Y'
|
||||
LEFT JOIN m_branch ON WarehouseM_BranchID = M_BranchID
|
||||
AND M_BranchIsActive = 'Y'
|
||||
WHERE ReceiveOrderPoID = ?";
|
||||
$que_ro = $this->db->query($sql_ro, [$ROID]);
|
||||
if (!$que_ro) {
|
||||
$this->db->trans_rollback();
|
||||
@@ -1545,23 +1545,23 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
}
|
||||
|
||||
$sql_detail_ro = "SELECT
|
||||
receive_order_po_detail.*,
|
||||
PurchaseOrderID,
|
||||
PurchaseOrderNumber,
|
||||
PurchaseOrderTaxPercentPph,
|
||||
PurchaseOrderTaxPercentPpn,
|
||||
PurchaseOrderSummaryDiscountAmount as DiscountPerItem,
|
||||
PurchaseOrderSummaryQty as QtyAllPO,
|
||||
PurchaseOrderSummaryTotal as TotalAllPO,
|
||||
PurchaseOrderDiscountPercent AS DiscPOPercent,
|
||||
PurchaseOrderDiscountAmount AS DiscPORupiah
|
||||
FROM receive_order_po_detail
|
||||
JOIN purchase_order ON ReceiveOrderPoDetailPurchaseOrderID = PurchaseOrderID
|
||||
JOIN purchase_order_summary ON ReceiveOrderPoDetailPurchaseOrderSummaryID = PurchaseOrderSummaryID
|
||||
AND PurchaseOrderSummaryIsActive = 'Y'
|
||||
WHERE ReceiveOrderPoDetailReceiveOrderPoID = ?
|
||||
AND ReceiveOrderPoDetailIsActive='Y'
|
||||
GROUP BY ReceiveOrderPoDetailID";
|
||||
receive_order_po_detail.*,
|
||||
PurchaseOrderID,
|
||||
PurchaseOrderNumber,
|
||||
PurchaseOrderTaxPercentPph,
|
||||
PurchaseOrderTaxPercentPpn,
|
||||
PurchaseOrderSummaryDiscountAmount as DiscountPerItem,
|
||||
PurchaseOrderSummaryQty as QtyAllPO,
|
||||
PurchaseOrderSummaryTotal as TotalAllPO,
|
||||
PurchaseOrderDiscountPercent AS DiscPOPercent,
|
||||
PurchaseOrderDiscountAmount AS DiscPORupiah
|
||||
FROM receive_order_po_detail
|
||||
JOIN purchase_order ON ReceiveOrderPoDetailPurchaseOrderID = PurchaseOrderID
|
||||
JOIN purchase_order_summary ON ReceiveOrderPoDetailPurchaseOrderSummaryID = PurchaseOrderSummaryID
|
||||
AND PurchaseOrderSummaryIsActive = 'Y'
|
||||
WHERE ReceiveOrderPoDetailReceiveOrderPoID = ?
|
||||
AND ReceiveOrderPoDetailIsActive='Y'
|
||||
GROUP BY ReceiveOrderPoDetailID";
|
||||
$que_detail_ro = $this->db->query($sql_detail_ro, [$ROID]);
|
||||
if (!$que_detail_ro) {
|
||||
$this->db->trans_rollback();
|
||||
@@ -1572,10 +1572,10 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
|
||||
# UPDATE STATUS RO #
|
||||
$sql_update_ro = "UPDATE receive_order_po SET
|
||||
ReceiveOrderPoConfirmed = 'Y',
|
||||
ReceiveOrderPoConfirmedDate = NOW(),
|
||||
ReceiveOrderPoConfirmedUserID = ?
|
||||
WHERE ReceiveOrderPoID = ?";
|
||||
ReceiveOrderPoConfirmed = 'Y',
|
||||
ReceiveOrderPoConfirmedDate = NOW(),
|
||||
ReceiveOrderPoConfirmedUserID = ?
|
||||
WHERE ReceiveOrderPoID = ?";
|
||||
$que_update_ro = $this->db->query($sql_update_ro, [$user['M_UserID'], $ROID]);
|
||||
if (!$que_update_ro) {
|
||||
$this->db->trans_rollback();
|
||||
@@ -1594,8 +1594,8 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
$jurnal_number = $que_jrnl_num->row_array()['numbering'];
|
||||
|
||||
$sql_periode = "SELECT periodeID FROM periode
|
||||
WHERE DATE(NOW()) BETWEEN periodeStartDate AND periodeEndDate
|
||||
AND periodeIsActive= 'Y' AND periodeIsClosed = 'N'";
|
||||
WHERE DATE(NOW()) BETWEEN periodeStartDate AND periodeEndDate
|
||||
AND periodeIsActive= 'Y' AND periodeIsClosed = 'N'";
|
||||
$que_periode = $this->db->query($sql_periode, []);
|
||||
if (!$que_periode) {
|
||||
$this->sys_error_db("[Error] get periode", $this->db);
|
||||
@@ -1631,17 +1631,17 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
|
||||
# INSERT JURNAL HEADER #
|
||||
$sql_head_jurnal = "INSERT INTO jurnal (
|
||||
jurnalM_BranchCompanyID,
|
||||
JurnalS_RegionalID,
|
||||
jurnalM_BranchCode,
|
||||
jurnalperiodeID,
|
||||
jurnalNo,
|
||||
jurnalTitle,
|
||||
jurnalDescription,
|
||||
jurnalDate,
|
||||
jurnalJurnalTypeID,
|
||||
jurnalM_UserID
|
||||
) VALUES (?,?,?,?,?,?,?,NOW(),?,?)";
|
||||
jurnalM_BranchCompanyID,
|
||||
JurnalS_RegionalID,
|
||||
jurnalM_BranchCode,
|
||||
jurnalperiodeID,
|
||||
jurnalNo,
|
||||
jurnalTitle,
|
||||
jurnalDescription,
|
||||
jurnalDate,
|
||||
jurnalJurnalTypeID,
|
||||
jurnalM_UserID
|
||||
) VALUES (?,?,?,?,?,?,?,NOW(),?,?)";
|
||||
$que_head_jurnal = $this->db->query($sql_head_jurnal, [
|
||||
$user['M_BranchCompanyID'],
|
||||
$user['S_RegionalID'],
|
||||
@@ -1668,9 +1668,9 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
foreach ($data_detail_ro as $key => $detail) {
|
||||
# UPDATE PO Summary #
|
||||
$sql_posummary = "UPDATE purchase_order_summary SET
|
||||
PurchaseOrderSummaryQtyReceived = PurchaseOrderSummaryQtyReceived + ?
|
||||
WHERE PurchaseOrderSummaryIsActive = 'Y'
|
||||
AND PurchaseOrderSummaryID = ?";
|
||||
PurchaseOrderSummaryQtyReceived = PurchaseOrderSummaryQtyReceived + ?
|
||||
WHERE PurchaseOrderSummaryIsActive = 'Y'
|
||||
AND PurchaseOrderSummaryID = ?";
|
||||
$que_posummary = $this->db->query($sql_posummary, [
|
||||
intval($detail['ReceiveOrderPoDetailQty']),
|
||||
$detail['ReceiveOrderPoDetailPurchaseOrderSummaryID']
|
||||
@@ -1862,8 +1862,8 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
|
||||
// save diskon prorata
|
||||
$sql_save_diskon = "UPDATE receive_order_po_detail SET
|
||||
ReceiveOrderPoDetailDiskonPoProrata = ?
|
||||
WHERE ReceiveOrderPoDetailID = ?";
|
||||
ReceiveOrderPoDetailDiskonPoProrata = ?
|
||||
WHERE ReceiveOrderPoDetailID = ?";
|
||||
$que_save_diskon = $this->db->query($sql_save_diskon, [
|
||||
$diskon_prorata_item,
|
||||
$detail['ReceiveOrderPoDetailID']
|
||||
@@ -1898,9 +1898,9 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
// update stock based on batch
|
||||
foreach ($batch_list as $key => $batch) {
|
||||
$sql_cek_stock = "SELECT *
|
||||
FROM stock s
|
||||
JOIN m_item i ON s.StockItemID = i.M_ItemID
|
||||
WHERE s.StockItemID = ?
|
||||
FROM stock s
|
||||
JOIN m_item i ON s.StockItemID = i.M_ItemID
|
||||
WHERE s.StockItemID = ?
|
||||
AND s.StockItemUnitID = ?
|
||||
AND s.StockWarehouseID = ?
|
||||
AND i.M_ItemItem_CategoryID = ?";
|
||||
@@ -1946,18 +1946,18 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
}
|
||||
|
||||
// insert stockid barcode barang
|
||||
$sql_update_barcode = "UPDATE t_barcode_barang SET
|
||||
T_BarcodeBarangStockID = ?
|
||||
WHERE T_BarcodeBarangReceiveOrderPoDetailID = ?";
|
||||
$qry_update_barcode = $this->db->query($sql_update_barcode, [
|
||||
$stock_ID,
|
||||
$detail['ReceiveOrderPoDetailID']
|
||||
]);
|
||||
if (!$qry_update_barcode) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] update barcode stockID", $this->db);
|
||||
exit;
|
||||
}
|
||||
// $sql_update_barcode = "UPDATE t_barcode_barang SET
|
||||
// T_BarcodeBarangStockID = ?
|
||||
// WHERE T_BarcodeBarangReceiveOrderPoDetailID = ?";
|
||||
// $qry_update_barcode = $this->db->query($sql_update_barcode, [
|
||||
// $stock_ID,
|
||||
// $detail['ReceiveOrderPoDetailID']
|
||||
// ]);
|
||||
// if (!$qry_update_barcode) {
|
||||
// $this->db->trans_rollback();
|
||||
// $this->sys_error_db("[Error] update barcode stockID", $this->db);
|
||||
// exit;
|
||||
// }
|
||||
} else {
|
||||
$sql_insert_stock = "INSERT INTO stock (
|
||||
StockWarehouseAlmariID,
|
||||
@@ -1990,18 +1990,18 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
$stock_qty_end = intval($batch['qty']);
|
||||
|
||||
// insert stockid barcode barang
|
||||
$sql_update_barcode = "UPDATE t_barcode_barang SET
|
||||
T_BarcodeBarangStockID = ?
|
||||
WHERE T_BarcodeBarangReceiveOrderPoDetailID = ?";
|
||||
$qry_update_barcode = $this->db->query($sql_update_barcode, [
|
||||
$stockID,
|
||||
$detail['ReceiveOrderPoDetailID']
|
||||
]);
|
||||
if (!$qry_update_barcode) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] update barcode stockID", $this->db);
|
||||
exit;
|
||||
}
|
||||
// $sql_update_barcode = "UPDATE t_barcode_barang SET
|
||||
// T_BarcodeBarangStockID = ?
|
||||
// WHERE T_BarcodeBarangReceiveOrderPoDetailID = ?";
|
||||
// $qry_update_barcode = $this->db->query($sql_update_barcode, [
|
||||
// $stockID,
|
||||
// $detail['ReceiveOrderPoDetailID']
|
||||
// ]);
|
||||
// if (!$qry_update_barcode) {
|
||||
// $this->db->trans_rollback();
|
||||
// $this->sys_error_db("[Error] update barcode stockID", $this->db);
|
||||
// exit;
|
||||
// }
|
||||
}
|
||||
|
||||
// insert stock card
|
||||
@@ -2095,14 +2095,14 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
// insert jurnal tx for GRNI
|
||||
$total_grni = round($total_debet - ($total_discount_item + $total_discount_po), 2) + $ship_cost;
|
||||
$sql_grni = "INSERT INTO jurnal_tx (
|
||||
jurnalTxJurnalID,
|
||||
jurnalTxCoaID,
|
||||
jurnalTxDescription,
|
||||
jurnalTxDebit,
|
||||
jurnalTxCredit,
|
||||
jurnalTxM_UserID
|
||||
) SELECT ?, coaID, coaDescription, 0, ?, ?
|
||||
FROM coa WHERE coaAccountNo = '2110100030' LIMIT 1";
|
||||
jurnalTxJurnalID,
|
||||
jurnalTxCoaID,
|
||||
jurnalTxDescription,
|
||||
jurnalTxDebit,
|
||||
jurnalTxCredit,
|
||||
jurnalTxM_UserID
|
||||
) SELECT ?, coaID, coaDescription, 0, ?, ?
|
||||
FROM coa WHERE coaAccountNo = '2110100030' LIMIT 1";
|
||||
$que_grni = $this->db->query($sql_grni, [$jurnal_ID, $total_grni, $user['M_UserID']]);
|
||||
if (!$que_grni) {
|
||||
$this->db->trans_rollback();
|
||||
@@ -2112,13 +2112,13 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
$grni_jurnal_id = $this->db->insert_id();
|
||||
|
||||
$sql_addon_grni = "INSERT INTO jurnal_addon (
|
||||
jurnalAddOnJurnalID,
|
||||
jurnalAddOnJurnalTxID,
|
||||
jurnalAddOnCode,
|
||||
jurnalAddOnValue,
|
||||
jurnalAddOnCreated,
|
||||
jurnalAddOnCreatedUserID
|
||||
) VALUES (?,?,'RONUMB',?,NOW(),?)";
|
||||
jurnalAddOnJurnalID,
|
||||
jurnalAddOnJurnalTxID,
|
||||
jurnalAddOnCode,
|
||||
jurnalAddOnValue,
|
||||
jurnalAddOnCreated,
|
||||
jurnalAddOnCreatedUserID
|
||||
) VALUES (?,?,'RONUMB',?,NOW(),?)";
|
||||
$que_addon_grni = $this->db->query($sql_addon_grni, [
|
||||
$jurnal_ID,
|
||||
$grni_jurnal_id,
|
||||
@@ -2344,22 +2344,22 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
$this->db->trans_begin();
|
||||
|
||||
$sql_insert = "INSERT INTO receive_order_po_inspeksi (
|
||||
ReceiveOrderPoInspeksiReceiveOrderPoDetailID,
|
||||
ReceiveOrderPoInspeksiQtyPesan,
|
||||
ReceiveOrderPoInspeksiQtyActual,
|
||||
ReceiveOrderPoInspeksiPricePesan,
|
||||
ReceiveOrderPoInspeksiPriceActual,
|
||||
ReceiveOrderPoInspeksiDatePesan,
|
||||
ReceiveOrderPoInspeksiDateActual,
|
||||
ReceiveOrderPoInspeksiExpireDate,
|
||||
ReceiveOrderPoInspeksiKeadaanKemasan,
|
||||
ReceiveOrderPoInspeksiKondisiPengiriman,
|
||||
ReceiveOrderPoInspeksiSimpulan,
|
||||
ReceiveOrderPoInspeksiCatatan,
|
||||
ReceiveOrderPoInspeksiStaffPenerima,
|
||||
ReceiveOrderPoInspeksiStaffPengirim,
|
||||
ReceiveOrderPoInspeksiUserID
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
ReceiveOrderPoInspeksiReceiveOrderPoDetailID,
|
||||
ReceiveOrderPoInspeksiQtyPesan,
|
||||
ReceiveOrderPoInspeksiQtyActual,
|
||||
ReceiveOrderPoInspeksiPricePesan,
|
||||
ReceiveOrderPoInspeksiPriceActual,
|
||||
ReceiveOrderPoInspeksiDatePesan,
|
||||
ReceiveOrderPoInspeksiDateActual,
|
||||
ReceiveOrderPoInspeksiExpireDate,
|
||||
ReceiveOrderPoInspeksiKeadaanKemasan,
|
||||
ReceiveOrderPoInspeksiKondisiPengiriman,
|
||||
ReceiveOrderPoInspeksiSimpulan,
|
||||
ReceiveOrderPoInspeksiCatatan,
|
||||
ReceiveOrderPoInspeksiStaffPenerima,
|
||||
ReceiveOrderPoInspeksiStaffPengirim,
|
||||
ReceiveOrderPoInspeksiUserID
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
$que_insert = $this->db->query($sql_insert, [
|
||||
$ROdetailID,
|
||||
$inspeksi['qty_po'],
|
||||
@@ -2736,6 +2736,47 @@ class ReceiveItemPoInventaris extends MY_Controller
|
||||
|
||||
$barcodeID = $this->db->insert_id();
|
||||
|
||||
# check if item already in stock #
|
||||
$sql_cekstock = "SELECT StockID
|
||||
FROM stock
|
||||
JOIN warehouse ON WarehouseID = StockWarehouseID
|
||||
AND WarehouseIsActive = 'Y'
|
||||
WHERE WarehouseM_BranchID = ?
|
||||
AND StockItemID = ?
|
||||
AND StockItemUnitID = ?";
|
||||
$que_cekstock = $this->db->query($sql_cekstock, [
|
||||
$user['M_BranchID'],
|
||||
$item['ReceiveOrderPoItemID'],
|
||||
$item['ReceiveOrderPoItemUnitID'],
|
||||
]);
|
||||
if (!$que_cekstock) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] query cek stock");
|
||||
exit;
|
||||
}
|
||||
$stockID = $que_cekstock->row_array()['StockID'];
|
||||
|
||||
# insert stock inventaris #
|
||||
$sql_stockinventaris = "INSERT INTO stock_inventory (
|
||||
StockInventoryStockID,
|
||||
StockInventoryRuanganID,
|
||||
StockInventoryBarcode,
|
||||
StockInventoryBranchID,
|
||||
StockInventoryCreatedUserID
|
||||
) VALUES (?,?,?,?,?)";
|
||||
$que_stockinventaris = $this->db->query($sql_stockinventaris, [
|
||||
$stockID,
|
||||
$param['ruanganID'],
|
||||
$noBarcode,
|
||||
$user['M_BranchID'],
|
||||
$user['M_UserID']
|
||||
]);
|
||||
if (!$que_stockinventaris) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] insert into table stock inventaris");
|
||||
exit;
|
||||
}
|
||||
|
||||
# insert each inventory handover detail #
|
||||
$sql_insert_handover_detail = "INSERT INTO asset_handover_detail(
|
||||
AssetHandoverDetailAssetHandoverID,
|
||||
|
||||
54
scripts/deploy-controllers.sh
Executable file
54
scripts/deploy-controllers.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
REMOTE_HOST="accone.aplikasi.web.id"
|
||||
LOCAL_PATH="application/controllers/"
|
||||
REMOTE_PATH="/home/one/project/accone/one-api/application/controllers/"
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
if ! command -v rsync >/dev/null 2>&1; then
|
||||
echo "rsync is required but was not found in PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v ssh >/dev/null 2>&1; then
|
||||
echo "ssh is required but was not found in PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v awk >/dev/null 2>&1; then
|
||||
echo "awk is required but was not found in PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 <test|sync> [remote_user]" >&2
|
||||
echo "Examples:" >&2
|
||||
echo " $0 test" >&2
|
||||
echo " $0 sync" >&2
|
||||
echo " $0 test one" >&2
|
||||
}
|
||||
|
||||
COMMAND="${1:-}"
|
||||
REMOTE_USER="${2:-one}"
|
||||
REMOTE="${REMOTE_USER}@${REMOTE_HOST}"
|
||||
|
||||
case "$COMMAND" in
|
||||
test)
|
||||
echo "Checking SSH connection to ${REMOTE}..."
|
||||
ssh -o ConnectTimeout=10 "$REMOTE" "test -d '$REMOTE_PATH'"
|
||||
|
||||
echo
|
||||
echo "Files/folders that would be uploaded:"
|
||||
rsync -rzcin --out-format="%i %n%L" "$LOCAL_PATH" "${REMOTE}:${REMOTE_PATH}" \
|
||||
| awk '$1 ~ /^</ || $1 ~ /^cd/ { print }'
|
||||
;;
|
||||
sync)
|
||||
rsync -rzcv "$LOCAL_PATH" "${REMOTE}:${REMOTE_PATH}"
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user