db->select ('ED.FirstName,CM.CostCenterCode,CM.CostCenterName,CB.BudgetAmount,CB.BudgetType'); $this->db-> from(' T_CostCenter_Master CM'); $this->db->join ('T_CostCenter_Departments CD ',' CD.CostCenterCode = CM.CostCenterCode'); $this->db->join ('T_CostCenter_Budget CB ',' CB.CostCenterCode = CM.CostCenterCode'); $this->db->join ('T_Employee_Details ED ','ED.Departmentcode = CD.DEPCode'); $this->db->join ('tbl_users TU ',' TU.EmpID = ED.EmpID '); $this->db->where('TU.userId ',$userId); //$this->db->where('CB.BudgetType','SERVICE'); $query = $this->db->get(); $result = $query->result(); //print_r( $result ); return $result; } function getRawMaterialList($MaterialCode='') { $this->db->select('MaterialName,UOM,MaterialCode'); $this->db->from('T_MaterialMaster'); //$this->db->where('MaterialCode',$MaterialCode ); $query = $this->db->get(); $result = $query->result(); // print_r($result); return $result; } /** * This function is used to add the Raise store Requestion into the Database * @return array $result : This is result of the query */ function addRequistion($ReqDate='') { $this->db->trans_start(); $this->db->insert('T_Store_Requestion_Master', $ReqDate); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); if($insert_id>0) { $subQuery = 'select max(StoreReqNo) as StoreReqNo from T_Store_Requestion_Master'; $query = $this->db->query($subQuery); return $query->result_array(); } //return $insert_id; } /** * This function is used to update the details into Database * @return array $result : This is result of the query */ function UpdateRequistion($StoreReqNo,$Request) { $this->db->where('StoreReqNo',$StoreReqNo); $this->db->update('T_Store_Requestion_Master',$Request); return TRUE; } function getRequistionList() { $this->db->select('Sm.StoreReqNo, Emp.FirstName as Requestedby,Sm.ReqDate,Sm.Status,Sm.Comments as Remarks,St.StatusName,Dept.DepartmentName '); $this->db->from ('T_Store_Requestion_Master Sm'); $this->db->join('tbl_users user','Sm.CreatedBy = user.userId '); $this->db->join('T_Employee_Details Emp','Emp.EmpID= user.EmpID'); $this->db->join('T_DepartmentDetails Dept','Dept.DEPCode = Sm.DepartmentCode'); $this->db->join('T_Status St','St.StatusCode = Sm.Status'); $this->db->where('Sm.Status ',STORE_APPROVAL); $this->db->or_where('Sm.Status ',STORE_PARTIALLYISSUSED); $query = $this->db->get(); $result = $query->result(); // print_r($this->db->last_query()); //print_r($result); return $result; } /*this function used to Add Store Requistion*/ function addstoreRequistion($Request) { //print_r($Request); //die(); $this->db->trans_start(); $this->db->insert('T_Store_Requestion_Details',$Request); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); if($insert_id>0) { $subQuery = 'select max(StoreReqLineItemNo) as StoreReqLineItemNo from T_Store_Requestion_Details'; $query = $this->db->query($subQuery); return $query->result_array(); } } /*this function used to Update Store Requistion*/ function upstoreRequistion($Request) { //print_r($Request); $this->db->trans_start(); $this->db->update('T_Store_Requestion_Details',$Request); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); if($insert_id>0) { $subQuery = 'select max(StoreReqLineItemNo) as StoreReqLineItemNo from T_Store_Requestion_Details'; $query = $this->db->query($subQuery); return $query->result_array(); } /** * This function is used to check the Request Line Item is in Draft status * @return array $result : This is result of the query */ function LineItemIsExists($StoreReqNo,$MaterialCode) { $this->db->select('StoreReqNo'); $this->db->from('T_Store_Requestion_Details'); $this->db->where('StoreReqNo ',$StoreReqNo ); $this->db->where('MaterialCode ',$MaterialCode ); $query = $this->db->get(); if ($query->num_rows > 0) { //echo $result->num_rows; return $query->result_array(); } } } /** * This function is used to add the Line item details to the Database * @return array $result : This is result of the query */ function addRequistionDetails($StoreReqLineItemNo) { //echo "nsmdnsjkkjasdf"; die(); $this->db->trans_start(); $this->db->insert('T_Store_Requestion_Details', $StoreReqLineItemNo ); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); //print_r($this->db->last_query()); return $insert_id; } /** * This function is used to update the Line item details to the Database * @return array $result : This is result of the query */ function upRequistionDetails($StoreReqLineItemNo) { //echo "nsmdnsjkkjasdf"; die(); $this->db->trans_start(); $this->db->update('T_Store_Requestion_Details', $StoreReqLineItemNo ); $insert_id = $this->db->affected_rows(); $this->db->trans_complete(); //print_r($this->db->last_query()); return $insert_id; } /** * This function is used to check the Request Line Item is in Draft status * @return array $result : This is result of the query */ function LineItemIsExists($StoreReqNo,$MaterialCode) { $this->db->select('StoreReqNo'); $this->db->from('T_Store_Requestion_Details'); $this->db->where('StoreReqNo ',$StoreReqNo ); $this->db->where('MaterialCode ',$MaterialCode ); $query = $this->db->get(); if ($query->num_rows > 0) { //echo $result->num_rows; return $query->result_array(); } } /** * This function is used to update the details into Database * @return array $result : This is result of the query */ function UpdateRequistionLineItem($Request,$StoreReqNo,$MaterialCode) { $this->db->where('StoreReqNo', $StoreReqNo); $this->db->where('MaterialCode', $MaterialCode); $this->db->update('T_Store_Requestion_Details',($Request)); return TRUE; } /** * This function is used to delete the Line item from details into Database * @return array $result : This is result of the query */ function DeleteRequistionLineItem( $StoreReqNo,$MaterialCode) { $this->db->where('StoreReqNo', $StoreReqNo); $this->db->where('MaterialCode', $MaterialCode); $this->db->delete('T_Store_Requestion_Details'); return TRUE; } /** * This function is used to get the userId information * @return array $result : This is result of the query */ function getStatus() { $this->db->select('StatusCode,StatusName '); $this->db->from('T_Status'); $this->db->where('Remarks', 'STORE REQUISTION STATUS'); //$this->db->where('StatusCode!=', REQ_DRAFT); $query = $this->db->get(); // print_r($query); return $query->result(); } function editstorerequistions($StoreReqNo) { $this->db->select('Sr.StoreReqNo,Sr.MaterialCode,Sr.QuantityRequired,Sr.Status,Sr.Remarks,Mm.MaterialName,Mm.UOM,Sr.QuantityIssued,STM.Status '); $this->db->from('T_Store_Requestion_Details Sr'); $this->db->join('T_MaterialMaster Mm' ,' Mm.MaterialCode = Sr.MaterialCode'); $this->db->join('T_Store_Requestion_Master STM' ,' STM.StoreReqNo = Sr.StoreReqNo'); $this->db->where('Sr.StoreReqNo',$StoreReqNo); $query = $this->db->get(); return $query->result(); } /** * This function is used to check the Request is in Draft status * @return array $result : This is result of the query */ function RequistionIsExists($ReqDate) { $this->db->select('StoreReqNo'); $this->db->from('T_Store_Requestion_Master'); //$this->db->where('Status ',REQ_DRAFT ); $this->db->where('ReqDate',$ReqDate ); $query = $this->db->get(); if ($query->num_rows > 0) { //echo $result->num_rows; return $query->result_array(); } } /** * This function is used to check the Request is in Draft status * @return array $result : This is result of the query */ function Storerequisition($MaterialCode) { $this->db->select('StoreReqNo'); $this->db->from('T_Store_Requestion_Details'); //$this->db->where('Status ',REQ_DRAFT ); $this->db->where('MaterialCode',$MaterialCode); $query = $this->db->get(); if ($query->num_rows > 0) { //echo $result->num_rows; return $query->result_array(); } } /** COMPLETED * This function is used to get the List of Store Requist details to the approver * @return array $result : This is result of the query */ function getApproverRequistList($UserID) { // echo 'UserId: '.$UserID . 'From: '.$FromDate .'TO: '. $ToDate. 'Status: '. $Status; $subQuery = ' select distinct Str.StoreReqNo,Str.Requestedby,Str.ReqDate,Str.Status,Str.CreatedDate,Str.Comments,St.StatusName,Emp1.FirstName from T_Store_Requestion_Master Str join T_Status St on St.StatusCode = Str.Status join T_Employee_Details Emp on Emp.Departmentcode =Str.DepartmentCode join T_Employee_Details Emp1 on Emp1.EmpID =Str.Requestedby join T_DepartmentDetails Dept on Dept.DEPCode = Emp.Departmentcode where Str.Status not in(?,?,?) and Emp.Departmentcode in (select DEPCode from T_DepartmentDetails where HeadDept= (select HeadDept from T_DepartmentDetails where DEPCode = (select Departmentcode from T_Employee_Details where EmpID=(select EmpID from tbl_users where userId=?))))'; $query =''; $query = $this->db->query($subQuery, array(STORE_REJECT,STORE_DRAFT,REQ_DELETED,$UserID)); // print_r($this->db->last_query()); return $query->result(); } /** * This function is used to get the Store Requsition List for the login user * @return array $result : This is result of the query */ function getRequistDetails($StoreReqNo='') { $subQuery = ' select Str.StoreReqNo,Str.Requestedby,Str.ReqDate,Dept.DEPCode,Dept.DepartmentName,Cm.CostCenterCode,Cm.CostCenterName,Emp.FirstName from T_Store_Requestion_Master Str join T_DepartmentDetails Dept on Dept.DEPCode = Str.DepartmentCode join T_CostCenter_Master Cm on Cm.CostCenterCode =Str.CostCenterCode join T_Employee_Details Emp on Emp.EmpID =Str.Requestedby where StoreReqNo =? '; $query = $this->db->query($subQuery, array($StoreReqNo)); // print_r($this->db->last_query()); return $query->result(); } function editRequistDetails($StoreReqNo) { $this->db->select('StoreReqNo,Sr.CostCenterCode,Cc.CostCenterName '); $this->db->from('T_Store_Requestion_Master Sr'); $this->db->join('T_CostCenter_Master Cc ',' Cc.CostCenterCode=Sr.CostCenterCode'); $this->db->where('StoreReqNo',$StoreReqNo); $query = $this->db->get(); return $query->result(); } /** * This function is used to get the Store Requsition List for the login user * @return array $result : This is result of the query */ function getRequistItemListApproval($StoreReqNo,$NoArray='') { $subQuery = ' select Str.StoreReqNo,Str.MaterialCode,Str.QuantityRequired,Str.Remarks,Mat.MaterialName,Mat.UOM,Ss.StatusName,Str.Status,Str.QuantityIssued from T_Store_Requestion_Details Str join T_MaterialMaster Mat on Mat.MaterialCode = Str.MaterialCode join T_Status Ss on Ss.StatusCode = Str.Status where Str.StoreReqNo =?'; $query = $this->db->query($subQuery, array($StoreReqNo)); if($NoArray == '') { return $query->result_array(); } else { return $query->result(); } } /** * This function is used to get the Store Requsition List for the login user * @return array $result : This is result of the query */ function getRequistItemList($StoreReqNo) { $subQuery = ' select Str.StoreReqNo,Str.MaterialCode,Str.QuantityRequired,Str.QuantityIssued,Str.Remarks,Str.StoreComments,Mat.MaterialName,Mat.UOM,Ss.StatusName,St.Status,St.Quantity from T_Store_Requestion_Details Str join T_MaterialMaster Mat on Mat.MaterialCode = Str.MaterialCode join T_Status Ss on Ss.StatusCode = Str.Status left join T_Store_Stockdetails St on St.MaterialCode=Str.MaterialCode where Str.StoreReqNo =?'; $query = $this->db->query($subQuery, array($StoreReqNo)); //print_r($this->db->last_query()); return $query->result(); } function getStoreRequistionStatus($StreReqNo='') { $this->db->select('Status'); $this->db->from('T_Store_Requestion_Master Sr'); $this->db->where('StoreReqNo',$StreReqNo); $query = $this->db->get(); return $query->result(); } function UpdateStoreRequistionItem($Items,$ReqNo,$MaterialCode) { $this->db->where('StoreReqNo', $ReqNo); $this->db->where('MaterialCode', $MaterialCode); $this->db->update('T_Store_Requestion_Details', $Items); return TRUE; } function getSavedQty($ReqNO,$MaterialCode) { $subQuery='select QuantityIssued from T_Store_Requestion_Details where StoreReqNo=? and MaterialCode=?'; $query = $this->db->query($subQuery, array($ReqNO,$MaterialCode)); return $query->result(); } function updatestoremaster($updatestatus,$StoreReqNo) { $this->db->where('StoreReqNo', $StoreReqNo); $this->db->update('T_Store_Requestion_Master', $updatestatus); return TRUE; } function getstatuscount($Status,$StoreReqNo) { $this->db->select('count(Status) as SCount'); $this->db->from('T_Store_Requestion_Details'); $this->db->where('Status', $Status); $this->db->where('StoreReqNo',$StoreReqNo); //$this->db->where('StoreReqNo', $StoreReqNo); $query = $this->db->get(); //print_r($this->db->last_query()); return $query->result(); } /*this function used to get the all store requistion list view*/ function Storeall($StoreReqNo,$IsArray='') { $result = $this->db-> query("CALL P_GET_AllSTOREREQUISTION('".$StoreReqNo."')") or die(mysql_error()); { //echo 'Store Line item Inserted successfully'; if($IsArray != '') { return $result->result_array(); } else { return $result->result(); } } } function getItemQuantityFromStock($MaterialCode) { $subQuery = 'select Quantity from T_Store_Stockdetails where MaterialCode=?'; $query = $this->db->query($subQuery,array($MaterialCode)); return $query->result_array(); } function UpdateStock($StockDetails,$MaterialCode) { $this->db->where('MaterialCode', $MaterialCode); $this->db->update('T_Store_Stockdetails', $StockDetails); return TRUE; } }