File: /var/www/html/taxicamera/application/views/admin/report/driver_income_report/list.php
<div class="main-content">
<div class="content-wrapper">
<div class="container-fluid">
<!-- Basic form layout section start -->
<section id="basic-form-layouts">
<!--<div class="row">
<div class="col-sm-12">
<h2 class="content-header">Driver Master</h2>
</div>
</div>-->
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<div class="page-title-wrap">
<h4 class="card-title">Driver Income Report</h4>
</div>
<!--<p class="mb-0">This is the most basic and cost estimation form is the default position.</p>-->
</div>
<div class="card-body">
<div class="px-3">
<form class="form custom_form_style">
<div class="form-body">
<div class="user_permission_top">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>Driver</label>
<select class="js-select2" name="driver_id" id="driver_id" data-show-subtext="true" data-live-search="true">
<option value="">Select Driver</option>
<?php foreach ($driver_list as $driver) { ?>
<option value="<?= $driver['user_id'] ?>"><?= $driver['first_name'] . ' - ' . $driver['dc_no'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>From Date</label>
<div class="input-group">
<input type="text" id="from_date" class="form-control pickadate" placeholder="" />
<div class="input-group-append">
<span class="input-group-text">
<span class="fa fa-calendar-o"></span>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>To Date</label>
<div class="input-group">
<input type="text" id="to_date" class="form-control pickadate" placeholder="" />
<div class="input-group-append">
<span class="input-group-text">
<span class="fa fa-calendar-o"></span>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label class="blank_lbl"> </label>
<button type="button" class="btn btn-success" onclick="populate_income_list();">
<i class="fa fa-search" aria-hidden="true"></i> Search
</button>
</div>
</div>
<div id="pdf_btn_div" class="col-md-1" style="margin-left: 20px;display:none;">
<div class="form-group">
<label class="blank_lbl"> </label>
<button id="download_pdf" type="button" class="btn btn-success">
<i class="fa fa-download" aria-hidden="true"></i>PDF
</button>
</div>
</div>
</div>
</div>
</div>
<!--<div class="form-actions">
<button type="button" class="btn btn-danger mr-1">
<i class="fa fa-times" aria-hidden="true"></i> Cancel
</button>
<button type="button" class="btn btn-success">
<i class="fa fa-floppy-o" aria-hidden="true"></i> Save
</button>
</div>-->
</form>
<div class="row ">
<div class="table-responsive custom_table_area export_table_area">
<table id="income_table" class="table table-striped table-bordered export_btn_dt c_table_style">
<thead>
<tr>
<th>SL No.</th>
<th style="min-width: 70px;">Payment date</th>
<th>Car Number</th>
<th>Shift No</th>
<th>Levy Count</th>
<th>Meter Total</th>
<th>KLMS Total</th>
<th>Owner Commission Received</th>
<th>Driver Commission</th>
<th>Discount</th>
<th>Lifting Fees </th>
</tr>
</thead>
<tbody id="tbody_income_table">
</tbody>
<tfoot id="tfoot_income_table">
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- // Basic form layout section end -->
</div>
</div>
</div>
<script>
$(document).ready(function() {
populate_datepicker();
populate_income_list();
});
function populate_datepicker() {
var from_$input = $('#from_date').pickadate({
format: 'dd/mm/yyyy',
autoclose: true
}),
from_picker = from_$input.pickadate('picker')
var to_$input = $('#to_date').pickadate({
format: 'dd/mm/yyyy',
autoclose: true
}),
to_picker = to_$input.pickadate('picker')
// Check if there’s a “from” or “to” date to start with.
if (from_picker.get('value')) {
to_picker.set('min', from_picker.get('select'))
}
if (to_picker.get('value')) {
from_picker.set('max', to_picker.get('select'))
}
// When something is selected, update the “from” and “to” limits.
from_picker.on('set', function(event) {
if (event.select) {
to_picker.set('min', from_picker.get('select'));
} else if ('clear' in event) {
to_picker.set('min', false);
}
})
to_picker.on('set', function(event) {
if (event.select) {
from_picker.set('max', to_picker.get('select'));
} else if ('clear' in event) {
from_picker.set('max', false);
}
})
}
function populate_income_list() {
var start_date = $("#from_date").val();
var end_date = $("#to_date").val();
var driver_id = $("#driver_id").val();
var resulthtml = footerhtml ='';
$.ajax({
url: "<?php echo base_url('admin/report/get_driver_income_report'); ?>",
type: "POST",
data: {
'driver_id': driver_id,
'start_date': start_date,
'end_date': end_date,
},
dataType: "json",
encode: true,
//async: false
})
.done(function(data) {
if (data.status) {
if (data.income_list) {
var i = 0;
var shift_name ;
var total_levy = total_metered_fares = total_klms = total_driver_commission_amt = total_owner_commission_amt = total_total_lifting_fees = total_discount = 0 *1;
$.each(data.income_list, function(key, value) {
i++;
var driver_commission_amt = 0;
var owner_commission_amt = 0;
if (value.driver_commission_share && value.owner_commission_share) {
driver_commission_amt = Number((value.metered_fares * value.driver_commission_share / 100));
owner_commission_amt = Number((value.metered_fares * value.owner_commission_share / 100));
} else {
driver_commission_amt = 0;
owner_commission_amt = Number(value.metered_fares);
}
resulthtml += '<tr>';
resulthtml += '<td>' + i + '</td>';
resulthtml += '<td>' + value.payin_date + '</td>';
resulthtml += '<td>' + value.registration_no + '</td>';
// if(value.shift_name == "D"){
// shift_name = "Day";
// }
// else if(value.shift_name == "H"){
// shift_name = "Hungry";
// }
// else{
// shift_name = "Night";
// }
resulthtml += '<td>' + value.shift_no + '</td>';
resulthtml += '<td>' + value.levy + '</td>';
resulthtml += '<td>' + value.metered_fares + '</td>';
resulthtml += '<td>' + (Number(value.total_km_end) - Number(value.total_km_start)) + '</td>';
resulthtml += '<td>' + parseFloat(owner_commission_amt).toFixed(2) + '</td>';
resulthtml += '<td>' + parseFloat(driver_commission_amt).toFixed(2) + '</td>';
resulthtml += '<td>' + parseFloat(value.discount).toFixed(2) + '</td>';
resulthtml += '<td>' + parseFloat(value.total_lifting_fees * 2).toFixed(2) + '</td>';
resulthtml += '</tr>';
total_levy +=Number(value.levy);
total_metered_fares +=Number(value.metered_fares);
total_klms +=(Number(value.total_km_end) - Number(value.total_km_start));
total_driver_commission_amt +=Number(driver_commission_amt);
total_owner_commission_amt +=Number(owner_commission_amt);
total_discount +=Number(value.discount);
total_total_lifting_fees +=Number(value.total_lifting_fees * 2);
})
footerhtml +='<tr style="background: #1db5bd;color: #fff;"><td colspan="4"><strong>TOTAL</strong></td>';
footerhtml +='<td><strong>'+parseFloat(total_levy).toFixed(2)+'<strong></td>';
footerhtml +='<td><strong>'+parseFloat(total_metered_fares).toFixed(2)+'</td>';
footerhtml +='<td><strong>'+parseFloat(total_klms).toFixed(2)+'</strong></td>';
footerhtml +='<td><strong>'+parseFloat(total_owner_commission_amt).toFixed(2)+'</strong></td>';
footerhtml +='<td><strong>'+parseFloat(total_driver_commission_amt).toFixed(2)+'</strong></td>';
footerhtml +='<td><strong>'+parseFloat(total_discount).toFixed(2)+'</strong></td>';
footerhtml +='<td><strong>'+parseFloat(total_total_lifting_fees).toFixed(2)+'</strong></td>';
footerhtml+='</tr>';
//console.log(resulthtml);
var now = new Date();
var date = now.getFullYear() + ":" + now.getMonth() + ":" + now.getDate();
$("#income_table").dataTable().fnDestroy();
$("#tbody_income_table").html(resulthtml);
$("#tfoot_income_table").html(footerhtml);
$('#income_table').DataTable({
pageLength: 100,
dom: 'Bfrtip',
buttons: [{
extend: 'excel',
text: 'Download Excel',
className: 'btn btn-outline-primary mr-1',
filename: 'driver_income_report' + date,
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 8, 9]
}
},
//'copy', 'csv', 'excel', 'pdf', 'print'
],
});
}
} else {
$.alert({
type: 'red',
title: 'Alert!',
content: 'Oops!Something went wrong...',
});
}
})
.fail(function(result) {
$.alert({
type: 'red',
title: 'Alert!',
content: 'Oops!Something went wrong...',
});
})
}
$(document).on('click', '#download_pdf', function() {
var start_date = $("#from_date").val();
var end_date = $("#to_date").val();
var driver_id = $("#driver_id").val();
var format_start_date = start_date.split("/").reverse().join("-");
var format_end_date = end_date.split("/").reverse().join("-");
window.location.href = "<?= base_url() ?>admin/report/download_pdf_driver_income_report?start_date="+ format_start_date + "&end_date=" + format_end_date + "&driver_id=" + driver_id;
})
$(document).on('change','#driver_id',function(){
var driver_id =$("#driver_id").val();
if(driver_id){
$("#pdf_btn_div").show();
}else{
$("#pdf_btn_div").hide();
}
})
</script>