bag stock changes
This commit is contained in:
parent
3eef21a464
commit
e007d6a299
@ -281,6 +281,22 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
$this->global['pageTitle']='Bag Stock Details';
|
$this->global['pageTitle']='Bag Stock Details';
|
||||||
|
|
||||||
|
|
||||||
|
$previousMonth = DateTime::createFromFormat('Y-m', $month)->modify('-1 month')->format('Y-m');
|
||||||
|
$previousMonthStartDate = "$previousMonth-01";
|
||||||
|
$previousMonthEndDate = date("Y-m-t", strtotime($previousMonthStartDate));
|
||||||
|
$data['previousMonthBagStockDetails'] = $this->bagStockDetails_model
|
||||||
|
->select(['materialCode', 'date' ,'balanceStock'])
|
||||||
|
->distinct()
|
||||||
|
->where('date =', $previousMonthEndDate)
|
||||||
|
->groupBy(['materialCode','date'])
|
||||||
|
->orderBy('date','desc')
|
||||||
|
->orderBy('materialCode','asc')
|
||||||
|
->findAll();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$startDate = "$month-01";
|
$startDate = "$month-01";
|
||||||
$endDate = date("Y-m-t", strtotime($startDate));
|
$endDate = date("Y-m-t", strtotime($startDate));
|
||||||
$data['bagStockDetails'] = $this->bagStockDetails_model
|
$data['bagStockDetails'] = $this->bagStockDetails_model
|
||||||
|
|||||||
@ -218,8 +218,6 @@
|
|||||||
|
|
||||||
<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($bagMaterials as $bagMaterial){ ?>
|
||||||
<!-- 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">
|
||||||
@ -230,11 +228,12 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th class="celda_encabezado_general" colspan="1">Customer </th>
|
<th class="celda_encabezado_general" colspan="1"> Customer </th>
|
||||||
|
|
||||||
<?php foreach($bagMaterials as $bagMaterial){ ?>
|
<?php foreach($bagMaterials as $bagMaterial){ ?>
|
||||||
<!-- this will loop till materials present -->
|
<!-- this will loop till materials present -->
|
||||||
<th class="celda_encabezado_general" colspan="4" contenteditable="true">
|
<th class="celda_encabezado_general" colspan="4"
|
||||||
|
data-materialCode="<?=$bagMaterial['MaterialCode']?>"
|
||||||
|
oninput="customerChange(this)" contenteditable="true">
|
||||||
<?= $bagMaterial['customers']?>
|
<?= $bagMaterial['customers']?>
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
@ -268,11 +267,7 @@
|
|||||||
//dd($groupedBagStockDetails);
|
//dd($groupedBagStockDetails);
|
||||||
foreach($groupedBagStockDetails as $groupedBagStockDetailsIndex => $bagStockDetails){
|
foreach($groupedBagStockDetails as $groupedBagStockDetailsIndex => $bagStockDetails){
|
||||||
?>
|
?>
|
||||||
|
<tr>
|
||||||
<tr>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php foreach($bagStockDetails as $bagStockIndex => $bagStock){ ?>
|
<?php foreach($bagStockDetails as $bagStockIndex => $bagStock){ ?>
|
||||||
<?php if ($bagStockIndex == 0): ?>
|
<?php if ($bagStockIndex == 0): ?>
|
||||||
<?php
|
<?php
|
||||||
@ -291,7 +286,11 @@
|
|||||||
class="materialCode" ><?= $bagStock['materialCode']?>
|
class="materialCode" ><?= $bagStock['materialCode']?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td style="display:none"><?= $bagStock['customer']?></td>
|
<td style="display:none" class="celda_normal customer"
|
||||||
|
data-materialCode="<?=$bagStock['materialCode']?>"
|
||||||
|
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>">
|
||||||
|
<?= $bagStock['customer']?>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td class="celda_normal openingStock"
|
<td class="celda_normal openingStock"
|
||||||
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
data-id="<?=$bagStock['date']?> <?=$bagStock['materialCode']?>"
|
||||||
@ -323,88 +322,92 @@
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<?php } ?>
|
<?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>
|
|
||||||
<?php
|
|
||||||
foreach($bagMaterials as $bagMaterialIndex => $bagMaterial){ ?>
|
|
||||||
<!-- this will loop till materials present -->
|
|
||||||
|
|
||||||
<?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>
|
</tr>
|
||||||
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
<!-- this else condition work if groupedBagStockDetails is empty and creating new records
|
||||||
|
with initial values 0 for entire month -->
|
||||||
|
<?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>
|
||||||
|
<?php
|
||||||
|
foreach($bagMaterials as $bagMaterialIndex => $bagMaterial){ ?>
|
||||||
|
<!-- this will loop till materials present -->
|
||||||
|
|
||||||
|
<?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 customer" style="display:none"
|
||||||
|
data-materialCode="<?=$bagMaterial['MaterialCode']?>"
|
||||||
|
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>">
|
||||||
|
<?= $bagMaterial['customers']?>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="celda_normal openingStock"
|
||||||
|
data-id="<?=$dateInMonth?> <?=$bagMaterial['MaterialCode']?>"
|
||||||
|
<?php if($datesInMonthIndex == 0){ ?>
|
||||||
|
|
||||||
|
oninput="openingStockChange(this)"
|
||||||
|
contenteditable="true"
|
||||||
|
|
||||||
|
<?php }?>
|
||||||
|
><?= $data['previousMonthBagStockDetails'][$bagMaterialIndex]['balanceStock']??'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 }?>
|
<?php }?>
|
||||||
|
|
||||||
|
|
||||||
@ -490,13 +493,15 @@
|
|||||||
const table = $('#bagStockDetailsTableId');
|
const table = $('#bagStockDetailsTableId');
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
||||||
|
//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
|
||||||
|
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(),
|
||||||
@ -621,6 +626,19 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateCustomerForMaterial(){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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