

<?php $__env->startSection('title', 'Documents'); ?>
<?php $__env->startSection('heading', 'Documents'); ?>

<?php $__env->startSection('content'); ?>
<?php echo $__env->make('documents.top-submenu', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    <?php if (isset($component)) { $__componentOriginal53747ceb358d30c0105769f8471417f6 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal53747ceb358d30c0105769f8471417f6 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.card','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('card'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
        <div class="mb-4 flex justify-between items-center">
            <p class="text-slate-600">Uploaded documents.</p>
            <a href="<?php echo e(route('documents.create')); ?>" class="inline-flex items-center rounded-lg bg-slate-800 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700">Upload Document</a>
        </div>
        <form method="GET" action="<?php echo e(route('documents.index')); ?>" class="mb-5 flex flex-nowrap items-end gap-2 overflow-x-auto rounded-lg border border-slate-200 bg-slate-50 p-3">
            <div class="min-w-[12rem] flex-1">
                <label class="mb-1 block text-xs font-medium text-slate-500">Search</label>
                <input type="text" name="search" value="<?php echo e($filters['search'] ?? ''); ?>" placeholder="Name / number / uploader" class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
            </div>
            <div class="min-w-[9rem]">
                <label class="mb-1 block text-xs font-medium text-slate-500">Category</label>
                <select name="category" class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm js-select2">
                    <option value="">All Categories</option>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($key); ?>" <?php if(($filters['category'] ?? '') === $key): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </select>
            </div>
            <div class="min-w-[8rem]">
                <label class="mb-1 block text-xs font-medium text-slate-500">Status</label>
                <select name="status" class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm js-select2">
                    <option value="">All Status</option>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $statusOptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $status): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($status); ?>" <?php if(($filters['status'] ?? '') === $status): echo 'selected'; endif; ?>><?php echo e(ucwords(str_replace('_', ' ', $status))); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </select>
            </div>
            <div class="min-w-[8rem]">
                <label class="mb-1 block text-xs font-medium text-slate-500">Visibility</label>
                <select name="visibility" class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm js-select2">
                    <option value="">All Visibility</option>
                    <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__currentLoopData = $visibilityOptions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($key); ?>" <?php if(($filters['visibility'] ?? '') === $key): echo 'selected'; endif; ?>><?php echo e($label); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                </select>
            </div>
            <div class="min-w-[8.5rem]">
                <label class="mb-1 block text-xs font-medium text-slate-500">From</label>
                <input type="date" name="from" value="<?php echo e($filters['from'] ?? ''); ?>" class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
            </div>
            <div class="min-w-[8.5rem]">
                <label class="mb-1 block text-xs font-medium text-slate-500">To</label>
                <input type="date" name="to" value="<?php echo e($filters['to'] ?? ''); ?>" class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm">
            </div>
            <div class="flex shrink-0 gap-2 pb-px">
                <button type="submit" class="rounded-lg bg-slate-800 px-4 py-2 text-sm font-medium text-white whitespace-nowrap">Apply</button>
                <a href="<?php echo e(route('documents.index')); ?>" class="rounded-lg bg-slate-100 px-4 py-2 text-sm font-medium text-slate-700 whitespace-nowrap">Reset</a>
            </div>
        </form>
        <?php if (isset($component)) { $__componentOriginal163c8ba6efb795223894d5ffef5034f5 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal163c8ba6efb795223894d5ffef5034f5 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.table','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('table'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
             <?php $__env->slot('head', null, []); ?> 
                <tr>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Name</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Category</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Status</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Issued</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Expires</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Visibility</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Uploaded By</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Date</th>
                    <th class="px-4 py-3 text-left text-xs font-medium uppercase text-slate-500">Actions</th>
                </tr>
             <?php $__env->endSlot(); ?>
            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php $__empty_1 = true; $__currentLoopData = $documents; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $doc): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-900"><?php echo e($doc->name); ?></td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600"><?php echo e($categories[$doc->category] ?? $doc->category ?? $doc->type ?? '—'); ?></td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm">
                        <?php ($status = $doc->computed_status); ?>
                        <span class="inline-flex rounded-full px-2 py-1 text-xs font-medium
                            <?php echo e($status === 'expired' ? 'bg-rose-100 text-rose-700' : ''); ?>

                            <?php echo e($status === 'expiring_soon' ? 'bg-amber-100 text-amber-700' : ''); ?>

                            <?php echo e($status === 'archived' ? 'bg-slate-200 text-slate-700' : ''); ?>

                            <?php echo e($status === 'active' ? 'bg-emerald-100 text-emerald-700' : ''); ?>">
                            <?php echo e(ucwords(str_replace('_', ' ', $status))); ?>

                        </span>
                    </td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600"><?php echo e(optional($doc->issued_on)->format('M d, Y') ?: '—'); ?></td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600"><?php echo e(optional($doc->expires_on)->format('M d, Y') ?: '—'); ?></td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600"><?php echo e(ucfirst($doc->visibility ?? 'company')); ?></td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600"><?php echo e($doc->uploader?->name ?? '—'); ?></td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600"><?php echo e($doc->created_at?->format('M d, Y')); ?></td>
                    <td class="whitespace-nowrap px-4 py-3 text-sm text-slate-600">
                        <div class="flex items-center gap-2">
                            <a href="<?php echo e(route('documents.download', $doc)); ?>" class="btn-icon-action btn-icon-action--view" title="Download" aria-label="Download"><i class="bi bi-download"></i></a>
                            <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if(auth()->user()?->isTenantManager() || auth()->user()?->hasPermission('documents_edit') || (int) $doc->uploaded_by === (int) auth()->id()): ?>
                                <form action="<?php echo e(route('documents.destroy', ['document' => $doc, 'redirect' => request()->fullUrl()])); ?>" method="POST" onsubmit="return confirm('Delete this document?');">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="btn-icon-action btn-icon-action--delete" title="Delete" aria-label="Delete"><i class="bi bi-trash3"></i></button>
                                </form>
                            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
                        </div>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="10" class="px-4 py-8 text-center text-sm text-slate-500">No documents found for the selected filters.</td></tr>
            <?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal163c8ba6efb795223894d5ffef5034f5)): ?>
<?php $attributes = $__attributesOriginal163c8ba6efb795223894d5ffef5034f5; ?>
<?php unset($__attributesOriginal163c8ba6efb795223894d5ffef5034f5); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal163c8ba6efb795223894d5ffef5034f5)): ?>
<?php $component = $__componentOriginal163c8ba6efb795223894d5ffef5034f5; ?>
<?php unset($__componentOriginal163c8ba6efb795223894d5ffef5034f5); ?>
<?php endif; ?>
        <?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if BLOCK]><![endif]--><?php endif; ?><?php if($documents->hasPages()): ?><div class="mt-4"><?php echo e($documents->links()); ?></div><?php endif; ?><?php if(\Livewire\Mechanisms\ExtendBlade\ExtendBlade::isRenderingLivewireComponent()): ?><!--[if ENDBLOCK]><![endif]--><?php endif; ?>
     <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal53747ceb358d30c0105769f8471417f6)): ?>
<?php $attributes = $__attributesOriginal53747ceb358d30c0105769f8471417f6; ?>
<?php unset($__attributesOriginal53747ceb358d30c0105769f8471417f6); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal53747ceb358d30c0105769f8471417f6)): ?>
<?php $component = $__componentOriginal53747ceb358d30c0105769f8471417f6; ?>
<?php unset($__componentOriginal53747ceb358d30c0105769f8471417f6); ?>
<?php endif; ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/kiyohr/v2_version/resources/views/documents/index.blade.php ENDPATH**/ ?>