From dfa364cdd878ac9bf7b8bbf8be9fc5081e03568c Mon Sep 17 00:00:00 2001 From: majid Date: Tue, 25 Feb 2025 08:50:03 +0700 Subject: [PATCH] fix(survyor/penilai): perbaikan view print-resume, lampiran, foto-lampiran, foto, header, main dan controller penilai dan surveyor --- app/Http/Controllers/PenilaianController.php | 12 +- app/Http/Controllers/SurveyorController.php | 164 ++++++------------ app/Http/Requests/FormSurveyorRequest.php | 6 +- .../components/foto-lampiran.blade.php | 133 ++++++++------ .../penilai/components/print-resume.blade.php | 15 +- .../views/penilai/components/resume.blade.php | 141 +++------------ resources/views/penilai/lampiran.blade.php | 4 +- .../views/surveyor/components/foto.blade.php | 45 ++++- .../surveyor/components/header.blade.php | 8 + .../components/print-out/main.blade.php | 35 ++-- 10 files changed, 245 insertions(+), 318 deletions(-) diff --git a/app/Http/Controllers/PenilaianController.php b/app/Http/Controllers/PenilaianController.php index 31e3e47..b45d7b6 100644 --- a/app/Http/Controllers/PenilaianController.php +++ b/app/Http/Controllers/PenilaianController.php @@ -96,6 +96,7 @@ class PenilaianController extends Controller } } else { + $teams_ids[] = $validatedData['teams_id']; $user_ids[] = $validatedData['surveyor_id']; } @@ -136,13 +137,14 @@ class PenilaianController extends Controller $user_ids[] = $validatedData['penilai_surveyor_id']; } } else { + $teams_ids[] = $validatedData['teams_id']; $user_ids[] = $validatedData['penilai_id']; } $roles[] = 'penilai'; } - // dd($teams_ids, $user_ids); + // dd($validatedData['penilai_region_id'],$validatedData['teams_id']); foreach ($teams_ids as $key => $teams_id) { PenilaianTeam::create([ 'penilaian_id' => $validatedData['penilaian_id'], @@ -153,13 +155,11 @@ class PenilaianController extends Controller } if ($validatedData['surveyor_id'] === 'pilih_dari_region' || $validatedData['penilai_id'] === 'pilih_dari_region' || $validatedData['penilai_surveyor_id'] === 'pilih_dari_region') { - $status = $permohonan->status; - }else { + $status = 'reassign'; + } else { $status = 'assign'; } - - $permohonan->update([ 'status' => $status, ]); @@ -344,7 +344,7 @@ class PenilaianController extends Controller }); } - $query->whereIn('status', ['registered', 'registrasi-final']); + $query->whereIn('status', ['registered', 'registrasi-final', 'reassign']); // Filter berdasarkan role if (Auth::user()->roles[0]->name !== 'administrator') { diff --git a/app/Http/Controllers/SurveyorController.php b/app/Http/Controllers/SurveyorController.php index decefc4..6654ed5 100644 --- a/app/Http/Controllers/SurveyorController.php +++ b/app/Http/Controllers/SurveyorController.php @@ -491,56 +491,78 @@ class SurveyorController extends Controller { if ($request->hasFile($paramName)) { $files = $request->file($paramName); - + // Pastikan $files adalah array if (!is_array($files)) { $files = [$files]; } - + $formatFotoData = []; $nomor_registrasi = $request->nomor_registrasi; - + + // Generate a unique timestamp for this batch + $batchTimestamp = time(); + foreach ($files as $index => $file) { - $timestamp = time(); $originalName = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); + // Validasi nama file if (empty($originalName)) { - $originalName = "file_{$timestamp}"; + $originalName = "file_{$batchTimestamp}"; } - $uniqueFileName = "{$timestamp}.{$extension}"; - + + // Use batchTimestamp and index to ensure uniqueness + $uniqueFileName = "{$batchTimestamp}_{$index}.{$extension}"; + // Simpan file - $nomor_registrasi = $request->nomor_registrasi; $path = $file->storeAs("surveyor/{$paramName}/{$nomor_registrasi}", $uniqueFileName, 'public'); - - $fotoData = [ - 'name' => pathinfo($originalName, PATHINFO_FILENAME), - 'path' => $path, - 'category' => 'lainnya', - 'sub' => null, - 'description' => null, - 'created_by' => Auth::user()->name, - 'created_at' => now()->toDateTimeString(), - ]; - - $formatFotoData[] = $fotoData; + + // Check if this file already exists in formatFotojson + $fileExists = false; + if (isset($formatFotojson[$paramName]) && is_array($formatFotojson[$paramName])) { + foreach ($formatFotojson[$paramName] as $existingFile) { + // Check if the original file name matches + if (isset($existingFile['name']) && + $existingFile['name'] === pathinfo($originalName, PATHINFO_FILENAME)) { + $fileExists = true; + break; + } + } + } + + // Only add if this file doesn't already exist + if (!$fileExists) { + $fotoData = [ + 'name' => pathinfo($originalName, PATHINFO_FILENAME), + 'path' => $path, + 'category' => 'lainnya', + 'sub' => null, + 'description' => null, + 'created_by' => Auth::user()->name, + 'created_at' => now()->toDateTimeString(), + ]; + + $formatFotoData[] = $fotoData; + } } - - // Struktur JSON yang konsisten - if (!isset($formatFotojson[$paramName])) { - $formatFotojson[$paramName] = $formatFotoData; - } else { - $formatFotojson[$paramName] = array_merge( - $formatFotojson[$paramName] ?? [], - $formatFotoData - ); + + // Only update if we have new photos to add + if (!empty($formatFotoData)) { + // Struktur JSON yang konsisten + if (!isset($formatFotojson[$paramName])) { + $formatFotojson[$paramName] = $formatFotoData; + } else { + $formatFotojson[$paramName] = array_merge( + $formatFotojson[$paramName] ?? [], + $formatFotoData + ); + } + + return $formatFotoData; } - - - return $formatFotoData; } - + return []; } @@ -699,80 +721,6 @@ class SurveyorController extends Controller return false; } - public function hapusLantai(Request $request) - { - $permohonanId = $request->permohonan_id; - $dokumentId = $request->dokument_id; - - // Normalisasi path foto - $cleanRequestPath = str_replace(['storage/', 'surveyor/'], '', $request->foto_path); - - $inspeksi = Inspeksi::firstOrNew( - ['permohonan_id' => $permohonanId, 'dokument_id' => $dokumentId] - ); - $fotoLantaiUnit = json_decode($inspeksi->foto_form, true); - - // Konversi lantai ke string untuk konsistensi - $lantai = (string)$request->lantai; - - // Cek apakah lantai ada di array - $pat = null; - if (isset($fotoLantaiUnit['foto_lantai_unit'][$lantai])) { - // Filter foto, hapus foto yang sesuai - $fotoLantaiUnit['foto_lantai_unit'][$lantai] = array_filter( - $fotoLantaiUnit['foto_lantai_unit'][$lantai], - function ($foto) use ($cleanRequestPath) { - // Normalisasi path foto yang tersimpan - $storedPath = str_replace(['storage/', 'surveyor/'], '', $foto['path']); - - // Jika path cocok, hapus file dari storage - if ($storedPath === $cleanRequestPath) { - // Hapus file dari storage dengan berbagai kemungkinan path - $possiblePaths = [ - 'storage/surveyor/lantai_unit/' . $cleanRequestPath, - 'storage/surveyor/' . $cleanRequestPath, - 'storage/' . $cleanRequestPath, - $cleanRequestPath - ]; - - foreach ($possiblePaths as $path) { - if (Storage::disk('public')->exists($path)) { - Storage::disk('public')->delete($path); - break; - } - } - - return false; // Hapus dari array - } - return true; - } - ); - - // Reset index array - $fotoLantaiUnit['foto_lantai_unit'][$lantai] = array_values($fotoLantaiUnit['foto_lantai_unit'][$lantai]); - - // Hapus lantai jika tidak ada foto - if (empty($fotoLantaiUnit['foto_lantai_unit'][$lantai])) { - unset($fotoLantaiUnit['foto_lantai_unit'][$lantai]); - } - - // Update inspeksi - $inspeksi->foto_form = json_encode($fotoLantaiUnit); - $inspeksi->save(); - - return response()->json([ - 'success' => true, - 'foto_lantai_unit' => $pat - ]); - } - - return response()->json([ - 'success' => false, - 'message' => 'gagal menghapus' - ], 404); - } - - private function generateUniqueFileName($file, $prefix = '') { @@ -797,7 +745,7 @@ class SurveyorController extends Controller 'permohonan_id' => 'required', 'dokument_id' => 'required', 'nomor_registrasi' => 'required', - 'foto_rute.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize, + 'upload_foto.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg,webp,bmp,tiff,heic,heif|max:'. $maxSize, ]); } diff --git a/app/Http/Requests/FormSurveyorRequest.php b/app/Http/Requests/FormSurveyorRequest.php index 8d6ff65..80d28e6 100644 --- a/app/Http/Requests/FormSurveyorRequest.php +++ b/app/Http/Requests/FormSurveyorRequest.php @@ -577,11 +577,11 @@ class FormSurveyorRequest extends FormRequest 'alamat_sesuai' => 'required', 'alamat_tidak_sesuai' => 'nullable|string', 'pihak_bank' => 'nullable|string', - - 'hub_cadeb' => 'required', + 'nomor_nib' => 'nullable|string', + 'hub_cadeb' => 'nullable|string', 'hub_cadeb_sesuai' => 'nullable|string', 'hub_cadeb_tidak_sesuai' => 'nullable|string', - 'hub_cadeb_penghuni' => 'required', + 'hub_cadeb_penghuni' => 'nullable', 'hub_cadeb_penghuni_sesuai' => 'nullable|string', 'hub_penghuni_tidak_sesuai' => 'nullable|string', diff --git a/resources/views/penilai/components/foto-lampiran.blade.php b/resources/views/penilai/components/foto-lampiran.blade.php index f21b449..61ca306 100644 --- a/resources/views/penilai/components/foto-lampiran.blade.php +++ b/resources/views/penilai/components/foto-lampiran.blade.php @@ -13,70 +13,101 @@ @foreach ($groupedPhotos as $category => $photos)

{{ $category ?? 'Tanpa Kategori' }}

-
- @php - $groupedBySubcategory = $photos->groupBy('sub'); - @endphp +
+ +
+
@endforeach @endif @endisset + + + @php $fotoTypes = ['foto_gistaru', 'foto_bhumi', 'foto_argis_region', 'foto_tempat']; if (($key = array_search('foto_tempat', $fotoTypes)) !== false) { diff --git a/resources/views/penilai/components/print-resume.blade.php b/resources/views/penilai/components/print-resume.blade.php index d5e197c..9c09642 100644 --- a/resources/views/penilai/components/print-resume.blade.php +++ b/resources/views/penilai/components/print-resume.blade.php @@ -231,7 +231,7 @@ Luas Tanah Luas Bangunan Nilai Pasar Wajar - Nilai Likuidasi {{ isset($item['likuidasi']) ? '('. $item['likuidasi'] . ' %)' : '-' }} + {{ $item['sertifikat'] ?? '' }} @@ -242,8 +242,7 @@ {{ isset($item['luas_bangunan']) ? $item['luas_bangunan'] . ' m²' : '-' }} {{ isset($item['nilai']) ? formatRupiah($item['nilai']) : '-' }} - - {{ isset($item['total_likuidasi']) ? formatRupiah($item['total_likuidasi']) : '-' }} + @endforeach @@ -265,7 +264,7 @@ Luas Tanah Luas Bangunan Nilai Pasar Wajar - Nilai Likuidasi {{ isset($item['likuidasi']) ? '('. $item['likuidasi'] . ' %)' : '-' }} + @@ -277,8 +276,7 @@ {{ isset($item['luas_bangunan']) ? $item['luas_bangunan'] . ' m²' : '-' }} {{ isset($item['nilai']) ? formatRupiah($item['nilai']) : '-' }} - - {{ isset($item['total_likuidasi']) ? formatRupiah($item['total_likuidasi']) : '-' }} + @endforeach @@ -301,7 +299,7 @@ Luas Tanah Luas Bangunan Nilai Pasar Wajar - Nilai Likuidasi {{ isset($item['likuidasi']) ? '('. $item['likuidasi'] . ' %)' : '' }} + @@ -312,8 +310,7 @@ {{ isset($item['luas_bangunan']) ? $item['luas_bangunan'] . ' m²' : '-' }} {{ isset($item['nilai']) ? formatRupiah($item['nilai']) : '-' }} - - {{ isset($item['total_likuidasi']) ? formatRupiah($item['total_likuidasi']) : '-' }} + @endforeach diff --git a/resources/views/penilai/components/resume.blade.php b/resources/views/penilai/components/resume.blade.php index eeebc11..63c39b7 100644 --- a/resources/views/penilai/components/resume.blade.php +++ b/resources/views/penilai/components/resume.blade.php @@ -194,14 +194,13 @@ Luas Tanah Luas Bangunan Nilai Pasar Wajar - Nilai Likuidasi(%) - Total Nilai Likuidasi + - @if (!empty($resumeData['fisik'])) - @foreach ($resumeData['fisik'] as $item) + @if (!empty($resumeData['sesuai_imb'])) + @foreach ($resumeData['sesuai_imb'] as $item) - - - - - - + value="{{ $item['nilai'] }}" > + @endforeach @else @@ -277,16 +267,9 @@ - - - - - - + > + @endif @@ -306,8 +289,7 @@ Luas Tanah Luas Bangunan Nilai Pasar Wajar - Nilai Likuidasi (%) - Total Nilai Likuidasi + @@ -330,18 +312,9 @@ - - - - - - + value="{{ $item['nilai'] }}" > + @endforeach @else @@ -360,17 +333,9 @@ - - - - - - + > + @endif @@ -398,8 +363,7 @@ Luas Tanah Luas Bangunan Nilai Pasar Wajar - Nilai Likuidasi (%) - Total Nilai Likuidasi + @@ -421,18 +385,9 @@ - - - - - - + value="{{ $item['nilai'] }}" > + @@ -441,7 +396,7 @@
@endforeach @endif -
+
@@ -617,7 +564,7 @@ const formElement = document.querySelector('form'); const jsonData = formToJson(formElement); - console.log('Data dalam format JSON:', JSON.stringify(formElement, null, 2)); + console.log('Data dalam format JSON:', JSON.stringify(jsonData, null, 2)); const urlParams = new URLSearchParams(window.location.search); // Mengambil query parameters dari URL const permohonanId = urlParams.get('permohonanId'); @@ -714,10 +661,7 @@ sertifikat: row.querySelector('input[name="fisik_sertifikat[]"]')?.value || "", luas_tanah: row.querySelector('input[name="fisik_luas_tanah[]"]')?.value || "", luas_bangunan: row.querySelector('input[name="fisik_luas_bangunan[]"]')?.value || "", - nilai: cleanCurrencyValue(row.querySelector('input[name="fisik_nilai[]"]')?.value || ""), - likuidasi: row.querySelector('input[name="likuidasi[]"]')?.value || "", - total_likuidasi: cleanCurrencyValue(row.querySelector( - 'input[name="total_nilai_likuidasi[]"]')?.value || "") + nilai: cleanCurrencyValue(row.querySelector('input[name="fisik_nilai[]"]')?.value || "") }; if (fisikData.sertifikat) { jsonData.fisik.push(fisikData); @@ -730,10 +674,7 @@ sertifikat: row.querySelector('input[name="sesuai_sertifikat[]"]')?.value || "", luas_tanah: row.querySelector('input[name="sesuai_luas_tanah[]"]')?.value || "", luas_bangunan: row.querySelector('input[name="sesuai_luas_bangunan[]"]')?.value || "", - nilai: cleanCurrencyValue(row.querySelector('input[name="sesuai_nilai[]"]')?.value || ""), - likuidasi: row.querySelector('input[name="sesuai_likuidasi[]"]')?.value || "", - total_likuidasi: cleanCurrencyValue(row.querySelector( - 'input[name="sesuai_total_likuidasi[]"]')?.value || "") + nilai: cleanCurrencyValue(row.querySelector('input[name="sesuai_nilai[]"]')?.value || "") }; if (imbData.sertifikat) { jsonData.sesuai_imb.push(imbData); @@ -747,10 +688,7 @@ sertifikat: row.querySelector('input[name="tambahan_sertifikat[]"]')?.value || "", luas_tanah: row.querySelector('input[name="tambahan_luas_tanah[]"]')?.value || "", luas_bangunan: row.querySelector('input[name="tambahan_luas_bangunan[]"]')?.value || "", - nilai: cleanCurrencyValue(row.querySelector('input[name="tambahan_nilai[]"]')?.value || ""), - likuidasi: row.querySelector('input[name="tambahan_nilai_likuidasi[]"]')?.value || "", - total_likuidasi: cleanCurrencyValue(row.querySelector( - 'input[name="tambahan_total_likuidasi[]"]')?.value || "") + nilai: cleanCurrencyValue(row.querySelector('input[name="tambahan_nilai[]"]')?.value || "") }; console.log(imbData); if (imbData.sertifikat) { @@ -784,37 +722,6 @@ - function calculateTotal(element) { - - - const row = element.closest('tr'); - - const nilaiPasarInput = row.querySelector('.nilai-pasar'); - let likuidasiInput = row.querySelector('.likuidasi'); - - const totalLikuidasiInput = row.querySelector('.total-likuidasi'); - - const cleanNilaiPasar = cleanCurrencyValue(nilaiPasarInput.value); - let cleanLikuidasi = cleanCurrencyValue(likuidasiInput.value); - - // Batasi likuidasi maksimal hingga 100 - cleanLikuidasi = Math.min(parseFloat(cleanLikuidasi) || 0, 100); - - // Format nilai likuidasi dengan simbol % - likuidasiInput.value = cleanLikuidasi; - - // Konversi ke angka untuk perhitungan - const nilaiPasar = parseFloat(cleanNilaiPasar) || 0; - const likuidasi = cleanLikuidasi / 100; // Konversi persentase ke desimal - - // Hitung total likuidasi - const totalLikuidasi = nilaiPasar * likuidasi; - - // Tampilkan hasil dengan format yang benar - totalLikuidasiInput.value = formatCurrency(totalLikuidasi.toString()); - - - } diff --git a/resources/views/penilai/lampiran.blade.php b/resources/views/penilai/lampiran.blade.php index 0eed082..c768dc7 100644 --- a/resources/views/penilai/lampiran.blade.php +++ b/resources/views/penilai/lampiran.blade.php @@ -38,14 +38,14 @@
-
+
@if (isset($denah['foto_denah'])) @php $fileExtension = pathinfo($denah['foto_denah'], PATHINFO_EXTENSION); @endphp @if (in_array($fileExtension, ['jpg', 'jpeg', 'png'])) - + @elseif($fileExtension === 'pdf') diff --git a/resources/views/surveyor/components/foto.blade.php b/resources/views/surveyor/components/foto.blade.php index b7ec091..c3d6e99 100644 --- a/resources/views/surveyor/components/foto.blade.php +++ b/resources/views/surveyor/components/foto.blade.php @@ -283,11 +283,11 @@ console.error(`Dropzone element not found: ${selector}`); return null; } + const processedFiles = new Set(); myDropzone = new Dropzone(selector, { url: "{{ route('surveyor.storeFoto') }}", paramName: paramName, - maxFilesize: 30, acceptedFiles: 'image/*', uploadMultiple: false, parallelUploads: 1, @@ -304,14 +304,40 @@ param_name: paramName, nomor_registrasi: '{{ $permohonan->nomor_registrasi ?? '' }}', }, + accept: function(file, done) { + // Generate a unique identifier for the file + const fileId = file.name + '_' + file.size; - addedfiles: function(files) { - uploadQueue += files.length; - uploadBatch = Array.from(files); - if (files.length > 0) showLoadingOverlay(); + // If file is already being processed, reject it + if (processedFiles.has(fileId)) { + done('File sudah dalam antrian upload.'); + return; + } + + // Add file to processed set + processedFiles.add(fileId); + done(); }, + addedfiles: function(files) { + const validFiles = Array.from(files).filter(file => { + // Generate a unique ID for this file + const fileId = file.name + '_' + file.size; + + // Only count files that haven't been rejected + return !file.rejected; + }); + + uploadQueue += validFiles.length; + uploadBatch = validFiles; + + if (validFiles.length > 0) showLoadingOverlay(); + }, error: function(file, response) { + // Remove file from processed list on error + const fileId = file.name + '_' + file.size; + processedFiles.delete(fileId); + handleUploadComplete(file, false, response.message); }, success: function(file, response) { @@ -333,7 +359,14 @@ }, init: function() { - // var myDropzone = this; + const dz = this; + + // Clear processed files when all uploads complete + this.on("queuecomplete", function() { + processedFiles.clear(); + }); + + // Load existing photos loadExistingPhotos(this, paramName); } diff --git a/resources/views/surveyor/components/header.blade.php b/resources/views/surveyor/components/header.blade.php index 2c18f33..cd14ecb 100644 --- a/resources/views/surveyor/components/header.blade.php +++ b/resources/views/surveyor/components/header.blade.php @@ -280,6 +280,14 @@
@include('lpj::component.detail-jaminan', ['status' => true]) +
+ +
+ +
+
+

Hubungan cadeb/debitur dengan Pemilik Jaminan

diff --git a/resources/views/surveyor/components/print-out/main.blade.php b/resources/views/surveyor/components/print-out/main.blade.php index 2e74dfa..c25d233 100644 --- a/resources/views/surveyor/components/print-out/main.blade.php +++ b/resources/views/surveyor/components/print-out/main.blade.php @@ -424,9 +424,11 @@ @if (@isset($dokumen)) @foreach ($dokumen->detail as $detail) - - @if (isset($detail->dokumen_jaminan)) + @if (isset($detail->dokumen_jaminan)) + + + - @endif - + + @endif - - @if (isset($detail->details)) - @if (json_decode($detail->details)) - @foreach (json_decode($detail->details) as $key => $value) - @if (!is_null($value) && $value !== '') - + - - - @endif - @endforeach - @endif + + @endif + @endforeach @endif - + @endif @endforeach @endif
{{ $detail->name ?? '' }}
@if (isset($detail->dokumen_jaminan)) @php @@ -449,27 +451,28 @@ @endforeach @endif
{{ ucwords(str_replace('_', ' ', $key)) ?? '' }} + @if (isset($detail->details)) + @if (json_decode($detail->details)) + @foreach (json_decode($detail->details) as $key => $value) + @if (!is_null($value) && $value !== '') +
+ {{ ucwords(str_replace('_', ' ', $key)) ?? '' }} {{ $value }} + + {{ $value }} @if ($key == 'luas_bangunan' || $key == 'luas_tanah') m2 @endif