Requistion Code

This commit is contained in:
gandhimathi Bharathirajan 2017-05-12 09:21:36 +05:30
parent 612e68ba64
commit 8fcb907b1c

View File

@ -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 = "<option value='-1'>Select Material Type</option>";
@ -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.="<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>
</tr>";
//$index = $index + 1;
}
$CostCenter = "<option value='-1'>Select Cost center</option>";
if(count($CostList) > 0)
{
for ($j = 0; $j < count($CostList); $j++)
{
$Code = $CostList[$j]['CostCenterCode'];
$Name = $CostList[$j]['CostCenterName'];
$CostCenter .="<option value='".$Code."'>".$Code."-".$Name."</option>";
}
}
//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';