<?php
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/includes/functions.php';

expirePendingOrders();
$result = confirmOrderByToken($_GET['token'] ?? '');
$pageTitle = 'Bestellung bestätigen';

include __DIR__ . '/includes/header.php';
?>

<h2>Bestellung bestätigen</h2>

<?php if ($result['success']): ?>
    <div class="alert alert-success">
        <p>Die Bestellung wurde bestätigt und an <?php echo escape(SITE_DEPARTMENT_NAME); ?> weitergeleitet.</p>
    </div>
    <div class="panel">
        <p><strong>Bestellnummer:</strong> <span class="order-highlight"><?php echo escape($result['order']['id']); ?></span></p>
    </div>
<?php else: ?>
    <div class="alert alert-error">
        <p><?php echo escape($result['message']); ?></p>
    </div>
<?php endif; ?>

<a href="index.php" class="btn">Zur Startseite</a>

<?php include __DIR__ . '/includes/footer.php'; ?>
