39038-vm/index.php
2026-03-08 05:41:10 +00:00

285 lines
18 KiB
PHP

<?php
declare(strict_types=1);
require_once __DIR__ . '/includes/layout.php';
ensure_schema();
$stats = [
'shipments' => 0,
'offers' => 0,
'confirmed' => 0,
];
try {
$pdo = db();
$stats['shipments'] = (int) $pdo->query("SELECT COUNT(*) FROM shipments")->fetchColumn();
$stats['offers'] = (int) $pdo->query("SELECT COUNT(*) FROM shipments WHERE offer_price IS NOT NULL")->fetchColumn();
$stats['confirmed'] = (int) $pdo->query("SELECT COUNT(*) FROM shipments WHERE status IN ('confirmed','in_transit','delivered')")->fetchColumn();
} catch (Throwable $e) {
// Keep the landing page stable even if DB is unavailable.
}
$recentShipments = [];
try {
$stmt = db()->query("SELECT * FROM shipments ORDER BY created_at DESC LIMIT 5");
$recentShipments = $stmt->fetchAll();
} catch (Throwable $e) {
$recentShipments = [];
}
render_header(t('app_name'), 'home');
try {
$stmt = db()->query("SELECT * FROM landing_sections WHERE is_active = 1 ORDER BY section_order ASC, id ASC");
$landingSections = $stmt->fetchAll();
foreach ($landingSections as $sec):
if ($sec['section_type'] === 'hero'):
?>
<div class="hero-section mb-5">
<div class="row g-0">
<div class="col-lg-6 d-flex flex-column justify-content-center">
<div class="hero-content">
<span class="badge bg-primary bg-opacity-10 text-primary mb-3 px-3 py-2 fs-6 rounded-pill">
<?= e(t('hero_tagline')) ?>
</span>
<h1 class="display-5 fw-bold mb-4" style="line-height: 1.2;">
<?= e($sec['title'] ?: t('hero_title')) ?>
</h1>
<p class="fs-5 text-muted mb-5">
<?= e($sec['subtitle'] ?: t('hero_subtitle')) ?>
</p>
<div class="d-flex flex-column flex-sm-row gap-3">
<a class="btn btn-primary btn-lg shadow-sm" href="<?= e(url_with_lang('register.php', ['role' => 'shipper'])) ?>">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-box-seam me-2" viewBox="0 0 16 16">
<path d="M8.186 1.113a.5.5 0 0 0-.372 0L1.846 3.5l2.404.961L10.404 2zm3.564 1.426L5.596 5 8 5.961 14.154 3.5zm3.25 1.7-6.5 2.6v7.922l6.5-2.6V4.24zM7.5 14.762V6.84L1 4.239v7.923zM7.443.184a1.5 1.5 0 0 1 1.114 0l7.129 2.852A.5.5 0 0 1 16 3.5v8.662a1 1 0 0 1-.629.928l-7.185 2.874a.5.5 0 0 1-.372 0L.63 13.09a1 1 0 0 1-.63-.928V3.5a.5.5 0 0 1 .314-.464z"/>
</svg>
<?= e(t('register_shipper')) ?>
</a>
<a class="btn btn-outline-primary btn-lg bg-white shadow-sm" href="<?= e(url_with_lang('register.php', ['role' => 'truck_owner'])) ?>">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-truck me-2" viewBox="0 0 16 16">
<path d="M0 3.5A1.5 1.5 0 0 1 1.5 2h9A1.5 1.5 0 0 1 12 3.5V5h1.02a1.5 1.5 0 0 1 1.17.563l1.481 1.85a1.5 1.5 0 0 1 .329.938V10.5a1.5 1.5 0 0 1-1.5 1.5H14a2 2 0 1 1-4 0H5a2 2 0 1 1-3.998-.085A1.5 1.5 0 0 1 0 10.5v-7zm1.294 7.456A1.999 1.999 0 0 1 4.732 11h5.536a2.01 2.01 0 0 1 .732-.732V3.5a.5.5 0 0 0-.5-.5h-9a.5.5 0 0 0-.5.5v7a.5.5 0 0 0 .294.456zM12 10a2 2 0 0 1 1.732 1h.768a.5.5 0 0 0 .5-.5V8.35a.5.5 0 0 0-.11-.312l-1.48-1.85A.5.5 0 0 0 13.02 6H12v4zm-9 1a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm9 0a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"/>
</svg>
<?= e(t('register_owner')) ?>
</a>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="hero-img-container" style="background-image: url('<?= $sec['image_path'] ? e($sec['image_path']) : 'assets/images/hero_trucks.jpg' ?>');"></div>
</div>
</div>
</div>
<?php elseif ($sec['section_type'] === 'stats'): ?>
<div class="row mb-5 g-4">
<?php if ($sec['title']): ?>
<div class="col-12 text-center mb-3"><h2 class="display-6 fw-bold"><?= e($sec['title']) ?></h2></div>
<?php endif; ?>
<div class="col-md-4">
<div class="stat-card">
<div class="fs-4"><?= e($stats['shipments']) ?>+</div>
<div class="text-muted fw-semibold mt-1"><?= e(t('stats_shipments')) ?></div>
</div>
</div>
<div class="col-md-4">
<div class="stat-card">
<div class="fs-4"><?= e($stats['offers']) ?>+</div>
<div class="text-muted fw-semibold mt-1"><?= e(t('stats_offers')) ?></div>
</div>
</div>
<div class="col-md-4">
<div class="stat-card">
<div class="fs-4"><?= e($stats['confirmed']) ?>+</div>
<div class="text-muted fw-semibold mt-1"><?= e(t('stats_confirmed')) ?></div>
</div>
</div>
</div>
<?php elseif ($sec['section_type'] === 'features'): ?>
<section class="mb-5">
<div class="text-center mb-5">
<h2 class="display-6 fw-bold mb-3"><?= e($sec['title'] ?: t('why_choose_us')) ?></h2>
<p class="text-muted fs-5 mx-auto" style="max-width: 600px;"><?= e($sec['subtitle'] ?: t('motivation_phrase')) ?></p>
</div>
<div class="row g-4">
<div class="col-md-4">
<div class="panel p-4 h-100 text-center border-0 shadow-sm">
<div class="feature-icon mx-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-lightning-charge" viewBox="0 0 16 16"><path d="M11.251.068a.5.5 0 0 1 .227.58L9.677 6.5H13a.5.5 0 0 1 .364.843l-8 8.5a.5.5 0 0 1-.842-.49L6.323 9.5H3a.5.5 0 0 1-.364-.843l8-8.5a.5.5 0 0 1 .615-.09zM4.157 8.5H7a.5.5 0 0 1 .478.647L6.11 13.59l5.732-6.09H9a.5.5 0 0 1-.478-.647L9.89 2.41 4.157 8.5z"/></svg>
</div>
<h4 class="fw-bold mb-3"><?= e(t('feature_1_title')) ?></h4>
<p class="text-muted mb-0"><?= e(t('feature_1_desc')) ?></p>
</div>
</div>
<div class="col-md-4">
<div class="panel p-4 h-100 text-center border-0 shadow-sm">
<div class="feature-icon mx-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-shield-check" viewBox="0 0 16 16"><path d="M5.338 1.59a61.44 61.44 0 0 0-2.837.856.481.481 0 0 0-.328.39c-.554 4.157.726 7.19 2.253 9.188a10.725 10.725 0 0 0 2.287 2.233c.346.244.652.42.893.533.12.057.218.095.293.118a.55.55 0 0 0 .101.025.615.615 0 0 0 .1-.025c.076-.023.174-.061.294-.118.24-.113.547-.29.893-.533a10.726 10.726 0 0 0 2.287-2.233c1.527-1.997 2.807-5.031 2.253-9.188a.48.48 0 0 0-.328-.39c-.651-.213-1.75-.56-2.837-.855C9.552 1.29 8.531 1.067 8 1.067c-.53 0-1.552.223-2.662.524zM5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.775 11.775 0 0 1-2.517 2.453 7.159 7.159 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7.158 7.158 0 0 1-1.048-.625 11.777 11.777 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 62.456 62.456 0 0 1 5.072.56z"/><path d="M10.854 5.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 7.793l2.646-2.647a.5.5 0 0 1 .708 0z"/></svg>
</div>
<h4 class="fw-bold mb-3"><?= e(t('feature_2_title')) ?></h4>
<p class="text-muted mb-0"><?= e(t('feature_2_desc')) ?></p>
</div>
</div>
<div class="col-md-4">
<div class="panel p-4 h-100 text-center border-0 shadow-sm">
<div class="feature-icon mx-auto">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-people" viewBox="0 0 16 16"><path d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1h8Zm-7.978-1A.261.261 0 0 1 7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002a.274.274 0 0 1-.014.002H7.022ZM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM6.936 9.28a5.88 5.88 0 0 0-1.23-.247A7.35 7.35 0 0 0 5 9c-4 0-5 3-5 4 0 .667.333 1 1 1h4.216A2.238 2.238 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816ZM4.92 10A5.493 5.493 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275ZM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0Zm3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4Z"/></svg>
</div>
<h4 class="fw-bold mb-3"><?= e(t('feature_3_title')) ?></h4>
<p class="text-muted mb-0"><?= e(t('feature_3_desc')) ?></p>
</div>
</div>
</div>
</section>
<?php elseif ($sec['section_type'] === 'workflow'): ?>
<section class="mb-5">
<div class="row g-4 align-items-center">
<div class="col-md-6 order-md-2">
<img src="<?= $sec['image_path'] ? e($sec['image_path']) : 'assets/images/workflow_trucks.jpg' ?>" alt="Logistics" class="img-fluid rounded-4 shadow-sm" style="width: 100%; object-fit: cover; height: 350px;">
</div>
<div class="col-md-6 order-md-1">
<div class="p-lg-4">
<h2 class="display-6 fw-bold mb-4"><?= e($sec['title'] ?: t('section_workflow')) ?></h2>
<div class="d-flex mb-4">
<div class="flex-shrink-0">
<div class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center fs-5 fw-bold" style="width: 45px; height: 45px;">1</div>
</div>
<div class="ms-3">
<h5 class="fw-bold mb-1"><?= e(t('step_post')) ?></h5>
<p class="text-muted mb-0"><?= e(t('marketing_desc_1')) ?></p>
</div>
</div>
<div class="d-flex mb-4">
<div class="flex-shrink-0">
<div class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center fs-5 fw-bold" style="width: 45px; height: 45px;">2</div>
</div>
<div class="ms-3">
<h5 class="fw-bold mb-1"><?= e(t('step_offer')) ?></h5>
<p class="text-muted mb-0"><?= e(t('marketing_desc_2')) ?></p>
</div>
</div>
<div class="d-flex">
<div class="flex-shrink-0">
<div class="bg-primary text-white rounded-circle d-flex align-items-center justify-content-center fs-5 fw-bold" style="width: 45px; height: 45px;">3</div>
</div>
<div class="ms-3">
<h5 class="fw-bold mb-1"><?= e(t('step_confirm')) ?></h5>
<p class="text-muted mb-0"><?= e(t('step_confirm_desc')) ?></p>
</div>
</div>
</div>
</div>
</div>
</section>
<?php elseif ($sec['section_type'] === 'recent_shipments'): ?>
<?php if ($recentShipments): ?>
<section class="panel p-4 mb-5">
<div class="d-flex justify-content-between align-items-center mb-4">
<h2 class="section-title mb-0"><?= e($sec['title'] ?: t('recent_shipments')) ?></h2>
<a class="btn btn-outline-primary btn-sm rounded-pill px-3" href="<?= e(url_with_lang('register.php', ['role' => 'shipper'])) ?>"><?= e(t('cta_shipper')) ?></a>
</div>
<div class="table-responsive">
<table class="table align-middle mb-0">
<thead>
<tr>
<th><?= e(t('shipper_company')) ?></th>
<th><?= e(t('origin')) ?></th>
<th><?= e(t('destination')) ?></th>
<th><?= e(t('status')) ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($recentShipments as $row): ?>
<tr>
<td class="fw-semibold"><?= e($row['shipper_company']) ?></td>
<td>
<div class="d-flex align-items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" class="bi bi-geo-alt me-2 text-muted" viewBox="0 0 16 16"><path d="M12.166 8.94c-.524 1.062-1.234 2.12-1.96 3.07A31.493 31.493 0 0 1 8 14.58a31.481 31.481 0 0 1-2.206-2.57c-.726-.95-1.436-2.008-1.96-3.07C3.304 7.867 3 6.862 3 6a5 5 0 0 1 10 0c0 .862-.305 1.867-.834 2.94zM8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10z"/><path d="M8 8a2 2 0 1 1 0-4 2 2 0 0 1 0 4zm0 1a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"/></svg>
<?= e($row['origin_city']) ?>
</div>
</td>
<td>
<div class="d-flex align-items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" class="bi bi-geo-alt-fill me-2 text-primary" viewBox="0 0 16 16"><path d="M8 16s6-5.686 6-10A6 6 0 0 0 2 6c0 4.314 6 10 6 10zm0-7a3 3 0 1 1 0-6 3 3 0 0 1 0 6z"/></svg>
<?= e($row['destination_city']) ?>
</div>
</td>
<td><span class="badge-status <?= e($row['status']) ?>"><?= e(status_label($row['status'])) ?></span></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</section>
<?php endif; ?>
<?php elseif ($sec['section_type'] === 'faq'): ?>
<section class="mb-5 text-center">
<div class="panel p-5 border-0 shadow-sm rounded-4" style="background-color: #f8f9fa;">
<h2 class="display-6 fw-bold mb-3"><?= e($sec['title'] ?: t('faq_title')) ?></h2>
<p class="text-muted fs-5 mb-4 mx-auto" style="max-width: 600px;"><?= e($sec['subtitle'] ?: t('faq_subtitle')) ?></p>
<a href="<?= e(url_with_lang('faq.php')) ?>" class="btn btn-primary btn-lg px-4 rounded-pill shadow-sm">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" class="bi bi-question-circle me-2" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/><path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/></svg><?= e(t('view_faq')) ?>
</a>
</div>
</section>
<?php elseif ($sec['section_type'] === 'motivation'): ?>
<div class="motivation-box mb-5" <?php if ($sec['image_path']) { echo 'style="background-image: url(' . e($sec['image_path']) . '); background-size: cover; background-position: center;"'; } ?>>
<h3 class="display-6 fw-bold mb-3"><?= e($sec['title'] ?: t('motivation_title')) ?></h3>
<p class="fs-5 text-white-50 mb-4 mx-auto" style="max-width: 600px;"><?= e($sec['subtitle'] ?: t('motivation_subtitle')) ?></p>
<div class="d-flex flex-wrap justify-content-center gap-3">
<a class="btn btn-light btn-lg px-4 text-primary fw-bold" href="<?= e(url_with_lang('register.php', ['role' => 'shipper'])) ?>"><?= e(t('register_shipper')) ?></a>
<a class="btn btn-outline-light btn-lg px-4 fw-bold" href="<?= e(url_with_lang('register.php', ['role' => 'truck_owner'])) ?>"><?= e(t('register_owner')) ?></a>
</div>
</div>
<?php elseif ($sec['section_type'] === 'custom'): ?>
<section class="mb-5">
<?php if ($sec['layout'] === 'center'): ?>
<div class="panel p-5 border-0 shadow-sm rounded-4 text-center" style="background-color: #f8f9fa;">
<?php if ($sec['image_path']): ?>
<img src="<?= e($sec['image_path']) ?>" alt="" class="img-fluid mb-4 rounded-4 shadow-sm" style="max-height: 300px; object-fit: cover;">
<?php endif; ?>
<h2 class="display-6 fw-bold mb-3"><?= e($sec['title']) ?></h2>
<?php if ($sec['subtitle']): ?>
<p class="text-muted fs-5 mb-4 mx-auto" style="max-width: 600px;"><?= e($sec['subtitle']) ?></p>
<?php endif; ?>
<?php if ($sec['content']): ?>
<div class="mb-4 text-start mx-auto" style="max-width: 800px;"><?= $sec['content'] ?></div>
<?php endif; ?>
<?php if ($sec['button_text']): ?>
<a href="<?= e(url_with_lang($sec['button_link'] ?: '#')) ?>" class="btn btn-primary btn-lg px-4 rounded-pill shadow-sm"><?= e($sec['button_text']) ?></a>
<?php endif; ?>
</div>
<?php else: ?>
<div class="row g-4 align-items-center">
<div class="col-md-6 <?= $sec['layout'] === 'text_right' ? 'order-md-1' : 'order-md-2' ?>">
<?php if ($sec['image_path']): ?>
<img src="<?= e($sec['image_path']) ?>" alt="" class="img-fluid rounded-4 shadow-sm" style="width: 100%; object-fit: cover; max-height: 400px;">
<?php endif; ?>
</div>
<div class="col-md-6 <?= $sec['layout'] === 'text_right' ? 'order-md-2' : 'order-md-1' ?>">
<div class="p-lg-4">
<h2 class="display-6 fw-bold mb-4"><?= e($sec['title']) ?></h2>
<?php if ($sec['subtitle']): ?>
<h5 class="fw-bold mb-3 text-muted"><?= e($sec['subtitle']) ?></h5>
<?php endif; ?>
<?php if ($sec['content']): ?>
<div class="mb-4"><?= $sec['content'] ?></div>
<?php endif; ?>
<?php if ($sec['button_text']): ?>
<a href="<?= e(url_with_lang($sec['button_link'] ?: '#')) ?>" class="btn btn-primary btn-lg px-4 rounded-pill shadow-sm"><?= e($sec['button_text']) ?></a>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
</section>
<?php endif; ?>
<?php
endforeach;
} catch (Throwable $e) {}
?>
<?php render_footer(); ?>