255 lines
7.9 KiB
PHP
255 lines
7.9 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);
|
|
|
|
$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,'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 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);
|
|
}
|
|
}
|
|
|
|
?>
|