<?php require dirname(__DIR__) . '/layouts/app.php'; ?>
<section class="page-heading"><div><p class="eyebrow">Location longue duree</p><h1>Paiements loyers</h1></div><a class="button-link" href="<?= url('/long-rentals/payments/create') ?>">Ajouter</a></section>
<?php require __DIR__ . '/nav.php'; ?>
<?php if (!empty($notice)): ?><div class="alert alert-success"><?= e($notice) ?></div><?php endif; ?>
<section class="stat-grid compact-stats"><article class="stat-card"><span>Loyers encaisses</span><strong><?= number_format($summary['paid'], 2, ',', ' ') ?></strong></article><article class="stat-card"><span>Montants restants</span><strong><?= number_format($summary['remaining'], 2, ',', ' ') ?></strong></article></section>
<form class="filter-panel reservation-filter" method="get"><label>Du <input type="date" name="from" value="<?= e($from) ?>"></label><label>Au <input type="date" name="to" value="<?= e($to) ?>"></label><button>Filtrer</button></form>
<section class="table-panel"><table><thead><tr><th>Mois</th><th>Locataire</th><th>Bien</th><th>Loyer</th><th>Paye</th><th>Restant</th><th>Statut</th><th>Actions</th></tr></thead><tbody><?php foreach ($payments as $payment): ?><tr><td><?= e($payment['paid_month']) ?></td><td><?= e($payment['tenant_name']) ?></td><td><?= e($payment['property_title']) ?></td><td><?= number_format((float) $payment['due_amount'], 2, ',', ' ') ?></td><td><?= number_format((float) $payment['amount_paid'], 2, ',', ' ') ?></td><td><?= number_format((float) $payment['amount_remaining'], 2, ',', ' ') ?></td><td><?= e(long_payment_statuses()[$payment['status']] ?? $payment['status']) ?></td><td class="actions"><a href="<?= url('/long-rentals/payments/edit?id=' . $payment['id']) ?>">Modifier</a><form method="post" action="<?= url('/long-rentals/payments/delete') ?>" onsubmit="return confirm('Supprimer ce paiement ?');"><input type="hidden" name="_token" value="<?= csrf_token() ?>"><input type="hidden" name="id" value="<?= (int) $payment['id'] ?>"><button class="link-danger">Supprimer</button></form></td></tr><?php endforeach; ?><?php if (!$payments): ?><tr><td colspan="8">Aucun paiement.</td></tr><?php endif; ?></tbody></table></section>
<?php require dirname(__DIR__) . '/partials/pagination.php'; ?>
<?php require dirname(__DIR__) . '/layouts/app_footer.php'; ?>
