Compare commits
12 Commits
po-asset-c
...
c125289b92
| Author | SHA1 | Date | |
|---|---|---|---|
| c125289b92 | |||
| fe5e6dd6cb | |||
| 5fd6db863a | |||
| fc9947bce4 | |||
| c296d5598b | |||
| 5bd8e038fc | |||
| 8f07a65485 | |||
| b7a00bc242 | |||
| 13af691645 | |||
| 775a390bcb | |||
| 0d1dcb1b5e | |||
| 22719de06f |
@@ -236,17 +236,6 @@ Content-Type: application/json
|
||||
"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
|
||||
POST https://{{host}}/mockup/purchase/order/PurchaseOrderAset/getDataKontrakPoAset/
|
||||
|
||||
@@ -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,11 +14,11 @@ 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
|
||||
@@ -26,26 +28,31 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
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;
|
||||
@@ -132,22 +145,25 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
|
||||
$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,7 +174,14 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1102,91 +1125,33 @@ 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() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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