resin stock finished
This commit is contained in:
parent
1126731c5a
commit
7975bf5739
@ -628,6 +628,10 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
$updateResinStockDetailsData = json_decode($postData['updateResinStockDetails'], true);
|
$updateResinStockDetailsData = json_decode($postData['updateResinStockDetails'], true);
|
||||||
|
|
||||||
|
$updates = [];
|
||||||
|
|
||||||
|
$inserts = [];
|
||||||
|
|
||||||
foreach($updateResinStockDetailsData as $data){
|
foreach($updateResinStockDetailsData as $data){
|
||||||
|
|
||||||
$date = $data['date'];
|
$date = $data['date'];
|
||||||
@ -650,20 +654,31 @@ class StockController extends BaseController
|
|||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
|
||||||
if(!empty($resultExists)){
|
if(empty($resultExists)){
|
||||||
|
$inserts[] = $dbData;
|
||||||
$updated = $this->resinStockDetails_model
|
|
||||||
->where('date',$date)
|
|
||||||
->where('materialCode',$materialCode)
|
|
||||||
->set($dbData)
|
|
||||||
->update();
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$inserted = $this->resinStockDetails_model->insert($dbData);
|
$updates[] = $dbData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!empty($inserts)) {
|
||||||
|
$this->resinStockDetails_model->insertBatch($inserts);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($updates)) {
|
||||||
|
|
||||||
|
$updateResult = $this->resinStockDetails_model->updateBatch($updates, 'id');
|
||||||
|
|
||||||
|
if ($updateResult === FALSE) {
|
||||||
|
echo "Error during update";
|
||||||
|
} else {
|
||||||
|
echo "Data Updated Successfully";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
echo "Data Saved Successfully";
|
echo "Data Saved Successfully";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -173,7 +173,7 @@
|
|||||||
<ol class="breadcrumb m-0">
|
<ol class="breadcrumb m-0">
|
||||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Stocks</a></li>
|
<li class="breadcrumb-item"><a href="javascript: void(0);">Stocks</a></li>
|
||||||
<li class="breadcrumb-item active">
|
<li class="breadcrumb-item active">
|
||||||
<h4 class="page-title">Bag Stock Details </h4>
|
<h4 class="page-title">Resin Stock Details </h4>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
@ -193,7 +193,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
|
|
||||||
<form action="<?= base_url('bagStockDetails'); ?>" method="post">
|
<form action="<?= base_url('resinStockDetails'); ?>" method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
@ -210,7 +210,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="bagStockDetailsTableId" 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;">
|
||||||
|
|
||||||
@ -218,34 +218,21 @@
|
|||||||
|
|
||||||
<th class="celda_encabezado_general" colspan="1">material </th>
|
<th class="celda_encabezado_general" colspan="1">material </th>
|
||||||
|
|
||||||
<?php foreach($bagMaterials as $bagMaterial){ ?>
|
<?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">
|
||||||
<?= $bagMaterial['MaterialName']?>
|
<?= $resinMaterial['MaterialName']?>
|
||||||
<!-- (<?= $bagMaterial['MaterialCode']?>) -->
|
<!-- (<?= $resinMaterial['MaterialCode']?>) -->
|
||||||
</th>
|
</th>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th class="celda_encabezado_general" colspan="1"> Customer </th>
|
|
||||||
<?php foreach($bagMaterials as $bagMaterial){ ?>
|
|
||||||
<!-- this will loop till materials present -->
|
|
||||||
<th class="celda_encabezado_general" colspan="4"
|
|
||||||
data-materialCode="<?=$bagMaterial['MaterialCode']?>"
|
|
||||||
oninput="customerChange(this)" contenteditable="true">
|
|
||||||
<?= $bagMaterial['customers']?>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<?php } ?>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="celda_encabezado_general" colspan="1">Date </th>
|
<th class="celda_encabezado_general" colspan="1">Date </th>
|
||||||
|
|
||||||
<?php foreach($bagMaterials as $bagMaterial){ ?>
|
<?php foreach($resinMaterials as $resinMaterial){ ?>
|
||||||
<!-- this will loop till materials present -->
|
<!-- this will loop till materials present -->
|
||||||
<th class="celda_encabezado_general" style="display:none">Date</th>
|
<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"> material</th>
|
||||||
@ -262,16 +249,16 @@
|
|||||||
|
|
||||||
<tbody style="background-color: #fff;" >
|
<tbody style="background-color: #fff;" >
|
||||||
|
|
||||||
<?php if(!empty($groupedBagStockDetails))
|
<?php if(!empty($groupedResinStockDetails))
|
||||||
{
|
{
|
||||||
//dd($groupedBagStockDetails);
|
//dd($groupedBagStockDetails);
|
||||||
foreach($groupedBagStockDetails as $groupedBagStockDetailsIndex => $bagStockDetails){
|
foreach($groupedResinStockDetails as $groupedResinStockDetailsIndex => $resinStockDetails){
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<?php foreach($bagStockDetails as $bagStockIndex => $bagStock){ ?>
|
<?php foreach($resinStockDetails as $resinStockIndex => $resinStock){ ?>
|
||||||
<?php if ($bagStockIndex == 0): ?>
|
<?php if ($resinStockIndex == 0): ?>
|
||||||
<?php
|
<?php
|
||||||
$startDate =DateTime::createFromFormat('Y-m-d', $bagStock['date'])->format('d-m-Y');
|
$startDate =DateTime::createFromFormat('Y-m-d', $resinStock['date'])->format('d-m-Y');
|
||||||
?>
|
?>
|
||||||
<td class="celda_normal">
|
<td class="celda_normal">
|
||||||
<?= $startDate ?>
|
<?= $startDate ?>
|
||||||
@ -279,46 +266,46 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<td style="display:none">
|
<td style="display:none">
|
||||||
<?= $bagStock['date']?>
|
<?= $resinStock['date']?>
|
||||||
</td>
|
</td>
|
||||||
<td style="display:none"
|
<td style="display:none"
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
|
||||||
class="materialCode" ><?= $bagStock['materialCode']?>
|
class="materialCode" ><?= $resinStock['materialCode']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td style="display:none" class="celda_normal customer"
|
<td style="display:none" class="celda_normal customer"
|
||||||
data-materialCode="<?=$bagStock['materialCode']?>"
|
data-materialCode="<?=$resinStock['materialCode']?>"
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>">
|
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>">
|
||||||
<?= $bagStock['customer']?>
|
<?= $resinStock['customer']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal openingStock"
|
<td class="celda_normal openingStock"
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
|
||||||
|
|
||||||
<?php if ($groupedBagStockDetailsIndex == 0): ?>
|
<?php if ($groupedResinStockDetailsIndex == 0): ?>
|
||||||
oninput="openingStockChange(this)"
|
oninput="openingStockChange(this)"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
><?= $bagStock['opening']?>
|
><?= $resinStock['opening']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal receiptStock"
|
<td class="celda_normal receiptStock"
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
|
||||||
oninput="receiptStockChange(this)"
|
oninput="receiptStockChange(this)"
|
||||||
contenteditable="true">
|
contenteditable="true">
|
||||||
<?= $bagStock['receipt']?>
|
<?= $resinStock['receipt']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal usedStock"
|
<td class="celda_normal usedStock"
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
|
||||||
oninput="usedStockChange(this)"
|
oninput="usedStockChange(this)"
|
||||||
contenteditable="true"><?= $bagStock['used']?>
|
contenteditable="true"><?= $resinStock['used']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal balanceStock"
|
<td class="celda_normal balanceStock"
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>">
|
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>">
|
||||||
<?= $bagStock['balanceStock']?>
|
<?= $resinStock['balanceStock']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -355,10 +342,10 @@
|
|||||||
<?php foreach($datesInMonth as $datesInMonthIndex => $dateInMonth){ ?>
|
<?php foreach($datesInMonth as $datesInMonthIndex => $dateInMonth){ ?>
|
||||||
<tr>
|
<tr>
|
||||||
<?php
|
<?php
|
||||||
foreach($bagMaterials as $bagMaterialIndex => $bagMaterial){ ?>
|
foreach($resinMaterials as $resinMaterialIndex => $resinMaterial){ ?>
|
||||||
<!-- this will loop till materials present -->
|
<!-- this will loop till materials present -->
|
||||||
|
|
||||||
<?php if ($bagMaterialIndex == 0): ?>
|
<?php if ($resinMaterialIndex == 0): ?>
|
||||||
<?php
|
<?php
|
||||||
$startDate =DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
|
$startDate =DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
|
||||||
?>
|
?>
|
||||||
@ -372,39 +359,39 @@
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal" style="display:none"
|
<td class="celda_normal" style="display:none"
|
||||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>">
|
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>">
|
||||||
<?= $bagMaterial['MaterialCode']?>
|
<?= $resinMaterial['MaterialCode']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal customer" style="display:none"
|
<td class="celda_normal customer" style="display:none"
|
||||||
data-materialCode="<?=$bagMaterial['MaterialCode']?>"
|
data-materialCode="<?=$resinMaterial['MaterialCode']?>"
|
||||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>">
|
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>">
|
||||||
<?= $bagMaterial['customers']?>
|
<?= $resinMaterial['customers']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal openingStock"
|
<td class="celda_normal openingStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
||||||
<?php if($datesInMonthIndex == 0){ ?>
|
<?php if($datesInMonthIndex == 0){ ?>
|
||||||
|
|
||||||
oninput="openingStockChange(this)"
|
oninput="openingStockChange(this)"
|
||||||
contenteditable="true"
|
contenteditable="true"
|
||||||
|
|
||||||
<?php }?>
|
<?php }?>
|
||||||
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?></td>
|
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
|
||||||
|
|
||||||
<td class="celda_normal receiptStock"
|
<td class="celda_normal receiptStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
||||||
oninput="receiptStockChange(this)"
|
oninput="receiptStockChange(this)"
|
||||||
contenteditable="true">0</td>
|
contenteditable="true">0</td>
|
||||||
|
|
||||||
<td class="celda_normal usedStock"
|
<td class="celda_normal usedStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
||||||
oninput="usedStockChange(this)"
|
oninput="usedStockChange(this)"
|
||||||
contenteditable="true">0</td>
|
contenteditable="true">0</td>
|
||||||
|
|
||||||
<td class="celda_normal balanceStock"
|
<td class="celda_normal balanceStock"
|
||||||
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
|
||||||
><?= $previousMonthBagStockDetails[$bagMaterialIndex]['balanceStock']??'0' ?></td>
|
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -448,7 +435,7 @@
|
|||||||
|
|
||||||
//table to json function
|
//table to json function
|
||||||
|
|
||||||
var updateBagStockDetails = 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..!!');
|
||||||
@ -456,10 +443,10 @@
|
|||||||
$('#loader').show();
|
$('#loader').show();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: {
|
data: {
|
||||||
updateBagStockDetails
|
updateResinStockDetails
|
||||||
},
|
},
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?php echo base_url() ?>updateBagStockDetails",
|
url: "<?php echo base_url() ?>updateResinStockDetails",
|
||||||
|
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -490,7 +477,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
function tableToJson() {
|
function tableToJson() {
|
||||||
const table = $('#bagStockDetailsTableId');
|
const table = $('#resinStockDetailsTableId');
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
||||||
//this table to json is customized for bagstock not for all
|
//this table to json is customized for bagstock not for all
|
||||||
@ -594,7 +581,7 @@
|
|||||||
|
|
||||||
function updateStockValue( date, materialCode, currentBalanceStock ){
|
function updateStockValue( date, materialCode, currentBalanceStock ){
|
||||||
|
|
||||||
const table = $('#bagStockDetailsTableId');
|
const table = $('#resinStockDetailsTableId');
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
||||||
table.find('tbody tr').each(function() {
|
table.find('tbody tr').each(function() {
|
||||||
@ -619,22 +606,11 @@
|
|||||||
|
|
||||||
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
document.querySelector(`td.balanceStock[data-id="${dataId}"]`).innerText=currentBalanceStock;
|
||||||
|
|
||||||
// console.log( 'other date' , new Date(otherDate));
|
|
||||||
// console.log('new balance stock' , currentBalanceStock)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function customerChange(thElement){
|
|
||||||
let materialCode = thElement.getAttribute('data-materialCode');
|
|
||||||
let newCustomerValue = thElement.innerText;
|
|
||||||
let matchingCustomerData = document.querySelectorAll(`td.customer[data-materialCode="${materialCode}"]`);
|
|
||||||
matchingCustomerData.forEach((element,index)=>{
|
|
||||||
element.innerText=newCustomerValue;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user