stock module latest today vadivel J 07-1-2025

This commit is contained in:
vadivelJ96 2025-01-07 18:28:29 +05:30
parent cf032023d5
commit 9ec31b265b
3 changed files with 774 additions and 380 deletions

View File

@ -1307,81 +1307,12 @@ class StockController extends BaseController
$endDate = date("Y-m-t", strtotime($startDate));
// Subquery definition
$subquery = $this->db->table('t_materialmaster')
->select('materialCode')
->where('Category', 'waste core')
->get()
->getResultArray();
$data['trpProductionDetails'] = $this->TrpProduction_model->trpProductionDetails($startDate,$endDate);
$materialCodes = array_column($subquery, 'materialCode'); // Extracts 'materialCode' values
// dd($data['trpProductionDetails']);
// Convert the array of material codes to a comma-separated string
$materialCodesString = "'" . implode("','", $materialCodes) . "'";
// Main query
$sql = "SELECT
tpmd.*,
tpd.*,
tpwd.*,
tsu.*,
ip_invoice_items.*,
tigrd.* ,
ts.SupplierName
FROM
t_trpProductionMaintenanceDetails tpmd
JOIN
t_trpProductionDetails tpd ON tpd.date = tpmd.date
JOIN
t_trpProductionWasteDetails tpwd ON tpwd.date = tpmd.date
LEFT JOIN
t_coatingMachineDetails tcmd ON tcmd.date = tpmd.date
LEFT JOIN
t_drierMachineDetails tdmd ON tdmd.date = tpmd.date
LEFT JOIN
t_trp_sand_use tsu ON tsu.date = tpmd.date
LEFT JOIN
ip_invoice_items ON ip_invoice_items.item_date_added = tpmd.date
AND ip_invoice_items.item_name = 'Core Sand Reclaimed'
LEFT JOIN
t_igr_details tigrd
ON DATE(tigrd.CreatedDate) = tpmd.date
AND tigrd.MaterialCode IN ($materialCodesString)
LEFT JOIN
t_igr_master tigm
ON tigm.IGRNo = tigrd.IGRNo
LEFT JOIN
t_purchaseorder_master tpom
ON tpom.PONO = tigm.PONO
LEFT JOIN
t_supplierdetailsn ts
ON tpom.SupplierID = ts.SupplierID
WHERE
tpmd.date >= ?
AND
tpmd.date <= ?
Group BY
ts.SupplierName , tpmd.date , tigrd.MaterialCode
ORDER BY
tpmd.date ASC";
// Execute the query
$query = $this->db->query($sql, [ $startDate, $endDate]);
$data['trpProductionDetails'] = $query->getResultArray();
dd($data['trpProductionDetails']);
// dd($this->db->getLastQuery());
$date = DateTime::createFromFormat('Y-m', $month);
@ -1392,7 +1323,7 @@ class StockController extends BaseController
return $this->response->setJSON($data);
// return $this->loadViews("trpSandUseStockDetails", $this->global, $data, NULL);
// return $this->loadViews("trpProductionStockDetails", $this->global, $data, NULL);
@ -1532,151 +1463,6 @@ class StockController extends BaseController
}
// public function updateTrpProductionDetails() {
// $postData = $this->request->getPost();
// $updateTrpProductionDetails = json_decode($postData['updateTrpProductionDetails'], true);
// $updateProduction = [];
// $updateMaintenance = [];
// $updateWaste = [];
// $insertProduction = [];
// $insertMaintenance = [];
// $insertWaste = [];
// // Extract dates from the data
// $dates = array_column($updateTrpProductionDetails, 'Date');
// $formattedDates = array_map(function($date) {
// return $this->convertToDateWithFlexibleFormats($date, ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d");
// }, $dates);
// // Fetch existing records in bulk
// $existingMaintenanceRecords = $this->TrpProductionMaintenance_model->whereIn('date', $formattedDates)->findAll();
// $existingProductionRecords = $this->TrpProduction_model->whereIn('date', $formattedDates)->findAll();
// $existingWasteRecords = $this->TrpProductionWaste_model->whereIn('date', $formattedDates)->findAll();
// // Convert fetched records to associative arrays for quick lookup
// $existingMaintenanceMap = [];
// foreach ($existingMaintenanceRecords as $record) {
// $existingMaintenanceMap[$record['date']] = $record;
// }
// $existingProductionMap = [];
// foreach ($existingProductionRecords as $record) {
// $existingProductionMap[$record['date']] = $record;
// }
// $existingWasteMap = [];
// foreach ($existingWasteRecords as $record) {
// $existingWasteMap[$record['date']] = $record;
// }
// foreach ($updateTrpProductionDetails as $data) {
// $data['date'] = $this->convertToDateWithFlexibleFormats($data['Date'], ["d-m-Y", "Y-m-d", "m/d/Y", "m-d-Y"], "Y-m-d");
// $date = $data['date'];
// $dbDataTrpMaintenance = [
// 'date' => $data['date'],
// 'openingTime' => $data['openingTime'],
// 'closingTime' => $data['closingTime'],
// 'totalHours' => $data['totalHours'],
// 'coldStart' => $data['coldStart'],
// 'breakdownHours' => $data['breakdownHours'],
// 'burnerFiringHours' => $data['burnerFiringHours'],
// 'sandFeedingHours' => $data['sandFeedingHours'],
// 'workingPersonEngineers' => $data['workingPersonEngineers'],
// 'workingPersonSupervisiors' => $data['workingPersonSupervisiors'],
// 'workingPersonOperators' => $data['workingPersonOperators'],
// 'rollerDrivers' => $data['rollerDrivers'],
// 'natureOfMaintenance' => $data['natureOfMaintenance'],
// 'location' => $data['location'],
// 'description' => $data['description']
// ];
// $dbDataTrpProduction = [
// 'date' => $data['date'],
// 'gasReceiptBg' => $data['gasReceiptBg'],
// 'gasReceiptPg' => $data['gasReceiptPg'],
// 'physicalGasConsumption' => $data['physicalGasConsumption'],
// 'trpPlusDrierGasConsumption' => $data['trpPlusDrierGasConsumption'],
// 'trpPhysicalGasPerTon' => $data['trpPhysicalGasPerTon'],
// 'panelGasConsumption' => $data['panelGasConsumption'],
// 'panelGasPerTon' => $data['panelGasPerTon'],
// 'edRunningHours' => $data['edRunningHours'],
// 'edProduction' => $data['edProduction'],
// 'edUsage' => $data['edUsage'],
// 'trpProduction' => $data['trpProduction'],
// 'trpProductionPerHour' => $data['trpProductionPerHour'],
// 'waterReceipt' => $data['waterReceipt'],
// 'waterConsumption' => $data['waterConsumption'],
// 'ebReading' => $data['ebReading'],
// 'ebReadingPerUnitTon' => $data['ebReadingPerUnitTon']
// ];
// $dbDataTrpWaste = [
// 'date' => $data['date'],
// 'msSeperation' => $data['msSeperation'],
// 'edWaste' => $data['edWaste'],
// 'coolerBags' => $data['coolerBags'],
// 'edPlus20Waste' => $data['edPlus20Waste'],
// 'cycloneWaste' => $data['cycloneWaste']
// ];
// if (empty($existingMaintenanceMap[$date])) {
// $insertMaintenance[] = $dbDataTrpMaintenance;
// $insertProduction[] = $dbDataTrpProduction;
// $insertWaste[] = $dbDataTrpWaste;
// } else {
// $dbDataTrpMaintenance['id'] = $existingMaintenanceMap[$date]['id'];
// $dbDataTrpProduction['id'] = $existingProductionMap[$date]['id'];
// $dbDataTrpWaste['id'] = $existingWasteMap[$date]['id'];
// $updateMaintenance[] = $dbDataTrpMaintenance;
// $updateProduction[] = $dbDataTrpProduction;
// $updateWaste[] = $dbDataTrpWaste;
// }
// }
// // Start the transaction
// $this->db->transBegin();
// try {
// if (!empty($insertMaintenance)) {
// $this->TrpProductionMaintenance_model->insertBatch($insertMaintenance);
// }
// if (!empty($insertProduction)) {
// $this->TrpProduction_model->insertBatch($insertProduction);
// }
// if (!empty($insertWaste)) {
// $this->TrpProductionWaste_model->insertBatch($insertWaste);
// }
// if (!empty($updateMaintenance)) {
// $this->TrpProductionMaintenance_model->updateBatch($updateMaintenance, 'id');
// }
// if (!empty($updateProduction)) {
// $this->TrpProduction_model->updateBatch($updateProduction, 'id');
// }
// if (!empty($updateWaste)) {
// $this->TrpProductionWaste_model->updateBatch($updateWaste, 'id');
// }
// // Commit the transaction if all operations are successful
// $this->db->transCommit();
// echo "Data Saved Successfully";
// } catch (\Exception $error) {
// // Rollback the transaction in case of any errors
// $this->db->transRollback();
// echo "An error occurred: " . $error->getMessage();
// }
// }

View File

@ -46,4 +46,189 @@ class TrpProductionModel extends Model
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
public function trpProductionDetails($startDate,$endDate){
// Subquery definition
$subquery = $this->db->table('t_materialmaster')
->select('materialCode')
->where('Category', 'waste core')
->get()
->getResultArray();
$materialCodes = array_column($subquery, 'materialCode'); // Extracts 'materialCode' values
// Convert the array of material codes to a comma-separated string
$materialCodesString = "'" . implode("','", $materialCodes) . "'";
$sql = "SELECT
tpmd.date,
tpmd.openingTime,
tpmd.closingTime,
tpmd.totalHours,
tpmd.coldStart,
tpmd.breakdownHours,
tpmd.burnerFiringHours,
tpmd.sandFeedingHours,
tpmd.workingPersonEngineers,
tpmd.workingPersonSupervisiors,
tpmd.workingPersonOperators,
tpmd.rollerDrivers,
tpmd.natureOfMaintenance,
tpmd.location,
tpmd.description,
tpd.gasReceiptBg,
tpd.gasReceiptPg,
tpd.physicalGasConsumption,
tpd.trpPlusDrierGasConsumption,
tpd.trpPhysicalGasPerTon,
tpd.panelGasConsumption,
tpd.panelGasPerTon,
tpd.edRunningHours,
tpd.edProduction,
tpd.edUsage,
tpd.trpProduction,
tpd.trpProductionPerHour,
tpd.waterReceipt,
tpd.waterConsumption,
tpd.ebReading,
tpd.ebReadingPerUnitTon,
tpwd.msSeperation,
tpwd.edWaste,
tpwd.coolerBags,
tpwd.edPlus20Waste,
tpwd.cycloneWaste,
tcmd.totalGasConsumption as coatingGasConsumption,
tdmd.total_gas_consumption as drierGasConsumption,
tsu.total_kgs as coating,
invItems.item_date_added,
invItems.client_name,
invItems.TotalRsQuantity,
tigrd.SupplierName,
tigrd.TotalQuantityAsPerInvoice,
tigrd.CreatedDate
FROM
t_trpProductionMaintenanceDetails tpmd
JOIN
t_trpProductionDetails tpd ON tpd.date = tpmd.date
JOIN
t_trpProductionWasteDetails tpwd ON tpwd.date = tpmd.date
LEFT JOIN
t_coatingMachineDetails tcmd ON tcmd.date = tpmd.date
LEFT JOIN
t_drierMachineDetails tdmd ON tdmd.date = tpmd.date
LEFT JOIN
t_trp_sand_use tsu ON tsu.date = tpmd.date
LEFT JOIN
(
Select
clients.client_name,
invItems.item_date_added,
SUM(invItems.item_quantity) AS TotalRsQuantity
from ip_invoice_items invItems
-- All joins to get client name thats it
LEFT JOIN
ip_invoices inv
ON inv.invoice_id = invItems.invoice_id
LEFT JOIN
ip_clients clients
ON clients.client_id = inv.client_id
-- getting core reclamation sand
Where invItems.item_name = 'Core Sand Reclaimed'
-- grouping Client who provides reclamation sand on a particular date with 1 or more invoices
Group By invItems.item_date_added , clients.client_name
) invItems
ON invItems.item_date_added = tpmd.date
LEFT JOIN
(
Select tigrd.CreatedDate ,tigrd.MaterialCode , tigrd.IGRNo , ts.SupplierName,
SUM(QuantityAsPerInvoice) AS TotalQuantityAsPerInvoice
from t_igr_details tigrd
-- All joins to get supplier name thats it
LEFT JOIN
t_igr_master tigm
ON tigm.IGRNo = tigrd.IGRNo
LEFT JOIN
t_purchaseorder_master tpom
ON tpom.PONO = tigm.PONO
LEFT JOIN
t_supplierdetailsn ts
ON tpom.SupplierID = ts.SupplierID
-- getting waste core sands using three distinct material codes
Where tigrd.MaterialCode IN ($materialCodesString)
-- grouping supplier who provides waste core on a particular date with 1 or more IGRS
Group By Date(tigrd.CreatedDate) , ts.SupplierName
) tigrd
ON DATE(tigrd.CreatedDate) = tpmd.date
WHERE
tpmd.date >= ?
AND
tpmd.date <= ?
ORDER BY
tpmd.date ASC";
// Execute the query
$query = $this->db->query($sql, [ $startDate, $endDate]);
$result = $query->getResultArray();
return $result;
}
}

View File

@ -210,7 +210,7 @@
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">Stocks</a></li>
<li class="breadcrumb-item active">
<h4 class="page-title">TRP Production Details </h4>
<h4 class="page-title">TRP Production Stock Details </h4>
</li>
</ol>
</div>
@ -265,33 +265,134 @@
<thead class="celda_encabezado_general" style="padding: 10px;">
<tr>
<th class="celda_encabezado_general" colspan="1">material </th>
<?php foreach($resinMaterials as $resinMaterial){ ?>
<!-- this will loop till materials present -->
<th class="celda_encabezado_general" colspan="4">
<?= $resinMaterial['MaterialName']?>
<!-- (<?= $resinMaterial['MaterialCode']?>) -->
</th>
<?php } ?>
<!-- th:eq(0) -->
<th class="celda_encabezado_general" rowspan="2">Date </th>
<!-- th:eq(1) -->
<th class="celda_encabezado_general" rowspan="2">Opening Time </th>
<!-- th:eq(2) -->
<th class="celda_encabezado_general" rowspan="2">Closing Time </th>
<!-- th:eq(3) -->
<th class="celda_encabezado_general" rowspan="2">Total Hours </th>
<!-- th:eq(4) -->
<th class="celda_encabezado_general" rowspan="2">Cold Start </th>
<!-- th:eq(5) -->
<th class="celda_encabezado_general" rowspan="2">Break Down Hours </th>
<!-- th:eq(6) -->
<th class="celda_encabezado_general" rowspan="2">Burner Firing Hours </th>
<!-- th:eq(7) -->
<th class="celda_encabezado_general" rowspan="2">Sand Feeding Hours </th>
<!-- th:eq(8) -->
<th class="celda_encabezado_general" colspan="2">Gas Receipt </th>
<!-- th:eq(9) -->
<th class="celda_encabezado_general" rowspan="2">Physical Gas Consumption </th>
<!-- th:eq(10) -->
<th class="celda_encabezado_general" rowspan="2">Drier Gas Consumption </th>
<!-- th:eq(11) -->
<th class="celda_encabezado_general" rowspan="2">Coating Gas Consumption </th>
<!-- th:eq(12) -->
<th class="celda_encabezado_general" rowspan="2">TRP plus Drier Gas Consumption </th>
<!-- th:eq(13) -->
<th class="celda_encabezado_general" rowspan="2">TRP Physical Gas Per Ton </th>
<!-- th:eq(14) -->
<th class="celda_encabezado_general" rowspan="2">Panel Gas Consumption </th>
<!-- th:eq(15) -->
<th class="celda_encabezado_general" rowspan="2">Panel Gas Per Ton </th>
<!-- th:eq(16) -->
<th class="celda_encabezado_general" colspan="7">Incoming Sand/ Lump details </th>
<!-- th:eq(17) -->
<th class="celda_encabezado_general" colspan="3">ED details </th>
<!-- th:eq(18) -->
<th class="celda_encabezado_general" colspan="2">TRP Sand </th>
<!-- th:eq(19) -->
<th class="celda_encabezado_general" colspan="6">Usage </th>
<!-- th:eq(20) -->
<th class="celda_encabezado_general" colspan="2">Water </th>
<!-- th:eq(21) -->
<th class="celda_encabezado_general" rowspan="2">EB Reading </th>
<!-- th:eq(22) -->
<th class="celda_encabezado_general" rowspan="2">EB Unit Per Ton </th>
<!-- th:eq(23) -->
<th class="celda_encabezado_general" colspan="4">Working Persons </th>
<!-- th:eq(24) -->
<th class="celda_encabezado_general" colspan="2"> Maintanence Details </th>
<!-- th:eq(25) -->
<th class="celda_encabezado_general" rowspan="2">Description </th>
<!-- th:eq(26) -->
<th class="celda_encabezado_general" rowspan="2">MS Seperation </th>
<!-- th:eq(27) -->
<th class="celda_encabezado_general" rowspan="2">ED Waste </th>
<!-- th:eq(28) -->
<th class="celda_encabezado_general" rowspan="2">Cooler Bags </th>
<!-- th:eq(29) -->
<th class="celda_encabezado_general" rowspan="2">ED +20 Waste </th>
<!-- th:eq(30) -->
<th class="celda_encabezado_general" rowspan="2">Cyclone Waste </th>
<!-- th:eq(31) -->
</tr>
<tr>
<th class="celda_encabezado_general" colspan="1">Date </th>
<tr>
<!-- th:eq(0) -->
<th class="celda_encabezado_general" >BG</th>
<!-- th:eq(1) -->
<th class="celda_encabezado_general" >PG </th>
<!-- th:eq(2) -->
<th class="celda_encabezado_general" >AL(S) </th>
<!-- th:eq(3) -->
<th class="celda_encabezado_general" >AL(E) </th>
<!-- th:eq(4) -->
<th class="celda_encabezado_general" >ME </th>
<!-- th:eq(6) -->
<th class="celda_encabezado_general" >SI </th>
<!-- th:eq(7) -->
<th class="celda_encabezado_general" >caparo </th>
<!-- th:eq(8) -->
<th class="celda_encabezado_general" >Nemak </th>
<!-- th:eq(9) -->
<th class="celda_encabezado_general" >DR</th>
<!-- th:eq(10) -->
<th class="celda_encabezado_general" >Running Hours </th>
<!-- th:eq(11) -->
<th class="celda_encabezado_general" >Production </th>
<!-- th:eq(12) -->
<th class="celda_encabezado_general" >Usage </th>
<!-- th:eq(13) -->
<th class="celda_encabezado_general" >Production </th>
<!-- th:eq(14) -->
<th class="celda_encabezado_general" >Production Per Hour </th>
<!-- th:eq(15) -->
<th class="celda_encabezado_general" >Coating </th>
<!-- th:eq(16) -->
<th class="celda_encabezado_general" >Hindhuja </th>
<!-- th:eq(17) -->
<th class="celda_encabezado_general" >Nemak</th>
<!-- th:eq(18) -->
<th class="celda_encabezado_general" >ME </th>
<!-- th:eq(19) -->
<th class="celda_encabezado_general" >BI </th>
<!-- th:eq(20) -->
<th class="celda_encabezado_general" >Karmen </th>
<!-- th:eq(21) -->
<th class="celda_encabezado_general" >Receipt </th>
<!-- th:eq(22) -->
<th class="celda_encabezado_general" >Consumption </th>
<!-- th:eq(23) -->
<th class="celda_encabezado_general" >Engineers </th>
<!-- th:eq(24) -->
<th class="celda_encabezado_general" >Supervisors</th>
<!-- th:eq(25) -->
<th class="celda_encabezado_general" >Operators </th>
<!-- th:eq(26) -->
<th class="celda_encabezado_general" >Roller Drivers </th>
<!-- th:eq(27) -->
<th class="celda_encabezado_general" >Nature Of Maintenance </th>
<!-- th:eq(28) -->
<th class="celda_encabezado_general" >Location </th>
<?php foreach($resinMaterials as $resinMaterial){ ?>
<!-- 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>
@ -299,147 +400,486 @@
<tbody style="background-color: #fff;" >
<?php if(!empty($groupedResinStockDetails))
{
//dd($groupedResinStockDetails);
foreach($groupedResinStockDetails as $groupedResinStockDetailsIndex => $resinStockDetails){
?>
<tr
<?php if(!empty($trpProductionStockDetails))
{ ?>
<?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat= DateTime::createFromFormat('Y-m-d', $resinStockDetails[0]['date'])->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { echo 'style="background: #cef0ad;"';}
?>
>
<?php foreach($resinStockDetails as $resinStockIndex => $resinStock){ ?>
<?php if ($resinStockIndex == 0): ?>
<?php
$startDate =DateTime::createFromFormat('Y-m-d', $resinStock['date'])->format('d-m-Y');
?>
<td class="celda_normal">
<?= $startDate ?>
</td>
<?php endif; ?>
<td style="display:none">
<?= $resinStock['date']?>
</td>
<td style="display:none"
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
class="materialCode" ><?= $resinStock['materialCode']?>
</td>
<td style="display:none" class="celda_normal customer"
data-materialCode="<?=$resinStock['materialCode']?>"
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>">
<?= $resinStock['customer']?>
</td>
<td class="celda_normal openingStock"
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
<?php if ($groupedResinStockDetailsIndex == 0): ?>
oninput="openingStockChange(this)"
contenteditable="true"
<?php endif; ?>
><?= $resinStock['opening']?>
</td>
<td class="celda_normal receiptStock"
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
oninput="receiptStockChange(this)"
contenteditable="true">
<?= $resinStock['receipt']?>
</td>
<td class="celda_normal usedStock"
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>"
oninput="usedStockChange(this)"
contenteditable="true"><?= $resinStock['used']?>
</td>
<td class="celda_normal balanceStock"
data-id="<?=$resinStock['date']?> <?=$resinStock['materialCode']?>">
<?= $resinStock['balanceStock']?>
</td>
<?php } ?>
</tr>
<?php } ?>
<!-- this else condition work if groupedBagStockDetails is empty and creating new records
with initial values 0 for entire month -->
<?php } else { ?>
<?php foreach($datesInMonth as $datesInMonthIndex => $dateInMonth){ ?>
<tr
<!-- date -->
<!-- td:eq(0) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
54465656
</td>
<?php
<!-- openingTime -->
<!-- td:eq(1) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat= DateTime::createFromFormat('Y-m-d', $dateInMonth)->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) { echo 'style="background: #cef0ad;"';}
?>
>
<?php
foreach($resinMaterials as $resinMaterialIndex => $resinMaterial){ ?>
<!-- this will loop till materials present -->
<!-- closingTime -->
<!-- td:eq(2) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<?php if ($resinMaterialIndex == 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>
<!-- totalHours -->
<!-- td:eq(3) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<td class="celda_normal" style="display:none"
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>">
<?= $resinMaterial['MaterialCode']?>
</td>
<!-- coldStart -->
<!-- td:eq(4) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<td class="celda_normal customer" style="display:none"
data-materialCode="<?=$resinMaterial['MaterialCode']?>"
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>">
<?= $resinMaterial['customers']?>
</td>
<!-- breakdownHours -->
<!-- td:eq(5) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<td class="celda_normal openingStock"
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
<?php if($datesInMonthIndex == 0){ ?>
oninput="openingStockChange(this)"
contenteditable="true"
<!-- burnerFiringHours -->
<!-- td:eq(6) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- sandFeedingHours -->
<!-- td:eq(7) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- workingPersonEngineers -->
<!-- td:eq(8) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- workingPersonSupervisiors -->
<!-- td:eq(9) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- workingPersonOperators -->
<!-- td:eq(10) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- rollerDrivers -->
<!-- td:eq(11) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- natureOfMaintenance -->
<!-- td:eq(12) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- location -->
<!-- td:eq(13) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- description -->
<!-- td:eq(14) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- gasReceiptBg -->
<!-- td:eq(15) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- gasReceiptPg -->
<!-- td:eq(16) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- physicalGasConsumption -->
<!-- td:eq(17) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- trpPlusDrierGasConsumption -->
<!-- td:eq(18) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- trpPhysicalGasPerTon -->
<!-- td:eq(19) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- panelGasConsumption -->
<!-- td:eq(20) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- panelGasPerTon -->
<!-- td:eq(21) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- edRunningHours -->
<!-- td:eq(22) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- edProduction -->
<!-- td:eq(23) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!--edUsage -->
<!-- td:eq(24) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- trpProduction -->
<!-- td:eq(25) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- trpProductionPerHour -->
<!-- td:eq(26) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- waterReceipt -->
<!-- td:eq(27) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- waterConsumption -->
<!-- td:eq(28) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- ebReading -->
<!-- td:eq(29) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- ebReadingPerUnitTon -->
<!-- td:eq(30) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- msSeperation -->
<!-- td:eq(31) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- edWaste -->
<!-- td:eq(32) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- coolerBags -->
<!-- td:eq(33) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- edPlus20Waste -->
<!-- td:eq(34) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!--cycloneWaste -->
<!-- td:eq(35) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- coatingGasConsumption -->
<!-- td:eq(36) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- drierGasConsumption -->
<!-- td:eq(37) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- coating -->
<!-- td:eq(38) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- TotalQuantityAsPerInvoice -->
<!-- td:eq(39) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- TotalRsQuantity -->
<!-- td:eq(40) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(41) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(42) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(43) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(44) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(45) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(46) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(47) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(48) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(49) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<!-- td:eq(50) -->
<td class="celda_normal receiptStock"
data-id=""
oninput="receiptStockChange(this)"
contenteditable="true">
0
</td>
<?php }?>
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
<td class="celda_normal receiptStock"
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
oninput="receiptStockChange(this)"
contenteditable="true">0</td>
<td class="celda_normal usedStock"
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
oninput="usedStockChange(this)"
contenteditable="true">0</td>
<td class="celda_normal balanceStock"
data-id="<?=$dateInMonth?> <?=$resinMaterial['MaterialCode']?>"
><?= $previousMonthResinStockDetails[$resinMaterialIndex]['balanceStock']??'0' ?></td>
<?php } ?>
</tr>
<?php } ?>
<?php }?>
@ -467,7 +907,7 @@
<div >
<div class="modal fade" id="bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" >
<div class="modal-dialog modal-md" >
<div class="modal-content" >
<div class="modal-header">
<h4 class="modal-title" id="myLargeModalLabel">Navigation Options</h4>
@ -475,24 +915,7 @@
</div>
<div class="modal-body">
<div class="row">
<!-- bag Dropdown -->
<div class="col-md-6">
<div class="form-group">
<label for="resinDropdown">Select Bag</label>
<select id="resinDropdown" class="form-control">
<option value="">Select Resin</option>
<?php foreach($resinMaterials as $resinMaterial): ?>
<option value=" <?= $resinMaterial['MaterialName']?>">
<?= $resinMaterial['MaterialName']?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<!-- Date Dropdown -->
<div class="col-md-6">
<div class="form-group">
@ -747,9 +1170,9 @@
const table = $('#resinStockDetailsTableId');
const rows = [];
table.find('tbody tr').each(function() {
const rowCells = $(this).find('td');
const otherDate = rowCells.eq(1).text().trim();
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