stock module latest today vadivel J 27-01-2025
This commit is contained in:
parent
830db88b7b
commit
496834541a
@ -2018,7 +2018,7 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
$electricMachines = $this->factoryMachine_model
|
$electricMachines = $this->factoryMachine_model
|
||||||
->where('is_active', 1)
|
->where('is_active', 1)
|
||||||
->where('energy_type', 'Diesel')
|
->where('energy_type', 'Electric')
|
||||||
->orderBy('id', 'asc')
|
->orderBy('id', 'asc')
|
||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
@ -2045,64 +2045,121 @@ class StockController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function updatePowerConsumptionDetails(){
|
public function updatePowerConsumptionDetails(){
|
||||||
|
|
||||||
|
//pm stands for power machine
|
||||||
|
|
||||||
|
|
||||||
$postData = $this->request->getPost();
|
$postData = $this->request->getPost();
|
||||||
|
|
||||||
$updatePowerConsumptionDetailsData = json_decode($postData['updatePowerConsumptionDetails'], true);
|
$updatePowerConsumptionDetailsData = json_decode($postData['updatePowerConsumptionDetails'], true);
|
||||||
|
|
||||||
$updates = [];
|
$updateTotalPmDetailsData = $updatePowerConsumptionDetailsData[0];
|
||||||
|
$updatePmDetailsData = $updatePowerConsumptionDetailsData[1];
|
||||||
|
|
||||||
|
//PmR stands for power machine readings
|
||||||
|
|
||||||
$inserts = [];
|
$updatesPmR = [];
|
||||||
|
$insertsPmR = [];
|
||||||
foreach ($updatePowerConsumptionDetailsData as $data) {
|
|
||||||
|
|
||||||
$date = $data['date'];
|
|
||||||
$machineId = $data['machine_id'];
|
|
||||||
|
|
||||||
|
|
||||||
$dbData = [
|
|
||||||
'date' => $data['date'],
|
|
||||||
'machine_id' => $data['machine_id'],
|
|
||||||
'opening_units' => $data['opening'],
|
|
||||||
'closing_units' => $data['receipt'],
|
|
||||||
'total_units' => $data['used']
|
|
||||||
];
|
|
||||||
|
|
||||||
$resultExists = $this->factoryVehicleDieselDetails_model
|
|
||||||
->where('date', $date)
|
|
||||||
->where('machine_id', $machineId)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
|
|
||||||
if (empty($resultExists)) {
|
|
||||||
$inserts[] = $dbData;
|
|
||||||
} else {
|
|
||||||
$dbData['id'] = $resultExists['id'];
|
|
||||||
$updates[] = $dbData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!empty($inserts)) {
|
|
||||||
$this->factoryVehicleDieselDetails_model->insertBatch($inserts);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($updates)) {
|
|
||||||
|
|
||||||
$updateResult = $this->factoryVehicleDieselDetails_model->updateBatch($updates, 'id');
|
|
||||||
|
|
||||||
if ($updateResult === FALSE) {
|
|
||||||
echo "Error during update";
|
|
||||||
} else {
|
|
||||||
echo "Data Updated Successfully";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Data Saved Successfully";
|
|
||||||
|
|
||||||
|
$updatesTotalPmR = [];
|
||||||
|
$insertsTotalPmR = [];
|
||||||
|
|
||||||
|
// Fetch existing records in bulk for power machine details
|
||||||
|
$dates = array_column($updatePmDetailsData, 'date');
|
||||||
|
$machineIds = array_column($updatePmDetailsData, 'machine_id');
|
||||||
|
$existingPmRecords = $this->powerConsumptionDetails_model
|
||||||
|
->whereIn('date', $dates)
|
||||||
|
->whereIn('machine_id', $machineIds)
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
$existingPmMap = [];
|
||||||
|
foreach ($existingPmRecords as $record) {
|
||||||
|
$existingPmMap[$record['date']][$record['machine_id']] = $record;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($updatePmDetailsData as $data) {
|
||||||
|
$date = $data['date'];
|
||||||
|
$machineId = $data['machine_id'];
|
||||||
|
|
||||||
|
$dbData = [
|
||||||
|
'date' => $data['date'],
|
||||||
|
'machine_id' => $data['machine_id'],
|
||||||
|
'opening_units' => $data['opening_units'],
|
||||||
|
'closing_units' => $data['closing_units'],
|
||||||
|
'total_units' => $data['total_units'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isset($existingPmMap[$date][$machineId])) {
|
||||||
|
$dbData['id'] = $existingPmMap[$date][$machineId]['id'];
|
||||||
|
$updatesPmR[] = $dbData;
|
||||||
|
} else {
|
||||||
|
$insertsPmR[] = $dbData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch existing records in bulk for power stock summary
|
||||||
|
$dates = array_column($updateTotalPmDetailsData, 'date');
|
||||||
|
$existingTotalPmRecords = $this->powerConsumptionSummary_model
|
||||||
|
->whereIn('date', $dates)
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
$existingTotalPmMap = [];
|
||||||
|
foreach ($existingTotalPmRecords as $record) {
|
||||||
|
$existingTotalPmMap[$record['date']] = $record;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($updateTotalPmDetailsData as $data) {
|
||||||
|
$date = $data['date'];
|
||||||
|
|
||||||
|
$dbData = [
|
||||||
|
'date' => $data['date'],
|
||||||
|
'opening_reading' => $data['opening_reading'],
|
||||||
|
'final_reading' => $data['final_reading'],
|
||||||
|
'total_reading' => $data['total_reading'],
|
||||||
|
'total_units' => $data['total_units'],
|
||||||
|
'average_pf' => $data['average_pf'],
|
||||||
|
'present_pf' => $data['present_pf'],
|
||||||
|
'md' => $data['md'],
|
||||||
|
'mf' => $data['mf']
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isset($existingTotalPmMap[$date])) {
|
||||||
|
$dbData['id'] = $existingTotalPmMap[$date]['id'];
|
||||||
|
$updatesTotalPmR[] = $dbData;
|
||||||
|
} else {
|
||||||
|
$insertsTotalPmR[] = $dbData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the transaction
|
||||||
|
$this->db->transBegin();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!empty($insertsPmR)) {
|
||||||
|
$this->powerConsumptionDetails_model->insertBatch($insertsPmR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($updatesPmR)) {
|
||||||
|
$this->powerConsumptionDetails_model->updateBatch($updatesPmR, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($insertsTotalPmR)) {
|
||||||
|
$this->powerConsumptionSummary_model->insertBatch($insertsTotalPmR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($updatesTotalPmR)) {
|
||||||
|
$this->powerConsumptionSummary_model->updateBatch($updatesTotalPmR, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit the transaction if all operations are successful
|
||||||
|
$this->db->transCommit();
|
||||||
|
echo "Data Saved Successfully";
|
||||||
|
|
||||||
|
} catch (\Exception $error) {
|
||||||
|
// Rollback the transaction in case of any errors
|
||||||
|
$this->db->transRollback();
|
||||||
|
echo "An error occurred: " . $error->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -335,11 +335,6 @@ foreach ($period as $day) {
|
|||||||
</th>
|
</th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<th class="celda_encabezado_general" colspan="3">
|
|
||||||
Others
|
|
||||||
</th>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
@ -377,7 +372,7 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
$summary = [];
|
$summary = [];
|
||||||
|
|
||||||
foreach ($groupedPowerConsumptionStockDetails as $groupedPowerConsumptionStockDetailsIndex => $powerStockDetails) {
|
foreach ($groupedPowerConsumptionStockDetails as $groupedIndex => $powerStockDetails) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -395,7 +390,7 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$startDate = DateTime::createFromFormat('Y-m-d', $totalPower[$groupedPowerConsumptionStockDetailsIndex]['date'])->format('d-m-Y');
|
$startDate = DateTime::createFromFormat('Y-m-d', $totalPower[$groupedIndex]['date'])->format('d-m-Y');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<td class="celda_normal">
|
<td class="celda_normal">
|
||||||
@ -404,72 +399,73 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
|
|
||||||
<td class="celda_normal openingTP"
|
<td class="celda_normal openingTP"
|
||||||
data-id="<?=$totalPower[$groupedPowerConsumptionStockDetailsIndex]['date']?>"
|
data-id="<?=$totalPower[$groupedIndex]['date']?>"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php if ($groupedPowerConsumptionStockDetailsIndex == 0): ?>
|
<?php if ($groupedIndex == 0): ?>
|
||||||
oninput="openingTPStockChange(this)"
|
oninput="openingTPStockChange(this)"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
><?= $totalPower[$groupedPowerConsumptionStockDetailsIndex]['opening_reading'] ?? ' ' ?></td>
|
><?= $totalPower[$groupedIndex]['opening_reading'] ?? ' ' ?></td>
|
||||||
|
|
||||||
|
|
||||||
<td class="celda_normal finalTP"
|
<td class="celda_normal finalTP"
|
||||||
data-id="<?=$totalPower[$groupedPowerConsumptionStockDetailsIndex]['date']?>"
|
data-id="<?=$totalPower[$groupedIndex]['date']?>"
|
||||||
|
|
||||||
oninput="purchaseTDStockChange(this)"
|
oninput="purchaseTDStockChange(this)"
|
||||||
contenteditable="true">
|
contenteditable="true">
|
||||||
|
|
||||||
<?= $totalPower[$groupedPowerConsumptionStockDetailsIndex]['final_reading'] ?? ' ' ?>
|
<?= $totalPower[$groupedIndex]['final_reading'] ?? ' ' ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal totalReadingTP"
|
<td class="celda_normal totalReadingTP"
|
||||||
data-id="<?=$totalPower[$groupedPowerConsumptionStockDetailsIndex]['date']?>" >
|
data-id="<?=$totalPower[$groupedIndex]['date']?>" >
|
||||||
|
|
||||||
<?= $totalPower[$groupedPowerConsumptionStockDetailsIndex]['total_reading'] ?? ' ' ?>
|
<?= $totalPower[$groupedIndex]['total_reading'] ?? ' ' ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal totalUnitsTP"
|
<td class="celda_normal totalUnitsTP"
|
||||||
data-id="<?=$totalPower[$groupedPowerConsumptionStockDetailsIndex]['date']?>"
|
data-id="<?=$totalPower[$groupedIndex]['date']?>"
|
||||||
>
|
>
|
||||||
|
|
||||||
<?= $totalPower[$groupedPowerConsumptionStockDetailsIndex]['total_units'] ?? ' ' ?>
|
<?= $totalPower[$groupedIndex]['total_units'] ?? ' ' ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal averagePfTP"
|
<td class="celda_normal averagePfTP"
|
||||||
data-id="<?=$totalPower[$groupedPowerConsumptionStockDetailsIndex]['date']?>"
|
data-id="<?=$totalPower[$groupedIndex]['date']?>"
|
||||||
>
|
>
|
||||||
|
|
||||||
<?= $totalPower[$groupedPowerConsumptionStockDetailsIndex]['average_pf'] ?? ' ' ?>
|
<?= $totalPower[$groupedIndex]['average_pf'] ?? ' ' ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal presentPfTP"
|
<td class="celda_normal presentPfTP"
|
||||||
data-id="<?=$totalPower[$groupedPowerConsumptionStockDetailsIndex]['date']?>"
|
data-id="<?=$totalPower[$groupedIndex]['date']?>"
|
||||||
>
|
>
|
||||||
|
|
||||||
<?= $totalPower[$groupedPowerConsumptionStockDetailsIndex]['present_pf'] ?? ' ' ?>
|
<?= $totalPower[$groupedIndex]['present_pf'] ?? ' ' ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal mdTP"
|
<td class="celda_normal mdTP"
|
||||||
data-id="<?=$totalPower[$groupedPowerConsumptionStockDetailsIndex]['date']?>"
|
oninput="mdTPStockChange(this)"
|
||||||
|
data-id="<?=$totalPower[$groupedIndex]['date']?>"
|
||||||
>
|
>
|
||||||
|
|
||||||
<?= $totalPower[$groupedPowerConsumptionStockDetailsIndex]['md'] ?? ' ' ?>
|
<?= $totalPower[$groupedIndex]['md'] ?? ' ' ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal mfTP"
|
<td class="celda_normal mfTP"
|
||||||
data-id="<?=$totalPower[$groupedPowerConsumptionStockDetailsIndex]['date']?>"
|
data-id="<?=$totalPower[$groupedIndex]['date']?>"
|
||||||
>
|
>
|
||||||
|
|
||||||
<?= $totalPower[$groupedPowerConsumptionStockDetailsIndex]['mf'] ?? ' ' ?>
|
<?= $totalPower[$groupedIndex]['mf'] ?? ' ' ?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@ -479,7 +475,7 @@ foreach ($period as $day) {
|
|||||||
//before closing outer loop
|
//before closing outer loop
|
||||||
|
|
||||||
if (!isset($summary['openingReading'])) {
|
if (!isset($summary['openingReading'])) {
|
||||||
$summary['openingReading'] = '-' ;
|
$summary['openingReading'] = 0 ;
|
||||||
$summary['finalReading'] = 0 ;
|
$summary['finalReading'] = 0 ;
|
||||||
$summary['totalReading'] = 0 ;
|
$summary['totalReading'] = 0 ;
|
||||||
$summary['totalUnits'] = 0 ;
|
$summary['totalUnits'] = 0 ;
|
||||||
@ -489,15 +485,19 @@ foreach ($period as $day) {
|
|||||||
$summary['mf'] = 0 ;
|
$summary['mf'] = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
$summary['openingReading'] += $totalPower[$groupedPowerConsumptionStockDetailsIndex]['openingReading'] == '-' ? 0 : $totalPower[$groupedPowerConsumptionStockDetailsIndex]['openingReading'] ;
|
|
||||||
$summary['finalReading'] += $totalPower[$groupedPowerConsumptionStockDetailsIndex]['finalReading'] == '-' ? 0 : $totalPower[$groupedPowerConsumptionStockDetailsIndex]['finalReading'] ;
|
|
||||||
$summary['totalReading'] += $totalPower[$groupedPowerConsumptionStockDetailsIndex]['totalReading'] == '-' ? 0 : $totalPower[$groupedPowerConsumptionStockDetailsIndex]['totalReading'] ;
|
$summary['openingReading'] = " " ;
|
||||||
$summary['totalUnits'] += $totalPower[$groupedPowerConsumptionStockDetailsIndex]['totalUnits'] == '-' ? 0 : $totalPower[$groupedPowerConsumptionStockDetailsIndex]['totalUnits'] ;
|
$summary['finalReading'] = is_numeric($totalPower[$groupedIndex]['final_reading']) ? $totalPower[$groupedIndex]['final_reading'] : 0 ;
|
||||||
$summary['averagePf'] += $totalPower[$groupedPowerConsumptionStockDetailsIndex]['averagePf'] == '-' ? 0 : $totalPower[$groupedPowerConsumptionStockDetailsIndex]['averagePf'] ;
|
$summary['totalReading'] += is_numeric($totalPower[$groupedIndex]['total_reading']) ? $totalPower[$groupedIndex]['total_reading'] : 0 ;
|
||||||
$summary['presentPf'] += $totalPower[$groupedPowerConsumptionStockDetailsIndex]['presentPf'] == '-' ? 0 : $totalPower[$groupedPowerConsumptionStockDetailsIndex]['balance_stock'] ;
|
$summary['totalUnits'] += is_numeric($totalPower[$groupedIndex]['total_units']) ? $totalPower[$groupedIndex]['total_units'] : 0 ;
|
||||||
$summary['md'] += $totalPower[$groupedPowerConsumptionStockDetailsIndex]['md'] == '-' ? 0 : $totalPower[$groupedPowerConsumptionStockDetailsIndex]['md'] ;
|
$summary['averagePf'] = " " ;
|
||||||
$summary['mf'] += $totalPower[$groupedPowerConsumptionStockDetailsIndex]['mf'] == '-' ? 0 : $totalPower[$groupedPowerConsumptionStockDetailsIndex]['mf'] ;
|
$summary['presentPf'] = " ";
|
||||||
|
$summary['md'] = " " ;
|
||||||
|
$summary['mf'] = " " ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@ -521,7 +521,7 @@ foreach ($period as $day) {
|
|||||||
<td class="celda_normal openingUnits"
|
<td class="celda_normal openingUnits"
|
||||||
data-id="<?= $powerStock['date'] ?> <?= $powerStock['machine_id'] ?>"
|
data-id="<?= $powerStock['date'] ?> <?= $powerStock['machine_id'] ?>"
|
||||||
|
|
||||||
<?php if ($groupedPowerConsumptionStockDetailsIndex == 0): ?>
|
<?php if ($groupedIndex == 0): ?>
|
||||||
oninput="openingUnitsChange(this)"
|
oninput="openingUnitsChange(this)"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
<?php endif; ?>>
|
<?php endif; ?>>
|
||||||
@ -570,8 +570,8 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
// Sum values for the material
|
// Sum values for the material
|
||||||
|
|
||||||
$summary["machineId_$machineId"]['opening_units'] = 0 ;
|
$summary["machineId_$machineId"]['opening_units'] = " " ;
|
||||||
$summary["machineId_$machineId"]['closing_units'] += is_numeric($powerStock['closing_units']) ? $powerStock['closing_units'] : 0 ;
|
$summary["machineId_$machineId"]['closing_units'] = " " ;
|
||||||
$summary["machineId_$machineId"]['total_units'] += is_numeric($powerStock['total_units']) ? $powerStock['total_units'] : 0 ;
|
$summary["machineId_$machineId"]['total_units'] += is_numeric($powerStock['total_units']) ? $powerStock['total_units'] : 0 ;
|
||||||
|
|
||||||
|
|
||||||
@ -592,25 +592,25 @@ foreach ($period as $day) {
|
|||||||
<table id="powerStockDetailsTableSummaryId" class="fht-table table-striped">
|
<table id="powerStockDetailsTableSummaryId" class="fht-table table-striped">
|
||||||
|
|
||||||
<thead >
|
<thead >
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="celda_encabezado_general" colspan="1">Date </th>
|
<th class="celda_encabezado_total" colspan="1">Date </th>
|
||||||
<th class="celda_encabezado_general">Opening Reading </th>
|
<th class="celda_encabezado_total">Opening Reading </th>
|
||||||
<th class="celda_encabezado_general">Final Reading</th>
|
<th class="celda_encabezado_total">Final Reading</th>
|
||||||
<th class="celda_encabezado_general">Total Reading</th>
|
<th class="celda_encabezado_total">Total Reading</th>
|
||||||
<th class="celda_encabezado_general">Total Units </th>
|
<th class="celda_encabezado_total">Total Units </th>
|
||||||
<th class="celda_encabezado_general">Average PF</th>
|
<th class="celda_encabezado_total">Average PF</th>
|
||||||
<th class="celda_encabezado_general">Present PF</th>
|
<th class="celda_encabezado_total">Present PF</th>
|
||||||
<th class="celda_encabezado_general">MD </th>
|
<th class="celda_encabezado_total">MD </th>
|
||||||
<th class="celda_encabezado_general">MF *60</th>
|
<th class="celda_encabezado_total">MF *60</th>
|
||||||
|
|
||||||
<?php foreach ($powerMachines as $powerMachine) { ?>
|
<?php foreach ($electricMachines as $powerMachine) { ?>
|
||||||
<!-- this will loop till machines present -->
|
<!-- this will loop till machines present -->
|
||||||
<th class="celda_encabezado_general" style="display:none">Date</th>
|
<th class="celda_encabezado_total" style="display:none">Date</th>
|
||||||
<th class="celda_encabezado_general" style="display:none"> Machine Id</th>
|
<th class="celda_encabezado_total" style="display:none"> Machine Id</th>
|
||||||
<th class="celda_encabezado_general">Opening Units</th>
|
<th class="celda_encabezado_total">Opening Units</th>
|
||||||
<th class="celda_encabezado_general">Final Units</th>
|
<th class="celda_encabezado_total">Final Units</th>
|
||||||
<th class="celda_encabezado_general">Total Units</th>
|
<th class="celda_encabezado_total">Total Units</th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -728,21 +728,22 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
> </td>
|
> </td>
|
||||||
|
|
||||||
<td class="celda_normal averagePfTP"
|
<td class="celda_normal averagePfTP" contenteditable="true"
|
||||||
data-id="<?= $dateInMonth ?>"
|
data-id="<?= $dateInMonth ?>"
|
||||||
|
|
||||||
> </td>
|
> </td>
|
||||||
<td class="celda_normal presentPfTP"
|
<td class="celda_normal presentPfTP" contenteditable="true"
|
||||||
data-id="<?= $dateInMonth ?>"
|
data-id="<?= $dateInMonth ?>"
|
||||||
|
|
||||||
> </td>
|
> </td>
|
||||||
|
|
||||||
<td class="celda_normal mdTP"
|
<td class="celda_normal mdTP" contenteditable="true"
|
||||||
|
oninput="mdTPStockChange(this)"
|
||||||
data-id="<?= $dateInMonth ?>"
|
data-id="<?= $dateInMonth ?>"
|
||||||
|
|
||||||
> </td>
|
> </td>
|
||||||
|
|
||||||
<td class="celda_normal mfTP"
|
<td class="celda_normal mfTP"
|
||||||
data-id="<?= $dateInMonth ?>"
|
data-id="<?= $dateInMonth ?>"
|
||||||
|
|
||||||
> </td>
|
> </td>
|
||||||
@ -829,9 +830,9 @@ foreach ($period as $day) {
|
|||||||
<!-- bag Dropdown -->
|
<!-- bag Dropdown -->
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="dieselDropdown">Select Bag</label>
|
<label for="powerDropdown">Select Bag</label>
|
||||||
<select id="dieselDropdown" class="form-control">
|
<select id="powerDropdown" class="form-control">
|
||||||
<option value="">Select Diesel</option>
|
<option value="">Select Electric Machines</option>
|
||||||
<?php foreach ($electricMachines as $powerMachine): ?>
|
<?php foreach ($electricMachines as $powerMachine): ?>
|
||||||
<option value=" <?= $powerMachine['machine_name'] ?>">
|
<option value=" <?= $powerMachine['machine_name'] ?>">
|
||||||
<?= $powerMachine['machine_name'] ?>
|
<?= $powerMachine['machine_name'] ?>
|
||||||
@ -857,7 +858,7 @@ foreach ($period as $day) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary float-right" onclick="navigateToDiesel()">Navigate</button>
|
<button class="btn btn-primary float-right" onclick="navigateToPower()">Navigate</button>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- /.modal-content -->
|
</div><!-- /.modal-content -->
|
||||||
</div><!-- /.modal-dialog -->
|
</div><!-- /.modal-dialog -->
|
||||||
@ -868,11 +869,11 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function navigateToDiesel() {
|
function navigateToPower() {
|
||||||
$('.close').click();
|
$('.close').click();
|
||||||
const dieselDropdown = document.getElementById('dieselDropdown');
|
const powerDropdown = document.getElementById('powerDropdown');
|
||||||
const dateDropdown = document.getElementById('dateDropdown');
|
const dateDropdown = document.getElementById('dateDropdown');
|
||||||
const selectedDiesel = dieselDropdown.value;
|
const selectedPower = powerDropdown.value;
|
||||||
const selectedDate = dateDropdown.value;
|
const selectedDate = dateDropdown.value;
|
||||||
|
|
||||||
const table = document.getElementById('powerStockDetailsTableId');
|
const table = document.getElementById('powerStockDetailsTableId');
|
||||||
@ -881,14 +882,14 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
let targetColumnIndex = -1;
|
let targetColumnIndex = -1;
|
||||||
headerCells.forEach((header, index) => {
|
headerCells.forEach((header, index) => {
|
||||||
if ((header.innerText.trim()) === selectedDiesel.trim()) {
|
if ((header.innerText.trim()) === selectedPower.trim()) {
|
||||||
targetColumnIndex = index;
|
targetColumnIndex = index;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (targetColumnIndex === -1) {
|
if (targetColumnIndex === -1) {
|
||||||
console.log("Diesel column not found.");
|
console.log("power column not found.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,7 +947,7 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
//table to json function
|
//table to json function
|
||||||
|
|
||||||
var updatePowerMachineDetails = tableToJson();
|
var updatePowerConsumptionDetails = tableToJson();
|
||||||
|
|
||||||
|
|
||||||
alert('Updation may take a while, And we appreciate your patience..!!');
|
alert('Updation may take a while, And we appreciate your patience..!!');
|
||||||
@ -954,10 +955,10 @@ foreach ($period as $day) {
|
|||||||
$('#loader').show();
|
$('#loader').show();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: {
|
data: {
|
||||||
updatePowerMachineDetails
|
updatePowerConsumptionDetails
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?php echo base_url() ?>updatePowerMachineDetails",
|
url: "<?php echo base_url() ?>updatePowerConsumptionDetails",
|
||||||
|
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -1003,13 +1004,17 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
const formattedDate = `${date.split('-')[2]}-${date.split('-')[1]}-${date.split('-')[0]}`;
|
const formattedDate = `${date.split('-')[2]}-${date.split('-')[1]}-${date.split('-')[0]}`;
|
||||||
|
|
||||||
|
|
||||||
const summaryRowData = {
|
const summaryRowData = {
|
||||||
date: formattedDate,
|
date: formattedDate,
|
||||||
opening_stock: rowCells.eq(1).text().trim(),
|
opening_reading: rowCells.eq(1).text().trim(),
|
||||||
purchase_diesel: rowCells.eq(2).text().trim(),
|
final_reading : rowCells.eq(2).text().trim(),
|
||||||
total_filling_diesel: rowCells.eq(3).text().trim(),
|
total_reading : rowCells.eq(3).text().trim(),
|
||||||
balance_stock: rowCells.eq(4).text().trim(),
|
total_units : rowCells.eq(4).text().trim(),
|
||||||
|
average_pf : rowCells.eq(5).text().trim(),
|
||||||
|
present_pf : rowCells.eq(6).text().trim(),
|
||||||
|
md : rowCells.eq(7).text().trim(),
|
||||||
|
mf : rowCells.eq(8).text().trim()
|
||||||
};
|
};
|
||||||
|
|
||||||
summaryRowPart.push(summaryRowData);
|
summaryRowPart.push(summaryRowData);
|
||||||
@ -1018,16 +1023,13 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
/** we get eight entries against a machines so we loop from 1 to 8 and so on
|
/** we get eight entries against a machines so we loop from 1 to 8 and so on
|
||||||
in a single row **/
|
in a single row **/
|
||||||
for (let i = 5 ; i < rowCells.length; i += 8) {
|
for (let i = 9 ; i < rowCells.length; i += 5 ) {
|
||||||
const readingsRowData = {
|
const readingsRowData = {
|
||||||
date: rowCells.eq(i).text().trim(),
|
date: rowCells.eq(i).text().trim(),
|
||||||
machine_id: rowCells.eq(i + 1).text().trim(),
|
machine_id: rowCells.eq(i + 1).text().trim(),
|
||||||
opening_reading: rowCells.eq(i + 2).text().trim(),
|
opening_units: rowCells.eq(i + 2).text().trim(),
|
||||||
closing_reading: rowCells.eq(i + 3).text().trim(),
|
closing_units: rowCells.eq(i + 3).text().trim(),
|
||||||
filling_diesel: rowCells.eq(i + 4).text().trim(),
|
total_units : rowCells.eq(i + 4).text().trim(),
|
||||||
consumption: rowCells.eq(i + 5).text().trim(),
|
|
||||||
running_hours: rowCells.eq(i + 6).text().trim(),
|
|
||||||
mileage: rowCells.eq(i + 7).text().trim()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
readingsRowPart.push(readingsRowData);
|
readingsRowPart.push(readingsRowData);
|
||||||
@ -1049,22 +1051,20 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function openingReadingChange(tdElement) {
|
function openingUnitsChange(tdElement) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
let dataId = tdElement.getAttribute('data-id');
|
||||||
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
|
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
|
||||||
let openingReading = validateInput(tdElement.innerText);
|
let openingUnits = validateInput(tdElement.innerText);
|
||||||
let closingReading = validateInput(document.querySelector(`td.closingReading[data-id="${dataId}"]`).innerText);
|
let closingUnits = validateInput(document.querySelector(`td.closingUnits[data-id="${dataId}"]`).innerText);
|
||||||
let consumption = validateInput(document.querySelector(`td.consumption[data-id="${dataId}"]`).innerText);
|
|
||||||
let runningHours = Math.abs(Number(closingReading) - Number(openingReading));
|
|
||||||
let mileage = consumption == 0 || runningHours == 0 ? 0 : (Number(consumption) / Number(runningHours)).toFixed(2) ;
|
|
||||||
|
|
||||||
document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText = runningHours;
|
let totalUnits = parseFloat(closingUnits) - parseFloat(openingUnits) ;
|
||||||
document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = mileage;
|
|
||||||
|
document.querySelector(`td.totalUnits[data-id="${dataId}"]`).innerText = (totalUnits).toFixed(2);
|
||||||
|
|
||||||
|
|
||||||
updateStockValue(date,machine_id,closingReading)
|
updateStockValue(date,machine_id,closingUnits)
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -1074,21 +1074,20 @@ foreach ($period as $day) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closingReadingChange(tdElement) {
|
function closingUnitsChange(tdElement) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
let dataId = tdElement.getAttribute('data-id');
|
||||||
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
|
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
|
||||||
let closingReading = validateInput(tdElement.innerText);
|
let openingUnits = validateInput(document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText);
|
||||||
let openingReading = validateInput(document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText);
|
let closingUnits = validateInput(tdElement.innerText);
|
||||||
let consumption = validateInput(document.querySelector(`td.consumption[data-id="${dataId}"]`).innerText);
|
|
||||||
let runningHours = Math.abs(Number(closingReading) - Number(openingReading));
|
|
||||||
let mileage = consumption == 0 || runningHours == 0 ? 0 : (Number(consumption) / Number(runningHours)).toFixed(2) ;
|
|
||||||
|
|
||||||
document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText = runningHours;
|
let totalUnits = parseFloat(closingUnits) - parseFloat(openingUnits) ;
|
||||||
document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = mileage;
|
|
||||||
|
|
||||||
updateStockValue(date, machine_id, closingReading)
|
document.querySelector(`td.totalUnits[data-id="${dataId}"]`).innerText = (totalUnits).toFixed(2);
|
||||||
|
|
||||||
|
|
||||||
|
updateStockValue(date,machine_id,closingUnits)
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -1099,92 +1098,24 @@ foreach ($period as $day) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function consumptionChange(tdElement) {
|
function openingTPStockChange(tdElement){
|
||||||
|
|
||||||
try {
|
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
|
||||||
let [date, machine_id] = tdElement.getAttribute('data-id').split(' ');
|
|
||||||
let closingReading = validateInput(document.querySelector(`td.closingReading[data-id="${dataId}"]`).innerText);
|
|
||||||
let openingReading = validateInput(document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText);
|
|
||||||
let consumption = validateInput(tdElement.innerText);
|
|
||||||
let runningHours = Math.abs(Number(closingReading) - Number(openingReading));
|
|
||||||
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.mileage[data-id="${dataId}"]`).innerText = mileage;
|
|
||||||
|
|
||||||
updateStockValue(date, machine_id, closingReading)
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
console.error("There is an error updating stock ..!!" + error);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function fillingReadingChange(tdElement) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
|
||||||
let [date,machine_id] = tdElement.getAttribute('data-id').split(" ");
|
|
||||||
|
|
||||||
|
|
||||||
let fillingDiesel = tdElement.innerText;
|
|
||||||
|
|
||||||
let totalFillingDiesel = 0 ;
|
|
||||||
|
|
||||||
let machines = <?= json_encode($electricMachines) ?> ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
machines.forEach((each)=>{
|
|
||||||
totalFillingDiesel += Number(document.querySelector(`td.fillingDiesel[data-id="${date} ${each.id}"]`).innerText
|
|
||||||
)});
|
|
||||||
|
|
||||||
|
|
||||||
document.querySelector(`td.fillingTD[data-id="${date}"]`).innerText = totalFillingDiesel;
|
|
||||||
|
|
||||||
let openingTD = validateInput(document.querySelector(`td.openingTD[data-id="${date}"]`).innerText);
|
|
||||||
|
|
||||||
let purchaseTD = validateInput(document.querySelector(`td.purchaseTD[data-id="${date}"]`).innerText);
|
|
||||||
|
|
||||||
let balanceTD = (Number(openingTD) + Number(purchaseTD)) - Number(totalFillingDiesel) ;
|
|
||||||
|
|
||||||
document.querySelector(`td.balanceTD[data-id="${date}"]`).innerText = balanceTD ;
|
|
||||||
|
|
||||||
updateTotalStockValue(date, balanceTD) ;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
console.error("There is an error updating stock ..!!" + error);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function openingTDStockChange(tdElement){
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
let dataId = tdElement.getAttribute('data-id') ;
|
||||||
|
|
||||||
let openingTD = validateInput(tdElement.innerText);
|
let openingTP = validateInput(tdElement.innerText) ;
|
||||||
let purchaseTD = validateInput(document.querySelector(`td.purchaseTD[data-id="${dataId}"]`).innerText);
|
let finalTP = validateInput(document.querySelector(`td.finalTP[data-id="${dataId}"]`).innerText) ;
|
||||||
let fillingTD = validateInput(document.querySelector(`td.fillingTD[data-id="${dataId}"]`).innerText);
|
|
||||||
|
|
||||||
|
let totalReadingTP = (Number(finalTP) - Number(openingTP)) ;
|
||||||
|
|
||||||
let balanceTD = (Number(openingTD) + Number(purchaseTD)) - Number(fillingTD) ;
|
let totalUnitsTP = totalReadingTP * 60 ;
|
||||||
|
|
||||||
document.querySelector(`td.balanceTD[data-id="${dataId}"]`).innerText = balanceTD ;
|
document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText = totalReadingTP ;
|
||||||
|
|
||||||
|
document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = totalUnitsTP ;
|
||||||
|
|
||||||
updateTotalStockValue(dataId , balanceTD)
|
updateTotalStockValue(dataId , finalTP) ;
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -1195,20 +1126,24 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function purchaseTDStockChange(tdElement){
|
function finalTPStockChange(tdElement){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
|
||||||
let purchaseTD = validateInput(tdElement.innerText);
|
let dataId = tdElement.getAttribute('data-id');
|
||||||
let openingTD = validateInput(document.querySelector(`td.openingTD[data-id="${dataId}"]`).innerText);
|
|
||||||
let fillingTD = validateInput(document.querySelector(`td.fillingTD[data-id="${dataId}"]`).innerText);
|
|
||||||
let balanceTD = validateInput(document.querySelector(`td.balanceTD[data-id="${dataId}"]`).innerText);
|
|
||||||
|
|
||||||
balanceTD = (Number(openingTD) + Number(purchaseTD)) - Number(fillingTD) ;
|
let openingTP = validateInput(document.querySelector(`td.openingTP[data-id="${dataId}"]`).innerText);
|
||||||
|
let finalTP = validateInput(tdElement.innerText);
|
||||||
|
|
||||||
document.querySelector(`td.balanceTD[data-id="${dataId}"]`).innerText = balanceTD ;
|
let totalReadingTP = (Number(finalTP) - Number(openingTP)) ;
|
||||||
|
|
||||||
updateTotalStockValue(dataId, balanceTD) ;
|
let totalUnitsTP = totalReadingTP * 60 ;
|
||||||
|
|
||||||
|
document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText = totalReadingTP ;
|
||||||
|
|
||||||
|
document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = totalUnitsTP ;
|
||||||
|
|
||||||
|
updateTotalStockValue(dataId , finalTP)
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -1219,6 +1154,24 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mdTPStockChange(tdElement){
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
let dataId = tdElement.getAttribute('data-id');
|
||||||
|
|
||||||
|
let mdTP = validateInput(tdElement.innerText);
|
||||||
|
|
||||||
|
document.querySelector(`td.mfTP[data-id="${dataId}"]`).innerText = (mdTP * 60).toFixed(2) ;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
console.error("There is an error updating stock ..!!" + error) ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function validateInput(input) {
|
function validateInput(input) {
|
||||||
|
|
||||||
@ -1250,7 +1203,7 @@ foreach ($period as $day) {
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
function updateStockValue(date, machine_id, closingReading) {
|
function updateStockValue(date, machine_id, closingUnits) {
|
||||||
|
|
||||||
const table = $('#powerStockDetailsTableId');
|
const table = $('#powerStockDetailsTableId');
|
||||||
const rows = [];
|
const rows = [];
|
||||||
@ -1264,33 +1217,20 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
|
|
||||||
if (new Date(otherDate) > new Date(date)) {
|
if (new Date(otherDate) > new Date(date)) {
|
||||||
|
|
||||||
//other records present after it
|
|
||||||
|
|
||||||
/**this data-id ,openingStock ,used stock , current Balance Stock
|
console.log(otherDate);
|
||||||
is for changing subsequent dates not the earlier one **/
|
|
||||||
|
|
||||||
let dataId = `${otherDate} ${machine_id}`;
|
let dataId = `${otherDate} ${machine_id}`;
|
||||||
|
|
||||||
document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText = closingReading == 0 ? " " : closingReading ;
|
document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText = closingUnits == 0 ? " " : closingUnits ;
|
||||||
|
|
||||||
let openingReading = validateInput(document.querySelector(`td.openingReading[data-id="${dataId}"]`).innerText);
|
let openingUnits = validateInput(document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
let runningHours = validateInput(document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText);
|
let totalUnits = validateInput(document.querySelector(`td.totalUnits[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
closingReading = Math.abs(Number(openingReading) + Number(runningHours));
|
closingUnits = Math.abs(Number(openingUnits) + Number(totalUnits));
|
||||||
|
|
||||||
let consumption = validateInput(document.querySelector(`td.consumption[data-id="${dataId}"]`).innerText);
|
document.querySelector(`td.closingUnits[data-id="${dataId}"]`).innerText = closingUnits == 0 ? " " : closingUnits ;
|
||||||
|
|
||||||
runningHours = Math.abs(Number(closingReading) - Number(openingReading));
|
|
||||||
|
|
||||||
let mileage = consumption == 0 || runningHours == 0 ? 0 : (Number(consumption) / Number(runningHours)).toFixed(2) ;
|
|
||||||
|
|
||||||
document.querySelector(`td.runningHours[data-id="${dataId}"]`).innerText = runningHours == 0 ? " " : runningHours ;
|
|
||||||
|
|
||||||
document.querySelector(`td.mileage[data-id="${dataId}"]`).innerText = mileage == 0 ? " " : mileage ;
|
|
||||||
|
|
||||||
document.querySelector(`td.closingReading[data-id="${dataId}"]`).innerText = closingReading == 0 ? " " : closingReading ;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1300,7 +1240,9 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function updateTotalStockValue(date, balanceTD){
|
function updateTotalStockValue(date, finalTP){
|
||||||
|
|
||||||
|
console.log("inside updateTotalStockValue");
|
||||||
|
|
||||||
const table = $('#powerStockDetailsTableId');
|
const table = $('#powerStockDetailsTableId');
|
||||||
const rows = [];
|
const rows = [];
|
||||||
@ -1314,29 +1256,30 @@ foreach ($period as $day) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (new Date(otherDate) > new Date(date)) { //other records present after it
|
if (new Date(otherDate) > new Date(date)) {
|
||||||
|
|
||||||
/**this data-id ,openingStock ,used stock , current Balance Stock
|
console.log(date);
|
||||||
is for changing subsequent dates not the earlier one **/
|
console.log(otherDate);
|
||||||
|
|
||||||
let dataId = `${otherDate}`;
|
let dataId = `${otherDate}`;
|
||||||
|
|
||||||
|
|
||||||
document.querySelector(`td.openingTD[data-id="${dataId}"]`).innerText = balanceTD;
|
document.querySelector(`td.openingTP[data-id="${dataId}"]`).innerText = finalTP == 0 ? " " : finalTP ;
|
||||||
|
|
||||||
let openingTD = document.querySelector(`td.openingTD[data-id="${dataId}"]`).innerText;
|
let openingTP = validateInput(document.querySelector(`td.openingTP[data-id="${dataId}"]`).innerText) ;
|
||||||
|
|
||||||
|
let totalReadingTP = validateInput(document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText) ;
|
||||||
|
|
||||||
|
let finalTp = openingTP + totalReadingTP ;
|
||||||
|
|
||||||
|
let totalUnitsTP = Number(totalReadingTP * 60 );
|
||||||
|
|
||||||
|
|
||||||
let purchaseTD = document.querySelector(`td.purchaseTD[data-id="${dataId}"]`).innerText ;
|
document.querySelector(`td.finalTP[data-id="${dataId}"]`).innerText = finalTP == 0 ? " " : finalTP;
|
||||||
|
document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText = totalReadingTP == 0 ? " " : totalReadingTP ;
|
||||||
|
document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = totalUnitsTP == 0 ? " " : totalUnitsTP;
|
||||||
|
|
||||||
|
|
||||||
let fillingTD = document.querySelector(`td.fillingTD[data-id="${dataId}"]`).innerText ;
|
|
||||||
|
|
||||||
|
|
||||||
balanceTD = (Number(openingTD) + Number(purchaseTD)) - Number(fillingTD) ;
|
|
||||||
|
|
||||||
document.querySelector(`td.balanceTD[data-id="${dataId}"]`).innerText = balanceTD ;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user