stock module latest today vadivel J 21-02-2025

This commit is contained in:
vadivelJ96 2025-02-21 12:22:49 +05:30
parent 50db9f5ae5
commit 2885d14239
4 changed files with 423 additions and 468 deletions

View File

@ -146,7 +146,7 @@ class Rawmaterialdetails_model extends Model
$builder = $this->db->table('t_materialmaster') $builder = $this->db->table('t_materialmaster')
->select('MaterialCode') ->select('MaterialCode')
->where('Category', 'silica sand') ->where('Category', '248')
->orderBy('CreatedDate', 'desc'); ->orderBy('CreatedDate', 'desc');
$query = $builder->get(); $query = $builder->get();
$materialResults = $query->getResultArray(); $materialResults = $query->getResultArray();
@ -158,7 +158,7 @@ class Rawmaterialdetails_model extends Model
$builder = $this->db->table('t_materialmaster') $builder = $this->db->table('t_materialmaster')
->select('MaterialCode') ->select('MaterialCode')
->where('Category', 'waste core') ->where('Category', '328')
->orderBy('CreatedDate', 'desc'); ->orderBy('CreatedDate', 'desc');
$query = $builder->get(); $query = $builder->get();
$materialResults = $query->getResultArray(); $materialResults = $query->getResultArray();
@ -171,7 +171,7 @@ class Rawmaterialdetails_model extends Model
//when no data present for current month we are showing only active materials with filter option //when no data present for current month we are showing only active materials with filter option
$builder = $this->db->table('t_materialmaster') $builder = $this->db->table('t_materialmaster')
->select('MaterialCode, MaterialName') ->select('MaterialCode, MaterialName')
->where('Category', 'Packing Material') ->where('Category', '236')
->where('IsActive', 1) ->where('IsActive', 1)
->orderBy('MaterialCode', 'asc'); ->orderBy('MaterialCode', 'asc');
$query = $builder->get(); $query = $builder->get();
@ -184,7 +184,7 @@ class Rawmaterialdetails_model extends Model
//when data present with whether material is active or not we have to show them with filter option //when data present with whether material is active or not we have to show them with filter option
$builder = $this->db->table('t_materialmaster') $builder = $this->db->table('t_materialmaster')
->select('MaterialCode, MaterialName') ->select('MaterialCode, MaterialName')
->where('Category', 'Packing Material') ->where('Category', '236')
->whereIn('MaterialCode', $distinctMaterialCodes) ->whereIn('MaterialCode', $distinctMaterialCodes)
->orderBy('MaterialCode', 'asc'); ->orderBy('MaterialCode', 'asc');
$query = $builder->get(); $query = $builder->get();
@ -199,7 +199,7 @@ class Rawmaterialdetails_model extends Model
$builder = $this->db->table('t_materialmaster') $builder = $this->db->table('t_materialmaster')
->select('MaterialCode , MaterialName') ->select('MaterialCode , MaterialName')
->where('IsActive', 1) ->where('IsActive', 1)
->where('Category', 'Resin') ->where('Category', '327')
->orderBy('MaterialCode', 'asc'); ->orderBy('MaterialCode', 'asc');
$query = $builder->get(); $query = $builder->get();
$materialResults = $query->getResultArray(); $materialResults = $query->getResultArray();
@ -212,6 +212,7 @@ class Rawmaterialdetails_model extends Model
{ {
$builder = $this->db->table('t_materialmaster') $builder = $this->db->table('t_materialmaster')
->select('MaterialCode, MaterialName') ->select('MaterialCode, MaterialName')
->where('Category', '327')
->whereIn('MaterialCode', $distinctMaterialCodes) // Matches MaterialCode with the array ->whereIn('MaterialCode', $distinctMaterialCodes) // Matches MaterialCode with the array
->orderBy('MaterialCode', 'asc'); ->orderBy('MaterialCode', 'asc');

View File

@ -704,6 +704,7 @@ foreach ($period as $day) {
<?php <?php
// dd($previousMonthDieselMachineStockDetails);
foreach ($dieselMachines as $dieselMachineIndex => $dieselMachine) { foreach ($dieselMachines as $dieselMachineIndex => $dieselMachine) {
?> ?>
<!-- this will loop till machines present --> <!-- this will loop till machines present -->
@ -731,7 +732,7 @@ foreach ($period as $day) {
><?= !empty($previousMonthDieselMachineStockDetails) ><?= (!empty($previousMonthDieselMachineStockDetails) && isset($previousMonthDieselMachineStockDetails[$dieselMachineIndex]) )
? $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading'] ? $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading']
:" " ; :" " ;
?> ?>
@ -740,7 +741,9 @@ foreach ($period as $day) {
<td class="celda_normal closingReading" <td class="celda_normal closingReading"
data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>" data-id="<?= $dateInMonth ?> <?= $dieselMachine['id'] ?>"
oninput="closingReadingChange(this)" oninput="closingReadingChange(this)"
contenteditable="true"><?= !empty($previousMonthDieselMachineStockDetails) contenteditable="true">
<?= !empty($previousMonthDieselMachineStockDetails) && isset($previousMonthDieselMachineStockDetails[$dieselMachineIndex])
? $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading'] ? $previousMonthDieselMachineStockDetails[$dieselMachineIndex]['closing_reading']
:" " ; :" " ;
?> ?>

View File

@ -156,7 +156,7 @@
} }
.celda_encabezado_total { .celda_encabezado_total {
background-color:#ffffff !important; background-color: #ffffff !important;
border: 1px solid #ffffff; border: 1px solid #ffffff;
color: #ffffff !important; color: #ffffff !important;
font-weight: bold; font-weight: bold;
@ -177,12 +177,14 @@
.fht-table thead { .fht-table thead {
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 20; /* Ensure the entire header stays above table rows */ z-index: 20;
background-color: #50bbd9; /* Header background color */ /* Ensure the entire header stays above table rows */
background-color: #50bbd9;
/* Header background color */
} }
.dropdown-menu { .dropdown-menu {
z-index :25 ; z-index: 25;
} }
@ -191,8 +193,10 @@
.fht-table thead th { .fht-table thead th {
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 11; /* Higher than table rows but lower than first column */ z-index: 11;
background-color: #50bbd9; /* Green background */ /* Higher than table rows but lower than first column */
background-color: #50bbd9;
/* Green background */
color: #ffffff; color: #ffffff;
border: 1px solid #ddd; border: 1px solid #ddd;
padding: 10px; padding: 10px;
@ -204,7 +208,8 @@
position: sticky; position: sticky;
left: 0; left: 0;
background-color: #50bbd9; background-color: #50bbd9;
z-index: 15; /* Ensures it stays above other cells */ z-index: 15;
/* Ensures it stays above other cells */
border-right: 2px solid #ddd; border-right: 2px solid #ddd;
color: #ffffff; color: #ffffff;
} }
@ -213,21 +218,15 @@
.table-responsive { .table-responsive {
overflow-x: auto; overflow-x: auto;
overflow-y: auto; overflow-y: auto;
max-height: 500px; /* Adjust as needed */ max-height: 500px;
/* Adjust as needed */
position: relative; position: relative;
} }
td{ td {
min-width: 100px; min-width: 100px;
max-width: 100px; max-width: 100px;
} }
</style> </style>
@ -404,20 +403,18 @@ foreach ($period as $day) {
<td class="celda_normal openingTP" <td class="celda_normal openingTP"
data-id="<?=$totalPower[$groupedIndex]['date']?>" data-id="<?= $totalPower[$groupedIndex]['date'] ?>"
<?php if ($groupedIndex == 0): ?> <?php if ($groupedIndex == 0): ?>
oninput="openingTPStockChange(this)" oninput="openingTPStockChange(this)"
contenteditable="true" contenteditable="true"
<?php endif; ?> <?php endif; ?>><?= $totalPower[$groupedIndex]['opening_reading'] ?? ' ' ?></td>
><?= $totalPower[$groupedIndex]['opening_reading'] ?? ' ' ?></td>
<td class="celda_normal finalTP" <td class="celda_normal finalTP"
data-id="<?=$totalPower[$groupedIndex]['date']?>" data-id="<?= $totalPower[$groupedIndex]['date'] ?>"
oninput="finalTPStockChange(this)" oninput="finalTPStockChange(this)"
contenteditable="true"> contenteditable="true">
@ -427,31 +424,28 @@ foreach ($period as $day) {
</td> </td>
<td class="celda_normal totalReadingTP" <td class="celda_normal totalReadingTP"
data-id="<?=$totalPower[$groupedIndex]['date']?>" > data-id="<?= $totalPower[$groupedIndex]['date'] ?>">
<?= $totalPower[$groupedIndex]['total_reading'] ?? ' ' ?> <?= $totalPower[$groupedIndex]['total_reading'] ?? ' ' ?>
</td> </td>
<td class="celda_normal totalUnitsTP" <td class="celda_normal totalUnitsTP"
data-id="<?=$totalPower[$groupedIndex]['date']?>" data-id="<?= $totalPower[$groupedIndex]['date'] ?>">
>
<?= $totalPower[$groupedIndex]['total_units'] ?? ' ' ?> <?= $totalPower[$groupedIndex]['total_units'] ?? ' ' ?>
</td> </td>
<td class="celda_normal averagePfTP" contenteditable="true" <td class="celda_normal averagePfTP" contenteditable="true"
data-id="<?=$totalPower[$groupedIndex]['date']?>" data-id="<?= $totalPower[$groupedIndex]['date'] ?>">
>
<?= $totalPower[$groupedIndex]['average_pf'] ?? ' ' ?> <?= $totalPower[$groupedIndex]['average_pf'] ?? ' ' ?>
</td> </td>
<td class="celda_normal presentPfTP" contenteditable="true" <td class="celda_normal presentPfTP" contenteditable="true"
data-id="<?=$totalPower[$groupedIndex]['date']?>" data-id="<?= $totalPower[$groupedIndex]['date'] ?>">
>
<?= $totalPower[$groupedIndex]['present_pf'] ?? ' ' ?> <?= $totalPower[$groupedIndex]['present_pf'] ?? ' ' ?>
@ -459,16 +453,14 @@ foreach ($period as $day) {
<td class="celda_normal mdTP" contenteditable="true" <td class="celda_normal mdTP" contenteditable="true"
oninput="mdTPStockChange(this)" oninput="mdTPStockChange(this)"
data-id="<?=$totalPower[$groupedIndex]['date']?>" data-id="<?= $totalPower[$groupedIndex]['date'] ?>">
>
<?= $totalPower[$groupedIndex]['md'] ?? ' ' ?> <?= $totalPower[$groupedIndex]['md'] ?? ' ' ?>
</td> </td>
<td class="celda_normal mfTP" <td class="celda_normal mfTP"
data-id="<?=$totalPower[$groupedIndex]['date']?>" data-id="<?= $totalPower[$groupedIndex]['date'] ?>">
>
<?= $totalPower[$groupedIndex]['mf'] ?? ' ' ?> <?= $totalPower[$groupedIndex]['mf'] ?? ' ' ?>
@ -480,26 +472,26 @@ foreach ($period as $day) {
//before closing outer loop //before closing outer loop
if (!isset($summary['openingReading'])) { if (!isset($summary['openingReading'])) {
$summary['openingReading'] = 0 ; $summary['openingReading'] = 0;
$summary['finalReading'] = 0 ; $summary['finalReading'] = 0;
$summary['totalReading'] = 0 ; $summary['totalReading'] = 0;
$summary['totalUnits'] = 0 ; $summary['totalUnits'] = 0;
$summary['averagePf'] = 0 ; $summary['averagePf'] = 0;
$summary['presentPf'] = 0 ; $summary['presentPf'] = 0;
$summary['md'] = 0 ; $summary['md'] = 0;
$summary['mf'] = 0 ; $summary['mf'] = 0;
} }
$summary['openingReading'] = " " ; $summary['openingReading'] = " ";
$summary['finalReading'] = is_numeric($totalPower[$groupedIndex]['final_reading']) ? $totalPower[$groupedIndex]['final_reading'] : 0 ; $summary['finalReading'] = is_numeric($totalPower[$groupedIndex]['final_reading']) ? $totalPower[$groupedIndex]['final_reading'] : 0;
$summary['totalReading'] += is_numeric($totalPower[$groupedIndex]['total_reading']) ? $totalPower[$groupedIndex]['total_reading'] : 0 ; $summary['totalReading'] += is_numeric($totalPower[$groupedIndex]['total_reading']) ? $totalPower[$groupedIndex]['total_reading'] : 0;
$summary['totalUnits'] += is_numeric($totalPower[$groupedIndex]['total_units']) ? $totalPower[$groupedIndex]['total_units'] : 0 ; $summary['totalUnits'] += is_numeric($totalPower[$groupedIndex]['total_units']) ? $totalPower[$groupedIndex]['total_units'] : 0;
$summary['averagePf'] = " " ; $summary['averagePf'] = " ";
$summary['presentPf'] = " "; $summary['presentPf'] = " ";
$summary['md'] = " " ; $summary['md'] = " ";
$summary['mf'] = " " ; $summary['mf'] = " ";
@ -567,24 +559,17 @@ foreach ($period as $day) {
// Initialize the material entry if it doesn't exist // Initialize the material entry if it doesn't exist
if (!isset($summary["machineId_$machineId"])) { if (!isset($summary["machineId_$machineId"])) {
$summary["machineId_$machineId"] = [ $summary["machineId_$machineId"] = [
'opening_units' => "-" , 'opening_units' => "-",
'closing_units' => 0 , 'closing_units' => 0,
'total_units' => 0 , 'total_units' => 0,
]; ];
} }
// Sum values for the material // Sum values for the material
$summary["machineId_$machineId"]['opening_units'] = " " ; $summary["machineId_$machineId"]['opening_units'] = " ";
$summary["machineId_$machineId"]['closing_units'] = " " ; $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;
} ?> } ?>
</tr> </tr>
@ -596,7 +581,7 @@ foreach ($period as $day) {
<div class="table-responsive"> <div class="table-responsive">
<table id="powerStockDetailsTableSummaryId" class="fht-table table-striped"> <table id="powerStockDetailsTableSummaryId" class="fht-table table-striped">
<thead > <thead>
<tr> <tr>
<th class="celda_encabezado_total" colspan="1">Date </th> <th class="celda_encabezado_total" colspan="1">Date </th>
@ -639,13 +624,13 @@ foreach ($period as $day) {
<td><?= $summary['md'] ?></td> <td><?= $summary['md'] ?></td>
<td><?= $summary['mf'] ?></td> <td><?= $summary['mf'] ?></td>
<?php foreach($summary as $each){ <?php foreach ($summary as $each) {
if(is_array($each)){ if (is_array($each)) {
?> ?>
<td class="celda_normal "><?=$each['opening_units']?> </td> <td class="celda_normal "><?= $each['opening_units'] ?> </td>
<td class="celda_normal "><?=$each['closing_units']?></td> <td class="celda_normal "><?= $each['closing_units'] ?></td>
<td class="celda_normal "><?=$each['total_units']?></td> <td class="celda_normal "><?= $each['total_units'] ?></td>
<?php <?php
} }
@ -674,7 +659,7 @@ foreach ($period as $day) {
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
?> > ?>>
<?php <?php
$startDate = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y'); $startDate = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
@ -687,20 +672,18 @@ foreach ($period as $day) {
<td class="celda_normal openingTP" <td class="celda_normal openingTP"
data-id="<?= $dateInMonth?>" data-id="<?= $dateInMonth ?>"
<?php if ($datesInMonthIndex == 0) { ?> <?php if ($datesInMonthIndex == 0) { ?>
oninput="openingTPStockChange(this)" oninput="openingTPStockChange(this)"
contenteditable="true" contenteditable="true"
<?php } ?> <?php } ?>><?php
if (empty($previousMonthTotalPowerMachineStockDetails)) {
><?php echo " ";
if(empty( $previousMonthTotalPowerMachineStockDetails)){ } else {
echo " " ; echo $previousMonthTotalPowerMachineStockDetails[0]['final_reading'];
}else{
echo $previousMonthTotalPowerMachineStockDetails[0]['final_reading'] ;
} }
?> ?>
@ -715,10 +698,10 @@ foreach ($period as $day) {
contenteditable="true"> contenteditable="true">
<?php <?php
if(empty( $previousMonthTotalPowerMachineStockDetails)){ if (empty($previousMonthTotalPowerMachineStockDetails)) {
echo " " ; echo " ";
}else{ } else {
echo $previousMonthTotalPowerMachineStockDetails[0]['final_reading'] ; echo $previousMonthTotalPowerMachineStockDetails[0]['final_reading'];
} }
?> ?>
@ -729,29 +712,19 @@ foreach ($period as $day) {
data-id="<?= $dateInMonth ?>"> </td> data-id="<?= $dateInMonth ?>"> </td>
<td class="celda_normal totalUnitsTP" <td class="celda_normal totalUnitsTP"
data-id="<?= $dateInMonth ?>" data-id="<?= $dateInMonth ?>"> </td>
> </td>
<td class="celda_normal averagePfTP" contenteditable="true" <td class="celda_normal averagePfTP" contenteditable="true"
data-id="<?= $dateInMonth ?>" data-id="<?= $dateInMonth ?>"> </td>
> </td>
<td class="celda_normal presentPfTP" contenteditable="true" <td class="celda_normal presentPfTP" contenteditable="true"
data-id="<?= $dateInMonth ?>" data-id="<?= $dateInMonth ?>"> </td>
> </td>
<td class="celda_normal mdTP" contenteditable="true" <td class="celda_normal mdTP" contenteditable="true"
oninput="mdTPStockChange(this)" 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>
@ -772,21 +745,16 @@ foreach ($period as $day) {
</td> </td>
<td class="celda_normal openingUnits" <td class="celda_normal openingUnits"
data-id="<?= $dateInMonth ?> <?= $powerMachine['id'] ?>"
<?php if ($datesInMonthIndex == 0) { ?> <?php if ($datesInMonthIndex == 0) { ?>
oninput="openingUnitsChange(this)" oninput="openingUnitsChange(this)"
contenteditable="true" contenteditable="true"
<?php } ?> <?php } ?>
><?php data-id="<?= $dateInMonth ?> <?= $powerMachine['id'] ?>">
if(empty( $previousMonthPowerConsumptionStockDetails)){ <?= (!empty($previousMonthPowerConsumptionStockDetails) && isset($previousMonthPowerConsumptionStockDetails[$powerMachineIndex]))
echo " " ; ? $previousMonthPowerConsumptionStockDetails[$powerMachineIndex]['closing_units']
}else{ : " ";
echo $previousMonthPowerConsumptionStockDetails[$powerMachineIndex]['closing_units'] ;
}
?> ?>
</td> </td>
@ -795,12 +763,10 @@ foreach ($period as $day) {
data-id="<?= $dateInMonth ?> <?= $powerMachine['id'] ?>" data-id="<?= $dateInMonth ?> <?= $powerMachine['id'] ?>"
oninput="closingUnitsChange(this)" oninput="closingUnitsChange(this)"
contenteditable="true"> contenteditable="true">
<?php
if(empty( $previousMonthPowerConsumptionStockDetails)){ <?= (!empty($previousMonthPowerConsumptionStockDetails) && isset($previousMonthPowerConsumptionStockDetails[$powerMachineIndex]))
echo " " ; ? $previousMonthPowerConsumptionStockDetails[$powerMachineIndex]['closing_units']
}else{ : " ";
echo $previousMonthPowerConsumptionStockDetails[$powerMachineIndex]['closing_units'] ;
}
?> ?>
</td> </td>
@ -1010,9 +976,9 @@ foreach ($period as $day) {
<script> <script>
function tableToJson() { function tableToJson() {
const table = $('#powerStockDetailsTableId'); const table = $('#powerStockDetailsTableId');
const summaryRowPart = [] ; const summaryRowPart = [];
const readingsRowPart = []; const readingsRowPart = [];
const allRow = [] ; const allRow = [];
//this table to json is customized for powerStock not for all //this table to json is customized for powerStock not for all
@ -1027,13 +993,13 @@ foreach ($period as $day) {
const summaryRowData = { const summaryRowData = {
date: formattedDate, date: formattedDate,
opening_reading: rowCells.eq(1).text().trim(), opening_reading: rowCells.eq(1).text().trim(),
final_reading : rowCells.eq(2).text().trim(), final_reading: rowCells.eq(2).text().trim(),
total_reading : rowCells.eq(3).text().trim(), total_reading: rowCells.eq(3).text().trim(),
total_units : rowCells.eq(4).text().trim(), total_units: rowCells.eq(4).text().trim(),
average_pf : rowCells.eq(5).text().trim(), average_pf: rowCells.eq(5).text().trim(),
present_pf : rowCells.eq(6).text().trim(), present_pf: rowCells.eq(6).text().trim(),
md : rowCells.eq(7).text().trim(), md: rowCells.eq(7).text().trim(),
mf : rowCells.eq(8).text().trim() mf: rowCells.eq(8).text().trim()
}; };
summaryRowPart.push(summaryRowData); summaryRowPart.push(summaryRowData);
@ -1042,13 +1008,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 = 9 ; i < rowCells.length; i += 5 ) { 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_units: rowCells.eq(i + 2).text().trim(), opening_units: rowCells.eq(i + 2).text().trim(),
closing_units: rowCells.eq(i + 3).text().trim(), closing_units: rowCells.eq(i + 3).text().trim(),
total_units : rowCells.eq(i + 4).text().trim(), total_units: rowCells.eq(i + 4).text().trim(),
}; };
readingsRowPart.push(readingsRowData); readingsRowPart.push(readingsRowData);
@ -1060,16 +1026,13 @@ foreach ($period as $day) {
}); });
allRow.push(summaryRowPart ,readingsRowPart ) allRow.push(summaryRowPart, readingsRowPart)
return JSON.stringify(allRow, null, 2); return JSON.stringify(allRow, null, 2);
} }
</script> </script>
<script> <script>
function openingUnitsChange(tdElement) { function openingUnitsChange(tdElement) {
try { try {
@ -1078,12 +1041,12 @@ foreach ($period as $day) {
let openingUnits = validateInput(tdElement.innerText); let openingUnits = validateInput(tdElement.innerText);
let closingUnits = validateInput(document.querySelector(`td.closingUnits[data-id="${dataId}"]`).innerText); let closingUnits = validateInput(document.querySelector(`td.closingUnits[data-id="${dataId}"]`).innerText);
let totalUnits = parseFloat(closingUnits) - parseFloat(openingUnits) ; let totalUnits = parseFloat(closingUnits) - parseFloat(openingUnits);
document.querySelector(`td.totalUnits[data-id="${dataId}"]`).innerText = parseFloat(totalUnits).toFixed(2); document.querySelector(`td.totalUnits[data-id="${dataId}"]`).innerText = parseFloat(totalUnits).toFixed(2);
updateStockValue(date,machine_id,closingUnits) updateStockValue(date, machine_id, closingUnits)
} catch (error) { } catch (error) {
@ -1101,12 +1064,12 @@ foreach ($period as $day) {
let openingUnits = validateInput(document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText); let openingUnits = validateInput(document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText);
let closingUnits = validateInput(tdElement.innerText); let closingUnits = validateInput(tdElement.innerText);
let totalUnits = parseFloat(closingUnits) - parseFloat(openingUnits) ; let totalUnits = parseFloat(closingUnits) - parseFloat(openingUnits);
document.querySelector(`td.totalUnits[data-id="${dataId}"]`).innerText = parseFloat(totalUnits).toFixed(2); document.querySelector(`td.totalUnits[data-id="${dataId}"]`).innerText = parseFloat(totalUnits).toFixed(2);
updateStockValue(date,machine_id,closingUnits) updateStockValue(date, machine_id, closingUnits)
} catch (error) { } catch (error) {
@ -1117,24 +1080,24 @@ foreach ($period as $day) {
} }
function openingTPStockChange(tdElement){ function openingTPStockChange(tdElement) {
try { try {
let dataId = tdElement.getAttribute('data-id') ; let dataId = tdElement.getAttribute('data-id');
let openingTP = validateInput(tdElement.innerText) ; let openingTP = validateInput(tdElement.innerText);
let finalTP = validateInput(document.querySelector(`td.finalTP[data-id="${dataId}"]`).innerText) ; let finalTP = validateInput(document.querySelector(`td.finalTP[data-id="${dataId}"]`).innerText);
let totalReadingTP = (Number(finalTP) - Number(openingTP)) ; let totalReadingTP = (Number(finalTP) - Number(openingTP));
let totalUnitsTP = totalReadingTP * 60 ; let totalUnitsTP = totalReadingTP * 60;
document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText = parseFloat(totalReadingTP).toFixed(2) ; document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText = parseFloat(totalReadingTP).toFixed(2);
document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = parseFloat(totalUnitsTP).toFixed(2) ; document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = parseFloat(totalUnitsTP).toFixed(2);
updateTotalStockValue(dataId , finalTP) ; updateTotalStockValue(dataId, finalTP);
} catch (error) { } catch (error) {
@ -1145,7 +1108,7 @@ foreach ($period as $day) {
} }
function finalTPStockChange(tdElement){ function finalTPStockChange(tdElement) {
try { try {
@ -1154,15 +1117,15 @@ foreach ($period as $day) {
let openingTP = validateInput(document.querySelector(`td.openingTP[data-id="${dataId}"]`).innerText); let openingTP = validateInput(document.querySelector(`td.openingTP[data-id="${dataId}"]`).innerText);
let finalTP = validateInput(tdElement.innerText); let finalTP = validateInput(tdElement.innerText);
let totalReadingTP = (Number(finalTP) - Number(openingTP)) ; let totalReadingTP = (Number(finalTP) - Number(openingTP));
let totalUnitsTP = totalReadingTP * 60 ; let totalUnitsTP = totalReadingTP * 60;
document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText = parseFloat(totalReadingTP).toFixed(2) ; document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText = parseFloat(totalReadingTP).toFixed(2);
document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = parseFloat(totalUnitsTP).toFixed(2) ; document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = parseFloat(totalUnitsTP).toFixed(2);
updateTotalStockValue(dataId , finalTP) updateTotalStockValue(dataId, finalTP)
} catch (error) { } catch (error) {
@ -1173,7 +1136,7 @@ foreach ($period as $day) {
} }
function mdTPStockChange(tdElement){ function mdTPStockChange(tdElement) {
try { try {
@ -1181,11 +1144,11 @@ foreach ($period as $day) {
let mdTP = validateInput(tdElement.innerText); let mdTP = validateInput(tdElement.innerText);
document.querySelector(`td.mfTP[data-id="${dataId}"]`).innerText = parseFloat(mdTP * 60).toFixed(2) ; document.querySelector(`td.mfTP[data-id="${dataId}"]`).innerText = parseFloat(mdTP * 60).toFixed(2);
} catch (error) { } catch (error) {
console.error("There is an error updating stock ..!!" + error) ; console.error("There is an error updating stock ..!!" + error);
} }
@ -1212,16 +1175,9 @@ foreach ($period as $day) {
return input; return input;
} }
</script> </script>
<script> <script>
function updateStockValue(date, machine_id, closingUnits) { function updateStockValue(date, machine_id, closingUnits) {
const table = $('#powerStockDetailsTableId'); const table = $('#powerStockDetailsTableId');
@ -1241,7 +1197,7 @@ foreach ($period as $day) {
let dataId = `${otherDate} ${machine_id}`; let dataId = `${otherDate} ${machine_id}`;
document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText = closingUnits == 0 ? " " : parseFloat(closingUnits).toFixed(2) ; document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText = closingUnits == 0 ? " " : parseFloat(closingUnits).toFixed(2);
let openingUnits = validateInput(document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText); let openingUnits = validateInput(document.querySelector(`td.openingUnits[data-id="${dataId}"]`).innerText);
@ -1249,7 +1205,7 @@ foreach ($period as $day) {
closingUnits = Math.abs(Number(openingUnits) + Number(totalUnits)); closingUnits = Math.abs(Number(openingUnits) + Number(totalUnits));
document.querySelector(`td.closingUnits[data-id="${dataId}"]`).innerText = closingUnits == 0 ? " " : parseFloat(closingUnits).toFixed(2) ; document.querySelector(`td.closingUnits[data-id="${dataId}"]`).innerText = closingUnits == 0 ? " " : parseFloat(closingUnits).toFixed(2);
} }
@ -1259,7 +1215,7 @@ foreach ($period as $day) {
function updateTotalStockValue(date, finalTP){ function updateTotalStockValue(date, finalTP) {
const table = $('#powerStockDetailsTableId'); const table = $('#powerStockDetailsTableId');
@ -1280,24 +1236,24 @@ foreach ($period as $day) {
let dataId = `${otherDate}`; let dataId = `${otherDate}`;
document.querySelector(`td.openingTP[data-id="${dataId}"]`).innerText = finalTP == 0 ? " " : parseFloat(finalTP).toFixed(2) ; document.querySelector(`td.openingTP[data-id="${dataId}"]`).innerText = finalTP == 0 ? " " : parseFloat(finalTP).toFixed(2);
let openingTP = validateInput(document.querySelector(`td.openingTP[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 totalReadingTP = validateInput(document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText);
finalTP = Number(openingTP) + Number(totalReadingTP) ; finalTP = Number(openingTP) + Number(totalReadingTP);
let totalUnitsTP = Number(totalReadingTP * 60 ); let totalUnitsTP = Number(totalReadingTP * 60);
document.querySelector(`td.finalTP[data-id="${dataId}"]`).innerText = finalTP == 0 ? " " : parseFloat(finalTP).toFixed(2) ; document.querySelector(`td.finalTP[data-id="${dataId}"]`).innerText = finalTP == 0 ? " " : parseFloat(finalTP).toFixed(2);
document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText = totalReadingTP == 0 ? " " : parseFloat(totalReadingTP).toFixed(2) ; document.querySelector(`td.totalReadingTP[data-id="${dataId}"]`).innerText = totalReadingTP == 0 ? " " : parseFloat(totalReadingTP).toFixed(2);
document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = totalUnitsTP == 0 ? " " : parseFloat(totalUnitsTP).toFixed(2) ; document.querySelector(`td.totalUnitsTP[data-id="${dataId}"]`).innerText = totalUnitsTP == 0 ? " " : parseFloat(totalUnitsTP).toFixed(2);
@ -1305,26 +1261,24 @@ foreach ($period as $day) {
}) })
} }
</script> </script>
<script> <script>
$(document).ready(function() {
$(document).ready(function(){
function exportTableToExcel(tableID, filename = '') { function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID); let table = document.getElementById(tableID);
let cloneTable = table.cloneNode(true); // Clone the table to modify let cloneTable = table.cloneNode(true); // Clone the table to modify
// Remove hidden rows // Remove hidden rows
$(cloneTable).find('tr').filter(function () { $(cloneTable).find('tr').filter(function() {
return $(this).css('display') === 'none'; return $(this).css('display') === 'none';
}).remove(); }).remove();
// Remove hidden columns // Remove hidden columns
$(cloneTable).find('th, td').each(function () { $(cloneTable).find('th, td').each(function() {
if ($(this).css('display') === 'none') { if ($(this).css('display') === 'none') {
$(this).remove(); $(this).remove();
} }
@ -1338,21 +1292,18 @@ foreach ($period as $day) {
let tableId = 'powerStockDetailsTableId'; let tableId = 'powerStockDetailsTableId';
document.getElementById('powerConsumptionExport').addEventListener('click',function(){ document.getElementById('powerConsumptionExport').addEventListener('click', function() {
exportTableToExcel(tableId,'power_Consumption_details<?=$month?>.xlsx'); exportTableToExcel(tableId, 'power_Consumption_details<?= $month ?>.xlsx');
}) })
}) })
</script> </script>
<script> <script>
document.addEventListener("keydown", function (event) { document.addEventListener("keydown", function(event) {
if (event.key === "Enter") { if (event.key === "Enter") {
@ -1382,6 +1333,5 @@ foreach ($period as $day) {
} }
} }
} }
}); });
</script> </script>

View File

@ -511,6 +511,7 @@ foreach ($period as $day) {
} }
?>> ?>>
<?php <?php
// dd($resinMaterials);
foreach ($resinMaterials as $resinMaterialIndex => $resinMaterial) { ?> foreach ($resinMaterials as $resinMaterialIndex => $resinMaterial) { ?>
<!-- this will loop till materials present --> <!-- this will loop till materials present -->