84 lines
3.6 KiB
PHP
84 lines
3.6 KiB
PHP
<?php
|
|
class Stock 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_stock_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'];
|
|
$sql = "SELECT CONCAT('S',StockID) as xid,
|
|
0 as id,
|
|
'N' as is_exist,
|
|
'N' as selected,
|
|
ItemId as item_id,
|
|
ItemUnitID as unit_id,
|
|
ItemName as item_name,
|
|
ItemUnitName as unit_name,
|
|
StockBatchNo as batch_no,
|
|
StockStockNumber as stock_no,
|
|
StockED as ed,
|
|
StockStockNumber as stock_no,
|
|
StockWarehouseID as warehouse_id,
|
|
StockWarehouseAlmariID as almari_id,
|
|
StockWarehouseRackID as rack_id,
|
|
SUM(StockQty) as qty_stock,
|
|
0 as qty,
|
|
CONCAT(WarehouseName,'/',IFNULL(WarehouseAlmariName,'-'),'/',IFNULL(WarehouseRackName,'-')) as location
|
|
FROM stock
|
|
JOIN item ON StockItemID = ItemID
|
|
JOIN itemunit ON StockItemUnitID = ItemUnitID
|
|
JOIN `purchasereceivedetail` ON PurchaseReceiveDetailStockNumber = StockStockNumber
|
|
JOIN `purchaseorderdetail` ON PurchaseReceiveDetailPurchaseOrderDetailID = PurchaseOrderDetailID
|
|
JOIN `purchaseorder` ON PurchaseOrderDetailPurchaseOrderID = PurchaseOrderID AND PurchaseOrderID = ?
|
|
JOIN `purchasereceive` ON PurchaseReceiveDetailPurchaseReceiveID = PurchaseReceiveID
|
|
JOIN warehouse ON StockWarehouseID = WarehouseID AND WarehouseIsOffice = 'Y'
|
|
JOIN `warehousealmari` ON StockWarehouseAlmariID = WarehouseAlmariID
|
|
JOIN `warehouserack` ON StockWarehouseRackID = WarehouseRackID
|
|
WHERE
|
|
StockQty > 0
|
|
GROUP BY StockID";
|
|
$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 {
|
|
// echo $this->db_inventory->last_query();
|
|
$this->sys_error_db("stock rows",$this->db_inventory);
|
|
exit;
|
|
}
|
|
}
|
|
else{
|
|
$this->sys_error("Invalid Param ID");
|
|
exit;
|
|
}
|
|
|
|
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
}
|