bag stock module table to json conversion done
This commit is contained in:
parent
0d1d94ecf5
commit
06bc75aa2f
@ -208,85 +208,105 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
<table id="data-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th rowspan="4" colspan="1">
|
|
||||||
Material <br><br> Customer <br><br> Date
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<?php foreach ($materials as $material) { ?>
|
|
||||||
<th colspan="4"><?php echo ($material) ?></th>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<?php foreach ($materials as $material) { ?>
|
|
||||||
<th colspan="4" contenteditable="true">
|
|
||||||
customers
|
|
||||||
</th>
|
|
||||||
<?php } ?>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<?php foreach ($materials as $material) { ?>
|
|
||||||
<th>info1</th>
|
|
||||||
<th>info2</th>
|
|
||||||
<th>info3</th>
|
|
||||||
<th>info4</th>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>23-10-2024</td>
|
|
||||||
<td>472</td>
|
|
||||||
<td></td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>472</td>
|
|
||||||
|
|
||||||
|
|
||||||
<td>472</td>
|
|
||||||
<td></td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>472</td>
|
|
||||||
</tr>
|
|
||||||
<!-- Add more rows as needed -->
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<!-- Add table-responsive for horizontal scroll -->
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="bagStockDetailsTableId" class="fht-table table-striped"
|
<table id="bagStockDetailsTableId" class="fht-table table-striped"
|
||||||
style="font-size: small;">
|
style="font-size: small;">
|
||||||
<thead>
|
|
||||||
|
<thead class="celda_encabezado_general" style="padding: 10px;">
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="celda_encabezado_general" style="padding: 10px;">S.NO </th>
|
|
||||||
<th class="celda_encabezado_general" style="padding: 10px;">IGR No </th>
|
<th colspan="1">material </th>
|
||||||
|
|
||||||
|
<th colspan="4">material 1</th>
|
||||||
|
|
||||||
|
<th colspan="4">material 2</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th colspan="1">Customer </th>
|
||||||
|
|
||||||
|
<th colspan="4" contenteditable="true">
|
||||||
|
<?php echo $customer??'Customer' ?>
|
||||||
|
</th>
|
||||||
|
|
||||||
|
<th colspan="4" contenteditable="true">
|
||||||
|
<?php echo $customer??'Customer2' ?>
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th colspan="1">Date </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>
|
||||||
|
|
||||||
|
<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>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody style="background-color: #fff;">
|
<tbody style="background-color: #fff;" >
|
||||||
|
|
||||||
<tr id="1">
|
|
||||||
<td width="45" height="45" class="celda_normal">1</td>
|
<tr>
|
||||||
<td class="celda_normal">
|
<td class="celda_normal" >23-10-2024</td>
|
||||||
data 2
|
<td style="display:none">23-10-2024</td>
|
||||||
</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">-</td>
|
||||||
|
<td class="celda_normal">472</td>
|
||||||
|
|
||||||
|
<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">-</td>
|
||||||
|
<td class="celda_normal">472</td>
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td class="celda_normal" >23-10-2024</td>
|
||||||
|
<td style="display:none">Date</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">-</td>
|
||||||
|
<td class="celda_normal">472</td>
|
||||||
|
|
||||||
|
<td style="display:none">Date</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">-</td>
|
||||||
|
<td class="celda_normal">472</td>
|
||||||
|
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div><!-- End table-responsive -->
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12 text-right">
|
<div class="col-md-12 text-right">
|
||||||
@ -349,8 +369,45 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function tableToJson() {
|
||||||
|
const table = $('#bagStockDetailsTableId');
|
||||||
|
const rows = [];
|
||||||
|
|
||||||
|
|
||||||
|
table.find('tbody tr').each(function() {
|
||||||
|
const rowCells = $(this).find('td');
|
||||||
|
const date = rowCells.eq(0).text().trim();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (let i = 1; i < rowCells.length; i += 7) {
|
||||||
|
const rowData = {
|
||||||
|
date: rowCells.eq(i).text().trim(),
|
||||||
|
material: 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(),
|
||||||
|
used: rowCells.eq(i + 5).text().trim(),
|
||||||
|
balanceStock: rowCells.eq(i + 6).text().trim()
|
||||||
|
};
|
||||||
|
|
||||||
|
rows.push(rowData);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return JSON.stringify(rows, null, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(tableToJson());
|
||||||
|
|
||||||
|
$('#saveId').on('click', function() {
|
||||||
|
const jsonResult = tableToJson();
|
||||||
|
console.log(jsonResult);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user