<?php $__env->startSection('content'); ?>
<div class="bg-body-light">
    <div class="content content-full">
        <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center py-2">
            <div class="flex-grow-1">
                <h1 class="h3 fw-bold mb-2">
                    <i class="fa fa-receipt text-primary me-2"></i>Pagos de Trámites
                </h1>
                <h2 class="fs-base lh-base fw-medium text-muted mb-0">
                    Búsqueda y listado de recibos por gestión documental.
                </h2>
            </div>
        </div>
    </div>
</div>

<div class="content">
    
    <?php if(session('success')): ?>
        <div class="alert alert-success d-flex align-items-center mb-4" role="alert">
            <div class="flex-shrink-0">
                <i class="fa fa-fw fa-check"></i>
            </div>
            <div class="flex-grow-1 ms-3">
                <p class="mb-0"><?php echo e(session('success')); ?></p>
            </div>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    <?php endif; ?>

    
    <div class="block block-rounded block-bordered shadow-sm">
        <div class="block-content block-content-full bg-body-extra-light">
            <form method="GET" action="<?php echo e(route('pagos-tramites.index')); ?>">
                <div class="row g-2 align-items-end">
                    <div class="col-md-3">
                        <label class="form-label fs-xs text-uppercase fw-bold text-muted">Urbanización</label>
                        <select name="urb" id="selUrb" class="form-select form-select-alt fs-sm">
                            <option value="0">--- Todas ---</option>
                            <?php $__currentLoopData = $urbanizaciones; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($u->id); ?>" <?php echo e($urb == $u->id ? 'selected' : ''); ?>>
                                    <?php echo e($u->id); ?>. <?php echo e($u->nombre); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>

                    <div class="col-md-2">
                        <label class="form-label fs-xs text-uppercase fw-bold text-muted">Distrito</label>
                        <select name="dis" id="selDis" class="form-select form-select-alt fs-sm">
                            <option value="0">--- Todos ---</option>
                            <?php $__currentLoopData = $distritos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $d): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($d->id); ?>" <?php echo e($dis == $d->id ? 'selected' : ''); ?>>
                                    <?php echo e($d->nombre); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>

                    <div class="col-md-1">
                        <label class="form-label fs-xs text-uppercase fw-bold text-muted">Mz.</label>
                        <select name="manzano" id="selMan" class="form-select form-select-alt fs-sm">
                            <option value="">—</option>
                            <?php $__currentLoopData = $manzanos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option value="<?php echo e($m); ?>" <?php echo e($manzano == $m ? 'selected' : ''); ?>><?php echo e($m); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>

                    <div class="col-md-2">
                        <label class="form-label fs-xs text-uppercase fw-bold text-muted">Cód. Cliente</label>
                        <input type="text" class="form-control form-control-alt fs-sm" 
                               name="cliente" value="<?php echo e($cliente); ?>" placeholder="ID Cliente" inputmode="numeric">
                    </div>

                    <div class="col-md-4 d-flex gap-2">
                        <button type="submit" class="btn btn-primary w-100">
                            <i class="fa fa-search me-1"></i> Buscar
                        </button>
                        <a href="<?php echo e(route('pagos-tramites.index')); ?>" class="btn btn-alt-secondary" title="Limpiar filtros">
                            <i class="fa fa-sync-alt"></i>
                        </a>
                    </div>
                </div>
            </form>
        </div>
    </div>

    
    <div class="block block-rounded shadow-sm overflow-hidden">
        <div class="block-content p-0">
            <div class="table-responsive">
                <table class="table table-vcenter table-hover table-striped mb-0 fs-sm">
                    <thead>
                        <tr class="bg-body-dark text-uppercase fs-xs">
                            <th class="text-center" style="width: 100px;">N° Rec.</th>
                            <th>Cliente</th>
                            <th>Urbanización</th>
                            <th>Distrito</th>
                            <th class="text-center" style="width: 80px;">Mzno</th>
                            <th class="text-center" style="width: 80px;">Lote</th>
                            <th class="text-center" style="width: 180px;">Concepto</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $pagos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr style="cursor:pointer" onclick="window.location='<?php echo e(route('pagos-tramites.show', $p->id)); ?>'">
                            <td class="text-center fw-bold text-primary">
                                #<?php echo e($p->id); ?>

                            </td>
                            <td class="fw-semibold text-dark">
                                <?php echo e($p->nom_cliente ?? 'Desconocido'); ?>

                            </td>
                            <td><?php echo e($p->nom_urb); ?></td>
                            <td><?php echo e($p->nom_dis); ?></td>
                            <td class="text-center fw-bold"><?php echo e($p->manzano); ?></td>
                            <td class="text-center fw-bold"><?php echo e($p->lote); ?></td>
                            <td class="text-center">
                                <span class="badge rounded-pill bg-alt-secondary text-dark border border-2 w-100 py-2">
                                    <?php echo e(\App\Models\PagoTramite::tipoTexto((int)$p->tipo)); ?>

                                </span>
                            </td>
                        </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="7" class="text-center py-5 text-muted">
                                <i class="fa fa-receipt fa-2x mb-2 opacity-25"></i><br>
                                No hay pagos que cumplan los criterios de búsqueda.
                            </td>
                        </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>
        </div>
        <?php if($pagos->hasPages()): ?>
            <div class="block-content block-content-full block-content-sm bg-body-light border-top">
                <?php echo e($pagos->links()); ?>

            </div>
        <?php endif; ?>
    </div>
</div>

<style>
    .bg-alt-secondary { background-color: rgba(200, 200, 200, 0.15); }
    .table-hover tbody tr:hover { background-color: rgba(6, 101, 208, 0.05) !important; transition: 0.2s; }
</style>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
document.getElementById('selUrb').addEventListener('change', async function () {
    const selDis = document.getElementById('selDis');
    const selMan = document.getElementById('selMan');
    selDis.innerHTML = '<option value="0">--- Todos ---</option>';
    selMan.innerHTML = '<option value="">— —</option>';
    if (this.value == 0) return;
    const data = await fetch(`<?php echo e(url('pagos-tramites/distritos')); ?>/${this.value}`).then(r => r.json());
    data.forEach(d => selDis.innerHTML += `<option value="${d.id}">${d.nombre}</option>`);
});

document.getElementById('selDis').addEventListener('change', async function () {
    const selMan = document.getElementById('selMan');
    selMan.innerHTML = '<option value="">— —</option>';
    if (this.value == 0) return;
    const data = await fetch(`<?php echo e(url('pagos-tramites/manzanos')); ?>/${this.value}`).then(r => r.json());
    data.forEach(m => selMan.innerHTML += `<option value="${m}">${m}</option>`);
});
</script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/proyect-laravel/cosmos-app/resources/views/pagos_tramites/index.blade.php ENDPATH**/ ?>