diff --git a/app/Config/Routes.php b/app/Config/Routes.php index cc235356..7b075eb5 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -458,20 +458,14 @@ $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'drierMachineDetails', 'StockCo $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'addOrEditdrierMachineDetails', 'StockController::addOrEditdrierMachineDetails'); //diesel machine details -$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'factoryVehicleDieselDetails', 'StockController::factoryVehicleDieselDetails'); -$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'addOrEditfactoryVehicleDieselDetails', 'StockController::addOrEditfactoryVehicleDieselDetails'); +$routes->match(['GET','POST'] , 'dieselMachineDetails' , 'StockController::dieselMachineStockDetails') ; +$routes->post('updateDieselMachineDetails' , 'StockController::updateDieselMachineDetails'); //power consumption details $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'powerConsumptionDetails', 'StockController::powerConsumptionDetails'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'addOrEditPowerConsumptionDetails', 'StockController::addOrEditPowerConsumptionDetails'); - -//new diesel machine details -$routes->match(['GET','POST'] , 'dieselMachineDetails' , 'StockController::dieselMachineStockDetails') ; -$routes->post('updateDieselMachineDetails' , 'StockController::updateDieselMachineDetails'); - - //new power consumption details $routes->match(['GET','POST'] , 'newPowerConsumptionDetails' , 'StockController::newPowerConsumptionDetails'); $routes->post('updatePowerConsumptionDetails','StockController::updatePowerConsumptionDetails'); diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 84eda4ac..456ce71b 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -1893,308 +1893,7 @@ class StockController extends BaseController } - - public function factoryVehicleDieselDetails() - { - $currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y'); - - $monthData = $this->getMonthDatesFromInput($currentMonth); - - $data['startDate'] = $monthData[0]['database']; - $data['endDate'] = $monthData[count($monthData) - 1]['database']; - $data['datefordropdown'] = $currentMonth; - - //Machine Details - $data['machineDetails'] = $this->factoryMachine_model->where('energy_type', 'diesel')->where('is_active', 1)->findAll(); - if (!count([$data['machineDetails']])) { - return $this->response->setBody(""); - } - - //Diesel Stock Summary Details - $data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model->select('date,opening_stock as opening_stock_0,purchase_diesel as purchase_diesel_0,total_filling_diesel as total_filling_diesel_0,balance_stock as balance_stock_0') - ->where('date >=', $data['startDate']) - ->where('date <=', $data['endDate']) - ->findAll(); - - if (!count($data['summaryDetails'])) { - - //before insert check previous month data present? - - if (isset($data['startDate']) && !empty($data['startDate'])) { - // Extract the year and month part from the startDate - $startDate = substr($data['startDate'], 0, 7); // Get 'Y-m' part - $date = DateTime::createFromFormat('Y-m', $startDate); - - if ($date) { - $previousMonth = $date->modify('-1 month')->format('Y-m'); - $previousMonthStartDate = "$previousMonth-01"; - $previousMonthEndDate = date("Y-m-t", strtotime($previousMonthStartDate)); - } - } - - // Now you can use $previousMonth, $previousMonthStartDate, and $previousMonthEndDate - - $previousMonthData = $this->factoryVehicleDieselStockSummary_model - ->where('date >=', $previousMonthStartDate) - ->where('date <=', $previousMonthEndDate) - ->orderBy('date', 'desc') - ->first(); - - if (!empty($previousMonthData)) { - //insert empty data - $tempInsert = []; - foreach ($monthData as $key => $value) { - if($value['database'] == $previousMonthData['date']){ //add +1day to previous month date - - array_push($tempInsert, [ - 'date' => $value['database'], - 'opening_stock' => $previousMonthData['balance_stock'], - 'purchase_diesel' => 0.00, - 'total_filling_diesel' => 0.00, - 'balance_stock' => $previousMonthData['balance_stock']]); - }else{ - array_push($tempInsert, ['date' => $value['database']]); - } - } - - $this->factoryVehicleDieselStockSummary_model->insertBatch($tempInsert); - - $data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model->where('date >=', $data['startDate'])->where('date <=', $data['endDate'])->findAll(); - - - - }else{ - //insert empty data - $tempInsert = []; - foreach ($monthData as $key => $value) { - array_push($tempInsert, ['date' => $value['database']]); - } - $this->factoryVehicleDieselStockSummary_model->insertBatch($tempInsert); - - $data['summaryDetails'] = $this->factoryVehicleDieselStockSummary_model->where('date >=', $data['startDate'])->where('date <=', $data['endDate'])->findAll(); - } - - } - - //Diesel Consumption Details - $data['dieselConsumptionDetails'] = $this->getDieselConsumptionPivot($data['machineDetails'],$data['startDate'], $data['endDate']); - - if (!count($data['dieselConsumptionDetails'])) { - - //before insert check previous month data present? - - if (isset($data['startDate']) && !empty($data['startDate'])) { - // Extract the year and month part from the startDate - $startDate = substr($data['startDate'], 0, 7); // Get 'Y-m' part - - $date = DateTime::createFromFormat('Y-m', $startDate); - - if ($date) { - $previousMonth = $date->modify('-1 month')->format('Y-m'); - $previousMonthStartDate = "$previousMonth-01"; - $previousMonthEndDate = date("Y-m-t", strtotime($previousMonthStartDate)); - } - } - - $previousMonthData = $this->factoryVehicleDieselDetails_model - ->where('date >=', $previousMonthStartDate) - ->where('date <=', $previousMonthEndDate) - ->orderBy('date', 'desc') - ->first(); - - - - if (!empty($previousMonthData)) { - //insert empty data - $tempInsert = []; - foreach ($monthData as $key => $value) { - - foreach($data['machineDetails'] as $machine){ - - - $previousMonthDataFetched = $this->factoryVehicleDieselDetails_model - ->where('date >=', $previousMonthStartDate) - ->where('date <=', $previousMonthEndDate) - ->where('machine_id', $machine['id']) - ->orderBy('date', 'desc') - ->first(); - - - if($value['database'] == $previousMonthData['date']){ //add +1day to previous month date - - array_push($tempInsert, [ - 'date' => $value['database'], - 'machine_id' => $machine['id'], - 'opening_reading' => $previousMonthDataFetched['closing_reading'], - 'closing_reading' => $previousMonthDataFetched['closing_reading'], - 'filling_diesel' => 0.00, - 'consumption' => 0.00, - 'running_hours' => 0.00, - 'mileage' => 0.00]); - - - }else{ - array_push($tempInsert, [ - 'date' => $value['database'], - 'machine_id' => $machine['id'], - 'opening_reading' => 0.00, - 'closing_reading' => 0.00, - 'filling_diesel' => 0.00, - 'consumption' => 0.00, - 'running_hours' => 0.00, - 'mileage' => 0.00]); - } - - } - - - - } - }else{ - $tempInsert = []; - foreach ($monthData as $key => $value) { - - foreach($data['machineDetails'] as $machine){ - array_push( $tempInsert, - ['date' => $value['database'], - 'machine_id' => $machine['id'], - 'opening_reading' => 0.00, - 'closing_reading' => 0.00, - 'filling_diesel' => 0.00, - 'consumption' => 0.00, - 'running_hours' => 0.00, - 'mileage' => 0.00]); - } - - } - } - - $this->factoryVehicleDieselDetails_model->insertBatch($tempInsert); - - - $data['dieselConsumptionDetails'] = $this->getDieselConsumptionPivot($data['machineDetails'], $data['startDate'], $data['endDate']); - - } - - // Merge the two arrays - $mergedArray = []; - - // Loop through the first array - foreach ($data['summaryDetails'] as $item1) { - $date = $item1["date"]; - - // Find the matching item in the second array by date - foreach ($data['dieselConsumptionDetails'] as $item2) { - if ($item2["date"] === $date) { - // Merge the two arrays - $mergedArray[] = array_merge($item1, $item2); - break; // Stop once the matching date is found - } - } - } - $data['dieselConsumptionDetails'] = $mergedArray; - - $data['machineName'] = array_column($data['machineDetails'], 'machine_name'); - - $this->global['pageTitle'] = 'Drier Details'; - - $this->loadViews("factoryDieselMachineDetails", $this->global, $data, NULL); - - } - - public function getDieselConsumptionPivot($machineDetails, $startDate, $endDeate) - { - $machineIds = array_column($machineDetails, 'id'); - - if (empty($machineIds)) { - return []; - } - - $fields = ['opening_reading', 'closing_reading', 'filling_diesel', 'consumption', 'running_hours', 'mileage']; - - $pivotColumns = []; - foreach ($machineIds as $machineId) { - foreach ($fields as $field) { - $pivotColumns[] = "MAX(CASE WHEN machine_id = $machineId THEN $field ELSE 0 END) AS {$field}_{$machineId}"; - } - } - - $pivotColumnString = implode(", ", $pivotColumns); - - $sql = "SELECT `date`, $pivotColumnString FROM `t_factoryVehicleDieselDetails` - WHERE machine_id IN (" . implode(",", $machineIds) . ") AND `date` >= ? AND `date` <= ? - GROUP BY `date`"; - - $query = $this->db->query($sql, [$startDate, $endDeate]); - $result = $query->getResultArray(); - - return $result; - } - - public function addOrEditfactoryVehicleDieselDetails() - { - $dieselMachineTableData = json_decode($this->request->getPost('dieselMachineTableData'), true); - - $transformedData = []; - foreach ($dieselMachineTableData as $entry) { - $date = $entry['date']; - - foreach ($entry as $key => $value) { - - if ($key === 'date') { - continue; - } - - preg_match('/(.*?)_(\d+)$/', $key, $matches); - - if (count($matches) === 3) { - $field = $matches[1]; - $machineId = $matches[2]; - - $insertKey = "{$date}_{$machineId}"; - if (!isset($transformedData[$insertKey])) { - $transformedData[$insertKey] = [ - 'date' => DateTime::createFromFormat('d-m-Y', $date)->format('Y-m-d'), - 'machine_id' => $machineId, - 'opening_reading' => 0.00, - 'closing_reading' => 0.00, - 'filling_diesel' => 0.00, - 'consumption' => 0.00, - 'running_hours' => 0.00, - 'mileage' => 0.00, - ]; - } - - $transformedData[$insertKey][$field] = (float) $value; - } - } - } - - - foreach ($transformedData as $row) { - - if ($row['machine_id'] == 0) { - // Summary data: if machine_id is 0, it indicates summary data. This distinction is used because these records will be stored in a separate table. - $this->factoryVehicleDieselStockSummary_model->where('date', $row['date'])->set($row)->update(); - } else { - - // Diesel - factory vehicle data : - $existingRow = $this->factoryVehicleDieselDetails_model->where('date', $row['date'])->where('machine_id', $row['machine_id'])->first(); - if ($existingRow) { - $this->factoryVehicleDieselDetails_model->update($existingRow['id'], $row); - } else { - $this->factoryVehicleDieselDetails_model->insert($row); - } - } - } - - - echo "Data successfully saved."; - } - - - public function powerConsumptionDetails() diff --git a/app/Views/dieselStockDetails.php b/app/Views/dieselStockDetails.php index 40648ada..c41ae5af 100644 --- a/app/Views/dieselStockDetails.php +++ b/app/Views/dieselStockDetails.php @@ -106,17 +106,15 @@ color: #ffffff; font-weight: bold; padding: 6px 10px; - ; text-align: center; } .celda_encabezado_total { - background-color:#ffffff; - border: 1px solid #ccc; - color: #ffffff; + background-color:#ffffff !important; + border: 1px solid #ffffff; + color: #ffffff !important; font-weight: bold; padding: 6px 10px; - ; text-align: center; } @@ -138,7 +136,7 @@ /* */ text-align: center; border: 1px solid #ccc; - padding: 2px 4px; + padding: 10px 6px; } /*style excel*/ @@ -167,31 +165,62 @@ height: 20px; } - #dieselStockDetailsTableId th:nth-child(1), - #dieselStockDetailsTableId td:nth-child(1) { - position: sticky; - left: 0; - background-color: #00a65a; - z-index: 2; - border-right: 2px solid #ddd; - color: #ffffff; - } - - #dieselStockDetailsTableSummaryId th:nth-child(1), - #dieselStockDetailsTableSummaryId td:nth-child(1) { - position: sticky; - left: 0; - background-color: #ffffff; - z-index: 2; - border-right: 2px solid #ddd; - color: #ffffff; - } +/* Make entire thead sticky */ +.fht-table thead { + position: sticky; + top: 0; + z-index: 20; /* Ensure the entire header stays above table rows */ + background-color: #00a65a; /* Header background color */ +} + +.dropdown-menu { + z-index :25 ; +} + + + +/* Ensure each in thead stays sticky */ +.fht-table thead th { + position: sticky; + top: 0; + z-index: 11; /* Higher than table rows but lower than first column */ + background-color: #00a65a; /* Green background */ + color: #ffffff; + border: 1px solid #ddd; + padding: 10px; +} + +/* Sticky First Column */ +.fht-table th:nth-child(1), +.fht-table td:nth-child(1) { + position: sticky; + left: 0; + background-color: #00a65a; + z-index: 15; /* Ensures it stays above other cells */ + border-right: 2px solid #ddd; + color: #ffffff; +} + +/* Table Wrapper for Scrolling */ +.table-responsive { + overflow-x: auto; + overflow-y: auto; + max-height: 450px; /* Adjust as needed */ + position: relative; +} + +td{ + min-width: 100px; + max-width: 100px; +} + + + + + - .modal { - padding-right: 30% ! important; - } @@ -259,6 +288,7 @@ foreach ($period as $day) {
" class="form-control mt-2" data-provide="datepicker" + style="z-index:30;" data-date-format="M-yyyy" data-date-min-view-mode="1">
@@ -289,7 +319,7 @@ foreach ($period as $day) { - machine + Machine Total Diesel @@ -443,7 +473,7 @@ foreach ($period as $day) { contenteditable="true" > - + @@ -454,7 +484,7 @@ foreach ($period as $day) { oninput="closingReadingChange(this)" contenteditable="true"> - + @@ -463,7 +493,7 @@ foreach ($period as $day) { oninput="fillingReadingChange(this)" contenteditable="true"> - + @@ -472,7 +502,7 @@ foreach ($period as $day) { oninput="consumptionChange(this)" contenteditable="true"> - + @@ -480,14 +510,14 @@ foreach ($period as $day) { data-id=" " > - + - + @@ -513,12 +543,16 @@ foreach ($period as $day) { // Sum values for the material $summary["machineId_$machineId"]['opening_reading'] = 0 ; - $summary["machineId_$machineId"]['closing_reading'] = $dieselStock['closing_reading'] == '-' ? 0 : $dieselStock['closing_reading'] ; - $summary["machineId_$machineId"]['filling_diesel'] += $dieselStock['filling_diesel'] == '-' ? 0 : $dieselStock['filling_diesel'] ; - $summary["machineId_$machineId"]['consumption'] += $dieselStock['consumption'] == '-' ? 0 : $dieselStock['consumption'] ; - $summary["machineId_$machineId"]['running_hours'] += $dieselStock['running_hours'] == '-' ? 0 : $dieselStock['running_hours'] ; - $summary["machineId_$machineId"]['mileage'] += $dieselStock['mileage'] == '-' ? 0 : $dieselStock['mileage'] ; + $summary["machineId_$machineId"]['closing_reading'] = is_numeric($dieselStock['closing_reading']) ? $dieselStock['closing_reading'] : 0 ; + $summary["machineId_$machineId"]['filling_diesel'] += is_numeric($dieselStock['filling_diesel']) ? $dieselStock['filling_diesel'] : 0 ; + $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 ; + $summary["machineId_$machineId"]['mileage'] += is_numeric($dieselStock['mileage']) ? $dieselStock['mileage'] : 0 ; + + + + } ?> @@ -531,8 +565,9 @@ foreach ($period as $day) {
- - + + + @@ -626,7 +661,7 @@ foreach ($period as $day) { - > + > @@ -634,15 +669,15 @@ foreach ($period as $day) { data-id="" oninput="purchaseTDStockChange(this)" - contenteditable="true">0 + contenteditable="true"> + data-id=""> + > @@ -672,30 +707,30 @@ foreach ($period as $day) { - > + > + contenteditable="true"> + contenteditable="true"> + data-id=""> + data-id=""> @@ -1179,7 +1214,7 @@ foreach ($period as $day) { let dataId = `${otherDate} ${machine_id}`; - document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText = closingReading; + document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText = closingReading == 0 ? " " : closingReading ; let openingReading = validateInput(document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText); @@ -1193,11 +1228,11 @@ foreach ($period as $day) { let mileage = consumption == 0 || runningHours == 0 ? 0 : (Number(consumption) / Number(runningHours)).toFixed(2) ; - document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText = runningHours ; + document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText = runningHours == 0 ? " " : runningHours ; - document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = mileage ; + document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = mileage == 0 ? " " : mileage ; - document.querySelector(`td.closingReading[data-id="${dataId}"]`).innerText = closingReading ; + document.querySelector(`td.closingReading[data-id="${dataId}"]`).innerText = closingReading == 0 ? " " : closingReading ; } diff --git a/app/Views/factoryDieselMachineDetails.php b/app/Views/factoryDieselMachineDetails.php deleted file mode 100644 index dcd36a10..00000000 --- a/app/Views/factoryDieselMachineDetails.php +++ /dev/null @@ -1,667 +0,0 @@ - - - - - - - - - -modify('first day of this month')->format('Y-m-d'); -$endDate = $date->modify('last day of this month')->format('Y-m-d'); - -$datesInMonth = []; - - -$period = new DatePeriod( - new DateTime($startDate), - new DateInterval('P1D'), - (new DateTime($endDate))->modify('+1 day') -); - -foreach ($period as $day) { - $datesInMonth[] = $day->format('Y-m-d'); -} - -?> - - - - - - - - - - - - -
-
- -
- -
-
-
-
-
- -
- -
-
-
- -
-
- - - -
-
-
- - -
- - -
-
- -
- - - -
-
- -
-
- -
- -
- - - -
- - - -
Total Sum
Total Sum Opening Purchase Diesel 0 + contenteditable="true"> 0 0 0 0
- - - - - - - - - - - - - - - - - - - - - $row): ?> - format('Y-m-d'); - $currentDate = date('Y-m-d'); - if ($date === $currentDate) { echo 'style="background: #cef0ad;"'; } - ?> - > - - $column): ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Total Diesel
- format('d-m-Y'); ?> - - - -
- - -
- -
-
- -
-
- -
- - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/Views/includes/new_header.php b/app/Views/includes/new_header.php index 2a67a5fe..f63bb69b 100755 --- a/app/Views/includes/new_header.php +++ b/app/Views/includes/new_header.php @@ -403,6 +403,10 @@ max-width: none; } + .datepicker { + z-index :30 !important; + } + /* This CSS is for Table Cell Expend*/ @@ -882,9 +886,7 @@ Gas Stock Details - Diesel - Factory Vehicle - - New Diesel - Factory Vehicle + Diesel - Factory Vehicle Power Consumption diff --git a/app/Views/newresinbatchcard.php b/app/Views/newresinbatchcard.php index 7bc66f46..18f9c76e 100755 --- a/app/Views/newresinbatchcard.php +++ b/app/Views/newresinbatchcard.php @@ -1,4 +1,4 @@ -