211 lines
6.1 KiB
PHP
211 lines
6.1 KiB
PHP
<?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 : 8 Jun 2017
|
|
*/
|
|
class inwardgateregister extends BaseController
|
|
{
|
|
/**
|
|
* This is 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 function used to load the first screen of the user
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : Inward Gate Register';
|
|
|
|
$this->loadViews("viewinwardgateregister", $this->global,NULL , NULL);
|
|
}
|
|
|
|
|
|
function viewIGRDetails()
|
|
{
|
|
$this->load->model('inwardgateregister_model');
|
|
$this->global['pageTitle'] = 'Siddharth : Inward Gate Register Details';
|
|
$data['IGR']= $this->inwardgateregister_model->igrListing();
|
|
|
|
$this->loadViews("viewIGRDetails",$this->global,$data,NULL);
|
|
}
|
|
|
|
function addinwardgateregister()
|
|
{
|
|
|
|
$this->load->model('inwardgateregister_model');
|
|
$this->global['pageTitle'] = 'Siddharth : Add Inward Gate Register';
|
|
|
|
|
|
$data['PO_NO'] = $this->inwardgateregister_model->getpurchaseorder();
|
|
//print_r($data['PO_NO']);
|
|
|
|
$this->loadViews("inwardgateregister", $this->global, $data, NULL);
|
|
}
|
|
|
|
function getDateformat($Val)
|
|
{
|
|
$date = new DateTime($Val,new DateTimeZone('Asia/Kolkata'));
|
|
// print_r($date);
|
|
$retDate = $date->format('Y-m-d H:i:s');
|
|
return $retDate;
|
|
}
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
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');
|
|
//$Remarks = $this->input->post('Remarks');
|
|
$RowCount = $this->input->post('txtRowCount');
|
|
//echo $RowCount;
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$createddt = $dt->format('Y-m-d H:i:s');
|
|
|
|
$IGRStatus = IGR_CREATED;
|
|
|
|
|
|
//echo $RowCount;
|
|
|
|
$igr = array();
|
|
|
|
$igr = array('PONO'=>$PONO,'VehicleNo'=>$VehicleNo,'DeliveryChellanOrInvoiceNo'=>$DeliveryChellanOrInvoiceNo,'DeliveryChellanDate'=>$DeliveryChellanDate,'CourierNo'=>$CourierNo,'IGRStatus'=>$IGRStatus,'CreatedBy'=>$CreatedBy,'CreatedDate' =>$createddt);
|
|
|
|
|
|
$igrM = $this->inwardgateregister_model->addigrM($igr);
|
|
|
|
|
|
|
|
$IGRNO = '';
|
|
if(count($igrM)>0)
|
|
{
|
|
foreach ($igrM as $key ) {
|
|
$IGRNO=$key->IGRNO;
|
|
}
|
|
}
|
|
//echo $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);
|
|
//echo $QuantityAsPerInvoice;
|
|
//echo $PendingQty.'ReceivedQty'.$ReceivedQty;
|
|
//echo ' ';
|
|
|
|
if(strlen($QuantityAsPerInvoice)>0 && $QuantityAsPerInvoice != '0')
|
|
{
|
|
$Remarks = $this->input->post('txtRemarks'.$i);
|
|
$ItemStatus = '';
|
|
//if($QuantityAsPerInvoice == $OrderedQuantity)
|
|
|
|
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;
|
|
|
|
//echo '';
|
|
|
|
$POLineItem = array('ReceivedQuantity'=>$totalReceivedqty,'Status'=>$ItemStatus,'UpdateBY'=>$CreatedBy,'UpdatedOn'=>$createddt );
|
|
|
|
$this->inwardgateregister_model->UpdatePOLineItem($POLineItem,$PONO,$MaterialCode);
|
|
}
|
|
|
|
|
|
}
|
|
$this->inwardgateregister_model->UpdatePOMaster($PONO,$CreatedBy);
|
|
|
|
echo 'Successfully Created IGR Number:'. $IGRNO;
|
|
}
|
|
|
|
function ViewIGR()
|
|
{
|
|
|
|
$IGRNO= $this->input->post('id');
|
|
//print_r($IGRNO);
|
|
$data = $this->inwardgateregister_model->viewigr($IGRNO);
|
|
// print_r( $data);
|
|
|
|
echo json_encode($data);
|
|
|
|
}
|
|
function pageNotFound()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found';
|
|
|
|
$this->loadViews("404", $this->global, NULL, NULL);
|
|
}
|
|
}
|
|
|
|
?>
|