214 lines
9.3 KiB
PHP
214 lines
9.3 KiB
PHP
<?php
|
|
class Terms extends MY_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_inventory = $this->load->database("inventory", true);
|
|
$this->db_inventory_log = $this->load->database('inventory_log', true);
|
|
$this->db_onex = 'one_aditya';
|
|
}
|
|
|
|
function get_terms(){
|
|
try{
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = 0;
|
|
if(isset($prm['id']) && intval($prm) > 0){
|
|
$id = $prm['id'];
|
|
$sql = "SELECT PurchaseReturID as id,
|
|
PurchaseReturCode as code,
|
|
PurchaseReturName as name,
|
|
PurchaseReturDescription as description,
|
|
DATE_FORMAT(PurchaseReturStartDate,'%d-%m-%Y') as start_date,
|
|
DATE_FORMAT(PurchaseReturEndDate,'%d-%m-%Y') as end_date
|
|
FROM purchaseretur
|
|
WHERE
|
|
PurchaseReturSupplierID = ? AND PurchaseReturIsActive = 'Y'";
|
|
$query = $this->db_inventory->query($sql,$id);
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
$result = array("records" => $rows);
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("purchaseretur rows",$this->db_inventory);
|
|
exit;
|
|
}
|
|
}
|
|
else{
|
|
$this->sys_error("Invalid Param ID");
|
|
exit;
|
|
}
|
|
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
function get_term_detail(){
|
|
try{
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = 0;
|
|
if(isset($prm['id']) && intval($prm) > 0){
|
|
$id = $prm['id'];
|
|
$warehouseid = $prm['warehouseid'];
|
|
|
|
$almari = $this->db_inventory->query("SELECT WarehouseAlmariID as id
|
|
FROM warehousealmari
|
|
WHERE
|
|
WarehouseAlmariIsActive = 'Y'
|
|
AND WarehouseAlmariWarehouseID = $warehouseid
|
|
ORDER BY id ASC LIMIT 1")->row();
|
|
$almarid = $almari->id;
|
|
|
|
$rack = $this->db_inventory->query("SELECT WarehouseRackID as id
|
|
FROM warehouserack
|
|
WHERE
|
|
WarehouseRackIsActive = 'Y'
|
|
AND WarehouseRackWarehouseAlmariID = $almarid
|
|
AND WarehouseRackRow = 1
|
|
AND WarehouseRackCol = 1
|
|
ORDER BY id ASC LIMIT 1")->row();
|
|
$rackid = $rack->id;
|
|
|
|
|
|
|
|
$sql = "SELECT PurchaseReturDetailID as id,
|
|
PurchaseReturDetailID as podetailid,
|
|
PurchaseReturDetailItemID as item_id,
|
|
ItemName as item_name,
|
|
ItemSKU as item_sku,
|
|
PurchaseReturDetailItemUnitID as unit_id,
|
|
ItemUnitName as unit_name,
|
|
PurchaseReturDetailQty as po_qty,
|
|
PurchaseReturDetailReceiveQty as receive_qty,
|
|
0 as qty,
|
|
'N' as is_exist,
|
|
'N' as selected,
|
|
'' as batch_no,
|
|
'' as ed,
|
|
WarehouseAlmariID as almariid,
|
|
WarehouseAlmariName as almariname,
|
|
WarehouseRackID as rackid,
|
|
WarehouseRackName as rackname
|
|
|
|
FROM purchasereturdetail
|
|
JOIN item ON PurchaseReturDetailItemID = ItemID
|
|
LEFT JOIN itemunit ON PurchaseReturDetailItemUnitID = ItemUnitID
|
|
LEFT JOIN warehousealmari ON WarehouseAlmariID = $almarid
|
|
LEFT JOIN warehouserack ON WarehouseRackID = $rackid
|
|
LEFT JOIN purchasereturreceivedetail ON PurchaseReturReceiveDetailPurchaseReturDetailID = PurchaseReturDetailID AND PurchaseReturReceiveDetailIsActive = 'Y'
|
|
LEFT JOIN purchasereturreceive ON PurchaseReturReceiveID = PurchaseReturReceiveDetailPurchaseReturReceiveID AND PurchaseReturReceiveIsActive = 'Y'
|
|
WHERE
|
|
PurchaseReturDetailPurchaseReturID = ? AND
|
|
PurchaseReturDetailIsActive = 'Y' AND
|
|
PurchaseReturDetailStatus NOT IN('D','X')
|
|
GROUP BY PurchaseReturDetailID";
|
|
$query = $this->db_inventory->query($sql,$id);
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
if($rows && count($rows) > 0){
|
|
foreach ($rows as $key => $value) {
|
|
$rows[$key]['selected'] = false;
|
|
}
|
|
}
|
|
$result = array("records" => $rows);
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("purchasereturdetail rows",$this->db_inventory);
|
|
exit;
|
|
}
|
|
}
|
|
else{
|
|
$this->sys_error("Invalid Param ID");
|
|
exit;
|
|
}
|
|
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
function get_term_detail_edit(){
|
|
try{
|
|
if (! $this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$id = 0;
|
|
if(isset($prm['id']) && intval($prm) > 0){
|
|
$id = $prm['id'];
|
|
$sql = "SELECT PurchaseReturReceiveDetailID as id,
|
|
PurchaseReturDetailID as podetailid,
|
|
PurchaseReturDetailItemID as item_id,
|
|
ItemName as item_name,
|
|
ItemSKU as item_sku,
|
|
PurchaseReturDetailItemUnitID as unit_id,
|
|
ItemUnitName as unit_name,
|
|
PurchaseReturDetailQty as po_qty,
|
|
PurchaseReturDetailReceiveQty as receive_qty,
|
|
PurchaseReturReceiveDetailQty as qty,
|
|
'N' as is_exist,
|
|
'N' as selected,
|
|
PurchaseReturReceiveDetailBatchNo as batch_no,
|
|
DATE_FORMAT(PurchaseReturReceiveDetailED,'%d%m%Y') as ed,
|
|
WarehouseAlmariID as almariid,
|
|
WarehouseAlmariName as almariname,
|
|
WarehouseRackID as rackid,
|
|
WarehouseRackName as rackname
|
|
FROM `purchasereturreceivedetail`
|
|
JOIN purchasereturdetail ON PurchaseReturDetailID = PurchaseReturReceiveDetailPurchaseReturDetailID
|
|
JOIN purchaseretur ON PurchaseReturID = PurchaseReturDetailPurchaseReturID
|
|
JOIN `item` ON PurchaseReturDetailItemID = ItemID
|
|
LEFT JOIN itemunit ON PurchaseReturDetailItemUnitID = ItemUnitID
|
|
JOIN supplier ON SupplierID = PurchaseReturSupplierID
|
|
LEFT JOIN warehousealmari ON WarehouseAlmariID = PurchaseReturReceiveDetailWarehouseAlmariID
|
|
LEFT JOIN warehouserack ON WarehouseRackID = PurchaseReturReceiveDetailWarehouseRackID
|
|
WHERE
|
|
PurchaseReturReceiveDetailPurchaseReturReceiveID = ? AND
|
|
PurchaseReturReceiveDetailIsActive = 'Y'";
|
|
$query = $this->db_inventory->query($sql,$id);
|
|
if ($query) {
|
|
$rows = $query->result_array();
|
|
if($rows && count($rows) > 0){
|
|
foreach ($rows as $key => $value) {
|
|
$rows[$key]['selected'] = false;
|
|
}
|
|
}
|
|
$result = array("records" => $rows);
|
|
$this->sys_ok($result);
|
|
}
|
|
else {
|
|
$this->sys_error_db("purchasereturdetail rows",$this->db_inventory);
|
|
exit;
|
|
}
|
|
}
|
|
else{
|
|
$this->sys_error("Invalid Param ID");
|
|
exit;
|
|
}
|
|
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
}
|