From 36a8b0bb155b78bdf3d7bf176707ebbbfd0beacf Mon Sep 17 00:00:00 2001 From: majid Date: Fri, 7 Feb 2025 11:25:55 +0700 Subject: [PATCH] fix(print-out): perbaikan print out foto dan sederhana dan standard --- .../penilai/components/foto-jaminan.blade.php | 205 +++++++++++------- .../components/print-out-sederhana.blade.php | 70 ++++-- .../components/print-out-standard.blade.php | 86 +++++--- 3 files changed, 230 insertions(+), 131 deletions(-) diff --git a/resources/views/penilai/components/foto-jaminan.blade.php b/resources/views/penilai/components/foto-jaminan.blade.php index 65ba464..1888478 100644 --- a/resources/views/penilai/components/foto-jaminan.blade.php +++ b/resources/views/penilai/components/foto-jaminan.blade.php @@ -19,10 +19,7 @@ } .photo-item { - width: 48%; - margin-right: 2%; - float: left; - padding: 5px; + box-sizing: border-box; page-break-inside: avoid; } @@ -38,7 +35,6 @@ object-fit: contain; background-color: #f0f0f0; border-radius: 5px; - page-break-inside: avoid; } /* Clearfix */ @@ -90,7 +86,7 @@ } $groupedPhotos = collect($photos)->groupBy('category'); - $mainPhotos = $groupedPhotos->filter(fn($_, $key) => $key !== 'lainnya'); + $mainPhotos = $groupedPhotos->filter(fn($_, $key) => strtolower($key) !== 'lainnya'); $otherPhotos = $groupedPhotos->get('lainnya', collect()); @endphp @@ -98,91 +94,148 @@

Tidak ada foto yang tersedia.

@else @foreach ($mainPhotos as $category => $photos) -
-

{{ $category }}

- @php - $groupedBySubcategory = $photos->groupBy('sub'); - @endphp + @php + $groupedBySubcategory = $photos->groupBy('sub'); + @endphp - @if ($groupedBySubcategory->isEmpty()) -

Tidak ada subkategori yang tersedia.

- @else - @foreach ($groupedBySubcategory as $subcategory => $subPhotos) - @isset($subcategory) -
- {{ $subcategory ?: '' }} -
- @endisset - -
- @foreach ($subPhotos as $index => $item) + @foreach ($groupedBySubcategory as $subcategory => $subPhotos) + @if (count($subPhotos) > 0) + + + @if (count($subPhotos) === 1) @php + $item = $subPhotos->first(); $imagePath = storage_path('app/public/' . $item['path']); @endphp -
-

{{ $item['name'] }}

+
+ @else + @foreach ($subPhotos as $index => $item) + @php + $imagePath = storage_path('app/public/' . $item['path']); + @endphp + + @if (($index + 1) % 2 == 0) + + @endif @endforeach - + @if (count($subPhotos) % 2 != 0) + + @endif + @endif + +
+

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

@if ($statusLpj || file_exists($imagePath)) - {{ $item['path'] }} - @else -

Foto tidak ditemukan.

+ {{ $item['path'] }} @endif @isset($item['description'])

{{ $item['description'] }}

@endisset - +
+

{{ $category }} - - @if (($index + 1) % 2 == 0 && !$loop->last) - -

- @endif - @endforeach -
- @endforeach - @endif - - @endforeach + @isset($subcategory) + @if (trim($subcategory) !== '') + {{ $subcategory }} - + @endif + @endisset - @if (!$otherPhotos->isEmpty()) -
-

Lainnya

- - @php - $groupedBySubcategory = $otherPhotos->groupBy('sub'); - @endphp - - @if ($groupedBySubcategory->isEmpty()) -

Tidak ada subkategori yang tersedia.

- @else - @foreach ($groupedBySubcategory as $subcategory => $subPhotos) - @isset($subcategory) -
- {{ $subcategory ?: '' }} -
- @endisset - -
- @foreach ($subPhotos as $index => $item) - @php - $imagePath = storage_path('app/public/' . $item['path']); - @endphp -
-
{{ $item['name'] }}
- @if ($statusLpj || file_exists($imagePath)) - {{ $item['path'] }} - @else -

Foto tidak ditemukan.

- @endif -
- - @if (($index + 1) % 2 == 0 && !$loop->last) -
-
+ {{ $item['name'] ?? '' }} +

+ @if ($statusLpj || file_exists($imagePath)) + {{ $item['path'] }} + @endif + @isset($item['description']) +

{{ $item['description'] }}

+ @endisset +
+ @endif + @endforeach @endforeach @endif -
+ +
+ + @if (!$otherPhotos->isEmpty()) + @foreach ($otherPhotos->groupBy('sub') as $subcategory => $subPhotos) + @if (count($subPhotos) > 0) + + + @if (count($subPhotos) === 1) + @php + $item = $subPhotos->first(); + $imagePath = storage_path('app/public/' . $item['path']); + @endphp + + @else + @foreach ($subPhotos as $index => $item) + @php + $imagePath = storage_path('app/public/' . $item['path']); + @endphp + + @if (($index + 1) % 2 == 0) + + + @endif + @endforeach + @if (count($subPhotos) % 2 != 0) + + @endif @endif + +
+

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

+ @if ($statusLpj || file_exists($imagePath)) + {{ $item['path'] }} + @endif + @isset($item['description']) +

{{ $item['description'] }}

+ @endisset +
+

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

+ @if ($statusLpj || file_exists($imagePath)) + {{ $item['path'] }} + @endif + @isset($item['description']) +

{{ $item['description'] }}

+ @endisset +
+ @endif + @endforeach @endif @endisset diff --git a/resources/views/penilai/components/print-out-sederhana.blade.php b/resources/views/penilai/components/print-out-sederhana.blade.php index 7de2d7f..be8cc84 100644 --- a/resources/views/penilai/components/print-out-sederhana.blade.php +++ b/resources/views/penilai/components/print-out-sederhana.blade.php @@ -115,7 +115,7 @@ - + @@ -1175,35 +1175,57 @@ unset($fotoTypes[$key]); array_unshift($fotoTypes, 'foto_tempat'); } + // 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])); + }); @endphp - @if (isset($forminspeksi)) - @php $counter = 0; @endphp - @foreach ($fotoTypes as $type) - @php - $imagePath = $forminspeksi[$type] ?? null; - @endphp - @if ($imagePath && file_exists(storage_path('app/public/' . $imagePath))) - @if ($counter % 2 == 0) -
- @endif -
- {{ $type }} -

+

Fasilitas Kredit
+ + @if (count($validPhotoTypes) === 1) + @php + $type = reset($validPhotoTypes); + $imagePath = $forminspeksi[$type] ?? null; + @endphp + + @else + @foreach ($fotoTypes as $index => $type) + @php + $imagePath = $forminspeksi[$type] ?? null; + @endphp + @isset($imagePath) + + @endisset + @if (($index + 1) % 2 == 0) + + + @endif + @endforeach + @if (count($fotoTypes) % 2 != 0) + @endif - @php $counter++; @endphp @endif - @endforeach - @endif + +
+

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

- - @if ($counter % 2 == 1 || $loop->last) - + @if ($imagePath) + {{ $imagePath }} + @endif +
+

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

+ @if ($imagePath && file_exists(storage_path('app/public/' . $imagePath))) + {{ $imagePath }} + @endif +
+ @@ -1214,7 +1236,7 @@ FOTO JAMINAN - @include('lpj::penilai.components.foto-jaminan') + @include('lpj::penilai.components.foto') diff --git a/resources/views/penilai/components/print-out-standard.blade.php b/resources/views/penilai/components/print-out-standard.blade.php index cac6b86..6aca672 100644 --- a/resources/views/penilai/components/print-out-standard.blade.php +++ b/resources/views/penilai/components/print-out-standard.blade.php @@ -643,42 +643,66 @@ unset($fotoTypes[$key]); array_unshift($fotoTypes, 'foto_tempat'); } + // 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])); + }); @endphp - @if (isset($forminspeksi)) - @php $counter = 0; @endphp - @foreach ($fotoTypes as $type) - @php - $imagePath = $forminspeksi[$type] ?? null; - @endphp - @if ($imagePath && file_exists(storage_path('app/public/' . $imagePath))) - @if ($counter % 2 == 0) -
- @endif -
- {{ $type }} -

+ + + @if (count($validPhotoTypes) === 1) + @php + $type = reset($validPhotoTypes); // Ambil elemen pertama + $imagePath = $forminspeksi[$type] ?? null; + @endphp + + @else + @foreach ($fotoTypes as $index => $type) + @php + $imagePath = $forminspeksi[$type] ?? null; + @endphp + @isset($imagePath) + + @endisset + @if (($index + 1) % 2 == 0) + + + @endif + @endforeach + @if (count($fotoTypes) % 2 != 0) + + @endif + @endif + +
+

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

- - @if ($counter % 2 == 1 || $loop->last) + @if ($imagePath) + {{ $imagePath }} + @endif +
+

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

+ @if ($imagePath && file_exists(storage_path('app/public/' . $imagePath))) + {{ $imagePath }} + @endif +

- @endif - @php $counter++; @endphp - @endif - @endforeach - @endif -
-
- - - - -
- FOTO JAMINAN -
- @include('lpj::penilai.components.foto-jaminan') + +
+ + + + +
+ FOTO JAMINAN +
+ @include('lpj::penilai.components.foto')