<?php $__env->startSection('title', env('APP_NAME') . ' :: Lista de Parques e Jardins'); ?>
<?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">
        <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center mb-3">
            <h5 class="mb-0">Lista de Parques e Jardins</h5>
            
        </div>
        <div class="card-body">
            <div class="d-flex">
                <?php echo $__env->make('components.buttons._newButton', ['url' => 'admin.parquesJardins.create', 'text' => 'Novo parques e jardins'], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
            </div>
            <form id="searchAccounts" class="d-flex mb-4 pt-4" method="get">
                <input type="hidden" name="page" value="<?php echo e(request()->input('page', 1)); ?>">
                <input type="text" class="form-control me-2" name="q" placeholder="Pesquisar parques e jardins municipal..."
                    value="<?php echo e(request()->input('q')); ?>">
                <button class="btn btn-outline-success" type="submit"><i class="fa-solid fa-magnifying-glass"></i></button>
            </form>

            <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' => ['Foto', 'Nome', 'Pertence a', 'Bairro', 'Status', 'Ações']], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                    <tbody>
                        <?php $index = 0 ?>
                        <?php $__empty_1 = true; $__currentLoopData = $parques; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $parque): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td>
                                    <img src="<?php echo e(asset($parque->foto)); ?>" alt="<?php echo e($parque->nome); ?>" class="rounded-circle"
                                        style="width: 90px; height: 90px; object-fit: cover; cursor: pointer;"
                                        data-bs-toggle="modal" data-bs-target="#modalFotoEscola<?php echo e($parque->id); ?>" />

                                    <!-- Modal exclusivo para esse paciente -->
                                    <div class="modal fade" id="modalFotoEscola<?php echo e($parque->id); ?>" tabindex="-1"
                                        aria-hidden="true">
                                        <div class="modal-dialog modal-fullscreen">
                                            <div class="modal-content bg-dark">
                                                <div class="modal-header border-0">
                                                    <button type="button" class="btn-close btn-close-white ms-auto"
                                                        data-bs-dismiss="modal" aria-label="Fechar"></button>
                                                </div>
                                                <div class="modal-body d-flex justify-content-center align-items-center">
                                                    <img src="<?php echo e(asset($parque->foto)); ?>" alt="<?php echo e($parque->nome); ?>"
                                                        class="img-fluid rounded" style="max-height: 90vh;" />
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td><?php echo e($parque->nome); ?></td>
                                <td><?php echo e($parque->pertence->name); ?></td>
                                <td><?php echo e($parque->endereco->bairro); ?></td>
                                <td>
                                    <?php
                                        $permissao = auth()->user()->getPermissaoDetalhes('GERENCIADOR_DE_PARQUES_E_JARDINS');
                                    ?>
                                    <?php if($permissao && !empty($permissao['editar']) && $permissao['editar']): ?>
                                        <form id="<?php echo e("checkStatus_" . $index); ?>" class="fix"
                                            action="<?php echo e(route("admin.parquesJardins.status", $parque->id)); ?>" method="post">
                                            <?php echo csrf_field(); ?>
                                            <input type="hidden" name="page" value="<?php echo e(request()->input('page', 1)); ?>">
                                            <?php if($parque->status == "ATIVADO"): ?>
                                                <div class="form-check form-switch d-flex justify-content-center">
                                                    <input type="hidden" name="checkStatus" value="DESATIVADO">
                                                    <input class="form-check-input" type="checkbox" checked
                                                        onclick="javascript:$('#<?php echo e("checkStatus_" . $index); ?>').submit()">
                                                </div>
                                            <?php else: ?>
                                                <div class="form-check form-switch d-flex justify-content-center">
                                                    <input type="hidden" name="checkStatus" value="ATIVADO">
                                                    <input class="form-check-input" type="checkbox"
                                                        onclick="javascript:$('#<?php echo e("checkStatus_" . $index); ?>').submit()">
                                                </div>
                                            <?php endif; ?>
                                        </form>
                                    <?php endif; ?>
                                </td>
                                <td class="text-nowrap text-center align-middle">
                                    <div class="d-flex justify-content-center flex-wrap gap-1">
                                        <a href="<?php echo e(route('admin.parquesJardins.edit', $parque->id)); ?>"
                                            class="btn btn-sm btn-warning" title="Editar"><i
                                                class="fa-solid fa-pen-to-square"></i>
                                        </a>

                                        <a href="<?php echo e(route("admin.parquesJardins.arquivos.index", $parque->id)); ?>"
                                            class="btn btn-sm btn-warning">
                                            <i class="fa-solid fa-cloud-arrow-up"></i>
                                        </a>

                                        <?php
                                            $permissao = auth()->user()->getPermissaoDetalhes('GERENCIADOR_DE_PARQUES_E_JARDINS');
                                        ?>
                                        <?php if($permissao && !empty($permissao['excluir']) && $permissao['excluir']): ?>
                                            <form class="d-inline" action="<?php echo e(route('admin.parquesJardins.destroy', $parque->id)); ?>"
                                                method="post" onsubmit="return confirmDelete(this)">
                                                <?php echo csrf_field(); ?>
                                                <?php echo method_field('delete'); ?>
                                                <input type="hidden" name="page" value="<?php echo e(request()->input('page', 1)); ?>">
                                                <input type="hidden" name="confirm"
                                                    value="<?php echo e(__('* Este parque e jardim será excluído e esta ação não poderá ser desfeita, deseja continuar?')); ?>">
                                                <button type="submit" class="btn btn-sm btn-danger" title="Excluir">
                                                    <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-muted fst-italic">* Nenhum registro encontrado!</td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>

            <div class="d-flex justify-content-center mt-4">
                <?php echo $parques->links(); ?>

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