changes in stock controller

This commit is contained in:
vadivel J 2024-11-16 16:41:22 +05:30
parent f6573a31db
commit ab5e5b10a1
3 changed files with 280 additions and 273 deletions

View File

@ -85,232 +85,248 @@ class StockController extends BaseController
$this->isLoggedIn(); $this->isLoggedIn();
} }
public function index() public function index()
{ {
// //
} }
//Coating Machine Details starts //Coating Machine Details starts
public function loadView_coatingMachineDetails(){
public function loadView_coatingMachineDetails(){ if ($this->request->getMethod() === 'POST'){
$month = $this->request->getPost('month');
if ($this->request->getMethod() === 'POST'){ $date = DateTime::createFromFormat('M-Y', $month);
$month = $this->request->getPost('month');
$date = DateTime::createFromFormat('M-Y', $month); $formattedDate = $date->format('Y-m');
$formattedDate = $date->format('Y-m'); $month=$formattedDate;
}
$month=$formattedDate; else{
}
else{ $filteredMonth=$this->request->getGet('month');
$month = date('Y-m'); $month = $filteredMonth ?? date('Y-m');
}
$this->global['pageTitle'] = 'Coating Machine Details ';
$startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate));
$data['coatingMachineDetails']= $this->coatingMachineDetails_model
->where('date >=', $startDate)
->where('date <=', $endDate)
->where('is_active', 1)
->orderBy('date','asc')
->findAll();
$date = DateTime::createFromFormat('Y-m', $month);
$formattedDate = $date->format('M-Y');
$data['month']=$formattedDate;
return $this->loadViews("CoatingMachineDetail", $this->global, $data, NULL);
} }
public function addNewCoatingMachineDetails(){ $this->global['pageTitle'] = 'Coating Machine Details ';
$postData=$this->request->getPost();
$date = $postData['date']; $startDate = "$month-01";
$shift = $postData['shift']; $endDate = date("Y-m-t", strtotime($startDate));
$data['coatingMachineDetails']= $this->coatingMachineDetails_model
$sameShiftOnDateExists = $this->coatingMachineDetails_model ->where('date >=', $startDate)
->where('date',$date) ->where('date <=', $endDate)
->where('shift',$shift) ->where('is_active', 1)
->where('is_active',1) ->orderBy('date','asc')
->first(); ->findAll();
if(!empty($sameShiftOnDateExists)){
return redirect()->back()->with('error', 'Already same shift exists on the same date ..!!');
}
$inserted= $this->coatingMachineDetails_model->insert($postData);
if ($inserted) {
// Set flashdata for success message
return redirect()->to('/coatingMachineDetails')->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(){
$putData=$this->request->getPost();
$id = $putData['editCoatingMachineDetailId'];
$updated= $this->coatingMachineDetails_model->update($id,$putData);
if ($updated) {
// Set flashdata for success message
return redirect()->to('/coatingMachineDetails')->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(){
$id = $this->request->getGet('id');
$data['is_active']=0;
$updated = $this->coatingMachineDetails_model->update($id,$data);
if ($updated) {
// Set flashdata for success message
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details deleted successfully');
} else {
// 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(){
if ($this->request->getMethod() === 'POST'){
$month = $this->request->getPost('month');
$date = DateTime::createFromFormat('M-Y', $month);
$formattedDate = $date->format('Y-m');
$month=$formattedDate;
}
else{
$month = date('Y-m');
}
$data['month']=$month;
$this->global['pageTitle']='Incoming Silica Sand Details';
$materialCodes = $this->rawmaterialdetails_model->getAllSilicaRawMaterialCode();
if (!empty($materialCodes)) {
$data['igrDetails'] = $this->inwardGateRegister_model->findIgrDetailsForIncomingSilicaSand($materialCodes,$month);
} else {
$data['igrDetails'] = [];
}
$date = DateTime::createFromFormat('Y-m', $month); $date = DateTime::createFromFormat('Y-m', $month);
$formattedDate = $date->format('M-Y'); $formattedDate = $date->format('M-Y');
$data['month']=$formattedDate; $data['month']=$formattedDate;
return $this->loadViews("incomingSilicaSandDetails", $this->global, $data, NULL); return $this->loadViews("CoatingMachineDetail", $this->global, $data, NULL);
}
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'];
$sameShiftOnDateExists = $this->coatingMachineDetails_model
->where('date',$date)
->where('shift',$shift)
->where('is_active',1)
->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?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 updateIncomingSilicaSandDetails(){ }
$postData = $this->request->getPost();
$incomingSilicaSandDetailsData = json_decode($postData['incomingSilicaSandDetailsData'], true);
foreach($incomingSilicaSandDetailsData as $data){
$IGRNO=$data['IGR No'];
$materialCode=$data['MaterialCode'];
$dbData=[ public function updateCoatingMachineDetails(){
'igrNo_fk'=>$data['IGR No'],
'materialCode'=>$data['MaterialCode'],
'grade'=>$data['Grade'],
'gradeCondition'=>$data['Grade Condition'],
'_10'=>$data['___10___'],
'_20'=>$data['___20___'],
'_30'=>$data['___30___'],
'_40'=>$data['___40___'],
'_50'=>$data['___50___'],
'_70'=>$data['___70___'],
'_100'=>$data['___100___'],
'_140'=>$data['___140___'],
'_200'=>$data['___200___'],
'_300'=>$data['___300___'],
'pan'=>$data['PAN'],
'total'=>$data['Total'],
'afsSpec'=>$data['AFS Spec'],
'afsActual'=>$data['AFS Actual'],
'plus20loss'=>$data['Plus 20 loss%'],
'plus30Loss'=>$data['Plus 30 Loss %'],
'moistureSpec'=>$data['Moisture % Spec'],
'moistureActual'=>$data['Moisture Actual'],
'moistureLoss'=>$data['Moisture Loss'],
'moistureLossQty'=>$data['Moisture loss Qty'],
'sieveLossQty'=>$data['Sieve Loss Qty'],
'salableQty'=>$data['Salable Qty'],
'remark'=>$data['Remark']
$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);
$resultExists=$this->incomingSilicaSandDetails_model if ($updated) {
->where('igrNo_fk',$IGRNO) //update Gas stock consumption if update is successfull..!!
->where('materialCode',$materialCode) $dateToBeUpdated = $putData['date'];
->first();
if(!empty($resultExists)){
$updated = $this->incomingSilicaSandDetails_model
->where('igrNo_fk', $IGRNO)
->where('materialCode', $materialCode)
->set($dbData)
->update();
}else{
$inserted = $this->incomingSilicaSandDetails_model->insert($dbData);
}
$existingCoatingGasConsumption = $putData['existingTotalGasConsumption'];
$updatedCoatingGasConsumption = $putData['totalGasConsumption'];
if( $existingCoatingGasConsumption != $updatedCoatingGasConsumption ){
$changeInConsumption = $updatedCoatingGasConsumption - $existingCoatingGasConsumption;
$this->updateGasStockConsumption($dateToBeUpdated , $changeInConsumption);
} }
echo "Data Saved Successfully"; // Set flashdata for success message
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(){
$id = $this->request->getGet('id');
$data['is_active']=0;
$updated = $this->coatingMachineDetails_model->update($id,$data);
if ($updated) {
// Set flashdata for success message
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details deleted successfully');
} else {
// 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(){
if ($this->request->getMethod() === 'POST'){
$month = $this->request->getPost('month');
$date = DateTime::createFromFormat('M-Y', $month);
$formattedDate = $date->format('Y-m');
$month=$formattedDate;
}
else{
$month = date('Y-m');
}
$data['month']=$month;
$this->global['pageTitle']='Incoming Silica Sand Details';
$materialCodes = $this->rawmaterialdetails_model->getAllSilicaRawMaterialCode();
if (!empty($materialCodes)) {
$data['igrDetails'] = $this->inwardGateRegister_model->findIgrDetailsForIncomingSilicaSand($materialCodes,$month);
} else {
$data['igrDetails'] = [];
}
$date = DateTime::createFromFormat('Y-m', $month);
$formattedDate = $date->format('M-Y');
$data['month']=$formattedDate;
return $this->loadViews("incomingSilicaSandDetails", $this->global, $data, NULL);
}
public function updateIncomingSilicaSandDetails(){
$postData = $this->request->getPost();
$incomingSilicaSandDetailsData = json_decode($postData['incomingSilicaSandDetailsData'], true);
foreach($incomingSilicaSandDetailsData as $data){
$IGRNO=$data['IGR No'];
$materialCode=$data['MaterialCode'];
$dbData=[
'igrNo_fk'=>$data['IGR No'],
'materialCode'=>$data['MaterialCode'],
'grade'=>$data['Grade'],
'gradeCondition'=>$data['Grade Condition'],
'_10'=>$data['___10___'],
'_20'=>$data['___20___'],
'_30'=>$data['___30___'],
'_40'=>$data['___40___'],
'_50'=>$data['___50___'],
'_70'=>$data['___70___'],
'_100'=>$data['___100___'],
'_140'=>$data['___140___'],
'_200'=>$data['___200___'],
'_300'=>$data['___300___'],
'pan'=>$data['PAN'],
'total'=>$data['Total'],
'afsSpec'=>$data['AFS Spec'],
'afsActual'=>$data['AFS Actual'],
'plus20loss'=>$data['Plus 20 loss%'],
'plus30Loss'=>$data['Plus 30 Loss %'],
'moistureSpec'=>$data['Moisture % Spec'],
'moistureActual'=>$data['Moisture Actual'],
'moistureLoss'=>$data['Moisture Loss'],
'moistureLossQty'=>$data['Moisture loss Qty'],
'sieveLossQty'=>$data['Sieve Loss Qty'],
'salableQty'=>$data['Salable Qty'],
'remark'=>$data['Remark']
];
$resultExists=$this->incomingSilicaSandDetails_model
->where('igrNo_fk',$IGRNO)
->where('materialCode',$materialCode)
->first();
if(!empty($resultExists)){
$updated = $this->incomingSilicaSandDetails_model
->where('igrNo_fk', $IGRNO)
->where('materialCode', $materialCode)
->set($dbData)
->update();
}else{
$inserted = $this->incomingSilicaSandDetails_model->insert($dbData);
}
} }
// Bag Stock details starts echo "Data Saved Successfully";
public function loadView_bagStockDetails(){ }
// Bag Stock details starts
public function loadView_bagStockDetails(){
if ($this->request->getMethod() === 'POST'){ if ($this->request->getMethod() === 'POST'){
$month = $this->request->getPost('month'); $month = $this->request->getPost('month');
@ -408,9 +424,9 @@ class StockController extends BaseController
return $this->loadViews("bagStockDetails", $this->global, $data, NULL); return $this->loadViews("bagStockDetails", $this->global, $data, NULL);
} }
public function updateBagStockDetails(){ public function updateBagStockDetails(){
$postData = $this->request->getPost(); $postData = $this->request->getPost();
@ -469,12 +485,11 @@ class StockController extends BaseController
echo "Data Saved Successfully"; echo "Data Saved Successfully";
} }
//Dust And Rough Stock Details //Dust And Rough Stock Details
public function loadView_dustAndRoughStockDetails(){
public function loadView_dustAndRoughStockDetails(){
if ($this->request->getMethod() === 'POST'){ if ($this->request->getMethod() === 'POST'){
$month = $this->request->getPost('month'); $month = $this->request->getPost('month');
@ -511,9 +526,9 @@ class StockController extends BaseController
return $this->loadViews("dustAndRoughStockDetails", $this->global, $data, NULL); return $this->loadViews("dustAndRoughStockDetails", $this->global, $data, NULL);
} }
public function updateDustAndRoughStockDetails(){ public function updateDustAndRoughStockDetails(){
$postData = $this->request->getPost(); $postData = $this->request->getPost();
@ -523,31 +538,31 @@ class StockController extends BaseController
$inserts = []; $inserts = [];
foreach($updateDustAndRoughStockDetailsData as $data){ foreach($updateDustAndRoughStockDetailsData as $data){
$data['date'] = DateTime::createFromFormat('d-m-Y', $data['date'])->format('Y-m-d');
$date =$data['date'];
$dbData= [
'date' => $data['date'],
'finalRough' => $data['finalRough'],
'dust' => $data['dust'],
'total' => $data['total']
];
$resultExists=$this->dustAndRoughStockDetails_model
->where('date',$date)
->first();
if (empty($resultExists)) { $data['date'] = DateTime::createFromFormat('d-m-Y', $data['date'])->format('Y-m-d');
$inserts[] = $dbData;
$date =$data['date'];
$dbData= [
'date' => $data['date'],
'finalRough' => $data['finalRough'],
'dust' => $data['dust'],
'total' => $data['total']
];
$resultExists=$this->dustAndRoughStockDetails_model
->where('date',$date)
->first();
} else { if (empty($resultExists)) {
$updates[] = $dbData; $inserts[] = $dbData;
}
} } else {
$updates[] = $dbData;
}
}
if (!empty($inserts)) { if (!empty($inserts)) {
$this->dustAndRoughStockDetails_model->insertBatch($inserts); $this->dustAndRoughStockDetails_model->insertBatch($inserts);
@ -567,12 +582,11 @@ class StockController extends BaseController
echo "Data Saved Successfully"; echo "Data Saved Successfully";
} }
//Resin Stock Details //Resin Stock Details
public function loadView_resinStockDetails(){
public function loadView_resinStockDetails(){
if ($this->request->getMethod() === 'POST'){ if ($this->request->getMethod() === 'POST'){
@ -669,9 +683,9 @@ class StockController extends BaseController
return $this->loadViews("resinStockDetails", $this->global, $data, NULL); return $this->loadViews("resinStockDetails", $this->global, $data, NULL);
} }
public function updateResinStockDetails(){ public function updateResinStockDetails(){
$postData = $this->request->getPost(); $postData = $this->request->getPost();
@ -732,12 +746,11 @@ class StockController extends BaseController
echo "Data Saved Successfully"; echo "Data Saved Successfully";
} }
//Gas Stock Details //Gas Stock Details
public function loadView_gasStockDetails(){
public function loadView_gasStockDetails(){
if ($this->request->getMethod() === 'POST'){ if ($this->request->getMethod() === 'POST'){
@ -800,9 +813,9 @@ class StockController extends BaseController
$data['month'] = DateTime::createFromFormat('Y-m', $month)->format('M-Y'); $data['month'] = DateTime::createFromFormat('Y-m', $month)->format('M-Y');
return $this->loadViews("gasStockDetails", $this->global, $data, NULL); return $this->loadViews("gasStockDetails", $this->global, $data, NULL);
} }
public function updateGasStockDetails(){ public function updateGasStockDetails(){
$postData = $this->request->getPost(); $postData = $this->request->getPost();
@ -859,11 +872,9 @@ class StockController extends BaseController
} }
echo "Data Saved Successfully"; echo "Data Saved Successfully";
} }
private function updateGasStockConsumption($date , $consumption){ private function updateGasStockConsumption($date , $consumption){
$resultExists = $this->gasStockDetails_model $resultExists = $this->gasStockDetails_model
->where('date',$date) ->where('date',$date)
@ -908,17 +919,16 @@ class StockController extends BaseController
if(!empty($inserts)){ if(!empty($inserts)){
$this->gasStockDetails_model->insertBatch($inserts); $this->gasStockDetails_model->insertBatch($inserts);
} }
} }
} }
// --------------------------------------------gwm---------------------------------------------- // --------------------------------------------gwm----------------------------------------------
function getMonthDatesFromInput($monthYear) { public function getMonthDatesFromInput($monthYear) {
$date = DateTime::createFromFormat('M-Y', $monthYear); $date = DateTime::createFromFormat('M-Y', $monthYear);
@ -943,10 +953,9 @@ class StockController extends BaseController
} }
return $dates; return $dates;
} }
public function generateTimeOptions() {
function generateTimeOptions() {
$times = []; $times = [];
$start = strtotime('00:00'); // Start at midnight (12:00 AM) $start = strtotime('00:00'); // Start at midnight (12:00 AM)
$end = strtotime('23:45'); // End at 11:45 PM $end = strtotime('23:45'); // End at 11:45 PM
@ -959,10 +968,9 @@ class StockController extends BaseController
} }
return $times; return $times;
} }
function drierMachineDetails() public function drierMachineDetails(){
{
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y'); $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->global['pageTitle'] = 'Drier Details';
$this->loadViews("drierMachineDetails", $this->global, $data, NULL); $this->loadViews("drierMachineDetails", $this->global, $data, NULL);
} }
public function addOrEditdrierMachineDetails() public function addOrEditdrierMachineDetails(){
{
$drierData = json_decode($this->request->getPost('drierData'), true); $drierData = json_decode($this->request->getPost('drierData'), true);
if (empty($drierData)) { if (empty($drierData)) {
@ -1055,10 +1062,9 @@ class StockController extends BaseController
} }
echo "Data successfully saved."; echo "Data successfully saved.";
} }
public function factoryVehicleDieselDetails()
public function factoryVehicleDieselDetails()
{ {
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y'); $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->global['pageTitle'] = 'Drier Details';
$this->loadViews("factoryDieselMachineDetails", $this->global, $data, NULL); $this->loadViews("factoryDieselMachineDetails", $this->global, $data, NULL);
} }
public function getDieselConsumptionPivot($machineDetails , $startDate , $endDeate) public function getDieselConsumptionPivot($machineDetails , $startDate , $endDeate)
{ {
$machineIds = array_column($machineDetails, 'id'); $machineIds = array_column($machineDetails, 'id');
@ -1153,9 +1159,9 @@ class StockController extends BaseController
$result = $query->getResultArray(); $result = $query->getResultArray();
return $result; return $result;
} }
public function addOrEditfactoryVehicleDieselDetails() public function addOrEditfactoryVehicleDieselDetails()
{ {
$dieselMachineTableData = json_decode($this->request->getPost('dieselMachineTableData'), true); $dieselMachineTableData = json_decode($this->request->getPost('dieselMachineTableData'), true);
@ -1217,10 +1223,10 @@ class StockController extends BaseController
echo "Data successfully saved."; echo "Data successfully saved.";
} }
public function powerConsumptionDetails() public function powerConsumptionDetails()
{ {
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y'); $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->global['pageTitle'] = 'Power Consumption Details';
$this->loadViews("powerConsumptionDetails", $this->global, $data, NULL); $this->loadViews("powerConsumptionDetails", $this->global, $data, NULL);
} }
public function getElectricConsumptionPivot($machineDetails , $startDate , $endDeate) public function getElectricConsumptionPivot($machineDetails , $startDate , $endDeate) {
{
$machineIds = array_column($machineDetails, 'id'); $machineIds = array_column($machineDetails, 'id');
if (empty($machineIds)) { return []; } if (empty($machineIds)) { return []; }
@ -1288,10 +1293,9 @@ class StockController extends BaseController
$result = $query->getResultArray(); $result = $query->getResultArray();
return $result; return $result;
} }
public function addOrEditPowerConsumptionDetails() public function addOrEditPowerConsumptionDetails(){
{
$electricMachineTableData = json_decode($this->request->getPost('electricMachineTableData'), true); $electricMachineTableData = json_decode($this->request->getPost('electricMachineTableData'), true);
$transformedData = []; $transformedData = [];
@ -1338,7 +1342,7 @@ class StockController extends BaseController
echo "Data successfully saved."; echo "Data successfully saved.";
} }
} }

View File

@ -338,7 +338,7 @@
</div> </div>
<!-- form --> <!-- 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="modal-body">
<div class="form-row"> <div class="form-row">
@ -518,7 +518,7 @@
<!-- form --> <!-- form -->
<form method="post" id="editCoatingMachineDetailModalFormId" <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="modal-body">
<div class="form-row"> <div class="form-row">
@ -634,6 +634,8 @@
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editTotalGasConsumptionId" <input type="text" class="form-control" id="editTotalGasConsumptionId"
name="totalGasConsumption" value="" required> name="totalGasConsumption" value="" required>
<input type="hidden" class="form-control" id="existingTotalGasConsumptionId"
name="existingTotalGasConsumption" value="" >
</div> </div>
@ -743,6 +745,7 @@
$('#editTotalCoatingId').val(totalCoating); $('#editTotalCoatingId').val(totalCoating);
$('#editTotalCoatingSandId').val(totalCoatingSandInKg); $('#editTotalCoatingSandId').val(totalCoatingSandInKg);
$('#editTotalGasConsumptionId').val(totalGasConsumption); $('#editTotalGasConsumptionId').val(totalGasConsumption);
$('#existingTotalGasConsumptionId').val(totalGasConsumption);
$('#editMachineRunningInHrsId').val(machineRunningInHrs); $('#editMachineRunningInHrsId').val(machineRunningInHrs);
$('#editPerHourGasConsumptionId').val(perHourGasConsumption); $('#editPerHourGasConsumptionId').val(perHourGasConsumption);
$('#editPerHourCoatingSandQTYId').val(perHourCoatingSandQTY); $('#editPerHourCoatingSandQTYId').val(perHourCoatingSandQTY);
@ -954,7 +957,7 @@
let machineOffTime24 = convertTo24Hr(machineOffTime12); let machineOffTime24 = convertTo24Hr(machineOffTime12);
const startDate = new Date(`${machineOnDate}T${machineOnTime24}`); const startDate = new Date(`${machineOnDate}T${machineOnTime24}`);
const endDate = new Date(`${machineOnDate}T${machineOffTime24}`); const endDate = new Date(`${machineOnDate}T${machineOffTime24}`);
// Handle the case where end time is on the next day // Handle the case where end time is on the next day
if (endDate < startDate) { if (endDate < startDate) {

View File

@ -461,7 +461,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
const totalHours = hours + (minutes / 60); 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); const totalHours = hours + (minutes / 60);
tr.find('td:eq(4)').text(totalHours); tr.find('td:eq(3)').text(totalHours);
} }