diff --git a/app/Services/PreviewLaporanService.php b/app/Services/PreviewLaporanService.php index 8cf1ae7..fa37d94 100644 --- a/app/Services/PreviewLaporanService.php +++ b/app/Services/PreviewLaporanService.php @@ -69,6 +69,7 @@ use Modules\Lpj\Jobs\SendJadwalKunjunganEmailJob; use App\Helpers\Lpj; use Modules\Lpj\Models\Penilai; use Barryvdh\DomPDF\Facade\Pdf; + class PreviewLaporanService { public function previewLaporan($permohonan_id, $dokumen_id, $jaminan_id, $back) @@ -78,7 +79,12 @@ class PreviewLaporanService $dokumen_id, $jaminan_id ); + // $tipeLaporanResponse = $this->checkPrintOutLaporan($permohonan_id, $document_id); + // $tipeLaporan = $tipeLaporanResponse->getData(); + // if (!$tipeLaporan->status) { + // return redirect()->back()->with('error', 'Laporan tidak valid'); + // } $basicData = $this->getCommonData(); $inspeksi = Inspeksi::where('permohonan_id', $permohonan_id)->where('dokument_id', $dokumen_id)->first(); @@ -90,20 +96,20 @@ class PreviewLaporanService $lpjData = null; $formFoto = null; - if ($inspeksi) { - $forminspeksi = json_decode($inspeksi->data_form, true); - $formFoto = json_decode($inspeksi->foto_form, true); - // $denahForm = json_decode($data->denah_form, true); - $dataPembanding = json_decode($inspeksi->data_pembanding, true); - } + // if ($inspeksi) { + $forminspeksi = json_decode($inspeksi?->data_form, true) ?? null; + $formFoto = json_decode($inspeksi?->foto_form, true) ?? null; + // $denahForm = json_decode($data->denah_form, true); + $dataPembanding = json_decode($inspeksi?->data_pembanding, true) ?? null; + // } - if ($lpj) { - $lpjData = json_decode($lpj->lpj, true); - $memo = json_decode($lpj->memo, true); - $resumeData = json_decode($lpj->resume, true); - $rap = json_decode($lpj->rap, true); - $report = json_decode($lpj->call_report, true); - } + // if ($lpj) { + $lpjData = json_decode($lpj?->lpj, true) ?? null; + $memo = json_decode($lpj?->memo, true) ?? null; + $resumeData = json_decode($lpj?->resume, true) ?? null; + $rap = json_decode($lpj?->rap, true); + $report = json_decode($lpj?->call_report, true) ?? null; + // } $inputAddress = $forminspeksi['asset']['alamat']['sesuai'] ?? $forminspeksi['asset']['alamat']['tidak sesuai'] ?? []; @@ -118,7 +124,7 @@ class PreviewLaporanService $statusLpj = 0; // $viewLaporan = $this->getViewLaporan($tipeLaporan); - return view('lpj::component.show-laporan-inspeksi', compact('permohonan', 'basicData', 'forminspeksi', 'alamat', 'lpjData', 'memo', 'resumeData', 'rap', 'report', 'lpj', 'formFoto', 'nomorLaporan', 'tanggalLaporan', 'dataPembanding', 'inspeksi', 'statusLpj', 'permohonan_id', 'back')); + return view('lpj::component.show-laporan-inspeksi', compact('permohonan', 'basicData', 'forminspeksi', 'alamat', 'lpjData', 'memo', 'resumeData', 'rap', 'report', 'lpj', 'formFoto', 'nomorLaporan', 'tanggalLaporan', 'dataPembanding', 'inspeksi', 'statusLpj', 'permohonan_id', 'back', )); } public function printOutLaporan($permohonan_id, $document_id, $jaminan_id) @@ -230,7 +236,7 @@ class PreviewLaporanService return $viewMap[$tipe] ?? 'penilai.components.print-resume'; } - public function checkPrintOutLaporan($permohonan_id, $dokumen_id) + public function checkPrintOutLaporan($permohonan_id, $dokumen_id) { diff --git a/resources/views/penilai/components/foto-jaminan.blade.php b/resources/views/penilai/components/foto-jaminan.blade.php index 000a43b..64597e7 100644 --- a/resources/views/penilai/components/foto-jaminan.blade.php +++ b/resources/views/penilai/components/foto-jaminan.blade.php @@ -98,41 +98,83 @@ @foreach ($chunkedPhotos as $item) - @php - $filePath = $statusLpj == 1 ? storage_path('app/public/' . $item['path']) : asset('storage/' . $item['path']); - $filePath = asset('storage/' . $item['path']); + @php + $filePath = + $statusLpj == 1 + ? storage_path('app/public/' . $item['path']) + : asset('storage/' . $item['path']); + $extension = strtolower(pathinfo($item['path'], PATHINFO_EXTENSION)); - $isImage = in_array($extension, ['jpg', 'jpeg', 'png', 'gif']); + $isImage = in_array($extension, [ + 'jpg', + 'jpeg', + 'png', + 'gif', + 'bmp', + 'svg', + 'webp', + 'tiff', + ]); $isPdf = $extension === 'pdf'; @endphp - - + + + @endif + @elseif ($statusLpj != 1) + + - + + @isset($item['description']) +

{{ $item['description'] }}

+ @endisset + + + + @endif @endforeach @if (count($chunkedPhotos) < 2) @@ -151,41 +193,79 @@
-

{{ $category }} - - @isset($subcategory) - @if (trim($subcategory) !== '') - {{ $subcategory }} - + @if ($statusLpj == 1) + @if ($isImage && $filePath) +

+

{{ $category }} - + @isset($subcategory) + @if (trim($subcategory) !== '') + {{ $subcategory }} - + @endif + @endisset + {{ $item['name'] ?? '' }} +

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

{{ $category }} - + @isset($subcategory) + @if (trim($subcategory) !== '') + {{ $subcategory }} - + @endif + @endisset + + {{ $item['name'] ?? '' }} + +

+ @if ($statusLpj || file_exists(public_path('storage/' . $item['path']))) + @if ($isImage) + {{ $item['path'] }} + @elseif ($isPdf) + + ⬇️ Unduh File PDF + + @else + + ⬇️ Unduh File + @endif - @endisset - {{ $item['name'] ?? '' }} -

- @if ($statusLpj || file_exists(public_path('storage/' . $item['path']))) - @if ($isImage) - {{ $item['path'] }} - @elseif ($isPdf) - - ⬇️ Unduh File PDF - - @else - - ⬇️ Unduh File - @endif - @endif - @isset($item['description']) -

{{ $item['description'] }}

- @endisset -
@foreach ($chunkedPhotos as $item) - @php - $filePath = $statusLpj == 1 ? storage_path('app/public/' . $item['path']) : asset('storage/' . $item['path']); + @php + $filePath = + $statusLpj == 1 + ? storage_path('app/public/' . $item['path']) + : asset('storage/' . $item['path']); $extension = strtolower(pathinfo($item['path'], PATHINFO_EXTENSION)); + $isImage = in_array($extension, [ + 'jpg', + 'jpeg', + 'png', + 'gif', + 'bmp', + 'svg', + 'webp', + 'tiff', + ]); $isPdf = $extension === 'pdf'; @endphp - - + + + @endif + @elseif ($statusLpj != 1) + + + + @isset($item['description']) +

{{ $item['description'] }}

+ @endisset + + + + @endif @endforeach - @if (count($chunkedPhotos) < 2) @endif
-

Lainnya - - @isset($subcategory) - @if (trim($subcategory) !== '') - {{ $subcategory }} - + @if ($statusLpj == 1) + @if ($isImage && $filePath) +

+

{{ $category }} - + @isset($subcategory) + @if (trim($subcategory) !== '') + {{ $subcategory }} - + @endif + @endisset + {{ $item['name'] ?? '' }} +

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

Lainnya - + @isset($subcategory) + @if (trim($subcategory) !== '') + {{ $subcategory }} - + @endif + @endisset + {{ $item['name'] ?? '' }} +

+ @if ($statusLpj || file_exists(public_path('storage/' . $item['path']))) + @if ($isImage) + {{ $item['path'] }} + @elseif ($isPdf) + + ⬇️ Unduh File PDF + + @else + + ⬇️ Unduh File + @endif - @endisset - {{ $item['name'] ?? '' }} -

- @if ($statusLpj || file_exists(public_path('storage/' . $item['path']))) - @if ($isImage) - {{ $item['path'] }} - @elseif ($isPdf) - - ⬇️ Unduh File PDF - - @else - - ⬇️ Unduh File - @endif - @endif - @isset($item['description']) -

{{ $item['description'] }}

- @endisset -