39080-vm/staff_checkin.php
Flatlogic Bot a60c7b17bb booking
2026-03-10 08:55:05 +00:00

116 lines
4.2 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/bootstrap.php';
$projectName = $_SERVER['PROJECT_NAME'] ?? 'CineReserve';
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
$message = '';
$booking = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$code = trim($_POST['booking_code'] ?? '');
if ($code === '') {
$message = 'Enter a booking code to check in.';
} else {
$pdo = db();
$stmt = $pdo->prepare(
"SELECT b.*, s.show_time, m.title
FROM bookings b
JOIN shows s ON s.id = b.show_id
JOIN movies m ON m.id = s.movie_id
WHERE b.booking_code = ?"
);
$stmt->execute([$code]);
$booking = $stmt->fetch();
if (!$booking) {
$message = 'No booking found for that code.';
} elseif ($booking['checked_in']) {
$message = 'Guest already checked in.';
} else {
$update = $pdo->prepare("UPDATE bookings SET checked_in = 1, checked_in_at = NOW() WHERE id = ?");
$update->execute([$booking['id']]);
$message = 'Check-in successful for ' . $booking['customer_name'] . '.';
$booking['checked_in'] = 1;
}
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><?= h($projectName) ?> — Staff check-in</title>
<?php if ($projectDescription): ?>
<meta name="description" content="<?= h($projectDescription) ?>" />
<meta property="og:description" content="<?= h($projectDescription) ?>" />
<meta property="twitter:description" content="<?= h($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<meta property="og:image" content="<?= h($projectImageUrl) ?>" />
<meta property="twitter:image" content="<?= h($projectImageUrl) ?>" />
<?php endif; ?>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time(); ?>">
</head>
<body>
<div class="app-shell">
<nav class="navbar navbar-light">
<div class="container">
<a class="navbar-brand fw-semibold" href="/"> <?= h($projectName) ?></a>
<a class="btn btn-outline-dark btn-sm" href="/">Back to dashboard</a>
</div>
</nav>
<main class="container my-4">
<div class="row g-4">
<div class="col-lg-5">
<div class="surface">
<h1 class="h5 mb-3">Staff check-in</h1>
<form method="post">
<div class="mb-3">
<label class="form-label">Booking code</label>
<input class="form-control" name="booking_code" placeholder="Enter or scan code">
</div>
<button class="btn btn-primary w-100" type="submit">Confirm check-in</button>
</form>
<?php if ($message): ?>
<div class="alert alert-light border mt-3 mb-0"><?= h($message) ?></div>
<?php endif; ?>
</div>
</div>
<div class="col-lg-7">
<div class="surface">
<h2 class="h6">Latest scan result</h2>
<?php if (!$booking): ?>
<p class="text-muted small mb-0">Scan a ticket to see details here.</p>
<?php else: ?>
<div class="d-flex justify-content-between">
<div>
<div class="text-muted small">Guest</div>
<div class="fw-semibold"><?= h($booking['customer_name']) ?></div>
<div class="text-muted small"><?= h($booking['customer_email']) ?></div>
</div>
<div>
<div class="text-muted small">Movie</div>
<div class="fw-semibold"><?= h($booking['title']) ?></div>
<div class="text-muted small"><?= h(date('M d, H:i', strtotime($booking['show_time']))) ?></div>
</div>
<div>
<div class="text-muted small">Seats</div>
<div class="fw-semibold"><?= h($booking['seats']) ?></div>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</main>
</div>
</body>
</html>