ria/application/controllers/MRIRcontroller.php
venbatechnologies@gmail.com ad73ea2913 company name changed all screen
2018-04-05 19:19:16 +05:30

424 lines
15 KiB
PHP

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
require APPPATH . '/third_party/mpdf/mpdf.php';
/**
* Class : MRIRcontroller (Material Inspection Report - Controller)
* MRIRcontroller Class to control all MRIR related operations.
* @author : Venba Info Tech - Saravana kumar
* @version : 1.1
* @since : 18 Novmeber 2017
*/
class MRIRcontroller extends BaseController
{
/**
* default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->load->model('purchaseorder_model');
$this->load->model('mrir_model');
$this->load->library('session');
$this->load->library('form_validation');
$this->isLoggedIn();
$this->CompanyName = $this->global['CompanyName'];
}
/**
* Index Page for this controller (default function of the class)
*/
public function index()
{
//$this->global['pageTitle'] = 'Resico : View material inspection report';
$this->global['pageTitle'] = $this->CompanyName.' : View material inspection report';
$this->loadViews("viewmaterialinspectionreport", $this->global,NULL , NULL);
}
/*
* For New mrir datas
*/
function materialinspectionreport($mrir='',$IGRNO='')
{
//$this->global['pageTitle'] = 'Resico : Material Inspection Report';
$this->global['pageTitle'] = $this->CompanyName.' : Material Receipt and Inspection Report';
$this->load->model('mrir_model');
$data['IGRNOonly'] = $this->mrir_model->getIGRNOonly();
$this->loadViews("materialinspectionreport", $this->global,$data,NULL);
}
/*
* For MRIR datas has PDF
*/
public function MrirDetailsPrintPdf()
{
$MrirNo = $_GET['MRIRNO'];
//$this->global['pageTitle'] = 'Resico : MRIR Pdf ';
$this->global['pageTitle'] = $this->CompanyName.' : MRIR pdf';
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
$data['MRIRDetails'] = $this->mrir_model->edit_mrir($MrirNo);
$this->load->View("Mrirprintpdf",$data, NULL);
//*********************MPDF***********
$mpdf=new mPDF('utf-8','A4-P',10, 10,10, 10,10, 38, 4, 6);
$HTMLFooter = $this->load->view('includes/bankreport_footer',$data, true);
$mpdf->SetDisplayMode('fullpage');
//$mpdf->SetTitle('Resico : MRIR PDF');
$mpdf->SetTitle($this->CompanyName.' : MRIR PDF');
$mpdf->SetHTMLHeader($HtmlHeading);
$html = $this->load->view('Mrirprintpdf',$data,true);
$mpdf->SetDisplayMode('fullpage');
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
$mpdf->list_indent_first_level = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($html);
$mpdf->Output("MrirDetails".$data.'.pdf','I',$php);
}
/**
* For MRIR datas has in billing screen
*/
public function viewmrirforbilling()
{
//$this->global['pageTitle'] = 'Resico : Billing ';
$this->global['pageTitle'] = $this->CompanyName.' : Billing ';
$data['Billing'] = $this->mrir_model->view_mrir_Billing();
$this->loadViews("viewmrirforbilling", $this->global,$data , NULL);
}
/**
* For material issued/distribution list
*/
public function viewmMaterialDistributionList()
{
//$this->global['pageTitle'] = 'Resico : Distribution list ';
$this->global['pageTitle'] = $this->CompanyName.' : Distribution list ';
$data['Distribution'] = $this->mrir_model->ViewDistributionList();
$data['status'] = $this->mrir_model->getStatus();
$this->loadViews("MaterialIssueList", $this->global,$data , NULL);
}
/*FOR Displaying IGR Values (view folder- IGR view page (button link)) */
function igrdatavalues()
{
$IgrNo= $_GET['IGRNO'];
$IgrItemno = $_GET['IGRitemno'];
$data['IGRDetails'] = $this->mrir_model->get_IGR($IgrNo,$IgrItemno);
// $this->global['pageTitle'] = 'Resico: IGR Details ';
//$this->global['pageTitle'] = $this->CompanyName.' : IGR Details ';
$this->global['pageTitle'] = $this->CompanyName.' : Material Receipt and Inspection Report';
$this->loadViews("materialinspectionreport", $this->global, $data,NULL);
}
/*
* For view IGR datas.(store login only)
*/
function viewinwardgateregister()
{
// $this->global['pageTitle'] = 'Resico : View Inward Gate Register';
$this->global['pageTitle'] = $this->CompanyName.' : View Inward Gate Register';
$data['IGR']= $this->mrir_model->ViewigrListing();
$this->loadViews("viewinwardgateregister",$this->global,$data,NULL);
}
/* For View MRIR Screen (view folder - view page)*/
function viewmaterialinspectionreport()
{
$this->load->model('mrir_model');
$data['viewmrirdatas'] = $this->mrir_model-> view_mrir();
//$this->global['pageTitle'] = 'Resico : View Material Inspection Report';
$this->global['pageTitle'] = $this->CompanyName.' : View Material Receipt And Inspection Report';
$this->loadViews("viewmaterialinspectionreport", $this->global,$data,NULL);
}
/* For Editing purpose MRIR datas and its has old values (View folder - edit page)*/
function editmaterialinspectionreport()
{
$this->load->model('mrir_model');
$MrirNo = $_GET['MRIRNO'];
$data['MRIRDetails'] = $this->mrir_model->edit_mrir($MrirNo);
//$this->global['pageTitle'] = 'Resico : Edit Material Inspection Report';
$this->global['pageTitle'] = $this->CompanyName.' : Edit Material Inspection Report';
$this->loadViews("Editmaterialinspectionreport", $this->global,$data,NULL);
}
/**
* TO Stored new mrir datas into DB (for insert operation)
*/
function stored_db()
{
$this->load->model('mrir_model');
$RowCount = $this->input->post('RowCount');
$igrno = $this->input->post('IGRNO');
$PONO = $this->input->post('PONO');
$CreatedBy = $this->session->userdata('userId');
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$createddt = $dt->format('Y-m-d H:i:s');
$Remark = $this->input->post('Remark');
//this array to store the value in master table..
$mrirmastervalues = array('MRIRStatus'=>MRIR_CREATED,'IGRNO'=>$igrno,'PONO'=>$PONO,'CreatedBy'=>$CreatedBy,'Createdon'=>$createddt);
$mrirmaster = $this->mrir_model->master_mrir($mrirmastervalues);
$IGRDetails = array('IGRStatus'=>MRIR_CREATED,'UpdateBY'=>$CreatedBy,'UpdatedOn'=>$createddt);
$this->mrir_model->UpdateIGRStatus($IGRDetails,$igrno);
$MRIRNO = '';
if(count($mrirmaster)>0)
{
foreach ($mrirmaster as $key ) {
$MRIRNO=$key->MRIRNo; }
}
for ($i = 1; $i <= $RowCount; $i++)
{
$MaterialCode = trim($this->input->post('MaterialCode'.$i));
$ActualQuantityReceived = trim($this->input->post('ActualQuantity'.$i));
$QuantityAsPerInvoice = trim($this->input->post('ReceivedQuantity'.$i));
$Remarked = trim($this->input->post('Remark'.$i));
$StoreIncharge = $this->session->userdata('userId');
//this array to store the value in child table..
$mrirdetailvalues = array('MRIRNO'=>$MRIRNO,'MaterialCode'=>$MaterialCode,'ActualQuantityReceived'=>$ActualQuantityReceived,'StoreInchargeID'=>$StoreIncharge,'Remarks'=>$Remarked);
$mrirdetails = $this->mrir_model->detail_mrir($mrirdetailvalues);
}
echo "successfully created : ".$MRIRNO;
}
/**
* To Stored in edited MRIR datas into DB (for update operation)
*/
function updated_db()
{
$this->load->model('mrir_model');
$mrir_no = $this->input->post('MRIRNO');
$RowCount = $this->input->post('RowCount');
$Status = $this->input->post('status');
$UPdateby=$this->session->userdata('userId');
$date = new DateTime('now',new DateTimeZone('Asia/Kolkata'));
$UPdateon = $date->format('Y-m-d H:i:s');
$PONO = $this->input->post('PONO');
//this array to store the updated value in master table..
$strStatus = '';
$strStatus = '';
$ISRejected = 0;
for ($i = 1; $i <= $RowCount; $i++)
{
$ActualQty=trim($this->input->post('ActualQuantityReceived'.$i));
$acceptquantity=trim($this->input->post('QuantityAccepted'.$i));
$rejectquantity=trim($this->input->post('QuantityRejected'.$i));
$MaterialCode = trim($this->input->post('MaterialCode'.$i));
$Lineitm = trim($this->input->post('Lineitm'.$i));
if($acceptquantity != 0 )
{
$ISRejected = 1;
$strStatus = MRIR_APPROVED;
$avlQty = 0;
$getAvailableqty = $this->mrir_model->getItemQuantityFromStock(trim($MaterialCode));
if(count($getAvailableqty)>0)
{
$avlQty = $getAvailableqty[0]['Quantity'];
}
$updatStock = array('Quantity'=>($acceptquantity+$avlQty),'Status'=>'0','UpdatedOn'=>$UPdateon,'UpdatedBy'=>$UPdateby,'Remarks'=>'Stock added for '. $this->input->post('MRIRNO'));
$this->mrir_model->UpdateStock($updatStock,trim($MaterialCode));
}
elseif($rejectquantity !=0 && $acceptquantity == 0)
{
$strStatus = MRIR_REJECTED;
}
$remark=$this->input->post('Remark'.$i);
$updateby=$this->session->userdata('userId');
$date = new DateTime('now',new DateTimeZone('Asia/Kolkata'));
$updateon = $date->format('Y-m-d H:i:s');
if(strlen($acceptquantity)<=0 && $acceptquantity == 0)
{
$rejectquantity = $ActualQty;
}
//this array to store the update value in child table..
$updatedetailvalues = array('UpdateBy'=>$updateby,'UpdatedOn'=>$updateon,'QuantityAccepted'=>$acceptquantity,'QuantityRejected'=>$rejectquantity,'Remarks'=>$remark,'MRIRStatus'=>$strStatus);
$updatedetails = $this->mrir_model->update_mrirdetail($updatedetailvalues,$Lineitm);
$POLineItem = array('Status'=>$strStatus,'UpdateBY'=>$updateby,'UpdatedOn'=>$updateon );
$this->mrir_model->UpdatePOLineItem($POLineItem,$PONO,$MaterialCode);
}
$PoMrirStatus='';
if($ISRejected==1){
$PoMrirStatus = MRIR_APPROVED;
}
else{
$PoMrirStatus = MRIR_REJECTED;
}
$updatemastervalues = array('MRIRStatus'=>$PoMrirStatus,'UpdateBY'=>$UPdateby,'UpdatedOn'=>$UPdateon);
$updatemaster = $this->mrir_model->update_mrirmaster($updatemastervalues,$mrir_no);
$this->mrir_model->UpdatePOMaster($PONO,$PoMrirStatus,$UPdateby);
echo "successfully updated :".$mrir_no;
}
/**
* For display mrir datas in modal (viewmaterialinspectionreport.php)
*/
function displaying_MRIRvalues()
{
$mrir = $this->input->post("mrirno");
$result=$this->mrir_model->get_MRIRs($mrir);
$obj=json_encode($result);
echo $obj;
}
/**
* To get igr values form ajax
*/
function displaying_IGRvalues()
{
$igr= $this->input->post("igrno");
$result=$this->mrir_model->get_IGRs($igr);
$obj = json_encode($result);
echo $obj;
}
/**
* For material issued information based on requistion
*/
function UpdateReqItemStatus()
{
$this->load->model('requistion_model');
$Values = $this->input->post('id');
$StatusCode = trim($Values[0]);
$MaterialCode = trim($Values[1]);
$ReqNumber = trim($Values[2]);
$Remarks = trim($Values[3]);
$ReqQuantity=trim($Values[4]);
$AceptedQty=trim($Values[5]);
$UpdatedBy = $this->session->userdata ( 'userId' );
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$updatedDt = $dt->format('Y-m-d H:i:s');
$getAvailableqty = $this->mrir_model->getItemQuantityFromStock($MaterialCode);
$avlQty = 0;
if(count($getAvailableqty)>0)
{
$avlQty = $getAvailableqty[0]['Quantity'];
}
$BalanceQty=0;
if($avlQty>0 && $avlQty >= $AceptedQty)
{
$BalanceQty= $avlQty - $AceptedQty;
}
$ReqDetails = array('Status'=>$StatusCode,'remarks'=>$Remarks,'UpdatedBy'=>$UpdatedBy,'UpdatedOn'=>$updatedDt,'DeliveredQuantity'=>$ReqQuantity);
$this->requistion_model->UpdateRequistionLineItem($ReqDetails,$ReqNumber,$MaterialCode);
$StoreDetails=array('Remarks'=>'Stock Dedeucted for '.$ReqNumber.' from '.$avlQty,'Quantity'=>$BalanceQty);
$this->requistion_model->UpdateAvlQty($StoreDetails,$MaterialCode);
echo "Material Issued Successfully for the Requistion: ".$ReqNumber;
}
/**
* To load pagenotfound view
*/
function pageNotFound()
{
//$this->global['pageTitle'] = 'Resico : 404 - Page Not Found';
$this->global['pageTitle'] = $this->CompanyName.' : 404 - Page Not Found';
$this->loadViews("404", $this->global, NULL, NULL);
}
}
?>