524 lines
24 KiB
PHP
Executable File
524 lines
24 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="gobal_driver_id" id="gobal_driver_id" value="<?php echo $gobal_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(isset($driver_attendance_list) || $driver_attendance_list[0]['payroll_id'] == ''){ ?>
|
||
<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 } ?>
|
||
</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>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['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']).'&gobal_driver_id='.esc($record['driver_id']).'&month_year='.esc($datefordropdown); ?>">
|
||
|
||
<i class="fa fa-trash"></i>
|
||
</a>
|
||
<?php } ?>
|
||
</td>
|
||
</tr>
|
||
<?php } ?>
|
||
<?php endif; ?>
|
||
</tbody>
|
||
|
||
</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="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>
|
||
|
||
|
||
<!-- second row -->
|
||
<div class="row mt-2">
|
||
<div class="col-md-6">
|
||
<label class="form" for="customer">Customer</label>
|
||
<input type="text" class="form-control" id="customer" name="customer" readonly>
|
||
</div>
|
||
|
||
<div class="col-md-6">
|
||
<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="salary();">
|
||
<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="salary();">
|
||
</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="salary();">
|
||
</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 gobal_driver_id = urlParams.get("gobal_driver_id");
|
||
if (gobal_driver_id !== null) {
|
||
$("#gobal_driver_id").val(gobal_driver_id);
|
||
$("#driver_id").val(gobal_driver_id);
|
||
}
|
||
else {
|
||
$("#gobal_driver_id").val("<?php echo $gobal_driver_id; ?>");
|
||
$("#driver_id").val("<?php echo $gobal_driver_id; ?>");
|
||
}
|
||
|
||
|
||
|
||
$("#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'];
|
||
|
||
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']);
|
||
}
|
||
if(field == 'salary_amount' || field == 'food_amount') {
|
||
var ttl = parseFloat(arr['salary_amount']) + (parseFloat(arr['food_amount'] || 0));
|
||
$('#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(),
|
||
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(),
|
||
};
|
||
|
||
console.log(formData);
|
||
$('#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'
|
||
],
|
||
pageLength: 10,
|
||
lengthMenu: [
|
||
[10, 20, 30, 50, -1],
|
||
[10, 20, 30, 50, "All"]
|
||
],
|
||
responsive: false,
|
||
order: false,
|
||
language: {
|
||
paginate: {
|
||
next: '<i class="fas fa-angle-right"></i>', // Next button icon
|
||
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
|
||
}
|
||
}
|
||
});
|
||
|
||
});
|
||
</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(); }
|
||
}
|
||
|
||
function salary() {
|
||
|
||
var type = $('#load_type').val();
|
||
|
||
if(type == 'Load'){
|
||
var value = parseFloat(1300);
|
||
$('#salary_amount').val(value);
|
||
}else if(type == 'Waste Core'){
|
||
var value = parseFloat(1050);
|
||
$('#salary_amount').val(value);
|
||
}
|
||
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 ($('#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()
|
||
},
|
||
success: function (data) {
|
||
console.log('got the result: ' + 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");
|
||
}
|
||
});
|
||
}
|
||
}
|
||
</script>
|