@extends('layouts.app', ['class' => 'g-sidenav-show bg-gray-100']) {{-- section content --}} @section('content') @include('layouts.navbars.auth.topnav', ['title' => ''])
@include('components.alert')
Result {{ $title_menu }}

{{-- check result data --}} @if ($table_result) {{-- set table header --}} @foreach ($table_result as $result) @php $sAsArray = array_keys((array) $result); $i = 0; @endphp @endforeach @foreach ($sAsArray as $header) @if (substr($header, 0, 4) == 'HDN_') {{-- Hidden column: tidak tampilkan sebagai header --}} @elseif (substr($header, 0, 3) == 'IMG') @elseif (substr($header, 0, 3) == 'CDT') @elseif (substr($header, 0, 3) == 'CST') @else @endif @php $i++; @endphp @endforeach {{-- retrieve table result --}} @foreach ($table_result as $detail) @php // Collect HDN_ values to set as data-attributes on tr $hdnValues = []; foreach ((array) $detail as $k => $v) { if (substr($k, 0, 4) === 'HDN_') { $hdnValues[strtolower(substr($k, 4))] = $v; } } $hdnAttrStr = ''; foreach ($hdnValues as $hk => $hv) { $hdnAttrStr .= ' data-' . e($hk) . '="' . e($hv) . '"'; } @endphp isactive == '0' || @$detail->ISACTIVE == '0' ? 'class=not style=background-color:#ffe9ed;' : '' }} {!! $hdnAttrStr !!}> @foreach ($table_result as $result) @php $field = array_keys((array) $result); $i = 0; @endphp @endforeach @foreach ($field as $header) @php $string = $header; $img_id = ''; $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUFGHIJKLMNOPQRSTUVWXYZ'; for ($i = 0; $i < 10; $i++) { $img_id .= $characters[mt_rand(0, strlen($characters) - 1)]; } @endphp @if (substr($string, 0, 4) == 'HDN_') {{-- Hidden column: tidak render sebagai --}} @elseif (substr($string, 0, 3) == 'IMG') @elseif (substr($string, 0, 3) == 'CDT')) @elseif (substr($string, 0, 3) == 'CST') @else @endif @php $i++; @endphp @endforeach @endforeach @endif
No{{ substr($header, 4) }}{{ substr($header, 6) . '-' . substr($header, 3, 2) }}{{ substr($header, 4) }}{{ $header }}
{{ $loop->iteration }}, data sudah di data-attribute
@php $rawImages = trim((string) ($detail->$string ?? '')); $imageItems = []; if ($rawImages !== '') { $decodedImages = null; if (str_starts_with($rawImages, '[')) { $decodedImages = json_decode($rawImages, true); } if (is_array($decodedImages)) { $imageItems = $decodedImages; } else { $imagePaths = preg_split('/\s*(?:\|\||\||,)\s*/', $rawImages, -1, PREG_SPLIT_NO_EMPTY); foreach ($imagePaths as $imagePath) { $parts = explode('@@', (string) $imagePath, 2); $imageItems[] = [ 'date' => $parts[0] !== $imagePath ? trim($parts[0]) : '', 'path' => trim($parts[1] ?? $parts[0]), ]; } } } $imageItems = array_values(array_filter(array_map(function ($item) { if (is_array($item)) { return [ 'date' => trim((string) ($item['date'] ?? '')), 'path' => trim((string) ($item['path'] ?? '')), ]; } $rawItem = trim((string) $item); if ($rawItem === '') { return null; } $parts = explode('@@', $rawItem, 2); return [ 'date' => trim($parts[0] ?? ''), 'path' => trim($parts[1] ?? $parts[0]), ]; }, $imageItems))); $uniqueImageItems = []; $seenImagePaths = []; foreach ($imageItems as $imageItem) { $pathKey = $imageItem['path'] ?? ''; // skip empty, '0', 'null', or paths that are purely numeric (invalid) if ( $pathKey === '' || $pathKey === '0' || strtolower($pathKey) === 'null' || (is_numeric($pathKey) && strpos($pathKey, '/') === false) || in_array($pathKey, $seenImagePaths, true) ) { continue; } $seenImagePaths[] = $pathKey; $uniqueImageItems[] = $imageItem; } $imageItems = $uniqueImageItems; $getImageUrl = function ($path) { $normalizedPath = str_replace('\\', '/', trim((string) $path)); if ($normalizedPath === '') { return ''; } if (preg_match('/^https?:\/\//i', $normalizedPath)) { return $normalizedPath; } $normalizedPath = preg_replace('#^/?public/#', '', $normalizedPath); $normalizedPath = preg_replace('#^/?storage/#', '', $normalizedPath); return route('attachment.show', ['path' => ltrim($normalizedPath, '/')]); }; $galleryId = 'gallery_' . $img_id; $carouselId = 'carousel_' . $img_id; @endphp @if (count($imageItems) > 0)
@foreach ($imageItems as $imageIndex => $imageItem) @php $imageUrl = $getImageUrl($imageItem['path']); $isPdf = strtolower(pathinfo($imageItem['path'], PATHINFO_EXTENSION)) === 'pdf'; @endphp @if ($isPdf) PDF @else image @endif @endforeach
@else @php $rpnphdNpId = $detail->HDN_non_periodic_id ?? null; $hasPengerjaan = !empty($detail->HDN_has_pengerjaan) && (int) $detail->HDN_has_pengerjaan === 1; @endphp @if ($dmenu === 'rpnphd' && $rpnphdNpId && $hasPengerjaan)
Kosong
@else - @endif @endif
{{ $detail->$string }} {{ $detail->$string }} {{ $detail->$string }}
@if ($dmenu === 'rpnphd') {{-- Modal Upload Dokumentasi dari halaman report --}} @push('js') @endpush @endif
@if ($table_result) @else @endif
{{-- check flag js on dmenu --}} @if ($jsmenu == '1') @if (view()->exists("js.{$dmenu}")) @push('addjs') {{-- file js in folder (resources/views/js) --}} @include('js.' . $dmenu); @endpush @else @push('addjs') @endpush @endif @endif @endsection @push('js') @endpush