stock changes 18-04-2025

This commit is contained in:
vadivelJ96 2025-04-18 18:16:52 +05:30
parent 09c70db2be
commit 5973000586
12 changed files with 491 additions and 259 deletions

View File

@ -1011,7 +1011,7 @@ class StockController extends BaseController
->join( ->join(
'(SELECT date, '(SELECT date,
SUM(totalGasconsumption) AS coatingMachineGasconsumption, SUM(totalGasconsumption) AS coatingMachineGasconsumption,
SUM(totalCoatingSandInKg) / 1000 AS coatedSand SUM(totalCoatingSandInKg) AS coatedSand
FROM t_coatingmachinedetails FROM t_coatingmachinedetails
WHERE is_active = 1 WHERE is_active = 1
AND date >= ' . $this->db->escape($startDate) . ' AND date >= ' . $this->db->escape($startDate) . '
@ -1369,27 +1369,49 @@ class StockController extends BaseController
//possible if no filter applied at all...!!! //possible if no filter applied at all...!!!
if(empty($existingCustomMachineCodes)){ if(empty($existingCustomMachineCodes)){
//no filter applied at all just present all active material codes
$existingCustomMachineCodes = $this ->factoryMachine_model
->getAllActiveDieselMachines() ;
//add this active products in monthwisemachine stock table //no filter applied at all just present previous month material codes
$inserts = [];
foreach($existingCustomMachineCodes as $index => $customisedMachineCode){ $previousMonth = date('Y-m-01', strtotime('-1 month', strtotime("$month-01")));
$previousMonthCustomMachineCodes = $this->monthWiseMachineInStockModel
->select('machine_id')
->where('date',"$previousMonth")
->where('machine_category','diesel')
->get()
->getResultArray();
if(!empty($previousMonthCustomMachineCodes)){
$existingCustomMachineCodes = $this->factoryMachine_model
->getSelectedDieselMachines(array_column($previousMonthCustomMachineCodes, 'machine_id'));
}else{
// inserting all active if no previous month present
$existingCustomMachineCodes = $this ->factoryMachine_model
->getAllActiveDieselMachines();
//add this active products in monthwisemachine stock table
$inserts = [];
foreach($existingCustomMachineCodes as $index => $customisedMachineCode){
$inserts [] = [
'date' => "$month-01",
'machine_category' => "diesel",
'machine_id' => $customisedMachineCode['id']
];
}
if(!empty($inserts)){
//insert all the latest applied filter
$this->monthWiseMachineInStockModel->insertBatch($inserts);
}
$inserts [] = [
'date' => "$month-01",
'machine_category' => "diesel",
'machine_id' => $customisedMachineCode['id']
];
}
if(!empty($inserts)){
//insert all the latest applied filter
$this->monthWiseMachineInStockModel->insertBatch($inserts);
} }
}else{ }else{
//if filter present,get that material codes //if filter present,get that material codes
$existingCustomMachineCodes = $this->factoryMachine_model $existingCustomMachineCodes = $this->factoryMachine_model
@ -1816,7 +1838,24 @@ class StockController extends BaseController
//possible if no filter applied at all...!!! //possible if no filter applied at all...!!!
if(empty($existingCustomMachineCodes) ){ if(empty($existingCustomMachineCodes) ){
//no filter applied at all just present all active material codes
//no filter applied at all just present previous month material codes
$previousMonth = date('Y-m-01', strtotime('-1 month', strtotime("$month-01")));
$previousMonthCustomMachineCodes = $this->monthWiseMachineInStockModel
->select('machine_id')
->where('date',"$previousMonth")
->where('machine_category','electric')
->get()
->getResultArray();
if(!empty($previousMonthCustomMachineCodes)){
$existingCustomMachineCodes = $this->factoryMachine_model
->getSelectedDieselMachines(array_column($previousMonthCustomMachineCodes, 'machine_id'));
}else{
// inserting all active if no previous month present
$existingCustomMachineCodes = $this->factoryMachine_model $existingCustomMachineCodes = $this->factoryMachine_model
->getAllActiveElectricMachines(); ->getAllActiveElectricMachines();
@ -1839,7 +1878,7 @@ class StockController extends BaseController
$this->monthWiseMachineInStockModel->insertBatch($inserts); $this->monthWiseMachineInStockModel->insertBatch($inserts);
} }
}
}else{ }else{
@ -2372,11 +2411,25 @@ class StockController extends BaseController
//possible if no filter applied at all...!!! //possible if no filter applied at all...!!!
if(empty($existingCustomMaterialCodes)){ if(empty($existingCustomMaterialCodes)){
//no filter applied at all just present all active material codes //no filter applied at all just present previous month material codes
$existingCustomMaterialCodes = $this->rawmaterialdetails_model->getAllResinMaterialCode();
$previousMonth = date('Y-m-01', strtotime('-1 month', strtotime("$month-01")));
$previousMonthCustomMachineCodes = $this->monthWiseMaterialInStockModel
->select('materialCode')
->where('date',"$previousMonth")
->where('stock_category','resin')
->get()
->getResultArray();
if(!empty($previousMonthCustomMachineCodes)){
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
->getSelectedResinMaterialCode(array_column($previousMonthCustomMachineCodes, 'materialCode'));
}else{
// inserting all active if no previous month present
$existingCustomMaterialCodes = $this->rawmaterialdetails_model->getAllResinMaterialCode();
//if no filter already exists or removed current one , just add current filter for that month ....!!
$inserts = []; $inserts = [];
foreach($existingCustomMaterialCodes as $index => $customisedMaterialCode){ foreach($existingCustomMaterialCodes as $index => $customisedMaterialCode){
@ -2394,6 +2447,7 @@ class StockController extends BaseController
$this->monthWiseMaterialInStockModel->insertBatch($inserts) ; $this->monthWiseMaterialInStockModel->insertBatch($inserts) ;
} }
}
}else{ }else{
@ -2787,11 +2841,28 @@ class StockController extends BaseController
//possible if no filter applied at all...!!! //possible if no filter applied at all...!!!
if(empty($existingCustomMaterialCodes)){ if(empty($existingCustomMaterialCodes)){
//no filter applied at all just present all active material codes
//no filter applied at all just present previous month material codes
$previousMonth = date('Y-m-01', strtotime('-1 month', strtotime("$month-01")));
$previousMonthCustomMachineCodes = $this->monthWiseMaterialInStockModel
->select('materialCode')
->where('date',"$previousMonth")
->where('stock_category','packing_material')
->get()
->getResultArray();
if(!empty($previousMonthCustomMachineCodes)){
$existingCustomMaterialCodes = $this->rawmaterialdetails_model
->getSelectedResinMaterialCode(array_column($previousMonthCustomMachineCodes, 'materialCode'));
}else{
// inserting all active if no previous month present
$existingCustomMaterialCodes = $this->rawmaterialdetails_model $existingCustomMaterialCodes = $this->rawmaterialdetails_model
->getAllBagMaterialCode(); ->getAllBagMaterialCode();
//if no filter already exists or removed current one , just add current filter for that month ....!! //if no filter already exists or removed current one , just add current filter for that month ....!!
$inserts = []; $inserts = [];
foreach($existingCustomMaterialCodes as $index => $customisedMaterialCode){ foreach($existingCustomMaterialCodes as $index => $customisedMaterialCode){
@ -2809,6 +2880,8 @@ class StockController extends BaseController
$this->monthWiseMaterialInStockModel->insertBatch($inserts) ; $this->monthWiseMaterialInStockModel->insertBatch($inserts) ;
} }
}
}else{ }else{
//if filter present,get that material codes //if filter present,get that material codes
@ -2949,17 +3022,60 @@ 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 as '' empty string
// Collect all material codes to query in one go
$materialCodes = array_column($bagMaterials, 'MaterialCode');
// Get current month customers in bulk
$currentCustomers = $this->bagStockDetails_model
->select('materialCode, customer')
->where('date >=', $startDate)
->where('date <=', $endDate)
->whereIn('materialCode', $materialCodes)
->findAll();
// Map them as materialCode => customer
$currentCustomerMap = [];
foreach ($currentCustomers as $row) {
$currentCustomerMap[$row['materialCode']] = $row['customer'];
}
// Get previous month customers in bulk
$previousStartDate = date('Y-m-01', strtotime('-1 month', strtotime($startDate)));
$previousEndDate = date('Y-m-t', strtotime('-1 month', strtotime($startDate)));
$previousCustomers = $this->bagStockDetails_model
->select('materialCode, customer')
->where('date >=', $previousStartDate)
->where('date <=', $previousEndDate)
->whereIn('materialCode', $materialCodes)
->findAll();
// Map them as materialCode => customer
$previousCustomerMap = [];
foreach ($previousCustomers as $row) {
$previousCustomerMap[$row['materialCode']] = $row['customer'];
}
// Now merge this data efficiently
foreach ($bagMaterials as $key => $bagMaterial) { foreach ($bagMaterials as $key => $bagMaterial) {
$materialCode = $bagMaterial['MaterialCode']; $materialCode = $bagMaterial['MaterialCode'];
$bagMaterials[$key]['customers'] = $this->bagStockDetails_model
->select('customer') // First, check in current month
->where('date >=', $startDate) $customer = $currentCustomerMap[$materialCode] ?? '';
->where('date <=', $endDate)
->where('materialCode', $materialCode) // If not found or empty/blank, check in previous month
->first()['customer'] ?? ''; if (trim($customer) === '') {
$customer = $previousCustomerMap[$materialCode] ?? '';
}
// Set final customer value
$bagMaterials[$key]['customers'] = $customer;
} }
// Sort each date's materials based on the custom order to set table header th // Sort each date's materials based on the custom order to set table header th
if (!empty($customisedMaterialCodes)) { if (!empty($customisedMaterialCodes)) {
@ -2984,6 +3100,8 @@ class StockController extends BaseController
} }
// dd($bagMaterials);
$bagMaterialcount = count($bagMaterials); $bagMaterialcount = count($bagMaterials);

View File

@ -335,7 +335,11 @@
</div> </div>
</div> </div>
<?php if (session()->getFlashdata('error')): ?> <?php
use PhpOffice\PhpSpreadsheet\Reader\Xml\Style\NumberFormat;
if (session()->getFlashdata('error')): ?>
<div class="alert alert-danger"> <div class="alert alert-danger">
<?= session()->getFlashdata('error'); ?> <?= session()->getFlashdata('error'); ?>
</div> </div>
@ -999,15 +1003,15 @@
<!-- td:eq(6) --> <!-- td:eq(6) -->
<td class="celda_normal"><?php echo $record['grade'] ?? ' ' ?></td> <td class="celda_normal"><?php echo $record['grade'] ?? ' ' ?></td>
<!-- td:eq(7) --> <!-- td:eq(7) -->
<td class="celda_normal"><?php echo $record['totalCoating'] ?></td> <td class="celda_normal"><?php echo number_format((float)$record['totalCoating'],2) ?></td>
<!-- td:eq(8) --> <!-- td:eq(8) -->
<td class="celda_normal"><?php echo $record['totalCoatingSandInKg'] ?></td> <td class="celda_normal"><?php echo number_format((float)$record['totalCoatingSandInKg'],2) ?></td>
<!-- td:eq(9) --> <!-- td:eq(9) -->
<td class="celda_normal"><?php echo $record['totalGasConsumption'] ?></td> <td class="celda_normal"><?php echo number_format((float)$record['totalGasConsumption'],2) ?></td>
<!-- td:eq(10) --> <!-- td:eq(10) -->
<td class="celda_normal"><?php echo round($record['perHourGasConsumption']) ?? '' ?></td> <td class="celda_normal"><?php echo number_format($record['perHourGasConsumption'], 2) ?? '' ?></td>
<!-- td:eq(11) --> <!-- td:eq(11) -->
<td class="celda_normal"><?php echo round($record['perHourCoatingSandQTY']) ?? '' ?></td> <td class="celda_normal"><?php echo number_format($record['perHourCoatingSandQTY'] , 2) ?? '' ?></td>
<!-- td:eq(12) --> <!-- td:eq(12) -->
<!-- edit and download option..!! --> <!-- edit and download option..!! -->
<td class="celda_normal"> <td class="celda_normal">
@ -1077,11 +1081,11 @@
<td class="celda_normal "> <?= $summary['totalMachineRunningHrs'] ?></td> <td class="celda_normal "> <?= $summary['totalMachineRunningHrs'] ?></td>
<td class="celda_normal "> - </td> <td class="celda_normal "> - </td>
<td class="celda_normal "> - </td> <td class="celda_normal "> - </td>
<td class="celda_normal "><?= $summary['totalCoating'] ?></td> <td class="celda_normal "><?= number_format($summary['totalCoating'],2) ?></td>
<td class="celda_normal "><?= $summary['totalCoatingSandInKg'] ?></td> <td class="celda_normal "><?= number_format($summary['totalCoatingSandInKg'],2) ?></td>
<td class="celda_normal "><?= $summary['totalGasConsumption'] ?></td> <td class="celda_normal "><?= number_format($summary['totalGasConsumption'],2) ?></td>
<td class="celda_normal "><?= round($summary['totalGasConsumption'] / $summary['totalMachineRunningHrs']) ?> (A)</td> <td class="celda_normal "><?= number_format($summary['totalGasConsumption'] / $summary['totalMachineRunningHrs'] , 2) ?> (A)</td>
<td class="celda_normal "><?= round($summary['totalCoatingSandInKg'] / $summary['totalMachineRunningHrs']) ?> (A)</td> <td class="celda_normal "><?= number_format($summary['totalCoatingSandInKg'] / $summary['totalMachineRunningHrs'], 2) ?> (A)</td>
</tr> </tr>
</tfoot> </tfoot>
@ -1715,8 +1719,10 @@
viewMode: 'months', viewMode: 'months',
minViewMode: 'months', minViewMode: 'months',
autoclose: true, autoclose: true,
orientation: 'bottom' orientation: 'bottom',
}) startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
});
}) })

View File

@ -272,6 +272,11 @@
.card { .card {
margin-bottom: 5px; margin-bottom: 5px;
} }
.hidden-row {
display: none;
}
</style> </style>
@ -609,13 +614,14 @@ foreach ($period as $day) {
foreach ($groupedBagStockDetails as $groupedBagStockDetailsIndex => $bagStockDetails) { foreach ($groupedBagStockDetails as $groupedBagStockDetailsIndex => $bagStockDetails) {
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $bagStockDetails[0]['date'])->format('d-m-Y');
?> ?>
<tr <tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $bagStockDetails[0]['date'])->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
@ -730,124 +736,128 @@ foreach ($period as $day) {
<!-- this else condition work if groupedBagStockDetails is empty and creating new records <!-- this else condition work if groupedBagStockDetails is empty and creating new records
with initial values 0 for entire month --> with initial values 0 for entire month -->
<?php } else { <?php } else {
// dd($bagMaterials); // dd($bagMaterials);
// dd($previousMonthBagStockDetails); // dd($previousMonthBagStockDetails);
?> ?>
<?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { ?>
<tr
<?php
<?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
$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', $dateInMonth)->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"';
}
?>> ?>
<?php
foreach ($bagMaterials as $bagMaterialIndex => $bagMaterial) { ?> <tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<!-- this will loop till materials present -->
<?php if ($bagMaterialIndex == 0): ?>
<?php <?php
$startDate = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
?> if ($dateInMonthDmYFormat === $currentDate) {
<td class="celda_normal"> echo 'style="background: #cef0ad;"';
<?= $startDate ?> }
?>>
<?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 } ?>>
<?php
foreach ($previousMonthBagStockDetails as $index => $previousMonthBagStockDetail) {
if ($previousMonthBagStockDetail['materialCode'] == $bagMaterial['MaterialCode']) {
echo $previousMonthBagStockDetail['balanceStock'];
break;
}
}
?>
</td>
<td class="celda_normal receiptStock"
data-id="<?= $dateInMonth ?> <?= $bagMaterial['MaterialCode'] ?>"
oninput="receiptStockChange(this)"
contenteditable="true"> <?= " " ?> </td>
<td class="celda_normal usedStock"
data-id="<?= $dateInMonth ?> <?= $bagMaterial['MaterialCode'] ?>"
oninput="usedStockChange(this)" contenteditable="true"> <?= " " ?> </td>
<td class="celda_normal balanceStock"
data-id="<?= $dateInMonth ?> <?= $bagMaterial['MaterialCode'] ?>">
<?php
foreach ($previousMonthBagStockDetails as $index => $previousMonthBagStockDetail) {
if ($previousMonthBagStockDetail['materialCode'] == $bagMaterial['MaterialCode']) {
echo $previousMonthBagStockDetail['balanceStock'];
break;
}
}
?>
</td>
<?php } ?>
</tr>
<?php } ?>
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td> </td>
<?php endif; ?>
<td class="celda_normal" style="display:none"> <?php foreach ($bagMaterials as $each) {
<?= $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 } ?>>
<?php
foreach ($previousMonthBagStockDetails as $index => $previousMonthBagStockDetail) {
if ($previousMonthBagStockDetail['materialCode'] == $bagMaterial['MaterialCode']) {
echo $previousMonthBagStockDetail['balanceStock'];
break;
}
}
?> ?>
</td>
<td class="celda_normal receiptStock" <td class="celda_normal openingStock"
data-id="<?= $dateInMonth ?> <?= $bagMaterial['MaterialCode'] ?>" data-id="footer <?=$each['MaterialCode']?>"></td>
oninput="receiptStockChange(this)" <td class="celda_normal receiptStock"
contenteditable="true"> <?= " " ?> </td> data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal usedStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal balanceStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal usedStock" <?php } ?>
data-id="<?= $dateInMonth ?> <?= $bagMaterial['MaterialCode'] ?>"
oninput="usedStockChange(this)" contenteditable="true"> <?= " " ?> </td>
<td class="celda_normal balanceStock" </tr>
data-id="<?= $dateInMonth ?> <?= $bagMaterial['MaterialCode'] ?>"> </tfoot>
<?php
foreach ($previousMonthBagStockDetails as $index => $previousMonthBagStockDetail) {
if ($previousMonthBagStockDetail['materialCode'] == $bagMaterial['MaterialCode']) {
echo $previousMonthBagStockDetail['balanceStock'];
break;
}
}
?>
</td>
<?php } ?>
</tr>
<?php } ?>
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<?php foreach ($bagMaterials as $each) {
?>
<td class="celda_normal openingStock" <?php } ?>
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal receiptStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal usedStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<td class="celda_normal balanceStock"
data-id="footer <?=$each['MaterialCode']?>"></td>
<?php } ?>
</tr>
</tfoot>
<?php } ?>
</tbody> </tbody>
@ -1435,11 +1445,14 @@ foreach ($period as $day) {
}) })
$('#month').datepicker({ $('#month').datepicker({
format: "M-yyyy", // Format as "Jan-2025" format: 'M-yyyy',
minViewMode: 1, // Month-Year Picker viewMode: 'months',
autoclose: true, minViewMode: 'months',
todayHighlight: true autoclose: true,
}).on('focus', function() { orientation: 'bottom',
startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
}).on('focus', function() {
$(this).datepicker('show'); // Ensure it opens on focus $(this).datepicker('show'); // Ensure it opens on focus
}); });
}); });

View File

@ -260,6 +260,13 @@
.card { .card {
margin-bottom: 5px; margin-bottom: 5px;
} }
.hidden-row {
display: none;
}
</style> </style>
@ -594,17 +601,18 @@ foreach ($period as $day) {
foreach ($groupedDieselMachineStockDetails as $rowIndex => $dieselStockDetails) { foreach ($groupedDieselMachineStockDetails as $rowIndex => $dieselStockDetails) {
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dieselStockDetails[0]['date'])->format('d-m-Y');
?> ?>
<tr <tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
if ($dateInMonthDmYFormat === $currentDate) {
$currentDate = date('d-m-Y'); echo 'style="background: #cef0ad;"';
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dieselStockDetails[0]['date'])->format('d-m-Y'); }
if ($dateInMonthDmYFormat === $currentDate) { ?>
echo 'style="background: #cef0ad;"'; >
}
?>>
<?php <?php
@ -847,13 +855,16 @@ foreach ($period as $day) {
<?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { ?> <?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
<tr
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
?>
<tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
@ -1921,8 +1932,12 @@ foreach ($period as $day) {
viewMode: 'months', viewMode: 'months',
minViewMode: 'months', minViewMode: 'months',
autoclose: true, autoclose: true,
orientation: 'bottom' orientation: 'bottom',
}) startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
});
</script> </script>
<script> <script>

View File

@ -968,8 +968,9 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
$summary['input_sand_qty'] += $a['input_sand_qty'] == "-" ? 0 : (float) $a['input_sand_qty']; $summary['input_sand_qty'] += $a['input_sand_qty'] == "-" ? 0 : (float) $a['input_sand_qty'];
$summary['moisture_loss_qty'] += $a['moisture_loss_qty'] == "-" ? 0 : (float) $a['moisture_loss_qty']; $summary['moisture_loss_qty'] += $a['moisture_loss_qty'] == "-" ? 0 : (float) $a['moisture_loss_qty'];
$summary['sand_dried_qty'] += $a['sand_dried_qty'] == "-" ? 0 : (float) $a['sand_dried_qty']; $summary['sand_dried_qty'] += $a['sand_dried_qty'] == "-" ? 0 : (float) $a['sand_dried_qty'];
$summary['gas_per_ton'] = round(($summary['total_gas_consumption'] / $summary['sand_dried_qty'])); $summary['gas_per_ton'] = number_format(($summary['total_gas_consumption'] / $summary['sand_dried_qty']), 2);
$summary['qty_per_hrs'] = round( ($summary['sand_dried_qty'] / $summary['drier_running_hours']) ); $summary['qty_per_hrs'] = number_format(($summary['sand_dried_qty'] / $summary['drier_running_hours']), 2);
$summary['dust_qty'] += $a['dust_qty'] == "-" ? 0 : (float) $a['dust_qty']; $summary['dust_qty'] += $a['dust_qty'] == "-" ? 0 : (float) $a['dust_qty'];
} ?> } ?>

View File

@ -297,6 +297,12 @@
.card { .card {
margin-bottom: 5px; margin-bottom: 5px;
} }
.hidden-row {
display: none;
}
</style> </style>
@ -523,11 +529,12 @@
$summary = []; $summary = [];
foreach ($dustAndRoughStockDetails as $dustAndRoughStockDetailsIndex => $dustAndRoughStockDetail) { foreach ($dustAndRoughStockDetails as $dustAndRoughStockDetailsIndex => $dustAndRoughStockDetail) {
?> $currentDate = date('d-m-Y');
<tr $dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dustAndRoughStockDetail['date'])->format('d-m-Y');
?>
<tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dustAndRoughStockDetail['date'])->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
@ -602,11 +609,12 @@
} }
foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
?>
<tr
<?php
$currentDate = date('d-m-Y'); $currentDate = date('d-m-Y');
$dateInMonthDmYFormat = date("d-m-Y", strtotime($dateInMonth)); $dateInMonthDmYFormat = date("d-m-Y", strtotime($dateInMonth));
?>
<tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
@ -994,12 +1002,14 @@
$(document).ready(function() { $(document).ready(function() {
$('#month').datepicker({ $('#month').datepicker({
format: "M-yyyy", // Format as "Jan-2025" format: 'M-yyyy',
minViewMode: 1, // Month-Year Picker viewMode: 'months',
autoclose: true, minViewMode: 'months',
todayHighlight: true, autoclose: true,
orientation: "auto" // Adjusts automatically, or use "top" / "bottom" orientation: 'bottom',
}).on('focus', function() { startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
}).on('focus', function() {
$(this).datepicker('show'); // Ensure it opens on focus $(this).datepicker('show'); // Ensure it opens on focus
}); });
}); });

View File

@ -280,6 +280,12 @@
.card { .card {
margin-bottom: 5px; margin-bottom: 5px;
} }
.hidden-row {
display: none;
}
</style> </style>
<div class="content-page"> <div class="content-page">
<div class="content"> <div class="content">
@ -337,9 +343,7 @@
<input type="text" name="month" id="month" value="<?php echo "$month" ?>" <input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control " class="form-control "
data-provide="datepicker" readonly>
data-date-format="M-yyyy"
data-date-min-view-mode="1" readonly>
</div> </div>
@ -486,9 +490,9 @@
<!-- gas stock details stored --> <!-- gas stock details stored -->
<th class="celda_encabezado_general">Consumption </th> <th class="celda_encabezado_general">Consumption </th>
<th class="celda_encabezado_general">Sand Dried Qty </th> <th class="celda_encabezado_general">Sand Dried Qty(MT) </th>
<th class="celda_encabezado_general">Consumption</th> <th class="celda_encabezado_general">Consumption</th>
<th class="celda_encabezado_general">Sand Coated Qty </th> <th class="celda_encabezado_general">Sand Coated Qty(Kg) </th>
<th class="celda_encabezado_general">Panel Consumption</th> <th class="celda_encabezado_general">Panel Consumption</th>
<th class="celda_encabezado_general">Physical Consumption</th> <th class="celda_encabezado_general">Physical Consumption</th>
<th class="celda_encabezado_general">Ton </th> <th class="celda_encabezado_general">Ton </th>
@ -500,21 +504,22 @@
</thead> </thead>
<tbody style="background-color: #fff;"> <tbody style="background-color: #fff;">
<?php if (!empty($gasStockDetails)) { <?php if (!empty($gasStockDetails)) {
foreach ($gasStockDetails as $index => $gasStockDetail) { foreach ($gasStockDetails as $index => $gasStockDetail) {
$currentDate = date('d-m-Y');
$date = Datetime::createFromFormat('Y-m-d', $gasStockDetail['date'])->format('d-m-Y') $date = Datetime::createFromFormat('Y-m-d', $gasStockDetail['date'])->format('d-m-Y')
?> ?>
<!-- implementing date highlighter --> <!-- implementing date highlighter -->
<tr
<tr class="<?=$date > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
if ($date === $currentDate) {
$currentDate = date('d-m-Y'); echo 'style="background: #cef0ad;"';
if ($date === $currentDate) { }
echo 'style="background: #cef0ad;"'; ?>
} >
?>>
<!-- td:eq(0) --> <!-- td:eq(0) -->
<td class="celda_normal"><?= $date ?? '-' ?></td> <td class="celda_normal"><?= $date ?? '-' ?></td>
@ -726,17 +731,17 @@
} }
foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = Datetime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y'); $dateInMonthDmYFormat = Datetime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
?> ?>
<!-- implementing date highlighter --> <!-- implementing date highlighter -->
<tr <tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
$currentDate = date('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
@ -1414,6 +1419,15 @@
$('#month').change(function() { $('#month').change(function() {
$('#changeMonthForm').submit(); $('#changeMonthForm').submit();
}) })
$('#month').datepicker({
format: 'M-yyyy',
viewMode: 'months',
minViewMode: 'months',
autoclose: true,
orientation: 'bottom',
startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
});
}) })
</script> </script>

View File

@ -325,9 +325,6 @@
<input type="text" name="month" id="month" value="<?php echo "$month" ?>" <input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control " class="form-control "
data-provide="datepicker"
data-date-format="M-yyyy"
data-date-min-view-mode="1"
readonly> readonly>
<input type="hidden" name="remark" id="remark" value="<?php echo $remark ?>"> <input type="hidden" name="remark" id="remark" value="<?php echo $remark ?>">
@ -1979,6 +1976,15 @@
$('#month').change(function() { $('#month').change(function() {
$('#changeMonthForm').submit(); $('#changeMonthForm').submit();
}) })
$('#month').datepicker({
format: 'M-yyyy',
viewMode: 'months',
minViewMode: 'months',
autoclose: true,
orientation: 'bottom',
startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
});
}) })
</script> </script>

View File

@ -266,6 +266,11 @@
/* Replace with your table's actual ID or selector */ /* Replace with your table's actual ID or selector */
border-collapse: collapse; border-collapse: collapse;
} }
.hidden-row {
display: none;
}
</style> </style>
@ -605,15 +610,14 @@ foreach ($period as $day) {
foreach ($groupedPowerConsumptionStockDetails as $groupedIndex => $powerStockDetails) { foreach ($groupedPowerConsumptionStockDetails as $groupedIndex => $powerStockDetails) {
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $powerStockDetails[0]['date'])->format('d-m-Y');
?> ?>
<tr <tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $powerStockDetails[0]['date'])->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
@ -869,17 +873,20 @@ foreach ($period as $day) {
<?php } else { ?> <?php } else { ?>
<?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { ?> <?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
<tr
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
?>
<tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
?>> ?>
>
<?php <?php
$startDate = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y'); $startDate = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
@ -1799,8 +1806,10 @@ foreach ($period as $day) {
viewMode: 'months', viewMode: 'months',
minViewMode: 'months', minViewMode: 'months',
autoclose: true, autoclose: true,
orientation: 'bottom' orientation: 'bottom',
}) startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
});
</script> </script>

View File

@ -265,6 +265,13 @@
.card { .card {
margin-bottom: 5px; margin-bottom: 5px;
} }
.hidden-row {
display: none;
}
</style> </style>
@ -590,21 +597,28 @@ foreach ($period as $day) {
<?php if (!empty($groupedResinStockDetails)) { <?php if (!empty($groupedResinStockDetails)) {
$summary = []; $summary = [];
foreach ($groupedResinStockDetails as $groupedResinStockDetailsIndex => $resinStockDetails) { foreach ($groupedResinStockDetails as $groupedResinStockDetailsIndex => $resinStockDetails) {
?> $currentDate = date('d-m-Y');
<tr $dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $resinStockDetails[0]['date'])->format('d-m-Y');
$backgroundColor = " ";
?>
<tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
if ($dateInMonthDmYFormat === $currentDate) {
$backgroundColor ="background: #cef0ad;";
}
?>
style="<?= $backgroundColor;?> ">
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $resinStockDetails[0]['date'])->format('d-m-Y'); <!-- td -->
if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"';
}
?>>
<?php foreach ($resinStockDetails as $resinStockIndex => $resinStock) { <?php foreach ($resinStockDetails as $resinStockIndex => $resinStock) {
?> ?>
@ -721,17 +735,25 @@ foreach ($period as $day) {
<?php } else { ?> <?php } else { ?>
<?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { ?> <?php foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
<tr
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
?>
<tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad ;"'; echo 'style="background: #cef0ad ;"';
} }
?>> ?>
>
<?php <?php
// dd($resinMaterials); // dd($resinMaterials);
foreach ($resinMaterials as $resinMaterialIndex => $resinMaterial) { ?> foreach ($resinMaterials as $resinMaterialIndex => $resinMaterial) { ?>
@ -1145,7 +1167,7 @@ foreach ($period as $day) {
// Validate against the regex // Validate against the regex
const isValid = /^-?\d*\.?\d*$/.test(input); const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) { if (!isValid) {
alert('Invalid input! Please enter a valid number.');
return 0; return 0;
} }
@ -1409,8 +1431,10 @@ foreach ($period as $day) {
viewMode: 'months', viewMode: 'months',
minViewMode: 'months', minViewMode: 'months',
autoclose: true, autoclose: true,
orientation: 'bottom' orientation: 'bottom',
}) startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
});
</script> </script>
<script> <script>

View File

@ -310,6 +310,11 @@
/* Replace with your table's actual ID or selector */ /* Replace with your table's actual ID or selector */
border-collapse: collapse; border-collapse: collapse;
} }
.hidden-row {
display: none;
}
</style> </style>
@ -707,15 +712,15 @@ $timeOtions[] = "12:00 AM";
?> ?>
<?php foreach ($trpProductionDetails as $trpProductionDetailIndex => $trpProductionDetail) { <?php foreach ($trpProductionDetails as $trpProductionDetailIndex => $trpProductionDetail) {
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $trpProductionDetail['date'])->format('d-m-Y');
?> ?>
<tr id="<?= $trpProductionDetail['date'] ?>" <tr id="<?= $trpProductionDetail['date'] ?>" class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $trpProductionDetail['date'])->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
@ -2681,8 +2686,10 @@ $timeOtions[] = "12:00 AM";
viewMode: 'months', viewMode: 'months',
minViewMode: 'months', minViewMode: 'months',
autoclose: true, autoclose: true,
orientation: 'bottom' orientation: 'bottom',
}) startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
});
</script> </script>

View File

@ -283,6 +283,11 @@
.card { .card {
margin-bottom: 5px; margin-bottom: 5px;
} }
.hidden-row {
display: none;
}
</style> </style>
@ -508,17 +513,17 @@
$summary = []; $summary = [];
foreach ($trpSandUseStockDetails as $trpSandUseStockDetailsIndex => $trpSandUseStockDetail) { foreach ($trpSandUseStockDetails as $trpSandUseStockDetailsIndex => $trpSandUseStockDetail) {
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $trpSandUseStockDetail['date'])->format('d-m-Y');
?> ?>
<tr <tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php <?php
$currentDate = date('d-m-Y'); if($dateInMonthDmYFormat === $currentDate) {
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $trpSandUseStockDetail['date'])->format('d-m-Y'); echo 'style="background: #cef0ad;"';
if ($dateInMonthDmYFormat === $currentDate) { }
echo 'style="background: #cef0ad;"'; ?>
} >
?>>
<td class="celda_normal"> <td class="celda_normal">
<?php <?php
@ -609,11 +614,13 @@
} }
foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) { foreach ($datesInMonth as $datesInMonthIndex => $dateInMonth) {
?>
<tr
<?php
$currentDate = date('d-m-Y'); $currentDate = date('d-m-Y');
$dateInMonthDmYFormat = date("d-m-Y", strtotime($dateInMonth)); $dateInMonthDmYFormat = date("d-m-Y", strtotime($dateInMonth));
?>
<tr class="<?=$dateInMonthDmYFormat > $currentDate ? "hidden-row" : "" ?>"
<?php
if ($dateInMonthDmYFormat === $currentDate) { if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"'; echo 'style="background: #cef0ad;"';
} }
@ -1037,12 +1044,14 @@
$(document).ready(function() { $(document).ready(function() {
$('#month').datepicker({ $('#month').datepicker({
format: "M-yyyy", // Format as "Jan-2025" format: 'M-yyyy',
minViewMode: 1, // Month-Year Picker viewMode: 'months',
autoclose: true, minViewMode: 'months',
todayHighlight: true, autoclose: true,
orientation: "auto" // Adjusts automatically, or use "top" / "bottom" orientation: 'bottom',
}).on('focus', function() { startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
}).on('focus', function() {
$(this).datepicker('show'); // Ensure it opens on focus $(this).datepicker('show'); // Ensure it opens on focus
}); });
}); });