stock module dev 17/10 -vadivel J
This commit is contained in:
parent
12d85626cf
commit
c0b59d7836
@ -52,6 +52,9 @@ class StockController extends BaseController
|
||||
|
||||
$postData=$this->request->getPost();
|
||||
|
||||
$postData['machineOnTime']=$postData['machineOnTime']. " " .$postData['machineOnTimeAmOrPm'];
|
||||
$postData['machineOffTime']=$postData['machineOffTime']. " " .$postData['machineOffTimeAmOrPm'];
|
||||
|
||||
$inserted= $this->coatingMachineDetails_model->insert($postData);
|
||||
|
||||
if ($inserted) {
|
||||
@ -69,6 +72,9 @@ class StockController extends BaseController
|
||||
|
||||
$putData=$this->request->getPost();
|
||||
|
||||
$putData['machineOnTime']=$putData['machineOnTime']. " " .$putData['machineOnTimeAmOrPm'];
|
||||
$putData['machineOffTime']=$putData['machineOffTime']. " " .$putData['machineOffTimeAmOrPm'];
|
||||
|
||||
$id = $putData['editCoatingMachineDetailId'];
|
||||
|
||||
$updated= $this->coatingMachineDetails_model->update($id,$putData);
|
||||
|
||||
@ -101,7 +101,8 @@
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-success" data-target="#coatingMachineDetailModal" data-toggle="modal" >
|
||||
<button type="button" class="btn btn-success" data-target="#coatingMachineDetailModal"
|
||||
data-toggle="modal">
|
||||
Add New Record
|
||||
</button>
|
||||
</div>
|
||||
@ -115,7 +116,8 @@
|
||||
|
||||
<div class="card-body">
|
||||
|
||||
<table id="datatable" class="table table-hover table-bordered" style="background-color:#fff;">
|
||||
<table id="datatable" class="table table-hover table-bordered"
|
||||
style="background-color:#fff;">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
@ -129,7 +131,8 @@
|
||||
<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;">Per Hour Coating Sand QTY (kg)
|
||||
</th>
|
||||
<th style="text-align:center !important;">Customer Name</th>
|
||||
<th style="text-align:center !important;">Action</th>
|
||||
</tr>
|
||||
@ -155,7 +158,8 @@
|
||||
<td align="center"><?php echo $record['perHourCoatingSandQTY'] ?? '' ?></td>
|
||||
<td align="center"><?php echo $record['customerName']; ?></td>
|
||||
<td align="center">
|
||||
<a data-toggle="tooltip" class="edit-btn" data-target="editCoatingMachineDetailModal" data-toggle="modal"
|
||||
<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>
|
||||
@ -165,8 +169,7 @@
|
||||
|
||||
|
||||
<a data-toggle="tooltip" onclick="confirmDelete(event)"
|
||||
href="<?php echo base_url(); ?>deleteCoatingMachineDetails?id=<?php echo $record['id'] ?>"
|
||||
>
|
||||
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>
|
||||
|
||||
@ -196,7 +199,8 @@
|
||||
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="coatingMachineDetailModal" tabindex="-1" role="dialog" aria-labelledby="coatingMachineDetailModalLabel" aria-hidden="true">
|
||||
<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">
|
||||
@ -217,48 +221,92 @@
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="machineOnTimeHrId">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>
|
||||
<select class="form-control" name="machineOnTime" id="machineOnTimeHrId">
|
||||
<option value="12:00" selected> 12:00</option>
|
||||
<option value="12:30"> 12:30</option>
|
||||
<?php
|
||||
// Loop through the hours 1 to 12
|
||||
for ($hour = 1; $hour < 12; $hour++) {
|
||||
// Display each hour with ":00"
|
||||
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
|
||||
|
||||
echo '<option value="' . $formattedHour . ':00"> ' . $formattedHour . ':00</option>';
|
||||
|
||||
echo '<option value="' . $formattedHour . ':30">' . $formattedHour . ':30</option>';
|
||||
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-1">
|
||||
<label for="machineOnTimeAmOrPmId">am / pm</label>
|
||||
<select class="form-control" name="machineOnTimeAmOrPm" id="machineOnTimeAmOrPmId">
|
||||
<option value="AM" selected>AM</option>
|
||||
<option value="PM">PM</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="machineOffTimeHrId">Machine Off Time</label>
|
||||
<span class="badge mandatory">*</span>
|
||||
<select class="form-control" name="machineOffTime" id="machineOffTimeHrId">
|
||||
<option value="12:00" selected> 12:00</option>
|
||||
<option value="12:30"> 12:30</option>
|
||||
<?php
|
||||
// Loop through the hours 1 to 12
|
||||
for ($hour = 1; $hour < 12; $hour++) {
|
||||
// Display each hour with ":00"
|
||||
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
|
||||
echo '<option value="' . $formattedHour . ':00"> ' . $formattedHour . ':00</option>';
|
||||
|
||||
echo '<option value="' . $formattedHour . ':30">' . $formattedHour . ':30</option>';
|
||||
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-1">
|
||||
<label for="machineOffTimeAmOrPmId">am / pm</label>
|
||||
<select class="form-control" name="machineOffTimeAmOrPm" id="machineOffTimeAmOrPmId">
|
||||
<option value="AM" selected>AM</option>
|
||||
<option value="PM">PM</option>
|
||||
</select>
|
||||
</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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
@ -268,24 +316,33 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="machineRunningInHrsId"> Machine Running In Hrs</label>
|
||||
<span class="badge mandatory">*</span>
|
||||
<input type="text" class="form-control" id="machineRunningInHrsId" name="machineRunningInHrs" required>
|
||||
<input type="text" class="form-control" id="machineRunningInHrsId"
|
||||
name="machineRunningInHrs" required>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="perHourGasConsumptionId">Per Hour Gas Consumption </label>
|
||||
<span class="badge mandatory">*</span>
|
||||
<input type="text" class="form-control" id="perHourGasConsumptionId" name="perHourGasConsumption" required>
|
||||
<input type="text" class="form-control" id="perHourGasConsumptionId"
|
||||
name="perHourGasConsumption" required>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="perHourCoatingSandQTY">Per Hour Coating Sand QTY</label>
|
||||
<span class="badge mandatory">*</span>
|
||||
<input type="text" class="form-control" id="perHourCoatingSandQTYId" name="perHourCoatingSandQTY" required>
|
||||
<input type="text" class="form-control" id="perHourCoatingSandQTYId"
|
||||
name="perHourCoatingSandQTY" required>
|
||||
|
||||
</div>
|
||||
|
||||
@ -303,7 +360,8 @@
|
||||
|
||||
|
||||
<!-- editCoatingMachineDetailModal -->
|
||||
<div class="modal fade" id="editCoatingMachineDetailModal" tabindex="-1" role="dialog" aria-labelledby="editCoatingMachineDetailModalLabel" aria-hidden="true">
|
||||
<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">
|
||||
@ -317,35 +375,77 @@
|
||||
</div>
|
||||
|
||||
<!-- form -->
|
||||
<form method="post" id="editCoatingMachineDetailModalFormId" action="<?php echo base_url(); ?>updateCoatingMachineDetails">
|
||||
<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="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>
|
||||
<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>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="editMachineOnTimeHrId">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>
|
||||
<select class="form-control" name="machineOnTime" id="editMachineOnTimeHrId">
|
||||
<option value="12:00"> 12:00</option>
|
||||
<option value="12:30"> 12:30</option>
|
||||
<?php
|
||||
// Loop through the hours 1 to 12
|
||||
for ($hour = 1; $hour < 12; $hour++) {
|
||||
// Display each hour with ":00"
|
||||
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
|
||||
|
||||
echo '<option value="' . $formattedHour . ':00"> ' . $formattedHour . ':00</option>';
|
||||
|
||||
echo '<option value="' . $formattedHour . ':30">' . $formattedHour . ':30</option>';
|
||||
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-1">
|
||||
<label for="editMachineOnTimeAmOrPmId">am / pm</label>
|
||||
<select class="form-control" name="machineOnTimeAmOrPm" id="editMachineOnTimeAmOrPmId">
|
||||
<option value="AM" selected>AM</option>
|
||||
<option value="PM">PM</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-2">
|
||||
<label for="editMachineOffTimeHrId">Machine Off Time</label>
|
||||
<span class="badge mandatory">*</span>
|
||||
<select class="form-control" name="machineOffTime" id="editMachineOffTimeHrId">
|
||||
<option value="12:00"> 12:00</option>
|
||||
<option value="12:30"> 12:30</option>
|
||||
<?php
|
||||
// Loop through the hours 1 to 12
|
||||
for ($hour = 1; $hour < 12; $hour++) {
|
||||
// Display each hour with ":00"
|
||||
$formattedHour = str_pad($hour, 2, '0', STR_PAD_LEFT);
|
||||
|
||||
echo '<option value="' . $formattedHour . ':00"> ' . $formattedHour . ':00</option>';
|
||||
|
||||
echo '<option value="' . $formattedHour . ':30">' . $formattedHour . ':30</option>';
|
||||
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-1">
|
||||
<label for="editMachineOffTimeAmOrPmId">am / pm</label>
|
||||
<select class="form-control" name="machineOffTimeAmOrPm" id="editMachineOffTimeAmOrPmId">
|
||||
<option value="AM" selected>AM</option>
|
||||
<option value="PM">PM</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -353,14 +453,14 @@
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
@ -373,30 +473,37 @@
|
||||
<span class="badge mandatory">*</span>
|
||||
<input type="text" class="form-control" id="editTotalGasConsumptionId"
|
||||
name="totalGasConsumption" value="" required>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="editMachineRunningInHrsId"> Machine Running In Hrs</label>
|
||||
<span class="badge mandatory">*</span>
|
||||
<input type="text" class="form-control" id="editMachineRunningInHrsId" name="machineRunningInHrs" required>
|
||||
<input type="text" class="form-control" id="editMachineRunningInHrsId"
|
||||
name="machineRunningInHrs" required>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="editPerHourGasConsumptionId">Per Hour Gas Consumption </label>
|
||||
<span class="badge mandatory">*</span>
|
||||
<input type="text" class="form-control" id="editPerHourGasConsumptionId" name="perHourGasConsumption" required>
|
||||
<input type="text" class="form-control" id="editPerHourGasConsumptionId"
|
||||
name="perHourGasConsumption" required>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="editPerHourCoatingSandQTYId">Per Hour Coating Sand QTY</label>
|
||||
<span class="badge mandatory">*</span>
|
||||
<input type="text" class="form-control" id="editPerHourCoatingSandQTYId" name="perHourCoatingSandQTY" required>
|
||||
<input type="text" class="form-control" id="editPerHourCoatingSandQTYId"
|
||||
name="perHourCoatingSandQTY" required>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -521,47 +628,65 @@ $(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
$('#machineOnTimeId').change(function(){
|
||||
let machineOnTime = $(this).val();
|
||||
let machineOffTime =$('#machineOffTimeId').val();
|
||||
$('#machineOnTimeHrId , #machineOnTimeAmOrPmId').change(function () {
|
||||
|
||||
let machineOnDate = $('#dateId').val();
|
||||
|
||||
if (machineOnDate == '') {
|
||||
alert('Please Select Date before entering Machine On and Off Time ..!!');
|
||||
$('#machineOnTimeHrId').val('');
|
||||
return false;
|
||||
}
|
||||
|
||||
let machineOnTimeHr = $('#machineOnTimeHrId').val();
|
||||
let machineOnTimeAmOrPm = $('#machineOnTimeAmOrPmId').val();
|
||||
let machineOffTimeHr = $('#machineOffTimeHrId').val();
|
||||
let machineOffTimeAmOrPm = $('#machineOffTimeAmOrPmId').val();
|
||||
|
||||
|
||||
if( machineOnTime && machineOffTime){
|
||||
|
||||
let machineRunningInHrs= calculateMachineRunInHrs(machineOnTime , machineOffTime );
|
||||
let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOnTimeAmOrPm, machineOffTimeHr, machineOffTimeAmOrPm);
|
||||
|
||||
if (!machineRunningInHrs) {
|
||||
$(this).val('');
|
||||
$('machineOnTimeHrId').val('');
|
||||
return
|
||||
}
|
||||
$('#machineRunningInHrsId').val(machineRunningInHrs);
|
||||
$('#totalCoatingSandId').trigger('change');
|
||||
$('#totalGasConsumptionId').trigger('change');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('#machineOffTimeId').change(function(){
|
||||
$('#machineOffTimeHrId , #machineOffTimeAmOrPmId').change(function () {
|
||||
|
||||
let machineOffTime = $(this).val();
|
||||
let machineOnTime =$('#machineOnTimeId').val();
|
||||
let machineOnDate = $('#dateId').val();
|
||||
|
||||
if (machineOnDate == '') {
|
||||
alert('Please Select Date before entering Machine On and Off Time ..!!');
|
||||
$('#machineOffTimeHrId').val('');
|
||||
return false;
|
||||
}
|
||||
|
||||
let machineOffTimeHr = $('#machineOffTimeHrId').val();
|
||||
let machineOffTimeAmOrPm = $('#machineOffTimeAmOrPmId').val();
|
||||
let machineOnTimeHr = $('#machineOnTimeHrId').val();
|
||||
let machineOnTimeAmOrPm = $('#machineOnTimeAmOrPmId').val();
|
||||
|
||||
|
||||
if( machineOnTime && machineOffTime ){
|
||||
let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOnTimeAmOrPm, machineOffTimeHr, machineOffTimeAmOrPm);
|
||||
|
||||
let machineRunningInHrs= calculateMachineRunInHrs(machineOnTime , machineOffTime );
|
||||
if (!machineRunningInHrs) {
|
||||
|
||||
$(this).val('');
|
||||
$('#machineOffTimeHrId').val('');
|
||||
return
|
||||
}
|
||||
$('#machineRunningInHrsId').val(machineRunningInHrs);
|
||||
$('#totalCoatingSandId').trigger('change');
|
||||
$('#totalGasConsumptionId').trigger('change');
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
@ -600,47 +725,64 @@ $(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
$('#editMachineOnTimeId').change(function(){
|
||||
let machineOnTime = $(this).val();
|
||||
let machineOffTime =$('#editMachineOffTimeId').val();
|
||||
$('#editMachineOnTimeHrId , #editMachineOnTimeAmOrPm').change(function () {
|
||||
|
||||
let machineOnDate = $('#editDateId').val();
|
||||
|
||||
if( machineOnTime && machineOffTime){
|
||||
if (machineOnDate == '') {
|
||||
alert('Please Select Date before entering Machine On and Off Time ..!!');
|
||||
$('#editMachineOnTimeHrId').val('');
|
||||
return false;
|
||||
}
|
||||
|
||||
let machineRunningInHrs= calculateMachineRunInHrs(machineOnTime , machineOffTime );
|
||||
let machineOnTimeHr = $('#editMachineOnTimeHrId').val(); //07:00
|
||||
let machineOnTimeAmOrPm = $('#editMachineOnTimeAmOrPm').val(); //PM
|
||||
let machineOffTimeHr = $('#editMachineOffTimeHrId').val(); //03:00
|
||||
let machineOffTimeAmOrPm = $('#editMachineOffTimeAmOrPm').val(); //PM
|
||||
|
||||
let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOnTimeAmOrPm, machineOffTimeHr, machineOffTimeAmOrPm);
|
||||
|
||||
if (!machineRunningInHrs) {
|
||||
$(this).val('');
|
||||
$('#editMachineOnTimeHrId').val('');
|
||||
return
|
||||
}
|
||||
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
|
||||
$('#editTotalCoatingSandId').trigger('change');
|
||||
$('#editTotalGasConsumptionId').trigger('change');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
$('#editMachineOffTimeId').change(function(){
|
||||
$('#editMachineOffTimeHrId , #editMachineOffTimeAmOrPm ').change(function () {
|
||||
|
||||
let machineOffTime = $(this).val();
|
||||
let machineOnTime =$('#editMachineOnTimeId').val();
|
||||
let machineOnDate = $('#editDateId').val();
|
||||
|
||||
if (machineOnDate == '') {
|
||||
alert('Please Select Date before entering Machine On and Off Time ..!!');
|
||||
$('#editMachineOnTimeHrId').val('');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( machineOnTime && machineOffTime ){
|
||||
let machineOnTimeHr = $('#editMachineOnTimeHrId').val();
|
||||
let machineOnTimeAmOrPm = $('#editMachineOnTimeAmOrPm').val();
|
||||
let machineOffTimeHr = $('#editMachineOffTimeHrId').val();
|
||||
let machineOffTimeAmOrPm = $('#editMachineOffTimeAmOrPm').val();
|
||||
|
||||
let machineRunningInHrs = calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOnTimeAmOrPm, machineOffTimeHr, machineOffTimeAmOrPm);
|
||||
|
||||
let machineRunningInHrs= calculateMachineRunInHrs(machineOnTime , machineOffTime );
|
||||
if (!machineRunningInHrs) {
|
||||
|
||||
$(this).val('');
|
||||
$('#editMachineOffTimeHrId').val('');
|
||||
return
|
||||
}
|
||||
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
|
||||
$('#editTotalCoatingSandId').trigger('change');
|
||||
$('#editTotalGasConsumptionId').trigger('change');
|
||||
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
@ -676,30 +818,104 @@ $(document).ready(function() {
|
||||
|
||||
|
||||
<script>
|
||||
function calculateMachineRunInHrs(machineOnTime , machineOffTime ){
|
||||
function calculateMachineRunInHrs(machineOnDate, machineOnTimeHr, machineOnTimeAmOrPm, machineOffTimeHr, machineOffTimeAmOrPm) {
|
||||
|
||||
let startTime = new Date(machineOnTime);
|
||||
let endTime = new Date(machineOffTime);
|
||||
console.log(machineOnTimeHr);
|
||||
console.log(machineOnTimeAmOrPm);
|
||||
console.log(machineOffTimeHr);
|
||||
console.log(machineOffTimeAmOrPm);
|
||||
|
||||
let startDate = startTime.toISOString().split('T')[0];
|
||||
let endDate = endTime.toISOString().split('T')[0];
|
||||
let machineOnTime12 = machineOnTimeHr + " " + machineOnTimeAmOrPm; //07:00 PM
|
||||
let machineOffTime12 = machineOffTimeHr + " " + machineOffTimeAmOrPm; //03:00 PM
|
||||
|
||||
console.log(machineOnTime12);
|
||||
console.log(machineOffTime12);
|
||||
|
||||
let machineOnTime24 = convertTo24HrFormat(machineOnTime12) + ":00"; //19:00:00
|
||||
let machineOffTime24 = convertTo24HrFormat(machineOffTime12) + ":00"; //15:00:00
|
||||
|
||||
console.log(machineOnTime24);
|
||||
console.log(machineOffTime24);
|
||||
|
||||
let machineOnDateAndTime;
|
||||
let machineOffDateAndTime;
|
||||
|
||||
if (machineOnTimeAmOrPm == 'PM' && machineOffTimeAmOrPm == 'AM') {
|
||||
machineOnDateAndTime = machineOnDate + "T" + machineOnTime24;
|
||||
machineOffDateAndTime = getNextDay(machineOnDate) + "T" + machineOffTime24;
|
||||
} else {
|
||||
machineOnDateAndTime = machineOnDate + "T" + machineOnTime24;
|
||||
machineOffDateAndTime = machineOnDate + "T" + machineOffTime24;
|
||||
|
||||
}
|
||||
|
||||
console.log(machineOnDateAndTime);
|
||||
console.log(machineOffDateAndTime);
|
||||
|
||||
let startTime = new Date(machineOnDateAndTime);
|
||||
let endTime = new Date(machineOffDateAndTime);
|
||||
|
||||
console.log(startTime); //Thu Oct 17 2024 01:00:00 GMT+0530 (India Standard Time)
|
||||
|
||||
console.log(endTime); //Thu Oct 17 2024 05:30:00 GMT+0530 (India Standard Time)
|
||||
|
||||
let startDate = machineOnDateAndTime.split('T')[0];
|
||||
let endDate = machineOffDateAndTime.split('T')[0];
|
||||
|
||||
console.log(startDate); //2024-10-17
|
||||
console.log(endDate); //2024-10-17
|
||||
|
||||
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." );
|
||||
alert("incorrect machine on or off time..!");
|
||||
$('#machineOnTimeHrId').val('');
|
||||
$('#machineOffTimeHrId').val('');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (startTime > endTime) {
|
||||
alert("Start date cannot be greater than end date");
|
||||
$('#machineOnTimeHrId').val('');
|
||||
$('#machineOffTimeHrId').val('');
|
||||
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) ;
|
||||
let timeDifferenceInMinutes = Math.floor(timeDifferenceInMs / (1000 * 60));
|
||||
let hours = Math.floor(timeDifferenceInMinutes / 60);
|
||||
let minutes = timeDifferenceInMinutes % 60;
|
||||
|
||||
let timeDifferenceFormatted = `${hours}.${minutes >= 30 ? 5 : 0}`;
|
||||
|
||||
return Math.abs(timeDifferenceFormatted).toFixed(1);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
function convertTo24HrFormat(timeStr) {
|
||||
const [time, modifier] = timeStr.split(' ');
|
||||
let [hours, minutes] = time.split(':');
|
||||
if (hours === '12') {
|
||||
hours = '00';
|
||||
}
|
||||
if (modifier === 'PM') {
|
||||
hours = parseInt(hours, 10) + 12;
|
||||
}
|
||||
return `${hours}:${minutes}`;
|
||||
}
|
||||
|
||||
function getNextDay(givenDate) {
|
||||
// Given date in 'YYYY-MM-DD' format
|
||||
let date = new Date(givenDate);
|
||||
|
||||
// Increment the date by 1 day
|
||||
date.setDate(date.getDate() + 1);
|
||||
|
||||
// Output the updated date
|
||||
return date.toISOString().split('T')[0];
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -70,9 +70,6 @@
|
||||
|
||||
<link href="<?php echo base_url(); ?>public/new_assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.css">
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/timepicker/1.3.5/jquery.timepicker.min.js"></script>
|
||||
|
||||
<style>
|
||||
.mce-edit-area.mce-container.mce-panel.mce-first.mce-last.mce-stack-layout-item {
|
||||
border-width: 0px 0px 0px !important;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user