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

<section class="page-heading">
    <div>
        <p class="eyebrow">Fiche client</p>
        <h1><?= e($client['first_name'] . ' ' . $client['last_name']) ?></h1>
    </div>
    <div class="heading-actions">
        <?php if (Auth::can('clients.edit')): ?>
            <a class="button-link" href="<?= url('/clients/edit?id=' . $client['id']) ?>">Modifier</a>
        <?php endif; ?>
        <a class="button-link secondary" href="<?= url('/clients') ?>">Retour</a>
    </div>
</section>

<section class="detail-layout">
    <article class="detail-panel">
        <h2>Coordonnees</h2>
        <dl>
            <dt>Telephone</dt>
            <dd><?= e($client['phone'] ?: '-') ?></dd>
            <dt>Email</dt>
            <dd><?= e($client['email'] ?: '-') ?></dd>
            <dt>Identite</dt>
            <dd><?= e($client['identity_number'] ?: '-') ?></dd>
            <dt>Adresse</dt>
            <dd><?= e($client['address'] ?: '-') ?></dd>
        </dl>
        <h2>Notes</h2>
        <p><?= nl2br(e($client['notes'] ?: 'Aucune note.')) ?></p>
    </article>

    <article class="detail-panel">
        <h2>Historique des sejours</h2>
        <?php if (empty($reservations)): ?>
            <p class="muted">Aucune reservation pour ce client pour le moment.</p>
        <?php else: ?>
            <table>
                <thead>
                    <tr>
                        <th>Bien</th>
                        <th>Dates</th>
                        <th>Statut</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($reservations as $reservation): ?>
                        <tr>
                            <td><?= e($reservation['property_title'] ?: '-') ?></td>
                            <td><?= e($reservation['start_date'] . ' - ' . $reservation['end_date']) ?></td>
                            <td><?= e($reservation['status']) ?></td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        <?php endif; ?>
    </article>
</section>

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