From ad8925a65aa3353b6f769863aae3c94ce655f612 Mon Sep 17 00:00:00 2001 From: gandhimathi Bharathirajan Date: Sat, 13 May 2017 11:07:42 +0530 Subject: [PATCH] Requistion Code --- application/controllers/requisitionform.php | 136 ++++++++++++++++++-- 1 file changed, 123 insertions(+), 13 deletions(-) diff --git a/application/controllers/requisitionform.php b/application/controllers/requisitionform.php index d0a247a2..a2ff720c 100644 --- a/application/controllers/requisitionform.php +++ b/application/controllers/requisitionform.php @@ -85,22 +85,57 @@ class requisitionform extends BaseController 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'); + $data['MaterialCode'] = $this->requistion_model->EditMaterialCode($ReqNo, $ReqType); $this->loadViews("editrequisitionform", $this->global, $data, NULL); } + /** + * This function used to load the Delete the Requistion Items + */ + function DeleteRequistionForm() + { + + $ReqList= $this->input->post('id'); + $ReqNo =''; + $MaterialCode = ''; + if(count($ReqList) > 0) + { + $ReqNo = $ReqList[0]; + $MaterialCode = $ReqList[1]; + } + + $this->requistion_model->DeleteRequistionLineItem( $ReqNo,$MaterialCode); + + echo "Successfully Deleted the Line item".$ReqNo; + + } + /** + * This function used to load the Delete the Requistion Items + */ + function DeleteReqNo() + { + + $ReqNo= $this->input->post('id'); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updateddt = $dt->format('Y-m-d H:i:s'); + $Request = array('Status'=>REQ_DELETED,'updatedOn'=>$updateddt); + + $this->requistion_model->UpdateRequistion( $Request,$ReqNo); + + echo "Successfully Deleted the ".$ReqNo; + + } function SearchRequistList() { @@ -255,7 +290,7 @@ class requisitionform extends BaseController } else { - $Status= $_GET['ID']; + $Status= $_GET['ID']; $RequestType = strtoupper(trim($this->input->post('RequestType'))); $Requestedby = strtoupper(trim($this->input->post('EmpID'))); $CreateBy = $this->session->userdata ( 'userId' ); @@ -267,10 +302,6 @@ class requisitionform extends BaseController $comma_separated = explode(':', $DeletedRow); - //echo $DeletedRow; - //echo count($comma_separated); - - //echo $RowCount. " Status:". $Status; $IsExists = $this->requistion_model->RequistionIsExists($Requestedby); if(count( $IsExists) == 0) @@ -303,7 +334,7 @@ class requisitionform extends BaseController for($j = 1; $j < count($comma_separated); $j++) { $deletedRow = $comma_separated[$j] ; - //$SkipInsert = ($deletedRow != $i ? FALSE:True); + if($deletedRow == $i ) { $SkipInsert = "True"; @@ -323,13 +354,92 @@ class requisitionform extends BaseController } } - - echo 'Successfully Created Requistion details'; + if($Status == REQ_DRAFT) + { + echo 'Successfully Saved the Requistion details'; + } + else + { + echo 'Successfully Created the Requistion details'; + } } } - + function EditRequistion() + { + $Status = $this->input->post('txtStatus'); + $ReqNumber = $this->input->post('txtReqNo'); + //echo $ReqNumber; + $UpdatedBy = $this->session->userdata ( 'userId' ); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $updatedDate = $dt->format('Y-m-d H:i:s'); + + $DeletedRow = $this->input->post('txtDeletedRow'); + $RowCount = $this->input->post('txtRowCount'); + + if(strlen($Status) > 1) + { + $Request = array( 'Status'=>$Status,'CreatedDate'=>$updatedDate,'CreatedBy'=>$UpdatedBy); + $UpdateReq = $this->requistion_model->UpdateRequistion($Request, $ReqNumber); + } + else + { + $Request = array( 'Status'=>REQ_PENDING_APPROVAL,'updatedOn'=>updatedDate); + $UpdateReq = $this->requistion_model->UpdateRequistion($Request, $ReqNumber); + } + + + $comma_separated = explode(':', $DeletedRow); + + /* Table value update and Insert in the table */ + + $SkipInsert = False; + for ($i = 1; $i <= $RowCount; $i++) + { + $SkipInsert = "False"; + if( count($comma_separated) > 0) + { + for($j = 1; $j < count($comma_separated); $j++) + { + $deletedRow = $comma_separated[$j] ; + + if($deletedRow == $i ) + { + $SkipInsert = "True"; + break; + } + + } + } + + if($SkipInsert == "False") + { + $MaterialCode = $this->input->post('MaterialCode'.$i); + $Quantity = $this->input->post('Quantity'.$i); + $IsExists = $this->requistion_model->LineItemIsExists($ReqNumber,$MaterialCode); + if(count( $IsExists) == 0) + { + $ReqDetails = array('ReqNo'=>$ReqNumber, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'UpdatedBy'=>$UpdatedBy,'UpdatedOn'=>$updatedDate); + $this->requistion_model->addRequistionDetails($ReqDetails); + } + else + { + $ReqDetails = array('ReqNo'=>$ReqNumber, 'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity,'UpdatedBy'=>$UpdatedBy,'UpdatedOn'=>$updatedDate); + $this->requistion_model->UpdateRequistionLineItem($ReqDetails,$ReqNumber,$MaterialCode); + } + + + } + + } + echo ""; + $this->requisitionlisting(); + + + + + } /* To Edit the request*/ function ViewRequest() {