update add vehicle type filter at report
This commit is contained in:
@ -16,16 +16,19 @@ use App\Models\UserLogs;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Models\ConfTruckTypes;
|
||||
|
||||
class ReportsController extends Controller
|
||||
{
|
||||
public function view_report_vehicle_trips(Request $req)
|
||||
{
|
||||
$q = "SELECT id, nopol1 from t_vehicles WHERE dlt is null order by nopol1";
|
||||
$vehicletype = DB::table('t_vehicles_types')->where('is_active', 1)->get();
|
||||
$listNopol = DB::select($q);
|
||||
|
||||
$data = [
|
||||
'listNopol' => $listNopol,
|
||||
'vehicletype' => $vehicletype
|
||||
];
|
||||
|
||||
$log = [
|
||||
@ -59,6 +62,7 @@ class ReportsController extends Controller
|
||||
$from_date = $req->input('from_date') - Helper::TIMEFIX;
|
||||
$to_date = $req->input('to_date') - Helper::TIMEFIX;
|
||||
$vid = $req->input('vid');
|
||||
$vt = $req->input('vt');
|
||||
// $from_date = 1756054800;
|
||||
// $to_date = 1756745940;
|
||||
|
||||
@ -147,13 +151,17 @@ class ReportsController extends Controller
|
||||
SELECT
|
||||
t.*,
|
||||
tm.total_mileage, total_trip,
|
||||
vt.name as type_name,
|
||||
ROW_NUMBER() OVER (PARTITION BY t.id ORDER BY t.start) AS trip_id
|
||||
FROM trips t
|
||||
JOIN TotalMileage tm ON t.id = tm.id
|
||||
LEFT JOIN t_vehicles tvt ON tvt.id = t.vhc_id
|
||||
LEFT JOIN t_vehicles_types vt ON vt.id = tvt.type_id
|
||||
WHERE
|
||||
t.start BETWEEN ? AND ?
|
||||
and if(? , t.id = ? , 1=1)
|
||||
", [$from_date, $to_date, $from_date, $to_date, $vid, $vid]);
|
||||
and if(? , vt.id = ? , 1=1)
|
||||
", [$from_date, $to_date, $from_date, $to_date, $vid, $vid, $vt, $vt]);
|
||||
|
||||
// // RETURN 1 - LIST
|
||||
// if($req->type != 'report'){
|
||||
|
||||
@ -9,12 +9,8 @@
|
||||
@endsection
|
||||
|
||||
@section('customcss')
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
||||
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
|
||||
crossorigin=""
|
||||
/>
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
||||
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" />
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
@ -44,25 +40,24 @@
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<!-- filter -->
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
<div class="row g-3 align-items-end">
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label class="text-muted">From</label>
|
||||
<!-- default today -->
|
||||
<!-- <input class="form-control" id="tgl0" value="02-09-2025 00:00"> -->
|
||||
<input class="form-control" id="tgl0" value="{{ date('d-m-Y 00:00') }}">
|
||||
<label class="form-label text-muted mb-1">From</label>
|
||||
<input type="text" class="form-control" id="tgl0" value="{{ date('d-m-Y 00:00') }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label class="text-muted">To</label>
|
||||
<!-- <input class="form-control" id="tgl1" value="02-09-2025 23:00"> -->
|
||||
<input class="form-control" id="tgl1" value="{{ date('d-m-Y 23:59') }}">
|
||||
<label class="form-label text-muted mb-1">To</label>
|
||||
<input type="text" class="form-control" id="tgl1" value="{{ date('d-m-Y 23:59') }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label class="text-muted">License Plate</label>
|
||||
<label class="form-label text-muted mb-1">License Plate</label>
|
||||
<select name="license_plate" class="form-control" id="filterNopol">
|
||||
<option value="">-- All --</option>
|
||||
@foreach ($listNopol as $nopol)
|
||||
@ -71,11 +66,26 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-1 d-flex align-items-end">
|
||||
<button class="btn btn-primary" id="submitFilter">Submit</button>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div class="form-group">
|
||||
<label class="form-label text-muted mb-1">Vehicle Type</label>
|
||||
<select name="vehicle_type" class="form-control" id="vehicleType">
|
||||
<option value="">-- All --</option>
|
||||
@foreach ($vehicletype as $vehicletypes)
|
||||
<option value="{{ $vehicletypes->id }}">{{ $vehicletypes->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-5 d-flex align-items-end">
|
||||
<button class="btn btn-sm btn-danger ms-auto" id="btnDownloadReport">Download Report</button>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 d-flex justify-content-end gap-2">
|
||||
<button class="btn btn-primary" id="submitFilter">
|
||||
<i class="fa fa-search me-1"></i> Submit
|
||||
</button>
|
||||
<button class="btn btn-danger" id="btnDownloadReport">
|
||||
<i class="fa fa-download me-1"></i> Download Report
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -97,6 +107,7 @@
|
||||
<th class="">Finish (km)</th>
|
||||
<th class="">Distance (km)</th>
|
||||
<th class="">Fuel (L)</th>
|
||||
<th class="">Vehicle Type</th>
|
||||
<th class="">Detail</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -176,7 +187,8 @@
|
||||
</div>
|
||||
|
||||
<!-- modal -->
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlDetailTrip" aria-labelledby="mdlDetailTripLabel" aria-hidden="true">
|
||||
<div class="modal fade" data-bs-backdrop="static" data-bs-keyboard="false" id="mdlDetailTrip"
|
||||
aria-labelledby="mdlDetailTripLabel" aria-hidden="true">
|
||||
<!-- <div class="modal-dialog modal-dialog modal-dialog-centered modal-dialog-scrollable modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -198,8 +210,11 @@
|
||||
<script src="https://cdn.datatables.net/buttons/2.4.2/js/dataTables.buttons.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/buttons/2.4.2/js/buttons.html5.min.js"></script>
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js" integrity="sha512-ozq8xQKq6urvuU6jNgkfqAmT7jKN2XumbrX1JiB3TnF7tI48DPI4Gy1GXKD/V3EExgAs1V+pRO7vwtS1LHg0Gw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> -->
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.4/leaflet.draw.js"
|
||||
integrity="sha512-ozq8xQKq6urvuU6jNgkfqAmT7jKN2XumbrX1JiB3TnF7tI48DPI4Gy1GXKD/V3EExgAs1V+pRO7vwtS1LHg0Gw=="
|
||||
crossorigin="anonymous" referrerpolicy="no-referrer"></script> -->
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"
|
||||
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
|
||||
<script src="https://unpkg.com/leaflet-routing-machine@3.2.12/dist/leaflet-routing-machine.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
|
||||
@ -251,7 +266,8 @@
|
||||
const nopol1 = $(this).data('nopol1');
|
||||
|
||||
// $("#mdlDetailTrip").load("{{ route('view_report_trip_detail') }}");
|
||||
$('#mdlDetailTrip').empty().load("{{ route('view_report_trip_detail') }}", `vid=${vid}&tgl0=${tgl0}&tgl1=${tgl1}&nopol1=${nopol1}`, () => {
|
||||
$('#mdlDetailTrip').empty().load("{{ route('view_report_trip_detail') }}",
|
||||
`vid=${vid}&tgl0=${tgl0}&tgl1=${tgl1}&nopol1=${nopol1}`, () => {
|
||||
$('#mdlDetailTrip').modal('show')
|
||||
})
|
||||
|
||||
@ -297,6 +313,7 @@
|
||||
&from_date=${moment($('#tgl0').val(), "DD-MM-YYYY HH:mm").unix()}
|
||||
&to_date=${moment($('#tgl1').val(), "DD-MM-YYYY HH:mm").unix()}
|
||||
&vid=${$('#filterNopol').val() || ''}
|
||||
&vt=${$('#vehicleType').val() || ''}
|
||||
`,
|
||||
type: 'GET',
|
||||
success: function(json) {
|
||||
@ -313,8 +330,10 @@
|
||||
});
|
||||
},
|
||||
deferRender: true,
|
||||
columns: [
|
||||
{ data: 'id', visible: false }, // vhc_id
|
||||
columns: [{
|
||||
data: 'id',
|
||||
visible: false
|
||||
}, // vhc_id
|
||||
{
|
||||
data: 'nopol1',
|
||||
className: 'text-start',
|
||||
@ -322,11 +341,27 @@
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{ data: "dc_code", className: 'text-start'},
|
||||
{ data: "pool_code", className: 'text-start'},
|
||||
{ data: "total_trip", className: 'text-end'},
|
||||
{ data: "total_mileage", className: 'text-end', render: (data, type, row, meta) => parseFloat(data).toFixed(2)},
|
||||
{ data: "trip_id", className: 'text-end'},
|
||||
{
|
||||
data: "dc_code",
|
||||
className: 'text-start'
|
||||
},
|
||||
{
|
||||
data: "pool_code",
|
||||
className: 'text-start'
|
||||
},
|
||||
{
|
||||
data: "total_trip",
|
||||
className: 'text-end'
|
||||
},
|
||||
{
|
||||
data: "total_mileage",
|
||||
className: 'text-end',
|
||||
render: (data, type, row, meta) => parseFloat(data).toFixed(2)
|
||||
},
|
||||
{
|
||||
data: "trip_id",
|
||||
className: 'text-end'
|
||||
},
|
||||
{
|
||||
data: 'start',
|
||||
render: (data, type, row, meta) => {
|
||||
@ -348,7 +383,8 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
className: 'text-start', render: function(data, type, row, meta) {
|
||||
className: 'text-start',
|
||||
render: function(data, type, row, meta) {
|
||||
const start = moment.unix(row.start);
|
||||
const finish = moment.unix(row.finish);
|
||||
|
||||
@ -362,30 +398,38 @@
|
||||
},
|
||||
{
|
||||
data: 'startMileage',
|
||||
className: 'text-end', render: function(data, type, row, meta) {
|
||||
className: 'text-end',
|
||||
render: function(data, type, row, meta) {
|
||||
return (data === null) ? '0' : parseFloat(data).toFixed(0);
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'finishMileage',
|
||||
className: 'text-end', render: function(data, type, row, meta) {
|
||||
className: 'text-end',
|
||||
render: function(data, type, row, meta) {
|
||||
return (data === null) ? '0' : parseFloat(data).toFixed(0);
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'mileage',
|
||||
className: 'text-end', render: function(data, type, row, meta) {
|
||||
className: 'text-end',
|
||||
render: function(data, type, row, meta) {
|
||||
// const mileage = (row.finishMileage !== null && row.startMileage !== null) ? (row.finishMileage - row.startMileage) : row.mileage;
|
||||
return (parseFloat(data).toFixed(2));
|
||||
}
|
||||
},
|
||||
{
|
||||
data: 'fuel_consume',
|
||||
className: 'text-end', render: function(data, type, row, meta) {
|
||||
className: 'text-end',
|
||||
render: function(data, type, row, meta) {
|
||||
// const mileage = (row.finishMileage !== null && row.startMileage !== null) ? (row.finishMileage - row.startMileage) : row.mileage;
|
||||
return (parseFloat(data / 10).toFixed(1));
|
||||
}
|
||||
},
|
||||
{
|
||||
data: "type_name",
|
||||
className: 'text-start'
|
||||
},
|
||||
{
|
||||
// visible: false,
|
||||
data: 'vhc_id',
|
||||
@ -404,16 +448,22 @@
|
||||
paging: false,
|
||||
drawCallback: function(settings) {
|
||||
const api = this.api();
|
||||
const rows = api.rows({ page: 'current' }).nodes();
|
||||
const rows = api.rows({
|
||||
page: 'current'
|
||||
}).nodes();
|
||||
let last = null;
|
||||
|
||||
api.column(0, { page: 'current' }) // vhc_id col
|
||||
api.column(0, {
|
||||
page: 'current'
|
||||
}) // vhc_id col
|
||||
.data()
|
||||
.each(function(group, i) {
|
||||
if (last !== group) {
|
||||
// count how many rows this vhc_id spans
|
||||
const rowspanCount = api
|
||||
.column(0, { page: 'current' })
|
||||
.column(0, {
|
||||
page: 'current'
|
||||
})
|
||||
.data()
|
||||
.filter(function(d) {
|
||||
return d === group;
|
||||
@ -440,8 +490,7 @@
|
||||
}
|
||||
});
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
buttons: [{
|
||||
extend: 'excelHtml5',
|
||||
title: () => {
|
||||
return `
|
||||
@ -454,8 +503,7 @@
|
||||
exportOptions: {
|
||||
columns: ':visible:not(:last-child)' //
|
||||
}
|
||||
}
|
||||
]
|
||||
}]
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@ -183,7 +183,6 @@ Route::middleware(["auth", "auth.user"])->group(function () {
|
||||
Route::get("/reports/vehicle-trip-detail", "ReportsController@view_report_trip_detail")->name("view_report_trip_detail");
|
||||
Route::get("/reports/abnormalities", "ReportsController@view_report_abnormalities")->name("view_report_abnormalities");
|
||||
Route::get("/reports/abnormalities-list", "ReportsController@api_report_abnormalities_list")->name("api_report_abnormalities_list");
|
||||
|
||||
// media
|
||||
Route::get("/media", "MediaController@view_media")
|
||||
->name("view_media")
|
||||
|
||||
Reference in New Issue
Block a user