Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme
This commit is contained in:
commit
63ce96efec
@ -11,6 +11,7 @@ use App\Models\FactoryVehicleDieselStockSummaryModel;
|
||||
use App\Models\IncomingSilicaSandDetailsModel;
|
||||
use App\Models\Inwardgateregister_model;
|
||||
use App\Models\Rawmaterialdetails_model;
|
||||
use App\Models\BagStockDetailsModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use DateTime;
|
||||
|
||||
@ -26,6 +27,8 @@ class StockController extends BaseController
|
||||
protected $incomingSilicaSandDetails_model;
|
||||
protected $inwardGateRegister_model;
|
||||
protected $rawmaterialdetails_model;
|
||||
protected $bagStockDetails_model;
|
||||
protected $Rawmaterialdetails_model;
|
||||
|
||||
/**
|
||||
* This is default constructor of the class
|
||||
@ -42,6 +45,8 @@ class StockController extends BaseController
|
||||
$this->rawmaterialdetails_model = new Rawmaterialdetails_model();
|
||||
$this->incomingSilicaSandDetails_model = new IncomingSilicaSandDetailsModel();
|
||||
$this->inwardGateRegister_model = new Inwardgateregister_model();
|
||||
$this->bagStockDetails_model = new BagStockDetailsModel();
|
||||
|
||||
|
||||
$this->session = session();
|
||||
helper('form');
|
||||
@ -257,15 +262,133 @@ class StockController extends BaseController
|
||||
|
||||
public function loadView_bagStockDetails(){
|
||||
|
||||
if ($this->request->getMethod() === 'POST'){
|
||||
$month = $this->request->getPost('month');
|
||||
|
||||
$date = DateTime::createFromFormat('M-Y', $month);
|
||||
|
||||
$formattedDate = $date->format('Y-m');
|
||||
|
||||
$month=$formattedDate;
|
||||
}
|
||||
else{
|
||||
$month = date('Y-m');
|
||||
}
|
||||
|
||||
$data=[];
|
||||
|
||||
$data['month']=$month;
|
||||
|
||||
$this->global['pageTitle']='Bag Stock Details';
|
||||
|
||||
return $this->loadViews("bagStockDetails", $this->global, $data, NULL);
|
||||
$startDate = "$month-01";
|
||||
$endDate = date("Y-m-t", strtotime($startDate));
|
||||
$data['bagStockDetails'] = $this->bagStockDetails_model
|
||||
->where('date >=', $startDate)
|
||||
->where('date <=', $endDate)
|
||||
->groupBy(['materialCode','date'])
|
||||
->orderBy('date','asc')
|
||||
->orderBy('materialCode','asc')
|
||||
->findAll();
|
||||
|
||||
// Initialize an empty array to hold the grouped data
|
||||
$data['groupedBagStockDetails'] = [];
|
||||
|
||||
// Temporary array to store grouped data by date
|
||||
$groupedByDate = [];
|
||||
|
||||
// Group by 'date'
|
||||
foreach ($data['bagStockDetails'] as $detail) {
|
||||
$date = $detail['date'];
|
||||
|
||||
// Initialize the array for this date if it doesn't exist
|
||||
if (!isset($groupedByDate[$date])) {
|
||||
$groupedByDate[$date] = [];
|
||||
}
|
||||
|
||||
// Append the detail to the sub-array for this date
|
||||
$groupedByDate[$date][] = $detail;
|
||||
}
|
||||
|
||||
// Reset the structure to have indexed arrays without the date keys
|
||||
$data['groupedBagStockDetails'] = array_values($groupedByDate);
|
||||
|
||||
|
||||
|
||||
$bagMaterials= $this->rawmaterialdetails_model->getAllBagMaterialCode();
|
||||
|
||||
|
||||
|
||||
foreach($bagMaterials as $key => $bagMaterial){
|
||||
$materialCode = $bagMaterial['MaterialCode'];
|
||||
$bagMaterials[$key]['customers'] = $this->bagStockDetails_model
|
||||
->select('customer')
|
||||
->where('date >=', $startDate)
|
||||
->where('date <=', $endDate)
|
||||
->where('materialCode', $materialCode)
|
||||
->first()['customer'] ?? '';
|
||||
}
|
||||
|
||||
$bagMaterialcount = count($bagMaterials);
|
||||
|
||||
$data['bagMaterialcount'] = $bagMaterialcount;
|
||||
$data['bagMaterials'] = $bagMaterials;
|
||||
|
||||
$date = DateTime::createFromFormat('Y-m', $month);
|
||||
|
||||
$formattedDate = $date->format('M-Y');
|
||||
|
||||
$data['month']=$formattedDate;
|
||||
|
||||
return $this->loadViews("bagStockDetails", $this->global, $data, NULL);
|
||||
|
||||
}
|
||||
|
||||
public function updateBagStockDetails(){}
|
||||
public function updateBagStockDetails(){
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
$updateBagStockDetailsData = json_decode($postData['updateBagStockDetails'], true);
|
||||
|
||||
foreach($updateBagStockDetailsData as $data){
|
||||
|
||||
$date = $data['date'];
|
||||
$materialCode = $data['materialCode'];
|
||||
|
||||
|
||||
$dbData= [
|
||||
'date' =>$data['date'],
|
||||
'materialCode' =>$data['materialCode'],
|
||||
'customer' =>$data['customer'],
|
||||
'opening' =>$data['opening'],
|
||||
'receipt' =>$data['receipt'],
|
||||
'used' =>$data['used'],
|
||||
'balanceStock' =>$data['balanceStock'],
|
||||
];
|
||||
|
||||
$resultExists=$this->bagStockDetails_model
|
||||
->where('date',$date)
|
||||
->where('materialCode',$materialCode)
|
||||
->first();
|
||||
|
||||
|
||||
if(!empty($resultExists)){
|
||||
|
||||
$updated=$this->bagStockDetails_model
|
||||
->where('date',$date)
|
||||
->where('materialCode',$materialCode)
|
||||
->set($dbData)
|
||||
->update();
|
||||
|
||||
}else{
|
||||
$inserted = $this->bagStockDetails_model->insert($dbData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo "Data Saved Successfully";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -136,6 +136,20 @@ class Rawmaterialdetails_model extends Model
|
||||
return $materialCodes = array_column($materialResults, 'MaterialCode');
|
||||
}
|
||||
|
||||
function getAllBagMaterialCode(){
|
||||
|
||||
$builder = $this->db->table('t_materialmaster')
|
||||
->select('MaterialCode , MaterialName')
|
||||
->where('IsActive', 1)
|
||||
->where('Category', 'bag')
|
||||
->orderBy('MaterialCode', 'asc');
|
||||
$query = $builder->get();
|
||||
$materialResults = $query->getResultArray();
|
||||
|
||||
return $materialResults;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getMaterialstock($MaterialCode, $currentdate)
|
||||
|
||||
|
||||
@ -105,9 +105,10 @@
|
||||
border: 1px solid #ccc;
|
||||
color: #ffffff;
|
||||
font-weight: bold;
|
||||
padding: 2px 4px;
|
||||
padding: 6px 10px;;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
._Separador {
|
||||
background-color: #fff;
|
||||
@ -124,6 +125,7 @@
|
||||
.celda_normal {
|
||||
/*background-color: #fff;*/
|
||||
/* <!-- ad9271 into ffffff brown-light to green-light --> */
|
||||
text-align: center;
|
||||
border: 1px solid #ccc;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
@ -195,12 +197,9 @@
|
||||
<div class="row">
|
||||
|
||||
<div class="col-3">
|
||||
<?php $today = date('M-Y'); ?>
|
||||
|
||||
<input type="text" name="month" id="month" value=""
|
||||
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
|
||||
class="form-control mt-2" data-provide="datepicker"
|
||||
data-date-format="M-yyyy" data-date-min-view-mode="1">
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<button type="submit" class="btn btn-success"> Change Month </button>
|
||||
@ -208,104 +207,206 @@
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
<div class="table-responsive">
|
||||
<table id="bagStockDetailsTableId" class="fht-table table-striped"
|
||||
style="font-size: small;">
|
||||
<table id="bagStockDetailsTableId" class="fht-table table-striped">
|
||||
|
||||
<thead class="celda_encabezado_general" style="padding: 10px;">
|
||||
|
||||
<tr>
|
||||
|
||||
<th colspan="1">material </th>
|
||||
<th class="celda_encabezado_general" colspan="1">material </th>
|
||||
|
||||
<!-- this will loop till materials present -->
|
||||
<th colspan="4">material 1</th>
|
||||
|
||||
<th colspan="4">material 2</th>
|
||||
|
||||
|
||||
<?php foreach($bagMaterials as $bagMaterial){ ?>
|
||||
<!-- this will loop till materials present -->
|
||||
<th class="celda_encabezado_general" colspan="4">
|
||||
<?= $bagMaterial['MaterialName']?>
|
||||
<!-- (<?= $bagMaterial['MaterialCode']?>) -->
|
||||
</th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="1">Customer </th>
|
||||
|
||||
<tr>
|
||||
<th class="celda_encabezado_general" colspan="1">Customer </th>
|
||||
|
||||
<?php foreach($bagMaterials as $bagMaterial){ ?>
|
||||
<!-- this will loop till materials present -->
|
||||
<th colspan="4" contenteditable="true">
|
||||
<?php echo $customer??'Customer' ?>
|
||||
<th class="celda_encabezado_general" colspan="4" contenteditable="true">
|
||||
<?= $bagMaterial['customers']?>
|
||||
</th>
|
||||
|
||||
<th colspan="4" contenteditable="true">
|
||||
<?php echo $customer??'Customer2' ?>
|
||||
</th>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<th colspan="1">Date </th>
|
||||
|
||||
<!-- this will loop till materials present -->
|
||||
<th style="display:none">Date</th>
|
||||
<th style="display:none"> material</th>
|
||||
<th style="display:none"> customer</th>
|
||||
<th>Opening</th>
|
||||
<th>Receipt</th>
|
||||
<th>Used</th>
|
||||
<th>Balance Stock</th>
|
||||
|
||||
<th style="display:none">Date</th>
|
||||
<th style="display:none"> material</th>
|
||||
<th style="display:none"> customer</th>
|
||||
<th>Opening</th>
|
||||
<th>Receipt</th>
|
||||
<th>Used</th>
|
||||
<th>Balance Stock</th>
|
||||
<tr>
|
||||
<th class="celda_encabezado_general" colspan="1">Date </th>
|
||||
|
||||
<?php foreach($bagMaterials as $bagMaterial){ ?>
|
||||
<!-- this will loop till materials present -->
|
||||
<th class="celda_encabezado_general" style="display:none">Date</th>
|
||||
<th class="celda_encabezado_general" style="display:none"> material</th>
|
||||
<th class="celda_encabezado_general" style="display:none"> customer</th>
|
||||
<th class="celda_encabezado_general">Opening Stock</th>
|
||||
<th class="celda_encabezado_general">Receipt</th>
|
||||
<th class="celda_encabezado_general">Used</th>
|
||||
<th class="celda_encabezado_general">Balance Stock</th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody style="background-color: #fff;" >
|
||||
|
||||
|
||||
<?php if(!empty($groupedBagStockDetails))
|
||||
{
|
||||
//dd($groupedBagStockDetails);
|
||||
foreach($groupedBagStockDetails as $groupedBagStockDetailsIndex => $bagStockDetails){
|
||||
?>
|
||||
|
||||
<tr>
|
||||
|
||||
|
||||
|
||||
<?php foreach($bagStockDetails as $bagStockIndex => $bagStock){ ?>
|
||||
<?php if ($bagStockIndex == 0): ?>
|
||||
<?php
|
||||
$startDate =DateTime::createFromFormat('Y-m-d', $bagStock['date'])->format('d-m-Y');
|
||||
?>
|
||||
<td class="celda_normal">
|
||||
<?= $startDate ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
<td style="display:none">
|
||||
<?= $bagStock['date']?>
|
||||
</td>
|
||||
<td style="display:none"
|
||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||
class="materialCode" ><?= $bagStock['materialCode']?>
|
||||
</td>
|
||||
|
||||
<td style="display:none"><?= $bagStock['customer']?></td>
|
||||
|
||||
<td class="celda_normal openingStock"
|
||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||
|
||||
<?php if ($groupedBagStockDetailsIndex == 0): ?>
|
||||
oninput="openingStockChange(this)"
|
||||
contenteditable="true"
|
||||
<?php endif; ?>
|
||||
|
||||
><?= $bagStock['opening']?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal receiptStock"
|
||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||
oninput="receiptStockChange(this)"
|
||||
contenteditable="true">
|
||||
<?= $bagStock['receipt']?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal usedStock"
|
||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||
oninput="usedStockChange(this)"
|
||||
contenteditable="true"><?= $bagStock['used']?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal balanceStock"
|
||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>">
|
||||
<?= $bagStock['balanceStock']?>
|
||||
</td>
|
||||
|
||||
<?php } ?>
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php } else{?>
|
||||
|
||||
<?php
|
||||
|
||||
$date = DateTime::createFromFormat('M-Y', $month);
|
||||
|
||||
$startDate = $date->modify('first day of this month')->format('Y-m-d');
|
||||
$endDate = $date->modify('last day of this month')->format('Y-m-d');
|
||||
|
||||
$datesInMonth = [];
|
||||
|
||||
|
||||
$period = new DatePeriod(
|
||||
new DateTime($startDate),
|
||||
new DateInterval('P1D'),
|
||||
(new DateTime($endDate))->modify('+1 day')
|
||||
);
|
||||
|
||||
foreach ($period as $day) {
|
||||
$datesInMonth[] = $day->format('Y-m-d');
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php foreach($datesInMonth as $datesInMonthIndex => $dateInMonth){ ?>
|
||||
<tr>
|
||||
<td class="celda_normal" >23-10-2024</td>
|
||||
<td style="display:none">23-10-2024</td>
|
||||
<td style="display:none"> material 1</td>
|
||||
<td style="display:none"> customer 1</td>
|
||||
<td class="celda_normal">472</td>
|
||||
<td class="celda_normal" >11212</td>
|
||||
<td class="celda_normal" contenteditable="true" >-</td>
|
||||
<td class="celda_normal" >472</td>
|
||||
<?php
|
||||
foreach($bagMaterials as $bagMaterialIndex => $bagMaterial){ ?>
|
||||
<!-- this will loop till materials present -->
|
||||
|
||||
<td style="display:none">23-10-2024</td>
|
||||
<td style="display:none"> material 2</td>
|
||||
<td style="display:none"> customer 2</td>
|
||||
<td class="celda_normal" >472</td>
|
||||
<td class="celda_normal">11212</td>
|
||||
<td class="celda_normal" contenteditable="true" >-</td>
|
||||
<td class="celda_normal">472</td>
|
||||
|
||||
<?php if ($bagMaterialIndex == 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?> <?=$bagMaterial['MaterialCode']?>">
|
||||
<?= $bagMaterial['MaterialCode']?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal" style="display:none">
|
||||
<?= $bagMaterial['customers']?>
|
||||
</td>
|
||||
|
||||
<td class="celda_normal openingStock"
|
||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||
<?php if($datesInMonthIndex == 0){ ?>
|
||||
|
||||
oninput="openingStockChange(this)"
|
||||
contenteditable="true"
|
||||
|
||||
<?php }?>
|
||||
>0</td>
|
||||
|
||||
<td class="celda_normal receiptStock"
|
||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||
oninput="receiptStockChange(this)"
|
||||
contenteditable="true">0</td>
|
||||
|
||||
<td class="celda_normal usedStock"
|
||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||
oninput="usedStockChange(this)"
|
||||
contenteditable="true">0</td>
|
||||
|
||||
<td class="celda_normal balanceStock"
|
||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||
>0</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php }?>
|
||||
|
||||
<tr>
|
||||
<td class="celda_normal" >24-10-2024</td>
|
||||
<td style="display:none">24-10-2024</td>
|
||||
<td style="display:none"> material 1</td>
|
||||
<td style="display:none"> customer 1</td>
|
||||
<td class="celda_normal" >472</td>
|
||||
<td class="celda_normal">11212</td>
|
||||
<td class="celda_normal" contenteditable="true" >-</td>
|
||||
<td class="celda_normal">472</td>
|
||||
|
||||
<td style="display:none">24-10-2024</td>
|
||||
<td style="display:none"> material 2</td>
|
||||
<td style="display:none"> customer 2</td>
|
||||
<td class="celda_normal" >472</td>
|
||||
<td class="celda_normal">11212</td>
|
||||
<td class="celda_normal" contenteditable="true" >-</td>
|
||||
<td class="celda_normal">472</td>
|
||||
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
@ -339,13 +440,15 @@
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
|
||||
$('#saveId').click(function () {
|
||||
|
||||
//table to json function
|
||||
|
||||
var updateBagStockDetails = tableToJSON();
|
||||
var updateBagStockDetails = tableToJson();
|
||||
|
||||
|
||||
alert('Updation may take a while, And we appreciate your patience..!!');
|
||||
|
||||
$('#loader').show();
|
||||
$.ajax({
|
||||
@ -358,18 +461,26 @@
|
||||
success: function (data) {
|
||||
if (data) {
|
||||
$('#loader').hide();
|
||||
|
||||
console.log(data);
|
||||
alert(data);
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
|
||||
alert("An error occurred while processing the request. Please try again.");
|
||||
console.error("Error Code:", xhr.status);
|
||||
console.error("Error Message:", error);
|
||||
console.error("Response Text:", xhr.responseText);
|
||||
},
|
||||
complete: function() {
|
||||
$('#loader').hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -389,7 +500,7 @@
|
||||
for (let i = 1; i < rowCells.length; i += 7) {
|
||||
const rowData = {
|
||||
date: rowCells.eq(i).text().trim(),
|
||||
material: rowCells.eq(i+1).text().trim(),
|
||||
materialCode: rowCells.eq(i+1).text().trim(),
|
||||
customer: rowCells.eq(i+2).text().trim(),
|
||||
opening: rowCells.eq(i+3).text().trim(),
|
||||
receipt: rowCells.eq(i+4).text().trim(),
|
||||
@ -404,8 +515,112 @@
|
||||
|
||||
return JSON.stringify(rows, null, 2);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
console.log(tableToJson());
|
||||
<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);
|
||||
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{
|
||||
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;
|
||||
|
||||
|
||||
</script>
|
||||
updateStockValue( date,materialCode,currentBalanceStock )
|
||||
|
||||
|
||||
} catch(error){
|
||||
|
||||
console.error("There is an error updating stock ..!!" + error);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 = $('#bagStockDetailsTableId');
|
||||
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;
|
||||
|
||||
// console.log( 'other date' , new Date(otherDate));
|
||||
// console.log('new balance stock' , currentBalanceStock)
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@ -528,7 +528,17 @@
|
||||
|
||||
alert(data);
|
||||
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
|
||||
alert("An error occurred while processing the request. Please try again.");
|
||||
console.error("Error Code:", xhr.status);
|
||||
console.error("Error Message:", error);
|
||||
console.error("Response Text:", xhr.responseText);
|
||||
},
|
||||
complete: function() {
|
||||
$('#loader').hide();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user