update trips label done
This commit is contained in:
@ -129,74 +129,6 @@
|
||||
<th class="">Detail</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- <tbody>
|
||||
<tr>
|
||||
<td>24-679</td>
|
||||
<td>24-679</td>
|
||||
<td>26</td>
|
||||
<td>442.3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24-682</td>
|
||||
<td>24-682</td>
|
||||
<td>28</td>
|
||||
<td>312.7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>24-877</td>
|
||||
<td>24-877</td>
|
||||
<td>15</td>
|
||||
<td>276.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>A.16-347</td>
|
||||
<td>A.16-347</td>
|
||||
<td>37</td>
|
||||
<td>543.2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>AL2025-B21</td>
|
||||
<td>AL2025-B21</td>
|
||||
<td>18</td>
|
||||
<td>295.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>B.16-542</td>
|
||||
<td>B.16-542</td>
|
||||
<td>32</td>
|
||||
<td>478.2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>B.24-264</td>
|
||||
<td>B.24-264</td>
|
||||
<td>24</td>
|
||||
<td>188.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>B.24-274</td>
|
||||
<td>B.24-274</td>
|
||||
<td>33</td>
|
||||
<td>440.1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Ford Ranger</td>
|
||||
<td>26-199</td>
|
||||
<td>30</td>
|
||||
<td>631.4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nissan AD</td>
|
||||
<td>B.10-517</td>
|
||||
<td>27</td>
|
||||
<td>375.9</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Triton</td>
|
||||
<td>A.29-127</td>
|
||||
<td>26</td>
|
||||
<td>508.2</td>
|
||||
</tr>
|
||||
</tbody> -->
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@ -207,18 +139,6 @@
|
||||
<!-- modal -->
|
||||
<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">
|
||||
<h5 class="modal-title" id="mdlDetailTripLabel">-----</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@ -228,9 +148,6 @@
|
||||
<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://unpkg.com/leaflet-routing-machine@3.2.12/dist/leaflet-routing-machine.js"></script>
|
||||
@ -254,15 +171,12 @@
|
||||
activate: function() {
|
||||
Wrapper.init();
|
||||
Wrapper.event();
|
||||
// DTable.table = $('#tVehicleTrips').DataTable()
|
||||
// DTable.activate();
|
||||
},
|
||||
init: () => {
|
||||
$('#tgl0, #tgl1').datetimepicker({
|
||||
format: 'd-m-Y H:i',
|
||||
defaultTime: '00:00',
|
||||
closeOnDateSelect: true,
|
||||
// mask:true
|
||||
});
|
||||
|
||||
},
|
||||
@ -283,7 +197,6 @@
|
||||
const tgl1 = $(this).data('tgl1');
|
||||
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').modal('show')
|
||||
@ -293,35 +206,38 @@
|
||||
$('#filterNopol').select2({});
|
||||
},
|
||||
};
|
||||
// Data referensi site (lat/lng dalam desimal, bukan koma)
|
||||
const SITE_LOCATIONS = [{
|
||||
name: 'Bitterlaun',
|
||||
district: 'Dili',
|
||||
subdistrict: 'Cristo Rei',
|
||||
village: 'Hera',
|
||||
lat: -8.548328,
|
||||
lng: 125.623808
|
||||
},
|
||||
{
|
||||
name: 'Bebonuk',
|
||||
district: 'Dili',
|
||||
subdistrict: 'Dom Aleixo',
|
||||
village: 'Comoro',
|
||||
lat: -8.547527,
|
||||
lng: 125.548280
|
||||
},
|
||||
{
|
||||
name: 'Balide',
|
||||
district: 'Dili',
|
||||
subdistrict: 'Nain Feto',
|
||||
village: 'Santa Cruz',
|
||||
lat: -8.564396,
|
||||
lng: 125.582151
|
||||
},
|
||||
];
|
||||
|
||||
// Radius toleransi "berdekatan" dalam meter — sesuaikan sesuai kebutuhan
|
||||
const SITE_PROXIMITY_RADIUS_METERS = 500;
|
||||
// ================================
|
||||
// SITE LABELING (dari API, bukan hardcode)
|
||||
// ================================
|
||||
|
||||
// Data referensi site (lat/lng dalam desimal) — diisi via loadSiteLocations()
|
||||
let SITE_LOCATIONS = [];
|
||||
|
||||
// Ambil data site labeling dari API
|
||||
function loadSiteLocations() {
|
||||
return $.ajax({
|
||||
url: "{{ route('api_list_trips_label') }}",
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
}).then(function(json) {
|
||||
const list = (json && json.data) ? json.data : [];
|
||||
// hanya ambil yang belum dihapus (isdeleted = 0), lalu normalisasi field yang dipakai
|
||||
SITE_LOCATIONS = list
|
||||
.filter(site => Number(site.isdeleted) === 0)
|
||||
.map(site => ({
|
||||
id: site.id,
|
||||
address: site.address,
|
||||
lat: parseFloat(site.lat),
|
||||
lng: parseFloat(site.lng),
|
||||
// radius dari API sudah dalam meter
|
||||
radius: parseFloat(site.radius),
|
||||
}));
|
||||
}).catch(function(err) {
|
||||
console.error('Failed to load site locations:', err);
|
||||
SITE_LOCATIONS = [];
|
||||
});
|
||||
}
|
||||
|
||||
// Helper untuk parse string "lat, long" menjadi { lat, lng }
|
||||
function parseLatLong(latLongStr) {
|
||||
@ -361,6 +277,7 @@
|
||||
}
|
||||
|
||||
// Cari site terdekat dari koordinat yang diberikan; null jika tidak ada yang cukup dekat
|
||||
// menggunakan radius masing-masing site (bukan radius global)
|
||||
function findNearestSite(lat, lng) {
|
||||
if (lat === undefined || lng === undefined || lat === null || lng === null || lat === '' || lng === '') {
|
||||
return null;
|
||||
@ -369,7 +286,7 @@
|
||||
let minDist = Infinity;
|
||||
SITE_LOCATIONS.forEach(site => {
|
||||
const dist = getDistanceMeters(parseFloat(lat), parseFloat(lng), site.lat, site.lng);
|
||||
if (dist <= SITE_PROXIMITY_RADIUS_METERS && dist < minDist) {
|
||||
if (dist <= site.radius && dist < minDist) {
|
||||
minDist = dist;
|
||||
nearest = site;
|
||||
}
|
||||
@ -378,10 +295,15 @@
|
||||
}
|
||||
|
||||
// Format label sesuai output yang diinginkan
|
||||
// address dari API sudah lengkap (mis. "Bitterlaun, Hera, Cristo Rei, Dili")
|
||||
function formatSiteLabel(site) {
|
||||
return `Site ${site.name}, ${site.village}, ${site.subdistrict}, ${site.district}, Timor-Leste`;
|
||||
return `Site ${site.address}, Timor-Leste`;
|
||||
}
|
||||
|
||||
// ================================
|
||||
// END SITE LABELING
|
||||
// ================================
|
||||
|
||||
const DTable = {
|
||||
table: null,
|
||||
lastAjax: null, // keep track of the last ajax request
|
||||
@ -704,7 +626,6 @@
|
||||
|
||||
// Convert canvas to ImageState.
|
||||
let imageData = ctx.getImageData(0, 0, imgWidth, imgHeight)
|
||||
// console.log(imageState.data.byteLength + ' bytes.')
|
||||
|
||||
// Convert canvas to Blob
|
||||
canvas.toBlob((blob) => {
|
||||
@ -712,13 +633,6 @@
|
||||
newReader.addEventListener('loadend', () => {
|
||||
// Convert canvas to ArrayBuffer
|
||||
let arrayBuffer = newReader.result
|
||||
// console.log(arrayBuffer.byteLength + ' bytes.')
|
||||
|
||||
// Convert ArrayBuffer to Blob
|
||||
// let blob = new Blob([arrayBuffer], {type: mimeType})
|
||||
|
||||
// Dispay Blob content in an Image.
|
||||
// console.log(URL.createObjectURL(blob))
|
||||
|
||||
// Generate as file
|
||||
let newFile = new File([arrayBuffer], fileName, {
|
||||
@ -736,6 +650,10 @@
|
||||
});
|
||||
}
|
||||
|
||||
Wrapper.activate();
|
||||
// Pastikan data site sudah ter-load SEBELUM tabel trip dirender,
|
||||
// supaya findNearestSite() punya data yang benar saat kolom start/finish di-render.
|
||||
loadSiteLocations().always(function() {
|
||||
Wrapper.activate();
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user