135 lines
5.4 KiB
PHP
135 lines
5.4 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');
|
|
?>
|
|
|
|
<section class="hero-card mb-4">
|
|
<div class="row align-items-center g-4">
|
|
<div class="col-lg-7">
|
|
<p class="text-uppercase small fw-semibold text-muted mb-2"><?= e(t('hero_tagline')) ?></p>
|
|
<h1 class="display-6 fw-semibold"><?= e(t('hero_title')) ?></h1>
|
|
<p class="muted mt-3"><?= e(t('hero_subtitle')) ?></p>
|
|
<div class="d-flex flex-wrap gap-2 mt-4">
|
|
<a class="btn btn-primary" href="<?= e(url_with_lang('shipper_dashboard.php')) ?>"><?= e(t('cta_shipper')) ?></a>
|
|
<a class="btn btn-outline-dark" href="<?= e(url_with_lang('truck_owner_dashboard.php')) ?>"><?= e(t('cta_owner')) ?></a>
|
|
<a class="btn btn-outline-dark" href="<?= e(url_with_lang('admin_dashboard.php')) ?>"><?= e(t('cta_admin')) ?></a>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-5">
|
|
<div class="row g-3">
|
|
<div class="col-12">
|
|
<div class="stat-card">
|
|
<div class="small text-muted"><?= e(t('stats_shipments')) ?></div>
|
|
<div class="fs-4 fw-semibold"><?= e($stats['shipments']) ?></div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="stat-card">
|
|
<div class="small text-muted"><?= e(t('stats_offers')) ?></div>
|
|
<div class="fs-5 fw-semibold"><?= e($stats['offers']) ?></div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="stat-card">
|
|
<div class="small text-muted"><?= e(t('stats_confirmed')) ?></div>
|
|
<div class="fs-5 fw-semibold"><?= e($stats['confirmed']) ?></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="mb-4">
|
|
<h2 class="section-title"><?= e(t('section_workflow')) ?></h2>
|
|
<div class="row g-3">
|
|
<div class="col-md-4">
|
|
<div class="panel p-3 h-100">
|
|
<div class="fw-semibold mb-1">1</div>
|
|
<p class="muted mb-0"><?= e(t('step_post')) ?></p>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="panel p-3 h-100">
|
|
<div class="fw-semibold mb-1">2</div>
|
|
<p class="muted mb-0"><?= e(t('step_offer')) ?></p>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="panel p-3 h-100">
|
|
<div class="fw-semibold mb-1">3</div>
|
|
<p class="muted mb-0"><?= e(t('step_confirm')) ?></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="panel p-3">
|
|
<div class="d-flex justify-content-between align-items-center mb-2">
|
|
<h2 class="section-title mb-0"><?= e(t('recent_shipments')) ?></h2>
|
|
<a class="small text-decoration-none" href="<?= e(url_with_lang('shipper_dashboard.php')) ?>"><?= e(t('cta_shipper')) ?></a>
|
|
</div>
|
|
<?php if (!$recentShipments): ?>
|
|
<div class="text-muted"><?= e(t('no_shipments')) ?></div>
|
|
<?php else: ?>
|
|
<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>
|
|
<th><?= e(t('actions')) ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($recentShipments as $row): ?>
|
|
<tr>
|
|
<td><?= e($row['shipper_company']) ?></td>
|
|
<td><?= e($row['origin_city']) ?></td>
|
|
<td><?= e($row['destination_city']) ?></td>
|
|
<td><span class="badge-status <?= e($row['status']) ?>"><?= e(status_label($row['status'])) ?></span></td>
|
|
<td>
|
|
<a class="btn btn-sm btn-outline-dark" href="<?= e(url_with_lang('shipment_detail.php', ['id' => $row['id']])) ?>">
|
|
<?= e(t('view')) ?>
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
</section>
|
|
|
|
<?php render_footer(); ?>
|