683 lines
26 KiB
PHP
683 lines
26 KiB
PHP
<style>
|
|
#datatable_filter {
|
|
float: inline-end;
|
|
}
|
|
|
|
#datatable_wrapper .row .col-sm-4 {
|
|
flex-basis: 50%;
|
|
float: inline-end;
|
|
}
|
|
|
|
#datatable_paginate .pagination {
|
|
flex-basis: 50%;
|
|
float: inline-end;
|
|
margin: 0 0 15px;
|
|
}
|
|
|
|
#datatable_wrapper .row:nth-child(3),
|
|
#datatable_wrapper .row:nth-child(1) {
|
|
padding: 0 15px;
|
|
}
|
|
|
|
#datatable_info {
|
|
margin-top: 5px;
|
|
}
|
|
|
|
.dataTables_wrapper {
|
|
padding-bottom: 0;
|
|
}
|
|
|
|
.Date-filter-form {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
/* Adjust the gap as needed */
|
|
}
|
|
|
|
.Date-filter-form input,
|
|
.Date-filter-form button {
|
|
padding: 5px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.Date-filter-form button {
|
|
background-color: #007bff;
|
|
color: white;
|
|
border: none;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.Date-filter-form button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
|
|
.icon-button {
|
|
background: none;
|
|
border: none;
|
|
cursor: pointer;
|
|
color: #007bff;
|
|
font-size: 18px;
|
|
}
|
|
|
|
.icon-button:hover {
|
|
color: #0056b3;
|
|
}
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="content-page">
|
|
<div class="content">
|
|
<!-- Start Content-->
|
|
<div class="container-fluid">
|
|
<!-- start page title -->
|
|
<div>
|
|
<?php
|
|
helper('form');
|
|
$error = session()->getFlashdata('error');
|
|
if ($error) {
|
|
$type = "error";
|
|
echo show_alert($type, $error);
|
|
}
|
|
$success = session()->getFlashdata('success');
|
|
if ($success) {
|
|
$type = "success";
|
|
echo show_alert($type, $success);
|
|
}
|
|
?>
|
|
<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>
|
|
|
|
<button type="button" class="btn btn-success" data-target="#coatingMachineDetailModal" data-toggle="modal" >
|
|
Add New Record
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
|
|
<div class="card-body">
|
|
|
|
<table id="datatable" class="table table-hover table-bordered" style="background-color:#fff;">
|
|
|
|
<thead>
|
|
<tr>
|
|
<th style="text-align:center !important;">Customer Name</th>
|
|
<th style="text-align:center !important;">Date</th>
|
|
<th style="text-align:center !important;">Shift</th>
|
|
<th style="text-align:center !important;">Machine On Time</th>
|
|
<th style="text-align:center !important;">Machine Off Time</th>
|
|
<th style="text-align:center !important;">Machine Running (hr)</th>
|
|
<th style="text-align:center !important;">Total Coating</th>
|
|
<th style="text-align:center !important;">Total Coating Sand (kg)</th>
|
|
<th style="text-align:center !important;">Total Gas Consumption</th>
|
|
<th style="text-align:center !important;">Per Hour Gas Consumption</th>
|
|
<th style="text-align:center !important;">Per Hour Coating Sand QTY (kg)</th>
|
|
<th style="text-align:center !important;">Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
|
|
if (!empty($coatingMachineDetails)) {
|
|
|
|
foreach ($coatingMachineDetails as $record) {
|
|
?>
|
|
<tr data-id="<?php echo $record['id']; ?>">
|
|
<td align="center"><?php echo $record['customerName']; ?></td>
|
|
<td align="center"><?php echo $record['date'] ?></td>
|
|
<td align="center"><?php echo $record['shift'] ?></td>
|
|
<td align="center"><?php echo $record['machineOnTime'] ?></td>
|
|
<td align="center"><?php echo $record['machineOffTime'] ?></td>
|
|
<td align="center"><?php echo $record['machineRunningInHrs']??'' ?></td>
|
|
<td align="center"><?php echo $record['totalCoating'] ?></td>
|
|
<td align="center"><?php echo $record['totalCoatingSandInKg'] ?></td>
|
|
<td align="center"><?php echo $record['totalGasConsumption'] ?></td>
|
|
<td align="center"><?php echo $record['perHourGasConsumption']??'' ?></td>
|
|
<td align="center"><?php echo $record['perHourCoatingSandQTY']??'' ?></td>
|
|
<td align="center">
|
|
<a data-toggle="tooltip" class="edit-btn" data-target="editCoatingMachineDetailModal" data-toggle="modal"
|
|
style="cursor:pointer">
|
|
<i class="fa fa-pencil-alt" data-toggle="tooltip"
|
|
title="Click here to Edit "></i>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<a data-toggle="tooltip" onclick="confirmDelete(event)"
|
|
href="<?php echo base_url(); ?>deleteCoatingMachineDetails?id=<?php echo $record['id'] ?>"
|
|
>
|
|
<i class="fa fa-trash" data-toggle="tooltip"
|
|
title="Click here to Delete "></i>
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
</td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
|
|
</tbody>
|
|
</table>
|
|
</div> <!-- end card body-->
|
|
</div> <!-- end card -->
|
|
</div><!-- end col-->
|
|
</div>
|
|
</div>
|
|
</div> <!-- container -->
|
|
</div> <!-- content -->
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Modal -->
|
|
<div class="modal fade" id="coatingMachineDetailModal" tabindex="-1" role="dialog" aria-labelledby="coatingMachineDetailModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-xl" 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">×</span>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- form -->
|
|
<form method="post" action="<?php echo base_url(); ?>addNewCoatingMachineDetails">
|
|
<div class="modal-body">
|
|
|
|
<div class="form-row">
|
|
<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="" required>
|
|
</div>
|
|
<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>
|
|
<div class="form-group col-md-3">
|
|
<label for="machineOnTimeId">Machine On Time</label>
|
|
<span class="badge mandatory">*</span>
|
|
<input type="datetime-local" class="form-control" id="machineOnTimeId"
|
|
name="machineOnTime" value="" required>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="machineOffTimeId">Machine Off Time</label>
|
|
<span class="badge mandatory">*</span>
|
|
<input type="datetime-local" class="form-control" id="machineOffTimeId"
|
|
name="machineOffTime" value="" required>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<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>
|
|
<div class="form-group col-md-3">
|
|
<label for="totalCoatingId">Total Coating</label>
|
|
<span class="badge mandatory">*</span>
|
|
<input type="text" class="form-control" id="totalCoatingId"
|
|
name="totalCoating" value="" required>
|
|
</div>
|
|
<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>
|
|
<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>
|
|
|
|
<!-- hidden input fields -->
|
|
<input type="hidden" class="form-control" id="machineRunningInHrsId" name="machineRunningInHrs">
|
|
<input type="hidden" class="form-control" id="perHourGasConsumptionId" name="perHourGasConsumption">
|
|
<input type="hidden" class="form-control" id="perHourCoatingSandQTYId" name="perHourCoatingSandQTY" >
|
|
|
|
</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">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-xl" 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">×</span>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- form -->
|
|
<form method="post" id="editCoatingMachineDetailModalFormId" action="<?php echo base_url(); ?>updateCoatingMachineDetails">
|
|
<div class="modal-body">
|
|
|
|
<div class="form-row">
|
|
<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>
|
|
<input type="hidden" name="editCoatingMachineDetailId" id="editCoatingMachineDetailId">
|
|
</div>
|
|
<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>
|
|
<div class="form-group col-md-3">
|
|
<label for="editMachineOnTimeId">Machine On Time</label>
|
|
<span class="badge mandatory">*</span>
|
|
<input type="datetime-local" class="form-control" id="editMachineOnTimeId"
|
|
name="machineOnTime" value="" required>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label for="editMachineOffTimeId">Machine Off Time</label>
|
|
<span class="badge mandatory">*</span>
|
|
<input type="datetime-local" class="form-control" id="editMachineOffTimeId"
|
|
name="machineOffTime" value="" required>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<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>
|
|
<div class="form-group col-md-3">
|
|
<label for="editTotalCoatingId">Total Coating</label>
|
|
<span class="badge mandatory">*</span>
|
|
<input type="text" class="form-control" id="editTotalCoatingId"
|
|
name="totalCoating" value="" required>
|
|
</div>
|
|
<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>
|
|
<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>
|
|
|
|
</div>
|
|
|
|
<!-- hidden input fields -->
|
|
<input type="hidden" class="form-control" id="editMachineRunningInHrsId" name="machineRunningInHrs">
|
|
<input type="hidden" class="form-control" id="editPerHourGasConsumptionId" name="perHourGasConsumption">
|
|
<input type="hidden" class="form-control" id="editPerHourCoatingSandQTYId" name="perHourCoatingSandQTY" >
|
|
|
|
</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">Save </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 type="text/javascript">
|
|
|
|
$(function () {
|
|
|
|
$('#datatable').DataTable({
|
|
"paging": true,
|
|
"lengthChange": true,
|
|
"searching": true,
|
|
"ordering": true,
|
|
"info": true,
|
|
"autoWidth": true,
|
|
"pageLength": 10,
|
|
"lengthMenu": [10, 25, 50, 100]
|
|
|
|
});
|
|
});
|
|
|
|
</script> -->
|
|
<script>
|
|
$(document).ready(function() {
|
|
$.fn.dataTable.ext.type.order['date-eu-pre'] = function(date) {
|
|
var dateSplit = date.split('-');
|
|
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
|
|
};
|
|
// Initialize the DataTable
|
|
|
|
var table = $('#datatable').DataTable({
|
|
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
|
|
buttons: [
|
|
'copy', 'csv', 'excel', 'pdf', 'print' // Export buttons
|
|
],
|
|
pageLength: 10, // Default rows per page
|
|
lengthMenu: [ [10, 20, 30, 50, -1], [10, 20, 30, 50, "All"] ], // Rows per page options
|
|
// responsive: true, // Responsive table
|
|
order: [], // Default ordering (column index 0, descending)
|
|
language: {
|
|
paginate: {
|
|
next: '<i class="fas fa-angle-right"></i>', // Next button icon
|
|
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
// Handle form submission
|
|
$("#DateRangeFilter").submit(function(e) {
|
|
e.preventDefault();
|
|
table.draw();
|
|
});
|
|
});
|
|
</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();
|
|
});
|
|
</script>
|
|
|
|
|
|
<!-- appending values in the edit coating machine detail modal from the table -->
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
$('#datatable tbody').on('click', '.edit-btn', function() {
|
|
|
|
var row = $(this).closest('tr');
|
|
|
|
// Get values from the row
|
|
var customerName = row.find('td:eq(0)').text();
|
|
var date = row.find('td:eq(1)').text();
|
|
var shift = row.find('td:eq(2)').text();
|
|
var machineOnTime = row.find('td:eq(3)').text();
|
|
var machineOffTime = row.find('td:eq(4)').text();
|
|
var machineRunningInHrs= row.find('td:eq(5)').text();
|
|
var totalCoating = row.find('td:eq(6)').text();
|
|
var totalCoatingSandInKg = row.find('td:eq(7)').text();
|
|
var totalGasConsumption = row.find('td:eq(8)').text();
|
|
var perHourGasConsumption =row.find('td:eq(9)').text();
|
|
var perHourCoatingSandQTY =row.find('td:eq(10)').text();
|
|
|
|
|
|
|
|
// Fill the modal fields with the values
|
|
|
|
$('#editCustomerNameId').val(customerName);
|
|
$('#editDateId').val(date);
|
|
$('#editShiftId').val(shift);
|
|
$('#editMachineOnTimeId').val(machineOnTime);
|
|
$('#editMachineOffTimeId').val(machineOffTime);
|
|
$('#editTotalCoatingId').val(totalCoating);
|
|
$('#editTotalCoatingSandId').val(totalCoatingSandInKg);
|
|
$('#editTotalGasConsumptionId').val(totalGasConsumption);
|
|
$('#editCoatingMachineDetailId').val(row.data('id'));
|
|
|
|
|
|
// Show the modal
|
|
$('#editCoatingMachineDetailModal').modal('show');
|
|
});
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<!-- calculations for some fields needed in onChange while adding coating machine details -->
|
|
|
|
<script>
|
|
|
|
$(document).ready(function(){
|
|
|
|
|
|
$('#machineOnTimeId').change(function(){
|
|
let machineOnTime = $(this).val();
|
|
let machineOffTime =$('#machineOffTimeId').val();
|
|
|
|
|
|
if( machineOnTime && machineOffTime){
|
|
|
|
let machineRunningInHrs= calculateMachineRunInHrs(machineOnTime , machineOffTime );
|
|
|
|
if(!machineRunningInHrs){
|
|
$(this).val('');
|
|
return
|
|
}
|
|
$('#machineRunningInHrsId').val(machineRunningInHrs);
|
|
$('#totalCoatingSandId').trigger('change');
|
|
$('#totalGasConsumptionId').trigger('change');
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
$('#machineOffTimeId').change(function(){
|
|
|
|
let machineOffTime = $(this).val();
|
|
let machineOnTime =$('#machineOnTimeId').val();
|
|
|
|
|
|
if( machineOnTime && machineOffTime ){
|
|
|
|
let machineRunningInHrs= calculateMachineRunInHrs(machineOnTime , machineOffTime );
|
|
if(!machineRunningInHrs){
|
|
|
|
$(this).val('');
|
|
return
|
|
}
|
|
$('#machineRunningInHrsId').val(machineRunningInHrs);
|
|
$('#totalCoatingSandId').trigger('change');
|
|
$('#totalGasConsumptionId').trigger('change');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
$('#totalCoatingSandId').change(function(){
|
|
|
|
let totalCoatingSandValue= $(this).val();
|
|
let machineRunningInHrsValue= $('#machineRunningInHrsId').val();
|
|
|
|
if(totalCoatingSandValue && machineRunningInHrsValue){
|
|
let perHourCoatingSandQTYValue= (totalCoatingSandValue / machineRunningInHrsValue).toFixed(2);
|
|
$('#perHourCoatingSandQTYId').val(perHourCoatingSandQTYValue);
|
|
}
|
|
|
|
|
|
})
|
|
|
|
$('#totalGasConsumptionId').change(function(){
|
|
|
|
let totalGasConsumptionValue=$(this).val();
|
|
let machineRunningInHrsValue= $('#machineRunningInHrsId').val();
|
|
if(totalGasConsumptionValue && machineRunningInHrsValue){
|
|
let perHourGasConsumptionValue= (totalGasConsumptionValue / machineRunningInHrsValue).toFixed(2);
|
|
$('#perHourGasConsumptionId').val(perHourGasConsumptionValue);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
<!-- calculations for some fields needed in onChange while editing coating machine details -->
|
|
|
|
<script>
|
|
$(document).ready(function(){
|
|
|
|
|
|
$('#editMachineOnTimeId').change(function(){
|
|
let machineOnTime = $(this).val();
|
|
let machineOffTime =$('#editMachineOffTimeId').val();
|
|
|
|
|
|
if( machineOnTime && machineOffTime){
|
|
|
|
let machineRunningInHrs= calculateMachineRunInHrs(machineOnTime , machineOffTime );
|
|
|
|
if(!machineRunningInHrs){
|
|
$(this).val('');
|
|
return
|
|
}
|
|
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
|
|
$('#editTotalCoatingSandId').trigger('change');
|
|
$('#editTotalGasConsumptionId').trigger('change');
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
$('#editMachineOffTimeId').change(function(){
|
|
|
|
let machineOffTime = $(this).val();
|
|
let machineOnTime =$('#editMachineOnTimeId').val();
|
|
|
|
|
|
if( machineOnTime && machineOffTime ){
|
|
|
|
let machineRunningInHrs= calculateMachineRunInHrs(machineOnTime , machineOffTime );
|
|
if(!machineRunningInHrs){
|
|
|
|
$(this).val('');
|
|
return
|
|
}
|
|
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
|
|
$('#editTotalCoatingSandId').trigger('change');
|
|
$('#editTotalGasConsumptionId').trigger('change');
|
|
|
|
}
|
|
|
|
})
|
|
|
|
$('#editTotalCoatingSandId').change(function(){
|
|
|
|
let totalCoatingSandValue= $(this).val();
|
|
let machineRunningInHrsValue= $('#editMachineRunningInHrsId').val();
|
|
|
|
if(totalCoatingSandValue && machineRunningInHrsValue){
|
|
let perHourCoatingSandQTYValue= (totalCoatingSandValue / machineRunningInHrsValue).toFixed(2);
|
|
$('#editPerHourCoatingSandQTYId').val(perHourCoatingSandQTYValue);
|
|
}
|
|
|
|
|
|
})
|
|
|
|
$('#editTotalGasConsumptionId').change(function(){
|
|
|
|
let totalGasConsumptionValue=$(this).val();
|
|
let machineRunningInHrsValue= $('#editMachineRunningInHrsId').val();
|
|
if(totalGasConsumptionValue && machineRunningInHrsValue){
|
|
let perHourGasConsumptionValue= (totalGasConsumptionValue / machineRunningInHrsValue).toFixed(2);
|
|
$('#editPerHourGasConsumptionId').val(perHourGasConsumptionValue);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
</script>
|
|
|
|
<!-- utility function for input elements of type="time" -->
|
|
|
|
|
|
<script>
|
|
function calculateMachineRunInHrs(machineOnTime , machineOffTime ){
|
|
|
|
let startTime = new Date(machineOnTime);
|
|
let endTime = new Date(machineOffTime);
|
|
|
|
let startDate = startTime.toISOString().split('T')[0];
|
|
let endDate = endTime.toISOString().split('T')[0];
|
|
|
|
if (startDate === endDate && startTime.getTime() >= endTime.getTime()) {
|
|
alert(" Machine On time cannot be greater than or equal to Machine Off time on the same day." );
|
|
return false;
|
|
}
|
|
|
|
if (startTime > endTime) {
|
|
alert( "Start date cannot be greater than end date");
|
|
return false
|
|
}
|
|
|
|
let timeDifferenceInMs = endTime - startTime;
|
|
|
|
// Convert the time difference from milliseconds to hours
|
|
let timeDifferenceInHours = timeDifferenceInMs / (1000 * 60 * 60);
|
|
|
|
// Display the result in hours
|
|
return Math.abs(timeDifferenceInHours).toFixed(2) ;
|
|
}
|
|
</script>
|