<?php $__env->startSection("title", env("APP_NAME") . " :: Lista de Páginas HTML"); ?>
<?php $__env->startSection('content'); ?>

    <div class="card shadow-sm">
        <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
            <h5 class="my-2"><?php echo e(__('Lista de Páginas HTML')); ?></h5>
        </div>
        <div class="card-body">
            <?php if(session('success')): ?>
                <div class="alert alert-success"><?php echo e(session('success')); ?></div>
            <?php endif; ?>

            <?php if(session('error')): ?>
                <div class="alert alert-danger"><?php echo e(session('error')); ?></div>
            <?php endif; ?>

            <h6 class="card-subtitle mb-2 text-body-secondary">
                <?php if(auth()->user()->getPermissaoDetalhes("GERENCIADOR_DE_PAGINAS_HTML")['adicionar']): ?>
                    <?php echo $__env->make('components.buttons._newButton', ['url' => 'admin.htmls.create', 'text' => __('Nova Página HTML')], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                <?php endif; ?>
            </h6>

            <div class="mb-3 alert alert-light">
                <div class="mb-3 bg-gray border-0 rounded-4 shadow-sm p-3">
                    <div class="tab-pane fade show active" id="termos" role="tabpanel" aria-labelledby="termos-tab">
                        <form class="d-flex" method="get" action="<?php echo e(route('admin.htmls.index')); ?>">
                            <input
                                type="text"
                                class="form-control me-2 border-0"
                                name="q"
                                value="<?php echo e(request()->input('q')); ?>"
                                placeholder="<?php echo e(__('Buscar na publicação')); ?>"
                                aria-label="<?php echo e(__('Pesquisar')); ?>"
                            >
                            <button class="btn btn-success text-secondary fw-bold px-4 py-2 rounded-4" type="submit">
                                <?php echo e(__('Buscar')); ?>

                            </button>
                        </form>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-bordered table-hover table-striped align-middle text-center">
                    <?php echo $__env->make('components.tables._thead', ['thead' => [__('Data de criação'), __('Título'), __('Pertence a'), __('Exibição'), __('Link'), __('Menu Personalizado'), __('Visível na Lista de Serviços'), __('Status')]], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                    <?php
                        $index = 0;
                    ?>
                    <?php $__empty_1 = true; $__currentLoopData = $htmls; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $html): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td> <?php echo e(date("d/m/Y H:i:s", strtotime($html->created_at))); ?> </td>
                            <td>
                                <?php echo e($html->title); ?>

                                <div class="d-flex gap-2 justify-content-center mt-2">
                                    <?php echo $__env->make('components.buttons._editButton', [
                                        "route" => "admin.htmls.edit",
                                        "id" => $html->id,
                                        "title" => __('Editar'),
                                        "fontawesome" => null,
                                        "permission" => "GERENCIADOR_DE_PAGINAS_HTML",
                                    ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                    <?php echo $__env->make('components.buttons._deleteButton', [
                                        "message" => __("* Esta página HTML será excluída e esta ação não poderá ser desfeita, deseja continuar?"),
                                        "route" => "admin.htmls.destroy",
                                        "id" => $html->id,
                                        "title" => __('Excluir'),
                                        "fontawesome" => null,
                                        "permission" => "GERENCIADOR_DE_PAGINAS_HTML",
                                    ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                                </div>
                            </td>
                            <td>
                                <?php if(empty($html->structure_id)): ?>
                                    ---
                                <?php else: ?>
                                    <?php echo e(optional($html->pertence)->name); ?>

                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if(($html->display_context ?? 'BOTH') === 'ORG_PAGE'): ?>
                                    <?php echo e(__('Somente no órgão')); ?>

                                <?php elseif(($html->display_context ?? 'BOTH') === 'INDEPENDENT'): ?>
                                    <?php echo e(__('Somente independente')); ?>

                                <?php else: ?>
                                    <?php echo e(__('Órgão + independente')); ?>

                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if(($html->display_context ?? 'BOTH') !== 'ORG_PAGE'): ?>
                                    <a class="text-dark text-decoration-none d-inline fs-5"
                                        href='<?php echo e(url("servicos/" . $html->slug)); ?>' target="_blank" alt="<?php echo e($html->title); ?>"
                                        title="<?php echo e($html->title); ?>">
                                        <i class="fa-solid fa-link"></i>
                                    </a>
                                <?php else: ?>
                                    ---
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if(auth()->user()->getPermissaoDetalhes("GERENCIADOR_DE_PAGINAS_HTML")['editar']): ?>
                                    <form id="<?php echo e('checkCustomMenu_' . $index); ?>" class="fix d-flex flex-column align-items-center gap-2"
                                        action="<?php echo e(route("admin.htmls.customMenu", $html->id)); ?>" method="post">
                                        <?php echo csrf_field(); ?>
                                        <?php if(!empty($filterParams)): ?>
                                            <?php $__currentLoopData = $filterParams; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php if($value !== null && $value !== ''): ?>
                                                    <input type="hidden" name="<?php echo e($key); ?>" value="<?php echo e($value); ?>">
                                                <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php endif; ?>
                                        <input type="hidden" name="page" value="<?php echo e(request()->input('page', 1)); ?>">
                                        <div class="form-check form-switch">
                                            <input type="hidden" name="custom_menu_enabled" value="0">
                                            <input class="form-check-input" type="checkbox" <?php echo e($html->custom_menu_enabled ? 'checked' : ''); ?>

                                                onclick="var f=this.form; f.querySelector('input[name=custom_menu_enabled]').value=this.checked?'1':'0'; f.submit();">
                                            <label class="form-check-label small"><?php echo e($html->custom_menu_enabled ? __('Ativado') : __('Desativado')); ?></label>
                                        </div>
                                        <a href="<?php echo e(route('admin.htmls.menu.index', $html->id)); ?>" class="btn btn-sm btn-outline-primary">
                                            <i class="fa-solid fa-list"></i> <?php echo e(__('Editar Menu Personalizado')); ?>

                                        </a>
                                    </form>
                                <?php else: ?>
                                    <?php echo e($html->custom_menu_enabled ? __('Ativado') : __('Desativado')); ?>

                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if(auth()->user()->getPermissaoDetalhes("GERENCIADOR_DE_PAGINAS_HTML")['editar']): ?>
                                    <form id="<?php echo e('checkVisibility_' . $index); ?>" class="fix d-flex justify-content-center"
                                        action="<?php echo e(route("admin.htmls.visibility", $html->id)); ?>" method="post">
                                        <?php echo csrf_field(); ?>
                                        <?php if(!empty($filterParams)): ?>
                                            <?php $__currentLoopData = $filterParams; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php if($value !== null && $value !== ''): ?>
                                                    <input type="hidden" name="<?php echo e($key); ?>" value="<?php echo e($value); ?>">
                                                <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php endif; ?>
                                        <input type="hidden" name="page" value="<?php echo e(request()->input('page', 1)); ?>">
                                        <?php if($html->visibility == "ATIVADO"): ?>
                                            <div class="form-check form-switch">
                                                <input type="hidden" name="checkVisibility" value="DESATIVADO">
                                                <input class="form-check-input" type="checkbox" checked
                                                    onclick="document.getElementById('checkVisibility_<?php echo e($index); ?>').submit()">
                                            </div>
                                        <?php else: ?>
                                            <div class="form-check form-switch">
                                                <input type="hidden" name="checkVisibility" value="ATIVADO">
                                                <input class="form-check-input" type="checkbox"
                                                    onclick="document.getElementById('checkVisibility_<?php echo e($index); ?>').submit()">
                                            </div>
                                        <?php endif; ?>
                                    </form>
                                <?php else: ?>
                                    <?php echo e($html->visibility); ?>

                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if(auth()->user()->getPermissaoDetalhes("GERENCIADOR_DE_PAGINAS_HTML")['editar']): ?>
                                    <form id="<?php echo e('checkStatus_' . $index); ?>" class="fix d-flex justify-content-center"
                                        action="<?php echo e(route("admin.htmls.status", $html->id)); ?>" method="post">
                                        <?php echo csrf_field(); ?>
                                        <?php if(!empty($filterParams)): ?>
                                            <?php $__currentLoopData = $filterParams; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <?php if($value !== null && $value !== ''): ?>
                                                    <input type="hidden" name="<?php echo e($key); ?>" value="<?php echo e($value); ?>">
                                                <?php endif; ?>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php endif; ?>
                                        <input type="hidden" name="page" value="<?php echo e(request()->input('page', 1)); ?>">
                                        <?php if(($html->status ?? 'ATIVADO') == "ATIVADO"): ?>
                                            <div class="form-check form-switch">
                                                <input type="hidden" name="checkStatus" value="DESATIVADO">
                                                <input class="form-check-input" type="checkbox" checked
                                                    onclick="document.getElementById('checkStatus_<?php echo e($index); ?>').submit()">
                                            </div>
                                        <?php else: ?>
                                            <div class="form-check form-switch">
                                                <input type="hidden" name="checkStatus" value="ATIVADO">
                                                <input class="form-check-input" type="checkbox"
                                                    onclick="document.getElementById('checkStatus_<?php echo e($index); ?>').submit()">
                                            </div>
                                        <?php endif; ?>
                                    </form>
                                <?php else: ?>
                                    <?php echo e($html->status ?? 'ATIVADO'); ?>

                                <?php endif; ?>
                            </td>
                        </tr>
                        <?php
                            $index++;
                        ?>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="8">
                                <p><?php echo e(__('Nenhuma Página HTML encontrada.')); ?></p>
                            </td>
                        </tr>
                    <?php endif; ?>
                </table>
            </div>
            <div class="row">
                <div class="col-12 my-3">
                    <div class="d-flex justify-content-center"><?php echo $htmls->links(); ?> </div>
                </div>
            </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/htmls/index.blade.php ENDPATH**/ ?>