stock module latest today vadivel J 11-1-2025
This commit is contained in:
parent
5f24a5d177
commit
5a4077507e
@ -869,11 +869,11 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
// getting customer for creating table headers
|
// getting customer for creating table headers
|
||||||
// checking already existing stock if yes then get customer from the existing stock
|
// checking already existing stock if yes then get customer from the existing stock
|
||||||
// if not set customer as '' empty string
|
// if not set customer in db , then set '' empty string
|
||||||
|
|
||||||
foreach ($resinMaterials as $key => $resinMaterial) {
|
foreach ($resinMaterials as $key => $resinMaterial) {
|
||||||
$materialCode = $resinMaterial['MaterialCode'];
|
$materialCode = $resinMaterial['MaterialCode'];
|
||||||
$resinMaterials[$key]['customers'] = $this->bagStockDetails_model
|
$resinMaterials[$key]['customers'] = $this->resinStockDetails_model
|
||||||
->select('customer')
|
->select('customer')
|
||||||
->where('date >=', $startDate)
|
->where('date >=', $startDate)
|
||||||
->where('date <=', $endDate)
|
->where('date <=', $endDate)
|
||||||
|
|||||||
@ -32,30 +32,5 @@ class BagStockDetailsModel extends Model
|
|||||||
* @param array $data Array of records to be updated in bulk.
|
* @param array $data Array of records to be updated in bulk.
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function updateBatchWithCompositeKey(array $data)
|
|
||||||
{
|
|
||||||
$db = \Config\Database::connect();
|
|
||||||
$db->transBegin();
|
|
||||||
|
|
||||||
foreach ($data as $record) {
|
|
||||||
$db->table($this->table)
|
|
||||||
->where('date', $record['date'])
|
|
||||||
->where('materialCode', $record['materialCode'])
|
|
||||||
->update([
|
|
||||||
'customer' => $record['customer'],
|
|
||||||
'opening' => $record['opening'],
|
|
||||||
'receipt' => $record['receipt'],
|
|
||||||
'used' => $record['used'],
|
|
||||||
'balanceStock' => $record['balanceStock']
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($db->transStatus() === FALSE) {
|
|
||||||
$db->transRollback();
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
$db->transCommit();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -349,6 +349,7 @@
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal openingStock"
|
<td class="celda_normal openingStock"
|
||||||
|
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||||
|
|
||||||
<?php if ($groupedBagStockDetailsIndex == 0): ?>
|
<?php if ($groupedBagStockDetailsIndex == 0): ?>
|
||||||
@ -362,14 +363,18 @@
|
|||||||
<td class="celda_normal receiptStock"
|
<td class="celda_normal receiptStock"
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||||
oninput="receiptStockChange(this)"
|
oninput="receiptStockChange(this)"
|
||||||
contenteditable="true">
|
contenteditable="true"
|
||||||
|
>
|
||||||
<?= $bagStock['receipt']?>
|
<?= $bagStock['receipt']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal usedStock"
|
<td class="celda_normal usedStock"
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||||
oninput="usedStockChange(this)"
|
oninput="usedStockChange(this)"
|
||||||
contenteditable="true"><?= $bagStock['used']?>
|
contenteditable="true"
|
||||||
|
|
||||||
|
>
|
||||||
|
<?= $bagStock['used']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal balanceStock"
|
<td class="celda_normal balanceStock"
|
||||||
@ -432,21 +437,20 @@
|
|||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
|
|
||||||
<?php }?>
|
<?php }?>
|
||||||
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?></td>
|
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'-' ?></td>
|
||||||
|
|
||||||
<td class="celda_normal receiptStock"
|
<td class="celda_normal receiptStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||||
oninput="receiptStockChange(this)"
|
oninput="receiptStockChange(this)"
|
||||||
contenteditable="true">0</td>
|
contenteditable="true"> - </td>
|
||||||
|
|
||||||
<td class="celda_normal usedStock"
|
<td class="celda_normal usedStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||||
oninput="usedStockChange(this)"
|
oninput="usedStockChange(this)" contenteditable="true"> - </td>
|
||||||
contenteditable="true">0</td>
|
|
||||||
|
|
||||||
<td class="celda_normal balanceStock"
|
<td class="celda_normal balanceStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||||
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?></td>
|
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'-' ?></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -694,11 +698,17 @@
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
let dataId = tdElement.getAttribute('data-id');
|
||||||
|
|
||||||
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
|
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
|
||||||
let openingStock = tdElement.innerText;
|
|
||||||
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
|
let openingStock = validateInput( tdElement.innerText );
|
||||||
let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
|
|
||||||
|
let usedStock = validateInput(document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
|
let receiptStock = validateInput(document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
|
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
|
||||||
|
|
||||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
||||||
|
|
||||||
updateStockValue( date,materialCode,currentBalanceStock )
|
updateStockValue( date,materialCode,currentBalanceStock )
|
||||||
@ -713,12 +723,19 @@
|
|||||||
|
|
||||||
function receiptStockChange(tdElement) {
|
function receiptStockChange(tdElement) {
|
||||||
try{
|
try{
|
||||||
|
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
let dataId = tdElement.getAttribute('data-id');
|
||||||
|
|
||||||
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
|
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
|
||||||
let openingStock = document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText;
|
|
||||||
let receiptStock = tdElement.innerText;
|
let openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText);
|
||||||
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
|
|
||||||
|
let receiptStock = validateInput(tdElement.innerText);
|
||||||
|
|
||||||
|
let usedStock = validateInput(document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
|
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
|
||||||
|
|
||||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
||||||
|
|
||||||
updateStockValue( date,materialCode,currentBalanceStock )
|
updateStockValue( date,materialCode,currentBalanceStock )
|
||||||
@ -736,12 +753,19 @@
|
|||||||
function usedStockChange(tdElement) {
|
function usedStockChange(tdElement) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
let dataId = tdElement.getAttribute('data-id');
|
||||||
|
|
||||||
let [date,materialCode] = tdElement.getAttribute('data-id').split(' ');
|
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 openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText);
|
||||||
let usedStock = tdElement.innerText;
|
|
||||||
|
let receiptStock = validateInput(document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
|
let usedStock = validateInput(tdElement.innerText);
|
||||||
|
|
||||||
let currentBalanceStock = ( Number(openingStock) + Number(receiptStock) ) - Number(usedStock);
|
let currentBalanceStock = ( Number(openingStock) + Number(receiptStock) ) - Number(usedStock);
|
||||||
|
|
||||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
||||||
|
|
||||||
updateStockValue( date,materialCode,currentBalanceStock )
|
updateStockValue( date,materialCode,currentBalanceStock )
|
||||||
@ -776,9 +800,9 @@
|
|||||||
|
|
||||||
document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
||||||
|
|
||||||
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
|
let usedStock = validateInput(document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
|
let receiptStock = validateInput(document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
currentBalanceStock = (Number(currentBalanceStock) + Number(receiptStock)) - Number(usedStock);
|
currentBalanceStock = (Number(currentBalanceStock) + Number(receiptStock)) - Number(usedStock);
|
||||||
|
|
||||||
@ -800,6 +824,31 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function validateInput(input) {
|
||||||
|
|
||||||
|
|
||||||
|
if ( input == '' || input == ' ' || input == '-' ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeof input === 'string' && input.split('').map(char => char.charCodeAt(0))[0] == 10 ){
|
||||||
|
return 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate against the regex
|
||||||
|
const isValid = /^-?\d*\.?\d*$/.test(input);
|
||||||
|
if (!isValid) {
|
||||||
|
alert('Invalid input! Please enter a valid number.');
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -105,7 +105,8 @@
|
|||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding: 6px 10px;;
|
padding: 6px 10px;
|
||||||
|
;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,8 +300,7 @@
|
|||||||
|
|
||||||
<tbody style="background-color: #fff;">
|
<tbody style="background-color: #fff;">
|
||||||
|
|
||||||
<?php if(!empty($groupedResinStockDetails))
|
<?php if (!empty($groupedResinStockDetails)) {
|
||||||
{
|
|
||||||
//dd($groupedResinStockDetails);
|
//dd($groupedResinStockDetails);
|
||||||
foreach ($groupedResinStockDetails as $groupedResinStockDetailsIndex => $resinStockDetails) {
|
foreach ($groupedResinStockDetails as $groupedResinStockDetailsIndex => $resinStockDetails) {
|
||||||
?>
|
?>
|
||||||
@ -310,9 +310,10 @@
|
|||||||
|
|
||||||
$currentDate = date('d-m-Y');
|
$currentDate = date('d-m-Y');
|
||||||
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $resinStockDetails[0]['date'])->format('d-m-Y');
|
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $resinStockDetails[0]['date'])->format('d-m-Y');
|
||||||
if ($dateInMonthDmYFormat === $currentDate) { echo 'style="background: #cef0ad;"';}
|
if ($dateInMonthDmYFormat === $currentDate) {
|
||||||
?>
|
echo 'style="background: #cef0ad;"';
|
||||||
>
|
}
|
||||||
|
?>>
|
||||||
<?php foreach ($resinStockDetails as $resinStockIndex => $resinStock) { ?>
|
<?php foreach ($resinStockDetails as $resinStockIndex => $resinStock) { ?>
|
||||||
<?php if ($resinStockIndex == 0): ?>
|
<?php if ($resinStockIndex == 0): ?>
|
||||||
<?php
|
<?php
|
||||||
@ -343,9 +344,7 @@
|
|||||||
<?php if ($groupedResinStockDetailsIndex == 0): ?>
|
<?php if ($groupedResinStockDetailsIndex == 0): ?>
|
||||||
oninput="openingStockChange(this)"
|
oninput="openingStockChange(this)"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
<?php endif; ?>
|
<?php endif; ?>><?= $resinStock['opening'] ?>
|
||||||
|
|
||||||
><?= $resinStock['opening']?>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal receiptStock"
|
<td class="celda_normal receiptStock"
|
||||||
@ -383,9 +382,10 @@
|
|||||||
|
|
||||||
$currentDate = date('d-m-Y');
|
$currentDate = date('d-m-Y');
|
||||||
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
|
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
|
||||||
if ($dateInMonthDmYFormat === $currentDate) { echo 'style="background: #cef0ad;"';}
|
if ($dateInMonthDmYFormat === $currentDate) {
|
||||||
?>
|
echo 'style="background: #cef0ad;"';
|
||||||
>
|
}
|
||||||
|
?>>
|
||||||
<?php
|
<?php
|
||||||
foreach ($resinMaterials as $resinMaterialIndex => $resinMaterial) { ?>
|
foreach ($resinMaterials as $resinMaterialIndex => $resinMaterial) { ?>
|
||||||
<!-- this will loop till materials present -->
|
<!-- this will loop till materials present -->
|
||||||
@ -421,22 +421,20 @@
|
|||||||
oninput="openingStockChange(this)"
|
oninput="openingStockChange(this)"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
|
|
||||||
<?php }?>
|
<?php } ?>><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock'] ?? '-' ?></td>
|
||||||
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
|
|
||||||
|
|
||||||
<td class="celda_normal receiptStock"
|
<td class="celda_normal receiptStock"
|
||||||
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"
|
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"
|
||||||
oninput="receiptStockChange(this)"
|
oninput="receiptStockChange(this)"
|
||||||
contenteditable="true">0</td>
|
contenteditable="true">-</td>
|
||||||
|
|
||||||
<td class="celda_normal usedStock"
|
<td class="celda_normal usedStock"
|
||||||
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"
|
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"
|
||||||
oninput="usedStockChange(this)"
|
oninput="usedStockChange(this)"
|
||||||
contenteditable="true">0</td>
|
contenteditable="true">-</td>
|
||||||
|
|
||||||
<td class="celda_normal balanceStock"
|
<td class="celda_normal balanceStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock'] ?? '-' ?></td>
|
||||||
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -586,12 +584,9 @@
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$('#saveId').click(function() {
|
$('#saveId').click(function() {
|
||||||
@ -635,7 +630,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -670,20 +664,18 @@
|
|||||||
|
|
||||||
return JSON.stringify(rows, null, 2);
|
return JSON.stringify(rows, null, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function openingStockChange(tdElement) {
|
function openingStockChange(tdElement) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
let dataId = tdElement.getAttribute('data-id');
|
||||||
let [date, materialCode] = tdElement.getAttribute('data-id').split(' ');
|
let [date, materialCode] = tdElement.getAttribute('data-id').split(' ');
|
||||||
let openingStock = tdElement.innerText;
|
let openingStock = validateInput(tdElement.innerText);
|
||||||
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
|
let usedStock = validateInput(document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText);
|
||||||
let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
|
let receiptStock = validateInput(document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText);
|
||||||
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
|
let currentBalanceStock = validateInput((Number(openingStock) + Number(receiptStock)) - Number(usedStock));
|
||||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
|
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
|
||||||
|
|
||||||
updateStockValue(date, materialCode, currentBalanceStock)
|
updateStockValue(date, materialCode, currentBalanceStock)
|
||||||
@ -700,9 +692,9 @@
|
|||||||
try {
|
try {
|
||||||
let dataId = tdElement.getAttribute('data-id');
|
let dataId = tdElement.getAttribute('data-id');
|
||||||
let [date, materialCode] = tdElement.getAttribute('data-id').split(' ');
|
let [date, materialCode] = tdElement.getAttribute('data-id').split(' ');
|
||||||
let openingStock = document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText;
|
let openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText);
|
||||||
let receiptStock = tdElement.innerText;
|
let receiptStock = validateInput(tdElement.innerText);
|
||||||
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
|
let usedStock = validateInput(document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText);
|
||||||
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
|
let currentBalanceStock = (Number(openingStock) + Number(receiptStock)) - Number(usedStock);
|
||||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
|
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
|
||||||
|
|
||||||
@ -738,10 +730,34 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function validateInput(input) {
|
||||||
|
|
||||||
|
|
||||||
|
if (input == '' || input == ' ' || input == '-') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof input === 'string' && input.split('').map(char => char.charCodeAt(0))[0] == 10) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate against the regex
|
||||||
|
const isValid = /^-?\d*\.?\d*$/.test(input);
|
||||||
|
if (!isValid) {
|
||||||
|
alert('Invalid input! Please enter a valid number.');
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function updateStockValue(date, materialCode, currentBalanceStock) {
|
function updateStockValue(date, materialCode, currentBalanceStock) {
|
||||||
|
|
||||||
const table = $('#resinStockDetailsTableId');
|
const table = $('#resinStockDetailsTableId');
|
||||||
@ -761,9 +777,9 @@
|
|||||||
|
|
||||||
document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
|
document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
|
||||||
|
|
||||||
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
|
let usedStock = validateInput(document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
|
let receiptStock = validateInput(document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText);
|
||||||
|
|
||||||
currentBalanceStock = (Number(currentBalanceStock) + Number(receiptStock)) - Number(usedStock);
|
currentBalanceStock = (Number(currentBalanceStock) + Number(receiptStock)) - Number(usedStock);
|
||||||
|
|
||||||
@ -773,7 +789,4 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user