From 9f3ef6d65cbdf75e9a13f73f4c638ee10327b9eb Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Mon, 4 Sep 2017 12:12:05 +0530 Subject: [PATCH] Available budget amount and Service PO status update for requistion screen --- application/models/purchaseorder_model.php | 34 +++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php index a57be7a3..c01f91bd 100755 --- a/application/models/purchaseorder_model.php +++ b/application/models/purchaseorder_model.php @@ -1504,15 +1504,41 @@ join T_MaterialMaster Mat on Mat.MaterialCode = LineItem.MaterialCode $this->db->set('Req.Status',$POStatus); $this->db->where('Item.PONO',$PONO); $this->db->update('T_PurchaseOrder_LineItem Item JOIN T_Requestion_Details Req ON Item.ReqNo= Req.ReqNo'); - return TRUE; + return TRUE; } - function UpdateReceivedQtyforServicePO($PONO) + function UpdateReceivedQtyforServicePO($PONO,$updateddt,$updatedBy) { + $this->db->select('LineItemNo,MaterialCode'); + $this->db->from('T_PurchaseOrder_LineItem'); + $this->db->where('PONO ',$PONO ); + $query = $this->db->get(); + $result = $query->result(); + if(!empty($result)) + { + foreach ($result as $res) + { + $LineItemNo =$res->LineItemNo; + $MaterialCode = $res->MaterialCode; + //echo $LineItemNo; + $subQuery = 'update T_PurchaseOrder_LineItem - set ReceivedQuantity=Quantity, status=? where PONO=?'; - $query = $this->db->query($subQuery,array(PO_SERVICE_COMPLETED,$PONO)); + set ReceivedQuantity=Quantity, status=?,UpdatedOn=?,UpdateBY=? where PONO=? and LineItemNo=?'; + + $query = $this->db->query($subQuery,array(PO_SERVICE_COMPLETED,$updateddt,$updatedBy,$PONO,$LineItemNo)); + $finddot = strpos($PONO,'.'); + if($finddot = true) + { + $subQuery = 'update T_PurchaseOrder_LineItem + set ReceivedQuantity=Quantity, status=?,UpdatedOn=?,UpdateBY=? where PONO=substring(?,1,(case when INstr(?,?) > 0 then INstr(?,?)-1 else 0 end)) and MaterialCode=?'; + + $query = $this->db->query($subQuery,array(PO_SERVICE_COMPLETED,$updateddt,$updatedBy,$PONO,$PONO,'.',$PONO,'.',$MaterialCode)); + } + + } + + } } }