ria/app/Views/stock/trpProductionStockDetails.php
2025-03-27 18:48:26 +05:30

2509 lines
134 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<style type="text/css">
.num {
text-align: right;
}
.fht-table,
.fht-table thead,
.fht-table tfoot,
.fht-table tbody,
.fht-table tr,
.fht-table th,
.fht-table td {
margin: 0;
}
.fht-table td {
text-align: center;
}
.fht-table td:hover {
background-color: rgb(170, 222, 167);
color: rgb(2, 2, 2);
transform: scale(1.25);
/* Increases size by 25% */
transition: transform 0.5s ease-in-out;
/* Smooth scaling effect */
}
.fht-table tr:hover {
background-color: rgb(170, 222, 167);
color: rgb(2, 2, 2);
}
.fht-table {
border: 0 none;
height: auto;
width: auto;
border-collapse: collapse;
border-spacing: 0;
/*table-layout: fixed; Algoritmo de distribucion fijo */
white-space: nowrap;
}
.fht-table th,
.fht-table td {
overflow: hidden;
}
.fht-table-wrapper,
.fht-table-wrapper .fht-thead,
.fht-table-wrapper .fht-tfoot,
.fht-table-wrapper .fht-fixed-column .fht-tbody,
.fht-table-wrapper .fht-fixed-body .fht-tbody,
.fht-table-wrapper .fht-tbody {
overflow: hidden;
position: relative;
}
.fht-table-wrapper .fht-fixed-body .fht-tbody,
.fht-table-wrapper .fht-tbody {
overflow: auto;
}
.fht-table-wrapper .fht-table .fht-cell {
overflow: hidden;
height: 1px;
}
.fht-table-wrapper .fht-fixed-column,
.fht-table-wrapper .fht-fixed-body {
top: 0;
left: 0;
position: absolute;
}
.fht-table-wrapper .fht-fixed-column {
z-index: 1;
}
.fht-fixed-body .fht-thead table {
margin-right: 20px;
border: 0 none;
}
/*For Examples*/
.ContenedorTabla {
height: 500px;
margin: 0 auto;
overflow: auto;
width: auto;
position: relative;
}
.header,
.main {
display: inline-block;
height: auto;
width: 100%;
}
.titulosHeader {
border-bottom: 1px solid #e8bb25;
height: auto;
margin-bottom: 10px;
padding-bottom: 8px;
padding-top: 8px;
width: 100%;
}
._Separador {
background-color: #fff;
height: 12px;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
width: 7px;
}
._Separador div {
width: 4px;
}
/*style excel*/
.excel_cell {
border: 1px solid #CCC;
color: #222;
text-align: center;
font-size: 13px;
font-weight: normal;
padding: 4px;
white-space: pre-line;
empty-cells: show;
}
._cell_header {
background-color: #EEE;
}
._cell_Default {
background-color: #FFF;
text-align: left;
}
.excel_cell div {
width: 30px;
height: 20px;
}
.celda_encabezado_general {
background-color: #50bbd9;
border: 1px solid #ccc;
color: #ffffff;
font-weight: bold;
padding: 6px 10px;
text-align: center;
}
.celda_normal {
/*background-color: #fff;*/
/* <!-- ad9271 into ffffff brown-light to green-light --> */
text-align: center;
border: 1px solid #ccc;
padding: 2px 4px;
}
#abstractTableId tbody td.celda_normal {
/*background-color: #fff;*/
/* <!-- ad9271 into ffffff brown-light to green-light --> */
text-align: center;
border: 1px solid #ccc;
padding: 12px 4px;
}
#trpProductionStockDetailsTableId tfoot tr td.celda_normal {
/*background-color: #fff;*/
/* <!-- ad9271 into ffffff brown-light to green-light --> */
text-align: center;
border: 1px solid #ccc;
padding: 6px 4px;
}
/* Make entire thead sticky */
.fht-table thead {
position: sticky;
top: 0;
z-index: 20;
/* Ensure the entire header stays above table rows */
background-color: #50bbd9;
/* Header background color */
}
.dropdown-menu {
z-index: 25;
}
/* Ensure each <th> in thead stays sticky */
.fht-table thead th {
position: sticky;
top: 0;
z-index: 11;
/* Higher than table rows but lower than first column */
background-color: #50bbd9;
/* Green background */
color: #ffffff;
border: 1px solid #ddd;
white-space: normal;
/* Allows text to wrap */
word-wrap: break-word;
/* Breaks long words if needed */
text-align: center;
/* Centers text for better alignment */
}
/* Sticky First Column */
.fht-table th:nth-child(1),
.fht-table td:nth-child(1) {
position: sticky;
left: 0;
background-color: #50bbd9;
z-index: 15;
/* Ensures it stays above other cells */
border-right: 2px solid #ddd;
color: #ffffff;
}
/* Table Wrapper for Scrolling */
.table-responsive {
overflow-x: auto;
overflow-y: auto;
max-height: 500px;
max-width: 100%;
position: relative;
}
/* Adjust heights based on screen zoom */
@media only screen and (min-height: 1400px) {
/* Approximate Zoom < 100% */
.table-responsive {
max-height: 425px;
}
}
@media only screen and (min-height: 1200px) {
/* Approximate Zoom ~ 90% */
.table-responsive {
max-height: 500px;
}
}
@media only screen and (min-height: 1000px) {
/* Approximate Zoom ~ 80% */
.table-responsive {
max-height: 600px;
}
}
@media only screen and (min-height: 800px) {
/* Approximate Zoom ~ 75% */
.table-responsive {
max-height: 650px;
}
}
td {
min-width: 100px;
max-width: 100px;
}
.location {
min-width: 200px;
min-height: 200px;
}
.description {
min-width: 400px;
min-height: 200px;
}
tfoot tr {
background-color: rgb(235, 236, 203);
}
body[data-layout-mode=horizontal] .container-fluid {
max-width: 100%;
}
.card-body {
padding-top: 0;
padding-bottom: 0;
}
.card {
margin-bottom: 5px;
}
</style>
<!-- generating date options -->
<?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');
}
?>
<!-- generating time options -->
<?php
$timeOptions = [];
foreach (["AM", "PM"] as $meridian) {
for ($hour = 0; $hour < 12; $hour++) {
for ($minute = 0; $minute < 60; $minute += 15) {
$formattedHour = $hour === 0 ? 12 : $hour;
$timeOptions[] = sprintf("%02d:%02d %s", $formattedHour, $minute, $meridian);
}
}
}
$timeOtions[] = "12:00 AM";
?>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-6">
<div class="page-title-box page-title-box-alt">
<div class="page-title-right">
<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 Stock Details </h4>
</li>
</ol>
</div>
</div>
</div>
<div class="col-6 text-right">
<!-- Right-aligned buttons or links can be added here -->
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card" id="fullscreenDiv">
<div class="card-body">
<form id="changeMonthForm" action="<?= base_url('trpProductionDetails'); ?>" method="post">
<div class="row">
<?php $today = date('M-Y'); ?>
<div class="col-2 mt-2">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control "
data-provide="datepicker"
data-date-format="M-yyyy"
data-date-min-view-mode="1" readonly
style="max-width: 175px;">
</div>
<div class="col-10 text-right d-flex" style="justify-content: end;">
<input type="text" id="searchInput" placeholder="Search..."
class="mt-2"
style="padding: 8px;margin-bottom: 10px;width: 150px;border: 1px solid #ccc;
border-radius: 5px;margin-right:15px;">
<i class="fa fa-table btn-lg mt-2"
title="Date Range Filter"
style="font-size: x-large; cursor:pointer;"
data-toggle="modal"
data-target="#filterModalId">
</i>
<i class="fa fa-download btn-lg mt-2"
title="Excel Download"
style="font-size: x-large; cursor:pointer;"
id="trpProductionDetailsExport">
</i>
<i class="fe-maximize noti-icon btn-lg mt-2"
title="Full Screen"
style="font-size: x-large; cursor:pointer;"
onclick="toggleDivFullscreen()">
</i>
<i class="fa fa-save btn-lg mt-2"
title="Save"
style="font-size: x-large; cursor:pointer;"
id="saveId">
</i>
</div>
</div>
</form>
<div class="table-responsive" id="table-responsive">
<table id="trpProductionStockDetailsTableId" class="fht-table ">
<thead class="celda_encabezado_general" style="padding: 10px;">
<tr>
<!-- 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) -->
<?php if (count($wcsSupplierList) > 0) { ?>
<th class="celda_encabezado_general" colspan="<?= count($wcsSupplierList) ?>">Incoming Sand/ Lump details </th>
<?php } ?>
<!-- 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 class="celda_encabezado_general" rowspan="2">Coating </th>
<!-- th:eq(19) -->
<?php if (count($crsClientList) > 0) { ?>
<th class="celda_encabezado_general" colspan="<?= count($crsClientList) ?>">Usage </th>
<?php } ?>
<!-- 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>
</tr>
<tr>
<!-- th:eq(0) -->
<th class="celda_encabezado_general" style="z-index:11;">BG</th>
<!-- th:eq(1) -->
<th class="celda_encabezado_general">PG </th>
<!-- dynamic loop wcs-->
<?php foreach ($wcsSupplierList as $supplier) { ?>
<th class="celda_encabezado_general" style="min-width:200px !important;"><?= $supplier ?> </th>
<?php } ?>
<!-- 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) -->
<!-- dynamic loop crs -->
<?php foreach ($crsClientList as $client) { ?>
<th class="celda_encabezado_general" style="min-width:200px !important;"><?= $client ?> </th>
<?php } ?>
<!-- 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>
</tr>
</thead>
<tbody style="background-color: #fff;">
<?php if (!empty($trpProductionDetails)) {
$totalWcsReceived = 0;
$totalCrsReceived = 0;
// dd(array_keys($trpProductionDetails[0]));
// dd($trpProductionDetails);
?>
<?php foreach ($trpProductionDetails as $trpProductionDetailIndex => $trpProductionDetail) {
?>
<tr id="<?= $trpProductionDetail['date'] ?>"
<?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $trpProductionDetail['date'])->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"';
}
?>>
<!-- date -->
<!-- td:eq(0) -->
<td class="celda_normal trpProductionStock date"
data-id="<?= $trpProductionDetail['date'] ?> date">
<?= $dateInMonthDmYFormat ?>
</td>
<!-- openingTime -->
<!-- td:eq(1) -->
<td class="celda_normal trpProductionStock openingTime"
data-id="<?= $trpProductionDetail['date'] ?> openingTime">
<select class="timeDropdown trp_on_time" style="width: 150px;">
<?php
foreach ($timeOptions as $timeOption) {
?>
<option value="<?= $timeOption ?>"
<?php if ($timeOption == $trpProductionDetail['openingTime']) echo "selected"; ?>>
<?= $timeOption ?>
</option>
<?php
}
?>
</select>
</td>
<!-- closingTime -->
<!-- td:eq(2) -->
<td class="celda_normal trpProductionStock closingTime"
data-id="<?= $trpProductionDetail['date'] ?> closingTime">
<select class="timeDropdown trp_off_time" style="width: 150px;">
<?php
foreach ($timeOptions as $timeOption) {
?>
<option value="<?= $timeOption ?>"
<?php if ($timeOption == $trpProductionDetail['closingTime']) echo "selected"; ?>>
<?= $timeOption ?>
</option>
<?php
}
?>
</select>
</td>
<!-- totalHours -->
<!-- td:eq(3) -->
<td class="celda_normal trpProductionStock totalHours"
data-id="<?= $trpProductionDetail['date'] ?> totalHours">
<?= $trpProductionDetail['totalHours'] ?>
</td>
<!-- coldStart -->
<!-- td:eq(4) -->
<td class="celda_normal trpProductionStock coldStart"
data-id="<?= $trpProductionDetail['date'] ?> coldStart"
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['coldStart'] ?>
</td>
<!-- breakdownHours -->
<!-- td:eq(5) -->
<td class="celda_normal trpProductionStock breakdownHours"
data-id="<?= $trpProductionDetail['date'] ?> breakdownHours"
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['breakdownHours'] ?>
</td>
<!-- burnerFiringHours -->
<!-- td:eq(6) -->
<td class="celda_normal trpProductionStock burnerFiringHours"
data-id="<?= $trpProductionDetail['date'] ?> burnerFiringHours">
<?= $trpProductionDetail['burnerFiringHours'] ?>
</td>
<!-- sandFeedingHours -->
<!-- td:eq(7) -->
<td class="celda_normal trpProductionStock sandFeedingHours"
data-id="<?= $trpProductionDetail['date'] ?> sandFeedingHours">
<?= $trpProductionDetail['sandFeedingHours'] ?>
</td>
<!-- gasReceiptBg -->
<!-- td:eq(8) -->
<td class="celda_normal trpProductionStock gasReceiptBg"
data-id="<?= $trpProductionDetail['date'] ?> gasReceiptBg"
contenteditable="true">
<?= $trpProductionDetail['gasReceiptBg'] ?>
</td>
<!-- gasReceiptPg -->
<!-- td:eq(9) -->
<td class="celda_normal trpProductionStock gasReceiptPg"
data-id="<?= $trpProductionDetail['date'] ?> gasReceiptPg"
contenteditable="true">
<?= $trpProductionDetail['gasReceiptPg'] ?>
</td>
<!-- physicalGasConsumption -->
<!-- td:eq(10) -->
<td class="celda_normal trpProductionStock physicalGasConsumption"
data-id="<?= $trpProductionDetail['date'] ?> physicalGasConsumption"
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['physicalGasConsumption'] ?>
</td>
<!-- drierGasConsumption -->
<!-- td:eq(11) -->
<td class="celda_normal trpProductionStock drierGasConsumption"
data-id="<?= $trpProductionDetail['date'] ?> drierGasConsumption">
<?= $trpProductionDetail['drierGasConsumption'] == 0 ? " " : $trpProductionDetail['drierGasConsumption'] ?>
</td>
<!-- coatingGasConsumption -->
<!-- td:eq(12) -->
<td class="celda_normal trpProductionStock coatingGasConsumption"
data-id="<?= $trpProductionDetail['date'] ?> coatingGasConsumption">
<?= $trpProductionDetail['coatingGasConsumption'] ?>
</td>
<!-- trpPlusDrierGasConsumption -->
<!-- td:eq(13) -->
<td class="celda_normal trpProductionStock trpPlusDrierGasConsumption"
data-id="<?= $trpProductionDetail['date'] ?> trpPlusDrierGasConsumption">
<?= $trpProductionDetail['trpPlusDrierGasConsumption'] ?>
</td>
<!-- trpPhysicalGasPerTon -->
<!-- td:eq(14) -->
<td class="celda_normal trpProductionStock trpPhysicalGasPerTon"
data-id="<?= $trpProductionDetail['date'] ?> trpPhysicalGasPerTon">
<?= $trpPhysicalGasPerTon = $trpProductionDetail['trpPhysicalGasPerTon'] ?>
</td>
<!-- panelGasConsumption -->
<!-- td:eq(15) -->
<td class="celda_normal trpProductionStock panelGasConsumption"
data-id="<?= $trpProductionDetail['date'] ?> panelGasConsumption"
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['panelGasConsumption'] ?>
</td>
<!-- panelGasPerTon -->
<!-- td:eq(16) -->
<td class="celda_normal trpProductionStock panelGasPerTon"
data-id="<?= $trpProductionDetail['date'] ?> panelGasPerTon">
<?= $trpProductionDetail['panelGasPerTon'] ?>
</td>
<!-- loop for wcs supplier list -->
<?php foreach ($wcsSupplierList as $supplier) { ?>
<!-- td:eq(17) -->
<td class="celda_normal trpProductionStock <?= $supplier ?>"
data-id="<?= $trpProductionDetail['date'] ?> <?= $supplier ?>">
<?= $trpProductionDetail[$supplier] == 0 ? " " : $trpProductionDetail[$supplier] ?>
</td>
<?php } ?>
<!-- edRunningHours -->
<!-- td:eq(24) -->
<td class="celda_normal trpProductionStock edRunningHours"
data-id="<?= $trpProductionDetail['date'] ?> edRunningHours"
contenteditable="true">
<?= $trpProductionDetail['edRunningHours'] ?>
</td>
<!-- edProduction -->
<!-- td:eq(25) -->
<td class="celda_normal trpProductionStock edProduction"
data-id="<?= $trpProductionDetail['date'] ?> edProduction"
contenteditable="true">
<?= $trpProductionDetail['edProduction'] ?>
</td>
<!-- edUsage -->
<!-- td:eq(26) -->
<td class="celda_normal trpProductionStock edUsage"
data-id="<?= $trpProductionDetail['date'] ?> edUsage"
contenteditable="true">
<?= $trpProductionDetail['edUsage'] ?>
</td>
<!-- trpProduction -->
<!-- td:eq(27) -->
<td class="celda_normal trpProductionStock trpProduction"
data-id="<?= $trpProductionDetail['date'] ?> trpProduction"
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['trpProduction'] ?>
</td>
<!-- trpProductionPerHour -->
<!-- td:eq(28) -->
<td class="celda_normal trpProductionStock trpProductionPerHour"
data-id="<?= $trpProductionDetail['date'] ?> trpProductionPerHour">
<?= $trpProductionDetail['trpProductionPerHour'] ?>
</td>
<!-- coating -->
<!-- td:eq(29) -->
<td class="celda_normal trpProductionStock coating"
data-id="<?= $trpProductionDetail['date'] ?> coating">
<?= $trpProductionDetail['coating'] == 0 ? " " : $trpProductionDetail['coating'] ?>
</td>
<!-- loop for crs client ..!! -->
<?php foreach ($crsClientList as $client) { ?>
<!-- td:eq(17) -->
<td class="celda_normal trpProductionStock <?= $client ?>"
data-id="<?= $trpProductionDetail['date'] ?> <?= $client ?>">
<?= $trpProductionDetail[$client] == 0 ? " " : $trpProductionDetail[$client] ?>
</td>
<?php } ?>
<!-- waterReceipt -->
<!-- td:eq(35) -->
<td class="celda_normal trpProductionStock waterReceipt"
data-id="<?= $trpProductionDetail['date'] ?> waterReceipt"
contenteditable="true">
<?= $trpProductionDetail['waterReceipt'] ?>
</td>
<!-- waterConsumption -->
<!-- td:eq(36) -->
<td class="celda_normal trpProductionStock waterConsumption"
data-id="<?= $trpProductionDetail['date'] ?> waterConsumption"
contenteditable="true">
<?= $trpProductionDetail['waterConsumption'] ?>
</td>
<!-- ebReading -->
<!-- td:eq(37) -->
<td class="celda_normal trpProductionStock ebReading"
data-id="<?= $trpProductionDetail['date'] ?> ebReading"
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['ebReading'] ?>
</td>
<!-- ebReadingPerUnitTon -->
<!-- td:eq(38) -->
<td class="celda_normal trpProductionStock ebReadingPerUnitTon"
data-id="<?= $trpProductionDetail['date'] ?> ebReadingPerUnitTon">
<?= $trpProductionDetail['ebReadingPerUnitTon'] ?>
</td>
<!-- workingPersonEngineers -->
<!-- td:eq(39) -->
<td class="celda_normal trpProductionStock workingPersonEngineers"
data-id="<?= $trpProductionDetail['date'] ?> workingPersonEngineers"
contenteditable="true">
<?= $trpProductionDetail['workingPersonEngineers'] ?>
</td>
<!-- workingPersonSupervisiors -->
<!-- td:eq(40) -->
<td class="celda_normal trpProductionStock workingPersonSupervisiors"
data-id="<?= $trpProductionDetail['date'] ?> workingPersonSupervisiors"
contenteditable="true">
<?= $trpProductionDetail['workingPersonSupervisiors'] ?>
</td>
<!-- workingPersonOperators -->
<!-- td:eq(41) -->
<td class="celda_normal trpProductionStock workingPersonOperators"
data-id="<?= $trpProductionDetail['date'] ?> workingPersonOperators"
contenteditable="true">
<?= $trpProductionDetail['workingPersonOperators'] ?>
</td>
<!-- rollerDrivers -->
<!-- td:eq(42) -->
<td class="celda_normal trpProductionStock rollerDrivers"
data-id="<?= $trpProductionDetail['date'] ?> rollerDrivers"
contenteditable="true">
<?= $trpProductionDetail['rollerDrivers'] ?>
</td>
<!-- natureOfMaintenance -->
<!-- td:eq(43) -->
<td class="celda_normal trpProductionStock natureOfMaintenance"
data-id="<?= $trpProductionDetail['date'] ?> natureOfMaintenance"
contenteditable="true">
<?= $trpProductionDetail['natureOfMaintenance'] ?>
</td>
<!-- location -->
<!-- td:eq(44) -->
<td class="celda_normal trpProductionStock location"
data-id="<?= $trpProductionDetail['date'] ?> location"
contenteditable="true">
<?= $trpProductionDetail['location'] ?>
</td>
<!-- description -->
<!-- td:eq(45) -->
<td class="celda_normal trpProductionStock description"
data-id="<?= $trpProductionDetail['date'] ?> description"
contenteditable="true">
<?= $trpProductionDetail['description'] ?>
</td>
<!-- msSeperation -->
<!-- td:eq(46) -->
<td class="celda_normal trpProductionStock msSeperation"
data-id="<?= $trpProductionDetail['date'] ?> msSeperation"
contenteditable="true">
<?= $trpProductionDetail['msSeperation'] ?>
</td>
<!-- edWaste -->
<!-- td:eq(47) -->
<td class="celda_normal trpProductionStock edWaste"
data-id="<?= $trpProductionDetail['date'] ?> edWaste"
contenteditable="true">
<?= $trpProductionDetail['edWaste'] ?>
</td>
<!-- coolerBags -->
<!-- td:eq(48) -->
<td class="celda_normal trpProductionStock coolerBags"
data-id="<?= $trpProductionDetail['date'] ?> coolerBags"
contenteditable="true">
<?= $trpProductionDetail['coolerBags'] ?>
</td>
<!-- edPlus20Waste -->
<!-- td:eq(49) -->
<td class="celda_normal trpProductionStock edPlus20Waste"
data-id="<?= $trpProductionDetail['date'] ?> edPlus20Waste"
contenteditable="true">
<?= $trpProductionDetail['edPlus20Waste'] ?>
</td>
<!--cycloneWaste -->
<!-- td:eq(50) -->
<td class="celda_normal trpProductionStock cycloneWaste"
data-id="<?= $trpProductionDetail['date'] ?> cycloneWaste"
contenteditable="true">
<?= $trpProductionDetail['cycloneWaste'] ?>
</td>
</tr>
<?php
//before closing inner loop we just adding the total values insidde it
$eachDate = $trpProductionDetail['date']; // Unique identifier
// Initialize the date entry if it doesn't exist
if (!isset($summary['totalHours'])) {
$summary = [
'totalHours' => 0,
'coldStart' => 0,
'breakdownHours' => 0,
'burnerFiringHours' => 0,
'sandFeedingHours' => 0,
'gasReceiptBg' => 0,
'gasReceiptPg' => 0,
'physicalGasConsumption' => 0,
'drierGasConsumption' => 0,
'coatingGasConsumption' => 0,
'trpPlusDrierGasConsumption' => 0,
'trpPhysicalGasPerTon' => 0,
'panelGasConsumption' => 0,
'panelGasPerTon' => 0,
'edRunningHours' => 0,
'edProduction' => 0,
'edUsage' => 0,
'trpProduction' => 0,
'trpProductionPerHour' => 0,
'coating' => 0,
'waterReceipt' => 0,
'waterConsumption' => 0,
'ebReading' => 0,
'ebReadingPerUnitTon' => 0,
'workingPersonEngineers' => 0,
'workingPersonSupervisiors' => 0,
'workingPersonOperators' => 0,
'msSeperation' => 0,
'edWaste' => 0,
'coolerBags' => 0,
'edPlus20Waste' => 0,
'cycloneWaste' => 0
];
foreach ($crsClientList as $client) {
$summary[$client] = 0;
}
foreach ($wcsSupplierList as $supplier) {
$summary[$supplier] = 0;
}
}
// Sum values for the material
$summary['totalHours'] += is_numeric($trpProductionDetail['totalHours']) ? $trpProductionDetail['totalHours'] : 0;
$summary['coldStart'] += is_numeric($trpProductionDetail['coldStart']) ? $trpProductionDetail['coldStart'] : 0;
$summary['breakdownHours'] += is_numeric($trpProductionDetail['breakdownHours']) ? $trpProductionDetail['breakdownHours'] : 0;
$summary['burnerFiringHours'] += is_numeric($trpProductionDetail['burnerFiringHours']) ? $trpProductionDetail['burnerFiringHours'] : 0;
$summary['sandFeedingHours'] += is_numeric($trpProductionDetail['sandFeedingHours']) ? $trpProductionDetail['sandFeedingHours'] : 0;
$summary['gasReceiptBg'] += is_numeric($trpProductionDetail['gasReceiptBg']) ? $trpProductionDetail['gasReceiptBg'] : 0;
$summary['gasReceiptPg'] += is_numeric($trpProductionDetail['gasReceiptPg']) ? $trpProductionDetail['gasReceiptPg'] : 0;
$summary['physicalGasConsumption'] += is_numeric($trpProductionDetail['physicalGasConsumption']) ? $trpProductionDetail['physicalGasConsumption'] : 0;
$summary['drierGasConsumption'] += is_numeric($trpProductionDetail['drierGasConsumption']) ? $trpProductionDetail['drierGasConsumption'] : 0;
$summary['coatingGasConsumption'] += is_numeric($trpProductionDetail['coatingGasConsumption']) ? $trpProductionDetail['coatingGasConsumption'] : 0;
$summary['trpPlusDrierGasConsumption'] += is_numeric($trpProductionDetail['trpPlusDrierGasConsumption']) ? $trpProductionDetail['trpPlusDrierGasConsumption'] : 0;
$summary['trpPhysicalGasPerTon'] += is_numeric($trpProductionDetail['trpPhysicalGasPerTon']) ? $trpProductionDetail['trpPhysicalGasPerTon'] : 0;
$summary['panelGasConsumption'] += is_numeric($trpProductionDetail['panelGasConsumption']) ? $trpProductionDetail['panelGasConsumption'] : 0;
$summary['panelGasPerTon'] += is_numeric($trpProductionDetail['panelGasPerTon']) ? $trpProductionDetail['panelGasPerTon'] : 0;
//total of all incoming waste core sand
foreach ($wcsSupplierList as $supplier) {
$summary[$supplier] += is_numeric($trpProductionDetail[$supplier]) ? $trpProductionDetail[$supplier] : 0;
$totalWcsReceived += is_numeric($trpProductionDetail[$supplier]) ? $trpProductionDetail[$supplier] : 0;
}
$summary['edRunningHours'] += is_numeric($trpProductionDetail['edRunningHours']) ? $trpProductionDetail['edRunningHours'] : 0;
$summary['edProduction'] += is_numeric($trpProductionDetail['edProduction']) ? $trpProductionDetail['edProduction'] : 0;
$summary['edUsage'] += is_numeric($trpProductionDetail['edUsage']) ? $trpProductionDetail['edUsage'] : 0;
$summary['trpProduction'] += is_numeric($trpProductionDetail['trpProduction']) ? $trpProductionDetail['trpProduction'] : 0;
$summary['trpProductionPerHour'] += is_numeric($trpProductionDetail['trpProductionPerHour']) ? $trpProductionDetail['trpProductionPerHour'] : 0;
$summary['coating'] += is_numeric($trpProductionDetail['coating']) ? $trpProductionDetail['coating'] : 0;
// total of all core reclaimed sand
foreach ($crsClientList as $client) {
$summary[$client] += is_numeric($trpProductionDetail[$client]) ? $trpProductionDetail[$client] : 0;
$totalCrsReceived += is_numeric($trpProductionDetail[$client]) ? $trpProductionDetail[$client] : 0;
}
$summary['waterReceipt'] += is_numeric($trpProductionDetail['waterReceipt']) ? $trpProductionDetail['waterReceipt'] : 0;
$summary['waterConsumption'] += is_numeric($trpProductionDetail['waterConsumption']) ? $trpProductionDetail['waterConsumption'] : 0;
$summary['ebReading'] += is_numeric($trpProductionDetail['ebReading']) ? $trpProductionDetail['ebReading'] : 0;
$summary['ebReadingPerUnitTon'] += is_numeric($trpProductionDetail['ebReadingPerUnitTon']) ? $trpProductionDetail['ebReadingPerUnitTon'] : 0;
$summary['workingPersonEngineers'] += is_numeric($trpProductionDetail['workingPersonEngineers']) ? $trpProductionDetail['workingPersonEngineers'] : 0;
$summary['workingPersonSupervisiors'] += is_numeric($trpProductionDetail['workingPersonSupervisiors']) ? $trpProductionDetail['workingPersonSupervisiors'] : 0;
$summary['workingPersonOperators'] += is_numeric($trpProductionDetail['workingPersonOperators']) ? $trpProductionDetail['workingPersonOperators'] : 0;
$summary['msSeperation'] += is_numeric($trpProductionDetail['msSeperation']) ? $trpProductionDetail['msSeperation'] : 0;
$summary['edWaste'] += is_numeric($trpProductionDetail['edWaste']) ? $trpProductionDetail['edWaste'] : 0;
$summary['coolerBags'] += is_numeric($trpProductionDetail['coolerBags']) ? $trpProductionDetail['coolerBags'] : 0;
$summary['edPlus20Waste'] += is_numeric($trpProductionDetail['edPlus20Waste']) ? $trpProductionDetail['edPlus20Waste'] : 0;
$summary['cycloneWaste'] += is_numeric($trpProductionDetail['cycloneWaste']) ? $trpProductionDetail['cycloneWaste'] : 0;
} ?>
<tfoot>
<tr>
<!-- Total -->
<!-- td:eq(0) -->
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<!-- openingTime -->
<!-- td:eq(1) -->
<td class="celda_normal">
</td>
<!-- closingTime -->
<!-- td:eq(2) -->
<td class="celda_normal">
</td>
<!-- totalHours -->
<!-- td:eq(3) -->
<td class="celda_normal ">
<?= $summary['totalHours'] ?>
</td>
<!-- coldStart -->
<!-- td:eq(4) -->
<td class="celda_normal">
<?= $summary['coldStart'] ?>
</td>
<!-- breakdownHours -->
<!-- td:eq(5) -->
<td class="celda_normal">
<?= $summary['breakdownHours'] ?>
</td>
<!-- burnerFiringHours -->
<!-- td:eq(6) -->
<td class="celda_normal ">
<?= $summary['burnerFiringHours'] ?>
</td>
<!-- sandFeedingHours -->
<!-- td:eq(7) -->
<td class="celda_normal">
<?= $summary['sandFeedingHours'] ?>
</td>
<!-- gasReceiptBg -->
<!-- td:eq(8) -->
<td class="celda_normal">
<?= $summary['gasReceiptBg'] ?>
</td>
<!-- gasReceiptPg -->
<!-- td:eq(9) -->
<td class="celda_normal">
<?= $summary['gasReceiptPg'] ?>
</td>
<!-- physicalGasConsumption -->
<!-- td:eq(10) -->
<td class="celda_normal">
<?= $summary['physicalGasConsumption'] ?>
</td>
<!-- drierGasConsumption -->
<!-- td:eq(11) -->
<td class="celda_normal">
<?= $summary['drierGasConsumption'] ?>
</td>
<!-- coatingGasConsumption -->
<!-- td:eq(12) -->
<td class="celda_normal">
<?= $summary['coatingGasConsumption'] ?>
</td>
<!-- trpPlusDrierGasConsumption -->
<!-- td:eq(13) -->
<td class="celda_normal">
<?= $summary['trpPlusDrierGasConsumption'] ?>
</td>
<!-- trpPhysicalGasPerTon -->
<!-- td:eq(14) -->
<td class="celda_normal">
<?= $summary['trpPhysicalGasPerTon'] ?>
</td>
<!-- panelGasConsumption -->
<!-- td:eq(15) -->
<td class="celda_normal">
<?= $summary['panelGasConsumption'] ?>
</td>
<!-- panelGasPerTon -->
<!-- td:eq(16) -->
<td class="celda_normal">
<?= $summary['panelGasPerTon'] ?>
</td>
<?php
foreach ($wcsSupplierList as $supplier) { ?>
<td class="celda_normal">
<?= $summary[$supplier] ?>
</td>
<?php } ?>
<!-- edRunningHours -->
<!-- td:eq(24) -->
<td class="celda_normal">
<?= $summary['edRunningHours'] ?>
</td>
<!-- edProduction -->
<!-- td:eq(25) -->
<td class="celda_normal">
<?= $summary['edProduction'] ?>
</td>
<!-- edUsage -->
<!-- td:eq(26) -->
<td class="celda_normal">
<?= $summary['edUsage'] ?>
</td>
<!-- trpProduction -->
<!-- td:eq(27) -->
<td class="celda_normal">
<?= $summary['trpProduction'] ?>
</td>
<!-- trpProductionPerHour -->
<!-- td:eq(28) -->
<td class="celda_normal">
<?= $summary['trpProductionPerHour'] ?>
</td>
<!-- coating -->
<!-- td:eq(29) -->
<td class="celda_normal">
<?= $summary['coating'] ?>
</td>
<?php
foreach ($crsClientList as $client) { ?>
<td class="celda_normal">
<?= $summary[$client] ?>
</td>
<?php } ?>
<!-- waterReceipt -->
<!-- td:eq(35) -->
<td class="celda_normal">
<?= $summary['waterReceipt'] ?>
</td>
<!-- waterConsumption -->
<!-- td:eq(36) -->
<td class="celda_normal">
<?= $summary['waterConsumption'] ?>
</td>
<!-- ebReading -->
<!-- td:eq(37) -->
<td class="celda_normal">
<?= $summary['ebReading'] ?>
</td>
<!-- ebReadingPerUnitTon -->
<!-- td:eq(38) -->
<td class="celda_normal">
<?= $summary['ebReadingPerUnitTon'] ?>
</td>
<!-- workingPersonEngineers -->
<!-- td:eq(39) -->
<td class="celda_normal">
<?= $summary['workingPersonEngineers'] ?>
</td>
<!-- workingPersonSupervisiors -->
<!-- td:eq(40) -->
<td class="celda_normal">
<?= $summary['workingPersonSupervisiors'] ?>
</td>
<!-- workingPersonOperators -->
<!-- td:eq(41) -->
<td class="celda_normal">
<?= $summary['workingPersonOperators'] ?>
</td>
<!-- rollerDrivers -->
<!-- td:eq(42) -->
<td class="celda_normal">
<?= " " ?>
</td>
<!-- natureOfMaintenance -->
<!-- td:eq(43) -->
<td class="celda_normal">
<?= " " ?>
</td>
<!-- location -->
<!-- td:eq(44) -->
<td class="celda_normal location">
<?= " " ?>
</td>
<!-- description -->
<!-- td:eq(45) -->
<td class="celda_normal description">
<?= " " ?>
</td>
<!-- msSeperation -->
<!-- td:eq(46) -->
<td class="celda_normal">
<?= $summary['msSeperation'] ?>
</td>
<!-- edWaste -->
<!-- td:eq(47) -->
<td class="celda_normal">
<?= $summary['edWaste'] ?>
</td>
<!-- coolerBags -->
<!-- td:eq(48) -->
<td class="celda_normal">
<?= $summary['coolerBags'] ?>
</td>
<!-- edPlus20Waste -->
<!-- td:eq(49) -->
<td class="celda_normal">
<?= $summary['edPlus20Waste'] ?>
</td>
<!--cycloneWaste -->
<!-- td:eq(50) -->
<td class="celda_normal">
<?= $summary['cycloneWaste'] ?>
</td>
</tr>
</tfoot>
<?php } ?>
</tbody>
</table>
</div>
</div>
<br>
</div> <!-- End card-body -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-2">
</div>
<div class="col">
<!-- right now client is not using this -->
<!-- <a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a> -->
<h4 class="mt-3" style="text-align:center">Abstract for the month <?= $month ?></h4>
</div>
<div class="col-2">
<a href="#">
<i class="fa fa-download btn-lg mt-2"
style="font-size: x-large;"
id="trpAbstractDetailsExport">
</i>
</a>
<input type="button" class="btn btn-success px-4 mb-3" id="abstractSaveId" value="Save">
</div>
<div class="col-1">
</div>
</div>
<div class="table-responsive" align="center">
<table id="abstractTableId" class="fht-table ">
<thead class="celda_encabezado_general" style="padding: 10px ;">
<tr>
<th class="celda_encabezado_general" style="width: 200px;">Particulars</th>
<th class="celda_encabezado_general">Running Hours</th>
<th class="celda_encabezado_general">Per Hour</th>
<th class="celda_encabezado_general">Opening Stock</th>
<th class="celda_encabezado_general">Receipt</th>
<th class="celda_encabezado_general">Total</th>
<th class="celda_encabezado_general">Consumption</th>
<th class="celda_encabezado_general">Closing Stock</th>
<th class="celda_encabezado_general">Physical Stock</th>
<th class="celda_encabezado_general" style="width: 200px;">Remarks</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($trpAbstract)) {
$abstractForCurrentMonth = [
[
'absDate' => $trpAbstract["Incoming Raw Sand Details"]['date'],
'absParticulars' => "Incoming Raw Sand Details",
'absRunningHrs' => "",
'absPerHour' => "",
'absOpeningStock' => (int)$trpAbstract["Incoming Raw Sand Details"]['opening_stock'],
'absReceipt' => $totalWcsReceived,
'absTotal' => (int)$trpAbstract["Incoming Raw Sand Details"]['opening_stock'] + $totalWcsReceived,
'absConsumption' => $summary['edProduction'],
'absClosingStock' => ((int)$trpAbstract["Incoming Raw Sand Details"]['opening_stock'] + $totalWcsReceived) - $summary['edProduction'],
'absPhysicalStock' => (int)$trpAbstract["Incoming Raw Sand Details"]['physical_stock'],
'absRemarks' => $trpAbstract["Incoming Raw Sand Details"]['remarks'],
],
[
'absDate' => $trpAbstract["ED Details"]['date'],
'absParticulars' => "ED Details",
'absRunningHrs' => $summary['edRunningHours'],
'absPerHour' => number_format($summary['edProduction'] / ($summary['edRunningHours'] == 0 ? 1 : $summary['edRunningHours']), 2),
'absOpeningStock' => (int)$trpAbstract["ED Details"]['opening_stock'],
'absReceipt' => $summary['edProduction'],
'absTotal' => (int)$trpAbstract["ED Details"]['opening_stock'] + $summary['edProduction'],
'absConsumption' => $summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250),
'absClosingStock' => (int)$trpAbstract["ED Details"]['opening_stock'] + $summary['edProduction'] - ($summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250)),
'absPhysicalStock' => (int)$trpAbstract["ED Details"]['physical_stock'],
'absRemarks' => $trpAbstract["ED Details"]['remarks'],
],
[
'absDate' => $trpAbstract["TRP Total Sand"]['date'],
'absParticulars' => "TRP Total Sand",
'absRunningHrs' => $summary['sandFeedingHours'],
'absPerHour' => $summary['trpProductionPerHour'],
'absOpeningStock' => (int)$trpAbstract["TRP Total Sand"]['opening_stock'],
'absReceipt' => $summary['trpProduction'],
'absTotal' => (int)$trpAbstract["TRP Total Sand"]['opening_stock'] + $summary['trpProduction'],
'absConsumption' => $totalCrsReceived,
'absClosingStock' => (int)$trpAbstract["TRP Total Sand"]['opening_stock'] + $summary['trpProduction'] - $totalCrsReceived,
'absPhysicalStock' => (int)$trpAbstract["TRP Total Sand"]['physical_stock'],
'absRemarks' => $trpAbstract["TRP Total Sand"]['remarks'],
],
[
'absDate' => $trpAbstract["Trp Physical Gas Consumption"]['date'],
'absParticulars' => "Trp Physical Gas Consumption",
'absRunningHrs' => "",
'absPerHour' => number_format(($summary['trpPlusDrierGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2, '.', ''),
'absOpeningStock' => (int)$trpAbstract["Trp Physical Gas Consumption"]['opening_stock'],
'absReceipt' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'],
'absTotal' => (int)$trpAbstract["Trp Physical Gas Consumption"]['opening_stock'] + $summary['gasReceiptBg'] + $summary['gasReceiptPg'],
'absConsumption' => $summary['physicalGasConsumption'],
'absClosingStock' => (int)$trpAbstract["Trp Physical Gas Consumption"]['opening_stock'] + $summary['gasReceiptBg'] + $summary['gasReceiptPg'] - $summary['physicalGasConsumption'],
'absPhysicalStock' => (int)$trpAbstract["Trp Physical Gas Consumption"]['physical_stock'],
'absRemarks' => $trpAbstract["Trp Physical Gas Consumption"]['remarks'],
],
[
'absDate' => $trpAbstract["Trp Panel Gas Consumption"]['date'],
'absParticulars' => "Trp Panel Gas Consumption",
'absRunningHrs' => "",
'absPerHour' => number_format(($summary['panelGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2),
'absOpeningStock' => (int)$trpAbstract["Trp Panel Gas Consumption"]['opening_stock'],
'absReceipt' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'],
'absTotal' => (int)$trpAbstract["Trp Panel Gas Consumption"]['opening_stock'] + $summary['gasReceiptBg'] + $summary['gasReceiptPg'],
'absConsumption' => $summary['panelGasConsumption'],
'absClosingStock' => (int)$trpAbstract["Trp Panel Gas Consumption"]['opening_stock'] + $summary['gasReceiptBg'] + $summary['gasReceiptPg'] - $summary['panelGasConsumption'],
'absPhysicalStock' => (int)$trpAbstract["Trp Panel Gas Consumption"]['physical_stock'],
'absRemarks' => $trpAbstract["Trp Panel Gas Consumption"]['remarks'],
],
[
'absDate' => $trpAbstract["Water Consumption"]['date'],
'absParticulars' => "Water Consumption",
'absRunningHrs' => "",
'absPerHour' => "",
'absOpeningStock' => (int)$trpAbstract["Water Consumption"]['opening_stock'],
'absReceipt' => $summary['waterReceipt'],
'absTotal' => (int)$trpAbstract["Water Consumption"]['opening_stock'] + $summary['waterReceipt'],
'absConsumption' => $summary['waterConsumption'],
'absClosingStock' => (int)$trpAbstract["Water Consumption"]['opening_stock'] + $summary['waterReceipt'] - $summary['waterConsumption'],
'absPhysicalStock' => (int)$trpAbstract["Water Consumption"]['physical_stock'],
'absRemarks' => $trpAbstract["Water Consumption"]['remarks'],
],
[
'absDate' => $trpAbstract["Power Consumption"]['date'],
'absParticulars' => "Power Consumption",
'absRunningHrs' => $summary['ebReadingPerUnitTon'],
'absPerHour' => "",
'absOpeningStock' => (int)$trpAbstract["Power Consumption"]['opening_stock'],
'absReceipt' => '',
'absTotal' => '',
'absConsumption' => $summary['ebReading'],
'absClosingStock' => '',
'absPhysicalStock' => (int)$trpAbstract["Power Consumption"]['physical_stock'],
'absRemarks' => $trpAbstract["Power Consumption"]['remarks'],
]
];
?>
<?php foreach ($abstractForCurrentMonth as $abstract) {
$absDate = DateTime::createFromFormat('M-Y', $month)->format('Y-m');
$absDate = "$absDate-01";
?>
<tr>
<!-- particulars -->
<td class="celda_normal absParticulars"><?= $abstract['absParticulars'] ?> </td>
<!-- running hours no need -->
<td class="celda_normal absRunningHrs"><?= $abstract['absRunningHrs'] ?></td>
<!-- per hour no need -->
<td class="celda_normal absPerHour"><?= $abstract['absPerHour'] ?></td>
<!-- opening stock be -->
<td class="celda_normal absOpeningStock"
oninput="absOpeningStockChange(this)"
contenteditable="true"><?= $abstract['absOpeningStock'] ?></td>
<!-- receipt total of all incoming waste core sand-->
<td class="celda_normal absReceipt"><?= $abstract['absReceipt'] ?> </td>
<!-- Total fe -->
<td class="celda_normal absTotal"><?= $abstract['absTotal'] ?></td>
<!-- consumption fe-->
<td class="celda_normal absConsumption"><?= $abstract['absConsumption'] ?></td>
<!-- closing stock fe -->
<td class="celda_normal absClosingStock"><?= $abstract['absClosingStock'] ?> </td>
<!-- physical stock be -->
<td class="celda_normal absPhysicalStock"
contenteditable="true"> <?= $abstract['absPhysicalStock'] ?> </td>
<!-- remarks be -->
<td class="celda_normal absRemarks"
contenteditable="true"> <?= $abstract['absRemarks'] ?> </td>
<!-- absDate -->
<td class="absDate" style="display:none"> <?= $absDate; ?> </td>
</tr>
<?php } ?>
<?php } else {
$abstractForCurrentMonth = [
[
'absParticulars' => "Incoming Raw Sand Details",
'absRunningHrs' => "",
'absPerHour' => "",
'absOpeningStock' => '',
'absReceipt' => $totalWcsReceived,
'absTotal' => $totalWcsReceived,
'absConsumption' => $summary['edProduction'],
'absClosingStock' => ($totalWcsReceived) - $summary['edProduction'],
'absPhysicalStock' => '',
'absRemarks' => '',
],
[
'absParticulars' => "ED Details",
'absRunningHrs' => $summary['edRunningHours'],
'absPerHour' => number_format($summary['edProduction'] / ($summary['edRunningHours'] == 0 ? 1 : $summary['edRunningHours']), 2),
'absOpeningStock' => '',
'absReceipt' => $summary['edProduction'],
'absTotal' => $summary['edProduction'],
'absConsumption' => $summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250),
'absClosingStock' => $summary['edProduction'] - $summary['edUsage'] + ($summary['coolerBags'] * 1250) + ($summary['cycloneWaste'] * 1250) + ($summary['edWaste'] * 1250),
'absPhysicalStock' => '',
'absRemarks' => '',
],
[
'absParticulars' => "TRP Total Sand",
'absRunningHrs' => $summary['sandFeedingHours'],
'absPerHour' => $summary['trpProductionPerHour'],
'absOpeningStock' => '',
'absReceipt' => $summary['trpProduction'],
'absTotal' => $summary['trpProduction'],
'absConsumption' => $totalCrsReceived,
'absClosingStock' => $summary['trpProduction'] - $totalCrsReceived,
'absPhysicalStock' => '',
'absRemarks' => '',
],
[
'absParticulars' => "Trp Physical Gas Consumption",
'absRunningHrs' => "",
'absPerHour' => number_format(($summary['trpPlusDrierGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2, '.', ''),
'absOpeningStock' => '',
'absReceipt' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'],
'absTotal' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'],
'absConsumption' => $summary['physicalGasConsumption'],
'absClosingStock' => ($summary['gasReceiptBg'] + $summary['gasReceiptPg']) - $summary['physicalGasConsumption'],
'absPhysicalStock' => '',
'absRemarks' => '',
],
[
'absParticulars' => "Trp Panel Gas Consumption",
'absRunningHrs' => "",
'absPerHour' => number_format(($summary['panelGasConsumption']) / (($summary['trpProduction'] == 0 ? 1000 : $summary['trpProduction']) / 1000), 2),
'absOpeningStock' => '',
'absReceipt' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'],
'absTotal' => $summary['gasReceiptBg'] + $summary['gasReceiptPg'],
'absConsumption' => $summary['panelGasConsumption'],
'absClosingStock' => ($summary['gasReceiptBg'] + $summary['gasReceiptPg']) - $summary['panelGasConsumption'],
'absPhysicalStock' => '',
'absRemarks' => '',
],
[
'absParticulars' => "Water Consumption",
'absRunningHrs' => "",
'absPerHour' => "",
'absOpeningStock' => '',
'absReceipt' => $summary['waterReceipt'],
'absTotal' => $summary['waterReceipt'],
'absConsumption' => $summary['waterReceipt'] - $summary['waterConsumption'],
'absClosingStock' => '',
'absPhysicalStock' => '',
'absRemarks' => '',
],
[
'absParticulars' => "Power Consumption",
'absRunningHrs' => $summary['ebReadingPerUnitTon'],
'absPerHour' => "",
'absOpeningStock' => '',
'absReceipt' => '',
'absTotal' => '',
'absConsumption' => $summary['ebReading'],
'absClosingStock' => '',
'absPhysicalStock' => '',
'absRemarks' => '',
],
]
?>
<?php foreach ($abstractForCurrentMonth as $abstract) {
$absDate = DateTime::createFromFormat('M-Y', $month)->format('Y-m');
$absDate = "$absDate-01";
?>
<tr>
<!-- particulars -->
<td class="celda_normal absParticulars"><?= $abstract['absParticulars'] ?></td>
<!-- running hours no need -->
<td class="celda_normal absRunningHrs"><?= $abstract['absRunningHrs'] ?></td>
<!-- per hour no need -->
<td class="celda_normal absPerHour"><?= $abstract['absPerHour'] ?></td>
<!-- opening stock be -->
<td class="celda_normal absOpeningStock"
oninput="absOpeningStockChange(this)"
contenteditable="true"><?= $abstract['absOpeningStock'] ?></td>
<!-- receipt total of all incoming waste core sand-->
<td class="celda_normal absReceipt"><?= $abstract['absReceipt'] ?> </td>
<!-- Total fe -->
<td class="celda_normal absTotal"><?= $abstract['absTotal'] ?></td>
<!-- consumption fe-->
<td class="celda_normal absConsumption"><?= $abstract['absConsumption'] ?></td>
<!-- closing stock fe -->
<td class="celda_normal absClosingStock"><?= $abstract['absClosingStock'] ?> </td>
<!-- physical stock be -->
<td class="celda_normal absPhysicalStock"
contenteditable="true"> <?= $abstract['absPhysicalStock'] ?> </td>
<!-- remarks be -->
<td class="celda_normal absRemarks"
contenteditable="true"> <?= $abstract['absRemarks'] ?> </td>
<!-- absDate -->
<td class="absDate" style="display:none"> <?= $absDate; ?> </td>
</tr>
<?php } ?>
<?php }
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div> <!-- End card -->
</div> <!-- End col -->
</div> <!-- End row -->
</div>
</div> <!-- End container-fluid -->
</div>
</div>
<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-md">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myLargeModalLabel">Navigation Options</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="row">
<!-- Date Dropdown -->
<div class="col-md-6">
<div class="form-group">
<label for="dateDropdown">Select Date</label>
<select id="dateDropdown" class="form-control">
<?php foreach ($datesInMonth as $selectDate): ?>
<?php $selectDate = DateTime::createFromFormat('Y-m-d', $selectDate)->format('d-m-Y'); ?>
<option value="<?= $selectDate ?>"><?= $selectDate ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
<button class="btn btn-primary float-right" onclick="navigateToResin()">Navigate</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
<!-- JAVASCRIPT CODE -->
<script type="text/javascript">
$(document).ready(function() {
$('#saveId').click(function() {
//table to json function
var updateTrpProductionDetails = tableToJsonTrp();
alert('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updateTrpProductionDetails
},
type: "POST",
url: "<?php echo base_url(); ?>updateTrpProductionDetails",
success: function(data) {
if (data) {
$('#loader').hide();
console.log(data);
alert(data);
window.location.reload();
}
},
error: function(xhr, status, error) {
alert("An error occurred while processing the request. Please try again.");
console.error("Error Code:", xhr.status);
console.error("Error Message:", error);
console.error("Response Text:", xhr.responseText);
},
complete: function() {
$('#loader').hide();
}
});
});
});
</script>
<script>
function tableToJsonTrp() {
const table = $('#trpProductionStockDetailsTableId');
const rows = [];
//this table to json is customized for bagstock not for all
table.find('tbody tr').each(function() {
const rowCells = $(this).find('td');
const date = rowCells.eq(0).text().trim(); //dmY format
let dateInYmD = `${date.split("-")[2]}-${date.split("-")[1]}-${date.split("-")[0]}`; //Ymd format
let openingDataId = `${dateInYmD} openingTime`;
let closingDataId = `${dateInYmD} closingTime`;
let openingTime = $(this).find(`td[data-id='${openingDataId}'] select.trp_on_time`).val();
let closingTime = $(this).find(`td[data-id='${closingDataId}'] select.trp_off_time`).val();
const rowData = {
Date: rowCells.eq(0).text().trim(),
openingTime: openingTime,
closingTime: closingTime,
totalHours: $(this).find(`td[data-id='${dateInYmD} totalHours']`).text().trim(),
coldStart: $(this).find(`td[data-id='${dateInYmD} coldStart']`).text().trim(),
breakdownHours: $(this).find(`td[data-id='${dateInYmD} breakdownHours']`).text().trim(),
burnerFiringHours: $(this).find(`td[data-id='${dateInYmD} burnerFiringHours']`).text().trim(),
sandFeedingHours: $(this).find(`td[data-id='${dateInYmD} sandFeedingHours']`).text().trim(),
gasReceiptBg: $(this).find(`td[data-id='${dateInYmD} gasReceiptBg']`).text().trim(),
gasReceiptPg: $(this).find(`td[data-id='${dateInYmD} gasReceiptPg']`).text().trim(),
physicalGasConsumption: $(this).find(`td[data-id='${dateInYmD} physicalGasConsumption']`).text().trim(),
trpPlusDrierGasConsumption: $(this).find(`td[data-id='${dateInYmD} trpPlusDrierGasConsumption']`).text().trim(),
trpPhysicalGasPerTon: $(this).find(`td[data-id='${dateInYmD} trpPhysicalGasPerTon']`).text().trim(),
panelGasConsumption: $(this).find(`td[data-id='${dateInYmD} panelGasConsumption']`).text().trim(),
panelGasPerTon: $(this).find(`td[data-id='${dateInYmD} panelGasPerTon']`).text().trim(),
edRunningHours: $(this).find(`td[data-id='${dateInYmD} edRunningHours']`).text().trim(),
edProduction: $(this).find(`td[data-id='${dateInYmD} edProduction']`).text().trim(),
edUsage: $(this).find(`td[data-id='${dateInYmD} edUsage']`).text().trim(),
waterConsumption: $(this).find(`td[data-id='${dateInYmD} waterConsumption']`).text().trim(),
trpProduction: $(this).find(`td[data-id='${dateInYmD} trpProduction']`).text().trim(),
trpProductionPerHour: $(this).find(`td[data-id='${dateInYmD} trpProductionPerHour']`).text().trim(),
waterReceipt: $(this).find(`td[data-id='${dateInYmD} waterReceipt']`).text().trim(),
ebReading: $(this).find(`td[data-id='${dateInYmD} ebReading']`).text().trim(),
ebReadingPerUnitTon: $(this).find(`td[data-id='${dateInYmD} ebReadingPerUnitTon']`).text().trim(),
workingPersonEngineers: $(this).find(`td[data-id='${dateInYmD} workingPersonEngineers']`).text().trim(),
workingPersonSupervisiors: $(this).find(`td[data-id='${dateInYmD} workingPersonSupervisiors']`).text().trim(),
workingPersonOperators: $(this).find(`td[data-id='${dateInYmD} workingPersonOperators']`).text().trim(),
rollerDrivers: $(this).find(`td[data-id='${dateInYmD} rollerDrivers']`).text().trim(),
natureOfMaintenance: $(this).find(`td[data-id='${dateInYmD} natureOfMaintenance']`).text().trim(),
location: $(this).find(`td[data-id='${dateInYmD} location']`).text().trim(),
description: $(this).find(`td[data-id='${dateInYmD} description']`).text().trim(),
msSeperation: $(this).find(`td[data-id='${dateInYmD} msSeperation']`).text().trim(),
edWaste: $(this).find(`td[data-id='${dateInYmD} edWaste']`).text().trim(),
coolerBags: $(this).find(`td[data-id='${dateInYmD} coolerBags']`).text().trim(),
edPlus20Waste: $(this).find(`td[data-id='${dateInYmD} edPlus20Waste']`).text().trim(),
cycloneWaste: $(this).find(`td[data-id='${dateInYmD} cycloneWaste']`).text().trim(),
};
rows.push(rowData);
});
return JSON.stringify(rows, null, 2);
}
</script>
<script>
function calculateSandFeedingHours(totalHours, coldStart, breakdownHours) {
let [totalHoursF, coldStartF, breakdownHoursF] = [totalHours, coldStart, breakdownHours].map((time) => {
if (time === "" || time == null) return "0.00";
if (typeof time === "number") return time.toFixed(2);
if (!time.includes(".")) return `${time}.00`;
return time;
});
let sandFeedingHours = 0;
let totalHoursInt = milliSecondsFormat((totalHoursF));
let coldStartInt = milliSecondsFormat(coldStartF);
let breakdownHoursInt = milliSecondsFormat(breakdownHoursF);
let burnerFiringHoursInt = totalHoursInt - breakdownHoursInt;
sandFeedingHours = milliSecondsToHourMinuteFormat(burnerFiringHoursInt - coldStartInt);
burnerFiringHours = milliSecondsToHourMinuteFormat(burnerFiringHoursInt);
return [sandFeedingHours, burnerFiringHours];
}
function milliSecondsFormat(givenCustomHourMinuteFormat) {
let hoursInMilliSeconds = givenCustomHourMinuteFormat.split(".")[0] * 60 * 60 * 1000;
let minutesInMilliseconds = givenCustomHourMinuteFormat.split(".")[1] * 60 * 1000;
totalMilliSeconds = hoursInMilliSeconds + minutesInMilliseconds;
return totalMilliSeconds;
}
function milliSecondsDifference(a, b) {
return a > b ? a - b : b - a;
}
function milliSecondsToHourMinuteFormat(givenMilliSeconds) {
const hours = parseInt(givenMilliSeconds / (1000 * 60 * 60));
const hoursInMilliSeconds = hours * 60 * 60 * 1000;
const minutesInMilliseconds = givenMilliSeconds - hoursInMilliSeconds;
const minutes = parseInt(minutesInMilliseconds / (1000 * 60));
const totalHours = hours + "." + minutes;
return totalHours;
}
function trpStockChange(tdElement) {
try {
let tr = $(tdElement).closest('tr');
let date = tr.find('td:eq(0)').text().trim();
date = `${date.split('-')[2]}-${date.split('-')[1]}-${date.split('-')[0]}`;
let totalHours = validateInput(document.querySelector(`td.totalHours[data-id="${date} totalHours"]`).innerText) ?? 0;
let coldStart = validateInput(document.querySelector(`td.coldStart[data-id="${date} coldStart"]`).innerText) ?? 0;
let breakdownHours = validateInput(document.querySelector(`td.breakdownHours[data-id="${date} breakdownHours"]`).innerText) ?? 0;
let burnerFiringHours = validateInput(document.querySelector(`td.burnerFiringHours[data-id="${date} burnerFiringHours"]`).innerText) ?? 0;
let sandFeedingHours = validateInput(document.querySelector(`td.sandFeedingHours[data-id="${date} sandFeedingHours"]`).innerText) ?? 0;
let gasReceiptBg = validateInput(document.querySelector(`td.gasReceiptBg[data-id="${date} gasReceiptBg"]`).innerText) ?? 0;
let gasReceiptPg = validateInput(document.querySelector(`td.gasReceiptPg[data-id="${date} gasReceiptPg"]`).innerText) ?? 0;
let physicalGasConsumption = validateInput(document.querySelector(`td.physicalGasConsumption[data-id="${date} physicalGasConsumption"]`).innerText) ?? 0;
let drierGasConsumption = validateInput(document.querySelector(`td.drierGasConsumption[data-id="${date} drierGasConsumption"]`).innerText) ?? 0;
let coatingGasConsumption = validateInput(document.querySelector(`td.coatingGasConsumption[data-id="${date} coatingGasConsumption"]`).innerText) ?? 0;
let trpPlusDrierGasConsumption = validateInput(document.querySelector(`td.trpPlusDrierGasConsumption[data-id="${date} trpPlusDrierGasConsumption"]`).innerText) ?? 0;
let trpPhysicalGasPerTon = validateInput(document.querySelector(`td.trpPhysicalGasPerTon[data-id="${date} trpPhysicalGasPerTon"]`).innerText) ?? 0;
let panelGasConsumption = validateInput(document.querySelector(`td.panelGasConsumption[data-id="${date} panelGasConsumption"]`).innerText) ?? 0;
let panelGasPerTon = validateInput(document.querySelector(`td.panelGasPerTon[data-id="${date} panelGasPerTon"]`).innerText) ?? 0;
let edRunningHours = validateInput(document.querySelector(`td.edRunningHours[data-id="${date} edRunningHours"]`).innerText) ?? 0;
let edProduction = validateInput(document.querySelector(`td.edProduction[data-id="${date} edProduction"]`).innerText) ?? 0;
let edUsage = validateInput(document.querySelector(`td.edUsage[data-id="${date} edUsage"]`).innerText) ?? 0;
let trpProduction = validateInput(document.querySelector(`td.trpProduction[data-id="${date} trpProduction"]`).innerText) ?? 0;
let trpProductionPerHour = validateInput(document.querySelector(`td.trpProductionPerHour[data-id="${date} trpProductionPerHour"]`).innerText) ?? 0;
let coating = validateInput(document.querySelector(`td.coating[data-id="${date} coating"]`).innerText) ?? 0;
let ebReading = validateInput(document.querySelector(`td.ebReading[data-id="${date} ebReading"]`).innerText) ?? 0;
let ebReadingPerUnitTon = validateInput(document.querySelector(`td.ebReadingPerUnitTon[data-id="${date} ebReadingPerUnitTon"]`).innerText) ?? 0;
let result = calculateSandFeedingHours(totalHours, coldStart, breakdownHours, burnerFiringHours);
sandFeedingHours = result[0];
burnerFiringHours = result[1];
trpPlusDrierGasConsumption = parseInt(parseFloat(physicalGasConsumption) -
(parseFloat(drierGasConsumption) + parseFloat(coatingGasConsumption)));
trpPhysicalGasPerTon = trpProduction == 0 ? 0 : parseFloat(trpPlusDrierGasConsumption) / (parseFloat(trpProduction) / 1000);
panelGasPerTon = parseFloat(panelGasConsumption) / (parseFloat(trpProduction) / 1000);
trpProductionPerHour = sandFeedingHours == 0 ? 0 : parseFloat(trpProduction) / parseFloat(sandFeedingHours);
ebReadingPerUnitTon = trpProduction == 0 ? 0 : parseFloat(ebReading) / (parseFloat(trpProduction) / 1000);
// Final updation of value into td
document.querySelector(`td.sandFeedingHours[data-id="${date} sandFeedingHours"]`).innerText = isFinite(sandFeedingHours) ? sandFeedingHours : " ";
document.querySelector(`td.burnerFiringHours[data-id="${date} burnerFiringHours"]`).innerText = isFinite(burnerFiringHours) ? burnerFiringHours : " ";
document.querySelector(`td.trpPlusDrierGasConsumption[data-id="${date} trpPlusDrierGasConsumption"]`).innerText = isFinite(trpPlusDrierGasConsumption) ? trpPlusDrierGasConsumption : " ";
document.querySelector(`td.trpPhysicalGasPerTon[data-id="${date} trpPhysicalGasPerTon"]`).innerText = isFinite(trpPhysicalGasPerTon) ? (trpPhysicalGasPerTon).toFixed(2) : " ";
document.querySelector(`td.panelGasPerTon[data-id="${date} panelGasPerTon"]`).innerText = isFinite(panelGasPerTon) ? (panelGasPerTon).toFixed(2) : " ";
document.querySelector(`td.trpProductionPerHour[data-id="${date} trpProductionPerHour"]`).innerText = isFinite(trpProductionPerHour) ? (trpProductionPerHour).toFixed(2) : " ";
document.querySelector(`td.ebReadingPerUnitTon[data-id="${date} ebReadingPerUnitTon"]`).innerText = isFinite(ebReadingPerUnitTon) ? (ebReadingPerUnitTon).toFixed(2) : " ";
} catch (error) {
console.error("There is an error updating stock ..!!" + error);
}
}
</script>
<script>
$(document).ready(function() {
$('.timeDropdown').select2({
placeholder: "Select",
});
$('.timeDropdown').change(function() {
var tr = $(this).closest('tr');
let date = tr.find('td:eq(0)').text().trim();
date = `${date.split('-')[2]}-${date.split('-')[1]}-${date.split('-')[0]}`;
var trpOnTime = tr.find('.trp_on_time').val();
var trpOffTime = tr.find('.trp_off_time').val();
if (trpOnTime != '' && trpOffTime != '') {
if (trpOnTime == trpOffTime) {
document.querySelector(`td.totalHours[data-id="${date} totalHours"]`).innerText = '24.0';
return;
}
const startDate = new Date(`1970-01-01T${convertTo24Hour(trpOnTime)}`);
const endDate = new Date(`1970-01-01T${convertTo24Hour(trpOffTime)}`);
// Handle the case where end time is on the next day
if (endDate < startDate) {
endDate.setDate(endDate.getDate() + 1);
}
// Calculate the difference in milliseconds
const totalDiffInMs = endDate - startDate;
// Convert milliseconds to hours and minutes 3,600,000
const hours = parseInt(totalDiffInMs / (1000 * 60 * 60));
const hoursInMilliSeconds = hours * 60 * 60 * 1000;
const minutesInMilliseconds = totalDiffInMs - hoursInMilliSeconds;
const minutes = parseInt(minutesInMilliseconds / (1000 * 60));
const totalHours = hours + "." + minutes;
document.querySelector(`td.totalHours[data-id="${date} totalHours"]`).innerText = totalHours;
trpStockChange(this);
}
}
);
})
function convertTo24Hour(time) {
const [timePart, modifier] = time.split(" ");
let [hours, minutes] = timePart.split(":");
// Convert hours to a number
hours = parseInt(hours, 10);
// Adjust hours based on AM/PM
if (modifier === "PM" && hours < 12) {
hours += 12;
} else if (modifier === "AM" && hours === 12) {
hours = 0;
}
return `${String(hours).padStart(2, '0')}:${minutes}`;
}
</script>
<script>
function validateInput(input) {
if (input == '' || input == ' ' || input == '-') {
return 0;
}
if (typeof input === 'string' && input.split('').map(char => char.charCodeAt(0))[0] == 10) {
return 0;
}
// Validate against the regex
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
alert('Invalid input! Please enter a valid number.');
return 0;
}
return input;
}
</script>
<script>
function absOpeningStockChange(element) {
let row = $(element).closest('tr'); // Get the current row
let openingStockTd = row.find('td.absOpeningStock').text().trim() ?? '';
let receiptTd = row.find('td.absReceipt').text().trim() ?? '';
let consumptionTd = row.find('td.absConsumption').text().trim() ?? '';
// Convert to numbers for calculations
let openingStock = validateInput(openingStockTd) || 0;
let receipt = validateInput(receiptTd) || 0;
let consumption = validateInput(consumptionTd) || 0;
// Calculate values
let totalStock = parseFloat(openingStock) + parseFloat(receipt);
let closingStock = parseFloat(totalStock) - parseFloat(consumption);
// Update the table cells
row.find('td.absTotal').text(parseFloat(totalStock).toFixed(2));
row.find('td.absClosingStock').text(parseFloat(closingStock).toFixed(2));
}
</script>
<script type="text/javascript">
$(document).ready(function() {
$('#abstractSaveId').click(function() {
//table to json function
var updateAbstractDetails = tableToJsonAbstract();
alert('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updateAbstractDetails
},
type: "POST",
url: "<?php echo base_url(); ?>updateAbstractDetails",
success: function(data) {
if (data) {
$('#loader').hide();
console.log(data);
alert(data);
}
},
error: function(xhr, status, error) {
alert("An error occurred while processing the request. Please try again.");
console.error("Error Code:", xhr.status);
console.error("Error Message:", error);
console.error("Response Text:", xhr.responseText);
},
complete: function() {
$('#loader').hide();
}
});
});
});
</script>
<script>
function tableToJsonAbstract() {
const table = $("#abstractTableId");
const rows = [];
//this table to json is customized for bagstock not for all
table.find('tbody tr').each(function() {
const rowData = {
particulars: $(this).find(`td.absParticulars`).text().trim(),
opening_stock: $(this).find(`td.absOpeningStock`).text(),
physical_stock: $(this).find(`td.absPhysicalStock`).text(),
remarks: $(this).find(`td.absRemarks`).text(),
date: $(this).find(`td.absDate`).text()
};
rows.push(rowData);
});
return JSON.stringify(rows, null, 2);
}
</script>
<script>
//excel export for trp production sheet
$(document).ready(function() {
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let cloneTable = table.cloneNode(true); // Clone the table to modify
// Remove hidden rows
$(cloneTable).find('tr').filter(function() {
return $(this).css('display') === 'none';
}).remove();
// Remove hidden columns
$(cloneTable).find('th, td').each(function() {
if ($(this).css('display') === 'none') {
$(this).remove();
}
});
$(cloneTable).find('tbody tr').each(function() {
let firstTd = $(this).find('td').eq(0); // Get the first column (Date)
let openingTimeTd = $(this).find('td').eq(1);
let closingTimeTd = $(this).find('td').eq(2);
let openingTime = $(this).find('td select.trp_on_time').val(); // No space before `.trp_on_time`
let closingTime = $(this).find('td select.trp_off_time').val(); // No space before `.trp_off_time`
// Convert Date Format (Assuming it's in YYYY-MM-DD format)
let originalDate = firstTd.text().trim(); // Get the text value
let parts = originalDate.split('-'); // Split into [YYYY, MM, DD]
if (parts.length === 3) {
let formattedDate = `${parts[2]}-${parts[1]}-${parts[0]}`; // Rearrange to DD-MM-YYYY
firstTd.text(formattedDate); // Update the cell value
}
// Apply left alignment to the date column
firstTd.css("text-align", "left");
openingTimeTd.text(openingTime);
closingTimeTd.text(closingTime);
});
let ws = XLSX.utils.table_to_sheet(cloneTable); // Convert modified table to sheet
let wb = XLSX.utils.book_new(); // Create a new workbook
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); // Append sheet to workbook
XLSX.writeFile(wb, filename || 'export.xlsx'); // Save the file
}
let tableId = 'trpProductionStockDetailsTableId';
document.getElementById('trpProductionDetailsExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'Trp Production Details<?= $month ?>.xlsx');
})
})
</script>
<script>
//excel export for trp abstract sheet
$(document).ready(function() {
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let cloneTable = table.cloneNode(true); // Clone the table to modify
// Remove hidden rows
$(cloneTable).find('tr').filter(function() {
return $(this).css('display') === 'none';
}).remove();
// Remove hidden columns
$(cloneTable).find('th, td').each(function() {
if ($(this).css('display') === 'none') {
$(this).remove();
}
});
let ws = XLSX.utils.table_to_sheet(cloneTable); // Convert modified table to sheet
let wb = XLSX.utils.book_new(); // Create a new workbook
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); // Append sheet to workbook
XLSX.writeFile(wb, filename || 'export.xlsx'); // Save the file
}
let tableId = 'abstractTableId';
document.getElementById('trpAbstractDetailsExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'Trp Abstract Details<?= $month ?>.xlsx');
})
})
</script>
<script>
$('#month').change(function() {
$('#changeMonthForm').submit();
})
$('#month').datepicker({
format: 'M-yyyy',
viewMode: 'months',
minViewMode: 'months',
autoclose: true,
orientation: 'bottom'
})
</script>
<script>
function toggleDivFullscreen() {
let div = document.getElementById("fullscreenDiv");
let tableResponsive = document.getElementById("table-responsive"); // Select the table container inside div
if (!document.fullscreenElement) {
div.requestFullscreen().then(() => {
div.style.width = "100vw"; // Full viewport width
div.style.height = "100vh"; // Full viewport height
// If .table-responsive exists, set its height to 90vh
if (tableResponsive) {
tableResponsive.style.maxHeight = "90vh";
tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed
}
}).catch(err => console.log("Error enabling fullscreen:", err));
} else {
document.exitFullscreen().then(() => {
div.style.width = "100%";
div.style.height = "100%";
// Reset .table-responsive height when exiting fullscreen
if (tableResponsive) {
tableResponsive.style.height = "auto";
}
}).catch(err => console.log("Error exiting fullscreen:", err));
}
}
$("#searchInput").on("keyup", function() {
let value = $(this).val().toLowerCase(); // Convert input to lowercase for case-insensitive search
$(".table-responsive tbody tr").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1);
});
});
</script>