Compare commits
23 Commits
po-asset-c
...
e62ec1d994
| Author | SHA1 | Date | |
|---|---|---|---|
| e62ec1d994 | |||
| 34fb944e6e | |||
| 17445d9534 | |||
| 17423ac0b5 | |||
| c83c42698a | |||
| 009aff7d44 | |||
| 6dbe0e400b | |||
| 0ea56f09fa | |||
| a6412c9688 | |||
| bcb553ea56 | |||
| 2874fab71d | |||
| c125289b92 | |||
| fe5e6dd6cb | |||
| 5fd6db863a | |||
| fc9947bce4 | |||
| c296d5598b | |||
| 5bd8e038fc | |||
| 8f07a65485 | |||
| b7a00bc242 | |||
| 13af691645 | |||
| 775a390bcb | |||
| 0d1dcb1b5e | |||
| 22719de06f |
113
application/controllers/map/InventarisCoaMapping.http
Normal file
113
application/controllers/map/InventarisCoaMapping.http
Normal file
@@ -0,0 +1,113 @@
|
||||
@token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJNX1VzZXJJRCI6IjM4MCIsIk1fVXNlclVzZXJuYW1lIjoicmVnc2J5IiwiTV9Vc2VyR3JvdXBEYXNoYm9hcmQiOiJvbmUtdWlcL3Rlc3RcL3Z1ZXhcL2FjYy1vbmUtanVybmFsXC8iLCJNX1VzZXJEZWZhdWx0VF9TYW1wbGVTdGF0aW9uSUQiOiIwIiwiTV9TdGFmZk5hbWUiOiJTdGFmZiBSZWdpb25hbCIsImlzX2NvdXJpZXIiOiJOIiwidGltZV9hdXRvbG9nb3V0IjoiMTIwIiwiTV9Vc2VyTG9jYXRpb25JRCI6IjM3IiwiTV9Vc2VyTG9jYXRpb25GbGFnIjoiUiIsIlNfUmVnaW9uYWxOYW1lIjoiU3VyYWJheWEgUmF5YSIsIlNfUmVnaW9uYWxJRCI6IjYiLCJNX0JyYW5jaE5hbWUiOiIiLCJNX0JyYW5jaENvZGUiOiIiLCJNX0JyYW5jaElEIjoiMCIsImxvZ2luTGV2ZWwiOiJyZWdpb25hbCIsIk1fQnJhbmNoQ29tcGFueUlEIjoiMSIsIk1fQnJhbmNoQ29tcGFueU5hbWUiOiJQVCBQUkFNSVRBIiwiaXAiOiIxMzkuMTk1LjEyMi4yMzUiLCJhZ2VudCI6Ik1vemlsbGFcLzUuMCAoWDExOyBMaW51eCB4ODZfNjQ7IHJ2OjEzNy4wKSBHZWNrb1wvMjAxMDAxMDEgRmlyZWZveFwvMTM3LjAiLCJ2ZXJzaW9uIjoidjIiLCJsYXN0LWxvZ2luIjoiMjAyNS0wNi0wNCAxMzoyMDowNSIsIk1fU2F0ZWxsaXRlSUQiOjB9.hm6JtstjaQOzb7oDSXQ-oMWuX_jFQZH-HDr3r3OzPac"
|
||||
|
||||
@host = accone.aplikasi.web.id/one-api
|
||||
|
||||
###
|
||||
// create inventaris coa mapping
|
||||
POST https://{{host}}/map/InventarisCoaMapping/createInvCoaMapping/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"token": {{token}},
|
||||
"M_InventarisGolID": 1,
|
||||
"CoaInventarisID": 101,
|
||||
"CoaHutangID": 102,
|
||||
"CoaPembelianID": 103,
|
||||
"CoaBebanPenyusutanID": 104,
|
||||
"CoaAkumulasiPenyusutanID": 105,
|
||||
"CoaLabaPelepasanID": 106,
|
||||
"CoaRugiPelepasanID": 107
|
||||
}
|
||||
|
||||
###
|
||||
// get inventaris coa mapping by ID
|
||||
POST https://{{host}}/map/InventarisCoaMapping/getInvCoaMapping/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"token": {{token}},
|
||||
"M_InventarisCoaMappingID": 1
|
||||
}
|
||||
|
||||
###
|
||||
// edit inventaris coa mapping
|
||||
POST https://{{host}}/map/InventarisCoaMapping/editInvCoaMapping/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"token": {{token}},
|
||||
"M_InventarisCoaMappingID": 1,
|
||||
"M_InventarisGolID": 2,
|
||||
"CoaInventarisID": 201,
|
||||
"CoaHutangID": 202,
|
||||
"CoaPembelianID": 203,
|
||||
"CoaBebanPenyusutanID": 204,
|
||||
"CoaAkumulasiPenyusutanID": 205,
|
||||
"CoaLabaPelepasanID": 206,
|
||||
"CoaRugiPelepasanID": 207
|
||||
}
|
||||
|
||||
###
|
||||
// delete inventaris coa mapping
|
||||
POST https://{{host}}/map/InventarisCoaMapping/deleteInvCoaMapping/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"token": {{token}},
|
||||
"M_InventarisCoaMappingID": 1
|
||||
}
|
||||
|
||||
###
|
||||
// create inventaris item coa mapping
|
||||
POST https://{{host}}/map/InventarisCoaMapping/createInvItemCoaMapping/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"token": {{token}},
|
||||
"M_ItemID": 10,
|
||||
"CoaInventarisID": 201,
|
||||
"CoaHutangID": 202,
|
||||
"CoaPembelianID": 203,
|
||||
"CoaBebanPenyusutanID": 204,
|
||||
"CoaAkumulasiPenyusutanID": 205,
|
||||
"CoaLabaPelepasanID": 206,
|
||||
"CoaRugiPelepasanID": 207
|
||||
}
|
||||
|
||||
###
|
||||
// get inventaris item coa mapping by ID
|
||||
POST https://{{host}}/map/InventarisCoaMapping/getInvItemCoaMapping/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"token": {{token}},
|
||||
"M_InventarisItemCoaMappingID": 1
|
||||
}
|
||||
|
||||
###
|
||||
// edit inventaris item coa mapping
|
||||
POST https://{{host}}/map/InventarisCoaMapping/editInvItemCoaMapping/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"token": {{token}},
|
||||
"M_InventarisItemCoaMappingID": 1,
|
||||
"M_ItemID": 11,
|
||||
"CoaInventarisID": 301,
|
||||
"CoaHutangID": 302,
|
||||
"CoaPembelianID": 303,
|
||||
"CoaBebanPenyusutanID": 304,
|
||||
"CoaAkumulasiPenyusutanID": 305,
|
||||
"CoaLabaPelepasanID": 306,
|
||||
"CoaRugiPelepasanID": 307
|
||||
}
|
||||
|
||||
###
|
||||
// delete inventaris item coa mapping
|
||||
POST https://{{host}}/map/InventarisCoaMapping/deleteInvItemCoaMapping/
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"token": {{token}},
|
||||
"M_InventarisItemCoaMappingID": 1
|
||||
}
|
||||
361
application/controllers/map/InventarisCoaMapping.php
Normal file
361
application/controllers/map/InventarisCoaMapping.php
Normal file
@@ -0,0 +1,361 @@
|
||||
<?php
|
||||
|
||||
class InventarisCoaMapping extends MY_Controller {
|
||||
var $db;
|
||||
public function index() {
|
||||
echo "Inventaris COA Mapping API";
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
## MUTATIONS ##
|
||||
public function createInvCoaMapping() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$para = $this->sys_input;
|
||||
$user = $this->sys_user;
|
||||
|
||||
$sql = "INSERT INTO m_inventaris_coa_mapping (
|
||||
M_InventarisCoaMappingM_InventarisGolID,
|
||||
M_InventarisCoaMappingCoaInventarisID,
|
||||
M_InventarisCoaMappingCoaHutangID,
|
||||
M_InventarisCoaMappingCoaPembelianID,
|
||||
M_InventarisCoaMappingCoaBebanPenyusutanID,
|
||||
M_InventarisCoaMappingCoaAkumulasiPenyusutanID,
|
||||
M_InventarisCoaMappingCoaLabaPelepasanID,
|
||||
M_InventarisCoaMappingCoaRugiPelepasanID,
|
||||
M_InventarisCoaMappingCreatedUserID,
|
||||
M_InventarisCoaMappingCreated,
|
||||
M_InventarisCoaMappingLastUpdated
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,NOW(),NOW())";
|
||||
$query = $this->db->query($sql, [
|
||||
$para['M_InventarisGolID'],
|
||||
$para['CoaInventarisID'],
|
||||
$para['CoaHutangID'],
|
||||
$para['CoaPembelianID'],
|
||||
$para['CoaBebanPenyusutanID'],
|
||||
$para['CoaAkumulasiPenyusutanID'],
|
||||
$para['CoaLabaPelepasanID'],
|
||||
$para['CoaRugiPelepasanID'],
|
||||
$user['M_UserID']
|
||||
]);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] insert into table m_inventaris_coa_mapping");
|
||||
exit;
|
||||
}
|
||||
|
||||
$insertID = $this->db->insert_id();
|
||||
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok($insertID);
|
||||
} catch (Exception $exc) {
|
||||
$msg = $exc->getMessage();
|
||||
$this->sys_error($msg);
|
||||
}
|
||||
}
|
||||
|
||||
## QUERY ##
|
||||
public function getInvCoaMapping() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$para = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
M_InventarisCoaMappingID,
|
||||
M_InventarisCoaMappingM_InventarisGolID,
|
||||
M_InventarisCoaMappingCoaInventarisID,
|
||||
M_InventarisCoaMappingCoaHutangID,
|
||||
M_InventarisCoaMappingCoaPembelianID,
|
||||
M_InventarisCoaMappingCoaBebanPenyusutanID,
|
||||
M_InventarisCoaMappingCoaAkumulasiPenyusutanID,
|
||||
M_InventarisCoaMappingCoaLabaPelepasanID,
|
||||
M_InventarisCoaMappingCoaRugiPelepasanID,
|
||||
M_InventarisCoaMappingCreatedUserID,
|
||||
M_InventarisCoaMappingCreated,
|
||||
M_InventarisCoaMappingLastUpdated
|
||||
FROM m_inventaris_coa_mapping
|
||||
WHERE M_InventarisCoaMappingIsActive = 'Y'
|
||||
AND M_InventarisCoaMappingID = ?";
|
||||
$query = $this->db->query($sql, [$para['M_InventarisCoaMappingID']]);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("[Error] get data m_inventaris_coa_mapping");
|
||||
exit;
|
||||
}
|
||||
$data = $query->row_array();
|
||||
|
||||
$this->sys_ok($data);
|
||||
} catch (Exception $exc) {
|
||||
$msg = $exc->getMessage();
|
||||
$this->sys_error($msg);
|
||||
}
|
||||
}
|
||||
|
||||
## MUTATIONS ##
|
||||
public function editInvCoaMapping() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$para = $this->sys_input;
|
||||
$user = $this->sys_user;
|
||||
|
||||
$sql = "UPDATE m_inventaris_coa_mapping SET
|
||||
M_InventarisCoaMappingM_InventarisGolID = ?,
|
||||
M_InventarisCoaMappingCoaInventarisID = ?,
|
||||
M_InventarisCoaMappingCoaHutangID = ?,
|
||||
M_InventarisCoaMappingCoaPembelianID = ?,
|
||||
M_InventarisCoaMappingCoaBebanPenyusutanID = ?,
|
||||
M_InventarisCoaMappingCoaAkumulasiPenyusutanID = ?,
|
||||
M_InventarisCoaMappingCoaLabaPelepasanID = ?,
|
||||
M_InventarisCoaMappingCoaRugiPelepasanID = ?,
|
||||
M_InventarisCoaMappingLastUpdated = NOW()
|
||||
WHERE M_InventarisCoaMappingIsActive = 'Y'
|
||||
AND M_InventarisCoaMappingID = ?";
|
||||
$query = $this->db->query($sql, [
|
||||
$para['M_InventarisGolID'],
|
||||
$para['CoaInventarisID'],
|
||||
$para['CoaHutangID'],
|
||||
$para['CoaPembelianID'],
|
||||
$para['CoaBebanPenyusutanID'],
|
||||
$para['CoaAkumulasiPenyusutanID'],
|
||||
$para['CoaLabaPelepasanID'],
|
||||
$para['CoaRugiPelepasanID'],
|
||||
$para['M_InventarisCoaMappingID']
|
||||
]);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] update table m_inventaris_coa_mapping");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("[Success] update data inventaris coa mapping");
|
||||
} catch (Exception $exc) {
|
||||
$msg = $exc->getMessage();
|
||||
$this->sys_error($msg);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteInvCoaMapping() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$para = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE m_inventaris_coa_mapping SET
|
||||
M_InventarisCoaMappingIsActive = 'N',
|
||||
M_InventarisCoaMappingLastUpdated = NOW()
|
||||
WHERE M_InventarisCoaMappingIsActive = 'Y'
|
||||
AND M_InventarisCoaMappingID = ?";
|
||||
$query = $this->db->query($sql, [$para['M_InventarisCoaMappingID']]);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] soft delete data m_inventaris_coa_mapping");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("[Success] delete data inventaris coa mapping");
|
||||
} catch (Exception $exc) {
|
||||
$msg = $exc->getMessage();
|
||||
$this->sys_error($msg);
|
||||
}
|
||||
}
|
||||
|
||||
## MUTATIONS ITEM ##
|
||||
public function createInvItemCoaMapping() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$para = $this->sys_input;
|
||||
$user = $this->sys_user;
|
||||
|
||||
$sql = "INSERT INTO m_inventaris_item_coa_mapping (
|
||||
M_InventarisItemCoaMappingM_ItemID,
|
||||
M_InventarisItemCoaMappingCoaInventarisID,
|
||||
M_InventarisItemCoaMappingCoaHutangID,
|
||||
M_InventarisItemCoaMappingCoaPembelianID,
|
||||
M_InventarisItemCoaMappingCoaBebanPenyusutanID,
|
||||
M_InventarisItemCoaMappingCoaAkumulasiPenyusutanID,
|
||||
M_InventarisItemCoaMappingCoaLabaPelepasanID,
|
||||
M_InventarisItemCoaMappingCoaRugiPelepasanID,
|
||||
M_InventarisItemCoaMappingCreatedUserID,
|
||||
M_InventarisItemCoaMappingCreated,
|
||||
M_InventarisItemCoaMappingLastUpdated
|
||||
) VALUES (?,?,?,?,?,?,?,?,?,NOW(),NOW())";
|
||||
$query = $this->db->query($sql, [
|
||||
$para['M_ItemID'],
|
||||
$para['CoaInventarisID'],
|
||||
$para['CoaHutangID'],
|
||||
$para['CoaPembelianID'],
|
||||
$para['CoaBebanPenyusutanID'],
|
||||
$para['CoaAkumulasiPenyusutanID'],
|
||||
$para['CoaLabaPelepasanID'],
|
||||
$para['CoaRugiPelepasanID'],
|
||||
$user['M_UserID']
|
||||
]);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] insert into table m_inventaris_item_coa_mapping");
|
||||
exit;
|
||||
}
|
||||
|
||||
$insertID = $this->db->insert_id();
|
||||
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok($insertID);
|
||||
} catch (Exception $exc) {
|
||||
$msg = $exc->getMessage();
|
||||
$this->sys_error($msg);
|
||||
}
|
||||
}
|
||||
|
||||
## QUERY ITEM ##
|
||||
public function getInvItemCoaMapping() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$para = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
M_InventarisItemCoaMappingID,
|
||||
M_InventarisItemCoaMappingM_ItemID,
|
||||
M_InventarisItemCoaMappingCoaInventarisID,
|
||||
M_InventarisItemCoaMappingCoaHutangID,
|
||||
M_InventarisItemCoaMappingCoaPembelianID,
|
||||
M_InventarisItemCoaMappingCoaBebanPenyusutanID,
|
||||
M_InventarisItemCoaMappingCoaAkumulasiPenyusutanID,
|
||||
M_InventarisItemCoaMappingCoaLabaPelepasanID,
|
||||
M_InventarisItemCoaMappingCoaRugiPelepasanID,
|
||||
M_InventarisItemCoaMappingCreatedUserID,
|
||||
M_InventarisItemCoaMappingCreated,
|
||||
M_InventarisItemCoaMappingLastUpdated
|
||||
FROM m_inventaris_item_coa_mapping
|
||||
WHERE M_InventarisItemCoaMappingIsActive = 'Y'
|
||||
AND M_InventarisItemCoaMappingID = ?";
|
||||
$query = $this->db->query($sql, [$para['M_InventarisItemCoaMappingID']]);
|
||||
if (!$query) {
|
||||
$this->sys_error_db("[Error] get data m_inventaris_item_coa_mapping");
|
||||
exit;
|
||||
}
|
||||
$data = $query->row_array();
|
||||
|
||||
$this->sys_ok($data);
|
||||
} catch (Exception $exc) {
|
||||
$msg = $exc->getMessage();
|
||||
$this->sys_error($msg);
|
||||
}
|
||||
}
|
||||
|
||||
## MUTATIONS ITEM ##
|
||||
public function editInvItemCoaMapping() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$para = $this->sys_input;
|
||||
$user = $this->sys_user;
|
||||
|
||||
$sql = "UPDATE m_inventaris_item_coa_mapping SET
|
||||
M_InventarisItemCoaMappingM_ItemID = ?,
|
||||
M_InventarisItemCoaMappingCoaInventarisID = ?,
|
||||
M_InventarisItemCoaMappingCoaHutangID = ?,
|
||||
M_InventarisItemCoaMappingCoaPembelianID = ?,
|
||||
M_InventarisItemCoaMappingCoaBebanPenyusutanID = ?,
|
||||
M_InventarisItemCoaMappingCoaAkumulasiPenyusutanID = ?,
|
||||
M_InventarisItemCoaMappingCoaLabaPelepasanID = ?,
|
||||
M_InventarisItemCoaMappingCoaRugiPelepasanID = ?,
|
||||
M_InventarisItemCoaMappingLastUpdated = NOW()
|
||||
WHERE M_InventarisItemCoaMappingIsActive = 'Y'
|
||||
AND M_InventarisItemCoaMappingID = ?";
|
||||
$query = $this->db->query($sql, [
|
||||
$para['M_ItemID'],
|
||||
$para['CoaInventarisID'],
|
||||
$para['CoaHutangID'],
|
||||
$para['CoaPembelianID'],
|
||||
$para['CoaBebanPenyusutanID'],
|
||||
$para['CoaAkumulasiPenyusutanID'],
|
||||
$para['CoaLabaPelepasanID'],
|
||||
$para['CoaRugiPelepasanID'],
|
||||
$para['M_InventarisItemCoaMappingID']
|
||||
]);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] update table m_inventaris_item_coa_mapping");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("[Success] update data inventaris item coa mapping");
|
||||
} catch (Exception $exc) {
|
||||
$msg = $exc->getMessage();
|
||||
$this->sys_error($msg);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteInvItemCoaMapping() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
$para = $this->sys_input;
|
||||
|
||||
$sql = "UPDATE m_inventaris_item_coa_mapping SET
|
||||
M_InventarisItemCoaMappingIsActive = 'N',
|
||||
M_InventarisItemCoaMappingLastUpdated = NOW()
|
||||
WHERE M_InventarisItemCoaMappingIsActive = 'Y'
|
||||
AND M_InventarisItemCoaMappingID = ?";
|
||||
$query = $this->db->query($sql, [$para['M_InventarisItemCoaMappingID']]);
|
||||
if (!$query) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] soft delete data m_inventaris_item_coa_mapping");
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
$this->sys_ok("[Success] delete data inventaris item coa mapping");
|
||||
} catch (Exception $exc) {
|
||||
$msg = $exc->getMessage();
|
||||
$this->sys_error($msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$sql = "SELECT
|
||||
SupplierID,
|
||||
SupplierName
|
||||
FROM supplier
|
||||
FROM supplier
|
||||
WHERE SupplierIsActive = 'Y'";
|
||||
$que = $this->db->query($sql, []);
|
||||
if (!$que) {
|
||||
@@ -46,19 +46,19 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
|
||||
$user = $this->sys_user;
|
||||
|
||||
$sql = "SELECT
|
||||
$sql = "SELECT
|
||||
M_BranchID,
|
||||
M_BranchCode,
|
||||
M_BranchName
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y'
|
||||
FROM m_branch
|
||||
WHERE M_BranchIsActive = 'Y'
|
||||
AND M_BranchS_RegionalID = ?";
|
||||
$que = $this->db->query($sql, [$user['S_RegionalID']]);
|
||||
if (!$que) {
|
||||
$this->sys_error_db("[Error] failed get list cabang");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$data = $que->result_array();
|
||||
$this->sys_ok($data);
|
||||
} catch (Exception $exc) {
|
||||
@@ -74,66 +74,65 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
$para = $this->sys_input;
|
||||
|
||||
|
||||
$keyword = "%";
|
||||
if ($para['search'] != '') {
|
||||
$keyword .= $para['search'] . "%";
|
||||
}
|
||||
|
||||
$limit = 10;
|
||||
$offset = 0;
|
||||
if ($para['currpage'] > 0) {
|
||||
$offset = ($para['currpage'] - 1) * $limit;
|
||||
}
|
||||
|
||||
$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
|
||||
)";
|
||||
|
||||
$sql_data = $sql . " LIMIT ? OFFSET ? ";
|
||||
$sql = "SELECT
|
||||
PurchaseRequestID,
|
||||
PurchaseRequestNumber,
|
||||
PurchaseRequestDetailID,
|
||||
PurchaseRequestFlagID,
|
||||
M_BranchID,
|
||||
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,
|
||||
M_UserUsername AS Requestedby
|
||||
FROM purchase_request
|
||||
JOIN purchase_request_detail ON PurchaseRequestDetailPurchaseRequestID = PurchaseRequestID
|
||||
AND PurchaseRequestDetailIsActive = 'Y'
|
||||
AND PurchaseRequestItemCategoryID = '3' -- id category item asset
|
||||
JOIN m_item ON M_ItemID = PurchaseRequestDetailM_ItemID
|
||||
AND (PurchaseRequestNumber LIKE ? OR M_ItemDesc LIKE ?)
|
||||
JOIN purchase_request_flag ON PurchaseRequestFlagPurchaseRequestDetailID = PurchaseRequestDetailID
|
||||
AND PurchaseRequestFlagStatus = 'PO'
|
||||
AND PurchaseRequestFlagIsActive = 'Y'
|
||||
JOIN m_branch ON M_BranchCode = PurchaseRequestFlagM_BranchCode
|
||||
AND M_BranchID = ?
|
||||
AND M_BranchIsActive = 'Y'
|
||||
JOIN itemunit ON ItemUnitID = PurchaseRequestDetailItemUnitID
|
||||
JOIN supplier_price ON SupplierPriceSupplierID = ?
|
||||
AND SupplierPriceM_ItemID = M_ItemID
|
||||
AND SupplierPriceItemUnitID = ItemUnitID
|
||||
AND SupplierPriceIsActive = 'Y'
|
||||
JOIN m_user ON M_UserID = PurchaseRequestRequestedBy
|
||||
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 ? ";
|
||||
$que_data = $this->db->query($sql_data, [
|
||||
$para['branchcode'], $keyword, $para['supplierID'],
|
||||
$limit, $offset
|
||||
$keyword, $keyword, $para['branchID'], $para['supplierID'],
|
||||
$limit
|
||||
]);
|
||||
if (!$que_data) {
|
||||
$this->sys_error_db("[Error] get daftar request data");
|
||||
@@ -143,7 +142,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
|
||||
$sql_total = "SELECT COUNT(*) AS total FROM ($sql) AS x";
|
||||
$que_total = $this->db->query($sql_total, [
|
||||
$para['branchcode'], $keyword, $para['supplierID']
|
||||
$keyword, $keyword, $para['branchID'], $para['supplierID']
|
||||
]);
|
||||
if (!$que_total) {
|
||||
$this->sys_error_db("[Error] get total request aset");
|
||||
@@ -177,7 +176,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$keyword .= $para['search'] . "%";
|
||||
}
|
||||
|
||||
$sql_base = "SELECT
|
||||
$sql_base = "SELECT
|
||||
PurchaseOrderID,
|
||||
PurchaseOrderDate,
|
||||
PurchaseOrderNote,
|
||||
@@ -194,9 +193,9 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
PurchaseOrderAssetContractEndDate AS contractEnd,
|
||||
SupplierID,
|
||||
SupplierName
|
||||
FROM purchase_order
|
||||
FROM purchase_order
|
||||
JOIN supplier ON SupplierID = PurchaseOrderSupplierID
|
||||
JOIN purchase_order_asset_contract
|
||||
JOIN purchase_order_asset_contract
|
||||
ON PurchaseOrderAssetContractPurchaseOrderID = PurchaseOrderID
|
||||
WHERE PurchaseOrderIsActive = 'Y'
|
||||
AND PurchaseOrderItemCategoryID = '3'
|
||||
@@ -254,15 +253,14 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
|
||||
$para = $this->sys_input;
|
||||
|
||||
$sql = "SELECT
|
||||
PurchaseOrderAssetAttachmentID AS attach_id,
|
||||
PurchaseOrderAssetAttachmentName AS img_url,
|
||||
PurchaseOrderAssetAttachmentCreated AS created
|
||||
FROM purchase_order_asset_attachment
|
||||
WHERE PurchaseOrderAssetAttachmentIsActive = 'Y'
|
||||
AND PurchaseOrderAssetAttachmentContractID = ?
|
||||
AND PurchaseOrderAssetAttachmentPurchaseOrderID = ?
|
||||
AND PurchaseOrderAssetAttachmentType = 'order'";
|
||||
$sql = "SELECT
|
||||
ContractAssetAttachmentID AS attach_id,
|
||||
ContractAssetAttachmentFileName AS img_url,
|
||||
ContractAssetAttachmentDate AS created
|
||||
FROM contract_asset_attachment
|
||||
WHERE ContractAssetAttachmentIsActive = 'Y'
|
||||
AND ContractAssetAttachmentPurchaseOrderAssetContractID = ?
|
||||
AND ContractAssetAttachmentPurchaseOrderID = ?";
|
||||
$que = $this->db->query($sql, [
|
||||
$para['contractID'], $para['poID']
|
||||
]);
|
||||
@@ -321,7 +319,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$detail_asset = $que_detail->result_array();
|
||||
|
||||
# get data from purchase order summary #
|
||||
$sql_sumry = "SELECT
|
||||
$sql_sumry = "SELECT
|
||||
PurchaseOrderID,
|
||||
PurchaseOrderSummaryID,
|
||||
PurchaseOrderSummaryQty AS RequestQty,
|
||||
@@ -359,11 +357,11 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
PurchaseOrderStatus,
|
||||
PurchaseOrderRefNumber AS reference,
|
||||
PurchaseOrderGrandTotal AS grandtotal,
|
||||
CASE
|
||||
CASE
|
||||
WHEN PurchaseOrderTaxPpnType = 'P' THEN 'percent'
|
||||
ELSE 'absolute'
|
||||
END AS typepajak,
|
||||
CASE
|
||||
CASE
|
||||
WHEN PurchaseOrderTaxPpnType = 'P' THEN PurchaseOrderTaxPercentPpn
|
||||
ELSE PurchaseOrderTaxAmountPpn
|
||||
END AS valuepajak,
|
||||
@@ -392,9 +390,9 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
PurchaseOrderAssetContractInstallmentDownPaymentType AS installmentDownPaymentType,
|
||||
PurchaseOrderAssetContractInstallmentDownPayment AS installmentDownPayment,
|
||||
PurchaseOrderApprovedManagerUserID AS verifiedby
|
||||
FROM purchase_order
|
||||
FROM purchase_order
|
||||
JOIN supplier ON SupplierID = PurchaseOrderSupplierID
|
||||
JOIN purchase_order_asset_contract
|
||||
JOIN purchase_order_asset_contract
|
||||
ON PurchaseOrderAssetContractPurchaseOrderID = PurchaseOrderID
|
||||
WHERE PurchaseOrderIsActive = 'Y'
|
||||
AND PurchaseOrderID = ?";
|
||||
@@ -460,6 +458,28 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserApproveLevel() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$user = $this->sys_user;
|
||||
$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;
|
||||
}
|
||||
$data = $que->row_array();
|
||||
$this->sys_ok($data);
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
## MUTATIONS ##
|
||||
public function createPoAsset() {
|
||||
try {
|
||||
@@ -481,7 +501,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$areatype = 'R';
|
||||
}
|
||||
|
||||
$sqlusrdivisi = "SELECT M_UserDivisionDivisionID FROM m_userdivision
|
||||
$sqlusrdivisi = "SELECT M_UserDivisionDivisionID FROM m_userdivision
|
||||
WHERE M_UserDivisionM_UserID = ? AND M_UserDivisionIsActive = 'Y'";
|
||||
$queusrdivisi = $this->db->query($sqlusrdivisi, [$user['M_UserID']]);
|
||||
if (!$queusrdivisi) {
|
||||
@@ -630,8 +650,8 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
/* purchase request update flag */
|
||||
$sql_flag = "UPDATE purchase_request_flag SET
|
||||
PurchaseRequestFlagQtyProses = ?
|
||||
$sql_flag = "UPDATE purchase_request_flag SET
|
||||
PurchaseRequestFlagQtyProses = ?
|
||||
WHERE PurchaseRequestFlagID = ?";
|
||||
$que_flag = $this->db->query($sql_flag, [
|
||||
$obj['RequestQty'], $obj['PurchaseRequestFlagID']
|
||||
@@ -727,7 +747,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$summary_total = floatval($para['summary']['total']);
|
||||
|
||||
# update po header #
|
||||
$sql_po = "UPDATE purchase_order SET
|
||||
$sql_po = "UPDATE purchase_order SET
|
||||
PurchaseOrderDate = ?,
|
||||
PurchaseOrderRefNumber = ?,
|
||||
PurchaseOrderSupplierID = ?,
|
||||
@@ -741,7 +761,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
PurchaseOrderTaxAmountPpn = ?,
|
||||
PurchaseOrderGrandTotal = ?,
|
||||
PurchaseOrderLastUpdated = NOW()
|
||||
WHERE PurchaseOrderID = ?
|
||||
WHERE PurchaseOrderID = ?
|
||||
AND PurchaseOrderIsActive = 'Y'";
|
||||
$que_po = $this->db->query($sql_po, [
|
||||
$para['podate'], $para['reference'], $para['supplierID'], $user['S_RegionalID'],
|
||||
@@ -755,7 +775,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
# update purchase_order_asset_contract #
|
||||
$sql_contract = "UPDATE purchase_order_asset_contract SET
|
||||
$sql_contract = "UPDATE purchase_order_asset_contract SET
|
||||
PurchaseOrderAssetContractTAssetAttachmentID = ?,
|
||||
PurchaseOrderAssetContractName = ?,
|
||||
PurchaseOrderAssetContractDate = ?,
|
||||
@@ -768,7 +788,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
PurchaseOrderAssetContractInstallmentDownPaymentType = ?,
|
||||
PurchaseOrderAssetContractInstallmentDownPayment = ?,
|
||||
PurchaseOrderAssetContractLastUpdated = NOW()
|
||||
WHERE PurchaseOrderAssetContractID = ?
|
||||
WHERE PurchaseOrderAssetContractID = ?
|
||||
AND PurchaseOrderAssetContractIsActive = 'Y'";
|
||||
$que_contract = $this->db->query($sql_contract, [
|
||||
$para['assetAttachmentID'],
|
||||
@@ -791,9 +811,9 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
# update status old po summary isActive to 'N' #
|
||||
$sql_active = "UPDATE purchase_order_summary SET
|
||||
$sql_active = "UPDATE purchase_order_summary SET
|
||||
PurchaseOrderSummaryIsActive = 'N'
|
||||
WHERE PurchaseOrderSummaryPurchaseOrderID = ?
|
||||
WHERE PurchaseOrderSummaryPurchaseOrderID = ?
|
||||
AND PurchaseOrderSummaryIsActive = 'Y'";
|
||||
$que_active = $this->db->query($sql_active, [$para['PurchaseOrderID']]);
|
||||
if (!$que_active) {
|
||||
@@ -848,7 +868,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
# update status po detail isActive to 'N' #
|
||||
$sql_active = "UPDATE purchase_order_detail SET
|
||||
$sql_active = "UPDATE purchase_order_detail SET
|
||||
PurchaseOrderDetailIsActive = 'N'
|
||||
WHERE PurchaseOrderDetailPurchaseOrderID = ?
|
||||
AND PurchaseOrderDetailIsActive = 'Y'";
|
||||
@@ -892,7 +912,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
$sql_flag = "UPDATE purchase_request_flag SET
|
||||
PurchaseRequestFlagQtyProses = ?
|
||||
PurchaseRequestFlagQtyProses = ?
|
||||
WHERE PurchaseRequestFlagID = ?";
|
||||
$que_flag = $this->db->query($sql_flag, [
|
||||
$obj['RequestQty'], $obj['PurchaseRequestFlagID']
|
||||
@@ -927,11 +947,11 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$para = $this->sys_input;
|
||||
$user = $this->sys_user;
|
||||
|
||||
$sql_detail = "SELECT
|
||||
$sql_detail = "SELECT
|
||||
PurchaseOrderDetailPurchaseRequestFlagID,
|
||||
PurchaseOrderDetailQty
|
||||
FROM purchase_order_detail
|
||||
WHERE PurchaseOrderDetailPurchaseOrderID = ?
|
||||
FROM purchase_order_detail
|
||||
WHERE PurchaseOrderDetailPurchaseOrderID = ?
|
||||
AND PurchaseOrderDetailIsActive = 'Y'";
|
||||
$que_detail = $this->db->query($sql_detail, [$para['poID']]);
|
||||
if (!$que_detail) {
|
||||
@@ -958,10 +978,10 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
/* soft delete purchase order detail */
|
||||
$sql_deldetail = "UPDATE purchase_order_detail SET
|
||||
PurchaseOrderDetailIsActive = 'N',
|
||||
$sql_deldetail = "UPDATE purchase_order_detail SET
|
||||
PurchaseOrderDetailIsActive = 'N',
|
||||
PurchaseOrderDetailDeleted = NOW(),
|
||||
PurchaseOrderDetailDeletedUserID = ?
|
||||
PurchaseOrderDetailDeletedUserID = ?
|
||||
WHERE PurchaseOrderDetailPurchaseOrderID = ?";
|
||||
$que_deldetail = $this->db->query($sql_deldetail, [
|
||||
$user['M_UserID'], $para['poID']
|
||||
@@ -976,7 +996,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$sql_delsummary = "UPDATE purchase_order_summary SET
|
||||
PurchaseOrderSummaryIsActive = 'N',
|
||||
PurchaseOrderSummaryDeleted = NOW(),
|
||||
PurchaseOrderSummaryDeletedUserID = ?
|
||||
PurchaseOrderSummaryDeletedUserID = ?
|
||||
WHERE PurchaseOrderSummaryPurchaseOrderID = ?";
|
||||
$que_delsummary = $this->db->query($sql_delsummary, [
|
||||
$user['M_UserID'], $para['poID']
|
||||
@@ -988,10 +1008,10 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
/* soft delete purchase_order_asset_contract */
|
||||
$sql_delcontract = "UPDATE purchase_order_asset_contract SET
|
||||
$sql_delcontract = "UPDATE purchase_order_asset_contract SET
|
||||
PurchaseOrderAssetContractIsActive = 'N',
|
||||
PurchaseOrderAssetContractLastUpdated = NOW()
|
||||
WHERE PurchaseOrderAssetContractID = ?
|
||||
WHERE PurchaseOrderAssetContractID = ?
|
||||
AND PurchaseOrderAssetContractPurchaseOrderID = ?";
|
||||
$que_delcontract = $this->db->query($sql_delcontract, [
|
||||
$para['contractID'], $para['poID']
|
||||
@@ -1003,10 +1023,10 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
|
||||
/* soft delete purchase order */
|
||||
$sql_delorder = "UPDATE purchase_order SET
|
||||
$sql_delorder = "UPDATE purchase_order SET
|
||||
PurchaseOrderIsActive = 'N',
|
||||
PurchaseOrderDeleted = NOW(),
|
||||
PurchaseOrderDeletedUserID = ?
|
||||
PurchaseOrderDeletedUserID = ?
|
||||
WHERE PurchaseOrderID = ?";
|
||||
$que_delorder = $this->db->query($sql_delorder, [
|
||||
$user['M_UserID'], $para['poID']
|
||||
@@ -1028,7 +1048,6 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// upload file
|
||||
public function uploadAttachment() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
@@ -1071,19 +1090,18 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$upload_data = $this->upload->data();
|
||||
$filename = $upload_data['file_name'];
|
||||
|
||||
$sql_insert = "INSERT INTO purchase_order_asset_attachment (
|
||||
PurchaseOrderAssetAttachmentContractID,
|
||||
PurchaseOrderAssetAttachmentPurchaseOrderID,
|
||||
PurchaseOrderAssetAttachmentName,
|
||||
PurchaseOrderAssetAttachmentType,
|
||||
PurchaseOrderAssetAttachmentCreated
|
||||
) VALUES (?,?,?,?,NOW())";
|
||||
$sql_insert = "INSERT INTO contract_asset_attachment (
|
||||
ContractAssetAttachmentPurchaseOrderAssetContractID,
|
||||
ContractAssetAttachmentPurchaseOrderID,
|
||||
ContractAssetAttachmentFileName,
|
||||
ContractAssetAttachmentCreated
|
||||
) VALUES (?,?,?,NOW())";
|
||||
$que_insert = $this->db->query($sql_insert, [
|
||||
$para['contractID'], $para['poID'], $filename, 'order'
|
||||
$para['contractID'], $para['poID'], $filename
|
||||
]);
|
||||
if (!$que_insert) {
|
||||
$this->db->trans_rollback();
|
||||
$this->sys_error_db("[Error] failed insert attachment table purchase order asset attachment");
|
||||
$this->sys_error_db("[Error] failed insert attachment table contract asset attachment");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
@@ -1119,7 +1137,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$sql = "UPDATE purchase_order SET
|
||||
PurchaseOrderStatus = 'Pending',
|
||||
PurchaseOrderLastUpdated = NOW()
|
||||
WHERE PurchaseOrderID = ?
|
||||
WHERE PurchaseOrderID = ?
|
||||
AND PurchaseOrderIsActive = 'Y'";
|
||||
$que = $this->db->query($sql, [$para['poID']]);
|
||||
if (!$que) {
|
||||
@@ -1134,7 +1152,7 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
$sql = "UPDATE purchase_order SET
|
||||
PurchaseOrderApprovedManagerUserID = ?,
|
||||
PurchaseOrderLastUpdated = NOW()
|
||||
WHERE PurchaseOrderID = ?
|
||||
WHERE PurchaseOrderID = ?
|
||||
AND PurchaseOrderIsActive = 'Y'";
|
||||
$que = $this->db->query($sql, [$user['M_UserID'], $para['poID']]);
|
||||
if (!$que) {
|
||||
@@ -1146,11 +1164,11 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
|
||||
/* approval oleh kepala regional */
|
||||
if ($approvelevel == '2') {
|
||||
$sql = "UPDATE purchase_order SET
|
||||
$sql = "UPDATE purchase_order SET
|
||||
PurchaseOrderStatus = 'Approved',
|
||||
PurchaseOrderLastUpdated = NOW(),
|
||||
PurchaseOrderApprovedUserID = ?
|
||||
WHERE PurchaseOrderID = ?
|
||||
WHERE PurchaseOrderID = ?
|
||||
AND PurchaseOrderIsActive = 'Y'";
|
||||
$que = $this->db->query($sql, [$user['M_UserID'], $para['poID']]);
|
||||
if (!$que) {
|
||||
@@ -1168,28 +1186,6 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserApproveLevel() {
|
||||
try {
|
||||
if (!$this->isLogin) {
|
||||
$this->sys_error("invalid token");
|
||||
exit;
|
||||
}
|
||||
|
||||
$user = $this->sys_user;
|
||||
$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;
|
||||
}
|
||||
$data = $que->row_array();
|
||||
$this->sys_ok($data);
|
||||
} catch (Exception $exc) {
|
||||
$this->sys_error($exc->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private function insertLog($poID, $type, $prm, $dataBefore, $dataAfter, $userID, $desc = '') {
|
||||
$sql = "INSERT INTO acc_one_log.purchase_order_log (
|
||||
PurchaseOrderLogPurchaseOrderID,
|
||||
@@ -1211,4 +1207,4 @@ class PurchaseOrderAset extends MY_Controller {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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