<?php $__env->startSection('title', env('APP_NAME') . ' :: ' . __('Atas')); ?>

<?php $__env->startSection('content'); ?>
    <?php echo $__env->make('errors.messageFlash', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <div class="card shadow-sm">
        <?php $headLine = "<i class='fa-solid fa-file-signature'></i> " . __('Atas'); ?>
        <?php echo $__env->make('components.buttons._headLineButtonsBackAdd', [
            'headLine' => __($headLine),
            'routeBack' => 'admin.dashboard',
            'routeBackParams' => [],
            'nameBack' => __('Voltar'),
            'routeAdd' => 'admin.atas.create',
            'routeAddParams' => request()->only(\App\Http\Resources\AtaResource::ADMIN_FILTER_KEYS),
            'nameAdd' => __('Nova ata'),
            'permission' => 'GERENCIADOR_DE_ATAS',
        ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

        <div class="card-body">
            <form method="get" class="row g-3 mb-3">
                <div class="col-12 col-lg-4">
                    <label class="form-label"><?php echo e(__('Busca geral')); ?></label>
                    <input type="text" class="form-control" name="q" value="<?php echo e(request('q')); ?>"
                           placeholder="<?php echo e(__('Número, objeto ou processo')); ?>">
                </div>
                <div class="col-12 col-md-6 col-lg-2">
                    <label class="form-label"><?php echo e(__('Nº da ata')); ?></label>
                    <input type="text" class="form-control" name="nr_ata" value="<?php echo e(request('nr_ata')); ?>"
                           placeholder="<?php echo e(__('Ex.: 012/2026')); ?>">
                </div>
                <div class="col-12 col-md-6 col-lg-2">
                    <label class="form-label"><?php echo e(__('Nº do processo')); ?></label>
                    <input type="text" class="form-control" name="nr_processo" value="<?php echo e(request('nr_processo')); ?>"
                           placeholder="<?php echo e(__('Ex.: 2026.001234')); ?>">
                </div>
                <div class="col-12 col-md-6 col-lg-2">
                    <label class="form-label"><?php echo e(__('Data')); ?></label>
                    <input type="date" class="form-control" name="dt_data_ata" value="<?php echo e(request('dt_data_ata')); ?>">
                </div>
                <div class="col-12 col-md-6 col-lg-2">
                    <label class="form-label"><?php echo e(__('Secretarias')); ?></label>
                    <select class="form-select" name="id_secretaria_ata">
                        <option value=""><?php echo e(__('Todas')); ?></option>
                        <?php $__currentLoopData = $secretarias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $secretaria): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($secretaria->id); ?>" <?php if((string) request('id_secretaria_ata') === (string) $secretaria->id): echo 'selected'; endif; ?>>
                                <?php echo e($secretaria->name); ?>

                            </option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div class="col-12 d-flex justify-content-end gap-2">
                    <a href="<?php echo e(route('admin.atas.index')); ?>" class="btn btn-outline-secondary px-4"><?php echo e(__('Limpar')); ?></a>
                    <button class="btn btn-success px-4" type="submit"><?php echo e(__('Filtrar')); ?></button>
                </div>
            </form>

            <?php if (isset($component)) { $__componentOriginal0650541a119648223455610148c86d0b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal0650541a119648223455610148c86d0b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.tables._table','data' => ['thead' => ['#', __('Número'), __('Objeto'), __('Processo'), __('Licitação'), __('Secretaria'), __('Data'), __('Ações')],'pagination' => $atas->links()]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('tables._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(['thead' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute(['#', __('Número'), __('Objeto'), __('Processo'), __('Licitação'), __('Secretaria'), __('Data'), __('Ações')]),'pagination' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($atas->links())]); ?>
                 <?php $__env->slot('body', null, []); ?> 
                    <?php $index = $atas->firstItem(); ?>
                    <?php $__empty_1 = true; $__currentLoopData = $atas; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ata): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($index); ?></td>
                            <td><?php echo e($ata->nr_ata); ?></td>
                            <td><?php echo e($ata->ds_objeto); ?></td>
                            <td><?php echo e($ata->nr_processo); ?></td>
                            <td><?php echo e($ata->licitacao->nr_licitacao ?? '-'); ?></td>
                            <td>
                                <?php echo e($ata->secretariasAtas->isNotEmpty()
                                        ? $ata->secretariasAtas->pluck('name')->implode(', ')
                                        : ($ata->secretaria->name ?? '-')); ?>

                            </td>
                            <td><?php echo e(\Carbon\Carbon::parse($ata->dt_data_ata)->format('d/m/Y')); ?></td>
                            <td>
                                <div class="d-flex justify-content-center gap-2">
                                    <?php if(auth()->user()->getPermissaoDetalhes('GERENCIADOR_DE_ATAS')['editar']): ?>
                                        <a class="btn btn-sm btn-warning"
                                           href="<?php echo e(route('admin.atas.edit', [$ata->id_ata] + request()->only(\App\Http\Resources\AtaResource::ADMIN_FILTER_KEYS))); ?>">
                                            <i class="fa-solid fa-pen-to-square"></i>
                                        </a>
                                    <?php endif; ?>
                                    <?php if(auth()->user()->getPermissaoDetalhes('GERENCIADOR_DE_ATAS')['excluir']): ?>
                                        <form class="d-inline" action="<?php echo e(route('admin.atas.destroy', $ata->id_ata)); ?>" method="post" onsubmit="return confirmDelete(this)">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('delete'); ?>
                                            <?php $__currentLoopData = request()->only(\App\Http\Resources\AtaResource::ADMIN_FILTER_KEYS); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php if(is_array($value)): ?>
                                                    <?php $__currentLoopData = $value; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                        <input type="hidden" name="<?php echo e($key); ?>[]" value="<?php echo e($item); ?>">
                                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                <?php else: ?>
                                                    <input type="hidden" name="<?php echo e($key); ?>" value="<?php echo e($value); ?>">
                                                <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <input type="hidden" name="confirm" value="<?php echo e(__('* Este registro será excluído e esta ação não poderá ser desfeita, deseja continuar?')); ?>">
                                            <button type="submit" class="btn btn-sm btn-danger">
                                                <i class="fa-solid fa-trash"></i>
                                            </button>
                                        </form>
                                    <?php endif; ?>
                                </div>
                            </td>
                        </tr>
                        <?php $index++; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="8" class="text-center"><?php echo e(__('Nenhum registro encontrado.')); ?></td>
                        </tr>
                    <?php endif; ?>
                 <?php $__env->endSlot(); ?>
             <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal0650541a119648223455610148c86d0b)): ?>
<?php $attributes = $__attributesOriginal0650541a119648223455610148c86d0b; ?>
<?php unset($__attributesOriginal0650541a119648223455610148c86d0b); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal0650541a119648223455610148c86d0b)): ?>
<?php $component = $__componentOriginal0650541a119648223455610148c86d0b; ?>
<?php unset($__componentOriginal0650541a119648223455610148c86d0b); ?>
<?php endif; ?>
        </div>
    </div>
<?php $__env->stopSection(); ?>


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