159 lines
4.6 KiB
PHP
Executable File
159 lines
4.6 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : Supplier Controller (supplier)
|
|
* User Class to control all user related operations.
|
|
* @author : Saravana kumar
|
|
* @version : 1.1
|
|
* @since : 4 July 2017
|
|
*/
|
|
class storestatus extends BaseController
|
|
{
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('store_model');
|
|
$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 Industries : Store Status';
|
|
|
|
$this->loadViews("storestatus", $this->global, NULL , NULL);
|
|
}
|
|
|
|
/**
|
|
* This function is used to load the Supplier list
|
|
*/
|
|
function storeavailability()
|
|
{
|
|
|
|
//$this->load->model('supplier_model');
|
|
|
|
|
|
//$data['userRecords'] = $this->supplier_model->supplierListing();
|
|
|
|
$this->global['pageTitle'] = 'Siddharth Industries : Store Status';
|
|
//viewStock
|
|
$data['Stock'] = $this->store_model->viewStock();
|
|
|
|
// print_r($data['Stock']);
|
|
$data['MaterialList'] = $this->store_model->GetAllMaterialList();
|
|
$data['StockStatus'] = $this->store_model->GetConfigValue('C021');
|
|
$this->loadViews("storestatus", $this->global, $data,null);
|
|
|
|
}
|
|
|
|
/**
|
|
* This function is used to load the Supplier list
|
|
*/
|
|
function AddStock()
|
|
{
|
|
|
|
$MaterialCode = $this->input->post('MaterialCode');
|
|
$AvailableQty = $this->input->post('AddAvailableStock');
|
|
$AvailbilityStatus = $this->input->post('StockAvail');
|
|
$Remarks = $this->input->post('Remarks');
|
|
$CreatedBy = $this->session->userdata('EmpID');
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$createddt = $dt->format('Y-m-d H:i:s');
|
|
$Status = 1;
|
|
if(trim($AvailbilityStatus) == 'YES')
|
|
{
|
|
$Status = 0;
|
|
}
|
|
|
|
|
|
//this array to store the value in master table..
|
|
$Stockdetails = array('MaterialCode'=>$MaterialCode,'Quantity'=>$AvailableQty,'Status'=>$Status,'Remarks'=>$Remarks, 'CreatedBy'=>$CreatedBy,'Createdon'=>$createddt);
|
|
|
|
$data['Stock'] = $this->store_model->addStock($Stockdetails);
|
|
echo 'Stock Added successfully';
|
|
|
|
|
|
}
|
|
|
|
function UpdateStock()
|
|
{
|
|
|
|
$MaterialCode = $this->input->post('EditMaterialCode');
|
|
$AvailableQty = $this->input->post('EditAvailableStock');
|
|
$AvailbilityStatus = $this->input->post('EditStockAvail');
|
|
$Remarks = $this->input->post('EditRemarks');
|
|
$CreatedBy = $this->session->userdata('EmpID');
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$createddt = $dt->format('Y-m-d H:i:s');
|
|
$Status = 1;
|
|
if(trim($AvailbilityStatus) == 'YES')
|
|
{
|
|
$Status = 0;
|
|
}
|
|
|
|
|
|
//this array to store the value in master table..
|
|
$Stockdetails = array('Quantity'=>$AvailableQty,'Status'=>$Status,'Remarks'=>$Remarks, 'UpdatedBy'=>$CreatedBy,'updatedOn'=>$createddt);
|
|
|
|
$data['Stock'] = $this->store_model->UpdateStock($Stockdetails,$MaterialCode);
|
|
echo 'Stock updated successfully';
|
|
|
|
|
|
}
|
|
|
|
function viewStockHistory()
|
|
{
|
|
|
|
$MaterialCode= $this->input->post('id');
|
|
|
|
$result = $this->store_model->GetStockHisory($MaterialCode);
|
|
|
|
$TotalStock = 0;
|
|
$HTML="";
|
|
for ($i = 0; $i < count($result); $i++)
|
|
{
|
|
$SNo = $i + 1;
|
|
|
|
$AvailableQty = $result[$i]['Quantity'];
|
|
$UpdatedStock = $result[$i]['ActualQuantity'];
|
|
$Remarks = $result[$i]['Remarks'];
|
|
$Updatedon= new DateTime($result[$i]['updatedOn']);
|
|
|
|
|
|
$HTML.="<tr id='".$i."'>
|
|
<td align='left'>".$SNo."</td>
|
|
<td align='left'>". $AvailableQty."</td>
|
|
|
|
<td align='left'>".$UpdatedStock."</td>
|
|
<td align='left'>".$Updatedon->format('d-m-Y')."</td>
|
|
<td align='left'>".$Remarks."</td>
|
|
|
|
|
|
</tr>";
|
|
$TotalStock = $TotalStock + $UpdatedStock;
|
|
//$index = $index + 1;
|
|
|
|
}
|
|
//print_r($HTML);
|
|
//echo $AvilBudAmt;
|
|
die(json_encode(array('History' =>$HTML,'AvalStock'=>$TotalStock)));
|
|
}
|
|
|
|
function pageNotFound()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found';
|
|
|
|
$this->loadViews("404", $this->global, NULL, NULL);
|
|
}
|
|
}
|
|
|
|
?>
|