<?php $__env->startSection("title", env("APP_NAME") . " :: Lista de Notícias"); ?>
<?php $__env->startSection('content'); ?>

    <div class="card shadow-sm">

        <?php $headLine = "<i class='fa-solid fa-bullhorn'></i> Lista de Notícias"; ?>

        <?php echo $__env->make('components.buttons._headLineButtonsBackAdd', [
                'headLine' => __($headLine),
                'routeAdd' => 'admin.noticias.create',
                'routeAddParams' => [],
                'nameAdd' => __('Nova notícia'),
                "permission" => "GERENCIADOR_DE_NOTICIAS",
            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

        <div class="card-body pt-3">
            <div class="mb-4">
                <span class="badge bg-primary fs-6">
                    <i class="fa-solid fa-newspaper me-1"></i>
                    <?php echo e(__('Total de notícias publicadas')); ?>: <strong><?php echo e(number_format($totalNoticiasPublicadas, 0, ',', '.')); ?></strong>
                </span>
            </div>

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

            <?php
                $noticiasListQueryParams = ['page' => request()->input('page', 1)];
                foreach (['q', 'dta', 'secretaria_id', 'ano', 'categoria'] as $noticiasListKey) {
                    if (request()->filled($noticiasListKey)) {
                        $noticiasListQueryParams[$noticiasListKey] = request($noticiasListKey);
                    }
                }
            ?>

            <form method="get" action="<?php echo e(route('admin.noticias.index')); ?>" class="mb-4 mt-3">
                <div class="row g-3 mb-3">
                    <div class="col-12 col-md-6 col-lg-5">
                        <label for="admin-noticias-q" class="form-label mb-2"><?php echo e(__('Termos')); ?></label>
                        <input id="admin-noticias-q" type="text" name="q" class="form-control"
                            value="<?php echo e(request('q')); ?>" placeholder="<?php echo e(__('Título, resumo ou corpo')); ?>"
                            maxlength="255" autocomplete="off">
                    </div>
                    <div class="col-12 col-md-3 col-lg-3">
                        <label for="admin-noticias-dta" class="form-label mb-2"><?php echo e(__('Data de publicação')); ?></label>
                        <input id="admin-noticias-dta" type="date" name="dta" class="form-control"
                            value="<?php echo e(request('dta')); ?>">
                    </div>
                    <div class="col-12 col-md-3 col-lg-4">
                        <label for="admin-noticias-secretaria" class="form-label mb-2"><?php echo e(__('Secretaria')); ?></label>
                        <select id="admin-noticias-secretaria" name="secretaria_id" class="form-select">
                            <option value=""><?php echo e(__('Todas')); ?></option>
                            <?php $__currentLoopData = $secretariasFiltro; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $secretaria): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($secretaria->id); ?>" <?php if(request('secretaria_id') === $secretaria->id): echo 'selected'; endif; ?>>
                                    <?php echo e($secretaria->name); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </div>
                <div class="row g-3 align-items-end">
                    <div class="col-12 col-sm-4 col-md-3 col-lg-2">
                        <label for="admin-noticias-ano" class="form-label mb-2"><?php echo e(__('Ano')); ?></label>
                        <select id="admin-noticias-ano" name="ano" class="form-select">
                            <option value=""><?php echo e(__('Todos')); ?></option>
                            <?php $__currentLoopData = $anos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ano): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($ano); ?>" <?php if((string) request('ano') === (string) $ano): echo 'selected'; endif; ?>><?php echo e($ano); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="col-12 col-sm-8 col-md-5 col-lg-5">
                        <label for="admin-noticias-categoria" class="form-label mb-2"><?php echo e(__('Categoria')); ?></label>
                        <select id="admin-noticias-categoria" name="categoria" class="form-select">
                            <option value=""><?php echo e(__('Todas')); ?></option>
                            <?php $__currentLoopData = $categorias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $categoriaEnum): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($categoriaEnum->name); ?>" <?php if(request('categoria') === $categoriaEnum->name): echo 'selected'; endif; ?>>
                                    <?php echo e(__($categoriaEnum->value)); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="col-12 col-md-4 col-lg-5 d-flex flex-wrap gap-2">
                        <button type="submit" class="btn btn-outline-success">
                            <i class="fa-solid fa-magnifying-glass me-1" aria-hidden="true"></i><?php echo e(__('Filtrar')); ?>

                        </button>
                        <a href="<?php echo e(route('admin.noticias.index')); ?>" class="btn btn-outline-secondary"><?php echo e(__('Limpar')); ?></a>
                    </div>
                </div>
            </form>

            <?php
                $pathSystem = $_SERVER['DOCUMENT_ROOT'] . "/";
                $angraDefault = asset("/pmar/assets/img/angra-default.png");
            ?>

            <?php if (isset($component)) { $__componentOriginal0650541a119648223455610148c86d0b = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal0650541a119648223455610148c86d0b = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.tables._table','data' => ['thead' => ['#', 'Publicada em', 'Título', 'Descrição', 'Fixar', 'Status', 'Ações'],'pagination' => $noticias->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(['#', 'Publicada em', 'Título', 'Descrição', 'Fixar', 'Status', 'Ações']),'pagination' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($noticias->links())]); ?>
                 <?php $__env->slot('body', null, []); ?> 

                    <?php $index = 0; ?>
                        <?php $__currentLoopData = $noticias; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $noticia): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <tr>
                            <td style="width:150px">
                                <?php echo $__env->make('components.tables._openPhoto', [
                                        'asset' => file_exists( $pathSystem . $noticia->featuredPhoto ) ? $noticia->featuredPhoto : $angraDefault,
                                        'alt' => $noticia->title,
                                        'title' => $noticia->title,
                                        'text' => 'Visualizar foto',
                                    ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                            </td>
                            <td><?php echo e(date("d/m/Y H:m:s", strtotime($noticia->created_at))); ?> </td>
                            <td> <?php echo e($noticia->title); ?> </td>
                            <td><?php echo Str::limit($noticia->summary, 50); ?> </td>
                            <td class="text-center align-middle">
                                <?php echo $__env->make('components.buttons._status', [
                                                "index" => $index,
                                                "route" => "admin.noticias.fix",
                                                "id" => $noticia->id,
                                                "status" => $noticia->fix,
                                                "permission" => "GERENCIADOR_DE_NOTICIAS",
                                                "queryParams" => $noticiasListQueryParams,
                                            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                            </td>
                            <td class="text-center align-middle">
                                <?php echo $__env->make('components.buttons._status', [
                                                "index" => $index,
                                                "route" => "admin.noticias.status",
                                                "id" => $noticia->id,
                                                "status" => $noticia->status,
                                                "permission" => "GERENCIADOR_DE_NOTICIAS",
                                                "queryParams" => $noticiasListQueryParams,
                                            ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                            </td>
                            <td>
                                <div class="d-flex gap-2 justify-content-center">
                                    <?php echo $__env->make('components.buttons._editButton', [
                                                    "route" => "admin.noticias.edit",
                                                    "id" => $noticia->id,
                                                    "title" => "Editar",
                                                    "fontawesome" => null,
                                                    "permission" => "GERENCIADOR_DE_NOTICIAS",
                                                ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

                                    <?php echo $__env->make('components.buttons._deleteButton', [
                                                    "message" => __("* Esta notícia será excluída e esta ação não poderá ser desfeita, deseja continuar??"),
                                                    "route" => "admin.noticias.destroy",
                                                    "id" => $noticia->id,
                                                    "title" => "Excluir",
                                                    "fontawesome" => null,
                                                    "permission" => "GERENCIADOR_DE_NOTICIAS",
                                                    "queryParams" => $noticiasListQueryParams,
                                                ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                            </td>
                        </tr>
                        <?php $index++; ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                 <?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/noticias/index.blade.php ENDPATH**/ ?>