update 2221

This commit is contained in:
Flatlogic Bot 2026-02-28 09:40:33 +00:00
parent c5ac8e3c6e
commit dcb1aa0c6b
8 changed files with 99 additions and 98 deletions

View File

@ -171,7 +171,7 @@ $page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int)$_GET['page'] :
if ($page < 1) $page = 1; if ($page < 1) $page = 1;
$offset = ($page - 1) * $limit; $offset = ($page - 1) * $limit;
$where_clauses = ["m.type = 'inbound'"]; $where_clauses = ["1=1"];
$params = []; $params = [];
if ($search) { if ($search) {

View File

@ -1,5 +1,5 @@
<?php if (isLoggedIn()): ?> <?php if (isLoggedIn()): ?>
</div><!-- Close main-content --> </main><!-- Close main-content -->
<?php endif; ?> <?php endif; ?>
<footer class="footer mt-auto py-4 bg-white border-top"> <footer class="footer mt-auto py-4 bg-white border-top">
@ -46,28 +46,6 @@
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<!-- Main App JS --> <!-- Main App JS -->
<script src="assets/js/main.js?v=<?= time() ?>"></script> <script src="assets/js/main.js?v=<?= time() ?>"></script>
<script>
// Sidebar Toggle for Mobile
document.getElementById('sidebarToggle')?.addEventListener('click', function() {
document.getElementById('sidebar').classList.toggle('show');
});
// Theme Switcher
const checkbox = document.getElementById('checkbox');
if (checkbox) {
checkbox.addEventListener('change', () => {
const theme = checkbox.checked ? 'dark' : 'light';
document.documentElement.setAttribute('data-bs-theme', theme);
// Save preference to database
fetch('api/update_theme.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ theme: theme })
});
});
}
</script>
</body> </body>
</html> </html>
<?php <?php

View File

@ -1,5 +1,5 @@
<?php <?php
ob_start(); ob_start(); error_reporting(E_ALL); ini_set("display_errors", 1);
session_start(); session_start();
require_once __DIR__ . '/../db/config.php'; require_once __DIR__ . '/../db/config.php';
@ -99,10 +99,14 @@ if (isLoggedIn()) {
'view' => (bool)$p['can_view'], 'view' => (bool)$p['can_view'],
'add' => (bool)$p['can_add'], 'add' => (bool)$p['can_add'],
'edit' => (bool)$p['can_edit'], 'edit' => (bool)$p['can_edit'],
'delete' => (bool)$p['can_delete'] 'delete' => (bool)$p['can_delete'],
]; ];
} }
} }
} else {
// User not found in DB but session exists - clean up
session_destroy();
redirect('login.php');
} }
} }
@ -171,6 +175,7 @@ if (!isLoggedIn() && basename($_SERVER['PHP_SELF']) !== 'login.php' && basename(
.sidebar .nav-link.active { .sidebar .nav-link.active {
border-right: 4px solid #0d6efd; border-right: 4px solid #0d6efd;
} }
.logo-link:hover { opacity: 0.8; }
.sidebar-heading { .sidebar-heading {
padding: 20px 20px 10px; padding: 20px 20px 10px;
font-size: 0.75rem; font-size: 0.75rem;
@ -213,11 +218,9 @@ if (!isLoggedIn() && basename($_SERVER['PHP_SELF']) !== 'login.php' && basename(
display: inline-block; display: inline-block;
height: 24px; height: 24px;
position: relative; position: relative;
width: 50px; width: 48px;
}
.theme-switch input {
display:none;
} }
.theme-switch input { display: none; }
.slider { .slider {
background-color: #ccc; background-color: #ccc;
bottom: 0; bottom: 0;
@ -240,13 +243,49 @@ if (!isLoggedIn() && basename($_SERVER['PHP_SELF']) !== 'login.php' && basename(
width: 16px; width: 16px;
border-radius: 50%; border-radius: 50%;
} }
input:checked + .slider { input:checked + .slider { background-color: #0d6efd; }
background-color: #0d6efd; input:checked + .slider:before { transform: translateX(24px); }
.slider .fa-sun {
position: absolute;
left: 6px;
top: 4px;
font-size: 12px;
color: #ffc107;
opacity: 1;
transition: .4s;
} }
input:checked + .slider:before { .slider .fa-moon {
transform: translateX(26px); position: absolute;
right: 6px;
top: 4px;
font-size: 12px;
color: #f8f9fa;
opacity: 0;
transition: .4s;
} }
input:checked + .slider .fa-sun { opacity: 0; }
input:checked + .slider .fa-moon { opacity: 1; }
/* RTL specific tweaks */
[dir="rtl"] .dropdown-menu { text-align: right; }
[dir="rtl"] .ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
[dir="rtl"] .me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
[dir="rtl"] .me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
</style> </style>
<script>
function toggleSidebar() {
document.getElementById('sidebar').classList.toggle('show');
}
function toggleTheme(checkbox) {
const theme = checkbox.checked ? 'dark' : 'light';
document.documentElement.setAttribute('data-bs-theme', theme);
fetch('api/update_theme.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ theme: theme })
});
}
</script>
</head> </head>
<body> <body>
@ -254,10 +293,12 @@ if (!isLoggedIn() && basename($_SERVER['PHP_SELF']) !== 'login.php' && basename(
<!-- Sidebar --> <!-- Sidebar -->
<div class="sidebar d-flex flex-column" id="sidebar"> <div class="sidebar d-flex flex-column" id="sidebar">
<div class="p-3 text-center border-bottom border-secondary"> <div class="p-3 text-center border-bottom border-secondary">
<?php if ($sys_settings['site_logo']): ?> <a href="index.php" class="text-decoration-none text-white d-block logo-link">
<?php if (!empty($sys_settings['site_logo'])): ?>
<img src="<?= $sys_settings['site_logo'] ?>" alt="Logo" class="img-fluid mb-2" style="max-height: 50px;"> <img src="<?= $sys_settings['site_logo'] ?>" alt="Logo" class="img-fluid mb-2" style="max-height: 50px;">
<?php endif; ?> <?php endif; ?>
<h5 class="mb-0 fw-bold"><?= htmlspecialchars($sys_settings['site_name']) ?></h5> <h5 class="mb-0 fw-bold"><?= htmlspecialchars($sys_settings['site_name']) ?></h5>
</a>
</div> </div>
<ul class="nav flex-column mt-3 mb-4"> <ul class="nav flex-column mt-3 mb-4">
@ -301,23 +342,15 @@ if (!isLoggedIn() && basename($_SERVER['PHP_SELF']) !== 'login.php' && basename(
</li> </li>
<?php endif; ?> <?php endif; ?>
<div class="sidebar-heading">التقارير</div>
<?php if (canView('reports')): ?> <?php if (canView('reports')): ?>
<div class="sidebar-heading">التقارير</div>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'overdue_report.php' ? 'active' : '' ?>" href="overdue_report.php"> <a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'overdue_report.php' ? 'active' : '' ?>" href="overdue_report.php">
<i class="fas fa-clock me-2"></i> بريد متأخر <i class="fas fa-exclamation-circle me-2"></i> تقرير التأخير
</a> </a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if (canView('inbound')): ?>
<li class="nav-item">
<a class="nav-link <?= (basename($_SERVER['PHP_SELF']) == 'inbound.php' && isset($_GET['my_tasks'])) ? 'active' : '' ?>" href="inbound.php?my_tasks=1">
<i class="fas fa-tasks me-2"></i> مهامي الحالية
</a>
</li>
<?php endif; ?>
<?php if (canView('users') || canView('settings')): ?> <?php if (canView('users') || canView('settings')): ?>
<div class="sidebar-heading">الإدارة</div> <div class="sidebar-heading">الإدارة</div>
<?php endif; ?> <?php endif; ?>
@ -329,74 +362,64 @@ if (!isLoggedIn() && basename($_SERVER['PHP_SELF']) !== 'login.php' && basename(
</a> </a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if (canView('settings')): ?> <?php if (canView('settings')): ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link <?= (basename($_SERVER['PHP_SELF']) == 'charity-settings.php' && !isset($_GET['tab'])) ? 'active' : '' ?>" href="charity-settings.php" onclick="localStorage.setItem('activeSettingsTab', '#general');"> <a class="nav-link <?= basename($_SERVER['PHP_SELF']) == 'charity-settings.php' ? 'active' : '' ?>" href="charity-settings.php">
<i class="fas fa-cog me-2"></i> الإعدادات <i class="fas fa-cog me-2"></i> إعدادات النظام
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="charity-settings.php#logs" onclick="localStorage.setItem('activeSettingsTab', '#logs'); if(location.pathname.includes('charity-settings.php')) location.hash='#logs';">
<i class="fas fa-history me-2"></i> سجل المراسلات
</a> </a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<div class="sidebar-heading">الحساب</div>
<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>
<!-- Theme Switcher -->
<li class="nav-item mt-4 px-3">
<div class="d-flex align-items-center justify-content-between text-secondary small">
<span>الوضع الليلي</span>
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" <?= $user_theme === 'dark' ? 'checked' : '' ?> />
<div class="slider"></div>
</label>
</div>
</li>
<li class="nav-item mt-auto border-top border-secondary">
<a class="nav-link text-danger" href="logout.php">
<i class="fas fa-sign-out-alt me-2"></i> تسجيل الخروج
</a>
</li>
</ul> </ul>
<div class="mt-auto p-3 text-center opacity-50 small">
&copy; <?= date('Y') ?> <?= htmlspecialchars($sys_settings['site_name']) ?>
</div>
</div> </div>
<!-- Top Navbar --> <!-- Top Navbar -->
<nav class="navbar navbar-expand navbar-light top-navbar sticky-top"> <nav class="navbar navbar-expand-lg top-navbar sticky-top p-0 shadow-sm">
<div class="container-fluid"> <div class="container-fluid px-3">
<button class="btn btn-outline-secondary d-lg-none me-2" id="sidebarToggle"> <button class="btn d-lg-none" type="button" onclick="toggleSidebar()">
<i class="fas fa-bars"></i> <i class="fas fa-bars"></i>
</button> </button>
<div class="ms-auto d-flex align-items-center"> <div class="ms-auto d-flex align-items-center">
<!-- Theme Switcher -->
<div class="theme-switch-wrapper me-3">
<label class="theme-switch" for="checkbox">
<input type="checkbox" id="checkbox" <?= $user_theme === 'dark' ? 'checked' : '' ?> onchange="toggleTheme(this)">
<div class="slider">
<i class="fas fa-sun"></i>
<i class="fas fa-moon"></i>
</div>
</label>
</div>
<div class="dropdown"> <div class="dropdown">
<a class="nav-link dropdown-toggle d-flex align-items-center" href="#" role="button" data-bs-toggle="dropdown"> <button class="btn d-flex align-items-center dropdown-toggle border-0" type="button" id="userMenu" data-bs-toggle="dropdown" aria-expanded="false">
<?php if (isset($current_user['profile_image']) && $current_user['profile_image']): ?> <div class="text-end me-2 d-none d-md-block">
<img src="<?= $current_user['profile_image'] ?>" alt="Profile" class="rounded-circle me-2 shadow-sm" style="width: 32px; height: 32px; object-fit: cover;"> <div class="fw-bold small"><?= htmlspecialchars($_SESSION['name'] ?? 'المستخدم') ?></div>
<div class="text-muted" style="font-size: 0.7rem;"><?= ucfirst($_SESSION['user_role'] ?? 'موظف') ?></div>
</div>
<?php if (!empty($current_user['profile_image'])): ?>
<img src="<?= $current_user['profile_image'] ?>" alt="Profile" class="rounded-circle" width="35" height="35" style="object-fit: cover;">
<?php else: ?> <?php else: ?>
<div class="<?= isSuperAdmin() ? 'bg-danger' : 'bg-primary' ?> text-white rounded-circle d-flex align-items-center justify-content-center me-2" style="width: 32px; height: 32px; font-size: 0.8rem;"> <div class="rounded-circle bg-primary bg-opacity-10 d-flex align-items-center justify-content-center" style="width: 35px; height: 35px;">
<?= mb_substr($_SESSION['name'] ?? 'U', 0, 1) ?> <i class="fas fa-user text-primary"></i>
</div> </div>
<?php endif; ?> <?php endif; ?>
<span class="d-none d-md-inline"><?= htmlspecialchars($_SESSION['name'] ?? 'المستخدم') ?> <?= isSuperAdmin() ? '<small class="badge bg-danger ms-1">مدير خارق</small>' : '' ?></span> </button>
</a> <ul class="dropdown-menu dropdown-menu-end shadow border-0" aria-labelledby="userMenu">
<ul class="dropdown-menu dropdown-menu-end"> <li><a class="dropdown-item" href="profile.php"><i class="fas fa-user-circle me-2 text-muted"></i> ملفي الشخصي</a></li>
<li><a class="dropdown-item" href="profile.php"><i class="fas fa-user me-2"></i> الملف الشخصي</a></li>
<li><hr class="dropdown-divider"></li> <li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item text-danger" href="logout.php"><i class="fas fa-sign-out-alt me-2"></i> خروج</a></li> <li><a class="dropdown-item text-danger" href="logout.php"><i class="fas fa-sign-out-alt me-2"></i> تسجيل الخروج</a></li>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
</nav> </nav>
<div class="main-content"> <!-- Main Content -->
<?php endif; ?> <main class="main-content">
<?php endif; ?>

View File

@ -27,8 +27,6 @@ foreach ($statuses_data as $id => $s) {
$in_progress_count = 0; $in_progress_count = 0;
if ($in_progress_id) { if ($in_progress_id) {
if (canView('inbound')) { if (canView('inbound')) {
$in_progress_count += db()->prepare("SELECT COUNT(*) FROM inbound_mail WHERE status_id = ?")->execute([$in_progress_id]) ? db()->prepare("SELECT COUNT(*) FROM inbound_mail WHERE status_id = ?")->execute([$in_progress_id]) : 0;
// Wait, execute returns bool.
$stmt = db()->prepare("SELECT COUNT(*) FROM inbound_mail WHERE status_id = ?"); $stmt = db()->prepare("SELECT COUNT(*) FROM inbound_mail WHERE status_id = ?");
$stmt->execute([$in_progress_id]); $stmt->execute([$in_progress_id]);
$in_progress_count += $stmt->fetchColumn(); $in_progress_count += $stmt->fetchColumn();

View File

@ -17,7 +17,7 @@ $limit = 10;
$offset = ($page - 1) * $limit; $offset = ($page - 1) * $limit;
$params = [$user_id]; $params = [$user_id];
$where = "m.type = 'internal' AND m.assigned_to = ?"; $where = "1=1 AND m.assigned_to = ?";
if ($search) { if ($search) {
$where .= " AND (m.subject LIKE ? OR m.description LIKE ? OR u_sender.full_name LIKE ?)"; $where .= " AND (m.subject LIKE ? OR m.description LIKE ? OR u_sender.full_name LIKE ?)";

View File

@ -107,7 +107,7 @@ $limit = 10;
$offset = ($page - 1) * $limit; $offset = ($page - 1) * $limit;
$params = [$user_id]; $params = [$user_id];
$where = "m.type = 'internal' AND m.created_by = ?"; $where = "1=1 AND m.created_by = ?";
if ($search) { if ($search) {
$where .= " AND (m.subject LIKE ? OR m.description LIKE ? OR u_recp.full_name LIKE ?)"; $where .= " AND (m.subject LIKE ? OR m.description LIKE ? OR u_recp.full_name LIKE ?)";

View File

@ -38,10 +38,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
<div class="card shadow-sm border-0"> <div class="card shadow-sm border-0">
<div class="card-body p-4"> <div class="card-body p-4">
<div class="text-center mb-4"> <div class="text-center mb-4">
<a href="index.php" class="text-decoration-none text-dark d-block">
<?php if (!empty($sys_settings['site_logo'])): ?> <?php if (!empty($sys_settings['site_logo'])): ?>
<img src="<?php echo htmlspecialchars($sys_settings['site_logo']); ?>" alt="Logo" class="img-fluid mb-3" style="max-height: 80px;"> <img src="<?php echo htmlspecialchars($sys_settings['site_logo']); ?>" alt="Logo" class="img-fluid mb-3" style="max-height: 80px;">
<?php endif; ?> <?php endif; ?>
<h4 class="fw-bold mb-0"><?php echo htmlspecialchars($sys_settings['site_name']); ?></h4> <h4 class="fw-bold mb-0"><?php echo htmlspecialchars($sys_settings['site_name']); ?></h4>
</a>
<p class="text-muted small">يرجى إدخال بيانات الاعتماد الخاصة بك</p> <p class="text-muted small">يرجى إدخال بيانات الاعتماد الخاصة بك</p>
</div> </div>

View File

@ -87,7 +87,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
db()->beginTransaction(); db()->beginTransaction();
if ($action === 'add') { if ($action === 'add') {
$stmt = db()->prepare("INSERT INTO outbound_mail (ref_no, date_registered, due_date, sender, recipient, subject, description, status_id, assigned_to, created_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt = db()->prepare("INSERT INTO outbound_mail (ref_no, date_registered, due_date, sender, recipient, subject, description, status_id, assigned_to, created_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$$ref_no, $date_registered, $due_date, $sender, $recipient, $subject, $description, $status_id, $assigned_to, $user_id]); $stmt->execute([$ref_no, $date_registered, $due_date, $sender, $recipient, $subject, $description, $status_id, $assigned_to, $user_id]);
$mail_id = db()->lastInsertId(); $mail_id = db()->lastInsertId();
if ($assigned_to) { if ($assigned_to) {
@ -184,7 +184,7 @@ $page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int)$_GET['page'] :
if ($page < 1) $page = 1; if ($page < 1) $page = 1;
$offset = ($page - 1) * $limit; $offset = ($page - 1) * $limit;
$where_clauses = ["m.type = 'outbound'"]; $where_clauses = ["1=1"];
$params = []; $params = [];
if ($search) { if ($search) {