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

@@ -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 @@
<p class="text-gray-500">Tidak ada foto yang tersedia.</p>
@else
@foreach ($mainPhotos as $category => $photos)
<div class="photo-container">
<h2>{{ $category }}</h2>
@php
$groupedBySubcategory = $photos->groupBy('sub');
@endphp
@php
$groupedBySubcategory = $photos->groupBy('sub');
@endphp
@if ($groupedBySubcategory->isEmpty())
<p class="text-gray-500">Tidak ada subkategori yang tersedia.</p>
@else
@foreach ($groupedBySubcategory as $subcategory => $subPhotos)
@isset($subcategory)
<h6 style="font-size:10px">
{{ $subcategory ?: '' }}
</h6>
@endisset
<div class="photo-row clearfix">
@foreach ($subPhotos as $index => $item)
@foreach ($groupedBySubcategory as $subcategory => $subPhotos)
@if (count($subPhotos) > 0)
<table width="100%" border="0" style="align-content: center; text-align: center">
<tr>
@if (count($subPhotos) === 1)
@php
$item = $subPhotos->first();
$imagePath = storage_path('app/public/' . $item['path']);
@endphp
<div class="photo-item border">
<p style="text-align: center" >{{ $item['name'] }}</p>
<td style="width: 100%; vertical-align: top; text-align: center" colspan="2"
class="photo-item border">
<p style="font-weight: medium; font-size: 10px">{{ $category }} -
@isset($subcategory)
@if (trim($subcategory) !== '')
{{ $subcategory }} -
@endif
@endisset
{{ $item['name'] ?? '' }}
</p>
@if ($statusLpj || file_exists($imagePath))
<img src="{{ $imagePath }}" alt="{{ $item['path'] }}" class="photo-image">
@else
<p class="text-gray-400">Foto tidak ditemukan.</p>
<img src="{{ $imagePath }}" alt="{{ $item['path'] }}" class="photo-image"
style="width: 100%; max-width: 300px;">
@endif
@isset($item['description'])
<p style="font-size:9px">{{ $item['description'] }}</p>
@endisset
</div>
</td>
@else
@foreach ($subPhotos as $index => $item)
@php
$imagePath = storage_path('app/public/' . $item['path']);
@endphp
<td style="width: 50%; vertical-align: top; text-align: center"
class="photo-item border">
<p style="font-weight: medium; font-size: 10px">{{ $category }} -
@if (($index + 1) % 2 == 0 && !$loop->last)
</div>
<div class="photo-row clearfix">
@endif
@endforeach
</div>
@endforeach
@endif
</div>
@endforeach
@isset($subcategory)
@if (trim($subcategory) !== '')
{{ $subcategory }} -
@endif
@endisset
@if (!$otherPhotos->isEmpty())
<div class="photo-container">
<h2 class="text-gray-800 font-bold text-lg">Lainnya</h2>
@php
$groupedBySubcategory = $otherPhotos->groupBy('sub');
@endphp
@if ($groupedBySubcategory->isEmpty())
<p class="text-gray-500">Tidak ada subkategori yang tersedia.</p>
@else
@foreach ($groupedBySubcategory as $subcategory => $subPhotos)
@isset($subcategory)
<h6 style="font-size:10px">
{{ $subcategory ?: '' }}
</h6>
@endisset
<div class="photo-row clearfix">
@foreach ($subPhotos as $index => $item)
@php
$imagePath = storage_path('app/public/' . $item['path']);
@endphp
<div class="photo-item border">
<h6 style="text-align: center" >{{ $item['name'] }}</h6>
@if ($statusLpj || file_exists($imagePath))
<img src="{{ $imagePath }}" alt="{{ $item['path'] }}" class="photo-image">
@else
<p class="text-gray-400">Foto tidak ditemukan.</p>
@endif
</div>
@if (($index + 1) % 2 == 0 && !$loop->last)
</div>
<div class="photo-row clearfix">
{{ $item['name'] ?? '' }}
</p>
@if ($statusLpj || file_exists($imagePath))
<img src="{{ $imagePath }}" alt="{{ $item['path'] }}" class="photo-image"
style="width: 100%; max-width: 300px;">
@endif
@isset($item['description'])
<p style="font-size:9px">{{ $item['description'] }}</p>
@endisset
</td>
@if (($index + 1) % 2 == 0)
</tr>
<tr>
@endif
@endforeach
</div>
@if (count($subPhotos) % 2 != 0)
<td style="width: 50%;"></td>
@endif
@endif
</tr>
</table>
@endif
@endforeach
@endforeach
@endif
</div>
<div class="page-break"></div>
@if (!$otherPhotos->isEmpty())
@foreach ($otherPhotos->groupBy('sub') as $subcategory => $subPhotos)
@if (count($subPhotos) > 0)
<table width="100%" border="0" style="align-content: center; text-align: center">
<tr>
@if (count($subPhotos) === 1)
@php
$item = $subPhotos->first();
$imagePath = storage_path('app/public/' . $item['path']);
@endphp
<td style="width: 100%; vertical-align: top; text-align: center" colspan="2"
class="photo-item border">
<p style="font-weight: medium; font-size: 10px">{{ $category }} -
@isset($subcategory)
@if (trim($subcategory) !== '')
{{ $subcategory }} -
@endif
@endisset
{{ $item['name'] ?? '' }}
</p>
@if ($statusLpj || file_exists($imagePath))
<img src="{{ $imagePath }}" alt="{{ $item['path'] }}" class="photo-image"
style="width: 100%; max-width: 300px;">
@endif
@isset($item['description'])
<p style="font-size:9px">{{ $item['description'] }}</p>
@endisset
</td>
@else
@foreach ($subPhotos as $index => $item)
@php
$imagePath = storage_path('app/public/' . $item['path']);
@endphp
<td style="width: 50%; vertical-align: top; text-align: center" class="photo-item border">
<p style="font-weight: medium; font-size: 10px">{{ $category }} -
@isset($subcategory)
@if (trim($subcategory) !== '')
{{ $subcategory }} -
@endif
@endisset
{{ $item['name'] ?? '' }}
</p>
@if ($statusLpj || file_exists($imagePath))
<img src="{{ $imagePath }}" alt="{{ $item['path'] }}" class="photo-image"
style="width: 100%; max-width: 300px;">
@endif
@isset($item['description'])
<p style="font-size:9px">{{ $item['description'] }}</p>
@endisset
</td>
@if (($index + 1) % 2 == 0)
</tr>
<tr>
@endif
@endforeach
@if (count($subPhotos) % 2 != 0)
<td style="width: 50%;"></td>
@endif
@endif
</tr>
</table>
@endif
@endforeach
@endif
@endisset

View File

@@ -115,7 +115,7 @@
</tr>
</table>
</td>
<td>
<td style="vertical-align: top">
<table style="width: 100%; border-collapse: collapse;">
<tr>
<td style=" padding: 2px; vertical-align: top;">Fasilitas Kredit</td>
@@ -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)
<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);
$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)
</div>
@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
@php $counter++; @endphp
@endif
@endforeach
@endif
</tr>
</table>
</div>
</div>
@@ -1214,7 +1236,7 @@
FOTO JAMINAN
</h6>
</div>
@include('lpj::penilai.components.foto-jaminan')
@include('lpj::penilai.components.foto')
</div>
</div>

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>