ria/app/Views/drierMachineDetails.php
2025-01-28 16:36:07 +05:30

1313 lines
53 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.

<?php
$datefordropdown = format_date($datefordropdown, 0, 'M-Y');
?>
<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;
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%;
}
th.celda_encabezado_general {
background-color: #00a65a;
border: 1px solid #ccc;
color: #ffffff;
font-weight: bold;
padding: 2px 4px;
text-align: center;
min-width: 120px; /* Set a fixed width */
max-width: 120px; /* Ensure it doesn't exceed this width */
white-space: nowrap; /* Prevent text from wrapping */
overflow: hidden; /* Hide overflowing content */
text-overflow: ellipsis; /* Show "..." for overflow text */
}
.celda_encabezado_total {
background-color:#ffffff;
border: 1px solid #ffff;
color: #ffffff;
font-weight: bold;
padding: 2px 4px;
text-align: center;
min-width: 120px; /* Set a fixed width */
max-width: 120px; /* Ensure it doesn't exceed this width */
white-space: nowrap; /* Prevent text from wrapping */
overflow: hidden; /* Hide overflowing content */
text-overflow: ellipsis; /* Show "..." for overflow text */
}
._Separador {
background-color: #fff;
height: 12px;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
width: 7px;
}
._Separador div {
width: 4px;
}
.celda_normal {
border: 1px solid #ccc;
padding: 6px 4px;
min-width: 120px; /* Set a fixed width */
max-width: 120px; /* Ensure it doesn't exceed this width */
white-space: nowrap; /* Prevent text from wrapping */
overflow: hidden; /* Hide overflowing content */
text-overflow: ellipsis; /* Show "..." for overflow text */
}
/*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: #00a65a;
border: 1px solid #ccc;
color: #ffffff;
font-weight: bold;
padding: 6px 10px;
}
.celda_encabezado_total {
background-color:#ffffff !important;
border: 1px solid #ffffff;
color: #ffffff !important;
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: 4px 6px;
}
/* Make entire thead sticky */
.fht-table thead {
position: sticky;
top: 0;
z-index: 20; /* Ensure the entire header stays above table rows */
background-color: #00a65a; /* 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:rgb(80, 187, 217); /* blue background */
color: #ffffff;
border: 1px solid #ddd;
padding:5px;
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 */
}
/* Sticky First Column */
.fht-table th:nth-child(1),
.fht-table td:nth-child(1) {
position: sticky;
left: 0;
background-color:rgb(80, 187, 217); /* blue background */
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: 450px; /* Adjust as needed */
position: relative;
}
</style>
<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">10 Ton Drier Details </h4>
</li>
</ol>
</div>
</div>
</div>
<div class="col-4 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('drierMachineDetails'); ?>" method="post">
<div class="row">
<div class="col-3">
<?php $today = date('M-Y'); ?>
<input type="text" name="month" id="month" value="<?php echo $datefordropdown; ?>" class="form-control" data-provide="datepicker" data-date-format="M-yyyy" data-date-min-view-mode="1">
</div>
<div class="col-3">
<input type="submit" value="Change Month" class="btn btn-success" style="margin-top:0px;">
<button type="button" style="margin-top:0px; background-color:grey" class="btn btn-success" data-target="#additionalEntriesModalId" data-toggle="modal">
Add Shift
</button>
</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 style="cursor:pointer"
class="dropdown-item" data-toggle="modal" data-target="#filterModalId">Filter</a>
<a style="cursor:pointer"
class="dropdown-item" id="drierMachineDetailsExport" href="#">Export</a>
</div>
</div>
</div>
</div>
</form>
<!-- Add table-responsive for horizontal scroll -->
<div class="table-responsive">
<table id="drierTable" class="fht-table table-striped" style="font-size: small;">
<thead>
<tr>
<th class="celda_encabezado_general" style="padding:5px;">Date</th>
<th class="celda_encabezado_general" style="padding:5px;">Drier On Time</th>
<th class="celda_encabezado_general" style="padding:5px;">Drier Off Time</th>
<th class="celda_encabezado_general" style="padding:5px;">Running Hrs</th>
<th class="celda_encabezado_general" style="padding:5px;">Supplier Name</th>
<th class="celda_encabezado_general" style="padding:5px;">Input Sand Qty</th>
<th class="celda_encabezado_general" style="padding:5px;">Input Sand Moisture(%)</th>
<th class="celda_encabezado_general" style="padding:5px;">Sand Dried Qty</th>
<th class="celda_encabezado_general" style="padding:5px;">Total Gas Consumption</th>
<th class="celda_encabezado_general" style="padding:5px;">Gas Per Ton</th>
<th class="celda_encabezado_general" style="padding:5px;">Qty Per Hrs</th>
<th class="celda_encabezado_general" style="padding:5px;">Moisture Loss Qty</th>
<th class="celda_encabezado_general" style="padding:5px;">Dust Qty</th>
<th class="celda_encabezado_general" style="padding:5px;">Customer Name</th>
<th class="celda_encabezado_general" style="display:none;">id</th>
</tr>
</thead>
<?php if(!empty($drierDetails)){ ?>
<tbody style="background-color: #fff;">
<?php $index = 0;
$row = 0;
foreach ($drierDetails as $a) {
$row++;
$index++; ?>
<tr id="<?php echo $row; ?>"
<?php
$date = DateTime::createFromFormat('Y-m-d', $a['date'])->format('Y-m-d');
$currentDate = date('Y-m-d');
if ($date === $currentDate) {
echo 'style="background: #cef0ad;"';
}
?>
<?php
$formattedDate = DateTime::createFromFormat('Y-m-d', $a['date'])->format('d-m-Y');
?>
>
<!-- tr tag closed -->
<!-- td:eq(0) date -->
<td class="celda_normal"><?php echo $formattedDate; ?></td>
<!-- td:eq(1) drier on time -->
<td class="celda_normal">
<select class="timeDropdown drier_on_time" style="width: 100px;">
<option value="">Select</option>
<?php foreach ($timeDropdown as $key => $time) { ?>
<option value="<?= $time; ?>" <?php if ($a['drier_on_time'] == $time) {
echo 'selected';
} ?>><?= $time; ?></option>
<?php } ?>
</select>
</td>
<!-- td:eq(2) drier off time -->
<td class="celda_normal">
<select class="timeDropdown drier_off_time" style="width: 100px;">
<option value="">Select</option>
<?php foreach ($timeDropdown as $key => $time) { ?>
<option value="<?= $time; ?>" <?php if ($a['drier_off_time'] == $time) {
echo 'selected';
} ?>><?= $time; ?></option>
<?php } ?>
</select>
</td>
<!-- td:eq(3) drier_running_hours-->
<td class="celda_normal">
<?php echo $a['drier_running_hours']; ?>
</td>
<!-- td:eq(4) supplier_name -->
<td class="celda_normal" contenteditable="true">
<select class="timeDropdown supplier_name" style="width: 300px;">
<option value="">Select</option>
<?php foreach ($supplierData as $key => $value) { ?>
<option value="<?= $value->SupplierID; ?>" <?php if ($a['supplier_name'] == $value->SupplierID) {
echo 'selected';
} ?>><?= $value->SupplierName; ?></option>
<?php } ?>
</select>
</td>
<!-- td:eq(5) input_sand_qty -->
<td class="celda_normal" oninput="gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this)" contenteditable="true">
<?php echo $a['input_sand_qty']; ?>
</td>
<!-- td:eq(6) input_sand_moisture -->
<td class="celda_normal" contenteditable="true">
<?php echo $a['input_sand_moisture']; ?>
</td>
<!-- td:eq(7) sand_dried_qty -->
<td class="celda_normal" oninput="gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this)" contenteditable="true">
<?php echo $a['sand_dried_qty']; ?>
</td>
<!-- td:eq(8) total_gas_consumption -->
<td class="celda_normal" oninput="gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this)" contenteditable="true">
<?php echo $a['total_gas_consumption']; ?>
</td>
<!-- td:eq(9) gas_per_ton -->
<td class="celda_normal">
<?php echo $a['gas_per_ton']; ?>
</td>
<!-- td:eq(10) qty_per_hours -->
<td class="celda_normal">
<?php echo $a['qty_per_hours']; ?>
</td>
<!-- td:eq(11) moisture_loss_qty -->
<td class="celda_normal">
<?php echo $a['moisture_loss_qty']; ?>
</td>
<!-- td:eq(12) dust_qty -->
<td class="celda_normal" contenteditable="true">
<?php echo $a['dust_qty']; ?>
</td>
<!-- td:eq(13) customer_name -->
<td class="celda_normal" contenteditable="true">
<?php echo $a['customer_name']; ?>
</td>
<!-- td:eq(14) id -->
<td class="celda_normal" style="display:none;">
<?php echo $a['id']??''; ?>
</td>
</tr>
<?php
//before closing inner loop
if (!isset($summary['drier_running_hours'])) {
$summary['drier_running_hours'] = 0 ;
$summary['total_gas_consumption'] = 0 ;
$summary['input_sand_qty'] = 0 ;
$summary['moisture_loss_qty'] = 0 ;
$summary['sand_dried_qty'] = 0 ;
$summary['dust_qty'] = 0 ;
}
$summary['drier_running_hours'] += $a['drier_running_hours'] == "-" ? 0 : (float) $a['drier_running_hours'] ;
$summary['total_gas_consumption'] += $a['total_gas_consumption'] == "-" ? 0 : (float) $a['total_gas_consumption'] ;
$summary['input_sand_qty'] += $a['input_sand_qty'] == "-" ? 0 : (float) $a['input_sand_qty'] ;
$summary['moisture_loss_qty'] += $a['moisture_loss_qty'] == "-" ? 0 : (float) $a['moisture_loss_qty'] ;
$summary['sand_dried_qty'] += $a['sand_dried_qty'] == "-" ? 0 : (float) $a['sand_dried_qty'] ;
$summary['dust_qty'] += $a['dust_qty'] == "-" ? 0 : (float) $a['dust_qty'] ;
} ?>
</tbody>
<?php } ?>
</table>
<?php if(!empty($drierDetails)){ ?>
<table id="drierTableSummaryId" class="fht-table table-striped">
<thead >
<tr>
<th class="celda_encabezado_total"
style="padding:5px; border:#ffffff; background-color: #ffffff;">Date value</th>
<th class="celda_encabezado_total" style="padding:5px;">Drier On Time </th>
<th class="celda_encabezado_total" style="padding:5px;">Drier Off Time</th>
<th class="celda_encabezado_total" style="padding:5px;">Running Hrs</th>
<th class="celda_encabezado_total" style="padding:5px;">Supplier Name </th>
<th class="celda_encabezado_total" style="padding:5px;">input Sand Qty</th>
<th class="celda_encabezado_total" style="padding:5px;">inputp Sand Moisture(%)</th>
<th class="celda_encabezado_total" style="padding:5px;">Sand Dried Qty</th>
<th class="celda_encabezado_total" style="padding:5px;">Total Gas Consumption</th>
<th class="celda_encabezado_total" style="padding:5px;">Gas Per Ton</th>
<th class="celda_encabezado_total" style="padding:5px;">Qty Per Hrs</th>
<th class="celda_encabezado_total" style="padding:5px;">Moisture Loss Qty</th>
<th class="celda_encabezado_total" style="padding:5px;">Dust Qty</th>
</tr>
</thead>
<tbody>
<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 "><?=$summary['drier_running_hours']?></td>
<td class="celda_normal ">-</td>
<td class="celda_normal "><?=$summary['input_sand_qty']?></td>
<td class="celda_normal ">-</td>
<td class="celda_normal "><?=$summary['sand_dried_qty']?></td>
<td class="celda_normal "><?=$summary['total_gas_consumption']?></td>
<td class="celda_normal "></td>
<td class="celda_normal "></td>
<td class="celda_normal "><?=$summary['moisture_loss_qty']?></td>
<td class="celda_normal "><?=$summary['dust_qty']?></td>
</tr>
</tbody>
</table>
<?php } ?>
<?php if(empty($drierDetails)){ ?>
<br><br>
<div align="center">
<p><h4 style="color:grey;">No Drier machine details present for this month..!!</h4> </p>
</div>
<?php } ?>
</div><!-- End table-responsive -->
<br>
<div class="row">
<div class="col-md-12 text-right">
<input type="button" class="btn btn-success btn-md px-3" id="save" 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>
<!-- modal section -->
<!-- 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', $datefordropdown);
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">
<?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 To Date</label>
<select id="toDateFilter" name="toDateFilter" class="form-control">
<?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 class="btn btn-primary float-right" onclick="customFilterDate()">Filter</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<!-- additional entries modal -->
<div class="modal fade" id="additionalEntriesModalId" tabindex="-1" role="dialog" aria-labelledby="additionalEntriesIdModalLabelId" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="additionalEntriesIdModalLabelId">Additional Entries</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<form action="<?php echo base_url("/addOrEditdrierMachineDetails")?>" method="POST">
<!--14 -->
<?php $calendarStartDate = DateTime::createFromFormat('M-Y', $datefordropdown)->modify('first day of this month')->format('Y-m-d');?>
<?php $calendarEndDate = DateTime::createFromFormat('M-Y', $datefordropdown)->modify('last day of this month')->format('Y-m-d');?>
<div class="row">
<div class="col-md-3">
<label class="form" for="additionalEntryDateId">Date</label>
<input type="date" class="form-control" id="additionalEntryDateId" name="date" value="<?= $calendarStartDate?>"
min="<?= $calendarStartDate?>" max="<?=$calendarEndDate?>" required>
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryDrierOnTimeId">Drier On Time</label>
<select onchange="calculateMachineRunningHrs()"
class="timeDropdown" style="width: 100px;"
id="additionalEntryDrierOnTimeId" name="drier_on_time">
<option value="">Select</option>
<?php foreach ($timeDropdown as $key => $time) { ?>
<option value="<?= $time; ?>"> <?= $time; ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryDrierOffTimeId">Drier Off Time</label>
<select onchange="calculateMachineRunningHrs()"
class="timeDropdown " style="width: 100px;"
id="additionalEntryDrierOffTimeId" name="drier_off_time">
<option value="">Select</option>
<?php foreach ($timeDropdown as $key => $time) { ?>
<option value="<?= $time; ?>"> <?= $time; ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryRunningHrsId">Running hrs</label>
<input type="text" class="form-control" id="additionalEntryRunningHrsId" name="drier_running_hours" value=""
readonly>
</div>
</div>
<div class="row mt-2">
<div class="col-md-3">
<label class="form" for="additionalEntryInputSandMoistureId">Input Sand Moisture (%)</label>
<input type="text" class="form-control" id="additionalEntryInputSandMoistureId" name="input_sand_moisture" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryTotalGasConsumptionId">Total Gas Consumption</label>
<input onchange="additionalEntryGasPerTon(); additionalEntryMoistureLossQty(); additionalEntryQtyPerHrs(); "
type="text" class="form-control" id="additionalEntryTotalGasConsumptionId" name="total_gas_consumption" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntrySandDriedQtyId">Sand Dried Qty</label>
<input onchange="additionalEntryGasPerTon(); additionalEntryMoistureLossQty(); additionalEntryQtyPerHrs(); "
type="text" class="form-control" id="additionalEntrySandDriedQtyId" name="sand_dried_qty" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryGasPerTonId">Gas per Ton</label>
<input type="text" class="form-control" id="additionalEntryGasPerTonId" name="gas_per_ton" value=""
readonly>
</div>
</div>
<div class="row mt-2">
<div class="col-md-3">
<label class="form" for="additionalEntryDustQtyId">Dust Qty</label>
<input type="text" class="form-control" id="additionalEntryDustQtyId" name="dust_qty" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryInputSandQtyId">Input sand Quantity</label>
<input onchange="additionalEntryGasPerTon(); additionalEntryMoistureLossQty(); additionalEntryQtyPerHrs(); "
type="text" class="form-control" id="additionalEntryInputSandQtyId" name="input_sand_qty" value="">
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryMoistureLossQtyId">Moisture Loss Qty</label>
<input type="text" class="form-control" id="additionalEntryMoistureLossQtyId" name="moisture_loss_qty" value=""
readonly>
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryQtyPerHoursId">Qty per Hours</label>
<input type="text" class="form-control" id="additionalEntryQtyPerHoursId" name="qty_per_hours" value=""
readonly>
</div>
</div>
<div class="row mt-2">
<div class="col-md-3">
<label class="form" for="additionalEntrySupplierNameId">Supplier Name</label>
<select class="timeDropdown supplier_name" style="width: 300px;"
id="additionalEntrySupplierNameId" name="supplier_name">
<option value="">Select</option>
<?php foreach ($supplierData as $key => $value) { ?>
<option value="<?= $value->SupplierID; ?>"> <?= $value->SupplierName; ?> </option>
<?php } ?>
</select>
</div>
<div class="col-md-3">
<label class="form" for="additionalEntryCustomerNameId">Customer Name</label>
<input type="text" class="form-control" id="additionalEntryCustomerNameId" name="customer_name" value="">
</div>
</div>
<button type="submit" class="btn btn-primary float-right">Add</button>
<!-- hidden fields -->
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<!-- script section starts -->
<script type="text/javascript">
$(document).ready(function() {
$('.timeDropdown').select2({
placeholder: "Select",
});
$('#save').click(function() {
let alldata = [];
$("#drierTable").find('tbody tr').each(function() {
const rowCells = $(this).find('td');
const rowData = {
date : rowCells.eq(0).text().trim(),
drier_on_time : rowCells.eq(1).text().trim(),
drier_off_time : rowCells.eq(2).text().trim(),
drier_running_hours : rowCells.eq(3).text().trim(),
supplier_name : rowCells.eq(4).text().trim(),
input_sand_qty : rowCells.eq(5).text().trim(),
input_sand_moisture : rowCells.eq(6).text().trim(),
sand_dried_qty : rowCells.eq(7).text().trim(),
total_gas_consumption : rowCells.eq(8).text().trim(),
gas_per_ton : rowCells.eq(9).text().trim(),
qty_per_hours : rowCells.eq(10).text().trim(),
moisture_loss_qty : rowCells.eq(11).text().trim(),
dust_qty : rowCells.eq(12).text().trim(),
customer_name : rowCells.eq(13).text().trim(),
id : rowCells.eq(14).text().trim()
};
alldata.push(rowData);
})
$('#drierTable tbody tr:visible').each(function(index) {
if (alldata[index]) {
let row = alldata[index];
// Get the selected values from dropdowns
row['drier_on_time'] = $(this).find('.drier_on_time').val();
row['drier_off_time'] = $(this).find('.drier_off_time').val();
row['supplier_name'] = $(this).find('.supplier_name').val();
}
});
alldata = JSON.stringify(alldata);
$('#loader').show();
$.ajax({
data: {
drierData: alldata,
},
type: "POST",
url: "<?php echo base_url() ?>addOrEditdrierMachineDetails",
success: function(data) {
if (data) {
$('#loader').hide();
alert(data);
window.location.reload();
}
},
error:function(error){
console.log("error occured", error);
},
complete:function()
{
$('#loader').hide();
console.log('ajax call is completed..!!');
}
});
});
// time diff finding script start
$('.drier_on_time').change(function() {
var tr = $(this).closest('tr');
var drierOnTime = $(this).val();
var drierOffTime = tr.find('.drier_off_time').val();
if(drierOnTime == drierOffTime){
tr.find('td:eq(3)').text(24.00);
gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this);
return;
}
if (drierOnTime != '' && drierOffTime != '') {
const startDate = new Date(`1970-01-01T${convertTo24Hour(drierOnTime)}`);
const endDate = new Date(`1970-01-01T${convertTo24Hour(drierOffTime)}`);
// 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));
const totalHours = hours + (minutes / 60);
tr.find('td:eq(3)').text(totalHours);
gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this);
return;
}
});
$('.drier_off_time').change(function() {
var tr = $(this).closest('tr');
var drierOffTime = $(this).val();
var drierOnTime = tr.find('.drier_on_time').val();
if(drierOnTime == drierOffTime){
tr.find('td:eq(3)').text(24.00);
gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this);
return;
}
if (drierOnTime != '' && drierOffTime != '') {
const startDate = new Date(`1970-01-01T${convertTo24Hour(drierOnTime)}`);
const endDate = new Date(`1970-01-01T${convertTo24Hour(drierOffTime)}`);
// 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));
const totalHours = hours + (minutes / 60);
tr.find('td:eq(3)').text(totalHours);
gasPerTon(this);
moistureLossQty(this);
qtyPerHrs(this);
}
});
});
</script>
<script>
function gasPerTon(value) {
let tr = $(value).closest('tr');
var totalGasConsumption = tr.find('td:eq(8)').text();
var sandDriedQty = tr.find('td:eq(7)').text();
if (totalGasConsumption != '' && sandDriedQty != '') {
var gasPerTon = parseFloat(totalGasConsumption) / parseFloat(sandDriedQty);
if (gasPerTon && gasPerTon != NaN && gasPerTon != Infinity)
tr.find('td:eq(9)').text(gasPerTon.toFixed(2));
}
}
function moistureLossQty(value) {
let tr = $(value).closest('tr');
var inputSandQty = tr.find('td:eq(5)').text();
var sandDriedQty = tr.find('td:eq(7)').text();
if (inputSandQty != '' && sandDriedQty != '') {
var moistureLossQty = parseFloat(inputSandQty) - parseFloat(sandDriedQty) ;
if (moistureLossQty != NaN && moistureLossQty != Infinity)
tr.find('td:eq(11)').text(moistureLossQty.toFixed(2)) ;
}
}
function qtyPerHrs(value) {
let tr = $(value).closest('tr');
var drierRunninhHrs = tr.find('td:eq(3)').text();
var sandDriedQty = tr.find('td:eq(7)').text();
if (drierRunninhHrs != '' && sandDriedQty != '') {
var qtyPerHrs = parseFloat(sandDriedQty) / parseFloat(drierRunninhHrs);
if (qtyPerHrs && qtyPerHrs != NaN && qtyPerHrs != Infinity)
tr.find('td:eq(10)').text(qtyPerHrs.toFixed(3));
}
}
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}`;
}
// time diff finding script end
function calculateMachineRunningHrs() {
let dreierMachineOnTime = $('#additionalEntryDrierOnTimeId').val();
let dreierMachineOffTime = $('#additionalEntryDrierOffTimeId').val();
if(dreierMachineOnTime == dreierMachineOffTime){
$('#additionalEntryRunningHrsId').val(24.00);
additionalEntryGasPerTon();
additionalEntryMoistureLossQty();
additionalEntryQtyPerHrs();
return;
}
if (dreierMachineOnTime != '' && dreierMachineOffTime != '') {
const startDate = new Date(`1970-01-01T${convertTo24Hour(dreierMachineOnTime)}`);
const endDate = new Date(`1970-01-01T${convertTo24Hour(dreierMachineOffTime)}`);
// 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));
const totalHours = hours + (minutes / 60);
console.log('working here', 'totalHours', totalHours);
if (totalHours != NaN && totalHours != Infinity) {
$('#additionalEntryRunningHrsId').val(totalHours);
additionalEntryGasPerTon();
additionalEntryMoistureLossQty();
additionalEntryQtyPerHrs();
}
}
}
function additionalEntryGasPerTon() {
var totalGasConsumption = $('#additionalEntryTotalGasConsumptionId').val();
var sandDriedQty = $('#additionalEntrySandDriedQtyId').val();
if (totalGasConsumption != '' && sandDriedQty != '') {
var gasPerTon = (parseFloat(totalGasConsumption) / parseFloat(sandDriedQty)).toFixed(2);
if (gasPerTon && gasPerTon != NaN && gasPerTon != Infinity)
$('#additionalEntryGasPerTonId').val(gasPerTon);
}
}
function additionalEntryMoistureLossQty(value) {
var inputSandQty = $('#additionalEntryInputSandQtyId').val();
var sandDriedQty = $('#additionalEntrySandDriedQtyId').val();
if (inputSandQty != '' && sandDriedQty != '') {
var moistureLossQty = parseFloat(inputSandQty) - parseFloat(sandDriedQty);
if (moistureLossQty != NaN && moistureLossQty != Infinity)
$('#additionalEntryMoistureLossQtyId').val(moistureLossQty);
}
}
function additionalEntryQtyPerHrs(value) {
var drierRunninhHrs = $('#additionalEntryRunningHrsId').val();
var sandDriedQty = $('#additionalEntrySandDriedQtyId').val();
if (drierRunninhHrs != '' && sandDriedQty != '') {
var qtyPerHrs = parseFloat(sandDriedQty) / parseFloat(drierRunninhHrs);
if (qtyPerHrs && qtyPerHrs != NaN && qtyPerHrs != Infinity)
$('#additionalEntryQtyPerHoursId').val((qtyPerHrs.toFixed(2)));
}
}
</script>
<script>
function customFilterDate(){
let fromDate = $('#fromDateFilter').val(); //01-12-2024
let toDate = $('#toDateFilter').val(); //05-12-2024
$('#drierTable').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() {
$('#fromDateFilter ').select2();
$('#toDateFilter ').select2();
});
</script>
<!-- excel export -->
<script>
$(document).ready(function(){
function exportTableToExcel(tableID, filename = '') {
let table = document.getElementById(tableID);
let rows = table.rows;
let data = [];
for (let i = 0; i < rows.length; i++) {
let row = rows[i];
let cols = row.querySelectorAll('td, th');
let rowData = [];
for (let j = 0; j < cols.length; j++) {
let cell = cols[j];
// Check if the cell contains a <select> dropdown
let select = cell.querySelector('select');
if (select) {
rowData.push(select.options[select.selectedIndex].text); // Get only selected value
} else {
rowData.push(cell.innerText.trim()); // Normal text
}
}
data.push(rowData);
}
let wb = XLSX.utils.book_new();
let ws = XLSX.utils.aoa_to_sheet(data);
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
XLSX.writeFile(wb, filename || 'export.xlsx');
}
let tableId = 'drierTable';
document.getElementById('drierMachineDetailsExport').addEventListener('click',function(){
exportTableToExcel(tableId,'drierMachineDetails_<?=$datefordropdown?>.xlsx');
})
})
</script>
<!-- script section ends -->