diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index fe8173f9..3fc57845 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -1973,7 +1973,37 @@ class StockController extends BaseController { - $currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y'); + //drier will be processing different method than other stock in case of session stock month and date format for generating + //dummy data and updating the data . be cautious while updating the code..!! + + if ($this->request->getMethod() === 'POST') { + + $currentMonth = $this->request->getPost('month'); + + $date = DateTime::createFromFormat('M-Y', $currentMonth); //in M-Y format + + $formattedDate = $date->format('Y-m'); //in Y-m format + + + $session = session (); + + $session->set('stock_month',$formattedDate); + + + } else { + + $session = session(); + + $currentMonth = $session->get('stock_month'); + + if (empty($currentMonth)) { + $currentMonth = date('M-Y'); // Default to the current month + }else{ + $currentMonth = DateTime::createFromFormat('Y-m', $currentMonth); // in Y-m format + + $currentMonth = $currentMonth->format('M-Y'); // in M-Y format + } + } $monthData = $this->getMonthDatesFromInput($currentMonth); @@ -2139,9 +2169,9 @@ class StockController extends BaseController $month = $this->request->getPost('month'); - $date = DateTime::createFromFormat('M-Y', $month); + $date = DateTime::createFromFormat('M-Y', $month); //in M-Y format - $formattedDate = $date->format('Y-m'); + $formattedDate = $date->format('Y-m'); //in Y-m format $month = $formattedDate; diff --git a/app/Views/stock/CoatingMachineDetail.php b/app/Views/stock/CoatingMachineDetail.php index f9e667b6..4ff0b62b 100644 --- a/app/Views/stock/CoatingMachineDetail.php +++ b/app/Views/stock/CoatingMachineDetail.php @@ -947,7 +947,7 @@ @@ -1704,8 +1704,13 @@ data: { id: batchId }, success: function (response) { if(response.status == "200"){ - alert("Batch file deleted successfully!"); + alert("Batch File Deleted Successfully!"); $(this).closest('.batch-container').remove(); // Remove from UI + location.reload(); // Reload the page + + } else{ + alert("Removed Empty batch file"); + // alert("Error deleting batch file: " + response.message); } }, error: function (xhr, status, error) { diff --git a/app/Views/stock/dieselStockDetails.php b/app/Views/stock/dieselStockDetails.php index 840eb915..2c0af006 100644 --- a/app/Views/stock/dieselStockDetails.php +++ b/app/Views/stock/dieselStockDetails.php @@ -550,15 +550,17 @@ foreach ($period as $day) { $summary["machineId_$machineId"]['consumption'] += is_numeric($dieselStock['consumption']) ? $dieselStock['consumption'] : 0 ; $summary["machineId_$machineId"]['running_hours'] += is_numeric($dieselStock['running_hours']) ? $dieselStock['running_hours'] : 0 ; - if($summary["machineId_$machineId"]['running_hours'] > 0){ - $dieselMileage = round( - $summary["machineId_$machineId"]['consumption'] / $summary["machineId_$machineId"]['running_hours'], - 2 - ); - - }else{ - $dieselMileage = 0 ; - } + if($summary["machineId_$machineId"]['running_hours'] > 0){ + $dieselMileage = round( + $summary["machineId_$machineId"]['consumption'] / $summary["machineId_$machineId"]['running_hours'], + 2 + ); + + }else{ + $dieselMileage = 0 ; + } + + $summary["machineId_$machineId"]['mileage'] = is_numeric( $dieselMileage) ? $dieselMileage : 0 ; @@ -1245,7 +1247,7 @@ foreach ($period as $day) { let dataId = `${otherDate} ${machine_id}`; - document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText = closingReading == 0 ? " " : (closingReading).toFixed(2) ; + document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText = closingReading == 0 ? " " : parseFloat(closingReading).toFixed(2) ; let openingReading = validateInput(document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText);