From ad8f5fe3a1ee93f4ab7df4ca4ebc37fe28f9a621 Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Wed, 10 May 2017 13:36:23 +0530 Subject: [PATCH] Requistion Flow --- application/models/requistion_model.php | 84 ++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/application/models/requistion_model.php b/application/models/requistion_model.php index 769c2fbf..0fc95257 100644 --- a/application/models/requistion_model.php +++ b/application/models/requistion_model.php @@ -126,6 +126,67 @@ class requistion_model extends CI_Model return $query->result(); } + /** + * This function is used to get the Employee Details + * @return array $result : This is result of the query + */ + function getEmpIdByUserID($UserID) + { + $subQuery ='SELECT EMP.EmpID,EMP.FirstName,EMP.Designation,DEPT.DEPCode,DEPT.DepartmentName + FROM T_Employee_Details EMP JOIN T_DepartmentDetails DEPT ON + EMP.Departmentcode = DEPT.DEPCode + WHERE EMP.EmpID=(select EmpID from tbl_users where userId=?)'; + + $query = $this->db->query($subQuery, array($UserID)); + + + return $query->result(); + } + + /** + * This function is used to get the CostCenter for the Selected Employee + * @return array $result : This is result of the query + */ + function getCostCenterUserID($UserID) + { + $subQuery ='SELECT Mast.CostCenterCode,Mast.CostCenterName from T_CostCenter_Master Mast + LEFT JOIN T_CostCenter_Departments COST ON COST.CostCenterCode = Mast.CostCenterCode + WHERE COST.DEPCode=(select Departmentcode from T_Employee_Details where EmpID = (select EmpID from tbl_users where userId=?))'; + + $query = $this->db->query($subQuery, array($UserID)); + //print_r($this->db->last_query()); + return $query->result(); + } + + /** + * This function is used to get the Purchase order Type + * @return array $result : This is result of the query + */ + function CheckDraftStatus($UserID) + { + $Status = 'Draft'; + $subQuery = 'select count(ReqNo) as cnt from T_Requestion_Master where + Requestedby= ( select EmpID from tbl_users where userId=?) and status=?'; + + $query = $this->db->query($subQuery, array($UserID,$Status)); + + return $query->result(); + } + /** + * This function is used to get the Purchase order Type + * @return array $result : This is result of the query + */ + function getRequistListUserID($UserID) + { + + $subQuery = 'select ReqNo, ReqType ,Status,CreatedDate from T_Requestion_Master where + Requestedby= ( select EmpID from tbl_users where userId=?)'; + + $query = $this->db->query($subQuery, array($UserID)); + + return $query->result(); + } + function addRequistion($Requistion) { $this->db->trans_start(); @@ -141,6 +202,20 @@ class requistion_model extends CI_Model return $query->result_array(); } + } + + function RequistionIsExists($ReqBy) + { + $this->db->select('ReqNo'); + $this->db->from('T_Requestion_Master'); + $this->db->where('Status ','Draft' ); + $this->db->where('Requestedby ',$ReqBy ); + $query = $this->db->get(); + + if ($query->num_rows > 0) { + //echo $result->num_rows; + return $query->result_array(); + } } function addRequistionDetails($Requistion) { @@ -148,11 +223,18 @@ class requistion_model extends CI_Model $this->db->insert('T_Requestion_Details', $Requistion); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); - print_r($this->db->last_query()); + // print_r($this->db->last_query()); return $insert_id; } + function UpdateRequistion($Requistion, $ReqNo) + { + $this->db->where('ReqNo', $ReqNo); + $this->db->update('T_Requestion_Master', $Requistion); + + return TRUE; + } }