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): // Determine correct language for dynamic content $isAr = ($lang ?? 'en') === 'ar'; $title = ($isAr && !empty($sec['title_ar'])) ? $sec['title_ar'] : $sec['title']; $subtitle = ($isAr && !empty($sec['subtitle_ar'])) ? $sec['subtitle_ar'] : $sec['subtitle']; $content = ($isAr && !empty($sec['content_ar'])) ? $sec['content_ar'] : $sec['content']; $button_text = ($isAr && !empty($sec['button_text_ar'])) ? $sec['button_text_ar'] : $sec['button_text']; if ($sec['section_type'] === 'hero'): ?>
= e($subtitle ?: t('hero_subtitle')) ?>
= e($subtitle ?: t('motivation_phrase')) ?>
= e(t('feature_1_desc')) ?>
= e(t('feature_2_desc')) ?>
= e(t('feature_3_desc')) ?>
= e(t('marketing_desc_1')) ?>
= e(t('marketing_desc_2')) ?>
= e(t('step_confirm_desc')) ?>
| = e(t('shipper_company')) ?> | = e(t('origin')) ?> | = e(t('destination')) ?> | = e(t('status')) ?> |
|---|---|---|---|
| = e($row['shipper_company']) ?> |
= e($row['origin_city']) ?>
|
= e($row['destination_city']) ?>
|
= e(status_label($row['status'])) ?> |
= e($subtitle ?: t('motivation_subtitle')) ?>