stock module latest today vadivel J 08-1-2025

This commit is contained in:
vadivelJ96 2025-01-08 13:48:11 +05:30
parent 9ec31b265b
commit 92bb35b995
3 changed files with 336 additions and 394 deletions

View File

@ -1321,9 +1321,9 @@ class StockController extends BaseController
$data['month'] = $formattedDate; $data['month'] = $formattedDate;
return $this->response->setJSON($data); // return $this->response->setJSON($data);
// return $this->loadViews("trpProductionStockDetails", $this->global, $data, NULL); return $this->loadViews("trpProductionStockDetails", $this->global, $data, NULL);
@ -1335,7 +1335,7 @@ class StockController extends BaseController
$updateTrpProductionDetails = json_decode($postData['updateTrpProductionDetails'], true); $updateTrpProductionDetails = json_decode($postData['updateTrpProductionDetails'], true);
$updateProduction = []; $updateProduction = [];
$updateMaintanence = []; $updateMaintanence = [];
$updateWaste = []; $updateWaste = [];

View File

@ -119,13 +119,9 @@ class TrpProductionModel extends Model
tsu.total_kgs as coating, tsu.total_kgs as coating,
invItems.item_date_added,
invItems.client_name,
invItems.TotalRsQuantity, invItems.TotalRsQuantity,
tigrd.SupplierName, tigrd.TotalQuantityAsPerInvoice
tigrd.TotalQuantityAsPerInvoice,
tigrd.CreatedDate
FROM FROM

View File

@ -156,8 +156,8 @@
height: 20px; height: 20px;
} }
#resinStockDetailsTableId th:nth-child(1), #trpProductionStockDetailsTableId th:nth-child(1),
#resinStockDetailsTableId td:nth-child(1) { #trpProductionStockDetailsTableId td:nth-child(1) {
position: sticky; position: sticky;
left: 0; left: 0;
background-color: #00a65a; background-color: #00a65a;
@ -260,7 +260,7 @@
<div class="table-responsive"> <div class="table-responsive">
<table id="resinStockDetailsTableId" class="fht-table table-striped"> <table id="trpProductionStockDetailsTableId" class="fht-table table-striped">
<thead class="celda_encabezado_general" style="padding: 10px;"> <thead class="celda_encabezado_general" style="padding: 10px;">
@ -422,213 +422,216 @@
<?php } else { ?> <?php } else { ?>
<?php foreach($datesInMonth as $datesInMonthIndex => $dateInMonth)
{
?>
<tr id="<?= $dateInMonth ?>"
<?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat= DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { echo 'style="background: #cef0ad;"';}
?>
>
<!-- date --> <!-- date -->
<!-- td:eq(0) --> <!-- td:eq(0) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock date"
data-id="" data-id="<?= $dateInMonth ?> date">
oninput="receiptStockChange(this)" <?= $dateInMonthDmYFormat ?>
contenteditable="true">
54465656
</td> </td>
<!-- openingTime --> <!-- openingTime -->
<!-- td:eq(1) --> <!-- td:eq(1) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock openingTime"
data-id="" data-id="<?= $dateInMonth ?> openingTime"
oninput="receiptStockChange(this)" oninput="trpStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- closingTime --> <!-- closingTime -->
<!-- td:eq(2) --> <!-- td:eq(2) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock closingTime"
data-id="" data-id="<?= $dateInMonth ?> closingTime"
oninput="receiptStockChange(this)" oninput="trpStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- totalHours --> <!-- totalHours -->
<!-- td:eq(3) --> <!-- td:eq(3) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock totalHours"
data-id="" data-id="<?= $dateInMonth ?> totalHours">
oninput="receiptStockChange(this)"
contenteditable="true">
0 0
</td> </td>
<!-- coldStart --> <!-- coldStart -->
<!-- td:eq(4) --> <!-- td:eq(4) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)" oninput="trpStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- breakdownHours --> <!-- breakdownHours -->
<!-- td:eq(5) --> <!-- td:eq(5) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)" oninput="trpStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- burnerFiringHours --> <!-- burnerFiringHours -->
<!-- td:eq(6) --> <!-- td:eq(6) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id="">
oninput="receiptStockChange(this)"
contenteditable="true">
0 0
</td> </td>
<!-- sandFeedingHours --> <!-- sandFeedingHours -->
<!-- td:eq(7) --> <!-- td:eq(7) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id="">
oninput="receiptStockChange(this)"
contenteditable="true">
0 0
</td> </td>
<!-- workingPersonEngineers -->
<!-- td:eq(8) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- workingPersonSupervisiors -->
<!-- td:eq(9) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- workingPersonOperators -->
<!-- td:eq(10) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- rollerDrivers -->
<!-- td:eq(11) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- natureOfMaintenance -->
<!-- td:eq(12) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- location -->
<!-- td:eq(13) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- description -->
<!-- td:eq(14) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- gasReceiptBg --> <!-- gasReceiptBg -->
<!-- td:eq(15) --> <!-- td:eq(8) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- gasReceiptPg --> <!-- gasReceiptPg -->
<!-- td:eq(16) --> <!-- td:eq(9) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- physicalGasConsumption -->
<!-- td:eq(10) -->
<td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)" oninput="trpStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- physicalGasConsumption -->
<!-- td:eq(17) -->
<td class="celda_normal receiptStock" <!-- drierGasConsumption -->
data-id="" <!-- td:eq(11) -->
oninput="receiptStockChange(this)" <td class="celda_normal trpProductionStock"
contenteditable="true"> data-id="">
0
</td>
<!-- coatingGasConsumption -->
<!-- td:eq(12) -->
<td class="celda_normal trpProductionStock"
data-id="">
0 0
</td> </td>
<!-- trpPlusDrierGasConsumption --> <!-- trpPlusDrierGasConsumption -->
<!-- td:eq(18) --> <!-- td:eq(13) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id="">
oninput="receiptStockChange(this)"
contenteditable="true">
0 0
</td> </td>
<!-- trpPhysicalGasPerTon --> <!-- trpPhysicalGasPerTon -->
<!-- td:eq(19) --> <!-- td:eq(14) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id="">
oninput="receiptStockChange(this)"
contenteditable="true">
0 0
</td> </td>
<!-- panelGasConsumption --> <!-- panelGasConsumption -->
<!-- td:eq(20) --> <!-- td:eq(15) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)" oninput="trpStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- panelGasPerTon --> <!-- panelGasPerTon -->
<!-- td:eq(21) --> <!-- td:eq(16) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id="">
oninput="receiptStockChange(this)"
contenteditable="true">
0 0
</td> </td>
<!-- AL(S) -->
<!-- td:eq(17) -->
<td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- AL(E) -->
<!-- td:eq(18) -->
<td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- ME -->
<!-- td:eq(19) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- SI -->
<!-- td:eq(20) -->
<td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- Caparo -->
<!-- td:eq(21) -->
<td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- Nemak -->
<!-- td:eq(22) -->
<td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- DR -->
<!-- td:eq(23) -->
<td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- edRunningHours --> <!-- edRunningHours -->
<!-- td:eq(22) --> <!-- td:eq(24) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
@ -636,246 +639,213 @@
<!-- edProduction --> <!-- edProduction -->
<!-- td:eq(23) --> <!-- td:eq(25) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!--edUsage --> <!-- edUsage -->
<!-- td:eq(24) --> <!-- td:eq(26) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- trpProduction --> <!-- trpProduction -->
<!-- td:eq(25) --> <!-- td:eq(27) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)" oninput="trpStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- trpProductionPerHour --> <!-- trpProductionPerHour -->
<!-- td:eq(26) --> <!-- td:eq(28) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- coating -->
<!-- td:eq(29) -->
<td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- Hindhuja -->
<!-- td:eq(30) -->
<td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- Nemak -->
<!-- td:eq(31) -->
<td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- ME -->
<!-- td:eq(32) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- BI -->
<!-- td:eq(33) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- Karmen -->
<!-- td:eq(34) -->
<td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- waterReceipt --> <!-- waterReceipt -->
<!-- td:eq(27) --> <!-- td:eq(35) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- waterConsumption --> <!-- waterConsumption -->
<!-- td:eq(28) --> <!-- td:eq(36) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- ebReading --> <!-- ebReading -->
<!-- td:eq(29) --> <!-- td:eq(37) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- ebReadingPerUnitTon --> <!-- ebReadingPerUnitTon -->
<!-- td:eq(30) --> <!-- td:eq(38) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="">
0
</td>
<!-- workingPersonEngineers -->
<!-- td:eq(39) -->
<td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- msSeperation --> <!-- workingPersonSupervisiors -->
<!-- td:eq(31) --> <!-- td:eq(40) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- workingPersonOperators -->
<!-- td:eq(41) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- rollerDrivers -->
<!-- td:eq(42) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- natureOfMaintenance -->
<!-- td:eq(43) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- location -->
<!-- td:eq(44) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- description -->
<!-- td:eq(45) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
0
</td>
<!-- msSeperation -->
<!-- td:eq(46) -->
<td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- edWaste --> <!-- edWaste -->
<!-- td:eq(32) --> <!-- td:eq(47) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- coolerBags --> <!-- coolerBags -->
<!-- td:eq(33) --> <!-- td:eq(48) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- edPlus20Waste --> <!-- edPlus20Waste -->
<!-- td:eq(34) --> <!-- td:eq(49) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!--cycloneWaste --> <!--cycloneWaste -->
<!-- td:eq(35) --> <!-- td:eq(50) -->
<td class="celda_normal receiptStock" <td class="celda_normal trpProductionStock"
data-id="" data-id=""
oninput="receiptStockChange(this)"
contenteditable="true"> contenteditable="true">
0 0
</td> </td>
<!-- coatingGasConsumption -->
<!-- td:eq(36) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- drierGasConsumption --> </tr>
<!-- td:eq(37) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- coating -->
<!-- td:eq(38) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- TotalQuantityAsPerInvoice --> <?php }?>
<!-- td:eq(39) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- TotalRsQuantity -->
<!-- td:eq(40) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(41) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(42) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(43) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(44) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(45) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(46) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(47) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(48) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(49) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(50) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
@ -947,7 +917,7 @@
const selectedResin = resinDropdown.value; const selectedResin = resinDropdown.value;
const selectedDate = dateDropdown.value; const selectedDate = dateDropdown.value;
const table = document.getElementById('resinStockDetailsTableId'); const table = document.getElementById('trpProductionStockDetailsTableId');
const headerCells = table.querySelectorAll('thead tr:nth-child(1) th'); const headerCells = table.querySelectorAll('thead tr:nth-child(1) th');
const rows = table.querySelectorAll('tbody tr'); const rows = table.querySelectorAll('tbody tr');
@ -1063,7 +1033,7 @@
<script> <script>
function tableToJson() { function tableToJson() {
const table = $('#resinStockDetailsTableId'); const table = $('#trpProductionStockDetailsTableId');
const rows = []; const rows = [];
//this table to json is customized for bagstock not for all //this table to json is customized for bagstock not for all
@ -1098,38 +1068,70 @@
<script> <script>
function openingStockChange(tdElement) { function trpStockChange(tdElement) {
try{
let dataId = tdElement.getAttribute('data-id');
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
let openingStock = tdElement.innerText;
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
updateStockValue( date,materialCode,currentBalanceStock )
} catch(error){
console.error("There is an error updating stock ..!!" + error);
}
}
function receiptStockChange(tdElement) {
try{ try{
let dataId = tdElement.getAttribute('data-id');
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
let openingStock = document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText;
let receiptStock = tdElement.innerText;
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
updateStockValue( date,materialCode,currentBalanceStock )
let tr = $(tdElement).closest('tr');
let openingTime = tr.find('td:eq(1)').text().trim();
let closingTime = tr.find('td:eq(2)').text().trim();
let totalHours = tr.find('td:eq(3)').text().trim();
let coldStart = tr.find('td:eq(4)').text().trim();
let breakdownHours = tr.find('td:eq(5)').text().trim();
let burnerFiringHours = tr.find('td:eq(6)').text().trim();
let sandFeedingHours = tr.find('td:eq(7)').text().trim();
let gasReceiptBg = tr.find('td:eq(8)').text().trim();
let gasReceiptPg = tr.find('td:eq(9)').text().trim();
let physicalGasConsumption = tr.find('td:eq(10)').text().trim();
let drierGasConsumption =tr.find('td:eq(11)').text().trim();
let coatingGasConsumption =tr.find('td:eq(12)').text().trim();
let trpPlusDrierGasConsumption = tr.find('td:eq(13)').text().trim();
let trpPhysicalGasPerTon = tr.find('td:eq(14)').text().trim();
let panelGasConsumption = tr.find('td:eq(15)').text().trim();
let panelGasPerTon =tr.find('td:eq(16)').text().trim();
let als = tr.find('td:eq(17)').text().trim();
let ale = tr.find('td:eq(18)').text().trim();
let me = tr.find('td:eq(19)').text().trim();
let si = tr.find('td:eq(20)').text().trim();
let caparo = tr.find('td:eq(21)').text().trim();
let nemak = tr.find('td:eq(22)').text().trim();
let dr = tr.find('td:eq(23)').text().trim();
let edRunningHours = tr.find('td:eq(24)').text().trim();
tr.find('td:eq(25)').text().trim();
tr.find('td:eq(26)').text().trim();
tr.find('td:eq(27)').text().trim();
tr.find('td:eq(28)').text().trim();
tr.find('td:eq(29)').text().trim();
tr.find('td:eq(30)').text().trim();
tr.find('td:eq(31)').text().trim();
tr.find('td:eq(32)').text().trim();
tr.find('td:eq(33)').text().trim();
tr.find('td:eq(34)').text().trim();
tr.find('td:eq(35)').text().trim();
tr.find('td:eq(36)').text().trim();
tr.find('td:eq(37)').text().trim();
tr.find('td:eq(38)').text().trim();
tr.find('td:eq(39)').text().trim();
tr.find('td:eq(40)').text().trim();
tr.find('td:eq(41)').text().trim();
tr.find('td:eq(42)').text().trim();
tr.find('td:eq(43)').text().trim();
tr.find('td:eq(44)').text().trim();
tr.find('td:eq(45)').text().trim();
tr.find('td:eq(46)').text().trim();
tr.find('td:eq(47)').text().trim();
tr.find('td:eq(48)').text().trim();
tr.find('td:eq(49)').text().trim();
tr.find('td:eq(50)').text().trim();
console.log(panelGasConsumption);
} catch(error){ } catch(error){
@ -1140,63 +1142,7 @@
} }
function usedStockChange(tdElement) {
try {
let dataId = tdElement.getAttribute('data-id');
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
let openingStock = document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText;
let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
let usedStock = tdElement.innerText;
let currentBalanceStock = ( Number(openingStock) + Number(receiptStock) ) - Number(usedStock);
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
updateStockValue( date,materialCode,currentBalanceStock )
} catch (error) {
console.error("There is an error updating stock ..!!" + error);
}
}
</script>
<script>
function updateStockValue( date, materialCode, currentBalanceStock ){
const table = $('#resinStockDetailsTableId');
const rows = [];
table.find('tbody tr').each(function() {
const rowCells = $(this).find('td');
const otherDate = rowCells.eq(1).text().trim();
if( new Date(otherDate) > new Date(date) ){ //other records present after it
/**this data-id ,openingStock ,used stock , current Balance Stock
is for changing subsequent dates not the earlier one **/
let dataId = `${otherDate} ${materialCode}`;
document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
currentBalanceStock = (Number(currentBalanceStock) + Number(receiptStock)) - Number(usedStock);
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
}
})
}
</script> </script>