add requistion fixes : ps

This commit is contained in:
VE10-Sanjeev 2023-06-12 18:38:25 +05:30
parent 22f0df4cf1
commit e5eb672202

View File

@ -357,21 +357,28 @@ ifnull(Po.Quantity,0) as POQTY,sta.StatusName
* This function is used to add the Requistion into the Database
* @return array $result : This is result of the query
*/
function addRequistion($Requistion)
{
function addRequistion($Requistion){
$this->db->trans_start();
$this->db->insert('T_Requestion_Master', $Requistion);
$insert_id = $this->db->affected_rows();
$result = $this->db->insert('T_Requestion_Master', $Requistion);
$insert_id = $this->db->insert_id();
$affected_rows = $this->db->affected_rows();
$this->db->trans_complete();
log_message('error','add new Requisition affected rows = '.$insert_id);
if($insert_id>0)
{
// $subQuery = 'select max(ReqNo) as ReqNo from T_Requestion_Master';
$subQuery = 'select ReqNo from T_Requestion_Master order by CreatedDate desc limit 1';
$query = $this->db->query($subQuery);
return $query->result_array();
}
try {
$result = ($result) ? $result : false;
if ($result && $affected_rows > 0) {
$subQuery = 'select ReqNo from T_Requestion_Master order by CreatedDate desc limit 1';
$query = $this->db->query($subQuery);
log_message('error','add new Requisition insert_id '.$insert_id);
return $query->result_array();
} else {
throw new Exception("database error occur requisition master details not inserted");
}
} catch (Exception $e) {
log_message('error',$e->getMessage());
return false;
}
}
/**
* This function is used to check the Request is in Draft status
* @return array $result : This is result of the query