<?php $__env->startSection('title', env('APP_NAME') . ' :: ' . __('Arquivos da Licitação/Procedimento')); ?>

<?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-folder-open'></i> " . __('Arquivos do Registro'); ?>
        <?php echo $__env->make('components.buttons._headLineButtonsBackAdd', [
            'headLine' => __($headLine),
            'routeBack' => 'admin.licitacoesProcedimentos.index',
            'routeBackParams' => request()->only(['ano', 'tipo_processo', 'tipo', 'status', 'nr_processo', 'page']),
            'nameBack' => __('Voltar'),
            'permission' => 'GERENCIADOR_DE_LICITACOES_E_PROCEDIMENTOS',
        ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

        <div class="card-body">
            <form method="post" action="<?php echo e(route('admin.licitacoesProcedimentos.uploads.store', [$registro->id] + request()->only(['ano', 'tipo_processo', 'tipo', 'status', 'nr_processo', 'page']))); ?>" enctype="multipart/form-data" class="mb-4">
                <?php echo csrf_field(); ?>
                <?php $__currentLoopData = ['ano', 'tipo_processo', 'tipo', 'status', 'nr_processo', 'page']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $filterKey): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if(request()->filled($filterKey)): ?>
                        <input type="hidden" name="<?php echo e($filterKey); ?>" value="<?php echo e(request($filterKey)); ?>">
                    <?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                <div class="row g-2 align-items-end">
                    <div class="col-md-8">
                        <label class="form-label"><?php echo e(__('Novo arquivo')); ?></label>
                        <input type="file" name="uploads[]" class="form-control" accept=".pdf,.mp4,application/pdf,video/mp4" multiple>
                    </div>
                    <div class="col-md-4">
                        <label class="form-label"><?php echo e(__('Legenda')); ?></label>
                        <input type="text" name="uploads_legendas[]" maxlength="100" class="form-control">
                    </div>
                </div>
                <div class="mt-3">
                    <button class="btn btn-success" type="submit"><?php echo e(__('Adicionar arquivo')); ?></button>
                </div>
            </form>

            <div class="table-responsive mt-3">
                <table class="table table-sm table-striped table-bordered align-middle">
                    <?php echo $__env->make('components.tables._thead', ['thead' => [__('Arquivo'), __('Legenda'), __('Cliques'), __('Ações')]], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $registro->uploads; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $upload): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td><?php echo e(basename($upload->ds_arquivo)); ?></td>
                                <td>
                                    <form method="post" action="<?php echo e(route('admin.licitacoesProcedimentos.uploads.update', [$registro->id, $upload->id] + request()->only(['ano', 'tipo_processo', 'tipo', 'status', 'nr_processo', 'page']))); ?>" enctype="multipart/form-data" class="row g-2">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('put'); ?>
                                        <?php $__currentLoopData = ['ano', 'tipo_processo', 'tipo', 'status', 'nr_processo', 'page']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $filterKey): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php if(request()->filled($filterKey)): ?>
                                                <input type="hidden" name="<?php echo e($filterKey); ?>" value="<?php echo e(request($filterKey)); ?>">
                                            <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <div class="col-md-5">
                                            <input type="text" name="ds_legenda" maxlength="100" class="form-control form-control-sm" value="<?php echo e($upload->ds_legenda); ?>">
                                        </div>
                                        <div class="col-md-4">
                                            <input type="file" name="arquivo" class="form-control form-control-sm" accept=".pdf,.mp4,application/pdf,video/mp4">
                                        </div>
                                        <div class="col-md-3 d-flex gap-1">
                                            <button type="submit" class="btn btn-sm btn-warning"><?php echo e(__('Salvar')); ?></button>
                                            <a class="btn btn-sm btn-primary" href="<?php echo e(route('admin.licitacoesProcedimentos.uploads.download', [$registro->id, $upload->id])); ?>">
                                                <i class="fa-solid fa-download"></i>
                                            </a>
                                        </div>
                                    </form>
                                </td>
                                <td><?php echo e($upload->qt_cliques); ?></td>
                                <td class="text-center">
                                    <form class="d-inline" action="<?php echo e(route('admin.licitacoesProcedimentos.uploads.destroy', [$registro->id, $upload->id])); ?>" method="post" onsubmit="return confirmDelete(this)">
                                        <?php echo csrf_field(); ?>
                                        <?php echo method_field('delete'); ?>
                                        <input type="hidden" name="confirm" value="<?php echo e(__('* Este upload será removido e esta ação não poderá ser desfeita, deseja continuar?')); ?>">
                                        <?php $__currentLoopData = ['ano', 'tipo_processo', 'tipo', 'status', 'nr_processo', 'page']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $filterKey): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <?php if(request()->filled($filterKey)): ?>
                                                <input type="hidden" name="<?php echo e($filterKey); ?>" value="<?php echo e(request($filterKey)); ?>">
                                            <?php endif; ?>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <button type="submit" class="btn btn-sm btn-danger">
                                            <i class="fa-solid fa-trash"></i>
                                        </button>
                                    </form>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="4" class="text-center"><?php echo e(__('Nenhum arquivo vinculado.')); ?></td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </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/licitacoesProcedimentos/uploads.blade.php ENDPATH**/ ?>