add: getDaftarPoAset api

This commit is contained in:
2026-07-09 10:11:28 +07:00
parent dc88589c78
commit 834f23f26e
2 changed files with 97 additions and 0 deletions

View File

@@ -172,6 +172,20 @@ Content-Type: application/json
"ID": "" "ID": ""
} }
###
// listing po asset
POST https://{{host}}/mockup/purchase/order/PurchaseOrderAset/getDaftarPoAset/
Content-Type: application/json
{
"token": {{token}},
"search": "",
"currpage": 1,
"startdate": "2026-01-01",
"enddate": "2026-12-31",
"status": "All"
}
### ###
// create po asset // create po asset
POST https://{{host}}/mockup/purchase/order/PurchaseOrderAset/createPoAsset/ POST https://{{host}}/mockup/purchase/order/PurchaseOrderAset/createPoAsset/

View File

@@ -162,6 +162,89 @@ class PurchaseOrderAset extends MY_Controller {
} }
} }
public function getDaftarPoAset() {
try {
if (!$this->isLogin) {
$this->sys_error("invalid token");
exit;
}
$para = $this->sys_input;
$user = $this->sys_user;
$keyword = "%";
if ($para['search'] != '') {
$keyword .= $para['search'] . "%";
}
$sql_base = "SELECT
PurchaseOrderID,
PurchaseOrderDate,
PurchaseOrderNote,
PurchaseOrderNumber,
PurchaseOrderStatus,
PurchaseOrderRefNumber,
PurchaseOrderGrandTotal,
PurchaseOrderS_RegionalID,
PurchaseOrderApprovedManagerUserID AS verifiedby,
IFNULL(PurchaseOrderApprovedUserID, 0) AS approvedby,
PurchaseOrderAssetContractID,
PurchaseOrderAssetContractName AS contractName,
PurchaseOrderAssetContractStartDate AS contractStart,
PurchaseOrderAssetContractEndDate AS contractEnd,
SupplierID,
SupplierName
FROM purchase_order
JOIN supplier ON SupplierID = PurchaseOrderSupplierID
JOIN purchase_order_asset_contract
ON PurchaseOrderAssetContractPurchaseOrderID = PurchaseOrderID
WHERE PurchaseOrderIsActive = 'Y'
AND PurchaseOrderItemCategoryID = '3'
AND PurchaseOrderS_RegionalID = ?
AND PurchaseOrderDate BETWEEN DATE(?) AND DATE(?)
AND (PurchaseOrderStatus = ? OR 'All' = ?)
AND PurchaseOrderNumber LIKE ?";
$limit = 10;
$offset = 0;
if ($para['currpage'] > 0) {
$offset = ($para['currpage'] - 1) * $limit;
}
$sql_data = $sql_base . " LIMIT ? OFFSET ?";
$que_data = $this->db->query($sql_data, [
$user['S_RegionalID'], $para['startdate'], $para['enddate'],
$para['status'], $para['status'], $keyword, $limit, $offset
]);
if (!$que_data) {
$this->sys_error_db("[Error] failed get data listing PO asset");
exit;
}
$data_services = $que_data->result_array();
$sql_total = "SELECT COUNT(*) AS total FROM ($sql_base) AS x";
$que_total = $this->db->query($sql_total, [
$user['S_RegionalID'], $para['startdate'], $para['enddate'],
$para['status'], $para['status'], $keyword
]);
if (!$que_total) {
$this->sys_error_db("[Error] failed get total data listing PO asset");
exit;
}
$total_services = $que_total->row_array()['total'];
$output = [
"records" => $data_services,
"total" => $total_services
];
$this->sys_ok($output);
} catch (Exception $exc) {
$msg = $exc->getMessage();
$this->sys_error($msg);
}
}
## MUTATIONS ## ## MUTATIONS ##
public function createPoAsset() { public function createPoAsset() {
try { try {