ria/app/Views/stock/CoatingMachineDetail.php
2025-05-14 17:02:44 +05:30

2030 lines
91 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;
}
.batch-card-table th,
.batch-card-table td {
text-align: center;
vertical-align: middle;
border: 1px solid black;
}
.batch-card-table-cell-space {
padding: 5px;
}
input[type="date"]::-webkit-calendar-picker-indicator {
transform: scale(2.0);
cursor: pointer;
}
input[type="date"] {
cursor: pointer;
}
.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%;
}
.celda_encabezado_general {
background-color: rgb(80, 187, 217);
/* blue background */
border: 1px solid #ccc;
color: #ffffff;
font-weight: bold;
padding: 2px 4px;
text-align: center;
min-width: 120px;
max-width: 120px;
white-space: normal;
/* Allows text to wrap */
word-wrap: break-word;
/* Breaks long words if needed */
text-align: center;
/* Centers text for better alignment */
max-width: 150px;
/* Set a max width to control wrapping */
}
.celda_encabezado_total {
background-color: #ffffff;
border: 1px solid white;
color: #ffffff;
font-weight: bold;
padding: 6px 10px;
text-align: center;
min-width: 120px;
max-width: 120px;
}
._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 --> */
border: 1px solid #ccc;
padding: 5px 6px;
min-width: 120px;
max-width: 120px;
}
/*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;
}
.fht-table th:nth-child(1),
.fht-table th:nth-child(1) {
position: sticky;
left: 0;
top: 0;
background-color: rgb(80, 187, 217);
/* blue background */
z-index: 7 !important;
border-right: 2px solid #ddd;
color: #ffffff;
}
.fht-table td:nth-child(1) {
position: sticky;
left: 0;
background-color: rgb(80, 187, 217);
/* blue background */
z-index: 2;
border-right: 2px solid #ddd;
color: #ffffff;
}
.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;
}
}
.fht-table thead th {
position: sticky;
top: 0;
z-index: 5 !important;
}
tfoot tr {
background-color: rgb(235, 236, 203);
}
body[data-layout-mode=horizontal] .container-fluid {
max-width: 100%;
}
.card-body {
padding-bottom: 0;
}
.card {
margin-bottom: 5px;
}
</style>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div>
<div class="row">
<div class="col-12">
<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);">Stock</a></li>
<li class="breadcrumb-item active">
<h4 class="page-title"> <?= trim(explode(":", $pageTitle)[1]) ?> </h4>
</li>
</ol>
</div>
<div>
<!-- <button type="button" class="btn btn-danger" data-target="#productionBatchCardDetailModalId"
data-toggle="modal">
Add Production Batch Card
</button> -->
</div>
</div>
</div>
</div>
<?php
use PhpOffice\PhpSpreadsheet\Reader\Xml\Style\NumberFormat;
if (session()->getFlashdata('error')): ?>
<div class="alert alert-danger">
<?= session()->getFlashdata('error'); ?>
</div>
<?php endif; ?>
<?php if (session()->getFlashdata('success')): ?>
<div class="alert alert-success">
<?= session()->getFlashdata('success'); ?>
</div>
<?php endif; ?>
<div class="row">
<div class="col-12">
<div class="card" id="fullscreenDiv">
<form id="changeMonthForm" method='post' action="<?= base_url('/coatingMachineDetails'); ?>">
<div class="card-body">
<div class="row">
<?php $today = date('M-Y'); ?>
<div class="col-2">
<input type="text" name="month" id="month" value="<?php echo "$month" ?>"
class="form-control "
readonly>
</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: 250px;border: 2px solid rgb(123, 11, 214);
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; color:rgb(95, 102, 105)"
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; color: #0b7cba"
id="coatingMachineDetailsExport">
</i>
<i class="fe-maximize noti-icon btn-lg mt-2"
title="Full Screen"
style="font-size: x-large; cursor:pointer; color:rgb(241, 9, 136)"
onclick="toggleDivFullscreen()">
</i>
<i class="fa fa-plus-circle btn-lg mt-2 auditor-restricted-btn"
title="Add Entry"
data-target="#coatingMachineDetailModal"
data-toggle="modal"
style="font-size: x-large; cursor:pointer; color:rgb(31, 132, 3)" >
</i>
</div>
</div>
</form>
<!-- Modal -->
<div class="modal fade" id="coatingMachineDetailModal" tabindex="-1" role="dialog"
aria-labelledby="coatingMachineDetailModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" style="width:1060px !important ;" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="coatingMachineDetailModalLabel">
Add New Coating Machine Detail</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<!-- form -->
<form
id="additionalEntriesForm"
method="post"
enctype="multipart/form-data"
action="<?php echo base_url(); ?>addNewCoatingMachineDetails?month=<?= $month; ?>">
<div class="modal-body">
<div class="form-row">
<?php $calendarStartDate = DateTime::createFromFormat('M-Y', $month)->modify('first day of this month')->format('Y-m-d'); ?>
<?php $calendarEndDate = DateTime::createFromFormat('M-Y', $month)->modify('last day of this month')->format('Y-m-d'); ?>
<?php $calendarCurrentDate = DateTime::createFromFormat('M-Y', $month)->format('Y-m-d'); ?>
<!-- date -->
<div class="form-group col-md-3">
<label for="dateId">Date</label>
<span class="badge mandatory">*</span>
<input type="date" class="form-control" id="dateId" name="date"
value="<?=$calendarCurrentDate?>"
min="<?= $calendarStartDate ?>"
max="<?= $calendarEndDate ?>"
required>
</div>
<!-- shift -->
<div class="form-group col-md-3">
<label for="shiftId">Shift</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="shiftId" name="shift" value="" required>
</div>
<!-- machine on time -->
<div class="form-group col-md-3">
<label for="machineOnTimeHrId">Machine On Time</label>
<span class="badge mandatory">*</span>
<select class="form-control select2" name="machineOnTime" id="machineOnTimeHrId" required>
<option value="">Select Time</option>
<option value="12:00 AM">12:00 AM</option>
<option value="12:30 AM"> 12:30 AM</option>
<?php
// Loop through the hours 1 to 12
for ($hour = 1; $hour < 12; $hour++) {
// Display each hour with ":00"
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
echo '<option value="' . $formattedHour . ':00 AM"> ' . $formattedHour . ':00 AM</option>';
echo '<option value="' . $formattedHour . ':30 AM">' . $formattedHour . ':30 AM</option>';
}
?>
<option value="12:00 PM">12:00 PM</option>
<option value="12:30 PM">12:30 PM</option>
<?php
// Loop through the hours 1 to 12
for ($hour = 1; $hour <= 12; $hour++) {
// Display each hour with ":00"
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
echo '<option value="' . $formattedHour . ':00 PM"> ' . $formattedHour . ':00 PM</option>';
echo '<option value="' . $formattedHour . ':30 PM">' . $formattedHour . ':30 PM</option>';
}
?>
</select>
</div>
<!-- machine off time -->
<div class="form-group col-md-3">
<label for="machineOffTimeHrId">Machine Off Time</label>
<span class="badge mandatory">*</span>
<select class="form-control select2" name="machineOffTime" id="machineOffTimeHrId" required>
<option value="">Select Time</option>
<option value="12:00 AM"> 12:00 AM</option>
<option value="12:30 AM"> 12:30 AM</option>
<?php
// Loop through the hours 1 to 12
for ($hour = 1; $hour < 12; $hour++) {
// Display each hour with ":00"
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
echo '<option value="' . $formattedHour . ':00 AM"> ' . $formattedHour . ':00 AM</option>';
echo '<option value="' . $formattedHour . ':30 AM">' . $formattedHour . ':30 AM</option>';
}
?>
<option value="12:00 PM"> 12:00 PM</option>
<option value="12:30 PM"> 12:30 PM</option>
<?php
// Loop through the hours 1 to 12
for ($hour = 1; $hour <= 12; $hour++) {
// Display each hour with ":00"
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
echo '<option value="' . $formattedHour . ':00 PM"> ' . $formattedHour . ':00 PM</option>';
echo '<option value="' . $formattedHour . ':30 PM">' . $formattedHour . ':30 PM</option>';
}
?>
</select>
</div>
</div>
<div class="form-row">
<!-- Total hours -->
<div class="form-group col-md-3">
<label for="machineRunningInHrsId"> Machine Running In Hrs</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" readonly id="machineRunningInHrsId"
name="machineRunningInHrs" required>
</div>
<!-- customer name -->
<div class="form-group col-md-3">
<label for="customerNameId">Customer Name</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="customerNameId" name="customerName" value=""
required>
</div>
<!-- grade -->
<div class="form-group col-md-3">
<label for="gradeId">Grade</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="gradeId" name="grade" value=""
required>
</div>
<!-- total coating as renamed to total production -->
<div class="form-group col-md-3">
<label for="totalCoatingId">Total Production</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="totalCoatingId" name="totalCoating" value=""
required>
</div>
</div>
<div class="form-row">
<!-- total coating sand in kg -->
<div class="form-group col-md-3">
<label for="totalCoatingSandId">Total Coating Sand (in Kg)</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="totalCoatingSandId" name="totalCoatingSandInKg"
value="" required>
</div>
<!-- total gas consumption -->
<div class="form-group col-md-3">
<label for="totalGasConsumptionId">Total Gas Consumption</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="totalGasConsumptionId"
name="totalGasConsumption" value="" required>
</div>
<!-- per hour Coating sand qty -->
<div class="form-group col-md-3">
<label for="perHourCoatingSandQTY">Per Hour Coating Sand QTY</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" readonly id="perHourCoatingSandQTYId"
name="perHourCoatingSandQTY" required>
</div>
<!-- per hour gas consumption -->
<div class="form-group col-md-3">
<label for="perHourGasConsumptionId">Per Hour Gas Consumption </label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" readonly id="perHourGasConsumptionId"
name="perHourGasConsumption" required>
</div>
</div>
<div class="form-row" id="batchCardRowId">
<!-- batch card file upload -->
<div class="form-group col-md-4">
<label for="">Upload Batch Card</label>
<br>
<button type="button" class="btn btn-success btn-sm mt-2" id="batchCardAddBtnId">Add File</button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary submit-btn auditor-restricted-btn">Save </button>
</div>
</form>
</div>
</div>
</div>
<!-- editCoatingMachineDetailModal -->
<div class="modal fade" id="editCoatingMachineDetailModal" tabindex="-1" role="dialog"
aria-labelledby="editCoatingMachineDetailModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" style="width:1060px !important ;" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="editCoatingMachineDetailModalLabel">
Edit Coating Machine Detail</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<!-- form -->
<form method="post" id="editEntriesForm"
enctype="multipart/form-data"
action="<?php echo base_url(); ?>updateCoatingMachineDetails?month=<?= $month; ?>">
<div class="modal-body">
<div class="form-row">
<!-- date -->
<div class="form-group col-md-3">
<label for="editDateId">Date</label>
<span class="badge mandatory">*</span>
<input type="date" class="form-control" id="editDateId" name="date" value="" required readonly>
<input type="hidden" name="editCoatingMachineDetailId" id="editCoatingMachineDetailId">
</div>
<!-- shift -->
<div class="form-group col-md-3">
<label for="editShiftId">Shift</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editShiftId" name="shift" value="" required>
</div>
<!-- machine on time -->
<div class="form-group col-md-3">
<label for="editMachineOnTimeHrId">Machine On Time</label>
<span class="badge mandatory">*</span>
<select class="form-control select2" name="machineOnTime" id="editMachineOnTimeHrId" required>
<option value="">Select Time</option>
<option value="12:00 AM">12:00 AM</option>
<option value="12:30 AM">12:30 AM</option>
<?php
// Loop through the hours 1 to 12
for ($hour = 1; $hour < 12; $hour++) {
// Display each hour with ":00"
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
echo '<option value="' . $formattedHour . ':00 AM"> ' . $formattedHour . ':00 AM</option>';
echo '<option value="' . $formattedHour . ':30 AM">' . $formattedHour . ':30 AM</option>';
}
?>
<option value="12:00 PM">12:00 PM</option>
<option value="12:30 PM">12:30 PM</option>
<?php
// Loop through the hours 1 to 12
for ($hour = 1; $hour <= 12; $hour++) {
// Display each hour with ":00"
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
echo '<option value="' . $formattedHour . ':00 PM"> ' . $formattedHour . ':00 PM</option>';
echo '<option value="' . $formattedHour . ':30 PM">' . $formattedHour . ':30 PM</option>';
}
?>
</select>
</div>
<!-- machine off time -->
<div class="form-group col-md-3">
<label for="editMachineOffTimeHrId">Machine Off Time</label>
<span class="badge mandatory">*</span>
<select class="form-control select2" name="machineOffTime" id="editMachineOffTimeHrId" required>
<option value="">Select Time</option>
<option value="12:00 AM">12:00 AM</option>
<option value="12:30 AM">12:30 AM</option>
<?php
// Loop through the hours 1 to 12
for ($hour = 1; $hour <= 12; $hour++) {
// Display each hour with ":00"
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
echo '<option value="' . $formattedHour . ':00 AM"> ' . $formattedHour . ':00 AM</option>';
echo '<option value="' . $formattedHour . ':30 AM">' . $formattedHour . ':30 AM</option>';
}
?>
<option value="12:00 PM">12:00 PM</option>
<option value="12:30 PM">12:30 PM</option>
<?php
// Loop through the hours 1 to 12
for ($hour = 1; $hour < 12; $hour++) {
// Display each hour with ":00"
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
echo '<option value="' . $formattedHour . ':00 PM"> ' . $formattedHour . ':00 PM</option>';
echo '<option value="' . $formattedHour . ':30 PM">' . $formattedHour . ':30 PM</option>';
}
?>
</select>
</div>
</div>
<div class="form-row">
<!-- total hours -->
<div class="form-group col-md-3">
<label for="editMachineRunningInHrsId"> Machine Running In Hrs</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" readonly id="editMachineRunningInHrsId"
name="machineRunningInHrs" required>
</div>
<!-- customer name -->
<div class="form-group col-md-3">
<label for="editCustomerNameId">Customer Name</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editCustomerNameId" name="customerName" value=""
required>
</div>
<!-- grade -->
<div class="form-group col-md-3">
<label for="editGradeId">Grade</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editGradeId" name="grade" value=""
required>
</div>
<!-- total coating as renamed to total production -->
<div class="form-group col-md-3">
<label for="editTotalCoatingId">Total Production</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editTotalCoatingId" name="totalCoating" value=""
required>
</div>
</div>
<div class="form-row">
<!-- total coating sand in kg -->
<div class="form-group col-md-3">
<label for="editTotalCoatingSandId">Total Coating Sand (in Kg)</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editTotalCoatingSandId"
name="totalCoatingSandInKg" value="" required>
</div>
<!-- total gas consumption -->
<div class="form-group col-md-3">
<label for="editTotalGasConsumptionId">Total Gas Consumption</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editTotalGasConsumptionId"
name="totalGasConsumption" value="" required>
<input type="hidden" class="form-control" id="existingTotalGasConsumptionId"
name="existingTotalGasConsumption" value="">
</div>
<!-- per hour Coating sand qty -->
<div class="form-group col-md-3">
<label for="editPerHourCoatingSandQTYId">Per Hour Coating Sand QTY</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" readonly id="editPerHourCoatingSandQTYId"
name="perHourCoatingSandQTY" required>
</div>
<!-- per hour gas consumption -->
<div class="form-group col-md-3">
<label for="editPerHourGasConsumptionId">Per Hour Gas Consumption </label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" readonly id="editPerHourGasConsumptionId"
name="perHourGasConsumption" required>
</div>
</div>
<div class="form-row" id="editBatchCardRowId">
<!-- batch card file upload -->
<div class="form-group auditor-restricted col-md-4">
<label for="editBatchCardId">Upload Batch Card</label>
<br>
<button type="button" class="btn btn-success btn-sm mt-2" id="editBatchCardAddBtnId">Add File</button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="cancelBtn">Cancel</button>
<button type="submit" class="btn btn-primary submit-btn auditor-restricted-btn">Save </button>
</div>
</form>
</div>
</div>
</div>
<!-- filter modal -->
<div class="modal fade" id="filterModalId" tabindex="-1" role="dialog" aria-labelledby="filterModalLabelId" aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="filterModalLabelId">Filter Options</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="row">
<?php
$currentDateInDmY = date('d-m-Y');
?>
<?php
$startDate = DateTime::createFromFormat('M-Y', $month);
if ($startDate) {
$startDate->modify('first day of this month');
$daysInMonth = $startDate->format('t');
$dateArray = [];
for ($i = 0; $i < $daysInMonth; $i++) {
$dateArray[] = $startDate->format('d-m-Y');
$startDate->modify('+1 day');
}
} else {
echo "Invalid date format.";
}
?>
<!-- From Date Filter -->
<div class="col-md-6">
<div class="form-group">
<label for="fromDateFilter">Select From Date</label>
<select id="fromDateFilter" name="fromDateFilter" class="form-control select2">
<?php if (!empty($dateArray)) : ?>
<?php foreach ($dateArray as $index => $date) : ?>
<option value="<?= $date ?>"><?= $date ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
</div>
<!-- To Date Filter -->
<div class="col-md-6">
<div class="form-group">
<label for="toDateFilter">Select Date</label>
<select id="toDateFilter" name="toDateFilter" class="form-control select2">
<?php if (!empty($dateArray)) : ?>
<?php foreach ($dateArray as $date) : ?>
<option value="<?= $date ?>" <?= ($date == $currentDateInDmY) || ($date == $dateArray[9]) ? "selected" : " " ?>><?= $date ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div>
</div>
</div>
<button type="button" class="btn btn-primary float-right" onclick="customFilterDate(event)">Filter</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<div class="table-responsive" id="table-responsive">
<table id="coatingMachineDetailTableId" class="fht-table table-responsiv"
style="background-color:#fff;">
<thead>
<tr>
<th class="celda_encabezado_general">Date</th>
<th class="celda_encabezado_general">Shift</th>
<th class="celda_encabezado_general">Machine On Time</th>
<th class="celda_encabezado_general">Machine Off Time</th>
<th class="celda_encabezado_general">Machine Running(hr)</th>
<th class="celda_encabezado_general">Customer Name</th>
<th class="celda_encabezado_general">Grade</th>
<th class="celda_encabezado_general">Total Coating</th>
<th class="celda_encabezado_general">Total Coating Sand(kg)</th>
<th class="celda_encabezado_general">Total Gas Consumption</th>
<th class="celda_encabezado_general">Per Hour Gas</th>
<th class="celda_encabezado_general">Per Hour QTY(kg)</th>
<th class="celda_encabezado_general">Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($coatingMachineDetails)) {
$summary = [];
foreach ($coatingMachineDetails as $record) {
$batchCardFiles = json_decode($record['batchcard_files'], true);
?>
<tr data-id="<?php echo $record['id']; ?>"
<?php
$currentDate = date('d-m-Y');
$dateInMonthDmYFormat = DateTime::createFromFormat('Y-m-d', $record['date'])->format('d-m-Y');
if ($dateInMonthDmYFormat === $currentDate) {
echo 'style="background: #cef0ad;"';
}
?>>
<?php
$date = DateTime::createFromFormat('Y-m-d', $record['date'])->format('d-m-Y');
?>
<!-- td:eq(0) -->
<td class="celda_normal"><?php echo $date ?></td>
<!-- td:eq(1) -->
<td class="celda_normal"><?php echo $record['shift'] ?></td>
<!-- td:eq(2) -->
<td class="celda_normal"><?php echo $record['machineOnTime'] ?></td>
<!-- td:eq(3) -->
<td class="celda_normal"><?php echo $record['machineOffTime'] ?></td>
<!-- td:eq(4) -->
<td class="celda_normal"><?php echo $record['machineRunningInHrs'] ?? ' ' ?></td>
<!-- td:eq(5) -->
<td class="celda_normal"
style="text-align: left !important;"><?php echo $record['customerName'] ?? '' ?></td>
<!-- td:eq(6) -->
<td class="celda_normal"><?php echo $record['grade'] ?? ' ' ?></td>
<!-- td:eq(7) -->
<td class="celda_normal"><?php echo round((float)$record['totalCoating'],2) ?></td>
<!-- td:eq(8) -->
<td class="celda_normal"><?php echo round((float)$record['totalCoatingSandInKg'],2) ?></td>
<!-- td:eq(9) -->
<td class="celda_normal"><?php echo round((float)$record['totalGasConsumption'],2) ?></td>
<!-- td:eq(10) -->
<td class="celda_normal"><?php echo round((float)$record['perHourGasConsumption'], 2) ?? '' ?></td>
<!-- td:eq(11) -->
<td class="celda_normal"><?php echo round((float)$record['perHourCoatingSandQTY'] , 2) ?? '' ?></td>
<!-- td:eq(12) -->
<!-- edit and download option..!! -->
<td class="celda_normal">
<a data-toggle="tooltip" class="edit-btn"
data-target="editCoatingMachineDetailModal" data-toggle="modal"
style="cursor:pointer;">
<i class="fa fa-edit"
title="Click here to Edit ">
</i>
&nbsp;&nbsp;&nbsp;
</a>
<?php
foreach ($batchCardFiles as $index => $files) {
if ($index === 0 && !empty($files['batchCardId']) && $files['coating_id'] == $record['id']) {
?>
<a href="<?= base_url('download-batchcard-zip?coating_id=' . $record['id'] . '&date=' . $date); ?>"
data-toggle="tooltip" title="Download Batch Card">
<i class="fa fa-download"></i>
</a>
<?php
break;
}
}
?>
</td>
<!-- td:eq(13) -->
<td style="display:none;"><?php echo $record['batchcard_files'] ?? ' ' ?></td>
</tr>
<?php
//before closing inner loop
if (!isset($summary['totalCoating'])) {
$summary['totalMachineRunningHrs'] = 0;
$summary['totalCoating'] = 0;
$summary['totalCoatingSandInKg'] = 0;
$summary['totalGasConsumption'] = 0;
$summary['perHourGasConsumption'] = 0;
$summary['perHourCoatingSandQTY'] = 0;
}
$summary['totalMachineRunningHrs'] += $record['machineRunningInHrs'] == "-" ? 0 : (float) $record['machineRunningInHrs'];
$summary['totalCoating'] += $record['totalCoating'] == "-" ? 0 : (float) $record['totalCoating'];
$summary['totalCoatingSandInKg'] += $record['totalCoatingSandInKg'] == "-" ? 0 : (float) $record['totalCoatingSandInKg'];
$summary['totalGasConsumption'] += $record['totalGasConsumption'] == "-" ? 0 : (float) $record['totalGasConsumption'];
$summary['perHourGasConsumption'] += $record['perHourGasConsumption'] == "-" ? 0 : (float) $record['perHourGasConsumption'];
$summary['perHourCoatingSandQTY'] += $record['perHourCoatingSandQTY'] == "-" ? 0 : (float) $record['perHourCoatingSandQTY'];
} ?>
<tfoot>
<tr>
<td style="background-color:rgb(189, 9, 6); color:#ffff;">
<b> Total </b>
</td>
<td class="celda_normal "> - </td>
<td class="celda_normal "> - </td>
<td class="celda_normal "> - </td>
<td class="celda_normal "> <?= $summary['totalMachineRunningHrs'] ?></td>
<td class="celda_normal "> - </td>
<td class="celda_normal "> - </td>
<td class="celda_normal "><?= round($summary['totalCoating'],2) ?></td>
<td class="celda_normal "><?= round($summary['totalCoatingSandInKg'],2) ?></td>
<td class="celda_normal "><?= round($summary['totalGasConsumption'],2) ?></td>
<td class="celda_normal "><?= round($summary['totalGasConsumption'] / $summary['totalMachineRunningHrs'] , 2) ?> (A)</td>
<td class="celda_normal "><?= round($summary['totalCoatingSandInKg'] / $summary['totalMachineRunningHrs'], 2) ?> (A)</td>
</tr>
</tfoot>
</div>
<?php
}
?>
</tbody>
</table>
</div>
<br>
<?php if (empty($coatingMachineDetails)) { ?>
<h5 align="center" style="color:grey;">
No Coating Machine Details present in this month
</h5>
<?php }else{?>
<br>
<p align="center">Note :- (A) -> Average</p>
<?php } ?>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div>
</div> <!-- container -->
</div> <!-- content -->
</div>
<!-- productionBatchCardModal -->
<div class="modal fade" id="productionBatchCardDetailModalId" tabindex="-1" role="dialog"
aria-labelledby="productionBatchCardDetailModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" style="width:1060px !important ;" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="productionBatchCardDetailModalLabel">
Production Batch Card Detail
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<!-- form -->
<form method="post" id="productionBatchCardDetailModalFormId"
action="<?php echo base_url(); ?>updateBatchCardDetail?month=<?= $month; ?>">
<div class="modal-body p-4">
<div class="table-responsive">
<table class="batch-card-table">
<thead>
<!-- Table Header Rows -->
<tr>
<th rowspan="5" colspan="1">logo</th>
<th rowspan="5" colspan="7">resico name</th>
<tr>
<td colspan="1">one </td>
<td colspan="1">one </td>
</tr>
<tr>
<td colspan="1">one </td>
<td colspan="1">one </td>
</tr>
<tr>
<td colspan="1">one </td>
<td colspan="1">one </td>
</tr>
<tr>
<td colspan="1">one </td>
<td colspan="1">one </td>
</tr>
</tr>
<tr>
<th class="batch-card-table-cell-space" colspan="10">Production Batch Card</th>
</tr>
<tr>
<th class="batch-card-table-cell-space">Customer Name</th>
<td class="batch-card-table-cell-space" colspan="4">DR Axion India Pvt.Ltd (PCS ROUGH) </td>
<th class="batch-card-table-cell-space">P.Batch No</th>
<td class="batch-card-table-cell-space" colspan="4">MI | 12 | 19 | C</td>
</tr>
<tr>
<th class="batch-card-table-cell-space">Date</th>
<td class="batch-card-table-cell-space" colspan="2">19/12/2024</td>
<th class="batch-card-table-cell-space">Shift</th>
<td class="batch-card-table-cell-space">III</td>
<th class="batch-card-table-cell-space">Batch No</th>
<td class="batch-card-table-cell-space" colspan="4">123</td>
</tr>
<tr>
<th class="batch-card-table-cell-space">Operator</th>
<td class="batch-card-table-cell-space" colspan="4">KUMARAN</td>
<th class="batch-card-table-cell-space">Helpers</th>
<td class="batch-card-table-cell-space" colspan="4">MURUGESAN</td>
</tr>
<!-- Sub Header -->
<tr>
<th class="batch-card-table-cell-space">S.No</th>
<th class="batch-card-table-cell-space">Sand</th>
<th class="batch-card-table-cell-space">Resin Solid</th>
<th class="batch-card-table-cell-space">Hexamine</th>
<th class="batch-card-table-cell-space">Water</th>
<th class="batch-card-table-cell-space">Catalyst Calcium Stearat</th>
<th class="batch-card-table-cell-space">Resin Mixing Time</th>
<th class="batch-card-table-cell-space">Hexamine Mixing Time</th>
<th class="batch-card-table-cell-space">Catalyst Mixing Time</th>
<th class="batch-card-table-cell-space">TS</th>
</tr>
<tr>
<th>SPEC</th>
<th>200KG-300KG</th>
<th>3KG-6KG</th>
<th>450G-900G</th>
<th>900G-1800G</th>
<th>150G-300G</th>
<th>60-120 SEC</th>
<th>60-120 SEC</th>
<th>180-300 SEC</th>
<th>50-60 KG/CM<sup>2</sup></th>
</tr>
</thead>
<tbody>
<!-- Data Rows -->
<tr>
<td>1</td>
<td>300</td>
<td>5.000</td>
<td>7.30</td>
<td>1500</td>
<td>230</td>
<td>60</td>
<td>60</td>
<td>180</td>
<td>54.2</td>
</tr>
<tr>
<td>2</td>
<td>300</td>
<td>5.000</td>
<td>7.30</td>
<td>1500</td>
<td>230</td>
<td>60</td>
<td>60</td>
<td>180</td>
<td>52.4</td>
</tr>
<!-- Add more rows dynamically as needed -->
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8">
</script>
<script>
function confirmDelete(event) {
let result = confirm(`Do you Confirm to Delete the Coating Machine Detail?`);
if (result) {
return result;
} else {
event.preventDefault();
}
}
</script>
<script>
$(document).ready(function() {
$('#exampleSelect2 ').select2();
$('#machineOnTimeHrId ').select2();
$('#machineOffTimeHrId ').select2();
$('#editMachineOnTimeHrId ').select2();
$('#editMachineOffTimeHrId ').select2();
$('#fromDateFilter ').select2();
$('#toDateFilter ').select2();
});
</script>
<!-- appending values in the edit coating machine detail modal from the table -->
<script>
$(document).ready(function() {
$('#coatingMachineDetailTableId tbody').on('click', '.edit-btn', function() {
var row = $(this).closest('tr');
// Get values from the row
var date = row.find('td:eq(0)').text().split('-');
date = `${date[2]}-${date[1]}-${date[0]}`;
var shift = row.find('td:eq(1)').text();
var machineOnTimeHr = row.find('td:eq(2)').text();
var machineOffTimeHr = row.find('td:eq(3)').text();
var machineRunningInHrs = row.find('td:eq(4)').text();
var customerName = row.find('td:eq(5)').text();
var grade = row.find('td:eq(6)').text();
var totalCoating = row.find('td:eq(7)').text();
var totalCoatingSandInKg = row.find('td:eq(8)').text();
var totalGasConsumption = row.find('td:eq(9)').text();
var perHourGasConsumption = row.find('td:eq(10)').text();
var perHourCoatingSandQTY = row.find('td:eq(11)').text();
var batchCards = row.find('td:eq(13)').text().trim();
JSON.parse(batchCards).map(element => {
if (!element.client_given_name) {
console.log("filename null")
return;
}
let fileCount = $('.editBatchFile').length; // Count existing batch files
if (fileCount >= 5) {
return;
}
let string = `<div class="form-group col-md-4 batch-container">
<label for="">Uploaded Batch Card</label>
<input type="file" class="editBatchFile additionalBatchFile" name="batchCard[]" disabled>
<p>( Previously Uploaded File ${element.client_given_name} )</p>
<button type="button" class="btn btn-danger btn-sm removeBatch auditor-restricted-btn" data-id="${element.batchCardId}" >Remove</button>
</div>`;
$('#editBatchCardRowId').append(string);
});
// Fill the modal fields with the values
//batchfile
$('#editCoatingMachineDetailId').val(row.data('id'));
$('#editCustomerNameId').val(customerName);
$('#editDateId').val(date); //convert this from d-m-y to Y-m-d in javascript
$('#editShiftId').val(shift);
$('#editMachineOnTimeHrId').val(machineOnTimeHr);
$('#editMachineOffTimeHrId').val(machineOffTimeHr);
$('#editGradeId').val(grade);
$('#editTotalCoatingId').val(totalCoating);
$('#editTotalCoatingSandId').val(totalCoatingSandInKg);
$('#editTotalGasConsumptionId').val(totalGasConsumption);
$('#existingTotalGasConsumptionId').val(totalGasConsumption);
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
$('#editPerHourGasConsumptionId').val(perHourGasConsumption);
$('#editPerHourCoatingSandQTYId').val(perHourCoatingSandQTY);
// Show the modal
$('#editCoatingMachineDetailModal').modal('show');
});
});
</script>
<script>
$(document).ready(function() {
$('#editCoatingMachineDetailModal').on('hidden.bs.modal', function() {
$('.batch-container').remove(); // This will remove all child elements
});
});
</script>
<!-- calculations for some fields needed in onChange while adding coating machine details -->
<script>
$(document).ready(function() {
$('#machineOnTimeHrId , #dateId').change(function() {
let machineOnDate = $('#dateId').val();
if (machineOnDate == '') {
alert('Please Select Date before entering Machine On and Off Time ..!!');
$('#machineOnTimeHrId').val("");
return false;
}
let machineOnTimeHr = $('#machineOnTimeHrId').val();
let machineOffTimeHr = $('#machineOffTimeHrId').val();
let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOffTimeHr);
if (!machineRunningInHrs) {
$('machineOnTimeHrId').val('');
return
}
$('#machineRunningInHrsId').val(machineRunningInHrs);
$('#totalCoatingSandId').trigger('change');
$('#totalGasConsumptionId').trigger('change');
});
$('#machineOffTimeHrId , #dateId').change(function() {
let machineOnDate = $('#dateId').val();
if (machineOnDate == '') {
alert('Please Select Date before entering Machine On and Off Time ..!!');
$('#machineOffTimeHrId').val('');
return false;
}
let machineOffTimeHr = $('#machineOffTimeHrId').val();
let machineOnTimeHr = $('#machineOnTimeHrId').val();
let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOffTimeHr);
if (!machineRunningInHrs) {
$('#machineOffTimeHrId').val('');
return
}
$('#machineRunningInHrsId').val(machineRunningInHrs);
$('#totalCoatingSandId').trigger('change');
$('#totalGasConsumptionId').trigger('change');
})
$('#totalCoatingId , #shiftId ').change(function(){
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
})
$('#totalCoatingSandId').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
let totalCoatingSandValue = $(this).val();
let machineRunningInHrsValue = $('#machineRunningInHrsId').val();
if (totalCoatingSandValue && machineRunningInHrsValue) {
let perHourCoatingSandQTYValue = (totalCoatingSandValue / machineRunningInHrsValue).toFixed(2);
$('#perHourCoatingSandQTYId').val(perHourCoatingSandQTYValue);
}
})
$('#totalGasConsumptionId').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
let totalGasConsumptionValue = $(this).val();
let machineRunningInHrsValue = $('#machineRunningInHrsId').val();
if (totalGasConsumptionValue && machineRunningInHrsValue) {
let perHourGasConsumptionValue = (totalGasConsumptionValue / machineRunningInHrsValue).toFixed(2);
$('#perHourGasConsumptionId').val(perHourGasConsumptionValue);
}
})
$('#editMachineOnTimeHrId , #editDateId').change(function() {
let machineOnDate = $('#editDateId').val();
if (machineOnDate == '') {
alert('Please Select Date before entering Machine On and Off Time ..!!');
$('#editMachineOnTimeHrId').val('');
return false;
}
let machineOnTimeHr = $('#editMachineOnTimeHrId').val();
let machineOffTimeHr = $('#editMachineOffTimeHrId').val();
let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOffTimeHr);
if (!machineRunningInHrs) {
$('#editMachineOnTimeHrId').val('');
return
}
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
$('#editTotalCoatingSandId').trigger('change');
$('#editTotalGasConsumptionId').trigger('change');
});
$('#editMachineOffTimeHrId , #editDateId').change(function() {
let machineOnDate = $('#editDateId').val();
if (machineOnDate == '') {
alert('Please Select Date before entering Machine On and Off Time ..!!');
$('#editMachineOnTimeHrId').val('');
return false;
}
let machineOnTimeHr = $('#editMachineOnTimeHrId').val();
let machineOffTimeHr = $('#editMachineOffTimeHrId').val();
let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOffTimeHr);
if (!machineRunningInHrs) {
$('#editMachineOffTimeHrId').val('');
return
}
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
$('#editTotalCoatingSandId').trigger('change');
$('#editTotalGasConsumptionId').trigger('change');
})
$('#editTotalCoatingId , #editShiftId ').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
})
$('#editTotalCoatingSandId').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
let totalCoatingSandValue = $(this).val();
let machineRunningInHrsValue = $('#editMachineRunningInHrsId').val();
if (totalCoatingSandValue && machineRunningInHrsValue) {
let perHourCoatingSandQTYValue = (totalCoatingSandValue / machineRunningInHrsValue).toFixed(2);
$('#editPerHourCoatingSandQTYId').val(perHourCoatingSandQTYValue);
}
})
$('#editTotalGasConsumptionId').change(function() {
let basicCheck =checkIsNumber($(this).val().trim());
if (basicCheck == 0) {
alert("Kindly Enter Numbers only..!!");
return;
}
let totalGasConsumptionValue = $(this).val();
let machineRunningInHrsValue = $('#editMachineRunningInHrsId').val();
if (totalGasConsumptionValue && machineRunningInHrsValue) {
let perHourGasConsumptionValue = (totalGasConsumptionValue / machineRunningInHrsValue).toFixed(2);
$('#editPerHourGasConsumptionId').val(perHourGasConsumptionValue);
}
})
function checkIsNumber(input) {
const isValid = /^-?\d*\.?\d*$/.test(input);
if (!isValid) {
return 0;
}
}
})
</script>
<!-- utility function for input elements of type="time" -->
<script>
function calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOffTimeHr) {
let machineOnTime12 = machineOnTimeHr;
let machineOffTime12 = machineOffTimeHr;
if (machineOnTime12 == machineOffTime12) {
return `24.00`;
}
let machineOnTime24 = convertTo24Hr(machineOnTime12);
let machineOffTime24 = convertTo24Hr(machineOffTime12);
const startDate = new Date(`${machineOnDate}T${machineOnTime24}`);
const endDate = new Date(`${machineOnDate}T${machineOffTime24}`);
// 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 diffInMs = endDate - startDate;
// Convert milliseconds to hours and minutes
const hours = Math.floor(diffInMs / (1000 * 60 * 60));
const minutes = Math.floor((diffInMs % (1000 * 60 * 60)) / (1000 * 60));
return `${hours}.${minutes >= 30 ? 5 : 0}`; // Return in HH.MM format
}
</script>
<script>
function convertTo24Hr(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; // Convert PM times to 24-hour format (e.g., 1 PM becomes 13:00)
} else if (modifier == "AM" && hours == 12) {
hours = 0; // Convert 12 AM to 00:00 (midnight)
}
// Format hours and minutes to ensure two digits
return `${String(hours).padStart(2, '0')}:${minutes}:00`;
}
</script>
<script>
$(document).on('change', '#month', function() {
$('#changeMonthForm').submit();
});
$('#month').datepicker({
format: 'M-yyyy',
viewMode: 'months',
minViewMode: 'months',
autoclose: true,
orientation: 'bottom',
startDate: new Date(2025, 0), // Jan is month 0
endDate: new Date() // current date as max
});
</script>
<script>
function customFilterDate(event) {
event.preventDefault();
let fromDate = $('#fromDateFilter').val(); //01-12-2024
let toDate = $('#toDateFilter').val(); //05-12-2024
$('#coatingMachineDetailTableId').find('tbody tr').each(function() {
const rowCells = $(this).find('td');
let tableDate = rowCells.eq(0).text();
let result = checkDateRange(fromDate, toDate, tableDate);
if (result) {
$(this).show();
} else {
$(this).hide();
}
});
$('#filterModalId').modal('hide');
}
function checkDateRange(fromDate, toDate, tableDate) {
// Convert the dates to a comparable format (YYYY-MM-DD)
let from = convertToDate(fromDate);
let to = convertToDate(toDate);
let table = convertToDate(tableDate);
// Return true if the table date is within the range
return table >= from && table <= to;
}
function convertToDate(dateString) {
// Convert from DD-MM-YYYY to YYYY-MM-DD for comparison
let parts = dateString.split('-');
return new Date(parts[2], parts[1] - 1, parts[0]); // Year, Month (0-based), Day
}
</script>
<script>
$(document).ready(function() {
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let rows = [];
// Extract table data row-by-row
$(table).find('tr').each(function(rowIndex) {
let rowData = [];
$(this).find('th, td').each(function(colIndex) {
// Skip hidden columns
if ($(this).css('display') === 'none') return;
let cellText = $(this).text().trim();
rowData.push(cellText);
});
// Add the cleaned row only if it has data
if (rowData.length > 0) {
rows.push(rowData);
}
});
// Create a worksheet from array (no DOM needed!)
let ws = XLSX.utils.aoa_to_sheet(rows);
// Set column widths: wch: 10 for each column
if (rows.length > 0) {
const colCount = rows[0].length;
const wscols = [];
for (let i = 0; i < colCount; i++) {
wscols.push({ wch: 10 });
}
ws['!cols'] = wscols;
}
// Create a new workbook and add the sheet
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
// Write the workbook to a file
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'coatingMachineDetailTableId';
document.getElementById('coatingMachineDetailsExport').addEventListener('click', function() {
exportTableToExcel(tableId, 'coatingMachineDetails_<?= $month ?>.xlsx');
});
});
</script>
<script>
$(document).ready(function() {
$('#batchCardAddBtnId').click(function() {
let fileCount = $('.batchfile').length; // Count existing batch files
if (fileCount >= 5) { // Set your limit here (e.g., max 5 files)
alert("You can only upload up to 5 batch files.");
return;
}
let string = `<div class="form-group col-md-4 batch-container">
<label for="">Upload Batch Card</label>
<input type="file" class="batchfile" name="batchCard[]" >
<button type="button" class="btn btn-danger btn-sm mt-2 removeBatch">Remove</button>
</div>`;
$('#batchCardRowId').append(string);
});
// Remove batch card field dynamically
$(document).on('click', '.removeBatch', function() {
$(this).closest('.batch-container').remove();
});
});
$(document).ready(function() {
$('#editBatchCardAddBtnId').click(function() {
let fileCount = $('.editBatchFile').length; // Count existing batch files
if (fileCount >= 5) { // Set your limit here (e.g., max 5 files)
alert("You can only upload up to 5 batch files.");
return;
}
let string = `<div class="form-group col-md-4 batch-container">
<label for="">Upload Batch Card</label>
<input type="file" class="editBatchFile" name="batchCard[]" >
<button type="button" class="btn btn-danger btn-sm mt-2 removeBatch">Remove</button>
</div>`;
$('#editBatchCardRowId').append(string);
});
// Remove batch card field dynamically
$(document).on('click', '.removeBatch', function() {
let batchId = this.getAttribute('data-id'); // Get the data-id
if (confirm("Are you sure you want to delete this batch file?")) {
$.ajax({
url: "<?php echo base_url(); ?>/deleteBatchCardFile",
type: "POST",
data: {
id: batchId
},
success: function(response) {
if (response.status == "200") {
alert("Batch File Deleted Successfully!");
$(this).closest('.batch-container').remove(); // Remove from UI
location.reload(); // Reload the page
} else {
alert("Removed Empty batch file");
// alert("Error deleting batch file: " + response.message);
}
},
error: function(xhr, status, error) {
alert("Error deleting batch file: " + error);
}
});
}
});
});
</script>
<!-- onchange of month submit will happen -->
<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 .table-responsive exists, set its height to 90vh
if (tableResponsive) {
tableResponsive.style.maxHeight = "450px";
tableResponsive.style.overflowY = "auto"; // Allow scrolling if needed
}
}).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>
<script>
$(document).ready(function() {
$('.select2').select2({
dropdownParent: $('#fullscreenDiv')
});
// Initialize Select2 when the modal is shown inside full screen
$('#filterModalId').on('shown.bs.modal', function () {
$('.select2').select2({
dropdownParent: $(this) // This ensures Select2 works in the modal
});
});
$('#coatingMachineDetailModal').on('shown.bs.modal', function () {
$('.select2').select2({
dropdownParent: $(this) // This ensures Select2 works in the modal
});
});
$('#editCoatingMachineDetailModal').on('shown.bs.modal', function () {
$('.select2').select2({
dropdownParent: $(this) // This ensures Select2 works in the modal
});
});
});
</script>
<script>
//getting modal backdrop inside full screen
$(document).ready(function() {
function moveModalBackdropToFullscreen() {
setTimeout(() => {
$('.modal-backdrop').appendTo('#fullscreenDiv'); // Move backdrop inside fullscreen
}, 10); // Small delay ensures backdrop is created first
}
// Move the modal backdrop when a modal opens
$('#filterModalId, #coatingMachineDetailModal, #editCoatingMachineDetailModal').on('show.bs.modal', function () {
moveModalBackdropToFullscreen();
});
// Ensure modals work properly in fullscreen mode
document.addEventListener("fullscreenchange", function() {
setTimeout(() => {
$('.modal-backdrop').remove(); // Remove any existing backdrops
moveModalBackdropToFullscreen();
}, 200);
});
});
</script>
<script>
document.getElementById('additionalEntriesForm').addEventListener('submit', function() {
event.preventDefault(); // Prevent default form submission
const submitButtons = document.getElementsByClassName('submit-btn');
for (let i = 0; i < submitButtons.length; i++) {
submitButtons[i].disabled = true;
submitButtons[i].innerText = 'Submitting...';
}
this.submit(); // Submit the form programmatically
});
document.getElementById('editEntriesForm').addEventListener('submit', function() {
event.preventDefault(); // Prevent default form submission
const submitButtons = document.getElementsByClassName('submit-btn');
for (let i = 0; i < submitButtons.length; i++) {
submitButtons[i].disabled = true;
submitButtons[i].innerText = 'Submitting...';
}
this.submit(); // Submit the form programmatically
});
</script>