179 lines
5.3 KiB
PHP
179 lines
5.3 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
use App\Models\Assetdetails_model;
|
|
use App\Models\Batchcard_model;
|
|
use App\Models\Cashbook_model;
|
|
use App\Models\Companydetails_model;
|
|
use App\Models\Config_model;
|
|
use App\Models\Costcenter_model;
|
|
use App\Models\Dashboard_Model;
|
|
use App\Models\Department_model;
|
|
use App\Models\Employeedetails_model;
|
|
use App\Models\Emppaydate_model;
|
|
use App\Models\Inwardgateregister_model;
|
|
use App\Models\Login_model;
|
|
use App\Models\Monthlypay_model;
|
|
use App\Models\Mrir_model;
|
|
use App\Models\Payroll_model;
|
|
use App\Models\Purchaseorder_model;
|
|
use App\Models\Quality_model;
|
|
use App\Models\Rawmaterialdetails_model;
|
|
use App\Models\Requistion_model;
|
|
use App\Models\Store_model;
|
|
use App\Models\Storerequistion_model;
|
|
use App\Models\Supplier_model;
|
|
use App\Models\User_model;
|
|
use App\Models\Zohobook_api_model;
|
|
/**
|
|
* Module - Store
|
|
* Storestatus Class to control all Storestatus related operations.
|
|
* @author : Saravana kumar
|
|
* @version : 1.1
|
|
* @since : 4 July 2017
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Storestatus extends BaseController
|
|
{
|
|
|
|
protected $supplier_model;
|
|
protected $store_model;
|
|
protected $session;
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$store_model = new Store_model();
|
|
$this->session = session();
|
|
// $this->supplier_model = new Supplier_model();
|
|
helper('form'); //$this->load->library('form_validation');
|
|
$this->isLoggedIn();
|
|
|
|
|
|
|
|
}
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->global['pageTitle'] = 'Store Status';
|
|
|
|
$this->loadViews("storestatus", $this->global, NULL, NULL);
|
|
}
|
|
|
|
/**
|
|
* This function is used to load the Supplier list
|
|
*/
|
|
function storeavailability()
|
|
{
|
|
|
|
//$data['userRecords'] = $this->supplier_model->supplierlisting();
|
|
|
|
$this->global['pageTitle'] = '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->request->getPost('MaterialCode');
|
|
$AvailableQty = $this->request->getPost('AddAvailableStock');
|
|
$AvailbilityStatus = $this->request->getPost('StockAvail');
|
|
$Remarks = $this->request->getPost('Remarks');
|
|
$CreatedBy = $this->session->get('EmpID');
|
|
|
|
$createddt = get_current_date_time();
|
|
$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->request->getPost('EditMaterialCode');
|
|
$AvailableQty = $this->request->getPost('EditAvailableStock');
|
|
$AvailbilityStatus = $this->request->getPost('EditStockAvail');
|
|
$Remarks = $this->request->getPost('EditRemarks');
|
|
$CreatedBy = $this->session->get('EmpID');
|
|
$createddt = get_current_date_time();
|
|
$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->request->getPost('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)));
|
|
}
|
|
|
|
|
|
}
|