From c94e68388d73f3b434c78e1bf343ff85b530771d Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Thu, 13 Jul 2017 11:24:41 +0530 Subject: [PATCH] Amendment issue --- .../models/inwardgateregister_model.php | 33 ++++++++++++++----- application/models/purchaseorder_model.php | 11 +++++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/application/models/inwardgateregister_model.php b/application/models/inwardgateregister_model.php index 75908fa8..d5be4a9c 100755 --- a/application/models/inwardgateregister_model.php +++ b/application/models/inwardgateregister_model.php @@ -34,13 +34,13 @@ class inwardgateregister_model extends CI_Model function getpurchaseorder() { $this->db->distinct(); - $this->db->select('POM.PONO,POM.ServiceDescription,POM.DeliveryDate,sup.SupplierName,sup.Address'); + $this->db->select('POM.PONO,POM.ServiceDescription,POM.DeliveryDate,sup.SupplierName,sup.Address,POM.status'); $this->db->from('T_PurchaseOrder_Master POM'); $this->db->join('T_PurchaseOrder_LineItem POL', 'POL.PONO = POM.PONO'); $this->db->join('T_SupplierDetailsN sup', 'POM.SupplierID = sup.SupplierID'); - $this->db->where('POM.Status',PO_RELEASED); - $this->db->where('POL.Status !=',IGR_CREATED); - $this->db->where('POL.Status !=',MRIR_CREATED); + $this->db->where('POM.Status',PO_RELEASED); + $this->db->or_where('POM.Status',IGR_CREATED); + $this->db->or_where('POM.Status',MRIR_CREATED); $query = $this->db->get(); @@ -53,17 +53,15 @@ class inwardgateregister_model extends CI_Model function viewpurchaseorder($PO) { - $subQuery ='SELECT distinct POM.PONO,POL.MaterialCode,(CASE WHEN (POL.Quantity > igr.QuantityAsPerInvoice ) - THEN ( POL.Quantity - igr.QuantityAsPerInvoice) ELSE POL.Quantity - END) as Quantity,POL.PONO,MM.MaterialName,MM.UOM + $subQuery ='SELECT distinct POM.PONO,POL.MaterialCode,POL.Quantity,POL.ReceivedQuantity,(POL.Quantity -POL.ReceivedQuantity ) as PendingQty,POL.PONO,MM.MaterialName,MM.UOM from T_PurchaseOrder_Master POM left join T_PurchaseOrder_LineItem POL on POL.PONO = POM.PONO left join T_IGR_Master IGM on IGM.PONO =POL.PONO left join T_IGR_Details igr on igr.MaterialCode = POL.MaterialCode and IGM.PONO =POL.PONO left join T_MaterialMaster MM - on MM.MaterialCode = POL.MaterialCode where POM.PONO=? and POL.Status not in(?,?) '; + on MM.MaterialCode = POL.MaterialCode where POM.PONO=? ';// and POM.Status not in(?) '; - $query = $this->db->query($subQuery, array($PO,IGR_CREATED,MRIR_CREATED)); + $query = $this->db->query($subQuery, array($PO,IGR_CREATED)); // print_r($this->db->last_query()); return $query->result(); @@ -145,4 +143,21 @@ class inwardgateregister_model extends CI_Model return TRUE; } + + function UpdatePOMaster($PONO,$updatedBy) + { + $this->db->select('Count(*) as cnt'); + $this->db->from('T_PurchaseOrder_LineItem'); + $this->db->where('PONO',$PONO); + $this->db->where('Status !=',IGR_CREATED); + + $query = $this->db->get(); + //print_r($this->db->last_query()); + if ($query->num_rows == 0) { + $this->db->where('PONO', $PONO); + $POStatus = array('status'=>IGR_CREATED,'UpdateBY'=>$updatedBy); + $this->db->update('T_PurchaseOrder_Master', $POStatus); + } + + } } \ No newline at end of file diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php index 1f11f8fc..71805a40 100755 --- a/application/models/purchaseorder_model.php +++ b/application/models/purchaseorder_model.php @@ -1249,4 +1249,15 @@ join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode $RequistionDetails = $ResultArray; return $RequistionDetails; } + function GetLineItemReceivedQty($ParentPO,$MaterialCode) + { + $this->db->select('ReceivedQuantity'); + $this->db->from('T_PurchaseOrder_LineItem'); + + $this->db->where('PONO',$ParentPO); + $this->db->where('MaterialCode',$MaterialCode); + $result=$this->db->get(); + + return $result->result_array(); + } } \ No newline at end of file