39038-vm/includes/layout.php
2026-03-07 17:29:29 +00:00

170 lines
9.9 KiB
PHP

<?php
require_once __DIR__ . '/app.php';
function render_header(string $title, string $active = ''): void
{
global $lang, $dir;
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
$toggleLang = $lang === 'ar' ? 'en' : 'ar';
$toggleLabel = $lang === 'ar' ? 'EN' : 'AR';
?>
<!doctype html>
<html lang="<?= e($lang) ?>" dir="<?= e($dir) ?>">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><?= e($title) ?></title>
<?php if ($projectDescription): ?>
<meta name="description" content="<?= e($projectDescription) ?>" />
<meta property="og:description" content="<?= e($projectDescription) ?>" />
<meta property="twitter:description" content="<?= e($projectDescription) ?>" />
<?php endif; ?>
<?php if ($projectImageUrl): ?>
<meta property="og:image" content="<?= e($projectImageUrl) ?>" />
<meta property="twitter:image" content="<?= e($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 class="app-body">
<nav class="navbar navbar-expand-lg navbar-light bg-white border-bottom sticky-top shadow-sm py-3">
<div class="container">
<a class="navbar-brand fs-4" href="<?= e(url_with_lang('index.php')) ?>">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="currentColor" class="bi bi-box-seam me-1 text-primary" 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('app_name')) ?>
</a>
<button class="navbar-toggler border-0" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="mainNav">
<ul class="navbar-nav me-auto mb-2 mb-lg-0 fw-semibold">
<li class="nav-item">
<a class="nav-link <?= $active === 'home' ? 'active text-primary' : '' ?>" href="<?= e(url_with_lang('index.php')) ?>">
<?= e(t('nav_home')) ?>
</a>
</li>
</ul>
<div class="d-flex align-items-center gap-3">
<div class="dropdown">
<a class="text-decoration-none text-muted fw-semibold dropdown-toggle" href="#" id="loginDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Demo Login
</a>
<ul class="dropdown-menu dropdown-menu-end shadow-sm border-0 mt-3" aria-labelledby="loginDropdown" style="border-radius: 12px;">
<li>
<a class="dropdown-item py-2 <?= $active === 'shipper' ? 'active' : '' ?>" href="<?= e(url_with_lang('shipper_dashboard.php')) ?>">
<?= e(t('nav_shipper')) ?>
</a>
</li>
<li>
<a class="dropdown-item py-2 <?= $active === 'owner' ? 'active' : '' ?>" href="<?= e(url_with_lang('truck_owner_dashboard.php')) ?>">
<?= e(t('nav_owner')) ?>
</a>
</li>
<li><hr class="dropdown-divider"></li>
<li>
<a class="dropdown-item py-2 <?= $active === 'admin' ? 'active' : '' ?>" href="<?= e(url_with_lang('admin_dashboard.php')) ?>">
<?= e(t('nav_admin')) ?>
</a>
</li>
</ul>
</div>
<a class="btn btn-sm btn-outline-dark rounded-pill px-3 fw-bold" href="<?= e(current_url_with_lang($toggleLang)) ?>">
<?= e($toggleLabel) ?>
</a>
<a class="btn btn-primary btn-sm rounded-pill px-4 fw-bold shadow-sm d-none d-lg-block" href="<?= e(url_with_lang('register.php', ['role' => 'shipper'])) ?>">
Get Started
</a>
</div>
</div>
</div>
</nav>
<main class="container py-5">
<?php
}
function render_footer(): void
{
global $lang;
?>
</main>
<footer class="bg-white border-top py-5 mt-5">
<div class="container">
<div class="row g-4 mb-4">
<div class="col-md-4">
<div class="d-flex align-items-center mb-3">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-box-seam me-2 text-primary" 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>
<h5 class="fw-bold mb-0 text-dark"><?= e(t('app_name')) ?></h5>
</div>
<p class="text-muted small pe-md-4">
<?= e(t('motivation_phrase')) ?>
</p>
</div>
<div class="col-md-2 offset-md-2">
<h6 class="fw-bold mb-3">Company</h6>
<ul class="list-unstyled text-muted small">
<li class="mb-2"><a href="#" class="text-decoration-none text-muted">About Us</a></li>
<li class="mb-2"><a href="#" class="text-decoration-none text-muted">Careers</a></li>
<li class="mb-2"><a href="#" class="text-decoration-none text-muted">Contact</a></li>
</ul>
</div>
<div class="col-md-2">
<h6 class="fw-bold mb-3">Resources</h6>
<ul class="list-unstyled text-muted small">
<li class="mb-2"><a href="#" class="text-decoration-none text-muted">Help Center</a></li>
<li class="mb-2"><a href="#" class="text-decoration-none text-muted">Terms of Service</a></li>
<li class="mb-2"><a href="#" class="text-decoration-none text-muted">Privacy Policy</a></li>
</ul>
</div>
<div class="col-md-2">
<h6 class="fw-bold mb-3">Language</h6>
<div class="d-flex gap-2">
<a href="<?= e(current_url_with_lang('en')) ?>" class="text-decoration-none <?= $lang === 'en' ? 'text-primary fw-bold' : 'text-muted' ?>">EN</a>
<span class="text-muted">|</span>
<a href="<?= e(current_url_with_lang('ar')) ?>" class="text-decoration-none <?= $lang === 'ar' ? 'text-primary fw-bold' : 'text-muted' ?>">AR</a>
</div>
</div>
</div>
<div class="d-flex flex-column flex-md-row justify-content-between align-items-center pt-4 border-top small text-muted">
<span>&copy; <?= date('Y') ?> <?= e(t('app_name')) ?>. All rights reserved.</span>
<span class="mt-2 mt-md-0"><?= e(t('footer_note')) ?></span>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="/assets/js/main.js?v=<?= time() ?>"></script>
</body>
</html>
<?php
}
function render_admin_sidebar(string $active = 'dashboard'): void
{
$items = [
'dashboard' => ['label' => 'Dashboard', 'href' => url_with_lang('admin_dashboard.php')],
'countries' => ['label' => 'Countries', 'href' => url_with_lang('admin_countries.php')],
'cities' => ['label' => 'Cities', 'href' => url_with_lang('admin_cities.php')],
'shippers' => ['label' => 'Shippers', 'href' => url_with_lang('admin_shippers.php')],
'truck_owners' => ['label' => 'Truck Owners', 'href' => url_with_lang('admin_truck_owners.php')],
'register' => ['label' => 'User Registration', 'href' => url_with_lang('register.php')],
];
?>
<aside class="admin-sidebar panel p-4 shadow-sm border-0">
<h2 class="h5 fw-bold mb-4">Admin Panel</h2>
<nav class="nav flex-column gap-2">
<?php foreach ($items as $key => $item): ?>
<a class="admin-nav-link <?= $active === $key ? 'active' : '' ?>" href="<?= e($item['href']) ?>">
<?= e($item['label']) ?>
</a>
<?php endforeach; ?>
</nav>
</aside>
<?php
}