stock module latest today vadivel J 24-01-2025
This commit is contained in:
parent
d47b80ed06
commit
10557af01b
@ -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');
|
||||
|
||||
@ -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("<script>alert('No Machine data available');</script>");
|
||||
}
|
||||
|
||||
//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()
|
||||
|
||||
@ -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 @@
|
||||
/* <!-- ad9271 into ffffff brown-light to green-light --> */
|
||||
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 <th> 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;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@ -259,6 +288,7 @@ foreach ($period as $day) {
|
||||
<div class="col-3">
|
||||
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
|
||||
class="form-control mt-2" data-provide="datepicker"
|
||||
style="z-index:30;"
|
||||
data-date-format="M-yyyy" data-date-min-view-mode="1">
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
@ -289,7 +319,7 @@ foreach ($period as $day) {
|
||||
|
||||
<tr>
|
||||
|
||||
<th class="celda_encabezado_general" colspan="1"> machine </th>
|
||||
<th class="celda_encabezado_general" colspan="1"> Machine </th>
|
||||
|
||||
<th class="celda_encabezado_general" colspan="4">
|
||||
Total Diesel
|
||||
@ -443,7 +473,7 @@ foreach ($period as $day) {
|
||||
contenteditable="true"
|
||||
<?php endif; ?>>
|
||||
|
||||
<?= $dieselStock['opening_reading'] ?>
|
||||
<?= $dieselStock['opening_reading'] ?? " " ?>
|
||||
|
||||
|
||||
</td>
|
||||
@ -454,7 +484,7 @@ foreach ($period as $day) {
|
||||
oninput="closingReadingChange(this)"
|
||||
contenteditable="true">
|
||||
|
||||
<?= $dieselStock['closing_reading'] ?>
|
||||
<?= $dieselStock['closing_reading'] ?? " " ?>
|
||||
|
||||
</td>
|
||||
|
||||
@ -463,7 +493,7 @@ foreach ($period as $day) {
|
||||
oninput="fillingReadingChange(this)"
|
||||
contenteditable="true">
|
||||
|
||||
<?= $dieselStock['filling_diesel'] ?>
|
||||
<?= $dieselStock['filling_diesel'] ?? " " ?>
|
||||
|
||||
</td>
|
||||
|
||||
@ -472,7 +502,7 @@ foreach ($period as $day) {
|
||||
oninput="consumptionChange(this)"
|
||||
contenteditable="true">
|
||||
|
||||
<?= $dieselStock['consumption'] ?>
|
||||
<?= $dieselStock['consumption'] ?? " " ?>
|
||||
|
||||
</td>
|
||||
|
||||
@ -480,14 +510,14 @@ foreach ($period as $day) {
|
||||
data-id="<?= $dieselStock['date'] ?> <?= $dieselStock['machine_id'] ?>"
|
||||
>
|
||||
|
||||
<?= $dieselStock['running_hours'] ?>
|
||||
<?= $dieselStock['running_hours'] ?? " " ?>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="celda_normal mileage"
|
||||
data-id="<?= $dieselStock['date'] ?> <?= $dieselStock['machine_id'] ?>">
|
||||
|
||||
<?= $dieselStock['mileage'] ?>
|
||||
<?= $dieselStock['mileage'] ?? " " ?>
|
||||
|
||||
</td>
|
||||
|
||||
@ -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) {
|
||||
<div class="table-responsive">
|
||||
<table id="dieselStockDetailsTableSummaryId" class="fht-table table-striped">
|
||||
|
||||
<thead>
|
||||
<th class="celda_encabezado_total">Total Sum</th>
|
||||
<thead >
|
||||
|
||||
<th class="celda_encabezado_total" >Total Sum</th>
|
||||
|
||||
<th class="celda_encabezado_total"> Opening</th>
|
||||
<th class="celda_encabezado_total"> Purchase Diesel</th>
|
||||
@ -626,7 +661,7 @@ foreach ($period as $day) {
|
||||
|
||||
<?php } ?>
|
||||
|
||||
><?= $previousMonthTotalDieselMachineStockDetails[0]['balance_stock'] ?? 0 ?></td>
|
||||
><?= $previousMonthTotalDieselMachineStockDetails[0]['balance_stock'] !=0 ?? " " ?></td>
|
||||
|
||||
|
||||
|
||||
@ -634,15 +669,15 @@ foreach ($period as $day) {
|
||||
data-id="<?= $dateInMonth ?>"
|
||||
|
||||
oninput="purchaseTDStockChange(this)"
|
||||
contenteditable="true">0</td>
|
||||
contenteditable="true"> </td>
|
||||
|
||||
<td class="celda_normal fillingTD"
|
||||
data-id="<?= $dateInMonth ?>">0</td>
|
||||
data-id="<?= $dateInMonth ?>"> </td>
|
||||
|
||||
<td class="celda_normal balanceTD"
|
||||
data-id="<?= $dateInMonth ?>"
|
||||
|
||||
><?= $previousMonthTotalDieselMachineStockDetails[0]['balance_stock'] ?? 0 ?></td>
|
||||
><?= $previousMonthTotalDieselMachineStockDetails[0]['balance_stock'] !=0 ?? " " ?></td>
|
||||
|
||||
|
||||
|
||||
@ -672,30 +707,30 @@ foreach ($period as $day) {
|
||||
|
||||
<?php } ?>
|
||||
|
||||
><?= $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading'] ?? '0' ?>
|
||||
><?= $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading'] ?? ' ' ?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal closingReading"
|
||||
data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>"
|
||||
oninput="closingReadingChange(this)"
|
||||
contenteditable="true"><?= $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading'] ?? '0' ?>
|
||||
contenteditable="true"><?= $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading'] ?? ' ' ?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal fillingDiesel"
|
||||
data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>"
|
||||
oninput="fillingReadingChange(this)"
|
||||
contenteditable="true">0</td>
|
||||
contenteditable="true"> </td>
|
||||
|
||||
<td class="celda_normal consumption"
|
||||
data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>"
|
||||
oninput="consumptionChange(this)"
|
||||
contenteditable="true">0</td>
|
||||
contenteditable="true"> </td>
|
||||
|
||||
<td class="celda_normal runningHours"
|
||||
data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>">0</td>
|
||||
data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>"> </td>
|
||||
|
||||
<td class="celda_normal mileage"
|
||||
data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>">0</td>
|
||||
data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>"> </td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@ -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 ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,667 +0,0 @@
|
||||
<?php
|
||||
$datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
||||
?>
|
||||
<style type="text/css">
|
||||
.num {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
||||
.fht-table,
|
||||
.fht-table thead,
|
||||
.fht-table tfoot,
|
||||
.fht-table tbody,
|
||||
.fht-table tr,
|
||||
.fht-table th,
|
||||
.fht-table td {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.fht-table td {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fht-table td:hover {
|
||||
background-color: #41a1c8;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.fht-table {
|
||||
border: 0 none;
|
||||
height: auto;
|
||||
width: auto;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
/*table-layout: fixed; Algoritmo de distribucion fijo */
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.fht-table th,
|
||||
.fht-table td {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.fht-table-wrapper,
|
||||
.fht-table-wrapper .fht-thead,
|
||||
.fht-table-wrapper .fht-tfoot,
|
||||
.fht-table-wrapper .fht-fixed-column .fht-tbody,
|
||||
.fht-table-wrapper .fht-fixed-body .fht-tbody,
|
||||
.fht-table-wrapper .fht-tbody {
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.fht-table-wrapper .fht-fixed-body .fht-tbody,
|
||||
.fht-table-wrapper .fht-tbody {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.fht-table-wrapper .fht-table .fht-cell {
|
||||
overflow: hidden;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
.fht-table-wrapper .fht-fixed-column,
|
||||
.fht-table-wrapper .fht-fixed-body {
|
||||
top: 0;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.fht-table-wrapper .fht-fixed-column {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.fht-fixed-body .fht-thead table {
|
||||
margin-right: 20px;
|
||||
border: 0 none;
|
||||
}
|
||||
|
||||
/*For Examples*/
|
||||
|
||||
.ContenedorTabla {
|
||||
height: 500px;
|
||||
margin: 0 auto;
|
||||
overflow: auto;
|
||||
width: auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.header,
|
||||
.main {
|
||||
display: inline-block;
|
||||
height: auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.titulosHeader {
|
||||
border-bottom: 1px solid #e8bb25;
|
||||
height: auto;
|
||||
margin-bottom: 10px;
|
||||
padding-bottom: 8px;
|
||||
padding-top: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.celda_encabezado_general {
|
||||
background-color: #00a65a;
|
||||
border: 1px solid #ccc;
|
||||
color: #ffffff;
|
||||
font-weight: bold;
|
||||
padding: 2px 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
._Separador {
|
||||
background-color: #fff;
|
||||
height: 12px;
|
||||
border-left: 1px solid #ccc;
|
||||
border-right: 1px solid #ccc;
|
||||
width: 7px;
|
||||
}
|
||||
|
||||
._Separador div {
|
||||
width: 4px;
|
||||
}
|
||||
|
||||
.celda_normal {
|
||||
border: 1px solid #ccc;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
|
||||
/*style excel*/
|
||||
.excel_cell {
|
||||
border: 1px solid #CCC;
|
||||
color: #222;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-weight: normal;
|
||||
padding: 4px;
|
||||
white-space: pre-line;
|
||||
empty-cells: show;
|
||||
}
|
||||
|
||||
._cell_header {
|
||||
background-color: #EEE;
|
||||
}
|
||||
|
||||
._cell_Default {
|
||||
background-color: #FFF;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.excel_cell div {
|
||||
width: 30px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#dieselMachineTable th:nth-child(1),
|
||||
#dieselMachineTable td:nth-child(1) {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
background-color: #00a65a;
|
||||
z-index: 2;
|
||||
border-right: 2px solid #ddd;
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
$date = DateTime::createFromFormat('M-Y', $datefordropdown);
|
||||
|
||||
$startDate = $date->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');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myLargeModalLabel">Navigation Options</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<!-- Machine Dropdown -->
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="machineDropdown">Select Machine</label>
|
||||
<select id="machineDropdown" class="form-control">
|
||||
<option value="">Select Machine</option>
|
||||
<?php foreach ($machineName as $name): ?>
|
||||
<option value="<?= $name; ?>"><?= $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Date Dropdown -->
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateDropdown">Select Date</label>
|
||||
<select id="dateDropdown" class="form-control">
|
||||
<?php foreach($datesInMonth as $selectDate): ?>
|
||||
<?php $selectDate=DateTime::createFromFormat('Y-m-d', $selectDate)->format('d-m-Y'); ?>
|
||||
<option value="<?=$selectDate?>"><?=$selectDate?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary float-right" onclick="navigateToMachine()">Navigate</button>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Stocks</a></li>
|
||||
<li class="breadcrumb-item active">
|
||||
<h4 class="page-title">Diesel - Factory Vehicle Details</h4>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 text-right">
|
||||
<!-- Right-aligned buttons or links can be added here -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
|
||||
|
||||
<div class="card-body" >
|
||||
|
||||
|
||||
<form action="<?= base_url('factoryVehicleDieselDetails'); ?>" method="post">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-3">
|
||||
<?php $today = date('M-Y'); ?>
|
||||
<input type="text" name="month" id="month"
|
||||
value="<?php echo $datefordropdown; ?>" class="form-control"
|
||||
data-provide="datepicker" data-date-format="M-yyyy"
|
||||
data-date-min-view-mode="1">
|
||||
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<input type="submit" value="Change Month" class="btn btn-success"
|
||||
style="margin-top:0px;">
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="dropdown float-right">
|
||||
<a href="#" class="dropdown-toggle arrow-none" data-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
<i class="mdi mdi-dots-vertical m-0 text-muted h3"></i>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a>
|
||||
<a class="dropdown-item" href="#">Export</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Add table-responsive for horizontal scroll -->
|
||||
<div class="table-responsive">
|
||||
<?php
|
||||
$columns = array_keys($dieselConsumptionDetails[0]);
|
||||
|
||||
function formatHeader($key)
|
||||
{
|
||||
$parts = explode('_', $key);
|
||||
if (is_numeric(end($parts))) { array_pop($parts); }
|
||||
return ucwords(implode(' ', $parts));
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<table id="dieselMachineTable" class="fht-table table-striped"
|
||||
style="font-size: small;">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="celda_encabezado_general" style="padding: 10px;"></th>
|
||||
<th class="celda_encabezado_general" colspan="4" style="padding: 10px;">
|
||||
Total Diesel</th>
|
||||
<?php foreach ($machineName as $name): ?>
|
||||
<th class="celda_encabezado_general" colspan="6" data-id="<?= $name; ?>"
|
||||
style="padding: 10px;"><?= $name; ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ($columns as $column): ?>
|
||||
<th class="celda_encabezado_general" style="padding: 10px;"
|
||||
id="<?= $column ?>"><?= formatHeader($column) ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody >
|
||||
<?php foreach ($dieselConsumptionDetails as $key => $row): ?>
|
||||
<tr id="<?php echo $key + 1; ?>"
|
||||
|
||||
<?php
|
||||
$date = DateTime::createFromFormat('Y-m-d', $row['date'])->format('Y-m-d');
|
||||
$currentDate = date('Y-m-d');
|
||||
if ($date === $currentDate) { echo 'style="background: #cef0ad;"'; }
|
||||
?>
|
||||
>
|
||||
|
||||
<?php foreach ($columns as $index => $column): ?>
|
||||
|
||||
<?php if($index == 0) : ?>
|
||||
<td class="celda_normal" style="padding: 5px;">
|
||||
<?php echo DateTime::createFromFormat('Y-m-d', $row[$column])->format('d-m-Y'); ?>
|
||||
</td>
|
||||
<?php elseif(formatHeader($column) == 'Opening Reading'): ?>
|
||||
<td class="celda_normal"
|
||||
contenteditable="true"
|
||||
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php elseif(formatHeader($column) == 'Closing Reading'): ?>
|
||||
<td class="celda_normal" contenteditable="true"
|
||||
onkeyup="calculateRunningHrs(this.parentNode.id,this.textContent);"
|
||||
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php elseif(formatHeader($column) == 'Filling Diesel'): ?>
|
||||
<td class="celda_normal" contenteditable="true"
|
||||
onkeyup="calculateTotalFillingDiesel(this.parentNode.id,this.textContent);"
|
||||
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php elseif(formatHeader($column) == 'Consumption'): ?>
|
||||
<td class="celda_normal" contenteditable="true"
|
||||
onkeyup="calculateMileage(this.parentNode.id,this.textContent);"
|
||||
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php elseif(formatHeader($column) == 'Running Hours'): ?>
|
||||
<td class="celda_normal" style="padding: 5px;">
|
||||
<?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php elseif(formatHeader($column) == 'Mileage'): ?>
|
||||
<td class="celda_normal" style="padding: 5px;">
|
||||
<?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php elseif(formatHeader($column) == 'Opening Stock'): ?>
|
||||
<td class="celda_normal"
|
||||
contenteditable="true"
|
||||
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php elseif(formatHeader($column) == 'Purchase Diesel'): ?>
|
||||
<td class="celda_normal" contenteditable="true"
|
||||
onkeyup="calculateBalanceStock(this.parentNode.id,this.textContent);"
|
||||
style="padding: 5px;"><?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php else : ?>
|
||||
<td class="celda_normal" style="padding: 5px;">
|
||||
<?= $row[$column] ?? 'N/A' ?></td>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
</div><!-- End table-responsive -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<input type="button" class="btn btn-success" id="save" value="save">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div> <!-- End card-body -->
|
||||
</div> <!-- End card -->
|
||||
</div> <!-- End col -->
|
||||
</div> <!-- End row -->
|
||||
</div>
|
||||
</div> <!-- End container-fluid -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#save').click(function() {
|
||||
|
||||
// Get headers from the second <thead> as keys
|
||||
var headers = [];
|
||||
$("#dieselMachineTable thead:nth-child(2) th").each(function() {
|
||||
headers.push($(this).attr("id"));
|
||||
});
|
||||
|
||||
// Convert table to JSON using custom headers as keys
|
||||
var tableData = [];
|
||||
$("#dieselMachineTable tbody tr").each(function() {
|
||||
var rowData = {};
|
||||
$(this).find("td").each(function(index) {
|
||||
var key = headers[index] || `column_${index}`;
|
||||
rowData[key] = $(this).text().trim();
|
||||
});
|
||||
tableData.push(rowData);
|
||||
});
|
||||
|
||||
var jsonData = JSON.stringify(tableData);
|
||||
|
||||
|
||||
$('#loader').show();
|
||||
$.ajax({
|
||||
data: {
|
||||
dieselMachineTableData: jsonData,
|
||||
},
|
||||
type: "POST",
|
||||
url: "<?php echo base_url() ?>/addOrEditfactoryVehicleDieselDetails",
|
||||
|
||||
success: function(data) {
|
||||
if (data) {
|
||||
|
||||
$('#loader').hide();
|
||||
alert(data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function openingReading(parentId, textContent) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function calculateRunningHrs(parentId, textContent) {
|
||||
|
||||
var tr = $('#' + parentId);
|
||||
var currentTd = $(event.target);
|
||||
var tdIndex = currentTd.index();
|
||||
|
||||
// runningHrs calculation
|
||||
closingReading = currentTd.text();
|
||||
openingReading = tr.find('td:eq(' + (tdIndex - 1) + ')').text();
|
||||
runningHrs = closingReading - openingReading;
|
||||
if (runningHrs != NaN && runningHrs != Infinity)
|
||||
tr.find('td:eq(' + (tdIndex + 3) + ')').text(runningHrs.toFixed(2));
|
||||
|
||||
// mileage calculation
|
||||
consumption = tr.find('td:eq(' + (tdIndex + 2) + ')').text();
|
||||
runningHrs = runningHrs.toFixed(2);
|
||||
mileage = consumption / runningHrs;
|
||||
if (mileage != NaN && mileage != Infinity)
|
||||
tr.find('td:eq(' + (tdIndex + 4) + ')').text(mileage.toFixed(2));
|
||||
|
||||
//next opening reading
|
||||
nextTrIndex = parseInt(parentId, 10) + 1
|
||||
var nexttr = $('#' + nextTrIndex);
|
||||
nexttr.find('td:eq(' + (tdIndex - 1) + ')').text(textContent);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
function calculateMileage(parentId, textContent) {
|
||||
|
||||
var tr = $('#' + parentId);
|
||||
var currentTd = $(event.target);
|
||||
var tdIndex = currentTd.index();
|
||||
|
||||
// mileage calculation
|
||||
consumption = currentTd.text();
|
||||
runningHrs = tr.find('td:eq(' + (tdIndex + 1) + ')').text();
|
||||
result = consumption / runningHrs;
|
||||
if (result != NaN && result != Infinity)
|
||||
tr.find('td:eq(' + (tdIndex + 2) + ')').text(result.toFixed(2));
|
||||
|
||||
}
|
||||
|
||||
|
||||
function calculateTotalFillingDiesel(parentId, textContent) {
|
||||
|
||||
var tr = $('#' + parentId);
|
||||
totalFillingDiesel = 0;
|
||||
|
||||
tr.children('td').each(function(index, td) {
|
||||
|
||||
var value = parseFloat($(td).text()) || 0;
|
||||
|
||||
// var headerText = $('table thead th').eq(index).text();
|
||||
var headerText = $('table thead tr:eq(1) th').eq(index).text();
|
||||
|
||||
if (headerText == 'Filling Diesel') {
|
||||
totalFillingDiesel += value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
tr.find('td:eq(' + (3) + ')').text(totalFillingDiesel.toFixed(2));
|
||||
|
||||
// Balance Stock calculation
|
||||
openingStock = tr.find('td:eq(' + (1) + ')').text();
|
||||
purchaseDiesel = tr.find('td:eq(' + (2) + ')').text();
|
||||
fillingDiesel = tr.find('td:eq(' + (3) + ')').text();
|
||||
|
||||
balanceStock = (parseFloat(openingStock) + parseFloat(purchaseDiesel)) - parseFloat(fillingDiesel);
|
||||
if (balanceStock != NaN && balanceStock != Infinity)
|
||||
tr.find('td:eq(' + (4) + ')').text(balanceStock.toFixed(2));
|
||||
|
||||
//next opening stock
|
||||
nextTrIndex = parseInt(parentId, 10) + 1
|
||||
var nexttr = $('#' + nextTrIndex);
|
||||
nexttr.find('td:eq(' + (1) + ')').text(balanceStock.toFixed(2));
|
||||
}
|
||||
|
||||
function calculateBalanceStock(parentId, textContent) {
|
||||
|
||||
var tr = $('#' + parentId);
|
||||
var currentTd = $(event.target);
|
||||
var tdIndex = currentTd.index();
|
||||
|
||||
// Balance Stock calculation
|
||||
openingStock = tr.find('td:eq(' + (tdIndex - 1) + ')').text();
|
||||
purchaseDiesel = currentTd.text();
|
||||
fillingDiesel = tr.find('td:eq(' + (tdIndex + 1) + ')').text();
|
||||
|
||||
balanceStock = (parseFloat(openingStock) + parseFloat(purchaseDiesel)) - parseFloat(fillingDiesel);
|
||||
if (balanceStock != NaN && balanceStock != Infinity)
|
||||
tr.find('td:eq(' + (tdIndex + 2) + ')').text(balanceStock.toFixed(2));
|
||||
|
||||
//next opening stock
|
||||
nextTrIndex = parseInt(parentId, 10) + 1
|
||||
var nexttr = $('#' + nextTrIndex);
|
||||
nexttr.find('td:eq(' + (1) + ')').text(balanceStock.toFixed(2));
|
||||
|
||||
}
|
||||
|
||||
|
||||
function navigateToMachine() {
|
||||
$('.close').click();
|
||||
const machineDropdown = document.getElementById('machineDropdown');
|
||||
const dateDropdown = document.getElementById('dateDropdown');
|
||||
const selectedMachine = machineDropdown.value;
|
||||
const selectedDate = dateDropdown.value;
|
||||
|
||||
const table = document.getElementById('dieselMachineTable');
|
||||
const headerCells = table.querySelectorAll('thead tr:nth-child(1) th');
|
||||
const rows = table.querySelectorAll('tbody tr');
|
||||
|
||||
let targetColumnIndex = -1;
|
||||
headerCells.forEach((header, index) => {
|
||||
if (header.getAttribute('data-id') === selectedMachine) {
|
||||
targetColumnIndex = index;
|
||||
}
|
||||
});
|
||||
|
||||
if (targetColumnIndex === -1) {
|
||||
console.log("Machine column not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
let targetRow = null;
|
||||
rows.forEach(row => {
|
||||
const dateCell = row.querySelector('td:first-child');
|
||||
if (dateCell && dateCell.textContent.trim() === selectedDate) {
|
||||
targetRow = row;
|
||||
}
|
||||
});
|
||||
|
||||
if (!targetRow) {
|
||||
console.log("Date row not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
targetColumnIndex = targetColumnIndex - 2;
|
||||
targetColumnIndex = targetColumnIndex * 6;
|
||||
targetColumnIndex = targetColumnIndex + 5;
|
||||
|
||||
targetRow.cells[targetColumnIndex].scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
inline: 'center',
|
||||
block: 'center'
|
||||
});
|
||||
|
||||
const highlightDuration = 10000;
|
||||
for (let i = targetColumnIndex; i < targetColumnIndex + 6; i++) {
|
||||
const cell = targetRow.cells[i];
|
||||
if (cell) {
|
||||
|
||||
cell.style.transition = "background-color 0.5s";
|
||||
cell.style.backgroundColor = "#df9675";
|
||||
|
||||
setTimeout(() => {
|
||||
cell.style.backgroundColor = "";
|
||||
}, highlightDuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
@ -403,6 +403,10 @@
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.datepicker {
|
||||
z-index :30 !important;
|
||||
}
|
||||
|
||||
/* This CSS is for Table Cell Expend*/
|
||||
</style>
|
||||
|
||||
@ -882,9 +886,7 @@
|
||||
|
||||
<a href="<?php echo base_url(); ?>gasStockDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Gas Stock Details</a>
|
||||
|
||||
<a href="<?php echo base_url(); ?>factoryVehicleDieselDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Diesel - Factory Vehicle </a>
|
||||
|
||||
<a href="<?php echo base_url(); ?>dieselMachineDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i> New Diesel - Factory Vehicle </a>
|
||||
<a href="<?php echo base_url(); ?>dieselMachineDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i> Diesel - Factory Vehicle </a>
|
||||
|
||||
<a href="<?php echo base_url(); ?>powerConsumptionDetails" class="dropdown-item"><i class="ri-file-info-line align-middle mr-1"></i>Power Consumption </a>
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<style>
|
||||
<style>
|
||||
|
||||
.edit{
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user