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
|
||||
// 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) {
|
||||
$materialCode = $resinMaterial['MaterialCode'];
|
||||
$resinMaterials[$key]['customers'] = $this->bagStockDetails_model
|
||||
$resinMaterials[$key]['customers'] = $this->resinStockDetails_model
|
||||
->select('customer')
|
||||
->where('date >=', $startDate)
|
||||
->where('date <=', $endDate)
|
||||
|
||||
@ -32,30 +32,5 @@ class BagStockDetailsModel extends Model
|
||||
* @param array $data Array of records to be updated in bulk.
|
||||
* @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 class="celda_normal openingStock"
|
||||
|
||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||
|
||||
<?php if ($groupedBagStockDetailsIndex == 0): ?>
|
||||
@ -362,14 +363,18 @@
|
||||
<td class="celda_normal receiptStock"
|
||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||
oninput="receiptStockChange(this)"
|
||||
contenteditable="true">
|
||||
contenteditable="true"
|
||||
>
|
||||
<?= $bagStock['receipt']?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal usedStock"
|
||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||
oninput="usedStockChange(this)"
|
||||
contenteditable="true"><?= $bagStock['used']?>
|
||||
contenteditable="true"
|
||||
|
||||
>
|
||||
<?= $bagStock['used']?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal balanceStock"
|
||||
@ -432,21 +437,20 @@
|
||||
contenteditable="true"
|
||||
|
||||
<?php }?>
|
||||
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?></td>
|
||||
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'-' ?></td>
|
||||
|
||||
<td class="celda_normal receiptStock"
|
||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||
oninput="receiptStockChange(this)"
|
||||
contenteditable="true">0</td>
|
||||
contenteditable="true"> - </td>
|
||||
|
||||
<td class="celda_normal usedStock"
|
||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||
oninput="usedStockChange(this)"
|
||||
contenteditable="true">0</td>
|
||||
oninput="usedStockChange(this)" contenteditable="true"> - </td>
|
||||
|
||||
<td class="celda_normal balanceStock"
|
||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?></td>
|
||||
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'-' ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@ -694,11 +698,17 @@
|
||||
|
||||
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 openingStock = validateInput( tdElement.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);
|
||||
|
||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
||||
|
||||
updateStockValue( date,materialCode,currentBalanceStock )
|
||||
@ -713,12 +723,19 @@
|
||||
|
||||
function receiptStockChange(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 = tdElement.innerText;
|
||||
let usedStock = document.querySelector(`td.usedStock[data-id="${dataId}"]`).innerText;
|
||||
|
||||
let openingStock = validateInput(document.querySelector(`td.openingStock[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);
|
||||
|
||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
||||
|
||||
updateStockValue( date,materialCode,currentBalanceStock )
|
||||
@ -736,12 +753,19 @@
|
||||
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 openingStock = validateInput(document.querySelector(`td.openingStock[data-id="${dataId}"]`).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);
|
||||
|
||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
||||
|
||||
updateStockValue( date,materialCode,currentBalanceStock )
|
||||
@ -776,9 +800,9 @@
|
||||
|
||||
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);
|
||||
|
||||
@ -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>
|
||||
|
||||
|
||||
|
||||
@ -105,7 +105,8 @@
|
||||
border: 1px solid #ccc;
|
||||
color: #ffffff;
|
||||
font-weight: bold;
|
||||
padding: 6px 10px;;
|
||||
padding: 6px 10px;
|
||||
;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@ -299,8 +300,7 @@
|
||||
|
||||
<tbody style="background-color: #fff;">
|
||||
|
||||
<?php if(!empty($groupedResinStockDetails))
|
||||
{
|
||||
<?php if (!empty($groupedResinStockDetails)) {
|
||||
//dd($groupedResinStockDetails);
|
||||
foreach ($groupedResinStockDetails as $groupedResinStockDetailsIndex => $resinStockDetails) {
|
||||
?>
|
||||
@ -310,9 +310,10 @@
|
||||
|
||||
$currentDate = date('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 if ($resinStockIndex == 0): ?>
|
||||
<?php
|
||||
@ -343,9 +344,7 @@
|
||||
<?php if ($groupedResinStockDetailsIndex == 0): ?>
|
||||
oninput="openingStockChange(this)"
|
||||
contenteditable="true"
|
||||
<?php endif; ?>
|
||||
|
||||
><?= $resinStock['opening']?>
|
||||
<?php endif; ?>><?= $resinStock['opening'] ?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal receiptStock"
|
||||
@ -383,9 +382,10 @@
|
||||
|
||||
$currentDate = date('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
|
||||
foreach ($resinMaterials as $resinMaterialIndex => $resinMaterial) { ?>
|
||||
<!-- this will loop till materials present -->
|
||||
@ -421,22 +421,20 @@
|
||||
oninput="openingStockChange(this)"
|
||||
contenteditable="true"
|
||||
|
||||
<?php }?>
|
||||
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
|
||||
<?php } ?>><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock'] ?? '-' ?></td>
|
||||
|
||||
<td class="celda_normal receiptStock"
|
||||
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"
|
||||
oninput="receiptStockChange(this)"
|
||||
contenteditable="true">0</td>
|
||||
contenteditable="true">-</td>
|
||||
|
||||
<td class="celda_normal usedStock"
|
||||
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"
|
||||
oninput="usedStockChange(this)"
|
||||
contenteditable="true">0</td>
|
||||
contenteditable="true">-</td>
|
||||
|
||||
<td class="celda_normal balanceStock"
|
||||
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
||||
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
|
||||
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock'] ?? '-' ?></td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@ -586,12 +584,9 @@
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#saveId').click(function() {
|
||||
@ -635,7 +630,6 @@
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
@ -670,20 +664,18 @@
|
||||
|
||||
return JSON.stringify(rows, null, 2);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
function openingStockChange(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);
|
||||
let openingStock = validateInput(tdElement.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 = validateInput((Number(openingStock) + Number(receiptStock)) - Number(usedStock));
|
||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
|
||||
|
||||
updateStockValue(date, materialCode, currentBalanceStock)
|
||||
@ -700,9 +692,9 @@
|
||||
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 openingStock = validateInput(document.querySelector(`td.openingStock[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);
|
||||
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>
|
||||
|
||||
function updateStockValue(date, materialCode, currentBalanceStock) {
|
||||
|
||||
const table = $('#resinStockDetailsTableId');
|
||||
@ -761,9 +777,9 @@
|
||||
|
||||
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);
|
||||
|
||||
@ -773,7 +789,4 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user