calculation in gas stock

This commit is contained in:
vadivel J 2024-11-04 17:46:42 +05:30
parent 96b90d6de7
commit 088157dd4d

View File

@ -273,11 +273,13 @@
<td style="display:none"><?= $bagStock['date']?></td>
<td style="display:none"><?= $bagStock['materialCode']?></td>
<td style="display:none"><?= $bagStock['customer']?></td>
<td class="celda_normal"
<td class="celda_normal "
data-id="<?= $bagStock['date']?> <?= $bagStock['materialCode']?>"
oninput="openingStockChange(this)"
contenteditable="true"><?= $bagStock['opening']?></td>
<td class="celda_normal"><?= $bagStock['receipt']?></td>
<td class="celda_normal"
data-id="<?= $bagStock['date']?> <?= $bagStock['materialCode']?>"
oninput="usedStockChange(this)"
contenteditable="true"><?= $bagStock['used']?></td>
<td class="celda_normal"><?= $bagStock['balanceStock']?></td>
@ -396,20 +398,63 @@
return JSON.stringify(rows, null, 2);
}
console.log(tableToJson());
</script>
<script>
function openingStockChange(tdElement){
alert('opening stock is changed');
console.log('New value:', tdElement);
}
function openingStockChange(tdElement) {
let dataId = tdElement.getAttribute('data-id').split(' ');
let date=dataId[0];
let materialCode= dataId[1];
let changedField = "openingStock";
let changedFieldValue = tdElement.innerText;
let currentBalanceStock=calculateCurrentBalanceStock(changedField,changedFieldValue);
const table = $('#bagStockDetailsTableId');
const rows = [];
table.find('tbody tr').each(function() {
const rowCells = $(this).find('td');
const otherDate = rowCells.eq(0).text().trim();
if( new Date(new Date(otherDate)) > new Date(date)){
console.log( new Date(otherDate));
console.log( new Date(date));
}
})
//find balance stock for this row first and update the balance stock for next rows
console.log('Date:', date);
console.log('materialCode:', materialCode);
console.log('changedField:', changedField);
console.log('changedFieldValue', tdElement.innerText); // Log the cell's current content
}
function usedStockChange(tdElement) {
alert('Used Stock is changed');
console.log('New value:', tdElement);
let dataId = tdElement.getAttribute('data-id').split(' ');
let date=dataId[0];
let materialCode= dataId[1];
let changedField = "usedStock";
let changedFieldValue = tdElement.innerText;
let newBalanceStock=calculateCurrentBalanceStock(changedField,changedFieldValue);
//find balance stock for this row first and update the balance stock for next rows
console.log('Date:', date);
console.log('materialCode:', materialCode);
console.log('changedField:', changedField);
console.log('changedFieldValue', tdElement.innerText); // Log the cell's current content
}
</script>
<script>
function calculateCurrentBalanceStock(changedField,changedFieldValue){
return
}
</script>