ria/app/Views/driverAttendance.php
2025-02-05 11:59:39 +00:00

487 lines
23 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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="post">
<div class="row">
<div class="col-4">
<?php $today = date('M-Y'); ?>
<input type="text" name="monthyear" id="monthyear" value="<?php echo $datefordropdown; ?>" class="form-control" data-provide="datepicker" data-date-format="M-yyyy" data-date-min-view-mode="1">
<input type="hidden" name="driver_id" id="driver_id" value="<?php echo $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">
<button type="button" style="margin-top:0px;" class="btn btn-success" data-target="#attendanceModal" data-id="0" data-toggle="modal">
Add Trip details
</button>
</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>Driver Name</th>
<th>Date</th>
<th>Invoice Number</th>
<th>Vehicle Number</th>
<th>Salary Amount</th>
<th>Food Amount</th>
<th>Load Type</th>
<th>Customer</th>
<th>Quantity</th>
<th>Status</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($record['driver_name']) ?></td>
<td><?= esc($attdate) ?></td>
<td><?= esc($record['invoice_number']) ?></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><?= esc($record['customer']) ?></td>
<td><?= esc($record['quantity']) ?></td>
<td><?= $record['isactive'] == 1 ? 'Active' : 'InActive' ?></td>
<td><?php if ($record['isactive'] == 0) { ?>
<!-- <a onclick="confirmReActivate(event)" style="cursor:pointer;" href="<?php echo base_url() . 'reActivateDriverAttendance?driverAttendanceId=' . esc($record['driver_attendance_id']).'&driverId='.esc($record['driver_id']); ?>">
<i class="fa fa-key" style="color:#02a8b5;"></i>&nbsp;&nbsp;&nbsp;
</a> -->
<?php }else{ ?>
<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>&nbsp;&nbsp;&nbsp;
</a>
<!-- <a onclick="confirmDelete(event)" style="cursor:pointer;" href="<?php echo base_url() . 'deleteDriverAttendance?driverAttendanceId=' . esc($record['driver_attendance_id']).'&driverId='.esc($record['driver_id']); ?>">
<i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;
</a> -->
<?php } ?>
</td>
</tr>
<?php } ?>
<?php endif; ?>
</tbody>
</table>
</div>
<p>&nbsp;</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_id">Driver Name</label>
<input type="text" class="form-control" id="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="vehicle_number">Vechile Number</label>
<input type="text" class="form-control" id="vehicle_number" name="vehicle_number">
</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-6">
<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);" readonly>
</div>
<div class="col-md-6">
<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);">
</div>
</div>
<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>
</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 type="text/javascript">
$('#monthyear').attr('class', 'form-control');
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 driver_id = urlParams.get("driver_id");
if (driver_id !== null) { $("#driver_id").val(driver_id);}
else { $("#driver_id").val("<?php echo $driver_id; ?>"); }
$("#attendanceModal").on("shown.bs.modal", function (e) {
var id = $(e.relatedTarget).data('id');
let fields = ['driver_attendance_id', 'date', 'driver_id', '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");
} else {
var arr = $(e.relatedTarget).data('arr');
fields.forEach(function(field) {
$("#" + field).val(arr && arr[field] ? arr[field] : "");
});
$('#attendanceTitle').html("Edit Driver Trip");
}
});
$('#tempClick').click(function () {
if ($('#invoice_number').val() === '') {
alert('Please Enter the Valid Invoice Number');
return;
}
if ($('#food_amount').val() === '') {
alert('Please Enter the Food Amount');
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 Choosen the Load Type Properly');
return;
}
var formData = {
driver_attendance_id:$('#driver_attendance_id').val(),
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).toFixed(2);
$('#salary_amount').val(value);
}else if(type == 'Waste Core'){
var value = parseFloat(1050).toFixed(2);
$('#salary_amount').val(value);
}
}
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) {
$('#customer').val(data['customer']);
$('#quantity').val(data['quantity']);
}
},
error: function (xhr, status, error) {
console.log('An error occurred: ' + error);
},
complete: function () {
console.log("ajax call completed");
}
});
}
}
</script>