ria/app/Views/trpProductionStockDetails.php
2025-01-21 09:29:44 +05:30

1518 lines
66 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: #00a65a;
color: #ffffff;
}
.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%;
}
.celda_encabezado_general {
background-color: #00a65a;
border: 1px solid #ccc;
color: #ffffff;
font-weight: bold;
padding: 6px 10px;;
text-align: center;
}
._Separador {
background-color: #fff;
height: 12px;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
width: 7px;
}
._Separador div {
width: 4px;
}
.celda_normal {
/*background-color: #fff;*/
/* <!-- ad9271 into ffffff brown-light to green-light --> */
text-align: center;
border: 1px solid #ccc;
padding: 2px 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;
}
#trpProductionStockDetailsTableId th:nth-child(1),
#trpProductionStockDetailsTableId td:nth-child(1) {
position: sticky;
left: 0;
background-color: #00a65a;
z-index: 2;
border-right: 2px solid #ddd;
color: #ffffff;
}
.modal {
padding-right: 30% ! important;
}
</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">
<div class="card-body">
<form action="<?= base_url('trpProductionDetails'); ?>" method="post">
<div class="row">
<div class="col-3">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control mt-2" data-provide="datepicker"
data-date-format="M-yyyy" data-date-min-view-mode="1">
</div>
<div class="form-group col-md-2">
<button type="submit" class="btn btn-success"> Change Month </button>
</div>
<div class="col-md-1"></div>
<div class="col-6">
<div class="dropdown float-right">
<a href="#" class="dropdown-toggle arrow-none" data-toggle="dropdown"
aria-expanded="false">
<i class="mdi mdi-dots-vertical m-0 text-muted h3"></i>
</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" data-toggle="modal" data-target="#bs-example-modal-lg">Navigation</a>
<a class="dropdown-item" href="#">Export</a>
</div>
</div>
</div>
</div>
</form>
<div class="table-responsive">
<table id="trpProductionStockDetailsTableId" class="fht-table table-striped">
<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) -->
<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: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>
</tr>
</thead>
<tbody style="background-color: #fff;" >
<?php if(!empty($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"
data-id=""
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['coldStart'] ?>
</td>
<!-- breakdownHours -->
<!-- td:eq(5) -->
<td class="celda_normal trpProductionStock"
data-id=""
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['breakdownHours'] ?>
</td>
<!-- burnerFiringHours -->
<!-- td:eq(6) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['burnerFiringHours'] ?>
</td>
<!-- sandFeedingHours -->
<!-- td:eq(7) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['sandFeedingHours'] ?>
</td>
<!-- gasReceiptBg -->
<!-- td:eq(8) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['gasReceiptBg'] ?>
</td>
<!-- gasReceiptPg -->
<!-- td:eq(9) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['gasReceiptPg'] ?>
</td>
<!-- physicalGasConsumption -->
<!-- td:eq(10) -->
<td class="celda_normal trpProductionStock"
data-id=""
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['physicalGasConsumption'] ?>
</td>
<!-- drierGasConsumption -->
<!-- td:eq(11) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['drierGasConsumption'] ?>
</td>
<!-- coatingGasConsumption -->
<!-- td:eq(12) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['coatingGasConsumption'] ?>
</td>
<!-- trpPlusDrierGasConsumption -->
<!-- td:eq(13) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['trpPlusDrierGasConsumption'] ?>
</td>
<!-- trpPhysicalGasPerTon -->
<!-- td:eq(14) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpPhysicalGasPerTon = $trpProductionDetail['trpPhysicalGasPerTon'] ?>
</td>
<!-- panelGasConsumption -->
<!-- td:eq(15) -->
<td class="celda_normal trpProductionStock"
data-id=""
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['panelGasConsumption'] ?>
</td>
<!-- panelGasPerTon -->
<!-- td:eq(16) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['panelGasPerTon'] ?>
</td>
<!-- AL(S) -->
<!-- td:eq(17) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['ALs_wcs'] ?>
</td>
<!-- AL(E) -->
<!-- td:eq(18) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['ALe_wcs'] ?>
</td>
<!-- ME -->
<!-- td:eq(19) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['ME_wcs'] ?>
</td>
<!-- SI -->
<!-- td:eq(20) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['SI_wcs'] ?>
</td>
<!-- Caparo -->
<!-- td:eq(21) -->
<td class="celda_normal trpProductionStock"
data-id="">
<? $trpProductionDetail['caparo_wcs'] ?>
</td>
<!-- Nemak -->
<!-- td:eq(22) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['Nemak_wcs'] ?>
</td>
<!-- DR -->
<!-- td:eq(23) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['DR_wcs'] ?>
</td>
<!-- edRunningHours -->
<!-- td:eq(24) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['edRunningHours'] ?>
</td>
<!-- edProduction -->
<!-- td:eq(25) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['edProduction'] ?>
</td>
<!-- edUsage -->
<!-- td:eq(26) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['edUsage'] ?>
</td>
<!-- trpProduction -->
<!-- td:eq(27) -->
<td class="celda_normal trpProductionStock"
data-id=""
oninput="trpStockChange(this)"
contenteditable="true">
<?= $trpProductionDetail['trpProduction'] ?>
</td>
<!-- trpProductionPerHour -->
<!-- td:eq(28) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['trpProductionPerHour'] ?>
</td>
<!-- coating -->
<!-- td:eq(29) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['coating'] ?>
</td>
<!-- Hindhuja -->
<!-- td:eq(30) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['ALs_crs'] ?>
</td>
<!-- Nemak -->
<!-- td:eq(31) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['Nemak_crs'] ?>
</td>
<!-- ME -->
<!-- td:eq(32) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['ME_crs'] ?>
</td>
<!-- BI -->
<!-- td:eq(33) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['BI_crs'] ?>
</td>
<!-- Karmen -->
<!-- td:eq(34) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['Karmen_crs'] ?>
</td>
<!-- waterReceipt -->
<!-- td:eq(35) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['waterReceipt'] ?>
</td>
<!-- waterConsumption -->
<!-- td:eq(36) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['waterConsumption'] ?>
</td>
<!-- ebReading -->
<!-- td:eq(37) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['ebReading'] ?>
</td>
<!-- ebReadingPerUnitTon -->
<!-- td:eq(38) -->
<td class="celda_normal trpProductionStock"
data-id="">
<?= $trpProductionDetail['ebReadingPerUnitTon'] ?>
</td>
<!-- workingPersonEngineers -->
<!-- td:eq(39) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['workingPersonEngineers'] ?>
</td>
<!-- workingPersonSupervisiors -->
<!-- td:eq(40) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['workingPersonSupervisiors'] ?>
</td>
<!-- workingPersonOperators -->
<!-- td:eq(41) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['workingPersonOperators'] ?>
</td>
<!-- rollerDrivers -->
<!-- td:eq(42) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['rollerDrivers'] ?>
</td>
<!-- natureOfMaintenance -->
<!-- td:eq(43) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['natureOfMaintenance'] ?>
</td>
<!-- location -->
<!-- td:eq(44) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['location'] ?>
</td>
<!-- description -->
<!-- td:eq(45) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['description'] ?>
</td>
<!-- msSeperation -->
<!-- td:eq(46) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['msSeperation'] ?>
</td>
<!-- edWaste -->
<!-- td:eq(47) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['edWaste'] ?>
</td>
<!-- coolerBags -->
<!-- td:eq(48) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['coolerBags'] ?>
</td>
<!-- edPlus20Waste -->
<!-- td:eq(49) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['edPlus20Waste'] ?>
</td>
<!--cycloneWaste -->
<!-- td:eq(50) -->
<td class="celda_normal trpProductionStock"
data-id=""
contenteditable="true">
<?= $trpProductionDetail['cycloneWaste'] ?>
</td>
</tr>
<?php }?>
<?php }?>
</tbody>
</table>
</div>
<div class="row">
<div class="col-md-12 text-right">
<input type="button" class="btn btn-success" id="saveId" value="save">
</div>
</div>
</div>
</div> <!-- End card-body -->
</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>
function navigateToResin() {
$('.close').click();
const resinDropdown = document.getElementById('resinDropdown');
const dateDropdown = document.getElementById('dateDropdown');
const selectedResin = resinDropdown.value;
const selectedDate = dateDropdown.value;
const table = document.getElementById('trpProductionStockDetailsTableId');
const headerCells = table.querySelectorAll('thead tr:nth-child(1) th');
const rows = table.querySelectorAll('tbody tr');
let targetColumnIndex = -1;
headerCells.forEach((header, index) => {
if ((header.innerText.trim()) === selectedResin.trim()) {
targetColumnIndex = index;
return;
}
});
if (targetColumnIndex === -1) {
console.log("Resin column not found.");
return;
}
let targetRow = null;
rows.forEach(row => {
const dateCell = row.querySelector('td:first-child');
if (dateCell && dateCell.textContent.trim() === selectedDate) {
targetRow = row;
}
});
if (!targetRow) {
console.log("Date row not found.");
return;
}
console.log(targetColumnIndex);
console.log(targetRow);
targetColumnIndex = targetColumnIndex * 7;
targetRow.cells[targetColumnIndex].scrollIntoView({
behavior: 'smooth',
inline: 'center',
block: 'center'
});
const highlightDuration = 10000;
for (let i = targetColumnIndex-4 ; i <= targetColumnIndex ; i++) {
const cell = targetRow.cells[i];
if (cell) {
cell.style.transition = "background-color 0.5s";
cell.style.backgroundColor = "#df9675";
setTimeout(() => {
cell.style.backgroundColor = "";
}, highlightDuration);
}
}
}
</script>
<script type="text/javascript">
$(document).ready(function () {
$('#saveId').click(function () {
//table to json function
var updateResinStockDetails = tableToJson();
alert('Updation may take a while, And we appreciate your patience..!!');
$('#loader').show();
$.ajax({
data: {
updateResinStockDetails
},
type: "POST",
url: "<?php echo base_url() ?>updateResinStockDetails",
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 tableToJson() {
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();
/** we get eight entries against a material so we loop from 1 to 7 and so on
in a single row **/
for (let i = 1; i < rowCells.length; i += 7) {
const rowData = {
date: rowCells.eq(i).text().trim() ?? 0,
materialCode: rowCells.eq(i+1).text().trim() ?? 0,
customer: rowCells.eq(i+2).text().trim() ?? 0,
opening: rowCells.eq(i+3).text().trim() ?? 0,
receipt: rowCells.eq(i+4).text().trim() ?? 0,
used: rowCells.eq(i+5).text().trim() ?? 0,
balanceStock: rowCells.eq(i + 6).text().trim() ?? 0
};
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((totalHours));
let coldStartInt = milliSecondsFormat(coldStart);
let breakdownHoursInt = milliSecondsFormat(breakdownHours);
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 totalHours = tr.find('td:eq(3)').text().trim() ?? 0;
let coldStart = tr.find('td:eq(4)').text().trim() ?? 0;
let breakdownHours = tr.find('td:eq(5)').text().trim() ?? 0;
let burnerFiringHours = tr.find('td:eq(6)').text().trim() ?? 0;
let sandFeedingHours = tr.find('td:eq(7)').text().trim() ?? 0;
let gasReceiptBg = tr.find('td:eq(8)').text().trim() ?? 0;
let gasReceiptPg = tr.find('td:eq(9)').text().trim() ?? 0;
let physicalGasConsumption = tr.find('td:eq(10)').text().trim()?? 0;
let drierGasConsumption = tr.find('td:eq(11)').text().trim()?? 0;
let coatingGasConsumption = tr.find('td:eq(12)').text().trim()?? 0;
let trpPlusDrierGasConsumption = tr.find('td:eq(13)').text().trim()?? 0;
let trpPhysicalGasPerTon = tr.find('td:eq(14)').text().trim()?? 0;
let panelGasConsumption = tr.find('td:eq(15)').text().trim()?? 0;
let panelGasPerTon = tr.find('td:eq(16)').text().trim()?? 0;
let edRunningHours = tr.find('td:eq(24)').text().trim()?? 0;
let edProduction = tr.find('td:eq(25)').text().trim()?? 0;
let edUsage = tr.find('td:eq(26)').text().trim()?? 0;
let trpProduction = tr.find('td:eq(27)').text().trim()?? 0;
let trpProductionPerHour = tr.find('td:eq(28)').text().trim()?? 0;
let coating = tr.find('td:eq(29)').text().trim()?? 0;
let ebReading = tr.find('td:eq(37)').text().trim()?? 0;
let ebReadingPerUnitTon = tr.find('td:eq(38)').text().trim()?? 0;
let result = calculateSandFeedingHours(totalHours,coldStart,breakdownHours,burnerFiringHours);
sandFeedingHours = result[0];
burnerFiringHours = result[1];
trpPlusDrierGasConsumption = parseInt( parseFloat(physicalGasConsumption) -
( parseFloat(drierGasConsumption) + parseFloat(coatingGasConsumption) ) );
trpPhysicalGasPerTon = parseFloat(trpPlusDrierGasConsumption) / (parseFloat(trpProduction)/1000) ;
panelGasPerTon = parseFloat(panelGasConsumption) / (parseFloat(trpProduction)/1000) ;
trpProductionPerHour = parseFloat(trpProduction) / parseFloat(sandFeedingHours) ;
ebReadingPerUnitTon = parseFloat(ebReading) / (parseFloat(trpProduction)/1000) ;
// Final updation of value into td
tr.find('td:eq(7)').text(sandFeedingHours);
tr.find('td:eq(6)').text(burnerFiringHours);
tr.find('td:eq(13)').text(trpPlusDrierGasConsumption);
tr.find('td:eq(14)').text(trpPhysicalGasPerTon);
tr.find('td:eq(15)').text(panelGasPerTon);
tr.find('td:eq(28)').text(trpProductionPerHour);
tr.find('td:eq(38)').text(ebReadingPerUnitTon);
} 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');
var trpOnTime = tr.find('.trp_on_time').val();
var trpOffTime = tr.find('.trp_off_time').val();
if (trpOnTime != '' && trpOffTime != '') {
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;
tr.find('td:eq(3)').text(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>
// !caution!
// !caution!
// !caution!
// !caution!
// !caution!
// !caution!
// dont delete this commented code , this is used for refernce in getting td values
// let openingTime = tr.find('td:eq(1)').text().trim();
// let closingTime = tr.find('td:eq(2)').text().trim();
// let totalHours = tr.find('td:eq(3)').text().trim();
// let coldStart = tr.find('td:eq(4)').text().trim();
// let breakdownHours = tr.find('td:eq(5)').text().trim();
// let burnerFiringHours = tr.find('td:eq(6)').text().trim();
// let sandFeedingHours = tr.find('td:eq(7)').text().trim();
// let gasReceiptBg = tr.find('td:eq(8)').text().trim();
// let gasReceiptPg = tr.find('td:eq(9)').text().trim();
// let physicalGasConsumption = tr.find('td:eq(10)').text().trim();
// let drierGasConsumption = tr.find('td:eq(11)').text().trim();
// let coatingGasConsumption = tr.find('td:eq(12)').text().trim();
// let trpPlusDrierGasConsumption = tr.find('td:eq(13)').text().trim();
// let trpPhysicalGasPerTon = tr.find('td:eq(14)').text().trim();
// let panelGasConsumption = tr.find('td:eq(15)').text().trim();
// let panelGasPerTon = tr.find('td:eq(16)').text().trim();
// let isolAls = tr.find('td:eq(17)').text().trim();
// let isolAle = tr.find('td:eq(18)').text().trim();
// let isolMe = tr.find('td:eq(19)').text().trim();
// let isolSi = tr.find('td:eq(20)').text().trim();
// let isolCaparo = tr.find('td:eq(21)').text().trim();
// let isolNemak = tr.find('td:eq(22)').text().trim();
// let isolDr = tr.find('td:eq(23)').text().trim();
// let edRunningHours = tr.find('td:eq(24)').text().trim();
// let edProduction = tr.find('td:eq(25)').text().trim();
// let edUsage = tr.find('td:eq(26)').text().trim();
// let trpProduction = tr.find('td:eq(27)').text().trim();
// let trpProductionPerHour = tr.find('td:eq(28)').text().trim();
// let coating = tr.find('td:eq(29)').text().trim();
// let usageHindhuja = tr.find('td:eq(30)').text().trim();
// let usageNemak = tr.find('td:eq(31)').text().trim();
// let usageMe = tr.find('td:eq(32)').text().trim();
// let usageBi = tr.find('td:eq(33)').text().trim();
// let usageKarmen = tr.find('td:eq(34)').text().trim();
// let waterReceipt = tr.find('td:eq(35)').text().trim();
// let waterConsumption = tr.find('td:eq(36)').text().trim();
// let ebReading = tr.find('td:eq(37)').text().trim();
// let ebReadingPerUnitTon = tr.find('td:eq(38)').text().trim();
// let workingPersonEngineers = tr.find('td:eq(39)').text().trim();
// let workingPersonSupervisiors = tr.find('td:eq(40)').text().trim();
// let workingPersonOperators = tr.find('td:eq(41)').text().trim();
// let rollerDrivers = tr.find('td:eq(42)').text().trim();
// let natureOfMaintenance = tr.find('td:eq(43)').text().trim();
// let location = tr.find('td:eq(44)').text().trim();
// let description = tr.find('td:eq(45)').text().trim();
// let msSeperation = tr.find('td:eq(46)').text().trim();
// let edWaste = tr.find('td:eq(47)').text().trim();
// let coolerBags = tr.find('td:eq(48)').text().trim();
// let edPlus20Waste = tr.find('td:eq(49)').text().trim();
// let cycloneWaste = tr.find('td:eq(50)').text().trim();
// !caution!
// !caution!
// !caution!
// !caution!
// !caution!
// !caution!
// dont delete this commented code , this is used for refernce in getting td values
</script>