From 8fcb907b1cc023e4a5eb472e1db6cf047535c4d4 Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Fri, 12 May 2017 09:21:36 +0530 Subject: [PATCH] Requistion Code --- application/controllers/requisitionform.php | 164 ++++++++++++++++++-- 1 file changed, 153 insertions(+), 11 deletions(-) diff --git a/application/controllers/requisitionform.php b/application/controllers/requisitionform.php index 4edceba7..d0a247a2 100644 --- a/application/controllers/requisitionform.php +++ b/application/controllers/requisitionform.php @@ -19,9 +19,9 @@ class requisitionform extends BaseController parent::__construct(); $this->load->model('requistion_model'); - $this->load->library('session'); - $this->load->library('form_validation'); - $this->load->library('pagination'); + $this->load->library('session'); + $this->load->library('form_validation'); + $this->isLoggedIn(); } /** @@ -29,7 +29,7 @@ class requisitionform extends BaseController */ function requisitionlisting() { - $this->global['pageTitle'] = 'Siddharth : Requisition Listing'; + $this->global['pageTitle'] = 'Siddharth : Requisition Listing'; $userID = $this->session->userdata ( 'userId' ); @@ -60,6 +60,95 @@ class requisitionform extends BaseController $this->loadViews("requisitionform", $this->global, $data,null); } + /** + * This function used to load the first screen of the Requistion List Approval Screen + */ + function requisitionlistApproval() + { + $this->global['pageTitle'] = 'Siddharth : Requisition Approval'; + + $data['Status']= $this->requistion_model->getStatus(); + + $userID = $this->session->userdata ( 'userId' ); + + $data['AppList'] = $this->requistion_model->getApproverRequistList($userID); + + + + $this->loadViews("requisitionlistapproval", $this->global, $data, NULL); + } + + + /** + * This function used to load the Edit Requistion Form + */ + function EditRequistionForm() + { + $this->global['pageTitle'] = 'Siddharth : Edit Requisition'; + + $ReqNo= $_GET['ReqNo']; + $ReqType= $_GET['ReqType']; + //$data['Status']= $this->requistion_model->getStatus(); + // echo $ReqNo; + $userID = $this->session->userdata ( 'userId' ); + + $data['ReqDetails'] = $this->requistion_model->getRequistDetails($ReqNo,'Yes'); + $data['LineItem'] = $this->requistion_model->getRequistItemList($ReqNo,'Yes'); + $data['CostCenter'] = $this->requistion_model->getCostCenterUserID($userID); + $data['MaterialCode'] = $this->requistion_model->GetMaterialCode( $ReqType,'Yes'); + + $this->loadViews("editrequisitionform", $this->global, $data, NULL); + } + + + + function SearchRequistList() + { + $userID = $this->session->userdata ( 'userId' ); + $ReqValue = $this->input->post('SearchDate'); + + $Dt = explode("-",$ReqValue); + + $FromDate =''; + $ToDate = ''; + $Status= ''; + if(count( $Dt)>1) + { + $FDate = $Dt[0]."-".$Dt[1]."-".$Dt[2]; + $TDate = $Dt[3]."-".$Dt[4]."-".$Dt[5]; + $FromDate = $this->getDateformat($FDate); + $ToDate = $this->getDateformat($TDate); + } + + $St = $this->input->post('RequisitionStatus'); + + if($St == "-1") + { + $Status = ''; + } + else + { + $Status = $St; + } + + $data['AppList'] = $this->requistion_model->getApproverRequistList($userID,$Status,$FromDate, $ToDate); + + $this->global['pageTitle'] = 'Siddharth : Requisition Approval'; + + $data['Status']= $this->requistion_model->getStatus(); + + $this->loadViews("requisitionlistapproval", $this->global, $data, NULL); + + } + + + + function getDateformat($Val) + { + $date = new DateTime($Val); + $retDate = $date->format('Y-m-d H:i:s'); + return $retDate; + } /** * This function used to load the Employee details based on the EmpID selection */ @@ -113,9 +202,9 @@ class requisitionform extends BaseController function getMaterialCode() { - $ReqType= $this->input->post('id'); + $ReqType= $this->input->post('id'); - $MaterialCode = $this->requistion_model->GetMaterialCode( $ReqType); + $MaterialCode = $this->requistion_model->GetMaterialCode( $ReqType); $MaterialName = ""; $UOM = ""; $HTML = ""; @@ -240,14 +329,67 @@ class requisitionform extends BaseController } } - - function editrequisitionlisting() + +/* To Edit the request*/ + function ViewRequest() { - $this->global['pageTitle'] = 'Siddharth : Edit Requisition Listing'; - - $this->loadViews("editrequisitionform", $this->global, NULL); + $ReqNo= $this->input->post('id'); + $result = $this->requistion_model->getRequistItemList($ReqNo); + $ReqList = $this->requistion_model->getRequistDetails($ReqNo); + $DepNo = $ReqList[0]['DEPCode']; + $CostList = $this->requistion_model->GetCostCenterByDept($DepNo); + $HTML=""; + for ($i = 0; $i < count($result); $i++) + { + $SNo = $i + 1; + $MaterialCode = $result[$i]['MaterialCode']; + $MaterialName = $result[$i]['MaterialName']; + $UOM = $result[$i]['UOM']; + $Quantity = $result[$i]['Quantity']; + $HTML.=" + ".$SNo." + ". $MaterialCode." + + ".$MaterialName." + + ".$UOM." + ".$Quantity." + "; + + //$index = $index + 1; + + } + + $CostCenter = ""; + if(count($CostList) > 0) + { + for ($j = 0; $j < count($CostList); $j++) + { + $Code = $CostList[$j]['CostCenterCode']; + $Name = $CostList[$j]['CostCenterName']; + $CostCenter .=""; + } + } + //echo $HTML; + //echo $CostCenter; + die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList,'Cost'=>$CostCenter))); } + function ApproveRequest() + { + $Status= Trim($_GET['Status']); + + $ReqNo= $_GET['ReqNo']; + $Remarks = trim($this->input->post('id')); + $ApprovedBy = $this->session->userdata ( 'userId' ); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $ApprovedDate = $dt->format('Y-m-d H:i:s'); + $Request = array('Status'=>$Status,'Comments'=>$Remarks,'ApprovedOn'=>$ApprovedDate,'Approvedby'=>$ApprovedBy); + $this->requistion_model->UpdateRequistion($Request,$ReqNo); + echo "Successfully Updated the Requistion No: ".$ReqNo; + + } + function pageNotFound() { $this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';