<?php $__env->startSection('title', 'Pagos de suscripción'); ?>

<?php $__env->startSection('content'); ?>
<div class="page-head">
    <div>
        <h1>Pagos de suscripción</h1>
        <div class="crumb"><a href="<?php echo e(route('admin.dashboard')); ?>">Panel</a> · Pagos</div>
    </div>
</div>

<div class="stats-grid" style="margin-bottom:22px; grid-template-columns:repeat(auto-fit,minmax(210px,1fr));">
    <div class="stat-card grad-violet"><div class="s-label">Total recaudado</div><div class="s-value">S/ <?php echo e(number_format($resumen['total'], 0)); ?></div><div class="s-sub"><i class="fa-solid fa-vault"></i> Histórico</div><i class="fa-solid fa-sack-dollar s-icon"></i></div>
    <div class="stat-card grad-teal"><div class="s-label">Este mes</div><div class="s-value">S/ <?php echo e(number_format($resumen['mes'], 0)); ?></div><div class="s-sub"><i class="fa-solid fa-calendar"></i> Cobrado</div><i class="fa-solid fa-money-bill-wave s-icon"></i></div>
    <div class="stat-card grad-blue"><div class="s-label">Pagos registrados</div><div class="s-value"><?php echo e($resumen['cantidad']); ?></div><div class="s-sub"><i class="fa-solid fa-receipt"></i> Transacciones</div><i class="fa-solid fa-receipt s-icon"></i></div>
</div>

<div class="charts-grid" style="grid-template-columns: 1fr 2fr;">
    <div class="panel" style="min-width:0;">
        <div class="panel-head"><h3>Registrar pago</h3></div>
        <div class="panel-body">
            <?php echo $__env->make('partials.form_errors', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
            <form method="POST" action="<?php echo e(route('admin.pagos.store')); ?>">
                <?php echo csrf_field(); ?>
                <label class="form-label">Taller *</label>
                <select name="taller_id" class="form-control" style="margin-bottom:14px;" required>
                    <option value="">Seleccionar taller...</option>
                    <?php $__currentLoopData = $talleres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $t): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($t->id); ?>"><?php echo e($t->nombre); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <label class="form-label">Monto (S/) *</label>
                <input type="number" step="0.01" name="monto" class="form-control" style="margin-bottom:14px;" min="0" required>
                <label class="form-label">Fecha de pago *</label>
                <input type="date" name="fecha_pago" class="form-control" style="margin-bottom:14px;" value="<?php echo e(now()->toDateString()); ?>" required>
                <label class="form-label">Periodo *</label>
                <select name="periodo" class="form-control" style="margin-bottom:14px;">
                    <option value="mensual">Mensual (+1 mes)</option>
                    <option value="anual">Anual (+1 año)</option>
                </select>
                <label class="form-label">Método *</label>
                <select name="metodo" class="form-control" style="margin-bottom:14px;">
                    <?php $__currentLoopData = ['transferencia'=>'Transferencia','tarjeta'=>'Tarjeta','yape'=>'Yape / Plin','efectivo'=>'Efectivo']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k=>$v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($k); ?>"><?php echo e($v); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
                <label class="form-label">Referencia</label>
                <input type="text" name="referencia" class="form-control" style="margin-bottom:18px;" placeholder="N° de operación">
                <button type="submit" class="btn btn-primary" style="width:100%;"><i class="fa-solid fa-plus"></i> Registrar y renovar</button>
            </form>
        </div>
    </div>

    <div class="panel" style="min-width:0;">
        <div class="panel-head" style="gap:12px; flex-wrap:wrap;">
            <div><h3>Historial de pagos</h3><div class="sub"><?php echo e($pagos->total()); ?> registros</div></div>
            <form method="GET" action="<?php echo e(route('admin.pagos.index')); ?>" style="display:flex; gap:10px; margin-left:auto;">
                <div class="search" style="max-width:220px;"><i class="fa-solid fa-magnifying-glass"></i><input type="text" name="q" value="<?php echo e($q); ?>" placeholder="Taller o referencia..."></div>
                <button type="submit" class="btn btn-primary" style="height:40px;">Buscar</button>
            </form>
        </div>
        <div class="table-wrap">
            <table class="tbl">
                <thead><tr><th>Fecha</th><th>Taller</th><th>Plan</th><th>Método</th><th style="text-align:right;">Monto</th><th></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>
                        <td class="cell-muted"><?php echo e(optional($p->fecha_pago)->format('d/m/Y')); ?></td>
                        <td class="cell-strong"><?php echo e($p->taller->nombre ?? '—'); ?></td>
                        <td><?php echo e($p->plan->nombre ?? '—'); ?></td>
                        <td class="cell-muted" style="text-transform:capitalize;"><?php echo e($p->metodo); ?></td>
                        <td style="text-align:right;" class="cell-strong">S/ <?php echo e(number_format($p->monto, 2)); ?></td>
                        <td style="text-align:right;">
                            <form method="POST" action="<?php echo e(route('admin.pagos.destroy', $p)); ?>" onsubmit="return confirm('¿Eliminar este pago?');">
                                <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                <button type="submit" class="ico-btn ico-danger" title="Eliminar"><i class="fa-solid fa-trash"></i></button>
                            </form>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr><td colspan="6" class="cell-muted" style="text-align:center; padding:30px;">Sin pagos registrados.</td></tr>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
        <?php echo $__env->make('partials.pager', ['paginator' => $pagos], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\SAAS\saas_taller-automotriz\resources\views/admin/pagos/index.blade.php ENDPATH**/ ?>