ria/app/Views/driverListing.php

300 lines
12 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.

<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-12">
<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);">HR</a></li>
<li class="breadcrumb-item active">
<h4 class="page-title">Driver Load Details</h4>
</li>
</ol>
</div>
<!-- <a data-toggle="modal" href="#ddwizard" data-id="0" data-name="" class="btn btn-success">Add Driver Details </a> -->
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<?php //dd($driver_list); ?>
<div class="card-body" style="overflow-x:scroll;">
<table id="driver_listing" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th>Create Date</th>
<th>Driver Name</th>
<th>Driver Mobile </th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($driver_list)) :
foreach ($driver_list as $record) {
if (date('d-m-Y', strtotime($record->Created_date)) == "30-11--0001") {
$cdate = '00-00-0000';
} else {
$cdate = date('d-m-Y', strtotime($record->Created_date));
}
?>
<tr>
<td><?= esc($cdate) ?></td>
<td><?php echo $record->FirstName; ?></td>
<td><?php echo $record->ContactNumber ?></td>
<td><?php echo $record->IsActive == 1 ? 'Active' : 'InActive' ?></td>
<td>
<?php if($record->is_driver){ ?>
&nbsp;&nbsp;&nbsp;
<a title="Trip Details" style="cursor:pointer;" href="<?= base_url() . 'loadDriverAttendance?drv_id=' . $record->EmpID; ?>">
<i class="fa fa-truck"></i>&nbsp;&nbsp;&nbsp;
</a>
<?php } ?>
</td>
</tr>
<?php } ?>
<?php endif; ?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div> <!-- container -->
</div> <!-- content -->
</div>
<!-- for Add and edit Modal -->
<div id="ddwizard" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<form id="transporterForm" class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<div class="col-md-4 col-md-offset-2">
<label class="col-form-label">Drive Name: </label>
</div>
<div class="col-md-6">
<input type="text" name="driver_name" id="driver_name" class="form-control">
<input type="hidden" name="driver_id" id="driver_id" class="form-control">
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-4 col-md-offset-2">
<label class="col-form-label">Drive Mobile: </label>
</div>
<div class="col-md-6">
<input type="text" name="driver_mobile" id="driver_mobile" class="form-control" onkeypress="return isNumber(event);" maxlength="10">
</div>
</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>
</div>
</div><!-- /.modal -->
<script>
$(document).ready(function () {
$("#ddwizard").on("shown.bs.modal", function (e) {
var id = $(e.relatedTarget).data('id');
var name = $(e.relatedTarget).data('name');
var mobile = $(e.relatedTarget).data('mobile');
$('#driver_name').val('');
$('#driver_mobile').val('');
$('#driver_id').val(id);
if (id == 0) {
$('.modal-title').html("Add Driver");
} else {
$('.modal-title').html("Edit Driver");
$('#driver_name').val(name);
$('#driver_mobile').val(mobile);
}
});
$('#tempClick').click(function () {
if ($('#driver_name').val() === '') {
alert('Please Enter the Driver Name');
return;
}
if ($('#driver_mobile').val() === '') {
alert('Please Enter the Driver Mobile');
return;
}
var formData = {
driver_id: $('#driver_id').val(),
driver_name: $('#driver_name').val(),
driver_mobile: $('#driver_mobile').val(),
};
console.log(formData);
$('#loader').show();
$.ajax({
type: 'POST',
url: "<?php echo base_url(); ?>checkDriver",
data: {
DriverId : $('#driver_id').val(),
DriverMobile: $('#driver_mobile').val().trim()
},
success: function (data) {
$('#loader').hide();
let isactive =data[0]?.isactive;
if (data && data.length > 0) {
if(isactive == 1){
alert("Mobile Number Exists..!!");
}else{
alert("Mobile NUmber Existing in the deleted section ..!!");
}
$('#ddwizard').modal('hide');
} else {
$.ajax({
type: 'POST',
url: "<?php echo base_url(); ?>fetchDriverDetails",
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");
}
});
}
},
error: function (xhr, status, error) {
$('#loader').hide();
console.error('An error occurred: ' + error);
},
complete: function () {
$('#loader').hide();
console.log("ajax call completed");
}
});
});
});
</script>
<script>
$(document).ready(function () {
$.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_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 Detail?`);
if (result) { return result; } else { event.preventDefault(); }
}
function confirmReActivate(event) {
let result = confirm(` Do you Confirm to Re-activate the Driver Detail?`);
if (result) { return result; } else { event.preventDefault(); }
}
function isNumber(evt) {
var iKeyCode = (evt.which) ? evt.which : evt.keyCode
if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57)) {
return false;
}
return true;
}
</script>
<script>
$(document).on('keydown', function(event) {
if (event.key === 'Enter') {
event.preventDefault(); // Prevent default Enter key behavior
}
});
</script>