siddharth_application/application/controllers/MRIRcontroller.php
gandhimathi Bharathirajan 8f9a34d3c3 Department Issue fixed
2017-07-30 03:55:03 +05:30

310 lines
11 KiB
PHP
Executable File

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : Inward Gate Register Controller (security)
* User Class to control all user related operations.
* @author : Saravana kumar
* @version : 1.1
* @since : 10 Jun 2017
*/
class MRIRcontroller extends BaseController
{
/**
* This is 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 function used to load the first screen of the user
*/
public function index()
{
$this->global['pageTitle'] = 'Siddharth : View material inspection report';
$this->loadViews("viewmaterialinspectionreport", $this->global,NULL , NULL);
}
/* For Entry MRIR Screen*/
function materialinspectionreport($mrir='',$IGRNO='')
{
$this->global['pageTitle'] = 'Siddharth : Material Inspection Report';
$this->load->model('mrir_model');
$data['IGRNOonly'] = $this->mrir_model->getIGRNOonly();
$this->loadViews("materialinspectionreport", $this->global,$data,NULL);
}
public function MrirDetailsPrintPdf()
{
$MrirNo = $_GET['MRIRNO'];
// echo $MrirNo;
$this->global['pageTitle'] = 'Siddharth : MRIR Pdf ';
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
//print_r($data['CompanyDetails']);
$data['MRIRDetails'] = $this->purchaseorder_model->edit_mrir($MrirNo);
//print_r($data['MRIRDetails']);
$this->load->View("Mrirprintpdf",$data, NULL);
// Get output html
$php = $this->output->get_output();
// Load library
$this->load->library('dompdf_gen');
// Convert to PDF
$this->dompdf->load_html($php);
$this->dompdf->render();
$data['Attachment'] = FALSE;
$this->dompdf->stream("MrirDetails.pdf",$data,$php);
}
public function viewmrirforbilling()
{
$this->global['pageTitle'] = 'Siddharth : Billing ';
$data['Billing'] = $this->mrir_model->view_mrir_Billing();
$this->loadViews("viewmrirforbilling", $this->global,$data , NULL);
}
public function viewmMaterialDistributionList()
{
$this->global['pageTitle'] = 'Siddharth : Distribution list ';
$data['Distribution'] = $this->mrir_model->ViewDistributionList();
$this->loadViews("MaterialIssueList", $this->global,$data , NULL);
}
/*FOR Displaying IGR Values (view folder- IGR view page (button link)) */
function igrdatavalues()
{
$IgrNo= $_GET['IGRNO'];
$data['IGRDetails'] = $this->mrir_model->get_IGR($IgrNo);
$this->global['pageTitle'] = 'Siddharth : IGR Details ';
$this->loadViews("materialinspectionreport", $this->global, $data,NULL);
}
function viewinwardgateregister()
{
$this->global['pageTitle'] = 'Siddharth : 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();
//old name:mrirdatas2
$this->global['pageTitle'] = 'Siddharth : View Material Inspection Report';
//print_r( $data);
$this->loadViews("viewmaterialinspectionreport", $this->global,$data,NULL);
}
/* FOR Edit MRIR Screen (View folder - edit page)*/
function editmaterialinspectionreport()
{
$this->load->model('mrir_model');
$MrirNo = $_GET['MRIRNO'];
$data['MRIRDetails'] = $this->mrir_model->edit_mrir($MrirNo);//get_MRIR_Values($MrirNo);
$this->global['pageTitle'] = 'Siddharth : Edit Material Inspection Report';
$this->loadViews("Editmaterialinspectionreport", $this->global,$data,NULL);
}
/* NEW Values TO Stored in DB (for insert operation) */
function stored_db()//old name : displaying_values()
{
$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 = $this->input->post('MaterialCode'.$i);
$ActualQuantityReceived = $this->input->post('ActualQuantity'.$i);
$QuantityAsPerInvoice = $this->input->post('ReceivedQuantity'.$i);
$Remarked = $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;
}
/* Values To Stored in 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');
//this array to store the updated value in master table..
$updatemastervalues = array('MRIRStatus'=>$Status,'UpdateBY'=>$UPdateby,'UpdatedOn'=>$UPdateon);
$updatemaster = $this->mrir_model->update_mrirmaster($updatemastervalues,$mrir_no);
$strStatus = '';
//echo "outside for loop";
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));
//echo $acceptquantity;
if(strlen($acceptquantity)>0)
{
$strStatus = MRIR_APPROVED;
$avlQty = 0;
$getAvailableqty = $this->mrir_model->getItemQuantityFromStock(trim($MaterialCode));
// print_r( $getAvailableqty);
if(count($getAvailableqty)>0)
{
$avlQty = $getAvailableqty[0]['Quantity'];
}
// echo $avlQty;
//echo 'Stock added for'.$mrir_no;
$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(strlen($acceptquantity)==0 && strlen($rejectquantity)>0)
{
$strStatus = MRIR_REJECTED;
}
$remark=$this->input->post('Remarks1'.$i);
$updateby=$this->session->userdata('userId');
$date = new DateTime('now',new DateTimeZone('Asia/Kolkata'));
$updateon = $date->format('Y-m-d H:i:s');
echo strlen($acceptquantity);
if(strlen($acceptquantity)<=0)
{
$rejectquantity = $ActualQty;
//echo 'Reject qty'.$rejectquantity;
}
//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);
}
echo "successfully updated :".$mrir_no;
}
/*in view screen we display values for modal (viewmaterialinspectionreport.php)*/
function displaying_MRIRvalues()
{
$mrir = $this->input->post("mrirno");
$result=$this->mrir_model->get_MRIRs($mrir);
$obj=json_encode($result);
echo $obj;
}
function displaying_IGRvalues()
{
$igr= $this->input->post("igrno");
$result=$this->mrir_model->get_IGRs($igr);
$obj = json_encode($result);
echo $obj;
}
function pageNotFound()
{
$this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found';
$this->loadViews("404", $this->global, NULL, NULL);
}
}
?>