Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme

This commit is contained in:
vadivel J 2024-10-10 12:53:34 +05:30
commit 54e927f0b2
2 changed files with 186 additions and 38 deletions

View File

@ -48,23 +48,6 @@ class StockController extends BaseController
public function addNewCoatingMachineDetails(){
$postData=$this->request->getPost();
$machineOnTime = $postData['machineOnTime'];
$machineOffTime = $postData['machineOffTime'];
$onTime = new DateTime($machineOnTime);
$offTime = new DateTime($machineOffTime);
$timeDifference = $onTime->diff($offTime);
$machineRunningInHrs = $timeDifference->h ;
$postData['machineRunningInHrs'] = $machineRunningInHrs;
$postData['perHourGasConsumption'] = number_format((float)$postData['totalGasConsumption'] / $machineRunningInHrs, 2, '.', '');
$postData['perHourCoatingSandQTY'] = number_format((float)$postData['totalCoatingSandInKg'] / $machineRunningInHrs, 2, '.', '');
$inserted= $this->coatingMachineDetails_model->insert($postData);

View File

@ -206,25 +206,25 @@
<label for="dateId">Date</label>
<span class="badge mandatory">*</span>
<input type="date" class="form-control" id="dateId"
name="date" value="">
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="">
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="time" class="form-control" id="machineOnTimeId"
name="machineOnTime" value="">
<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="time" class="form-control" id="machineOffTimeId"
name="machineOffTime" value="">
<input type="datetime-local" class="form-control" id="machineOffTimeId"
name="machineOffTime" value="" required>
</div>
</div>
@ -234,27 +234,32 @@
<label for="customerNameId">Customer Name</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="customerNameId"
name="customerName" value="">
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="">
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="">
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="">
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="perHourCoatingSandQTYId" >
</div>
@ -292,26 +297,26 @@
<label for="editDateId">Date</label>
<span class="badge mandatory">*</span>
<input type="date" class="form-control" id="editDateId"
name="date" value="">
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="">
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="time" class="form-control" id="editMachineOnTimeId"
name="machineOnTime" value="">
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="time" class="form-control" id="editMachineOffTimeId"
name="machineOffTime" value="">
name="machineOffTime" value="" required>
</div>
</div>
@ -321,28 +326,33 @@
<label for="editCustomerNameId">Customer Name</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editCustomerNameId"
name="customerName" value="">
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="">
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="">
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="">
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="perHourCoatingSandQTYId" >
</div>
</div>
@ -427,9 +437,7 @@ $(document).ready(function() {
</script>
<!-- tempchanges -->
<!-- appending values in the edit coating machine detail modal from the table -->
<script>
$(document).ready(function() {
@ -474,3 +482,160 @@ $(document).ready(function() {
});
</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();
console.log(machineOnTime);
console.log(machineOffTime);
if( machineOnTime && machineOffTime){
let machineRunningInHrs= calculateHours(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();
console.log(machineOnTime);
console.log(machineOffTime);
if( machineOnTime && machineOffTime ){
let machineRunningInHrs= calculateHours(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');
if(totalCoatingSandValue && machineRunningInHrsValue){
let perHourCoatingSandQTYValue= (totalCoatingSandValue / machineRunningInHrsValue).toFixed(2);
$('#perHourCoatingSandQTYId').val(perHourCoatingSandQTYValue);
}
})
$('#totalGasConsumptionId').change(function(){
let totalGasConsumptionValue=$(this).val();
let machineRunningInHrsValue= $('#machineRunningInHrsId');
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')
$('#editMachineOffTimeId')
$('#editTotalCoatingSandId')
$('#editTotalGasConsumptionId')
$('#editMachineRunningInHrsId')
$('#editPerHourGasConsumptionId')
$('#editPerHourCoatingSandQTYId')
})
</script>
<!-- utility function for input elements of type="time" -->
<script>
function calculateHours(machineOnTime , machineOffTime , date){
return hours;
}
</script>
<script>
function calculateHours(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>