ria/app/Views/drierMachineDetails.php
2024-12-24 14:31:44 +05:30

1006 lines
40 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%;
}
.celda_encabezado_general {
background-color: #00a65a;
border: 1px solid #ccc;
color: #ffffff;
font-weight: bold;
padding: 2px 4px;
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 --> */
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;
}
#drierTable th:nth-child(1) {
position: sticky;
left: 0;
background-color: #00a65a;
z-index: 2;
border-right: 2px solid #ddd;
color: #ffffff;
}
#drierTable td:nth-child(1) {
position: sticky;
left: 0;
background-color: #ffffff;
z-index: 2;
border-right: 2px solid #ddd;
color: #0e0b0b;
}
</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-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('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;">
</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" data-toggle="modal" data-target="#additionalEntriesModalId">Add Entry</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: 10px;">Date</th>
<th class="celda_encabezado_general" style="padding: 10px;">Drier On Time</th>
<th class="celda_encabezado_general" style="padding: 10px;">Drier Off Time</th>
<th class="celda_encabezado_general" style="padding: 10px;">Running Hrs</th>
<th class="celda_encabezado_general" style="padding: 10px;">Supplier Name</th>
<th class="celda_encabezado_general" style="padding: 10px;">i/p Sand Moisture(%)</th>
<th class="celda_encabezado_general" style="padding: 10px;">Tot Gas Consumption</th>
<th class="celda_encabezado_general" style="padding: 10px;">Gas Per Ton</th>
<th class="celda_encabezado_general" style="padding: 10px;">i/p Sand Qty</th>
<th class="celda_encabezado_general" style="padding: 10px;">Moisture Loss Qty</th>
<th class="celda_encabezado_general" style="padding: 10px;">Sand Dried Qty</th>
<th class="celda_encabezado_general" style="padding: 10px;">Qty Per Hrs</th>
<th class="celda_encabezado_general" style="padding: 10px;">Dust Qty</th>
<th class="celda_encabezado_general" style="padding: 10px;">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;"';
}
?>>
<!-- td:eq(0) date -->
<td width="79" height="45" class="celda_normal"><?php echo DateTime::createFromFormat('Y-m-d', $a['date'])->format('d-m-Y'); ?></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_moisture -->
<td class="celda_normal" contenteditable="true">
<?php echo $a['input_sand_moisture']; ?>
</td>
<!-- td:eq(6) 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(7) gas_per_ton -->
<td class="celda_normal">
<?php echo $a['gas_per_ton']; ?>
</td>
<!-- td:eq(8) 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(9) moisture_loss_qty -->
<td class="celda_normal">
<?php echo $a['moisture_loss_qty']; ?>
</td>
<!-- td:eq(10) 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(11) qty_per_hours -->
<td class="celda_normal">
<?php echo $a['qty_per_hours']; ?>
</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 } ?>
</tbody>
<?php } ?>
</table>
<?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 -->
<div class="row">
<div class="col-md-12 text-right">
<input type="button" class="btn btn-success" 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 -->
<div class="modal fade" id="filterModalId" tabindex="-1" role="dialog" aria-labelledby="filterModalLabelId" aria-hidden="true">
<div class="modal-dialog modal-lg">
<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 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 -->
<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="">
</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="Running Hrs" 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="i/p 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="Tot 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="i/p 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 Hrs" 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 type="text/javascript">
$(document).ready(function() {
$('.timeDropdown').select2({
placeholder: "Select",
});
$('#save').click(function() {
var alldata = $("#drierTable").tableToJSON();
console.log('alldata', alldata);
$('#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);
}
},
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 != '') {
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);
}
});
$('.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 != '') {
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(6)').text();
var sandDriedQty = tr.find('td:eq(10)').text();
if (totalGasConsumption != '' && sandDriedQty != '') {
var gasPerTon = parseFloat(totalGasConsumption) / parseFloat(sandDriedQty);
if (gasPerTon && gasPerTon != NaN && gasPerTon != Infinity)
tr.find('td:eq(7)').text(gasPerTon.toFixed(2));
}
}
function moistureLossQty(value) {
let tr = $(value).closest('tr');
var inputSandQty = tr.find('td:eq(8)').text();
var sandDriedQty = tr.find('td:eq(10)').text();
if (inputSandQty != '' && sandDriedQty != '') {
var moistureLossQty = parseFloat(inputSandQty) - parseFloat(sandDriedQty);
if (moistureLossQty != NaN && moistureLossQty != Infinity)
tr.find('td:eq(9)').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(10)').text();
if (drierRunninhHrs != '' && sandDriedQty != '') {
var qtyPerHrs = parseFloat(sandDriedQty) / parseFloat(drierRunninhHrs);
if (qtyPerHrs && qtyPerHrs != NaN && qtyPerHrs != Infinity)
tr.find('td:eq(11)').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 != '') {
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);
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');
}
$(document).ready(function() {
initialFilterDate();
});
function initialFilterDate(){
let fromDate = $('#fromDateFilter').val(); //01-12-2024
let toDate = $('#toDateFilter').val(); //05-12-2024
console.log("from Date and to date ..!!")
console.log(fromDate,toDate);
$('#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();
}
});
}
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>