461 lines
14 KiB
PHP
Executable File
461 lines
14 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : Cost Center (Cost Center Controller)
|
|
* User Class to control all user related operations.
|
|
* @author : VenbaMail Mali
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
*/
|
|
class storerequisitionlist extends BaseController
|
|
{
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('storerequistion_model');
|
|
|
|
$this->load->library('session');
|
|
$this->load->library('form_validation');
|
|
|
|
$this->isLoggedIn();
|
|
}
|
|
|
|
|
|
/*ADD Store requisition line item
|
|
*/
|
|
function addstores()
|
|
|
|
{
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : StoreRequisition Listing';
|
|
$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);
|
|
}
|
|
|
|
|
|
function addstore()
|
|
{
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : StoreRequisition Listing';
|
|
$userId= $this->session->userdata ('userId');
|
|
$data['Store'] = $this->storerequistion_model->Storeall($userId);
|
|
|
|
$this->loadViews("storerequisition", $this->global,$data,null);
|
|
}
|
|
|
|
/**
|
|
* This function used to load the Delete the StoreRequistion Items
|
|
*/
|
|
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;
|
|
|
|
}
|
|
|
|
/* The Function Edit Store Requistion list */
|
|
function EditStoreRequistion()
|
|
{
|
|
$StoreReqNo = $_GET['StoreReqNo'];
|
|
|
|
//$StoreReqNo= $this->input->post('id');
|
|
$this->global['pageTitle'] = 'Siddharth : StoreRequisition Listing';
|
|
$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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**get the date formatted**/
|
|
|
|
function getDateformat($Val)
|
|
{
|
|
$date = new DateTime($Val);
|
|
$retDate = $date->format('Y-m-d H:i:s');
|
|
return $retDate;
|
|
}
|
|
|
|
|
|
/**This function is used to add new StoreRequestion to the system */
|
|
|
|
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);
|
|
//echo 'done';
|
|
$StoreReqNo ='';
|
|
|
|
$StoreItemStatus =STORE_OPEN;
|
|
$Request = array( 'Requestedby'=>$Requestedby,'DepartmentCode'=>$DEPCode,'ReqDate'=>$createddt,'CostCenterCode'=>$CostCenter,'Status'=>$Status,'CreatedDate'=>$createddt,'CreatedBy'=>$CreateBy);
|
|
//print_r($Request);
|
|
$Req = $this->storerequistion_model->addRequistion($Request);
|
|
|
|
if(count($Req)>0)
|
|
{
|
|
$StoreReqNo = $Req[0]['StoreReqNo'];
|
|
//printf_r($ReqNumber);
|
|
}
|
|
echo $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';
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function addstorerequisitionlist()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : StoreRequisition Listing';
|
|
$this->load->model('storerequistion_model');
|
|
|
|
$data['Status']= $this->storerequistion_model->getStatus();
|
|
$data['TotNoOfLine']=$this->storerequistion_model->getRequistionList();
|
|
//print_r($data['TotNoOfLine']);
|
|
$this->loadViews("storerequisitionlisting", $this->global,$data,null);
|
|
|
|
|
|
}
|
|
|
|
//To issue Store Requistion
|
|
function issuestorerequisition()
|
|
{
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Issue StoreRequisition';
|
|
$this->load->model('storerequistion_model');
|
|
|
|
$StoreReqNo= $_GET['ReqNo'];
|
|
|
|
$data['ReqItem'] = $this->storerequistion_model->getRequistItemList($StoreReqNo);
|
|
$data['ReqListDetails'] = $this->storerequistion_model->getRequistDetails($StoreReqNo);
|
|
//print_r($data['ReqItem']);
|
|
$this->loadViews("issueStoreRequistion", $this->global,$data,null);
|
|
|
|
}
|
|
|
|
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');
|
|
|
|
$ItemStatus = STORE_ISSUSED;
|
|
|
|
for ($i = 1; $i <= $RowCount; $i++)
|
|
{
|
|
|
|
$MaterialCode = $this->input->post('MaterialCode'.$i);
|
|
// echo $MaterialCode;
|
|
$IssuedQuantity = $this->input->post('txtIssuedQuantity'.$i);
|
|
|
|
|
|
// echo'Material issed';
|
|
if(strlen($IssuedQuantity)>0)
|
|
{
|
|
$Remarks = $this->input->post('txtRemarks'.$i);
|
|
|
|
//echo $IssuedQuantity;
|
|
$CreatedBy = $this->session->userdata('userId');
|
|
|
|
|
|
$storerequisition = array('StoreReqNo'=>$ReqNO,'MaterialCode'=>$MaterialCode,'QuantityIssued'=>$IssuedQuantity,'Status'=>$ItemStatus,'StoreComments'=>$Remarks,'UpdatedOn'=>$createddt,'UpdatedBy'=>$CreatedBy);
|
|
|
|
|
|
$this->storerequistion_model->UpdateStoreRequistionItem($storerequisition,$ReqNO,$MaterialCode);
|
|
}
|
|
|
|
}
|
|
|
|
redirect('storerequisitionlisting','refresh');
|
|
|
|
//echo 'Updated successfully';
|
|
|
|
}
|
|
/* this function use to search StoreRequistlist*/
|
|
function SearchRequistLists()
|
|
{
|
|
$userID = $this->session->userdata ( 'userId' );
|
|
|
|
|
|
$data['AppList'] = $this->storerequistion_model->getApproverRequistList($userID);
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : ApprovalStoreRequisitionSlip';
|
|
$data['Status']= $this->storerequistion_model->getStatus();
|
|
|
|
$this->loadViews("approvalstorerequisitionslip", $this->global, $data, NULL);
|
|
|
|
}
|
|
|
|
/*Approve Completed*/
|
|
function ApproveRequest()
|
|
{
|
|
$Status= Trim($_GET['Status']);
|
|
|
|
//$StoreReqNo=$this->input->post('StoreReqNo');
|
|
$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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* This function used to load the first screen of the Requistion List Approval Screen
|
|
*/
|
|
function requisitionlistApproval()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth :Approvalstorerequisitionlist';
|
|
|
|
//$data['Status']= $this->storerequistion_model->getStatus();
|
|
|
|
$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);
|
|
// $DepNo = $ReqList[0]['DepartmentName'];
|
|
|
|
$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'];
|
|
$Remarks= $result[$i]['Remarks'];
|
|
$HTML.="<tr id='".$i."'>
|
|
<td align='left'>".$SNo."</td>
|
|
<td align='left'>".$MaterialCode."</td>
|
|
<td align='left'>".$MaterialName."</td>
|
|
<td align='left'>".$UOM."</td>
|
|
<td align='left'>".$Quantity."</td>
|
|
|
|
<td align='left'>".$Remarks."</td>
|
|
|
|
</tr>";
|
|
|
|
//$index = $index + 1;
|
|
|
|
}
|
|
|
|
//print_r($ReqList);
|
|
die(json_encode(array('Items' =>$HTML,'Requist'=>$ReqList)));
|
|
}
|
|
|
|
//not completed
|
|
function UpdateStoreRequistion()
|
|
{
|
|
|
|
$CostCenter = $this->input->post('CostCenter');
|
|
|
|
|
|
$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 =$this->input->post('txtReqNo');
|
|
|
|
|
|
$Requestedby = $this->input->post('RequestedBy');
|
|
|
|
//echo $CostCenter;
|
|
$UpdatedBy = $this->session->userdata ('userId' );
|
|
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$updatedDate = $dt->format('Y-m-d H:i:s');
|
|
|
|
|
|
if(strlen($Status) >1)
|
|
{
|
|
|
|
$Request = array('CostCenterCode'=>$CostCenter,'Status'=>$Status,'updatedOn'=>$updatedDate );
|
|
$UpdateReq = $this->storerequistion_model->UpdateRequistion($StoreReqNo,$Request);
|
|
|
|
}
|
|
|
|
$SkipInsert = False;
|
|
$StoreItemStatus =STORE_OPEN;
|
|
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")
|
|
{
|
|
//echo "string"; die();
|
|
$MaterialCode = $this->input->post('MaterialCode'.$i);
|
|
|
|
$QuantityRequired=$this->input->post('Quantity'.$i);
|
|
|
|
$Remarks=$this->input->post('Remarks'.$i);
|
|
|
|
|
|
$IsExists = $this->storerequistion_model->LineItemIsExists($StoreReqNo,$MaterialCode);
|
|
|
|
|
|
|
|
if(count( $IsExists) == 0)
|
|
{
|
|
$ReqDetails = array('StoreReqNo'=>$StoreReqNo, 'MaterialCode'=>$MaterialCode,'QuantityRequired'=>$QuantityRequired,'Remarks'=>$Remarks,'Status'=>$StoreItemStatus,'UpdatedBy'=>$UpdatedBy,'UpdatedOn'=>$updatedDate);
|
|
|
|
$this->storerequistion_model->addstoreRequistion($ReqDetails);
|
|
}
|
|
else
|
|
{
|
|
$ReqDetails = array('QuantityRequired'=>$QuantityRequired,'Remarks'=>$Remarks,'Status'=>$StoreItemStatus,'UpdatedBy'=>$UpdatedBy,'UpdatedOn'=>$updatedDate);
|
|
|
|
$this->storerequistion_model->UpdateRequistionLineItem($ReqDetails,$StoreReqNo,$MaterialCode);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo 'Successfully updated the Requistion details';
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* This function used to load the Delete the Requistion Items
|
|
*/
|
|
function DeleteRequistionForm()
|
|
{
|
|
|
|
$ReqList= $this->input->post('id');
|
|
$StoreReqNo ='';
|
|
$MaterialCode = '';
|
|
if(count($ReqList) > 0)
|
|
{
|
|
$StoreReqNo = $ReqList[0];
|
|
$MaterialCode = $ReqList[1];
|
|
}
|
|
|
|
$this->storerequistion_model->DeleteRequistionLineItem( $StoreReqNo,$MaterialCode);
|
|
|
|
echo "Successfully Deleted the Line item".$StoreReqNo;
|
|
|
|
}
|
|
|
|
}
|
|
|