<?php require dirname(__DIR__) . '/layouts/app.php'; ?>

<section class="page-heading">
    <div>
        <p class="eyebrow">Maintenance</p>
        <h1>Synchronisation des statuts biens</h1>
    </div>
    <form method="post" action="<?= url('/maintenance/property-statuses/sync') ?>">
        <input type="hidden" name="_token" value="<?= csrf_token() ?>">
        <button type="submit">Synchroniser</button>
    </form>
</section>

<?php if (!empty($notice)): ?>
    <div class="alert alert-success"><?= e($notice) ?></div>
<?php endif; ?>

<section class="work-panel">
    <h2>Regle appliquee</h2>
    <p>
        Un bien devient occupe s'il a une reservation active aujourd'hui. Il redevient disponible
        lorsqu'il n'a plus de reservation active. Les biens en maintenance ne sont pas modifies.
    </p>
</section>

<section class="table-panel backup-table">
    <table>
        <thead>
            <tr>
                <th>Bien</th>
                <th>Type</th>
                <th>Ville</th>
                <th>Statut</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($properties as $property): ?>
                <tr>
                    <td><?= e($property['title']) ?></td>
                    <td><?= e(property_types()[$property['type']] ?? $property['type']) ?></td>
                    <td><?= e($property['city']) ?></td>
                    <td>
                        <span class="status-pill status-<?= e($property['status']) ?>">
                            <?= e(property_statuses()[$property['status']] ?? $property['status']) ?>
                        </span>
                    </td>
                </tr>
            <?php endforeach; ?>
            <?php if (empty($properties)): ?>
                <tr>
                    <td colspan="4">Aucun bien trouve.</td>
                </tr>
            <?php endif; ?>
        </tbody>
    </table>
</section>

<?php require dirname(__DIR__) . '/layouts/app_footer.php'; ?>
