fix view foto jaminan

This commit is contained in:
majid
2025-02-06 14:48:45 +07:00
parent 8f2555c0a0
commit ac326c0a49
5 changed files with 276 additions and 446 deletions

View File

@@ -52,7 +52,7 @@ class PenilaiController extends Controller
$permohonanId = $request->query('permohonanId'); $permohonanId = $request->query('permohonanId');
$documentId = $request->query('documentId'); $documentId = $request->query('documentId');
$jaminanId = $request->query('jaminanId'); $jaminanId = $request->query('jaminanId');
$basicData = $this->surveyorController->getCommonData();
$permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId); $permohonan = $this->surveyorController->getPermohonanJaminanId($permohonanId, $documentId, $jaminanId);
$inpeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first(); $inpeksi = Inspeksi::where('permohonan_id', $permohonanId)->where('dokument_id', $documentId)->first();
@@ -62,7 +62,7 @@ class PenilaiController extends Controller
$forminspeksi = json_decode($inpeksi->data_form, true); $forminspeksi = json_decode($inpeksi->data_form, true);
} }
return view('lpj::penilai.lampiran', compact('permohonan', 'formFoto', 'forminspeksi')); return view('lpj::penilai.lampiran', compact('permohonan', 'formFoto', 'forminspeksi','basicData'));
} }
public function create() public function create()

View File

@@ -1,142 +1,169 @@
<div> <style>
@php /* General Styles */
$photoSections = [ body {
'rute_menuju_lokasi' => [ font-family: Arial, sans-serif;
'key' => 'rute_menuju_lokasi', margin: 0;
'name_prefix' => '', padding: 0;
'nested' => true, }
],
'foto_rute_lainnya' => [
'key' => 'name_rute_lainnya',
'name_prefix' => '',
'nested' => false,
],
'foto_lingkungan' => [
'key' => 'foto_lingkungan',
'name_prefix' => '',
'nested' => true,
],
'single_photos' => [
'foto_basement' => 'Basement',
'foto_gerbang' => 'Gerbang',
'pendamping' => 'Pendamping',
],
'object_jaminan' => [
'key' => 'name_objek',
'name_prefix' => '',
'nested' => false,
],
'foto_lantai_unit' => [
'key' => 'name',
'name_prefix' => 'Foto Lantai',
'nested' => true,
],
];
$hasPhotos = false; .photo-container {
width: 100%;
margin-bottom: 10px;
clear: both;
page-break-inside: avoid;
}
.photo-row {
width: 100%;
clear: both;
page-break-inside: avoid;
}
.photo-item {
width: 48%;
margin-right: 2%;
float: left;
padding: 5px;
box-sizing: border-box;
page-break-inside: avoid;
}
.photo-item:nth-child(2n) {
margin-right: 0;
}
/* Image Styling */
.photo-item img {
max-width: 100%;
height: auto;
object-fit: contain;
page-break-inside: avoid;
}
/* Clearfix */
.clearfix::after {
content: "";
clear: both;
display: table;
}
/* Media Print */
@media print {
.photo-item {
width: 48%;
margin-right: 2%;
float: left;
padding: 5px;
box-sizing: border-box;
page-break-inside: avoid;
}
.photo-item img {
max-width: 100%;
height: auto;
object-fit: contain;
}
h2 {
font-size: 14px;
margin-bottom: 5px;
}
}
</style>
@isset($basicData['foto'])
@php
$photos = $formFoto['upload_foto'] ?? [];
if (!is_array($photos)) {
$photos = [];
}
$groupedPhotos = collect($photos)->groupBy('category');
$mainPhotos = $groupedPhotos->filter(fn($_, $key) => $key !== 'Lainnya');
$otherPhotos = $groupedPhotos->get('Lainnya', collect());
@endphp @endphp
<style> @if ($groupedPhotos->isEmpty())
.photo-container { <p class="text-gray-500">Tidak ada foto yang tersedia.</p>
display: flex; @else
flex-wrap: wrap; <div class="photo-container">
justify-content: space-between; @foreach ($mainPhotos as $category => $photos)
margin-bottom: 20px; <h2 class="text-gray-800 font-bold text-lg">{{ $category }}</h2>
}
.photo-item {
width: 100%; /* Adjust to fit two photos per row */
margin-bottom: 10px;
}
.photo-item img {
width: 80%;
height: auto;
border-radius: 5px;
}
</style>
@foreach ($photoSections as $sectionKey => $sectionConfig) @php
@if ($sectionKey === 'single_photos') $groupedBySubcategory = $photos->groupBy('sub');
<div class="photo-container"> @endphp
@foreach ($sectionConfig as $photoKey => $photoName)
@if (isset($formFoto[$photoKey]) && !empty($formFoto[$photoKey]))
@php
$imagePath = storage_path('app/public/' . $formFoto[$photoKey]);
$hasPhotos = true;
@endphp
<div class="photo-item border">
<h2 class="text-gray-600 font-semibold text-xl">
{{ $photoName }}
</h2>
@if ($statusLpj || file_exists($imagePath))
<img src="{{ $imagePath }}" alt="{{ $photoName }}" class="photo-image">
@endif
</div>
@endif
@endforeach
</div>
@else
@php
$sectionData = $formFoto[$sectionKey] ?? null;
@endphp
@if (!empty($sectionData)) @if ($groupedBySubcategory->isEmpty())
@if ($sectionConfig['nested']) <p class="text-gray-500">Tidak ada subkategori yang tersedia.</p>
@if (isset($sectionData[$sectionConfig['key']][0])) @else
<div class="photo-container"> @foreach ($groupedBySubcategory as $subcategory => $subPhotos)
@foreach ($sectionData[$sectionConfig['key']][0] as $index => $item) <h3 class="text-gray-600 font-semibold text-md">
{{ $subcategory ?: '' }}
</h3>
<div class="photo-row clearfix">
@foreach ($subPhotos as $index => $item)
@php @php
$imagePath = storage_path('app/public/' . $item['path']); $imagePath = storage_path('app/public/' . $item['path']);
$hasPhotos = true;
@endphp @endphp
<div class="photo-item border"> <div class="photo-item border">
<h2 class="text-gray-600 font-semibold text-xl"> <h4 class="text-gray-600 font-semibold text-sm">{{ $item['name'] }}</h4>
{{ $sectionConfig['name_prefix']
? $sectionConfig['name_prefix'] . ' ' . ($index + 1)
: $item['name'] ?? 'Foto ' . ($index + 1) }}
</h2>
@if ($statusLpj || file_exists($imagePath)) @if ($statusLpj || file_exists($imagePath))
<img src="{{ $imagePath }}" alt="{{ $item['path'] }}" class="photo-image"> <img src="{{ $imagePath }}" alt="{{ $item['path'] }}" class="photo-image">
@else
<p class="text-gray-400">Foto tidak ditemukan.</p>
@endif @endif
</div> </div>
@endforeach
@if (($index + 1) % 2 == 0 && !$loop->last)
</div> </div>
<div class="photo-row clearfix">
@endif @endif
@else @endforeach
<div class="photo-container"> </div>
@foreach ($sectionData as $index => $item) @endforeach
@php @endif
$name = $item[$sectionConfig['key']] ?? '';
$photoPath =
$sectionKey === 'object_jaminan'
? $item['foto_objek'] ?? ''
: $item['foto_rute_lainnya'] ?? '';
$imagePath = storage_path('app/public/' . $photoPath);
@endphp
@if (!empty($name) || !empty($photoPath))
@php $hasPhotos = true; @endphp
<div class="photo-item border">
@if (!empty($name))
<h2 class="text-gray-600 font-semibold text-xl">
{{ $name }}
</h2>
@endif
@if ($statusLpj || (file_exists($imagePath) && !empty($photoPath)))
<img src="{{ $imagePath }}" alt="{{ $name ?: 'Foto' }}" class="photo-image">
@endif
</div>
@endif
@endforeach
</div>
@endif
@endif
@endif
@endforeach @endforeach
@if (!$hasPhotos) @if (!$otherPhotos->isEmpty())
<div class="text-center py-6 bg-gray-100 rounded-lg"> <h2 class="text-gray-800 font-bold text-lg">Lainnya</h2>
<p class="text-gray-500 italic">Tidak ada foto yang tersedia</p>
</div> @php
@endif $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)
<h3 class="text-gray-600 font-semibold text-md">
{{ $subcategory ?: '' }}
</h3>
<div class="photo-row clearfix">
@foreach ($subPhotos as $index => $item)
@php
$imagePath = storage_path('app/public/' . $item['path']);
@endphp
<div class="photo-item border">
<h4 class="text-gray-600 font-semibold text-sm">{{ $item['name'] }}</h4>
@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">
@endif
@endforeach
</div>
@endforeach
@endif
@endif
</div> </div>
@endif
@endisset

View File

@@ -1,264 +1,89 @@
@if (isset($formFoto['rute_menuju_lokasi']['rute_menuju_lokasi'])) @isset($basicData['foto'])
<div class="card"> @php
<div class="card-header bg-agi-50" id="basic_settings"> $photos = $formFoto['upload_foto'] ?? [];
<h3 class="card-title"> if (!is_array($photos)) {
Rute Menuju Lokasi $photos = [];
</h3> }
</div> $groupedPhotos = collect($photos)->groupBy('category');
<div class="card-body"> @endphp
@if (isset($formFoto['rute_menuju_lokasi']['rute_menuju_lokasi']))
@foreach ($formFoto['rute_menuju_lokasi']['rute_menuju_lokasi'][0] as $index => $item)
<div class="flex items-center justify-between mt-5">
<div class="grid gap-5">
<h2 class="text-gray-600 font-semibold text-xl">
{{ $item['name'] ?? 'Rute menuju lokasi - ' . ($index + 1) }}
</h2>
<div class="flex items-center">
<img src="{{ Storage::url($item['path']) }}" alt="Gambar {{ $index + 1 }}"
class="w-full h-auto object-cover">
</div>
</div>
</div>
@endforeach
@endif
</div>
</div>
@endif
@if (isset($formFoto['foto_rute_lainnya'])) @if ($groupedPhotos->isEmpty())
<div class="card"> <p class="text-gray-500">Tidak ada foto yang tersedia.</p>
<div class="card-header" id="basic_settings"> @else
<h3 class="card-title"> @foreach ($groupedPhotos as $category => $photos)
Rute Lainnya <div class="mt-5">
</h3> <h2 class="text-gray-800 font-bold text-xl mb-3">{{ $category ?? 'Tanpa Kategori' }}</h2>
</div>
<div class="card-body">
@if (isset($formFoto['foto_rute_lainnya']))
@foreach ($formFoto['foto_rute_lainnya'] as $index => $item)
<div class="flex items-center justify-between mt-5">
<div class="grid gap-5">
<h2 class="text-gray-600 font-semibold text-xl">
{{ $item['name_rute_lainnya'] ?? 'Rute Lainnya - ' . ($index + 1) }}
</h2>
<div class="flex items-center">
<img src="{{ Storage::url($item['foto_rute_lainnya']) }}" alt="Gambar {{ $index + 1 }}"
class="w-full h-auto object-cover">
</div>
</div>
</div>
@endforeach
@endif
</div>
</div>
@endif
@if (isset($formFoto['foto_gerbang']))
<div class="card">
<div class="card-header bg-agi-50" id="basic_settings">
<h3 class="card-title">
Gerbang
</h3>
</div>
<div class="card-body">
<div class="flex items-center justify-between mt-5">
<div class="grid gap-5"> <div class="grid gap-5">
<h2 class=" font-semibold text-xl"> @php
Gerbang $groupedBySubcategory = $photos->groupBy('sub');
</h2> @endphp
<div class="flex items-center">
@if ($groupedBySubcategory->isEmpty())
<img src="{{ Storage::url($formFoto['foto_gerbang']) }}" alt="" class="w-full h-auto object-cover"> @foreach ($photos as $index => $item)
<div class="flex items-center justify-between">
</div> <div class="grid gap-5">
</div> <h3 class="text-gray-600 font-semibold text-lg">
</div> {{ $item['name'] ?? 'Foto - ' . ($index + 1) }}
</h3>
</div> <div class="flex items-center">
</div> @if (isset($item['path']))
@endif <img src="{{ asset('storage/' . $item['path']) }}" alt="Gambar {{ $index + 1 }}"
class="w-full h-auto object-cover rounded-md">
@if (isset($formFoto['foto_lingkungan']['foto_lingkungan'])) @else
<div class="card"> <p class="text-gray-500">Gambar tidak tersedia</p>
<div class="card-header" id="basic_settings"> @endif
<h3 class="card-title"> </div>
Lingkungan </h3> <p class="text-gray-500 text-sm">{{ $item['description'] ?? '-' }}</p>
</div>
<div class="card-body">
@if (isset($formFoto['foto_lingkungan']['foto_lingkungan']))
@foreach ($formFoto['foto_lingkungan']['foto_lingkungan'][0] as $index => $item)
<div class="flex items-center justify-between mt-5">
<div class="grid gap-5">
<h2 class="text-gray-600 font-semibold text-xl">
{{ $item['name'] ?? 'Lingkungan - ' . ($index + 1) }}
</h2>
<div class="flex items-center">
<img src="{{ Storage::url($item['path']) }}" alt="Gambar {{ $index + 1 }}"
class="w-full h-auto object-cover">
</div>
</div>
</div>
@endforeach
@endif
</div>
</div>
@endif
@if (isset($formFoto['object_jaminan']))
<div class="card">
<div class="card-header bg-agi-50" id="basic_settings">
<h3 class="card-title">
Object Jaminan
</h3>
</div>
<div class="card-body">
@if (isset($formFoto['object_jaminan']))
@foreach ($formFoto['object_jaminan'] as $item)
<div class="flex items-center justify-between mt-5">
<div class="grid gap-5">
<h2 class=" font-semibold text-xl">
{{ $item['name_objek'] ?? "" }}
</h2>
<div class="flex items-center">
<img src="{{ Storage::url($item['foto_objek']) }}" alt=""
class="w-full h-auto object-cover">
</div>
</div>
</div>
@endforeach
@endif
</div>
</div>
@endif
@if (isset($formFoto['foto_lantai_unit']))
<div class="card">
<div class="card-header bg-agi-50" id="basic_settings">
<h3 class="card-title">Lantai</h3>
</div>
<div class="card-body">
@if (isset($formFoto['foto_lantai_unit']))
@foreach ($formFoto['foto_lantai_unit'] as $floorIndex => $floorPhotos)
<div class="mt-5">
@foreach ($floorPhotos as $index => $item)
@if (is_int($index) && isset($item['name'], $item['path']) && is_string($item['path']))
<div class="flex items-center justify-between mt-3">
<div class="grid gap-3">
<h3 class="text-gray-600 font-semibold text-lg">
{{ $item['name'] ?? 'Foto Lantai ' . ($floorIndex + 1) . ' - ' . ($index + 1) }}
</h3>
<div class="flex items-center ">
<img src="{{ Storage::url($item['path']) }}"
alt="Gambar {{ $floorIndex + 1 }}-{{ $index + 1 }}"
class="w-full h-auto object-cover">
</div> </div>
</div> </div>
</div> @endforeach
@endif @else
@endforeach <!-- Jika ada subkategori, tampilkan berdasarkan subkategori -->
</div> @foreach ($groupedBySubcategory as $subcategory => $subPhotos)
@endforeach <div class="mb-4">
<!-- Judul Subkategori -->
@endif <h4 class="text-gray-700 font-semibold text-lg mb-2">
</div> @if ($subcategory)
</div> {{ $subcategory }}
@endif @endif
</h4>
<div class="grid gap-5">
@foreach ($subPhotos as $index => $item)
@if (isset($formFoto['foto_basement'])) <div class="flex items-center justify-between">
<div class="card"> <div class="grid gap-5">
<div class="card-header bg-agi-50" id="basic_settings"> <h3 class="text-gray-600 font-semibold text-lg">
<h3 class="card-title"> {{ $item['name'] ?? 'Foto - ' . ($index + 1) }}
Basement </h3>
</h3> <div class="flex items-center">
</div> @if (isset($item['path']))
<div class="card-body"> <img src="{{ asset('storage/' . $item['path']) }}" alt="Gambar {{ $index + 1 }}"
<div class="flex items-center justify-between mt-5"> class="w-full h-auto object-cover rounded-md">
<div class="grid gap-5"> @else
<h2 class=" font-semibold text-xl"> <p class="text-gray-500">Gambar tidak tersedia</p>
Basemnt @endif
</h2> </div>
<div class="flex items-center"> <p class="text-gray-500 text-sm">{{ $item['description'] ?? '-' }}</p>
</div>
</div>
<img src="{{ Storage::url($formFoto['foto_basement']) }}" alt="" class="w-full h-auto object-cover"> @endforeach
</div>
</div> </div>
@endforeach
@endif
</div> </div>
</div> </div>
@endforeach
</div> @endif
</div> @endisset
@endif
@if (isset($formFoto['foto_lantai_lainnya']))
<div class="card">
<div class="card-header" id="basic_settings">
<h3 class="card-title">
Lantai Lainnya
</h3>
</div>
<div class="card-body">
@if (isset($formFoto['foto_lantai_lainnya']))
@foreach ($formFoto['foto_lantai_lainnya'] as $index => $item)
<div class="flex items-center justify-between mt-5">
<div class="grid gap-5">
<h2 class="text-gray-600 font-semibold text-xl">
{{ $item['name_lantai_lainnya'] ?? 'Lantai - ' . ($index + 1) }}
</h2>
<div class="flex items-center">
<img src="{{ Storage::url($item['foto_lantai_lainnya']) }}"
alt="Gambar {{ $index + 1 }}" class="w-full h-auto object-cover">
</div>
</div>
</div>
@endforeach
@endif
</div>
</div>
@endif
@if (isset($formFoto['pendamping']))
<div class="card">
<div class="card-header bg-agi-50" id="basic_settings">
<h3 class="card-title">
Pendamping
</h3>
</div>
<div class="card-body">
<div class="flex items-center justify-between mt-5">
<div class="grid gap-5">
<h2 class=" font-semibold text-xl">
Pendamping
</h2>
<div class="flex items-center">
<img src="{{ Storage::url($formFoto['pendamping']) }}" alt="" class="w-full h-auto object-cover">
</div>
</div>
</div>
</div>
</div>
@endif
@php @php
$fotoTypes = ['foto_gistaru', 'foto_bhumi', 'foto_argis_region', 'foto_tempat']; $fotoTypes = ['foto_gistaru', 'foto_bhumi', 'foto_argis_region', 'foto_tempat'];
if (($key = array_search('foto_tempat', $fotoTypes)) !== false) { if (($key = array_search('foto_tempat', $fotoTypes)) !== false) {
unset($fotoTypes[$key]); unset($fotoTypes[$key]);
array_unshift($fotoTypes, 'foto_tempat'); array_unshift($fotoTypes, 'foto_tempat');
} }
$adaFoto = false; $adaFoto = false;
if (isset($forminspeksi)) { if (isset($forminspeksi)) {
foreach ($fotoTypes as $type) { foreach ($fotoTypes as $type) {
$imagePath = $forminspeksi[$type] ?? null; $imagePath = $forminspeksi[$type] ?? null;
@@ -271,33 +96,33 @@ $adaFoto = false;
@endphp @endphp
@if ($adaFoto) @if ($adaFoto)
<div class="card"> <div class="card">
<div class="card-header bg-agi-50" id="basic_settings"> <div class="card-header bg-agi-50" id="basic_settings">
<h3 class="card-title"> <h3 class="card-title">
Peta Peta
</h3> </h3>
</div> </div>
<div class="card-body"> <div class="card-body">
<div> <div>
@if (isset($forminspeksi)) @if (isset($forminspeksi))
@forelse ($fotoTypes as $type) @forelse ($fotoTypes as $type)
<div class="border photo-item"> <div class="border photo-item">
@php @php
$imagePath = $forminspeksi[$type] ?? null; $imagePath = $forminspeksi[$type] ?? null;
@endphp @endphp
@if ($imagePath && file_exists(storage_path('app/public/' . $imagePath))) @if ($imagePath && file_exists(storage_path('app/public/' . $imagePath)))
<img src="{{ Storage::url($imagePath) }}" alt="{{ $type }}" <img src="{{ asset('storage/' . $imagePath) }}" alt="{{ $type }}"
class="w-full h-auto object-cover"> class="w-full h-auto object-cover">
@endif @endif
<p class="mt-2 text-sm">{{ Str::title(str_replace('_', ' ', $type)) }}</p> <p class="mt-2 text-sm">{{ Str::title(str_replace('_', ' ', $type)) }}</p>
</div> </div>
@empty @empty
<p>Tidak ada tipe foto yang tersedia</p> <p>Tidak ada tipe foto yang tersedia</p>
@endforelse @endforelse
@endif @endif
</div>
</div> </div>
</div> </div>
</div>
@endif @endif

View File

@@ -1,5 +1,5 @@
{ {
"rute_menuju_lokasi": [ "upload_foto": [
{ {
"name": "Tampak Depan Objek", "name": "Tampak Depan Objek",
"description": "terdapat jalan depan rumah", "description": "terdapat jalan depan rumah",
@@ -22,6 +22,5 @@
"updated_by": "Administrator", "updated_by": "Administrator",
"updated_at": "2025-02-05 04:38:53" "updated_at": "2025-02-05 04:38:53"
} }
], ]
"foto_lantai_unit": []
} }

View File

@@ -322,25 +322,7 @@
showConfirmButton: false, showConfirmButton: false,
timer: 1500 timer: 1500
}); });
var mockFile = { updatePhotoGallery();
name: file.name,
size: file.size || 12345,
originalPath: file.path
};
myDropzone.emit("addedfile", mockFile);
myDropzone.emit("thumbnail", mockFile, response.file.path);
myDropzone.emit("complete", mockFile);
addEditAndDeleteButtons(mockFile, {
path: response.file.path,
name: response.file.name,
description: response.file.description || '',
category: response.file.category || 'lainnya',
sub: response.file.sub || '',
param_name: paramName
});
} }
}, },
@@ -448,25 +430,25 @@
if (response.fotos && response.fotos.length) { if (response.fotos && response.fotos.length) {
response.fotos.forEach(function(foto) { response.fotos.forEach(function(foto) {
// Cek jika foto sudah ada di Dropzone // Cek jika foto sudah ada di Dropzone
if (!isFileInDropzone(foto.name)) {
var mockFile = {
name: foto.name,
size: foto.size || 12345,
originalPath: foto.path
};
myDropzone.emit("addedfile", mockFile); var mockFile = {
myDropzone.emit("thumbnail", mockFile, foto.path); name: foto.name,
myDropzone.emit("complete", mockFile); size: foto.size || 12345,
addEditAndDeleteButtons(mockFile, { originalPath: foto.path
path: foto.path, };
name: foto.name,
description: foto.description || '', myDropzone.emit("addedfile", mockFile);
category: foto.category || 'lainnya', myDropzone.emit("thumbnail", mockFile, foto.path);
sub: foto.sub || '', myDropzone.emit("complete", mockFile);
param_name: 'upload_foto' addEditAndDeleteButtons(mockFile, {
}); path: foto.path,
} name: foto.name,
description: foto.description || '',
category: foto.category || 'lainnya',
sub: foto.sub || '',
param_name: 'upload_foto'
});
}); });
} else { } else {
console.log('Tidak ada foto yang ditemukan'); console.log('Tidak ada foto yang ditemukan');
@@ -479,10 +461,7 @@
} }
function isFileInDropzone(fileName) {
let files = myDropzone.files;
return files.some(file => file.name === fileName);
}
// Inisialisasi Dropzone untuk elemen awal dengan pengecekan // Inisialisasi Dropzone untuk elemen awal dengan pengecekan
function safeInitDropzone(selector, paramName) { function safeInitDropzone(selector, paramName) {