

<?php $__env->startSection('title', 'pabellon'); ?>

<?php $__env->startSection('content_header'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<br>
<?php if (isset($component)) { $__componentOriginal0016fe8f62f0dc60d54a606049e169e1ae7c8127 = $component; } ?>
<?php $component = JeroenNoten\LaravelAdminLte\View\Components\Widget\Card::resolve(['title' => 'PABELLONES','theme' => 'dark','icon' => 'fas fa-id-card'] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? (array) $attributes->getIterator() : [])); ?>
<?php $component->withName('adminlte-card'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag && $constructor = (new ReflectionClass(JeroenNoten\LaravelAdminLte\View\Components\Widget\Card::class))->getConstructor()): ?>
<?php $attributes = $attributes->except(collect($constructor->getParameters())->map->getName()->all()); ?>
<?php endif; ?>
<?php $component->withAttributes(['class' => 'm-2']); ?>
    <div class="col-12">                                         
        <div class="row">
            <div class="col-12">
                <div class="card-body">
                    <div id="example1_wrapper" class="dataTables_wrapper dt-bootstrap4">
                        <div class="row">
                            <div class="col-sm-12">
                                <br>
                                <table id="tabla_pabellones" class="table table-hover align-middle dataTable dtr-inline collapsed" aria-describedby="example1_info">
                                    <thead class="text-center px-4 py-4 text-nowrap bg-gray">
                                        <tr >
                                            <th style="width: 5%">ID</th>
                                            <th>NOMBRE</th>
                                            <th>FILAS</th>
                                            <th>COLUMNAS</th>
                                            <!-- <th>ESTADO</th> -->
                                            <th>EDITAR</th>
                                            <th>ELIMINAR</th>
                                        </tr>
                                    </thead>
                                    <tbody class="">
                                        <?php $__currentLoopData = $pabellones; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $pabellon): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr>
                                            <td><?php echo e($pabellon->id); ?></td>
                                            <td><?php echo e($pabellon->nombre); ?></td>
                                            <td><?php echo e($pabellon->cant_filas); ?></td>
                                            <td><?php echo e($pabellon->cant_columnas); ?></td>
                                            <!-- <td><?php echo e($pabellon->estado); ?></td> -->
                                            <td>
                                                <button type="button" class="btn btn-warning btn-modificar" data-toggle="modal" data-target="#modal-edit-user" data-nombre-pabellon="<?php echo e($pabellon->nombre); ?>" data-id="<?php echo e($pabellon->id); ?>"><span class="fas fa-edit"></span></button>
                                            </td>
                                            <td>
                                                <form class="formDelete" method="post" action="<?php echo e(route('eliminarPabellon', ['pabellon' => $pabellon->id])); ?>">
                                                    <?php echo csrf_field(); ?>
                                                    <?php echo method_field('delete'); ?>
                                                    <button class="btn btn-danger" title="Desactivar" type="submit"><i class="fas fa-ban"></i></button>
                                                </form>
                                            </td>
                                        </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal0016fe8f62f0dc60d54a606049e169e1ae7c8127)): ?>
<?php $component = $__componentOriginal0016fe8f62f0dc60d54a606049e169e1ae7c8127; ?>
<?php unset($__componentOriginal0016fe8f62f0dc60d54a606049e169e1ae7c8127); ?>
<?php endif; ?>

<div class="modal fade" id="modal-edit-user">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Editar Nombre del Pabellón</h4>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
            </div>
            <div class="modal-body">
                <form id="formEdit" action="<?php echo e(route('actualizarPabellon', ['pabellon' => ':id'])); ?>" method="post">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('put'); ?>
                    <div class="form-group">
                        <label for="nombrePabellon">Nombre del Pabellón</label>
                        <input type="text" class="form-control" id="nombrePabellon" name="nombrePabellon">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
                <button type="submit" class="btn btn-primary" id="guardarCambios">Guardar Cambios</button>
            </div>
        </div>
    </div>
</div>

<?php echo $__env->make('administracion.usuario.modalCreate', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('css'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>

<script>
$(document).ready(function() {
    $('#tabla_pabellones').DataTable({
        "dom": 'Bfrtip',
        "paging": true,
        "lengthChange": true,
        "searching": true,      
        "ordering": true,
        "order": [[0, "asc"]],
        "info": true,
        "autoWidth": true,
        "responsive": true,
        "paging": true,
        "language": {"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json",
        "emptyTable": "No hay datos disponibles para mostrar",
        "info": "Mostrando START a END de TOTAL entradas",
        "infoEmpty": "Mostrando 0 a 0 de 0 entradas",
        "infoFiltered": "(filtrado de MAX entradas totales)",
        "infoPostFix": "",
        "thousands": ",",
        "lengthMenu": "Mostrar MENU entradas",
        "loadingRecords": "Cargando...",
        "processing": "Procesando...",
        "search": "Buscar:",
        "zeroRecords": "No se encontraron registros coincidentes",
        "paginate": {
            "first": "Primero",
            "last": "Último",
            "next": "Siguiente",
            "previous": "Anterior"
        },
    },
    "with-buttons": true,
    "buttons":
        [ { "extend": "excel", "text": '<i class="fas fa-file-excel"></i>', "titleAttr": "Exportar Excel", "className": "btn-success mt-1" }],
        /* 
        "ajax": {
            "url": "<?php echo e(url('/selectPabellon')); ?>",
            "type": "get",
            "dataSrc": ""
        },
        "columns": [
            { "data": 'id'},
            { "data": 'nombre'},
            { "data": 'cant_filas'},
            { "data": 'cant_columnas'},
            { "data": null,
                "render": function(data, type, row) {
                    var btnModificar = '<button type="button" class="btn btn-warning btn-modificar" data-toggle="modal" data-target="#modal-edit" data-nombre-pabellon="' + row.nombre + '"><span class="fas fa-edit"></span></button>';
                    return btnModificar.replace(":id", row.id);
                }
            },
            { "data": null,
                "render": function(data, type, row) {
                    var btnAnular = '<form class="formDelete" id="formDelete" method="post" action="<?php echo e(route("eliminarPabellon", ["pabellon" => ":id"])); ?>"> <?php echo csrf_field(); ?> <?php echo method_field("delete"); ?> <button class="btn btn-danger" title="Desactivar" type="submit"><i class="fas fa-ban"></i></button> </form>';
                    return btnAnular.replace(":id", row.id);
                }
            },
        ]*/
    });
}); 

$('#modal-edit-user').on('show.bs.modal', function (event) {
    var boton = $(event.relatedTarget); // Botón que abre el modal
    var nombrePabellon = boton.data('nombre-pabellon');
    var  id = boton.data('id');
    $('#formEdit').attr('action', $('#formEdit').attr('action').replace(':id', id));
    $('#nombrePabellon').val(nombrePabellon); // Rellenar el campo del formulario en el modal con el nombre del pabellón
});

// Evento para guardar cambios
$('#guardarCambios').click(function() {
    $('#formEdit').submit();
    $('#modal-edit-user').modal('hide');
});

$('.formDelete').submit(function(e){
    e.preventDefault();
    const swalWithBootstrapButtons = Swal.mixin({
        customClass: {
            confirmButton: 'btn btn-success m-2',
            cancelButton: 'btn btn-danger m-2'
        },
        buttonsStyling: false
    });
    swalWithBootstrapButtons.fire({
        title: '¿Estás seguro?',
        text: 'Se eliminará definitivamente',
        icon: 'warning',
        showCancelButton: true,
        confirmButtonText: 'Sí, eliminar',
        cancelButtonText: 'No, cancelar',
        reverseButtons: true
    }).then((result) => {
        if (result.isConfirmed) {
            this.submit();
        } else if (result.dismiss === Swal.DismissReason.cancel) {
            swalWithBootstrapButtons.fire(
                'Cancelado',
                'El pabellon sigue activo',
                'error'
            );
        }
    });
});
</script>

<?php if(session('user') == 'ok'): ?>
    <script>
        Swal.fire(
        'Exito!',
        'pabellon creado correctamente.',
        'success'
        )
    </script>
<?php endif; ?>

<?php if(session('user') == 'update'): ?>
    <script>
        Swal.fire(
        'Actualizado!',
        'El pabellon se actualizo correctamente.',
        'success'
        )
    </script>
<?php endif; ?>

<?php if(session('user') == 'error'): ?>
    <script>
        Swal.fire({
            icon: 'error',
            title:'Oops...',
            text: 'Fallo el proceso',
        })  
    </script>
<?php endif; ?>

<?php if(session('user') == 'delete'): ?>
    <script>
        Swal.fire(
        'Eliminado!',
        'El pabellon se elimino correctamente.',
        'success'
        )
    </script>
<?php endif; ?>

<?php if(session('user') == 'empty'): ?>
    <script>
        Swal.fire({
            icon: 'warning',
            title:'Oops...',
            text: 'Ingrese datos solicitados',
        })
    </script>
<?php endif; ?>

<?php if(session('user') == 'reset'): ?>
    <script>
        Swal.fire(
        'Restablecido!',
        'La contraseña se restablecio correctamente.',
        'success'
        )
    </script>
<?php endif; ?>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\cementerio\resources\views/administracion/pabellon/index.blade.php ENDPATH**/ ?>