158 lines
8.1 KiB
PHP
158 lines
8.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../includes/taxilanz.php';
|
|
app_boot();
|
|
|
|
$slug = trim((string) ($_GET['slug'] ?? ''));
|
|
$offer = $slug !== '' ? find_offer_by_slug($slug) : null;
|
|
$rideUuid = trim((string) ($_GET['ride'] ?? ''));
|
|
$ride = $rideUuid !== '' ? find_ride_by_uuid($rideUuid) : null;
|
|
|
|
if ($offer && $ride) {
|
|
$clickedKey = 'clicked_offer_' . $ride['uuid'] . '_' . $offer['id'];
|
|
if (empty($_SESSION[$clickedKey])) {
|
|
log_event('recommendation_clicked', [
|
|
'ride_id' => (int) $ride['id'],
|
|
'offer_id' => (int) $offer['id'],
|
|
'meta' => [
|
|
'offer_slug' => $offer['slug'],
|
|
'source' => 'ride-confirmed',
|
|
],
|
|
]);
|
|
$_SESSION[$clickedKey] = true;
|
|
}
|
|
}
|
|
|
|
if (!$offer) {
|
|
http_response_code(404);
|
|
render_page_start('Oferta no encontrada', 'No se encontro la oferta solicitada.', 'home');
|
|
?>
|
|
<section class="card-shell p-5 text-center">
|
|
<div class="empty-state">
|
|
<strong>La oferta ya no esta disponible.</strong>
|
|
<p class="text-secondary mb-4">Vuelve al inicio para explorar las experiencias y servicios vigentes.</p>
|
|
<a class="btn btn-app-primary" href="/">Volver al inicio</a>
|
|
</div>
|
|
</section>
|
|
<?php
|
|
render_page_end();
|
|
exit;
|
|
}
|
|
|
|
$related = related_offers($offer, 3);
|
|
$oldBooking = old_form('booking_form');
|
|
|
|
render_page_start(
|
|
$offer['title'],
|
|
excerpt_for_offer($offer),
|
|
'home'
|
|
);
|
|
?>
|
|
<section class="row g-4 mb-4">
|
|
<div class="col-12 col-lg-7">
|
|
<article class="card-shell overflow-hidden h-100">
|
|
<img src="<?= h($offer['image_url']) ?>" class="offer-hero-image" alt="<?= h($offer['title']) ?>" loading="lazy" width="1280" height="720">
|
|
<div class="p-4 p-lg-5">
|
|
<div class="offer-meta mb-3">
|
|
<span class="chip"><?= h(category_label($offer['category'])) ?></span>
|
|
<span class="text-secondary small"><?= h($offer['location_label'] ?? 'Lanzarote') ?></span>
|
|
</div>
|
|
<h1 class="section-title offer-detail-title mb-3"><?= h($offer['title']) ?></h1>
|
|
<p class="lead text-secondary mb-4"><?= h(excerpt_for_offer($offer)) ?></p>
|
|
<div class="summary-block mb-4">
|
|
<div class="summary-line"><span>Precio desde</span><strong><?= h(format_currency($offer['price_from'])) ?></strong></div>
|
|
<div class="summary-line"><span>Duracion</span><strong><?= h((string) $offer['duration_minutes']) ?> min</strong></div>
|
|
<div class="summary-line"><span>Estado</span><strong><?= $offer['available_now'] ? 'Disponible ahora' : 'Bajo demanda' ?></strong></div>
|
|
</div>
|
|
<div class="detail-card mb-0">
|
|
<span class="detail-kicker">Resumen</span>
|
|
<p class="mb-0 text-secondary"><?= h($offer['description'] ?? 'Seleccion recomendada para la fase de espera del trayecto.') ?></p>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
</div>
|
|
|
|
<div class="col-12 col-lg-5">
|
|
<div class="card-shell p-4 p-lg-5 h-100">
|
|
<div class="section-head mb-4">
|
|
<div>
|
|
<div class="eyebrow">Reserva rapida</div>
|
|
<h2 class="section-title mb-1">Confirmar interest</h2>
|
|
<p class="text-secondary mb-0">No hay pago real. Solo capturamos la reserva y generamos confirmacion para la demo.</p>
|
|
</div>
|
|
<span class="status-badge">Paso 3</span>
|
|
</div>
|
|
|
|
<?php if ($ride): ?>
|
|
<div class="notice-panel mb-4">
|
|
<strong>Recomendacion vinculada al ride</strong>
|
|
<p class="mb-0 text-secondary">Ruta activa: <?= h($ride['pickup_label']) ?> → <?= h($ride['destination_label']) ?> · ETA <?= h((string) $ride['eta_minutes']) ?> min.</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form action="/bookings/" method="post" class="row g-3" novalidate>
|
|
<input type="hidden" name="offer_id" value="<?= h((string) $offer['id']) ?>">
|
|
<input type="hidden" name="ride_uuid" value="<?= h($ride['uuid'] ?? '') ?>">
|
|
<div class="col-12">
|
|
<label class="form-label" for="customer_name">Nombre</label>
|
|
<input class="form-control form-control-app" id="customer_name" name="customer_name" type="text" value="<?= h($oldBooking['customer_name'] ?? '') ?>" required>
|
|
</div>
|
|
<div class="col-12 col-md-6">
|
|
<label class="form-label" for="customer_email">Email</label>
|
|
<input class="form-control form-control-app" id="customer_email" name="customer_email" type="email" value="<?= h($oldBooking['customer_email'] ?? '') ?>" placeholder="Opcional si dejas telefono">
|
|
</div>
|
|
<div class="col-12 col-md-6">
|
|
<label class="form-label" for="customer_phone">Telefono</label>
|
|
<input class="form-control form-control-app" id="customer_phone" name="customer_phone" type="text" value="<?= h($oldBooking['customer_phone'] ?? '') ?>" placeholder="Opcional si dejas email">
|
|
</div>
|
|
<div class="col-12 col-md-6">
|
|
<label class="form-label" for="party_size">Personas</label>
|
|
<input class="form-control form-control-app" id="party_size" name="party_size" type="number" min="1" max="12" step="1" value="<?= h((string) ($oldBooking['party_size'] ?? '2')) ?>">
|
|
</div>
|
|
<div class="col-12 col-md-6">
|
|
<label class="form-label" for="booking_for">Fecha/hora</label>
|
|
<input class="form-control form-control-app" id="booking_for" name="booking_for" type="datetime-local" value="<?= h($oldBooking['booking_for'] ?? '') ?>" data-min-now>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="form-label" for="notes">Notas</label>
|
|
<textarea class="form-control form-control-app" id="notes" name="notes" rows="4" placeholder="Alergias, punto de encuentro, preferencias...\n"><?= h($oldBooking['notes'] ?? '') ?></textarea>
|
|
</div>
|
|
<div class="col-12 d-flex flex-column flex-sm-row gap-2 pt-2">
|
|
<button class="btn btn-app-primary" type="submit">Reservar ahora</button>
|
|
<a class="btn btn-app-secondary" href="<?= $ride ? '/rides/confirmed.php?ride=' . urlencode($ride['uuid']) : '/' ?>">Volver</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="card-shell p-4 p-lg-5">
|
|
<div class="section-head mb-4">
|
|
<div>
|
|
<div class="eyebrow">Siguiente sugerencia</div>
|
|
<h2 class="section-title mb-1">Otras offers que podrian encajar</h2>
|
|
</div>
|
|
<span class="status-badge subtle">Cross-sell</span>
|
|
</div>
|
|
<div class="row g-3">
|
|
<?php foreach ($related as $item): ?>
|
|
<div class="col-12 col-md-6 col-xl-4">
|
|
<article class="offer-card h-100">
|
|
<img src="<?= h($item['image_url']) ?>" class="offer-image" alt="<?= h($item['title']) ?>" loading="lazy" width="640" height="420">
|
|
<div class="offer-body">
|
|
<div class="offer-meta">
|
|
<span class="chip"><?= h(category_label($item['category'])) ?></span>
|
|
<span class="text-secondary small"><?= h($item['location_label'] ?? 'Lanzarote') ?></span>
|
|
</div>
|
|
<h3 class="offer-title"><?= h($item['title']) ?></h3>
|
|
<p class="offer-text"><?= h(excerpt_for_offer($item)) ?></p>
|
|
<a class="btn btn-app-secondary w-100" href="/offers/?slug=<?= urlencode($item['slug']) ?><?= $ride ? '&ride=' . urlencode($ride['uuid']) : '' ?>">Explorar</a>
|
|
</div>
|
|
</article>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</section>
|
|
<?php render_page_end(); ?>
|