diff --git a/application/models/requistion_model.php b/application/models/requistion_model.php index 7dd487e6..9e1579d5 100755 --- a/application/models/requistion_model.php +++ b/application/models/requistion_model.php @@ -360,7 +360,8 @@ ifnull(Po.Quantity,0) as POQTY,sta.StatusName $this->db->trans_start(); $this->db->insert('T_Requestion_Master', $Requistion); $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); + $this->db->trans_complete(); + if($insert_id>0) { $subQuery = 'select max(ReqNo) as ReqNo from T_Requestion_Master'; @@ -409,16 +410,29 @@ ifnull(Po.Quantity,0) as POQTY,sta.StatusName * This function is used to add the Line item details to the Database * @return array $result : This is result of the query */ - function addRequistionDetails($Requistion) + function addRequistionDetails($Requistion,$RegNo='') { $this->db->trans_start(); $this->db->insert('T_Requestion_Details', $Requistion); $insert_id = $this->db->affected_rows(); - $this->db->trans_complete(); - // print_r($this->db->last_query()); - return $insert_id; + + $subQuery = 'select max(ItemNo) as ItemNo from T_Requestion_Details where ReqNo=?'; + + $query = $this->db->query($subQuery,array($RegNo)); + + + return $query->result_array(); } + + function getItemNumber($ReqNo,$MaterialCode) + { + $subQuery = 'select ItemNo from T_Requestion_Details where ReqNo=? and MaterialCode=?'; + + $query = $this->db->query($subQuery,array($ReqNo,$MaterialCode)); + + return $query->result_array(); + } /** * This function is used to delete the Line item from details into Database * @return array $result : This is result of the query