diff --git a/app/Http/Controllers/PenilaiController.php b/app/Http/Controllers/PenilaiController.php index 7528118..ca0e74f 100644 --- a/app/Http/Controllers/PenilaiController.php +++ b/app/Http/Controllers/PenilaiController.php @@ -190,7 +190,6 @@ class PenilaiController extends Controller */ public function paparan(Request $request) { - $permohonanId = $request->query('permohonanId'); $permohonanId = $request->query('permohonanId'); $documentId = $request->query('documentId'); @@ -198,9 +197,15 @@ class PenilaiController extends Controller $jaminanId = $request->query('jaminanId'); $permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId); - $inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first(); + $penilai = Penilai::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first(); + $inspeksi = Inspeksi::where('permohonan_id', $permohonanId)->where + ('dokument_id', $documentId)->first(); + $formFoto = null; + if ($inspeksi) { + $formFoto = json_decode($inspeksi->foto_form, true); + } - return view('lpj::penilai.components.paparan'); + return view('lpj::penilai.components.paparan', compact('permohonan', 'formFoto', 'penilai')); } @@ -296,21 +301,15 @@ class PenilaiController extends Controller ]); } - public function export_kertas_kerja($id, $jaminanId) + public function export_kertas_kerja(Request $request) { - $data = Inspeksi::where('permohonan_id', $id)->where('dokument_id', $jaminanId)->first(); - // $data = null; - // $headerInfo = [ - // 'tanggal_penilaian' => '', - // 'nama_pemilik' => '', - // 'nama_pemberi_tugas' => '', - // 'lokasi_lengkap' => '', - // 'nama_debitur' => '' - // ]; + $permohonanId = $request->query('permohonanId'); + $documentId = $request->query('documentId'); + $inspeksiId = $request->query('inspeksiId'); + $jaminanId = $request->query('jaminanId'); - // $datas = json_decode($data->data_pembanding); - // return response()->json(['data' =>$datas ]); + $data = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first(); // return view('lpj::component.kertas-kerja', compact('data')); return Excel::download(new KertasKerjaExport($data), 'kertas-kerja.xlsx'); diff --git a/resources/views/component/kertas-kerja.blade.php b/resources/views/component/kertas-kerja.blade.php index 5a92aef..195bc23 100644 --- a/resources/views/component/kertas-kerja.blade.php +++ b/resources/views/component/kertas-kerja.blade.php @@ -464,79 +464,147 @@ -

Peta Objek dan Pembanding -

+

Peta Objek dan Pembanding

- @php - $fotoTypes = ['foto_gistaru', 'foto_bhumi', 'foto_argis_region', 'foto_tempat']; +@php + $fotoTypes = ['foto_gistaru', 'foto_bhumi', 'foto_argis_region', 'foto_tempat']; +@endphp - // echo $dataForm; +@php + $imagePath = $dataform['foto_gistaru']; + @endphp + - @for ($i = 0; $i < count($fotoTypes); $i++) - {{ $fotoTypes[$i] }} - @endfor +
+ @forelse ($fotoTypes as $type) +
+ @php + $imagePath = $dataform[$type]; + @endphp -

FOTO OBJEK DAN DATA PEMBANDING

- - @foreach ($dataPembanding['data_pembanding'] as $item) - Foto Objek -

Data Pembanding {{ $loop->iteration }}

- @endforeach - - - @php - $dataFoto = json_decode($data->foto_form, true); - @endphp -

FOTO OBJEK

- - @php - $images = []; - - // Rute Menuju Lokasi - foreach ($dataFoto['rute_menuju_lokasi'] ?? [] as $rute) { - $images[] = $rute['foto_rute'] ?? null; - } - - // Objek Jaminan - foreach ($dataFoto['object_jaminan'] ?? [] as $objek) { - $images[] = $objek['foto_objek'] ?? null; - } - - // Lingkungan - foreach ($dataFoto['lingkungan'] ?? [] as $lingkungan) { - $images[] = $lingkungan['foto_lingkungan'] ?? null; - } - - // Lantai Unit - foreach ($dataFoto['foto_lantai_unit'] ?? [] as $lantai) { - $images[] = $lantai['foto_lantai_unit'] ?? null; - } - - // Tambahan foto lainnya - $images[] = $dataFoto['foto_basement'] ?? null; - $images[] = $dataFoto['foto_gerbang'] ?? null; - $images[] = $dataFoto['pendamping'] ?? null; - - // Filter null values - $images = array_filter($images); - @endphp - -
- @foreach ($images as $image) - Foto Survey - @endforeach + {{-- @if ($imagePath && Storage::exists($imagePath)) --}} + {{ $type }} +

{{ Str::title(str_replace('_', ' ', $type)) }}

+ {{-- @else +
+

Tidak ada gambar

+
+ @endif --}}
+ @empty +

Tidak ada tipe foto yang tersedia

+ @endforelse +
+ +

FOTO OBJEK DAN DATA PEMBANDING

+ +
+ @forelse ($dataPembanding['data_pembanding'] ?? [] as $index => $item) +
+ @php + $fotoObjek = $item['foto_objek']; + @endphp + + @if ($fotoObjek && Storage::exists($fotoObjek)) + Foto Objek Pembanding {{ $loop->iteration }} +

Data Pembanding {{ $loop->iteration }}

+ @else +
+

Tidak ada gambar pembanding

+
+ @endif +
+ @empty +

Tidak ada data pembanding

+ @endforelse +
+ +

FOTO OBJEK

+ +@php + // Fungsi untuk mengumpulkan foto dengan pengecekan yang aman + function collectSafeImages($data, $paths = []) { + if (!is_array($data)) { + return $paths; + } + + foreach ($data as $key => $value) { + if (is_array($value)) { + // Jika array memiliki kunci foto + if (isset($value['foto_rute'])) { + $paths[] = $value['foto_rute']; + } + if (isset($value['foto_objek'])) { + $paths[] = $value['foto_objek']; + } + if (isset($value['foto_lingkungan'])) { + $paths[] = $value['foto_lingkungan']; + } + if (isset($value['foto_lantai_unit'])) { + $paths[] = $value['foto_lantai_unit']; + } + + // Rekursif untuk nested array + $paths = collectSafeImages($value, $paths); + } elseif (is_string($value) && strpos($value, 'foto_') !== false) { + $paths[] = $value; + } + } + + return $paths; + } + + // Decode foto form dengan penanganan error + try { + $dataFoto = json_decode($data->foto_form, true) ?? []; + } catch (Exception $e) { + $dataFoto = []; + } + + // Kumpulkan foto + $images = collectSafeImages($dataFoto); + + // Filter foto yang valid + $validImages = array_filter($images, function($image) { + return $image && Storage::exists($image); + }) + + + +@endphp + +
+ @forelse ($validImages as $image) +
+ Foto Survey +
+ @empty +
+

Tidak ada foto objek yang tersedia

+
+ @endforelse +
+ diff --git a/resources/views/penilai/components/foto-lampiran.blade.php b/resources/views/penilai/components/foto-lampiran.blade.php new file mode 100644 index 0000000..b7dc091 --- /dev/null +++ b/resources/views/penilai/components/foto-lampiran.blade.php @@ -0,0 +1,137 @@ +
+
+

+ Rute Menuju Lokasi +

+
+
+ @if (isset($formFoto)) + @foreach ($formFoto['rute_menuju_lokasi'] as $item) +
+
+

+ {{ $item['name_rute'] . ' ' . $loop->index + 1 }} +

+
+ + + + +
+
+
+ @endforeach + @endif +
+
+ + +
+
+

+ Object Jaminan +

+
+
+ @if (isset($formFoto['object_jaminan'])) + @foreach ($formFoto['object_jaminan'] as $item) +
+
+

+ {{ $item['name_objek'] }} +

+
+ + + + +
+
+
+ @endforeach + @endif +
+
+ +@if (isset($formFoto['foto_basement'])) +
+
+

+ Basement +

+
+
+
+
+

+ Basemnt +

+
+ + + + +
+
+
+ +
+
+@endif + +@if (isset($formFoto['foto_gerbang'])) +
+
+

+ Gerbang +

+
+
+ + +
+
+

+ Gerbang +

+
+ + + + +
+
+
+ +
+
+@endif + + +@if (isset($formFoto['pendamping'])) +
+
+

+ Pendamping +

+
+
+ + +
+
+

+ Pendamping +

+
+ + + + +
+
+
+ +
+
+@endif diff --git a/resources/views/penilai/components/informasi-pembanding.blade.php b/resources/views/penilai/components/informasi-pembanding.blade.php index a65fa57..2fe77e1 100644 --- a/resources/views/penilai/components/informasi-pembanding.blade.php +++ b/resources/views/penilai/components/informasi-pembanding.blade.php @@ -11,8 +11,13 @@
- Gambar foto_objek +
+ Gambar foto_objek +
@@ -71,3 +76,20 @@ @endforeach @endif
+ + + + diff --git a/resources/views/penilai/components/paparan.blade.php b/resources/views/penilai/components/paparan.blade.php index bf5e1fd..3c6fe90 100644 --- a/resources/views/penilai/components/paparan.blade.php +++ b/resources/views/penilai/components/paparan.blade.php @@ -72,7 +72,23 @@
- - + @include('lpj::penilai.components.foto-lampiran') + +
+
+ Kertas Kerja +
+
+ + @php + $url = asset('storage/' . $penilai->kertas_kerja); + @endphp + + + +
+
+ + @endsection diff --git a/resources/views/penilai/lampiran.blade.php b/resources/views/penilai/lampiran.blade.php index 2fd7be2..22009f1 100644 --- a/resources/views/penilai/lampiran.blade.php +++ b/resources/views/penilai/lampiran.blade.php @@ -114,144 +114,7 @@ @endif - -
-
-

- Rute Menuju Lokasi -

-
-
- @if (isset($formFoto)) - @foreach ($formFoto['rute_menuju_lokasi'] as $item) -
-
-

- {{ $item['name_rute'] . ' ' . $loop->index + 1 }} -

-
- - - - -
-
-
- @endforeach - @endif -
-
- - -
-
-

- Object Jaminan -

-
-
- @if (isset($formFoto['object_jaminan'])) - @foreach ($formFoto['object_jaminan'] as $item) -
-
-

- {{ $item['name_objek'] }} -

-
- - - - -
-
-
- @endforeach - @endif -
-
- - @if (isset($formFoto['foto_basement'])) -
-
-

- Basement -

-
-
-
-
-

- Basemnt -

-
- - - - -
-
-
- -
-
- @endif - - @if (isset($formFoto['foto_gerbang'])) -
-
-

- Gerbang -

-
-
- - -
-
-

- Gerbang -

-
- - - - -
-
-
- -
-
- @endif - - - @if (isset($formFoto['pendamping'])) -
-
-

- Pendamping -

-
-
- - -
-
-

- Pendamping -

-
- - - - -
-
-
- -
-
- @endif + @include('lpj::penilai.components.foto-lampiran') @endsection diff --git a/resources/views/penilai/show.blade.php b/resources/views/penilai/show.blade.php index 576ef7a..37a4a2c 100644 --- a/resources/views/penilai/show.blade.php +++ b/resources/views/penilai/show.blade.php @@ -193,7 +193,7 @@ KERTAS KERJA - + PAPARAN @@ -308,7 +308,6 @@ @endforeach
-