load->model('storerequistion_model'); $this->load->library('session'); $this->load->library('form_validation'); $this->isLoggedIn(); $this->CompanyName = "RESICO"; } /** * For Store requisition listing (NOTE : this listing descripted - what are the store requistion) **/ function addstores() { //$this->global['pageTitle'] = 'Resico : Created Store Requisition Listing'; $this->global['pageTitle'] = $this->CompanyName.' : Raise Store Requisition'; $userId= $this->session->userdata ('userId'); $data['DEPCode'] = $this->session->userdata('DEPCode'); $data['DepName'] = $this->session->userdata('DepartmentName'); $data['cost'] = $this->storerequistion_model->getCostUser($userId); $data['MaterialList'] = $this->storerequistion_model->getRawMaterialList(); $this->loadViews("addstorerequisitionslip", $this->global,$data,null); } /** * Store requisition listing is under Draft status (this hide the raise StoreRequisition button). **/ function addstore() { //$this->global['pageTitle'] = 'Resico : StoreRequisition Listing'; $this->global['pageTitle'] = $this->CompanyName.' : Store Requisition Details'; $userId= $this->session->userdata ('userId'); $data['Store'] = $this->storerequistion_model->Storeall($userId); $this->loadViews("storerequisition", $this->global,$data,null); } /** * Its handles Store Requistion Delete Operations ( in Store Requistion listing ) */ function DeleteReqNo() { $StoreReqNo= $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->storerequistion_model->UpdateRequistion($StoreReqNo,$Request); echo "Successfully Deleted the ".$StoreReqNo; } /** * For editing purpose and it has oldest all store requistion. */ function EditStoreRequistion() { $StoreReqNo = $_GET['StoreReqNo']; //$this->global['pageTitle'] = 'Resico : Edit StoreRequisition'; $this->global['pageTitle'] = $this->CompanyName.' : Edit StoreRequisition'; $this->load->model('storerequistion_model'); $data['cost'] = $this->storerequistion_model->editRequistDetails($StoreReqNo); $data['Status'] = $this->storerequistion_model->getStoreRequistionStatus($StoreReqNo); $data['MaterialList'] = $this->storerequistion_model->getRawMaterialList(); $data['DepName'] = $this->session->userdata('DepartmentName'); $data['LineItem']=$this ->storerequistion_model->editstorerequistions($StoreReqNo); $this->loadViews("editstorerequisition", $this->global,$data,null); } /** * To convert the dateformat (date with time) and store to DB */ function getDateformat($Val) { $date = new DateTime($Val); $retDate = $date->format('Y-m-d H:i:s'); return $retDate; } /** * For new StoreRequestion values inserted into DB */ function addNewRequistion() { $CostCenter = $this->input->post('CostCenter'); $DEPCode = $this->input->post('txtDepCode'); $CreateBy = $this->session->userdata ( 'userId' ); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $DeletedRow = $this->input->post('txtDeletedRow'); $RowCount = $this->input->post('txtRowCount'); $Status = $this->input->post('txtStatus'); $Requestedby = $this->session->userdata ( 'EmpID' ); $comma_separated = explode(':', $DeletedRow); $StoreReqNo =''; $StoreItemStatus =STORE_OPEN; $Request = array( 'Requestedby'=>$Requestedby,'DepartmentCode'=>$DEPCode,'ReqDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy); $Req = $this->storerequistion_model->addRequistion($Request); if(count($Req)>0) { $StoreReqNo = $Req[0]['StoreReqNo']; } $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); $QuantityRequired=$this->input->post('Quantity'.$i); $Remarks=$this->input->post('Remarks'.$i); $Request = array('MaterialCode'=>$MaterialCode,'Status'=>$StoreItemStatus ,'QuantityRequired'=>$QuantityRequired,'Remarks'=>$Remarks,'StoreReqNo'=>$StoreReqNo); $addReq=$this->storerequistion_model->addstoreRequistion($Request); } } if($Status == STORE_DRAFT) { echo 'Successfully Saved the Store Requistion details'; } else { echo 'Successfully Created the Store Requistion details'; } } /** * For Store requisition listing (NOTE : this listing descripted - only approved store requistion) */ function addstorerequisitionlist() { //$this->global['pageTitle'] = 'Resico : Store Requisition Listing'; $this->global['pageTitle'] = $this->CompanyName.' : Store Requisition Listing'; $this->load->model('storerequistion_model'); $data['Status']= $this->storerequistion_model->getStatus(); $data['TotNoOfLine']=$this->storerequistion_model->getRequistionList(); $this->loadViews("storerequisitionlisting", $this->global,$data,null); } /** * To issue Store Requistion **/ function issuestorerequisition() { //$this->global['pageTitle'] = 'Resico : Issue StoreRequisition'; $this->global['pageTitle'] = $this->CompanyName.' : Issue StoreRequisition'; $this->load->model('storerequistion_model'); $StoreReqNo= $_GET['ReqNo']; $data['ReqItem'] = $this->storerequistion_model->getRequistItemList($StoreReqNo); $data['ReqListDetails'] = $this->storerequistion_model->getRequistDetails($StoreReqNo); $this->loadViews("issueStoreRequistion", $this->global,$data,null); } /** * To Update with existing one with new one (Issued Requistion) * */ function UpdateIssueRequistion() { $ReqNO = $this->input->post('txtReqNo'); $RowCount = $this->input->post('txtRowCount'); $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); $createddt = $dt->format('Y-m-d H:i:s'); $UPdateby=$this->session->userdata('userId'); $date = new DateTime('now',new DateTimeZone('Asia/Kolkata')); $UPdateon = $date->format('Y-m-d H:i:s'); for ($i = 1; $i <= $RowCount; $i++) { $MaterialCode = $this->input->post('MaterialCode'.$i); $IssuedQuantity = $this->input->post('txtIssuedQuantity'.$i); $Reqqty= $this->input->post('txtqty'.$i); $savedqty=$this->storerequistion_model->getSavedQty($ReqNO,$MaterialCode); $Qtyissued=0; foreach($savedqty as $Qty) { $Qtyissued=$Qty->QuantityIssued; } $ActQty=$Qtyissued+$IssuedQuantity; if($Reqqty>$ActQty) { $ItemStatus = STORE_PARTIALLYISSUSED; } else { $ItemStatus = STORE_ISSUSED; } if(strlen($IssuedQuantity)>0) { $Remarks = $this->input->post('txtRemarks'.$i); $CreatedBy = $this->session->userdata('userId'); $storerequisition = array('StoreReqNo'=>$ReqNO,'MaterialCode'=>$MaterialCode,'QuantityIssued'=>$ActQty,'Status'=>$ItemStatus,'StoreComments'=>$Remarks,'UpdatedOn'=>$createddt,'UpdatedBy'=>$CreatedBy); $this->storerequistion_model->UpdateStoreRequistionItem($storerequisition,$ReqNO,$MaterialCode); $getAvailableqty = $this->storerequistion_model->getItemQuantityFromStock(trim($MaterialCode)); if(count($getAvailableqty)>0) { $avlQty = $getAvailableqty[0]['Quantity']; } $BalanceQty=$avlQty-$IssuedQuantity; $updatStock = array('Quantity'=>$BalanceQty,'Status'=>'0', 'Remarks'=>'Stock Deducted For'.$ReqNO,'UpdatedOn'=>$UPdateon,'UpdatedBy'=>$UPdateby); $this->storerequistion_model->UpdateStock($updatStock,trim($MaterialCode)); $StoreReqNo=$ReqNO; $reqstatus=$this->storerequistion_model->getstatuscount('ST037',$ReqNO); $reqstatuscount=0; foreach ($reqstatus as $Req) { $reqstatuscount=$Req->SCount; } if($reqstatuscount==$RowCount) { $reqStatus=STORE_ISSUSED; } else { $reqStatus=STORE_PARTIALLYISSUSED; } $updatestatus=array('Status' =>$reqStatus); $this->storerequistion_model->updatestoremaster($updatestatus,$StoreReqNo); } } echo ""; redirect('storerequisitionlisting','refresh'); } /** * For Store Requisition listing (Note: this listing descripted - Approve the store requisition ) **/ function SearchRequistLists() { $userID = $this->session->userdata ( 'userId' ); $data['AppList'] = $this->storerequistion_model->getApproverRequistList($userID); //$this->global['pageTitle'] = 'Resico : Approval Store Requisition Listing'; $this->global['pageTitle'] = $this->CompanyName.' : Approval Store Requisition Listing'; $data['Status']= $this->storerequistion_model->getStatus(); $this->loadViews("approvalstorerequisitionslip", $this->global, $data, NULL); } /** * To change the approval storerequisition status ( Approve Completed are not) */ function ApproveRequest() { $Status= Trim($_GET['Status']); $StoreReqNo = trim($this->input->post('id')); $Remarks=trim($this->input->post('newcomments')); $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->storerequistion_model->UpdateRequistion($StoreReqNo,$Request); echo "Successfully Updated the Requistion No: ".$StoreReqNo; } /*to load the first screen of the Requistion List Approval Screen*/ function requisitionlistApproval() { // $this->global['pageTitle'] = 'Resico :Approvalstorerequisitionlist'; $this->global['pageTitle'] = $this->CompanyName.' : Approvalstorerequisitionlist'; $userID = $this->session->userdata ( 'userId' ); $data['AppList'] = $this->storerequistion_model->getApproverRequistList($userID); $this->loadViews("requisitionlistapproval", $this->global, $data, NULL); } /* To Edit the view store request*/ function ViewRequest() { $StoreReqNo= $this->input->post('id'); $result = $this->storerequistion_model->getRequistItemListApproval($StoreReqNo); $ReqList = $this->storerequistion_model->getRequistDetails($StoreReqNo); $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]['QuantityRequired']; $IssuedQty=$result[$i]['QuantityIssued']; $Status=$result[$i]['StatusName']; $Remarks= $result[$i]['Remarks']; $HTML.="