changes in stock controller
This commit is contained in:
parent
f6573a31db
commit
ab5e5b10a1
@ -85,14 +85,13 @@ class StockController extends BaseController
|
||||
$this->isLoggedIn();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
//Coating Machine Details starts
|
||||
|
||||
public function loadView_coatingMachineDetails(){
|
||||
public function loadView_coatingMachineDetails(){
|
||||
|
||||
if ($this->request->getMethod() === 'POST'){
|
||||
$month = $this->request->getPost('month');
|
||||
@ -104,7 +103,9 @@ class StockController extends BaseController
|
||||
$month=$formattedDate;
|
||||
}
|
||||
else{
|
||||
$month = date('Y-m');
|
||||
|
||||
$filteredMonth=$this->request->getGet('month');
|
||||
$month = $filteredMonth ?? date('Y-m');
|
||||
}
|
||||
|
||||
$this->global['pageTitle'] = 'Coating Machine Details ';
|
||||
@ -127,12 +128,13 @@ class StockController extends BaseController
|
||||
|
||||
return $this->loadViews("CoatingMachineDetail", $this->global, $data, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function addNewCoatingMachineDetails(){
|
||||
public function addNewCoatingMachineDetails(){
|
||||
|
||||
$postData=$this->request->getPost();
|
||||
|
||||
$month =$this->request->getGet('month');
|
||||
$month = DateTime::createFromFormat('M-Y', $month)->format('Y-m');
|
||||
|
||||
$date = $postData['date'];
|
||||
$shift = $postData['shift'];
|
||||
@ -144,44 +146,59 @@ class StockController extends BaseController
|
||||
->first();
|
||||
|
||||
if(!empty($sameShiftOnDateExists)){
|
||||
|
||||
return redirect()->back()->with('error', 'Already same shift exists on the same date ..!!');
|
||||
}
|
||||
|
||||
|
||||
$inserted= $this->coatingMachineDetails_model->insert($postData);
|
||||
|
||||
if ($inserted) {
|
||||
//update Gas stock consumption if insert is successfull..!!
|
||||
$dateToBeInserted = $postData['date'];
|
||||
$consumption = $postData['totalGasConsumption'];
|
||||
$this->updateGasStockConsumption($dateToBeInserted , $consumption);
|
||||
|
||||
// Set flashdata for success message
|
||||
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details updated successfully');
|
||||
return redirect()->to("/coatingMachineDetails?month=$month")->with('success', 'Coating Machine details updated successfully');
|
||||
} else {
|
||||
// Set flashdata for error message
|
||||
return redirect()->back()->with('error', 'Failed to update Coating machine details');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function updateCoatingMachineDetails(){
|
||||
public function updateCoatingMachineDetails(){
|
||||
|
||||
$putData=$this->request->getPost();
|
||||
$month =$this->request->getGet('month');
|
||||
$month = DateTime::createFromFormat('M-Y', $month)->format('Y-m');
|
||||
|
||||
$id = $putData['editCoatingMachineDetailId'];
|
||||
|
||||
$updated= $this->coatingMachineDetails_model->update($id,$putData);
|
||||
|
||||
if ($updated) {
|
||||
//update Gas stock consumption if update is successfull..!!
|
||||
$dateToBeUpdated = $putData['date'];
|
||||
|
||||
$existingCoatingGasConsumption = $putData['existingTotalGasConsumption'];
|
||||
$updatedCoatingGasConsumption = $putData['totalGasConsumption'];
|
||||
if( $existingCoatingGasConsumption != $updatedCoatingGasConsumption ){
|
||||
$changeInConsumption = $updatedCoatingGasConsumption - $existingCoatingGasConsumption;
|
||||
$this->updateGasStockConsumption($dateToBeUpdated , $changeInConsumption);
|
||||
}
|
||||
|
||||
// Set flashdata for success message
|
||||
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details updated successfully');
|
||||
return redirect()->to("/coatingMachineDetails?month=$month")->with('success', 'Coating Machine details updated successfully');
|
||||
} else {
|
||||
// Set flashdata for error message
|
||||
return redirect()->back()->with('error', 'Failed to update Coating machine details');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteCoatingMachineDetails(){
|
||||
public function deleteCoatingMachineDetails(){
|
||||
|
||||
$id = $this->request->getGet('id');
|
||||
|
||||
@ -196,11 +213,10 @@ class StockController extends BaseController
|
||||
// Set flashdata for error message
|
||||
return redirect()->back()->with('error', 'Failed to delete Coating machine details');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//incoming Silica Sand Details starts
|
||||
|
||||
public function loadView_incomingSilicaSandDetails(){
|
||||
public function loadView_incomingSilicaSandDetails(){
|
||||
|
||||
if ($this->request->getMethod() === 'POST'){
|
||||
$month = $this->request->getPost('month');
|
||||
@ -236,9 +252,9 @@ class StockController extends BaseController
|
||||
|
||||
return $this->loadViews("incomingSilicaSandDetails", $this->global, $data, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function updateIncomingSilicaSandDetails(){
|
||||
public function updateIncomingSilicaSandDetails(){
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
@ -306,11 +322,11 @@ class StockController extends BaseController
|
||||
|
||||
echo "Data Saved Successfully";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Bag Stock details starts
|
||||
|
||||
public function loadView_bagStockDetails(){
|
||||
public function loadView_bagStockDetails(){
|
||||
|
||||
if ($this->request->getMethod() === 'POST'){
|
||||
$month = $this->request->getPost('month');
|
||||
@ -408,9 +424,9 @@ class StockController extends BaseController
|
||||
|
||||
return $this->loadViews("bagStockDetails", $this->global, $data, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function updateBagStockDetails(){
|
||||
public function updateBagStockDetails(){
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
@ -469,12 +485,11 @@ class StockController extends BaseController
|
||||
|
||||
echo "Data Saved Successfully";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Dust And Rough Stock Details
|
||||
|
||||
public function loadView_dustAndRoughStockDetails(){
|
||||
public function loadView_dustAndRoughStockDetails(){
|
||||
|
||||
if ($this->request->getMethod() === 'POST'){
|
||||
$month = $this->request->getPost('month');
|
||||
@ -511,9 +526,9 @@ class StockController extends BaseController
|
||||
|
||||
return $this->loadViews("dustAndRoughStockDetails", $this->global, $data, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function updateDustAndRoughStockDetails(){
|
||||
public function updateDustAndRoughStockDetails(){
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
@ -567,12 +582,11 @@ class StockController extends BaseController
|
||||
|
||||
echo "Data Saved Successfully";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Resin Stock Details
|
||||
|
||||
public function loadView_resinStockDetails(){
|
||||
public function loadView_resinStockDetails(){
|
||||
|
||||
if ($this->request->getMethod() === 'POST'){
|
||||
|
||||
@ -669,9 +683,9 @@ class StockController extends BaseController
|
||||
|
||||
return $this->loadViews("resinStockDetails", $this->global, $data, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function updateResinStockDetails(){
|
||||
public function updateResinStockDetails(){
|
||||
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
@ -732,12 +746,11 @@ class StockController extends BaseController
|
||||
|
||||
echo "Data Saved Successfully";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Gas Stock Details
|
||||
|
||||
public function loadView_gasStockDetails(){
|
||||
public function loadView_gasStockDetails(){
|
||||
|
||||
if ($this->request->getMethod() === 'POST'){
|
||||
|
||||
@ -800,9 +813,9 @@ class StockController extends BaseController
|
||||
$data['month'] = DateTime::createFromFormat('Y-m', $month)->format('M-Y');
|
||||
|
||||
return $this->loadViews("gasStockDetails", $this->global, $data, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateGasStockDetails(){
|
||||
public function updateGasStockDetails(){
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
@ -859,11 +872,9 @@ class StockController extends BaseController
|
||||
}
|
||||
|
||||
echo "Data Saved Successfully";
|
||||
}
|
||||
|
||||
private function updateGasStockConsumption($date , $consumption){
|
||||
|
||||
}
|
||||
|
||||
private function updateGasStockConsumption($date , $consumption){
|
||||
|
||||
$resultExists = $this->gasStockDetails_model
|
||||
->where('date',$date)
|
||||
@ -908,17 +919,16 @@ class StockController extends BaseController
|
||||
|
||||
if(!empty($inserts)){
|
||||
$this->gasStockDetails_model->insertBatch($inserts);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------gwm----------------------------------------------
|
||||
|
||||
|
||||
function getMonthDatesFromInput($monthYear) {
|
||||
public function getMonthDatesFromInput($monthYear) {
|
||||
|
||||
$date = DateTime::createFromFormat('M-Y', $monthYear);
|
||||
|
||||
@ -943,10 +953,9 @@ class StockController extends BaseController
|
||||
}
|
||||
|
||||
return $dates;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function generateTimeOptions() {
|
||||
public function generateTimeOptions() {
|
||||
$times = [];
|
||||
$start = strtotime('00:00'); // Start at midnight (12:00 AM)
|
||||
$end = strtotime('23:45'); // End at 11:45 PM
|
||||
@ -959,10 +968,9 @@ class StockController extends BaseController
|
||||
}
|
||||
|
||||
return $times;
|
||||
}
|
||||
}
|
||||
|
||||
function drierMachineDetails()
|
||||
{
|
||||
public function drierMachineDetails(){
|
||||
|
||||
|
||||
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y');
|
||||
@ -994,10 +1002,9 @@ class StockController extends BaseController
|
||||
|
||||
$this->global['pageTitle'] = 'Drier Details';
|
||||
$this->loadViews("drierMachineDetails", $this->global, $data, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
public function addOrEditdrierMachineDetails()
|
||||
{
|
||||
public function addOrEditdrierMachineDetails(){
|
||||
$drierData = json_decode($this->request->getPost('drierData'), true);
|
||||
|
||||
if (empty($drierData)) {
|
||||
@ -1055,10 +1062,9 @@ class StockController extends BaseController
|
||||
}
|
||||
|
||||
echo "Data successfully saved.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function factoryVehicleDieselDetails()
|
||||
public function factoryVehicleDieselDetails()
|
||||
{
|
||||
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y');
|
||||
|
||||
@ -1126,9 +1132,9 @@ class StockController extends BaseController
|
||||
$this->global['pageTitle'] = 'Drier Details';
|
||||
$this->loadViews("factoryDieselMachineDetails", $this->global, $data, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getDieselConsumptionPivot($machineDetails , $startDate , $endDeate)
|
||||
public function getDieselConsumptionPivot($machineDetails , $startDate , $endDeate)
|
||||
{
|
||||
$machineIds = array_column($machineDetails, 'id');
|
||||
|
||||
@ -1153,9 +1159,9 @@ class StockController extends BaseController
|
||||
$result = $query->getResultArray();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function addOrEditfactoryVehicleDieselDetails()
|
||||
public function addOrEditfactoryVehicleDieselDetails()
|
||||
{
|
||||
$dieselMachineTableData = json_decode($this->request->getPost('dieselMachineTableData'), true);
|
||||
|
||||
@ -1217,10 +1223,10 @@ class StockController extends BaseController
|
||||
|
||||
echo "Data successfully saved.";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function powerConsumptionDetails()
|
||||
public function powerConsumptionDetails()
|
||||
{
|
||||
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y');
|
||||
|
||||
@ -1261,10 +1267,9 @@ class StockController extends BaseController
|
||||
$this->global['pageTitle'] = 'Power Consumption Details';
|
||||
$this->loadViews("powerConsumptionDetails", $this->global, $data, NULL);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getElectricConsumptionPivot($machineDetails , $startDate , $endDeate)
|
||||
{
|
||||
public function getElectricConsumptionPivot($machineDetails , $startDate , $endDeate) {
|
||||
$machineIds = array_column($machineDetails, 'id');
|
||||
|
||||
if (empty($machineIds)) { return []; }
|
||||
@ -1288,10 +1293,9 @@ class StockController extends BaseController
|
||||
$result = $query->getResultArray();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
public function addOrEditPowerConsumptionDetails()
|
||||
{
|
||||
public function addOrEditPowerConsumptionDetails(){
|
||||
$electricMachineTableData = json_decode($this->request->getPost('electricMachineTableData'), true);
|
||||
|
||||
$transformedData = [];
|
||||
@ -1338,7 +1342,7 @@ class StockController extends BaseController
|
||||
|
||||
echo "Data successfully saved.";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@
|
||||
</div>
|
||||
|
||||
<!-- form -->
|
||||
<form method="post" action="<?php echo base_url(); ?>addNewCoatingMachineDetails">
|
||||
<form method="post" action="<?php echo base_url(); ?>addNewCoatingMachineDetails?month=<?=$month;?>">
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-row">
|
||||
@ -518,7 +518,7 @@
|
||||
|
||||
<!-- form -->
|
||||
<form method="post" id="editCoatingMachineDetailModalFormId"
|
||||
action="<?php echo base_url(); ?>updateCoatingMachineDetails">
|
||||
action="<?php echo base_url(); ?>updateCoatingMachineDetails?month=<?=$month;?>">
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="form-row">
|
||||
@ -634,6 +634,8 @@
|
||||
<span class="badge mandatory">*</span>
|
||||
<input type="text" class="form-control" id="editTotalGasConsumptionId"
|
||||
name="totalGasConsumption" value="" required>
|
||||
<input type="hidden" class="form-control" id="existingTotalGasConsumptionId"
|
||||
name="existingTotalGasConsumption" value="" >
|
||||
</div>
|
||||
|
||||
|
||||
@ -743,6 +745,7 @@
|
||||
$('#editTotalCoatingId').val(totalCoating);
|
||||
$('#editTotalCoatingSandId').val(totalCoatingSandInKg);
|
||||
$('#editTotalGasConsumptionId').val(totalGasConsumption);
|
||||
$('#existingTotalGasConsumptionId').val(totalGasConsumption);
|
||||
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
|
||||
$('#editPerHourGasConsumptionId').val(perHourGasConsumption);
|
||||
$('#editPerHourCoatingSandQTYId').val(perHourCoatingSandQTY);
|
||||
|
||||
@ -461,7 +461,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
||||
|
||||
const totalHours = hours + (minutes / 60);
|
||||
|
||||
tr.find('td:eq(4)').text(totalHours);
|
||||
tr.find('td:eq(3)').text(totalHours);
|
||||
|
||||
}
|
||||
|
||||
@ -493,7 +493,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
||||
|
||||
const totalHours = hours + (minutes / 60);
|
||||
|
||||
tr.find('td:eq(4)').text(totalHours);
|
||||
tr.find('td:eq(3)').text(totalHours);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user