diff --git a/application/models/mrir_model.php b/application/models/mrir_model.php index 66ebdabc..79ed539d 100755 --- a/application/models/mrir_model.php +++ b/application/models/mrir_model.php @@ -310,14 +310,35 @@ TMD.QuantityRejected,ST.StatusName,TMD.Remarks,AdvanceAmount '); function UpdatePOMaster($PONO,$PoMrirStatus,$updatedBy) { - - + $this->db->select('*'); + $this->db->from('T_PurchaseOrder_LineItem'); + $this->db->where('PONO',$PONO); + $this->db->where('Status !=',MRIR_APPROVED); + $query = $this->db->get(); + + $ApprovedCnt = $query->num_rows; + + $this->db->select('*'); + $this->db->from('T_PurchaseOrder_LineItem'); + $this->db->where('PONO',$PONO); + $this->db->where('Status !=',MRIR_REJECTED); + $query1 = $this->db->get(); + $RejectedCnt = $query1->num_rows; + + if ($ApprovedCnt == 0) { $this->db->where('PONO', $PONO); - $POStatus = array('status'=>$PoMrirStatus,'UpdateBY'=>$updatedBy); + $POStatus = array('status'=>MRIR_APPROVED,'UpdateBY'=>$updatedBy); $this->db->update('T_PurchaseOrder_Master', $POStatus); + } + elseif ($RejectedCnt == 0) { + $this->db->where('PONO', $PONO); + $POStatus = array('status'=>MRIR_REJECTED,'UpdateBY'=>$updatedBy); + $this->db->update('T_PurchaseOrder_Master', $POStatus); + } + - return TRUE; } + } ?> \ No newline at end of file