time fix
This commit is contained in:
@ -218,12 +218,12 @@ class ReportsController extends Controller
|
|||||||
", $d);
|
", $d);
|
||||||
|
|
||||||
$start = [
|
$start = [
|
||||||
'time' => date('d-m-Y H:i:s', $list[0]->crt_s),
|
'time' => $list[0]->crt_s,
|
||||||
'fulladdress' => urldecode($list[0]->fulladdress),
|
'fulladdress' => urldecode($list[0]->fulladdress),
|
||||||
'mileage' => $list[0]->vhc_milleage,
|
'mileage' => $list[0]->vhc_milleage,
|
||||||
];
|
];
|
||||||
$finish = [
|
$finish = [
|
||||||
'time' => date('d-m-Y H:i:s', $list[count($list) - 1]->crt_s),
|
'time' => $list[count($list) - 1]->crt_s,
|
||||||
'fulladdress' => urldecode($list[count($list) - 1]->fulladdress),
|
'fulladdress' => urldecode($list[count($list) - 1]->fulladdress),
|
||||||
'mileage' => $list[count($list) - 1]->vhc_milleage,
|
'mileage' => $list[count($list) - 1]->vhc_milleage,
|
||||||
];
|
];
|
||||||
@ -237,11 +237,6 @@ class ReportsController extends Controller
|
|||||||
|
|
||||||
$distance = $list[count($list) - 1]->vhc_milleage - $list[0]->vhc_milleage;
|
$distance = $list[count($list) - 1]->vhc_milleage - $list[0]->vhc_milleage;
|
||||||
|
|
||||||
$polyline = [];
|
|
||||||
foreach ($list as $item) {
|
|
||||||
$polyline[] = [$item->latitude, $item->longitude];
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'nopol1' => $nopol1,
|
'nopol1' => $nopol1,
|
||||||
'vid' => $vid,
|
'vid' => $vid,
|
||||||
@ -252,7 +247,6 @@ class ReportsController extends Controller
|
|||||||
'finish' => $finish,
|
'finish' => $finish,
|
||||||
'duration' => $duration,
|
'duration' => $duration,
|
||||||
'distance' => $distance,
|
'distance' => $distance,
|
||||||
'polyline' => json_encode($polyline),
|
|
||||||
];
|
];
|
||||||
// dd($list);
|
// dd($list);
|
||||||
return view('menu_v1.reports._trip_detail', $data);
|
return view('menu_v1.reports._trip_detail', $data);
|
||||||
|
|||||||
@ -9,6 +9,9 @@
|
|||||||
.dtl-text{
|
.dtl-text{
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
/* .leaflet-overlay-pane svg {
|
||||||
|
transform: none !important;
|
||||||
|
} */
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
@ -18,19 +21,19 @@
|
|||||||
<h5 class="modal-title" id="mdlDetailTripLabel">{{$nopol1}} Trip Detail</h5>
|
<h5 class="modal-title" id="mdlDetailTripLabel">{{$nopol1}} Trip Detail</h5>
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body row">
|
<div class="modal-body row" id="viewPdf">
|
||||||
<!-- <div class="col-2">
|
<!-- <div class="col-2">
|
||||||
<img id="infoVehicles-thumb-md" src="https://products.unitedtractors.com/wp-content/uploads/2021/03/udtruck-GWE370.png" class="img-fluid thumb-img-landscape" alt="">
|
<img id="infoVehicles-thumb-md" src="https://products.unitedtractors.com/wp-content/uploads/2021/03/udtruck-GWE370.png" class="img-fluid thumb-img-landscape" alt="">
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<p class="text-bold mb-0">Start</p>
|
<p class="text-bold mb-0">Start</p>
|
||||||
<p class="mb-0">{{$start['time']}}</p>
|
<p class="mb-0 time">{{ $start['time'] }}</p>
|
||||||
<p class="mb-0">Vehicle Mileage: {{number_format($start['mileage'], 2)}} km</p>
|
<p class="mb-0">Vehicle Mileage: {{number_format($start['mileage'], 2)}} km</p>
|
||||||
<p>{{$start['fulladdress']}}</p>
|
<p>{{$start['fulladdress']}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<p class="text-bold mb-0">Finish</p>
|
<p class="text-bold mb-0">Finish</p>
|
||||||
<p class="mb-0">{{$finish['time']}}</p>
|
<p class="mb-0 time">{{ $finish['time'] }}</p>
|
||||||
<p class="mb-0">Vehicle Mileage: {{number_format($finish['mileage'], 2)}} km</p>
|
<p class="mb-0">Vehicle Mileage: {{number_format($finish['mileage'], 2)}} km</p>
|
||||||
<p>{{$finish['fulladdress']}}</p>
|
<p>{{$finish['fulladdress']}}</p>
|
||||||
</div>
|
</div>
|
||||||
@ -63,7 +66,7 @@
|
|||||||
<li class="list-group-item p-1 px-2">
|
<li class="list-group-item p-1 px-2">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<p class="text-bold mb-0">Time: {{date('d-m-Y H:i:s', $item->crt_s)}}</p>
|
<p class="text-bold mb-0">Time: <span class="time">{{ $item->crt_s }}</span></p>
|
||||||
<p class="text-muted mb-0 dtl-text">Vehicle Mileage: {{number_format($item->vhc_milleage, 2)}} km</p>
|
<p class="text-muted mb-0 dtl-text">Vehicle Mileage: {{number_format($item->vhc_milleage, 2)}} km</p>
|
||||||
<p class="text-muted mb-0 dtl-text">Current speed: {{$item->speed}} km/h</p>
|
<p class="text-muted mb-0 dtl-text">Current speed: {{$item->speed}} km/h</p>
|
||||||
</div>
|
</div>
|
||||||
@ -100,6 +103,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
$('.time').each(function () {
|
||||||
|
const unix = $(this).text().trim();
|
||||||
|
$(this).text(moment.unix(unix).format('DD MMM YYYY HH:mm:ss'));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
map.invalidateSize(); // force Leaflet to recalc
|
map.invalidateSize(); // force Leaflet to recalc
|
||||||
map.fitBounds(polyline.getBounds());
|
map.fitBounds(polyline.getBounds());
|
||||||
@ -113,7 +122,8 @@
|
|||||||
// 2) Add tile layer
|
// 2) Add tile layer
|
||||||
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
|
||||||
maxZoom: 20,
|
maxZoom: 20,
|
||||||
}).addTo(map)
|
crossOrigin: true
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
// // // 3) Coordinates (Lat, Lng) for polyline
|
// // // 3) Coordinates (Lat, Lng) for polyline
|
||||||
const points = linesData
|
const points = linesData
|
||||||
@ -147,7 +157,50 @@
|
|||||||
// 5) Auto-fit map to polyline bounds
|
// 5) Auto-fit map to polyline bounds
|
||||||
map.fitBounds(polyline.getBounds())
|
map.fitBounds(polyline.getBounds())
|
||||||
|
|
||||||
console.log("Points:", points)
|
// download pdf
|
||||||
console.log("Bounds:", polyline.getBounds())
|
$(document).on('click', '#btnDownloadReport', function () {
|
||||||
|
const viewPdf = document.getElementById("viewPdf");
|
||||||
|
|
||||||
|
// find overlay svg (the one holding polylines)
|
||||||
|
const overlaySvg = document.querySelector('.leaflet-overlay-pane svg');
|
||||||
|
let originalTransform = '';
|
||||||
|
if (overlaySvg) {
|
||||||
|
originalTransform = overlaySvg.style.transform;
|
||||||
|
overlaySvg.style.transform = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
html2canvas(viewPdf, {
|
||||||
|
scale: 2,
|
||||||
|
useCORS: true,
|
||||||
|
logging: true
|
||||||
|
}).then(canvas => {
|
||||||
|
const imgData = canvas.toDataURL('image/png');
|
||||||
|
const { jsPDF } = window.jspdf;
|
||||||
|
|
||||||
|
const pdf = new jsPDF('p', 'mm', 'a4');
|
||||||
|
const pageWidth = pdf.internal.pageSize.getWidth();
|
||||||
|
const pageHeight = pdf.internal.pageSize.getHeight();
|
||||||
|
|
||||||
|
const imgWidth = pageWidth - 20; // margin
|
||||||
|
const imgHeight = canvas.height * imgWidth / canvas.width;
|
||||||
|
|
||||||
|
let position = 10;
|
||||||
|
|
||||||
|
// 👉 Handle multipage content
|
||||||
|
let heightLeft = imgHeight;
|
||||||
|
while (heightLeft > 0) {
|
||||||
|
pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
|
||||||
|
heightLeft -= pageHeight;
|
||||||
|
if (heightLeft > 0) {
|
||||||
|
pdf.addPage();
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pdf.save(`{{$nopol1}} Trip Report {{$start['time']}}.pdf`);
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -9,12 +9,12 @@
|
|||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('customcss')
|
@section('customcss')
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css"
|
||||||
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
|
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
|
||||||
crossorigin=""
|
crossorigin=""
|
||||||
/>
|
/>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
@ -203,6 +203,8 @@
|
|||||||
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
|
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
|
||||||
crossorigin=""
|
crossorigin=""
|
||||||
></script>
|
></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>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|||||||
Reference in New Issue
Block a user