fix(print-out): perbaikan print out foto dan sederhana dan standard

This commit is contained in:
majid
2025-02-07 11:25:55 +07:00
parent 7c6059d479
commit 36a8b0bb15
3 changed files with 230 additions and 131 deletions

View File

@@ -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)
<div class="photo-row clearfix">
@endif
<div class="photo-item border">
<img src="{{ storage_path('app/public/' . $imagePath) }}" alt="{{ $type }}"
class="photo-image">
<p style="margin: 0; font-size: 14px;">
<table width="100%" border="0">
<tr>
@if (count($validPhotoTypes) === 1)
@php
$type = reset($validPhotoTypes); // Ambil elemen pertama
$imagePath = $forminspeksi[$type] ?? null;
@endphp
<td style="width: 100%; vertical-align: top; text-align: center" colspan="2" class="photo-item border">
<p style="margin: 0; font-size: 10px; text-align: center;">
{{ Str::title(str_replace('_', ' ', $type)) }}
</p>
</div>
@if ($counter % 2 == 1 || $loop->last)
@if ($imagePath)
<img src="{{ storage_path('app/public/' . $imagePath) }}" alt="{{ $imagePath }}"
class="photo-image" style="width: 100%; max-width: 300px;">
@endif
</td>
@else
@foreach ($fotoTypes as $index => $type)
@php
$imagePath = $forminspeksi[$type] ?? null;
@endphp
@isset($imagePath)
<td style="width: 50%; vertical-align: top; text-align: center" class="photo-item border">
<p style="margin: 0; font-size: 10px; text-align: center;">
{{ Str::title(str_replace('_', ' ', $type)) }}
</p>
@if ($imagePath && file_exists(storage_path('app/public/' . $imagePath)))
<img src="{{ storage_path('app/public/' . $imagePath) }}" alt="{{ $imagePath }}"
class="photo-image" style="width: 100%; max-width: 300px;">
@endif
</td>
@endisset
@if (($index + 1) % 2 == 0)
</tr>
<tr>
@endif
@endforeach
@if (count($fotoTypes) % 2 != 0)
<td style="width: 50%;"></td>
@endif
@endif
</tr>
</table>
</div>
@endif
@php $counter++; @endphp
@endif
@endforeach
@endif
</div>
<div class="page-break"></div>
<table style="width: 100%; ">
<tr>
<td style="border: 1px solid #000; text-align: center;">
FOTO JAMINAN
</td>
</tr>
</table>
@include('lpj::penilai.components.foto-jaminan')
<div class="page-break"></div>
<table style="width: 100%; ">
<tr>
<td style="border: 1px solid #000; text-align: center;">
FOTO JAMINAN
</td>
</tr>
</table>
@include('lpj::penilai.components.foto')
</div>
</div>
</main>