372 lines
11 KiB
PHP
372 lines
11 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : Inward Gate Register Controller (security)
|
|
* inwardgateregister to control all IGR related operations.
|
|
* @author :Venba Info Tech - Saravana kumar
|
|
* @version : 1.1
|
|
* @since :18 November 2017
|
|
*/
|
|
class inwardgateregister extends BaseController
|
|
{
|
|
/**
|
|
* default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('inwardgateregister_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 : Inward Gate Register';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Inward Gate Register';
|
|
|
|
$this->loadViews("viewinwardgateregister", $this->global,NULL , NULL);
|
|
}
|
|
|
|
/**
|
|
* To load the IGR details for View purpose.
|
|
*/
|
|
function viewIGRDetails()
|
|
{
|
|
$this->load->model('inwardgateregister_model');
|
|
//$this->global['pageTitle'] = 'Resico : Inward Gate Register Details';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Inward Gate Register Details';
|
|
$data['IGR']= $this->inwardgateregister_model->igrListing();
|
|
$this->loadViews("viewIGRDetails",$this->global,$data,NULL);
|
|
}
|
|
|
|
/**
|
|
* For add new value for the system.
|
|
*/
|
|
function addinwardgateregister()
|
|
{
|
|
|
|
$this->load->model('inwardgateregister_model');
|
|
//$this->global['pageTitle'] = 'Resico : Add Inward Gate Register';
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Inward Gate Register';
|
|
$data['PO_NO'] = $this->inwardgateregister_model->getpurchaseorder();
|
|
$this->loadViews("inwardgateregister", $this->global, $data, NULL);
|
|
}
|
|
|
|
/**
|
|
* To Convert the dateformat (date with time) and stored into DB
|
|
*/
|
|
function getDateformat($Val)
|
|
{
|
|
$date = new DateTime($Val,new DateTimeZone('Asia/Kolkata'));
|
|
$retDate = $date->format('Y-m-d H:i:s');
|
|
return $retDate;
|
|
}
|
|
|
|
/**
|
|
* To display igr lineitem datas
|
|
*/
|
|
function IGRITEM()
|
|
{
|
|
$PO = $this->input->post('id');
|
|
$CreatedBy = $this->session->userdata('userId');
|
|
$this->inwardgateregister_model->UpdatePOMaster($PO,$CreatedBy);
|
|
$data = $this->inwardgateregister_model->viewpurchaseorder($PO);
|
|
echo json_encode($data);
|
|
}
|
|
|
|
|
|
/**
|
|
* To upload IGR files
|
|
*/
|
|
function uploadFile()
|
|
{
|
|
|
|
$pathinfo = pathinfo($_FILES['myfile']['name']);
|
|
$config['upload_path'] = 'uploads/Igrfiles/';
|
|
$config['allowed_types'] = 'png|jpg|jpeg|pdf|docx';
|
|
$config['file_name'] = $_FILES['myfile']['name'];
|
|
|
|
//Load upload library and initialize configuration
|
|
$this->load->library('upload',$config);
|
|
$this->upload->initialize($config);
|
|
|
|
|
|
if($this->upload->do_upload('myfile'))
|
|
{
|
|
$uploadData = $this->upload->data();
|
|
$uploadfilename = $uploadData['file_name'];
|
|
return $uploadfilename;
|
|
|
|
}
|
|
else
|
|
{
|
|
$error = array('error' => $this->upload->display_errors());
|
|
$uploadfilename = '';
|
|
print_r($error);
|
|
return 0;
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* To Store IGR data into DB
|
|
*/
|
|
function addNewigr()
|
|
{
|
|
|
|
|
|
$PONO = $this->input->post('PONO');
|
|
|
|
$DeliveryChellanOrInvoiceNo = $this->input->post('InvoiceNo');
|
|
|
|
$DeliveryChellan = $this->input->post('InvoiceDate');
|
|
$DeliveryChellanDate = $this->getDateformat($DeliveryChellan);
|
|
|
|
|
|
$Mat_Rcvd_Dt = $this->input->post('MaterialRcvdDate');
|
|
$MaterialRcvdDt = $this->getDateformat($Mat_Rcvd_Dt);
|
|
|
|
|
|
$VehicleNo = $this->input->post('VehicleNo');
|
|
$CourierNo = $this->input->post('CourierNo');
|
|
|
|
|
|
$CreatedBy = $this->session->userdata('userId');
|
|
$RowCount = $this->input->post('txtRowCount');
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$createddt = $dt->format('Y-m-d H:i:s');
|
|
|
|
$IGRStatus = IGR_CREATED;
|
|
|
|
$document = null;
|
|
|
|
$fs = 0;
|
|
if(!empty($_FILES['myfile']['name']))
|
|
{
|
|
|
|
$config['file_name'] = $_FILES['myfile']['name'];
|
|
$config['upload_path'] = 'uploads/Igrfiles/';
|
|
$config['allowed_types'] = 'png|jpg|jpeg|pdf|docx';
|
|
$path = $config['upload_path'];
|
|
$filename = $config['file_name'];
|
|
$document = $path.$filename;
|
|
|
|
$fs = $this->uploadFile();
|
|
$document = $path.$fs;
|
|
|
|
}
|
|
|
|
|
|
$igr = array();
|
|
|
|
$igr = array('PONO'=>$PONO,'VehicleNo'=>$VehicleNo,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanOrInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'MaterialRcvdDate'=>$MaterialRcvdDt,'CourierNo'=>$CourierNo,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt,'file'=>$document);
|
|
|
|
|
|
$igrM = $this->inwardgateregister_model->addigrM($igr);
|
|
|
|
$IGRNO = '';
|
|
if(count($igrM)>0)
|
|
{
|
|
foreach ($igrM as $key ) {
|
|
$IGRNO=$key->IGRNO;
|
|
}
|
|
}
|
|
|
|
|
|
$IGRItemStatus = REQITEM_NEW;
|
|
|
|
|
|
for ($i = 1; $i <= $RowCount; $i++)
|
|
{
|
|
$MaterialCode = trim($this->input->post('MaterialCode'.$i));
|
|
$QuantityAsPerInvoice = trim($this->input->post('txtQuantityAsPerInvoice'.$i));
|
|
$OrderedQuantity = trim($this->input->post('OrderedQuantity'.$i));
|
|
$ReceivedQty = trim($this->input->post('txtReceivedQuantity'.$i));
|
|
$PendingQty = $this->input->post('txtPendingQty'.$i);
|
|
|
|
if(strlen($QuantityAsPerInvoice)>0 && $QuantityAsPerInvoice != '0')
|
|
{
|
|
$Remarks = $this->input->post('txtRemarks'.$i);
|
|
$ItemStatus = '';
|
|
|
|
if($PendingQty == 0.00 )
|
|
{
|
|
$ItemStatus = IGR_CREATED;
|
|
}
|
|
else
|
|
{
|
|
$ItemStatus = POLINEITEM_IGRPARTIAL_CREATED;
|
|
}
|
|
|
|
$CreatedBy = $this->session->userdata('userId');
|
|
|
|
$igrDetails = array('IGRNO'=>$IGRNO,'MaterialCode'=>$MaterialCode,'QuantityAsPerInvoice'=>$QuantityAsPerInvoice,'Remarks'=>$Remarks,'IGRItemStatus'=>$IGRItemStatus,'CreatedBy'=>$CreatedBy,'CreatedDate'=>$createddt);
|
|
$igrD = $this->inwardgateregister_model->addigrD($igrDetails);
|
|
$Recqty = $this->inwardgateregister_model->getPOLineItemReceivedQty($PONO,$MaterialCode);
|
|
$ReceivedQuantity = 0.00;
|
|
|
|
if(count($Recqty)>0)
|
|
{
|
|
foreach ($Recqty as $key ) {
|
|
$ReceivedQuantity=$key->ReceivedQuantity;
|
|
}
|
|
}
|
|
|
|
$totalReceivedqty = $ReceivedQuantity + $QuantityAsPerInvoice;
|
|
|
|
$POLineItem = array('ReceivedQuantity'=>$totalReceivedqty,'Status'=>$ItemStatus,'UpdateBY'=>$CreatedBy,'UpdatedOn'=>$createddt );
|
|
|
|
$this->inwardgateregister_model->UpdatePOLineItem($POLineItem,$PONO,$MaterialCode);
|
|
}
|
|
|
|
|
|
}
|
|
$this->inwardgateregister_model->UpdatePOMaster($PONO,$CreatedBy);
|
|
|
|
echo "<script>alert('Successfully Created IGR Number:$IGRNO'); window.location.href='viewIGRDetails';</script>";
|
|
}
|
|
|
|
/**
|
|
*To get igr Datas form ajax
|
|
*/
|
|
function ViewIGR()
|
|
{
|
|
|
|
$IGRNO= $this->input->post('id');
|
|
$data = $this->inwardgateregister_model->viewigr($IGRNO);
|
|
echo json_encode($data);
|
|
|
|
}
|
|
|
|
/**
|
|
*To Update igr Datas form ajax
|
|
*/
|
|
function UpdateIGR()
|
|
{
|
|
|
|
$IGRNo = $this->input->post('igr');
|
|
|
|
$DeliveryChellan = $this->input->post('invdate');
|
|
$DeliveryChellanDate = $this->getDateformat($DeliveryChellan);
|
|
|
|
$Mat_Rcvd_Dt = $this->input->post('mrc');
|
|
$MaterialRcvdDt = $this->getDateformat($Mat_Rcvd_Dt);
|
|
|
|
$updateby = $this->session->userdata('userId');
|
|
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$updatedon = $dt->format('Y-m-d H:i:s');
|
|
|
|
|
|
$igrarr = array('DeliveryChellanDate'=>$DeliveryChellanDate,'MaterialRcvdDate'=>$MaterialRcvdDt,'UpdateBY'=>$updateby,'UpdatedOn'=>$updatedon);
|
|
|
|
$data = $this->inwardgateregister_model->updateigr($igrarr,$IGRNo);
|
|
|
|
if($data > 0){
|
|
echo "Updated Succefully!";
|
|
}
|
|
else{
|
|
echo "Not Updated!";
|
|
}
|
|
|
|
}
|
|
|
|
function addoutwardgateregister()
|
|
{
|
|
|
|
$this->load->model('inwardgateregister_model');
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Add Outward Gate Register';
|
|
|
|
$data['Customer'] = $this->inwardgateregister_model->getCustomer();
|
|
$data['Supplier'] = $this->inwardgateregister_model->getSupplier();
|
|
$data['storedmaterialcode'] = $this->inwardgateregister_model->getstoredmaterialcode();
|
|
|
|
$this->loadViews("ogr", $this->global, $data, NULL);
|
|
|
|
}
|
|
|
|
function GetInvoices()
|
|
{
|
|
|
|
$CustomerId = $this->input->post('customerId');
|
|
|
|
$data = $this->inwardgateregister_model->getInvoice($CustomerId);
|
|
echo json_encode($data);
|
|
}
|
|
|
|
function GetPO()
|
|
{
|
|
$supplierId = $this->input->post('supplierId');
|
|
|
|
$data = $this->inwardgateregister_model->getPO($supplierId);
|
|
echo json_encode($data);
|
|
}
|
|
|
|
function getPODetails()
|
|
{
|
|
$PONO = $this->input->post('PONO');
|
|
$data = $this->inwardgateregister_model->getPODetails($PONO);
|
|
//$data['poout'] = $this->inwardgateregister_model->getPODetails($PONO);
|
|
|
|
echo json_encode($data);
|
|
}
|
|
|
|
function getPOmrir()
|
|
{
|
|
$PONO = $this->input->post('PONO');
|
|
$data = $this->inwardgateregister_model->getPOmrir($PONO);
|
|
//$data['poout'] = $this->inwardgateregister_model->getPODetails($PONO);
|
|
echo json_encode($data);
|
|
}
|
|
|
|
function getMRIRDetails()
|
|
{
|
|
$MRIRno = $this->input->post('mrirno');
|
|
$PONO = $this->input->post('PONO');
|
|
$materialcode = $this->input->post('materialcode');
|
|
$data = $this->inwardgateregister_model->getPOMRIRDetails($MRIRno,$PONO,$materialcode);
|
|
|
|
echo json_encode($data);
|
|
|
|
}
|
|
|
|
function ViewOgr()
|
|
{
|
|
$this->load->model('inwardgateregister_model');
|
|
$this->global['pageTitle'] = $this->CompanyName.' : View Outward Gate Register';
|
|
$data['OGR_Data'] = $this->inwardgateregister_model->getOGRData();
|
|
$this->loadViews("ogrlist", $this->global, $data, NULL);
|
|
|
|
}
|
|
|
|
|
|
function EditOGR()
|
|
{
|
|
$OGRNO = $_GET['OGRNO'];
|
|
$MRIRNO = $_GET['MRIRNO'];
|
|
$this->global['pageTitle'] = $this->CompanyName.' : View Outward Gate Register';
|
|
$data['OGR_Data'] = $this->inwardgateregister_model->getOGRDataforedit($OGRNO);
|
|
$data['OGR_line'] = $this->inwardgateregister_model->getOGRlineDataforedit($OGRNO,$MRIRNO);
|
|
$this->loadViews("editogr", $this->global, $data, NULL);
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
}
|
|
|
|
?>
|