584 lines
21 KiB
PHP
584 lines
21 KiB
PHP
|
|
|
|
<?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;
|
|
}
|
|
|
|
|
|
|
|
/* #drierTable th:nth-child(1),
|
|
#drierTable th:nth-child(2),
|
|
#drierTable td:nth-child(1),
|
|
#drierTable td:nth-child(2) {
|
|
position: sticky;
|
|
left: 0;
|
|
background-color: white;
|
|
z-index: 2;
|
|
border-right: 1px solid #ddd;
|
|
}
|
|
#drierTable th:nth-child(1),
|
|
#drierTable td:nth-child(1) {
|
|
z-index: 3;
|
|
} */
|
|
</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>
|
|
</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 Pre 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>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
<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 width="79" height="45" class="celda_normal"><?php echo DateTime::createFromFormat('Y-m-d', $a['date'])->format('d-m-Y'); ?></td>
|
|
<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 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 class="celda_normal">
|
|
<?php echo $a['drier_running_hours']; ?>
|
|
</td>
|
|
<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 class="celda_normal" contenteditable="true" >
|
|
<?php echo $a['input_sand_moisture']; ?>
|
|
</td>
|
|
<td class="celda_normal" onkeyup="gasPerTon(this.parentNode.id,this.textContent);" contenteditable="true" >
|
|
<?php echo $a['total_gas_consumption']; ?>
|
|
</td>
|
|
<td class="celda_normal">
|
|
<?php echo $a['gas_per_ton']; ?>
|
|
</td>
|
|
<td class="celda_normal" onkeyup="moistureLossQty(this.parentNode.id,this.textContent);" contenteditable="true" >
|
|
<?php echo $a['input_sand_qty']; ?>
|
|
</td>
|
|
<td class="celda_normal" >
|
|
<?php echo $a['moisture_loss_qty']; ?>
|
|
</td>
|
|
<td class="celda_normal" onkeyup="gasPerTon(this.parentNode.id, this.textContent); moistureLossQty(this.parentNode.id, this.textContent); qtyPerHrs(this.parentNode.id, this.textContent)" contenteditable="true" >
|
|
<?php echo $a['sand_dried_qty']; ?>
|
|
</td>
|
|
<td class="celda_normal" >
|
|
<?php echo $a['qty_per_hours']; ?>
|
|
</td>
|
|
<td class="celda_normal" contenteditable="true" >
|
|
<?php echo $a['dust_qty']; ?>
|
|
</td>
|
|
<td class="celda_normal" contenteditable="true">
|
|
<?php echo $a['customer_name']; ?>
|
|
</td>
|
|
|
|
</tr>
|
|
<?php } ?>
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
|
|
</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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
$(document).ready(function()
|
|
{
|
|
|
|
$('.timeDropdown').select2({
|
|
placeholder: "Select",
|
|
});
|
|
|
|
|
|
|
|
$('#save').click(function() {
|
|
|
|
var alldata = $("#drierTable").tableToJSON();
|
|
|
|
$('#drierTable tbody tr').each(function (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);
|
|
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
});
|
|
$('.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);
|
|
|
|
}
|
|
|
|
});
|
|
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
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
function gasPerTon(parentId , textContent) {
|
|
var tr = $('#' + parentId);
|
|
var totalGasConsumption = tr.find('td:eq(7)').text();
|
|
var sandDriedQty = tr.find('td:eq(11)').text();
|
|
if(totalGasConsumption != '' && sandDriedQty != '')
|
|
{
|
|
var gasPerTon = totalGasConsumption / sandDriedQty;
|
|
|
|
if(gasPerTon != NaN && gasPerTon != Infinity)
|
|
tr.find('td:eq(8)').text(gasPerTon.toFixed(1));
|
|
|
|
}else{
|
|
tr.find('td:eq(8)').text(0.0);
|
|
}
|
|
|
|
}
|
|
|
|
function moistureLossQty(parentId , textContent) {
|
|
var tr = $('#' + parentId);
|
|
var inputSandQty = tr.find('td:eq(9)').text();
|
|
var sandDriedQty = tr.find('td:eq(11)').text();
|
|
if(inputSandQty != '' && sandDriedQty != '')
|
|
{
|
|
var moistureLossQty = inputSandQty - sandDriedQty;
|
|
|
|
if(moistureLossQty != NaN && moistureLossQty != Infinity)
|
|
tr.find('td:eq(10)').text(moistureLossQty.toFixed(1));
|
|
|
|
}else{
|
|
tr.find('td:eq(10)').text(0.0);
|
|
}
|
|
|
|
}
|
|
|
|
function qtyPerHrs(parentId , textContent) {
|
|
var tr = $('#' + parentId);
|
|
var drierRunninhHrs = tr.find('td:eq(4)').text();
|
|
var sandDriedQty = tr.find('td:eq(11)').text();
|
|
if(drierRunninhHrs != '' && sandDriedQty != '')
|
|
{
|
|
var qtyPerHrs = sandDriedQty / drierRunninhHrs;
|
|
|
|
if(qtyPerHrs != NaN && qtyPerHrs != Infinity)
|
|
tr.find('td:eq(12)').text(qtyPerHrs.toFixed(3));
|
|
|
|
}else{
|
|
tr.find('td:eq(12)').text(0.000);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|