<?php $__env->startSection('title', 'Compras'); ?>
<?php $__env->startSection('header', 'Historial de Compras'); ?>

<?php $__env->startSection('content'); ?>
<?php $moneda = $empresaGlobal->moneda ?? 'S/'; ?>

<div class="bg-white rounded-2xl shadow-md p-5 mb-5">
    <div class="flex flex-col md:flex-row gap-3 justify-between">
        <form method="GET" class="flex-1 grid grid-cols-1 md:grid-cols-3 gap-2">
            <select name="proveedor_id" class="px-3 py-2.5 border border-slate-300 rounded-lg">
                <option value="">Todos los proveedores</option>
                <?php $__currentLoopData = $proveedores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($p->id); ?>" <?php echo e(request('proveedor_id') == $p->id ? 'selected' : ''); ?>><?php echo e($p->razon_social); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
            <input type="date" name="fecha_desde" value="<?php echo e(request('fecha_desde')); ?>" class="px-3 py-2.5 border border-slate-300 rounded-lg">
            <input type="date" name="fecha_hasta" value="<?php echo e(request('fecha_hasta')); ?>" class="px-3 py-2.5 border border-slate-300 rounded-lg">
        </form>
        <a href="<?php echo e(route('compras.create')); ?>" class="gradient-primary text-white px-5 py-2.5 rounded-lg font-semibold flex items-center gap-2"><i class="fas fa-plus"></i>Nueva Compra</a>
    </div>
</div>

<div class="bg-white rounded-2xl shadow-md overflow-hidden">
    <table class="w-full">
        <thead class="bg-slate-50 text-xs uppercase text-slate-500">
            <tr>
                <th class="text-left py-3 px-4">N° Compra</th>
                <th class="text-left py-3 px-4">Fecha</th>
                <th class="text-left py-3 px-4">Proveedor</th>
                <th class="text-left py-3 px-4">Factura</th>
                <th class="text-right py-3 px-4">Total</th>
                <th class="text-center py-3 px-4">Estado</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
        <?php $__empty_1 = true; $__currentLoopData = $compras; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr class="border-b border-slate-100 hover:bg-slate-50">
                <td class="py-3 px-4 font-mono text-sm"><?php echo e($c->numero); ?></td>
                <td class="py-3 px-4 text-sm"><?php echo e($c->fecha_compra->format('d/m/Y')); ?></td>
                <td class="py-3 px-4"><?php echo e($c->proveedor->razon_social); ?></td>
                <td class="py-3 px-4 text-sm"><?php echo e($c->numero_factura ?: '—'); ?></td>
                <td class="py-3 px-4 text-right font-bold text-emerald-600"><?php echo e($moneda); ?><?php echo e(number_format($c->total, 2)); ?></td>
                <td class="py-3 px-4 text-center"><span class="bg-green-100 text-green-700 px-2 py-1 rounded-full text-xs"><?php echo e(ucfirst($c->estado)); ?></span></td>
                <td class="py-3 px-4 text-right"><a href="<?php echo e(route('compras.show', $c->id)); ?>" class="text-blue-600 hover:bg-blue-50 p-2 rounded"><i class="fas fa-eye"></i></a></td>
            </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr><td colspan="7" class="text-center py-12 text-slate-400">Sin compras</td></tr>
        <?php endif; ?>
        </tbody>
    </table>
    <div class="p-4"><?php echo e($compras->withQueryString()->links()); ?></div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\TVP\tvp-minimarket\resources\views/compras/index.blade.php ENDPATH**/ ?>