180 lines
7.4 KiB
PHP
180 lines
7.4 KiB
PHP
<?php
|
|
session_start();
|
|
require_once __DIR__ . '/../db/config.php';
|
|
|
|
function isLoggedIn() {
|
|
return isset($_SESSION['user_id']);
|
|
}
|
|
|
|
function isAdmin() {
|
|
return isset($_SESSION['user_role']) && $_SESSION['user_role'] === 'admin';
|
|
}
|
|
|
|
function redirect($path) {
|
|
header("Location: $path");
|
|
exit;
|
|
}
|
|
|
|
if (!isLoggedIn() && basename($_SERVER['PHP_SELF']) !== 'login.php') {
|
|
redirect('login.php');
|
|
}
|
|
|
|
// Fetch charity settings
|
|
$stmt = db()->query("SELECT * FROM charity_settings WHERE id = 1");
|
|
$charity = $stmt->fetch();
|
|
$charity_name = $charity['charity_name'] ?? 'بريد الجمعية';
|
|
$charity_logo = $charity['charity_logo'] ?? null;
|
|
$charity_favicon = $charity['charity_favicon'] ?? null;
|
|
|
|
// Fetch current user info if logged in
|
|
$current_user = null;
|
|
if (isLoggedIn()) {
|
|
$stmt = db()->prepare("SELECT full_name, profile_image FROM users WHERE id = ?");
|
|
$stmt->execute([$_SESSION['user_id']]);
|
|
$current_user = $stmt->fetch();
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="ar" dir="rtl">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title><?= htmlspecialchars($charity_name) ?></title>
|
|
<?php if ($charity_favicon): ?>
|
|
<link rel="icon" type="image/x-icon" href="<?= $charity_favicon ?>?v=<?= time() ?>">
|
|
<?php endif; ?>
|
|
<!-- Bootstrap 5 RTL CSS -->
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.rtl.min.css">
|
|
<!-- Google Fonts: Cairo -->
|
|
<link href="https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap" rel="stylesheet">
|
|
<!-- Font Awesome -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
|
|
|
<!-- JS Libraries (Loaded in head to support inline onclick handlers) -->
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<script src="https://cdn.ckeditor.com/ckeditor5/36.0.1/classic/ckeditor.js"></script>
|
|
|
|
<style>
|
|
body {
|
|
font-family: 'Cairo', sans-serif;
|
|
background-color: #f8f9fa;
|
|
}
|
|
.sidebar {
|
|
min-height: 100vh;
|
|
background: #fff;
|
|
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
|
padding-top: 1rem;
|
|
}
|
|
.nav-link {
|
|
color: #333;
|
|
font-weight: 600;
|
|
padding: 0.8rem 1.5rem;
|
|
}
|
|
.nav-link:hover, .nav-link.active {
|
|
background-color: #f0f7ff;
|
|
color: #0d6efd;
|
|
border-left: 4px solid #0d6efd;
|
|
}
|
|
.card {
|
|
border: none;
|
|
box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
|
|
border-radius: 10px;
|
|
}
|
|
.btn-primary {
|
|
background-color: #0d6efd;
|
|
border: none;
|
|
}
|
|
.status-received { background-color: #e9ecef; color: #495057; }
|
|
.status-in_progress { background-color: #cff4fc; color: #055160; }
|
|
.status-closed { background-color: #d1e7dd; color: #0f5132; }
|
|
|
|
/* Modal Header Styling */
|
|
.modal-header.bg-primary {
|
|
background-color: #0d6efd !important;
|
|
}
|
|
|
|
.user-profile-img {
|
|
width: 80px;
|
|
height: 80px;
|
|
border-radius: 50%;
|
|
object-fit: cover;
|
|
border: 2px solid #0d6efd;
|
|
}
|
|
.charity-logo {
|
|
max-width: 100%;
|
|
max-height: 60px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<?php if (isLoggedIn()): ?>
|
|
<!-- Sidebar -->
|
|
<nav class="col-md-3 col-lg-2 d-md-block sidebar collapse">
|
|
<div class="position-sticky">
|
|
<div class="text-center mb-4">
|
|
<?php if ($charity_logo): ?>
|
|
<img src="<?= $charity_logo ?>?v=<?= time() ?>" alt="Logo" class="charity-logo mb-2">
|
|
<?php endif; ?>
|
|
<h5 class="fw-bold mt-2"><?= htmlspecialchars($charity_name) ?></h5>
|
|
</div>
|
|
|
|
<div class="user-info text-center mb-4 py-3 border-bottom border-top">
|
|
<?php if ($current_user['profile_image']): ?>
|
|
<img src="<?= $current_user['profile_image'] ?>?v=<?= time() ?>" alt="Profile" class="user-profile-img mb-2">
|
|
<?php else: ?>
|
|
<div class="user-profile-img bg-light mx-auto d-flex align-items-center justify-content-center mb-2">
|
|
<i class="fas fa-user text-secondary fa-2x"></i>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="small fw-bold"><?= htmlspecialchars($current_user['full_name'] ?? $_SESSION['username']) ?></div>
|
|
<div class="small text-muted"><?= $_SESSION['user_role'] === 'admin' ? 'مدير النظام' : 'موظف' ?></div>
|
|
</div>
|
|
|
|
<ul class="nav flex-column">
|
|
<li class="nav-item">
|
|
<a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'index.php' ? 'active' : '' ?>" href="index.php">
|
|
<i class="fas fa-home me-2"></i> لوحة التحكم
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'inbound.php' ? 'active' : '' ?>" href="inbound.php">
|
|
<i class="fas fa-download me-2"></i> البريد الوارد
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'outbound.php' ? 'active' : '' ?>" href="outbound.php">
|
|
<i class="fas fa-upload me-2"></i> البريد الصادر
|
|
</a>
|
|
</li>
|
|
<?php if (isAdmin()): ?>
|
|
<li class="nav-item">
|
|
<a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'users.php' ? 'active' : '' ?>" href="users.php">
|
|
<i class="fas fa-users me-2"></i> إدارة المستخدمين
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'charity-settings.php' ? 'active' : '' ?>" href="charity-settings.php">
|
|
<i class="fas fa-cog me-2"></i> إعدادات الجمعية
|
|
</a>
|
|
</li>
|
|
<?php endif; ?>
|
|
<li class="nav-item">
|
|
<a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'profile.php' ? 'active' : '' ?>" href="profile.php">
|
|
<i class="fas fa-user-circle me-2"></i> الملف الشخصي
|
|
</a>
|
|
</li>
|
|
<li class="nav-item mt-4">
|
|
<a class="nav-link text-danger" href="logout.php">
|
|
<i class="fas fa-sign-out-alt me-2"></i> تسجيل الخروج
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</nav>
|
|
<?php endif; ?>
|
|
|
|
<main class="<?= isLoggedIn() ? 'col-md-9 ms-sm-auto col-lg-10' : 'col-12' ?> px-md-4 py-4">
|