From 2e07d526a8f0dbaa604c3d034f58bb916b4975a0 Mon Sep 17 00:00:00 2001 From: majid Date: Wed, 16 Apr 2025 21:34:24 +0700 Subject: [PATCH 1/3] fix(surveyor/penilai):perbaikkan pengambilan key luas unit dan handle foto di informasi --- .../components/apartemen-kantor.blade.php | 2 +- .../surveyor/components/informasi.blade.php | 46 +++++++++++-------- .../components/print-out/informasi.blade.php | 6 ++- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/resources/views/surveyor/components/apartemen-kantor.blade.php b/resources/views/surveyor/components/apartemen-kantor.blade.php index 1034935..da7e5fe 100644 --- a/resources/views/surveyor/components/apartemen-kantor.blade.php +++ b/resources/views/surveyor/components/apartemen-kantor.blade.php @@ -16,7 +16,7 @@ $total_luas_unit = 0; $jenis_legalitas_jaminan_id = 0; if (isset($item->detail)) { - $total_luas_unit = calculateTotalLuas($item->detail, 'luas_tanah', 1, 27, 3); + $total_luas_unit = calculateTotalLuas($item->detail, 'luas_bangunan', 1, 27, 3); } @endphp Foto Gs + style="{{ isset($forminspeksi['upload_gs']) && is_string($forminspeksi['upload_gs']) && !empty($forminspeksi['upload_gs']) ? '' : 'display: none;' }} max-width: 30rem;" /> @@ -150,9 +150,9 @@ > Foto Bhumi + style="{{ isset($forminspeksi['foto_sentuh_tanahku']) && is_string($forminspeksi['foto_sentuh_tanahku']) && !empty($forminspeksi['foto_sentuh_tanahku']) ? '' : 'display: none;' }} max-width: 30rem;"/> @@ -173,9 +173,9 @@ onchange="uploadFile(this, 'gistaru-preview', 'foto_gistaru')"> Foto Bhumi + style="{{ isset($forminspeksi['foto_gistaru']) && is_string($forminspeksi['foto_gistaru']) && !empty($forminspeksi['foto_gistaru']) ? '' : 'display: none;' }} max-width: 30rem;" /> @@ -199,10 +199,15 @@ class="file-input file-input-bordered w-full " accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg" onchange="uploadFile(this, 'bhumi-preview', 'foto_bhumi')"> + @php + $bhumiPath = isset($forminspeksi['foto_bhumi']) && is_string($forminspeksi['foto_bhumi']) && !empty($forminspeksi['foto_bhumi']) + ? asset('storage/' . $forminspeksi['foto_bhumi']) + : ''; + @endphp Foto Bhumi + style="{{ $bhumiPath ? '' : 'display: none;' }} max-width: 30rem;" /> Bhumi @@ -222,10 +227,16 @@ class="file-input file-input-bordered w-full" accept=".jpg,.jpeg,.png,.gif,.bmp,.tiff,.tif,.webp,.svg" onchange="uploadFile(this, 'argis-region-preview', 'foto_argis_region')"> + @php + $argisRegionPath = isset($forminspeksi['foto_argis_region']) && is_string($forminspeksi['foto_argis_region']) && !empty($forminspeksi['foto_argis_region']) + ? asset('storage/' . $forminspeksi['foto_argis_region']) + : ''; + @endphp + Foto Argis Region + style="{{ $argisRegionPath ? '' : 'display: none;' }} max-width: 30rem;"> < @@ -247,19 +258,14 @@ @php - $fotoTempat = $forminspeksi['foto_tempat'] ?? null; - $fotoSrc = ''; - - if (is_array($fotoTempat)) { - $fotoSrc = asset('storage/' . $fotoTempat[0]); - } elseif (!empty($fotoTempat)) { - $fotoSrc = asset('storage/' . $fotoTempat); - } + $fotoTempat = isset($forminspeksi['foto_tempat']) && is_string($forminspeksi['foto_tempat']) && !empty($forminspeksi['foto_tempat']) + ? asset('storage/' . $forminspeksi['foto_tempat']) + : ''; @endphp - Foto Tempat + style="max-width: 30rem; {{ $fotoTempat ? '' : 'display: none;' }}"> diff --git a/resources/views/surveyor/components/print-out/informasi.blade.php b/resources/views/surveyor/components/print-out/informasi.blade.php index f1b2a27..7e529ba 100644 --- a/resources/views/surveyor/components/print-out/informasi.blade.php +++ b/resources/views/surveyor/components/print-out/informasi.blade.php @@ -67,19 +67,21 @@ } // Filter fotoTypes untuk memastikan hanya yang memiliki imagePath valid $validPhotoTypes = array_filter($fotoTypes, function ($type) use ($forminspeksi) { - return isset($forminspeksi[$type]) && file_exists(storage_path('app/public/' . $forminspeksi[$type])); + return isset($forminspeksi[$type]) && !empty($forminspeksi[$type]) && is_string($forminspeksi[$type]); }); @endphp @foreach ($validPhotoTypes as $type) @php $imagePath = $forminspeksi[$type] ?? null; + $imageUrl = is_string($imagePath) ? asset('storage/' . $imagePath) : null; + @endphp @if ($imagePath && file_exists(storage_path('app/public/' . $imagePath))) {{ $customLabels[$type] ?? '' }} - {{ $imagePath }} From 4647e75733b25dc327bc6f5c2c693a0d72b1fc68 Mon Sep 17 00:00:00 2001 From: majid Date: Wed, 16 Apr 2025 22:53:48 +0700 Subject: [PATCH 2/3] fix(penilai): rename nama file apartement-kantor ke apartemen-kantor --- .../{apartement-kantor.blade.php => apartemen-kantor.blade.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename resources/views/penilai/components/analisa/{apartement-kantor.blade.php => apartemen-kantor.blade.php} (100%) diff --git a/resources/views/penilai/components/analisa/apartement-kantor.blade.php b/resources/views/penilai/components/analisa/apartemen-kantor.blade.php similarity index 100% rename from resources/views/penilai/components/analisa/apartement-kantor.blade.php rename to resources/views/penilai/components/analisa/apartemen-kantor.blade.php From a5902305d02dd1a73b2137df80a728187d219964 Mon Sep 17 00:00:00 2001 From: majid Date: Thu, 17 Apr 2025 10:04:34 +0700 Subject: [PATCH 3/3] fix(surveyor): perbaikkan upload foto mengunakan kamera dan upload file foto --- .../views/surveyor/components/foto.blade.php | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/resources/views/surveyor/components/foto.blade.php b/resources/views/surveyor/components/foto.blade.php index c235149..a872162 100644 --- a/resources/views/surveyor/components/foto.blade.php +++ b/resources/views/surveyor/components/foto.blade.php @@ -286,6 +286,8 @@ // Track files that are already on the server const existingFiles = new Set(); + addCameraOption(dropzoneElement, paramName); + myDropzone = new Dropzone(selector, { url: "{{ route('surveyor.storeFoto') }}", paramName: paramName, @@ -392,6 +394,133 @@ } } + + function addCameraOption(dropzoneElement, paramName) { + if (dropzoneElement.querySelector('.upload-options')) { + return; + } + + // Create the upload options container + const uploadOptionsContainer = document.createElement('div'); + uploadOptionsContainer.className = 'upload-options'; + uploadOptionsContainer.style.cssText = ` + display: flex; + justify-content: center; + margin-top: 10px; + gap: 20px; + `; + + // Create camera button + const cameraButton = document.createElement('button'); + cameraButton.type = 'button'; + cameraButton.className = 'camera-button'; + cameraButton.innerHTML = ' Kamera'; + cameraButton.style.cssText = ` + padding: 8px 16px; + background-color: #f5f8fa; + border: 1px solid #e4e6ef; + border-radius: 6px; + display: flex; + align-items: center; + gap: 8px; + cursor: pointer; + `; + + // Create file button + const fileButton = document.createElement('button'); + fileButton.type = 'button'; + fileButton.className = 'file-button'; + fileButton.innerHTML = ' File'; + fileButton.style.cssText = ` + padding: 8px 16px; + background-color: #f5f8fa; + border: 1px solid #e4e6ef; + border-radius: 6px; + display: flex; + align-items: center; + gap: 8px; + cursor: pointer; + `; + + / + const cameraInput = document.createElement('input'); + cameraInput.type = 'file'; + cameraInput.id = 'camera-input-' + paramName; + cameraInput.accept = 'image/*'; + cameraInput.capture = 'environment'; + cameraInput.style.display = 'none'; + + + const fileInput = document.createElement('input'); + fileInput.type = 'file'; + fileInput.id = 'file-input-' + paramName; + fileInput.accept = 'image/*'; + fileInput.style.display = 'none'; + + // Add event listeners - use only one instance per button + cameraButton.addEventListener('click', function(e) { + e.preventDefault(); + e.stopPropagation(); + cameraInput.click(); + }, false); + + fileButton.addEventListener('click', function(e) { + e.preventDefault(); + e.stopPropagation(); + fileInput.click(); + }, false); + + // Handle file selection for camera - clear input after use + cameraInput.addEventListener('change', function() { + if (this.files && this.files.length > 0) { + handleFileSelection(this.files, myDropzone); + + this.value = ''; + } + }, false); + + // Handle file selection for gallery - clear input after use + fileInput.addEventListener('change', function() { + if (this.files && this.files.length > 0) { + handleFileSelection(this.files, myDropzone); + + this.value = ''; + } + }, false); + + // Append elements + uploadOptionsContainer.appendChild(cameraButton); + uploadOptionsContainer.appendChild(fileButton); + document.body.appendChild(cameraInput); + document.body.appendChild(fileInput); + + // Find the message element in dropzone and insert the options after it + const dzMessage = dropzoneElement.querySelector('.dz-message'); + if (dzMessage) { + dzMessage.appendChild(uploadOptionsContainer); + } else { + dropzoneElement.appendChild(uploadOptionsContainer); + } + + + if (dzMessage) { + dzMessage.style.cssText += ` + display: flex; + flex-direction: column; + align-items: center; + `; + } + } + + + function handleFileSelection(files, dropzone) { + if (!dropzone) return; + + Array.from(files).forEach(file => { + dropzone.addFile(file); + }); + } + function loadExistingPhotos(dropzone, paramName, existingFilesSet) { showLoadingOverlay(); @@ -529,6 +658,12 @@ }); } + + // Check if device is mobile + function isMobileDevice() { + return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); + } + // Inisialisasi Dropzone untuk elemen awal dengan pengecekan function safeInitDropzone(selector, paramName) { setTimeout(() => {