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,11 +349,12 @@
|
|||||||
</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): ?>
|
||||||
oninput="openingStockChange(this)"
|
oninput="openingStockChange(this)"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
><?= $bagStock['opening']?>
|
><?= $bagStock['opening']?>
|
||||||
@ -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,10 +105,11 @@
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
._Separador {
|
._Separador {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
@ -173,27 +174,27 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$date = DateTime::createFromFormat('M-Y', $month);
|
$date = DateTime::createFromFormat('M-Y', $month);
|
||||||
|
|
||||||
$startDate = $date->modify('first day of this month')->format('Y-m-d');
|
$startDate = $date->modify('first day of this month')->format('Y-m-d');
|
||||||
$endDate = $date->modify('last day of this month')->format('Y-m-d');
|
$endDate = $date->modify('last day of this month')->format('Y-m-d');
|
||||||
|
|
||||||
$datesInMonth = [];
|
$datesInMonth = [];
|
||||||
|
|
||||||
|
|
||||||
$period = new DatePeriod(
|
$period = new DatePeriod(
|
||||||
new DateTime($startDate),
|
new DateTime($startDate),
|
||||||
new DateInterval('P1D'),
|
new DateInterval('P1D'),
|
||||||
(new DateTime($endDate))->modify('+1 day')
|
(new DateTime($endDate))->modify('+1 day')
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($period as $day) {
|
foreach ($period as $day) {
|
||||||
$datesInMonth[] = $day->format('Y-m-d');
|
$datesInMonth[] = $day->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -242,207 +243,204 @@
|
|||||||
<button type="submit" class="btn btn-success"> Change Month </button>
|
<button type="submit" class="btn btn-success"> Change Month </button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<div class="dropdown float-right">
|
<div class="dropdown float-right">
|
||||||
<a href="#" class="dropdown-toggle arrow-none" data-toggle="dropdown"
|
<a href="#" class="dropdown-toggle arrow-none" data-toggle="dropdown"
|
||||||
aria-expanded="false">
|
aria-expanded="false">
|
||||||
<i class="mdi mdi-dots-vertical m-0 text-muted h3"></i>
|
<i class="mdi mdi-dots-vertical m-0 text-muted h3"></i>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu dropdown-menu-right">
|
<div class="dropdown-menu dropdown-menu-right">
|
||||||
<a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a>
|
<a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a>
|
||||||
<a class="dropdown-item" href="#">Export</a>
|
<a class="dropdown-item" href="#">Export</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="resinStockDetailsTableId" class="fht-table table-striped">
|
<table id="resinStockDetailsTableId" class="fht-table table-striped">
|
||||||
|
|
||||||
<thead class="celda_encabezado_general" style="padding: 10px;">
|
<thead class="celda_encabezado_general" style="padding: 10px;">
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th class="celda_encabezado_general" colspan="1">material </th>
|
<th class="celda_encabezado_general" colspan="1">material </th>
|
||||||
|
|
||||||
<?php foreach($resinMaterials as $resinMaterial){ ?>
|
<?php foreach ($resinMaterials as $resinMaterial) { ?>
|
||||||
<!-- this will loop till materials present -->
|
<!-- this will loop till materials present -->
|
||||||
<th class="celda_encabezado_general" colspan="4">
|
<th class="celda_encabezado_general" colspan="4">
|
||||||
<?= $resinMaterial['MaterialName']?>
|
<?= $resinMaterial['MaterialName'] ?>
|
||||||
<!-- (<?= $resinMaterial['MaterialCode']?>) -->
|
<!-- (<?= $resinMaterial['MaterialCode'] ?>) -->
|
||||||
</th>
|
</th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th class="celda_encabezado_general" colspan="1">Date </th>
|
|
||||||
|
|
||||||
<?php foreach($resinMaterials as $resinMaterial){ ?>
|
<tr>
|
||||||
<!-- this will loop till materials present -->
|
<th class="celda_encabezado_general" colspan="1">Date </th>
|
||||||
<th class="celda_encabezado_general" style="display:none">Date</th>
|
|
||||||
<th class="celda_encabezado_general" style="display:none"> material</th>
|
<?php foreach ($resinMaterials as $resinMaterial) { ?>
|
||||||
<th class="celda_encabezado_general" style="display:none"> customer</th>
|
<!-- this will loop till materials present -->
|
||||||
<th class="celda_encabezado_general">Opening Stock</th>
|
<th class="celda_encabezado_general" style="display:none">Date</th>
|
||||||
<th class="celda_encabezado_general">Receipt</th>
|
<th class="celda_encabezado_general" style="display:none"> material</th>
|
||||||
<th class="celda_encabezado_general">Used</th>
|
<th class="celda_encabezado_general" style="display:none"> customer</th>
|
||||||
<th class="celda_encabezado_general">Balance Stock</th>
|
<th class="celda_encabezado_general">Opening Stock</th>
|
||||||
<?php } ?>
|
<th class="celda_encabezado_general">Receipt</th>
|
||||||
|
<th class="celda_encabezado_general">Used</th>
|
||||||
|
<th class="celda_encabezado_general">Balance Stock</th>
|
||||||
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<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){
|
?>
|
||||||
?>
|
<tr
|
||||||
<tr
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$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;"';}
|
|
||||||
?>
|
|
||||||
>
|
|
||||||
<?php foreach($resinStockDetails as $resinStockIndex => $resinStock){ ?>
|
|
||||||
<?php if ($resinStockIndex == 0): ?>
|
|
||||||
<?php
|
|
||||||
$startDate =DateTime::createFromFormat('Y-m-d', $resinStock['date'])->format('d-m-Y');
|
|
||||||
?>
|
|
||||||
<td class="celda_normal">
|
|
||||||
<?= $startDate ?>
|
|
||||||
</td>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<td style="display:none">
|
|
||||||
<?= $resinStock['date']?>
|
|
||||||
</td>
|
|
||||||
<td style="display:none"
|
|
||||||
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
|
|
||||||
class="materialCode" ><?= $resinStock['materialCode']?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td style="display:none" class="celda_normal customer"
|
|
||||||
data-materialCode="<?=$resinStock['materialCode']?>"
|
|
||||||
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>">
|
|
||||||
<?= $resinStock['customer']?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="celda_normal openingStock"
|
|
||||||
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
|
|
||||||
|
|
||||||
<?php if ($groupedResinStockDetailsIndex == 0): ?>
|
|
||||||
oninput="openingStockChange(this)"
|
|
||||||
contenteditable="true"
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
><?= $resinStock['opening']?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="celda_normal receiptStock"
|
|
||||||
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
|
|
||||||
oninput="receiptStockChange(this)"
|
|
||||||
contenteditable="true">
|
|
||||||
<?= $resinStock['receipt']?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="celda_normal usedStock"
|
|
||||||
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
|
|
||||||
oninput="usedStockChange(this)"
|
|
||||||
contenteditable="true"><?= $resinStock['used']?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="celda_normal balanceStock"
|
|
||||||
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>">
|
|
||||||
<?= $resinStock['balanceStock']?>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<!-- this else condition work if groupedBagStockDetails is empty and creating new records
|
|
||||||
with initial values 0 for entire month -->
|
|
||||||
<?php } else { ?>
|
|
||||||
|
|
||||||
|
|
||||||
<?php foreach($datesInMonth as $datesInMonthIndex => $dateInMonth){ ?>
|
|
||||||
<tr
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$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', $resinStockDetails[0]['date'])->format('d-m-Y');
|
||||||
if ($dateInMonthDmYFormat === $currentDate) { echo 'style="background: #cef0ad;"';}
|
if ($dateInMonthDmYFormat === $currentDate) {
|
||||||
?>
|
echo 'style="background: #cef0ad;"';
|
||||||
>
|
}
|
||||||
<?php
|
?>>
|
||||||
foreach($resinMaterials as $resinMaterialIndex => $resinMaterial){ ?>
|
<?php foreach ($resinStockDetails as $resinStockIndex => $resinStock) { ?>
|
||||||
<!-- this will loop till materials present -->
|
<?php if ($resinStockIndex == 0): ?>
|
||||||
|
<?php
|
||||||
|
$startDate = DateTime::createFromFormat('Y-m-d', $resinStock['date'])->format('d-m-Y');
|
||||||
|
?>
|
||||||
|
<td class="celda_normal">
|
||||||
|
<?= $startDate ?>
|
||||||
|
</td>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($resinMaterialIndex == 0): ?>
|
<td style="display:none">
|
||||||
<?php
|
<?= $resinStock['date'] ?>
|
||||||
$startDate =DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
|
</td>
|
||||||
?>
|
<td style="display:none"
|
||||||
<td class="celda_normal">
|
data-id="<?= $resinStock['date'] ?> <?= $resinStock['materialCode'] ?>"
|
||||||
<?= $startDate ?>
|
class="materialCode"><?= $resinStock['materialCode'] ?>
|
||||||
</td>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<td class="celda_normal" style="display:none">
|
|
||||||
<?= $dateInMonth?>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal" style="display:none"
|
<td style="display:none" class="celda_normal customer"
|
||||||
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>">
|
data-materialCode="<?= $resinStock['materialCode'] ?>"
|
||||||
<?= $resinMaterial['MaterialCode']?>
|
data-id="<?= $resinStock['date'] ?> <?= $resinStock['materialCode'] ?>">
|
||||||
</td>
|
<?= $resinStock['customer'] ?>
|
||||||
|
|
||||||
<td class="celda_normal customer" style="display:none"
|
|
||||||
data-materialCode="<?=$resinMaterial['MaterialCode']?>"
|
|
||||||
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>">
|
|
||||||
<?= $resinMaterial['customers']?>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal openingStock"
|
<td class="celda_normal openingStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
data-id="<?= $resinStock['date'] ?> <?= $resinStock['materialCode'] ?>"
|
||||||
<?php if($datesInMonthIndex == 0){ ?>
|
|
||||||
|
|
||||||
oninput="openingStockChange(this)"
|
|
||||||
contenteditable="true"
|
|
||||||
|
|
||||||
<?php }?>
|
<?php if ($groupedResinStockDetailsIndex == 0): ?>
|
||||||
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
|
oninput="openingStockChange(this)"
|
||||||
|
contenteditable="true"
|
||||||
|
<?php endif; ?>><?= $resinStock['opening'] ?>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal receiptStock"
|
<td class="celda_normal receiptStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
data-id="<?= $resinStock['date'] ?> <?= $resinStock['materialCode'] ?>"
|
||||||
oninput="receiptStockChange(this)"
|
oninput="receiptStockChange(this)"
|
||||||
contenteditable="true">0</td>
|
contenteditable="true">
|
||||||
|
<?= $resinStock['receipt'] ?>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal usedStock"
|
<td class="celda_normal usedStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
data-id="<?= $resinStock['date'] ?> <?= $resinStock['materialCode'] ?>"
|
||||||
oninput="usedStockChange(this)"
|
oninput="usedStockChange(this)"
|
||||||
contenteditable="true">0</td>
|
contenteditable="true"><?= $resinStock['used'] ?>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal balanceStock"
|
<td class="celda_normal balanceStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
data-id="<?= $resinStock['date'] ?> <?= $resinStock['materialCode'] ?>">
|
||||||
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
|
<?= $resinStock['balanceStock'] ?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<!-- this else condition work if groupedBagStockDetails is empty and creating new records
|
||||||
|
with initial values 0 for entire month -->
|
||||||
|
<?php } else { ?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { ?>
|
||||||
|
<tr
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$currentDate = date('d-m-Y');
|
||||||
|
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
|
||||||
|
if ($dateInMonthDmYFormat === $currentDate) {
|
||||||
|
echo 'style="background: #cef0ad;"';
|
||||||
|
}
|
||||||
|
?>>
|
||||||
|
<?php
|
||||||
|
foreach ($resinMaterials as $resinMaterialIndex => $resinMaterial) { ?>
|
||||||
|
<!-- this will loop till materials present -->
|
||||||
|
|
||||||
|
<?php if ($resinMaterialIndex == 0): ?>
|
||||||
|
<?php
|
||||||
|
$startDate = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
|
||||||
|
?>
|
||||||
|
<td class="celda_normal">
|
||||||
|
<?= $startDate ?>
|
||||||
|
</td>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<td class="celda_normal" style="display:none">
|
||||||
|
<?= $dateInMonth ?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="celda_normal" style="display:none"
|
||||||
|
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>">
|
||||||
|
<?= $resinMaterial['MaterialCode'] ?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="celda_normal customer" style="display:none"
|
||||||
|
data-materialCode="<?= $resinMaterial['MaterialCode'] ?>"
|
||||||
|
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>">
|
||||||
|
<?= $resinMaterial['customers'] ?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="celda_normal openingStock"
|
||||||
|
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"
|
||||||
|
<?php if ($datesInMonthIndex == 0) { ?>
|
||||||
|
|
||||||
|
oninput="openingStockChange(this)"
|
||||||
|
contenteditable="true"
|
||||||
|
|
||||||
|
<?php } ?>><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock'] ?? '-' ?></td>
|
||||||
|
|
||||||
|
<td class="celda_normal receiptStock"
|
||||||
|
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"
|
||||||
|
oninput="receiptStockChange(this)"
|
||||||
|
contenteditable="true">-</td>
|
||||||
|
|
||||||
|
<td class="celda_normal usedStock"
|
||||||
|
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"
|
||||||
|
oninput="usedStockChange(this)"
|
||||||
|
contenteditable="true">-</td>
|
||||||
|
|
||||||
|
<td class="celda_normal balanceStock"
|
||||||
|
data-id="<?= $dateInMonth ?> <?= $resinMaterial['MaterialCode'] ?>"><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock'] ?? '-' ?></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php }?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -465,58 +463,58 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div >
|
<div>
|
||||||
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-lg" >
|
<div class="modal-dialog modal-lg">
|
||||||
<div class="modal-content" >
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h4 class="modal-title" id="myLargeModalLabel">Navigation Options</h4>
|
<h4 class="modal-title" id="myLargeModalLabel">Navigation Options</h4>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<div class="row">
|
|
||||||
<!-- bag Dropdown -->
|
|
||||||
<div class="col-md-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="resinDropdown">Select Bag</label>
|
|
||||||
<select id="resinDropdown" class="form-control">
|
|
||||||
<option value="">Select Resin</option>
|
|
||||||
<?php foreach($resinMaterials as $resinMaterial): ?>
|
|
||||||
<option value=" <?= $resinMaterial['MaterialName']?>">
|
|
||||||
<?= $resinMaterial['MaterialName']?>
|
|
||||||
</option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Date Dropdown -->
|
|
||||||
<div class="col-md-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="dateDropdown">Select Date</label>
|
|
||||||
<select id="dateDropdown" class="form-control">
|
|
||||||
<?php foreach($datesInMonth as $selectDate): ?>
|
|
||||||
<?php $selectDate=DateTime::createFromFormat('Y-m-d', $selectDate)->format('d-m-Y'); ?>
|
|
||||||
<option value="<?=$selectDate?>"><?=$selectDate?></option>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary float-right" onclick="navigateToResin()">Navigate</button>
|
<div class="modal-body">
|
||||||
</div>
|
<div class="row">
|
||||||
</div><!-- /.modal-content -->
|
<!-- bag Dropdown -->
|
||||||
</div><!-- /.modal-dialog -->
|
<div class="col-md-6">
|
||||||
</div><!-- /.modal -->
|
<div class="form-group">
|
||||||
|
<label for="resinDropdown">Select Bag</label>
|
||||||
|
<select id="resinDropdown" class="form-control">
|
||||||
|
<option value="">Select Resin</option>
|
||||||
|
<?php foreach ($resinMaterials as $resinMaterial): ?>
|
||||||
|
<option value=" <?= $resinMaterial['MaterialName'] ?>">
|
||||||
|
<?= $resinMaterial['MaterialName'] ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Date Dropdown -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="dateDropdown">Select Date</label>
|
||||||
|
<select id="dateDropdown" class="form-control">
|
||||||
|
<?php foreach ($datesInMonth as $selectDate): ?>
|
||||||
|
<?php $selectDate = DateTime::createFromFormat('Y-m-d', $selectDate)->format('d-m-Y'); ?>
|
||||||
|
<option value="<?= $selectDate ?>"><?= $selectDate ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-primary float-right" onclick="navigateToResin()">Navigate</button>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function navigateToResin() {
|
function navigateToResin() {
|
||||||
$('.close').click();
|
$('.close').click();
|
||||||
const resinDropdown = document.getElementById('resinDropdown');
|
const resinDropdown = document.getElementById('resinDropdown');
|
||||||
@ -547,7 +545,7 @@
|
|||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
const dateCell = row.querySelector('td:first-child');
|
const dateCell = row.querySelector('td:first-child');
|
||||||
if (dateCell && dateCell.textContent.trim() === selectedDate) {
|
if (dateCell && dateCell.textContent.trim() === selectedDate) {
|
||||||
|
|
||||||
targetRow = row;
|
targetRow = row;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -559,9 +557,9 @@
|
|||||||
|
|
||||||
console.log(targetColumnIndex);
|
console.log(targetColumnIndex);
|
||||||
console.log(targetRow);
|
console.log(targetRow);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
targetColumnIndex = targetColumnIndex * 7;
|
targetColumnIndex = targetColumnIndex * 7;
|
||||||
|
|
||||||
targetRow.cells[targetColumnIndex].scrollIntoView({
|
targetRow.cells[targetColumnIndex].scrollIntoView({
|
||||||
@ -571,7 +569,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
const highlightDuration = 10000;
|
const highlightDuration = 10000;
|
||||||
for (let i = targetColumnIndex-4 ; i <= targetColumnIndex ; i++) {
|
for (let i = targetColumnIndex - 4; i <= targetColumnIndex; i++) {
|
||||||
const cell = targetRow.cells[i];
|
const cell = targetRow.cells[i];
|
||||||
if (cell) {
|
if (cell) {
|
||||||
|
|
||||||
@ -586,20 +584,17 @@
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$('#saveId').click(function() {
|
||||||
$(document).ready(function () {
|
|
||||||
|
|
||||||
$('#saveId').click(function () {
|
|
||||||
|
|
||||||
//table to json function
|
//table to json function
|
||||||
|
|
||||||
var updateResinStockDetails = tableToJson();
|
var updateResinStockDetails = tableToJson();
|
||||||
|
|
||||||
|
|
||||||
alert('Updation may take a while, And we appreciate your patience..!!');
|
alert('Updation may take a while, And we appreciate your patience..!!');
|
||||||
|
|
||||||
@ -611,7 +606,7 @@
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?php echo base_url() ?>updateResinStockDetails",
|
url: "<?php echo base_url() ?>updateResinStockDetails",
|
||||||
|
|
||||||
success: function (data) {
|
success: function(data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
$('#loader').hide();
|
$('#loader').hide();
|
||||||
console.log(data);
|
console.log(data);
|
||||||
@ -620,14 +615,14 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
|
|
||||||
alert("An error occurred while processing the request. Please try again.");
|
alert("An error occurred while processing the request. Please try again.");
|
||||||
console.error("Error Code:", xhr.status);
|
console.error("Error Code:", xhr.status);
|
||||||
console.error("Error Message:", error);
|
console.error("Error Message:", error);
|
||||||
console.error("Response Text:", xhr.responseText);
|
console.error("Response Text:", xhr.responseText);
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function() {
|
||||||
$('#loader').hide();
|
$('#loader').hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -635,7 +630,6 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -646,134 +640,153 @@
|
|||||||
//this table to json is customized for bagstock not for all
|
//this table to json is customized for bagstock not for all
|
||||||
|
|
||||||
table.find('tbody tr').each(function() {
|
table.find('tbody tr').each(function() {
|
||||||
const rowCells = $(this).find('td');
|
const rowCells = $(this).find('td');
|
||||||
const date = rowCells.eq(0).text().trim();
|
const date = rowCells.eq(0).text().trim();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** we get eight entries against a material so we loop from 1 to 7 and so on
|
/** we get eight entries against a material so we loop from 1 to 7 and so on
|
||||||
in a single row **/
|
in a single row **/
|
||||||
for (let i = 1; i < rowCells.length; i += 7) {
|
for (let i = 1; i < rowCells.length; i += 7) {
|
||||||
const rowData = {
|
const rowData = {
|
||||||
date: rowCells.eq(i).text().trim(),
|
date: rowCells.eq(i).text().trim(),
|
||||||
materialCode: rowCells.eq(i+1).text().trim(),
|
materialCode: rowCells.eq(i + 1).text().trim(),
|
||||||
customer: rowCells.eq(i+2).text().trim(),
|
customer: rowCells.eq(i + 2).text().trim(),
|
||||||
opening: rowCells.eq(i+3).text().trim(),
|
opening: rowCells.eq(i + 3).text().trim(),
|
||||||
receipt: rowCells.eq(i+4).text().trim(),
|
receipt: rowCells.eq(i + 4).text().trim(),
|
||||||
used: rowCells.eq(i+5).text().trim(),
|
used: rowCells.eq(i + 5).text().trim(),
|
||||||
balanceStock: rowCells.eq(i + 6).text().trim()
|
balanceStock: rowCells.eq(i + 6).text().trim()
|
||||||
};
|
};
|
||||||
|
|
||||||
rows.push(rowData);
|
rows.push(rowData);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
} catch(error){
|
} catch (error) {
|
||||||
|
|
||||||
console.error("There is an error updating stock ..!!" + error);
|
console.error("There is an error updating stock ..!!" + error);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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;
|
||||||
|
|
||||||
updateStockValue( date,materialCode,currentBalanceStock )
|
updateStockValue(date, materialCode, currentBalanceStock)
|
||||||
|
|
||||||
|
|
||||||
} catch(error){
|
} catch (error) {
|
||||||
|
|
||||||
console.error("There is an error updating stock ..!!" + error);
|
console.error("There is an error updating stock ..!!" + error);
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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 openingStock = document.querySelector(`td.openingStock[data-id="${dataId}"]`).innerText;
|
||||||
let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
|
let receiptStock = document.querySelector(`td.receiptStock[data-id="${dataId}"]`).innerText;
|
||||||
let usedStock = tdElement.innerText;
|
let usedStock = 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)
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
console.error("There is an error updating stock ..!!" + error);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
|
|
||||||
console.error("There is an error updating stock ..!!" + error);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
function updateStockValue(date, materialCode, currentBalanceStock) {
|
||||||
function updateStockValue( date, materialCode, currentBalanceStock ){
|
|
||||||
|
|
||||||
const table = $('#resinStockDetailsTableId');
|
const table = $('#resinStockDetailsTableId');
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
||||||
table.find('tbody tr').each(function() {
|
table.find('tbody tr').each(function() {
|
||||||
const rowCells = $(this).find('td');
|
const rowCells = $(this).find('td');
|
||||||
const otherDate = rowCells.eq(1).text().trim();
|
const otherDate = rowCells.eq(1).text().trim();
|
||||||
|
|
||||||
|
|
||||||
if( new Date(otherDate) > new Date(date) ){ //other records present after it
|
if (new Date(otherDate) > new Date(date)) { //other records present after it
|
||||||
|
|
||||||
/**this data-id ,openingStock ,used stock , current Balance Stock
|
/**this data-id ,openingStock ,used stock , current Balance Stock
|
||||||
is for changing subsequent dates not the earlier one **/
|
is for changing subsequent dates not the earlier one **/
|
||||||
|
|
||||||
let dataId = `${otherDate} ${materialCode}`;
|
let dataId = `${otherDate} ${materialCode}`;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
|
||||||
|
|
||||||
|
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText = currentBalanceStock;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
</script>
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user