add api file po asset, api receive item inventaris add insert into table stock_inventaris
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
<?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";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,11 +14,11 @@ class PurchaseOrderAset extends MY_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
## QUERY ##
|
## QUERY ##
|
||||||
public function getListSupplier() {
|
public function getListSupplier()
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
if (!$this->isLogin) {
|
if (!$this->isLogin) {
|
||||||
$this->sys_error("invalid token");
|
throw new Exception('Invalid token');
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
@@ -26,26 +28,31 @@ class PurchaseOrderAset extends MY_Controller {
|
|||||||
WHERE SupplierIsActive = 'Y'";
|
WHERE SupplierIsActive = 'Y'";
|
||||||
$que = $this->db->query($sql, []);
|
$que = $this->db->query($sql, []);
|
||||||
if (!$que) {
|
if (!$que) {
|
||||||
$this->sys_error_db("[Error] get data supplier");
|
throw new Exception('failed to query list supplier', 1);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $que->result_array();
|
$data = $que->result_array();
|
||||||
$this->sys_ok($data);
|
$this->sys_ok($data);
|
||||||
} catch (Exception $exc) {
|
} 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 {
|
try {
|
||||||
if (!$this->isLogin) {
|
if (!$this->isLogin) {
|
||||||
$this->sys_error("invalid token");
|
throw new Exception('Invalid token');
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->sys_user;
|
$user = $this->sys_user;
|
||||||
|
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
M_BranchID,
|
M_BranchID,
|
||||||
M_BranchCode,
|
M_BranchCode,
|
||||||
@@ -55,22 +62,28 @@ 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) {
|
||||||
$this->sys_error_db("[Error] failed get list cabang");
|
throw new Exception('failed to query list cabang', 1);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $que->result_array();
|
$data = $que->result_array();
|
||||||
|
|
||||||
$this->sys_ok($data);
|
$this->sys_ok($data);
|
||||||
} catch (Exception $exc) {
|
} 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 {
|
try {
|
||||||
if (!$this->isLogin) {
|
if (!$this->isLogin) {
|
||||||
$this->sys_error("invalid token");
|
throw new Exception('Invalid token');
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$para = $this->sys_input;
|
$para = $this->sys_input;
|
||||||
@@ -132,22 +145,25 @@ class PurchaseOrderAset extends MY_Controller {
|
|||||||
|
|
||||||
$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'], $keyword, $para['supplierID'],
|
$para['branchcode'],
|
||||||
$limit, $offset
|
$keyword,
|
||||||
|
$para['supplierID'],
|
||||||
|
$limit,
|
||||||
|
$offset
|
||||||
]);
|
]);
|
||||||
if (!$que_data) {
|
if (!$que_data) {
|
||||||
$this->sys_error_db("[Error] get daftar request data");
|
throw new Exception('failed to query data request order aset', 1);
|
||||||
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'], $keyword, $para['supplierID']
|
$para['branchcode'],
|
||||||
|
$keyword,
|
||||||
|
$para['supplierID']
|
||||||
]);
|
]);
|
||||||
if (!$que_total) {
|
if (!$que_total) {
|
||||||
$this->sys_error_db("[Error] get total request aset");
|
throw new Exception('failed to query total request order aset', 1);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$total = $que_total->row_array()['total'];
|
$total = $que_total->row_array()['total'];
|
||||||
|
|
||||||
@@ -158,29 +174,64 @@ class PurchaseOrderAset extends MY_Controller {
|
|||||||
|
|
||||||
$this->sys_ok($out);
|
$this->sys_ok($out);
|
||||||
} catch (Exception $exc) {
|
} 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 {
|
try {
|
||||||
if (!$this->isLogin) {
|
if (!$this->isLogin) {
|
||||||
$this->sys_error("invalid token");
|
throw new Exception('Invalid token');
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->sys_user;
|
$user = $this->sys_user;
|
||||||
$sql = "SELECT M_UserM_ApproveLevelID FROM m_user
|
$sql = "SELECT M_UserM_ApproveLevelID
|
||||||
WHERE M_UserIsActive = 'Y' AND M_UserID = ? ";
|
FROM m_user
|
||||||
|
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) {
|
||||||
$this->sys_error_db("[Error] failed get approval level user");
|
throw new Exception('failed to query approval level', 1);
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
$data = $que->row_array();
|
$data = $que->row_array();
|
||||||
|
|
||||||
$this->sys_ok($data);
|
$this->sys_ok($data);
|
||||||
} catch (Exception $exc) {
|
} 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1946,18 +1946,18 @@ class ReceiveItemPoInventaris extends MY_Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
// insert stockid barcode barang
|
// insert stockid barcode barang
|
||||||
$sql_update_barcode = "UPDATE t_barcode_barang SET
|
// $sql_update_barcode = "UPDATE t_barcode_barang SET
|
||||||
T_BarcodeBarangStockID = ?
|
// T_BarcodeBarangStockID = ?
|
||||||
WHERE T_BarcodeBarangReceiveOrderPoDetailID = ?";
|
// WHERE T_BarcodeBarangReceiveOrderPoDetailID = ?";
|
||||||
$qry_update_barcode = $this->db->query($sql_update_barcode, [
|
// $qry_update_barcode = $this->db->query($sql_update_barcode, [
|
||||||
$stock_ID,
|
// $stock_ID,
|
||||||
$detail['ReceiveOrderPoDetailID']
|
// $detail['ReceiveOrderPoDetailID']
|
||||||
]);
|
// ]);
|
||||||
if (!$qry_update_barcode) {
|
// if (!$qry_update_barcode) {
|
||||||
$this->db->trans_rollback();
|
// $this->db->trans_rollback();
|
||||||
$this->sys_error_db("[Error] update barcode stockID", $this->db);
|
// $this->sys_error_db("[Error] update barcode stockID", $this->db);
|
||||||
exit;
|
// exit;
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
$sql_insert_stock = "INSERT INTO stock (
|
$sql_insert_stock = "INSERT INTO stock (
|
||||||
StockWarehouseAlmariID,
|
StockWarehouseAlmariID,
|
||||||
@@ -1990,18 +1990,18 @@ class ReceiveItemPoInventaris extends MY_Controller
|
|||||||
$stock_qty_end = intval($batch['qty']);
|
$stock_qty_end = intval($batch['qty']);
|
||||||
|
|
||||||
// insert stockid barcode barang
|
// insert stockid barcode barang
|
||||||
$sql_update_barcode = "UPDATE t_barcode_barang SET
|
// $sql_update_barcode = "UPDATE t_barcode_barang SET
|
||||||
T_BarcodeBarangStockID = ?
|
// T_BarcodeBarangStockID = ?
|
||||||
WHERE T_BarcodeBarangReceiveOrderPoDetailID = ?";
|
// WHERE T_BarcodeBarangReceiveOrderPoDetailID = ?";
|
||||||
$qry_update_barcode = $this->db->query($sql_update_barcode, [
|
// $qry_update_barcode = $this->db->query($sql_update_barcode, [
|
||||||
$stockID,
|
// $stockID,
|
||||||
$detail['ReceiveOrderPoDetailID']
|
// $detail['ReceiveOrderPoDetailID']
|
||||||
]);
|
// ]);
|
||||||
if (!$qry_update_barcode) {
|
// if (!$qry_update_barcode) {
|
||||||
$this->db->trans_rollback();
|
// $this->db->trans_rollback();
|
||||||
$this->sys_error_db("[Error] update barcode stockID", $this->db);
|
// $this->sys_error_db("[Error] update barcode stockID", $this->db);
|
||||||
exit;
|
// exit;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert stock card
|
// insert stock card
|
||||||
@@ -2736,6 +2736,16 @@ class ReceiveItemPoInventaris extends MY_Controller
|
|||||||
|
|
||||||
$barcodeID = $this->db->insert_id();
|
$barcodeID = $this->db->insert_id();
|
||||||
|
|
||||||
|
# insert stock inventaris #
|
||||||
|
$sql_stockinventaris = "INSERT INTO stock_inventaris (
|
||||||
|
StockInventoryStockID,
|
||||||
|
StockInventoryRuanganID,
|
||||||
|
StockInventoryBarcode,
|
||||||
|
StockInventoryCabangID,
|
||||||
|
StockInventoryCreatedUserID
|
||||||
|
) VALUES (?,?,?,?,?)";
|
||||||
|
$que_stockinventaris = $this->db->query($sql_stockinventaris, []);
|
||||||
|
|
||||||
# insert each inventory handover detail #
|
# insert each inventory handover detail #
|
||||||
$sql_insert_handover_detail = "INSERT INTO asset_handover_detail(
|
$sql_insert_handover_detail = "INSERT INTO asset_handover_detail(
|
||||||
AssetHandoverDetailAssetHandoverID,
|
AssetHandoverDetailAssetHandoverID,
|
||||||
|
|||||||
Reference in New Issue
Block a user