From 0510719349dca53e5cd8471c4c8a227c7084b596 Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Wed, 10 May 2017 13:35:50 +0530 Subject: [PATCH] Requistion Flow --- application/controllers/requisitionform.php | 40 ++++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/application/controllers/requisitionform.php b/application/controllers/requisitionform.php index 528730e1..539f94c5 100644 --- a/application/controllers/requisitionform.php +++ b/application/controllers/requisitionform.php @@ -29,9 +29,15 @@ class requisitionform extends BaseController */ function requisitionlisting() { - $this->global['pageTitle'] = 'Siddharth : Requisition Listing'; + $this->global['pageTitle'] = 'Siddharth : Requisition Listing'; + + $userID = $this->session->userdata ( 'userId' ); + + $data['ReqList'] = $this->requistion_model->getRequistListUserID($userID); + $data['Status'] = $this->requistion_model->CheckDraftStatus($userID); + - $this->loadViews("requisitionlisting", $this->global, NULL); + $this->loadViews("requisitionlisting", $this->global, $data, NULL); } /** * This function used to load the first screen of the requisition Form @@ -45,8 +51,11 @@ class requisitionform extends BaseController $data['EmpList'] = $this->requistion_model->getAllEmployees(); - // $data['MaterialList'] = $this->requistion_model->getRawMaterialList(); - + $userID = $this->session->userdata ( 'userId' ); + + $data['Emp'] = $this->requistion_model->getEmpIdByUserID($userID); + + $data['CostCenter'] = $this->requistion_model->getCostCenterUserID($userID); $this->loadViews("requisitionform", $this->global, $data,null); } @@ -173,16 +182,29 @@ class requisitionform extends BaseController //echo count($comma_separated); //echo $RowCount. " Status:". $Status; - $Request = array('ReqType'=>$RequestType, 'Requestedby'=>$Requestedby,'ReqDate'=>$createddt,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); - - $Req = $this->requistion_model->addRequistion($Request); + + $IsExists = $this->requistion_model->RequistionIsExists($Requestedby); + if(count( $IsExists) == 0) + { + $Request = array('ReqType'=>$RequestType, 'Requestedby'=>$Requestedby,'ReqDate'=>$createddt,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); + + $Req = $this->requistion_model->addRequistion($Request); + } + else + { + $Request = array('ReqType'=>$RequestType, 'Requestedby'=>$Requestedby,'ReqDate'=>$createddt,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); + $UpdateReq = $this->requistion_model->UpdateRequistion($Request,$IsExists[0]['ReqNo']); + } $ReqNumber = ''; if(count($Req)>0) { $ReqNumber = $Req[0]['ReqNo']; } - //print_r($comma_separated); - // $ReqNumber = 'REQ0001'; + else + { + $ReqNumber = $IsExists[0]['ReqNo']; + } + $SkipInsert = False; for ($i = 1; $i <= $RowCount; $i++) {