710 lines
34 KiB
PHP
Executable File
710 lines
34 KiB
PHP
Executable File
<?php
|
||
$datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
||
?>
|
||
<style>
|
||
|
||
|
||
</style>
|
||
<script>
|
||
$('html').bind('keypress', function(e) {
|
||
//alert('Key Pressed');
|
||
if (e.keyCode == 13) {
|
||
return false;
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<style type="text/css">
|
||
.num {
|
||
text-align: right;
|
||
}
|
||
</style>
|
||
<div class="content-wrapper"></div>
|
||
|
||
|
||
<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);">Driver</a></li>
|
||
<li class="breadcrumb-item"><a href="javascript: void(0);">Driver Attendance</a></li>
|
||
<li class="breadcrumb-item active">
|
||
<h4 class="page-title"><?php echo $page_driver_name;?></h4>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<div class="box">
|
||
<div class="box-header">
|
||
<div class="box-tools"></div>
|
||
</div>
|
||
<div class="box-body">
|
||
<div class="row">
|
||
<div class="col-8">
|
||
<form action="<?= base_url('loadDriverAttendance'); ?>" method="get">
|
||
<div class="row">
|
||
<div class="col-4">
|
||
<?php $today = date('M-Y'); ?>
|
||
<input type="text" value="<?php echo $datefordropdown; ?>" name="month_year" class="form-control monthpicker" id="month_year">
|
||
<input type="hidden" name="drv_id" id="drv_id" value="<?php echo $input_driver_id; ?>" >
|
||
</div>
|
||
|
||
<div class="col-4">
|
||
<input type="submit" value="Change Month" class="btn btn-success" style="margin-top:0px;">
|
||
</div>
|
||
<div class="col-4">
|
||
<h4><strong><?php echo $page_driver_name." ( ".$datefordropdown." )"; ?></strong></h4>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="col-4 text-right" id="savebutton">
|
||
|
||
|
||
<?php if($payslip_id == 0){ ?>
|
||
<button type="button" style="margin-top:0px;" class="btn btn-success" data-target="#attendanceModal" data-id="0" data-toggle="modal">
|
||
Add Trip details
|
||
</button>
|
||
<?php }else { ?>
|
||
<span style="color: green;">Payslip Generated</span>
|
||
<?php } ?>
|
||
</div>
|
||
</div></br>
|
||
<div class="table-responsive" style="overflow-x:scroll;">
|
||
<table id="driver_att_listing" class="table dt-responsive nowrap w-100">
|
||
<thead>
|
||
<tr>
|
||
<th>Create Date</th>
|
||
<th>Create By</th>
|
||
<th>Date</th>
|
||
<th>Invoice Number</th>
|
||
<th>Customer</th>
|
||
<th>Quantity</th>
|
||
<th>Vehicle Number</th>
|
||
<th>Salary Amount</th>
|
||
<th>Food Amount</th>
|
||
<th>Total</th>
|
||
<th>Load Type</th>
|
||
<th>Action</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php
|
||
if (!empty($driver_attendance_list)) :
|
||
foreach ($driver_attendance_list as $record) {
|
||
$createdat = new DateTime($record['created_on']);
|
||
$date = $createdat->format('d-m-Y');
|
||
$time = $createdat->format('h:i A');
|
||
$attendancedate = new DateTime($record['date']);
|
||
$attdate = $attendancedate->format('d-m-Y');
|
||
|
||
?>
|
||
<tr>
|
||
<td><?= esc($date) ?></td>
|
||
<td><?= esc($record['FullName']) ?></td>
|
||
<td><?= esc($attdate) ?></td>
|
||
<td><?= esc($record['invoice_number']) ?></td>
|
||
<td><?= esc($record['customer']) ?></td>
|
||
<td><?= esc($record['quantity']) ?></td>
|
||
<td><?= esc($record['vehicle_number']) ?></td>
|
||
<td><?= esc($record['salary_amount']) ?></td>
|
||
<td><?= esc($record['food_amount']) ?></td>
|
||
<td><?= esc($record['salary_amount']+$record['food_amount']) ?></td>
|
||
<td><?= esc($record['load_type']) ?></td>
|
||
<td><?php if($record['payroll_id'] == ''){ ?>
|
||
<a data-toggle="modal" href="#attendanceModal" data-arr='<?php echo json_encode($record); ?>' data-id='<?= esc($record['driver_attendance_id']) ?>'>
|
||
<i class="fas fa-edit"></i>
|
||
</a>
|
||
|
||
<a onclick="confirmDelete(event)" style="cursor:pointer;" href="<?php echo base_url() . 'deleteDriverAttendance?driverAttendanceId=' . esc($record['driver_attendance_id']).'&drv_id='.esc($record['driver_id']).'&month_year='.esc($datefordropdown); ?>">
|
||
|
||
<i class="fa fa-trash"></i>
|
||
</a>
|
||
<?php } ?>
|
||
</td>
|
||
</tr>
|
||
<?php } ?>
|
||
<?php endif; ?>
|
||
</tbody>
|
||
<tfoot>
|
||
<tr>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th>Salary Amount</th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th id="rowTotalAmount"></th>
|
||
<th></th>
|
||
<th></th>
|
||
</tr>
|
||
<tr>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th>Diesel</th>
|
||
<th><input type="text" class="editable" data-column="diesel_amount" <?php echo ($payslip_id != 0) ? 'readonly' : ''; ?> ></th>
|
||
<th></th>
|
||
<th></th>
|
||
</tr>
|
||
<tr>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th>Shed Amount</th>
|
||
<th><input type="text" class="editable" data-column="shed_amount" <?php echo ($payslip_id != 0) ? 'readonly' : ''; ?> ></th>
|
||
<th></th>
|
||
<th></th>
|
||
</tr>
|
||
<tr>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th></th>
|
||
<th>Total</th>
|
||
<th id="totalAmount">-</th>
|
||
<th></th>
|
||
<th></th>
|
||
</tr>
|
||
</tfoot>
|
||
|
||
</table>
|
||
</div>
|
||
<p> </p>
|
||
<div class="row">
|
||
<!-- <div class="col-md-12 text-right" id="savebutton">
|
||
<input type="button" id="submit" value="Save" class="btn btn-success"
|
||
onclick="getAllData();">
|
||
</div> -->
|
||
</div>
|
||
</div><!-- /.box-body -->
|
||
|
||
</div><!-- /.box -->
|
||
</div> <!-- end card body-->
|
||
</div> <!-- end card -->
|
||
</div><!-- end col-->
|
||
</div>
|
||
</div>
|
||
</div> <!-- container -->
|
||
</div> <!-- content -->
|
||
</div>
|
||
|
||
<!-- attendance entries modal -->
|
||
<div class="modal fade" id="attendanceModal" tabindex="-1" role="dialog" aria-labelledby="attendanceTitle" aria-hidden="true">
|
||
<div class="modal-dialog modal-xl" style="width:900px;">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="attendanceTitle">Add Attendance</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body">
|
||
|
||
<form id="attendanceForm" class="form-horizontal" role="form">
|
||
<!--first row -->
|
||
<input type="hidden" class="form-control" id="driver_attendance_id" name="driver_attendance_id">
|
||
<input type="hidden" class="form-control" id="driver_id" name="driver_id">
|
||
<?php $calendarStartDate = DateTime::createFromFormat('M-Y', $datefordropdown)->modify('first day of this month')->format('Y-m-d');?>
|
||
<?php $calendarEndDate = DateTime::createFromFormat('M-Y', $datefordropdown)->modify('last day of this month')->format('Y-m-d');?>
|
||
<?php $calendarCurrDate = DateTime::createFromFormat('M-Y', $datefordropdown)->modify('today')->format('Y-m-d');?>
|
||
<div class="row">
|
||
<div class="col-md-4">
|
||
<label class="form" for="date">Date</label>
|
||
<input type="date" class="form-control" id="date" name="date" value="<?= $calendarCurrDate?>" min="<?= $calendarStartDate?>" max="<?= $calendarEndDate?>" required>
|
||
</div>
|
||
<div class="col-md-4">
|
||
<label class="form" for="driver_name">Driver Name</label>
|
||
<input type="text" class="form-control" id="driver_name" name="driver_name" readonly>
|
||
|
||
</div>
|
||
<div class="col-md-4">
|
||
<label class="form" for="category_type">Category</label>
|
||
<select class="form-control" id="category_type" name="category_type" onchange="resetthefields();">
|
||
<option value="">Select</option>
|
||
<option value="IGR">IGR</option>
|
||
<option value="INVOICE">INVOICE</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- second row -->
|
||
<div class="row mt-2">
|
||
<div class="col-md-4">
|
||
<label class="form" for="invoice_number">Invoice Number</label>
|
||
<input type="text" class="form-control" id="invoice_number" name="invoice_number" onchange="customerandquantity();">
|
||
<!-- <select class="form-control" id="invoice_number" name="invoice_number">
|
||
<option value="">Select</option>
|
||
<?php foreach ($invoice_info as $key => $value) { ?>
|
||
<option value="<?= $value->invoice_id; ?>"> <?= $value->invoice_number; ?> </option>
|
||
<?php } ?>
|
||
</select> -->
|
||
</div>
|
||
<div class="col-md-4">
|
||
<label class="form" for="customer">Customer</label>
|
||
<input type="text" class="form-control" id="customer" name="customer" readonly>
|
||
</div>
|
||
|
||
<div class="col-md-4">
|
||
<label class="form" for="quantity">Quantity</label>
|
||
<input type="text" class="form-control" id="quantity" name="quantity" readonly>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="row mt-2">
|
||
|
||
<div class="col-md-6">
|
||
<label class="form" for="vehicle_number">Vechile Number</label>
|
||
<input type="text" class="form-control" id="vehicle_number" name="vehicle_number" onkeyup="this.value = this.value.toUpperCase();">
|
||
</div>
|
||
|
||
<div class="col-md-6">
|
||
<label class="form" for="load_type">Load Type</label>
|
||
<select class="form-control" id="load_type" name="load_type" onchange="updateSalaryBasedOnType();">
|
||
<option value="">Select</option>
|
||
<option value="Load">Load</option>
|
||
<option value="Waste Core">Waste Core</option>
|
||
</select>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- third row -->
|
||
<div class="row mt-2">
|
||
<div class="col-md-4">
|
||
<label class="form" for="salary_amount">Salary Amount</label>
|
||
<input type="text" class="form-control" id="salary_amount" name="salary_amount" onkeypress="return isNumber(event);" onchange="fetchSalary();">
|
||
</div>
|
||
<div class="col-md-4">
|
||
<label class="form" for="food_amount">Food Amount</label>
|
||
<input type="text" class="form-control" id="food_amount" name="food_amount" onkeypress="return isNumber(event);" onchange="fetchSalary();">
|
||
</div>
|
||
<div class="col-md-4">
|
||
<label class="form" for="total_amount">Total Amount</label>
|
||
<input type="text" class="form-control" id="total_amount" name="total_amount" onkeypress="return isNumber(event);" readonly>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</form>
|
||
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal"
|
||
value="Cancel">Cancel</button>
|
||
<button type="button" class="btn btn-info waves-effect waves-light tempClick"
|
||
id="tempClick">Submit</button>
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div>
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
|
||
<script>
|
||
$('#month_year').datepicker({
|
||
format: 'M-yyyy',
|
||
viewMode: 'months',
|
||
minViewMode: 'months',
|
||
autoclose: true,
|
||
orientation: 'bottom'
|
||
})
|
||
</script>
|
||
<script type="text/javascript">
|
||
|
||
function isNumber(evt) {
|
||
|
||
//alert("hi");
|
||
var iKeyCode = (evt.which) ? evt.which : evt.keyCode
|
||
if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57)) {
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
|
||
</script>
|
||
<script>
|
||
$(document).ready(function () {
|
||
|
||
$("#driver_name").val("<?php echo $page_driver_name; ?>");
|
||
let urlParams = new URLSearchParams(window.location.search);
|
||
let input_driver_id = urlParams.get("drv_id");
|
||
if (input_driver_id !== null) {
|
||
$("#drv_id").val(input_driver_id);
|
||
$("#driver_id").val(input_driver_id);
|
||
}
|
||
else {
|
||
$("#drv_id").val("<?php echo $input_driver_id; ?>");
|
||
$("#driver_id").val("<?php echo $input_driver_id; ?>");
|
||
}
|
||
let input_diesel_amount = "<?php echo $input_diesel_amount; ?>";
|
||
let input_shed_amount = "<?php echo $input_shed_amount; ?>";
|
||
if(input_diesel_amount != '' || input_shed_amount != ''){
|
||
$('input[data-column="diesel_amount"]').val(parseFloat(input_diesel_amount) || 0);
|
||
$('input[data-column="shed_amount"]').val(parseFloat(input_shed_amount) || 0);
|
||
calculateTotal();
|
||
}
|
||
|
||
|
||
|
||
|
||
$("#attendanceModal").on("shown.bs.modal", function (e) {
|
||
|
||
var id = $(e.relatedTarget).data('id');
|
||
let fields = ['invoice_number', 'vehicle_number', 'load_type', 'salary_amount', 'food_amount','customer','quantity','total_amount'];
|
||
|
||
fields.forEach(function(field) {
|
||
$("#" + field).val("");
|
||
});
|
||
|
||
if (id == 0) {
|
||
$('#attendanceTitle').html("Add Driver Trip");
|
||
$("#driver_attendance_id").val(0);
|
||
} else {
|
||
$("#driver_attendance_id").val(id);
|
||
var arr = $(e.relatedTarget).data('arr');
|
||
|
||
fields.forEach(function(field) {
|
||
$("#" + field).val(arr && arr[field] ? arr[field] : "");
|
||
if(field == 'date'){
|
||
$("#date").val(arr && arr['date']);
|
||
}
|
||
if(field == 'driver_id'){
|
||
$("#driver_id").val(arr && arr['driver_id']);
|
||
}
|
||
var salary = arr['salary_amount'] ? parseFloat(arr['salary_amount']) : 0;
|
||
var food = arr['food_amount'] ? parseFloat(arr['food_amount']) : 0;
|
||
|
||
if (isNaN(salary)) salary = 0;
|
||
if (isNaN(food)) food = 0;
|
||
|
||
var ttl = salary + food;
|
||
$('#total_amount').val(ttl.toFixed(2));
|
||
|
||
var ttl = parseFloat(salary) + parseFloat(food) ;
|
||
$('#total_amount').val(ttl.toFixed(2));
|
||
|
||
});
|
||
$('#attendanceTitle').html("Edit Driver Trip");
|
||
}
|
||
});
|
||
$('#tempClick').click(function () {
|
||
|
||
if ($('#invoice_number').val() === '') {
|
||
alert('Please Enter the Valid Invoice Number');
|
||
return;
|
||
}
|
||
if ($('#customer').val() === '') {
|
||
alert('Please Enter the Valid Invoice Number because Customer Value Not Fetched');
|
||
return;
|
||
}
|
||
if ($('#quantity').val() === '') {
|
||
alert('Please Enter the Valid Invoice Number because Quantity Value Not Fetched');
|
||
return;
|
||
}
|
||
|
||
if ($('#load_type').val() === '') {
|
||
alert('Please Select the Load Type');
|
||
return;
|
||
}
|
||
if ($('#salary_amount').val() === '') {
|
||
alert('Please Enter Salary Amount');
|
||
return;
|
||
}
|
||
|
||
|
||
var formData = {
|
||
driver_attendance_id:$('#driver_attendance_id').val() ? $('#driver_attendance_id').val() : 0,
|
||
date: $('#date').val(),
|
||
driver_id: $('#driver_id').val(),
|
||
category_type: $('#category_type').val(),
|
||
customer: $('#customer').val(),
|
||
quantity: $('#quantity').val(),
|
||
invoice_number: $('#invoice_number').val(),
|
||
vehicle_number: $('#vehicle_number').val(),
|
||
load_type: $('#load_type').val(),
|
||
salary_amount: $('#salary_amount').val(),
|
||
food_amount: $('#food_amount').val(),
|
||
diesel_amount: "<?php echo $input_diesel_amount; ?>",
|
||
shed_amount: "<?php echo $input_shed_amount; ?>"
|
||
};
|
||
$('#loader').show();
|
||
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: "<?php echo base_url(); ?>fetchDriverAttendanceDetails",
|
||
data: formData,
|
||
dataType: 'json',
|
||
success: function (response) {
|
||
$('#loader').hide();
|
||
|
||
if (response.status) {
|
||
alert(response.message);
|
||
// $('#ddwizard').modal('hide');
|
||
location.reload();
|
||
} else {
|
||
alert(response.message);
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
$('#loader').hide();
|
||
console.error('An error occurred: ' + error);
|
||
},
|
||
complete: function () {
|
||
$('#loader').hide();
|
||
console.log("ajax call completed");
|
||
}
|
||
});
|
||
|
||
|
||
|
||
});
|
||
|
||
$.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 = $('#driver_att_listing').DataTable({
|
||
dom: 'Blfrtip',
|
||
buttons: [
|
||
'excel', 'pdf'
|
||
],
|
||
responsive: false,
|
||
order: false,
|
||
paging: false,
|
||
footerCallback: function (row, data, start, end, display) {
|
||
var api = this.api();
|
||
var isTableEmpty = api.data().length === 0;
|
||
// Hide or show the tfoot based on whether the table is empty
|
||
if (isTableEmpty) {
|
||
$(this).find('tfoot').hide(); // Hide tfoot if the table is empty
|
||
} else {
|
||
$(this).find('tfoot').show(); // Show tfoot if the table has data
|
||
}
|
||
var api = this.api();
|
||
var columnIndex = 7;
|
||
var sum = api
|
||
.column(columnIndex, { page: 'current' })
|
||
.data()
|
||
.reduce(function (a, b) {
|
||
return a + parseFloat(b.replace(/[^\d.-]/g, ''));
|
||
}, 0);
|
||
$(api.column(columnIndex).footer()).html(sum);
|
||
var api = this.api();
|
||
var columnIndex = 8;
|
||
var sum = api
|
||
.column(columnIndex, { page: 'current' })
|
||
.data()
|
||
.reduce(function (a, b) {
|
||
return a + parseFloat(b.replace(/[^\d.-]/g, ''));
|
||
}, 0);
|
||
$(api.column(columnIndex).footer()).html(sum);
|
||
var api = this.api();
|
||
var columnIndex = 9;
|
||
var sum = api
|
||
.column(columnIndex, { page: 'current' })
|
||
.data()
|
||
.reduce(function (a, b) {
|
||
return a + parseFloat(b.replace(/[^\d.-]/g, ''));
|
||
}, 0);
|
||
$(api.column(columnIndex).footer()).html(sum);
|
||
}
|
||
});
|
||
// Function to calculate the total
|
||
function calculateTotal() {
|
||
var diesel = parseFloat($('input[data-column="diesel_amount"]').val()) || 0;
|
||
var shed = parseFloat($('input[data-column="shed_amount"]').val()) || 0;
|
||
var row = parseInt($('#rowTotalAmount').text()) || 0;
|
||
console.log(row);
|
||
|
||
var total = row + diesel + shed;
|
||
$('#totalAmount').text(total); // Display the total with 2 decimal places
|
||
}
|
||
// Make the cells editable and calculate the total on input change
|
||
$(document).on('input', '.editable', function() {
|
||
calculateTotal();
|
||
});
|
||
$(document).on('blur', '.editable', function() {
|
||
var column = $(this).data('column'); // Get the column name (diesel or shed)
|
||
var value = $(this).val(); // Get the updated value
|
||
let input_driver_id = urlParams.get("drv_id");
|
||
let input_date = '';
|
||
|
||
let param_month_year = urlParams.get("month_year");
|
||
let param_date = urlParams.get("date");
|
||
|
||
if(param_date == ""){
|
||
let monthMap = {"Jan": "01", "Feb": "02", "Mar": "03", "Apr": "04","May": "05", "Jun": "06", "Jul": "07", "Aug": "08","Sep": "09", "Oct": "10", "Nov": "11", "Dec": "12"};
|
||
let [month, year] = param_month_year.split('-');
|
||
input_date = `01-${monthMap[month]}-${year}`;
|
||
|
||
}else{
|
||
input_date = param_date;
|
||
}
|
||
|
||
// Send data to the server using AJAX
|
||
$.ajax({
|
||
url: "<?php echo base_url(); ?>updateDieselAndShedValuesBasedonEmpID",
|
||
method: 'POST',
|
||
data: {
|
||
column: column,
|
||
value: value,
|
||
date: input_date,
|
||
empid:input_driver_id
|
||
},
|
||
success: function(response) {
|
||
console.log('Data saved successfully:', response);
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error('Error saving data:', error);
|
||
}
|
||
});
|
||
});
|
||
|
||
// Initial calculation of the total
|
||
calculateTotal();
|
||
|
||
});
|
||
</script>
|
||
|
||
<script>
|
||
|
||
$(window).on('load', function () {
|
||
function flashMessage() {
|
||
|
||
// Fetch the flash data from PHP and encode it for JavaScript
|
||
let message = <?= json_encode(session()->getFlashdata('success')) ?>;
|
||
if (message) {
|
||
alert(message);
|
||
}
|
||
}
|
||
|
||
flashMessage();
|
||
|
||
})
|
||
|
||
|
||
function confirmDelete(event) {
|
||
let result = confirm(` Do you Confirm to Delete the Driver Trip Detail?`);
|
||
if (result) { return result; } else { event.preventDefault(); }
|
||
}
|
||
|
||
function confirmReActivate(event) {
|
||
let result = confirm(` Do you Confirm to Re-activate the Driver Trip Detail?`);
|
||
if (result) { return result; } else { event.preventDefault(); }
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
updateSalaryBasedOnType();
|
||
fetchSalary();
|
||
});
|
||
|
||
function updateSalaryBasedOnType() {
|
||
var type = $('#load_type').val();
|
||
if (type == 'Load') {
|
||
$('#salary_amount').val(1300);
|
||
$('#food_amount').val(100);
|
||
} else if (type == 'Waste Core') {
|
||
$('#salary_amount').val(1050);
|
||
$('#food_amount').val(100);
|
||
}
|
||
fetchSalary();
|
||
}
|
||
|
||
function fetchSalary() {
|
||
var sa = parseFloat($('#salary_amount').val()) || 0;
|
||
var fa = parseFloat($('#food_amount').val()) || 0;
|
||
var ttl = sa + fa;
|
||
|
||
$('#total_amount').val(ttl.toFixed(2));
|
||
}
|
||
|
||
function customerandquantity(){
|
||
if ($('#category_type').val() === '') {
|
||
alert('Please Select the Valid Type');
|
||
return;
|
||
}
|
||
else if ($('#invoice_number').val() === '') {
|
||
alert('Please Enter the Valid Invoice Number');
|
||
return;
|
||
}else{
|
||
|
||
$.ajax({
|
||
type: 'POST',
|
||
url: "<?php echo base_url(); ?>gatheredCustAndQty",
|
||
data: {
|
||
invoiceNumber : $('#invoice_number').val(),
|
||
type : $('#category_type').val()
|
||
},
|
||
success: function (data) {
|
||
console.log('got the result: ' + data);
|
||
console.log(data);
|
||
if (data) {
|
||
if(data == ""){
|
||
alert('Please Enter the Valid Invoice Number');
|
||
$('#invoice_number').val("");
|
||
}else{
|
||
if(data['customer'] != ""){
|
||
$('#customer').val(data['customer']);
|
||
}
|
||
if(data['quantity'] != ""){
|
||
$('#quantity').val(data['quantity']);
|
||
}
|
||
}
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.log('An error occurred: ' + error);
|
||
},
|
||
complete: function () {
|
||
console.log("ajax call completed");
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function resetthefields(){
|
||
$('#invoice_number').val("");
|
||
$('#customer').val("");
|
||
$('#quantity').val("");
|
||
}
|
||
</script>
|