siddharth_application/application/controllers/inwardgateregister.php
2017-07-07 17:47:36 +05:30

194 lines
5.5 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 : 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 viewinwardgateregister()
{
$this->load->model('inwardgateregister_model');
$this->global['pageTitle'] = 'Siddharth : Inward Gate Register';
$data['IGR']= $this->inwardgateregister_model->igrListing();
$this->loadViews("viewinwardgateregister",$this->global,$data,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');
$data = $this->inwardgateregister_model->viewpurchaseorder($PO);
//print_r($data);
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 = $this->input->post('MaterialCode'.$i);
$QuantityAsPerInvoice = $this->input->post('ReceivedQuantity'.$i);
$OrderedQuantity = $this->input->post('OrderedQuantity'.$i);
//echo 'OrderedQunatity'.$OrderedQuantity;
//echo 'QuantityAsPerInvoice'.$QuantityAsPerInvoice;
if(strlen($QuantityAsPerInvoice)>0)
{
$Remarks = $this->input->post('txtRemarks'.$i);
$ItemStatus = '';
if($QuantityAsPerInvoice == $OrderedQuantity)
{
$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);
$POLineItem = array('Status'=>$ItemStatus,'UpdateBY'=>$CreatedBy,'UpdatedOn'=>$createddt );
$this->inwardgateregister_model->UpdatePOLineItem($POLineItem,$PONO,$MaterialCode);
}
echo $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);
}
}
?>