diff --git a/app/Helpers/Lpj.php b/app/Helpers/Lpj.php index dc66a26..569f067 100644 --- a/app/Helpers/Lpj.php +++ b/app/Helpers/Lpj.php @@ -41,7 +41,7 @@ function formatRupiah($number,$decimals = 0) function formatAlamat($alamat) { - return ($alamat->address ? $alamat->address . ', ' : '') . (isset($alamat->village) ? $alamat->village->name . ', ' : '') . (isset($alamat->city) ? $alamat->city->name . ', ' : '') . (isset($alamat->province) ? $alamat->province->name . ', ' : '') . ($alamat->postal_code ?? ''); + return ($alamat->address ? $alamat->address . ', ' : '') . (isset($alamat->village) ? $alamat->village->name . ', ' : '') . (isset($alamat->city) ? $alamat->city->name . ', ' : '') . (isset($alamat->province) ? $alamat->province->name . ', ' : '') . ($alamat->village->postal_code ?? ''); } // andy add diff --git a/app/Http/Controllers/BankDataController.php b/app/Http/Controllers/BankDataController.php index f9d7fd9..4662338 100644 --- a/app/Http/Controllers/BankDataController.php +++ b/app/Http/Controllers/BankDataController.php @@ -139,15 +139,17 @@ class BankDataController extends Controller // Format the data as needed $formattedData = $data->map(function ($item) { return [ - 'id' => $item->id, - 'jenis_aset' => $item->jenis_aset, - 'tanggal' => $item->tanggal->format('d-m-Y'), - 'tahun' => $item->tahun, - 'luas_tanah' => $item->luas_tanah, + 'id' => $item->id, + 'jenis_aset' => $item->jenis_aset, + 'tanggal' => $item->tanggal->format('d-m-Y'), + 'tahun' => $item->tahun, + 'luas_tanah' => $item->luas_tanah, 'luas_bangunan' => $item->luas_bangunan, - 'harga' => $item->harga, - 'nilai_pasar' => $item->nilai_pasar, - 'location' => $item->kordinat_lat . ', ' . $item->kordinat_lng, + 'harga' => $item->harga, + 'nilai_pasar' => $item->nilai_pasar, + 'location' => $item->kordinat_lat . ', ' . $item->kordinat_lng, + 'address' => formatAlamat($item), + 'photos' => json_decode($item->foto_objek, true) ?: [$item->foto_objek], // Add more fields as needed ]; }); diff --git a/app/Models/BankData.php b/app/Models/BankData.php index 437cdd1..b7b992b 100644 --- a/app/Models/BankData.php +++ b/app/Models/BankData.php @@ -1,6 +1,10 @@ whereBetween('tanggal', [$startDate, $endDate]); } + public function village() + { + return $this->belongsTo(Village::class, 'village_code', 'code'); + } + + public function district() + { + return $this->belongsTo(District::class, 'district_code', 'code'); + } + + public function city() + { + return $this->belongsTo(City::class, 'city_code', 'code'); + } + + public function province() + { + return $this->belongsTo(Province::class, 'province_code', 'code'); + } + } diff --git a/resources/views/bank-data/index.blade.php b/resources/views/bank-data/index.blade.php index dc6b59b..547f6ac 100644 --- a/resources/views/bank-data/index.blade.php +++ b/resources/views/bank-data/index.blade.php @@ -166,6 +166,13 @@ + + @endsection @push('scripts') @@ -183,6 +190,26 @@ }); } + function openImageModal(src) { + const modal = document.getElementById('imageModal'); + const modalImage = document.getElementById('modalImage'); + modalImage.src = src; + modal.classList.remove('hidden'); + modal.classList.add('flex'); + } + + function closeImageModal() { + const modal = document.getElementById('imageModal'); + modal.classList.remove('flex'); + modal.classList.add('hidden'); + } + + function changeMainPhoto(thumbnail, index) { + const mainPhoto = thumbnail.closest('.photo-gallery').querySelector('.main-photo img'); + mainPhoto.src = thumbnail.src; + mainPhoto.alt = thumbnail.alt; + } + function updateMapMarkers(data) { // Clear existing markers markers.forEach(marker => marker.setMap(null)); @@ -218,16 +245,134 @@ // Create info window content const contentString = ` -
-

${item.jenis_aset}

-

Tanggal: ${item.tanggal}

-

Tahun: ${item.tahun}

-

Luas Tanah: ${item.luas_tanah} m²

-

Luas Bangunan: ${item.luas_bangunan} m²

-

Harga: ${window.formatRupiah(item.harga)}

-

Nilai Pasar: ${window.formatRupiah(item.nilai_pasar)}

-
- `; +
+
+

+ ${item.jenis_aset} +

+
+
+
+ + Tanggal Penilaian + +
+
+ + ${window.formatTanggalIndonesia(item.tanggal)} + +
+
+
+
+
+ + Tahun + +
+
+ + ${item.tahun} + +
+
+
+
+
+ + Luas Tanah + +
+
+ + ${item.luas_tanah} m² + +
+
+
+
+
+ + Luas Bangunan + +
+
+ + ${item.luas_bangunan} m² + +
+
+
+
+
+ + Harga + +
+
+ + ${window.formatRupiah(item.harga)} + +
+
+
+
+
+ + Nilai Pasar + +
+
+ + ${window.formatRupiah(item.nilai_pasar)} + +
+
+
+
+
+ + Location + +
+
+ + ${item.address.split(' ').reduce((acc, word, index, array) => { + if (index > 0 && index % 7 === 0) { + acc += '
'; + } + acc += word + (index < array.length - 1 ? ' ' : ''); + return acc; + }, '')} +
+
+
+ ${item.photos && item.photos.length > 0 ? ` + + ` : ''} +
+
+ +
+
+
+ `; // Create info window const infoWindow = new google.maps.InfoWindow({ @@ -259,6 +404,26 @@ } } + + function getDirections(lat, lng) { + console.log('Getting directions to:', lat, lng); + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition( + (position) => { + const origin = position.coords.latitude + ',' + position.coords.longitude; + const destination = lat + ',' + lng; + const url = `https://www.google.com/maps/dir/?api=1&origin=${origin}&destination=${destination}`; + window.open(url, '_blank'); + }, + () => { + alert('Unable to get your current location. Please enable location services.'); + } + ); + } else { + alert('Geolocation is not supported by your browser.'); + } + } + function initializeDataTable() { const element = document.querySelector('#bank-data-table'); const searchInput = document.getElementById('search'); @@ -349,6 +514,7 @@ // Reload the table to apply the new filters dataTable.reload(); }); + function initializeEverything() { initMap(); initializeDataTable();