Compare commits
2 Commits
06c06718a0
...
2d8e8f2776
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d8e8f2776 | ||
|
|
bd29389176 |
@ -129,8 +129,8 @@ function getStatusBadge($mail) {
|
||||
if (canView('reports')):
|
||||
// Combine overdue counts from inbound and outbound
|
||||
$overdue_count = 0;
|
||||
$overdue_count += db()->query("SELECT COUNT(*) FROM inbound_mail WHERE due_date < CURDATE() AND status_id IN (SELECT id FROM mailbox_statuses WHERE name != 'closed')")->fetchColumn();
|
||||
$overdue_count += db()->query("SELECT COUNT(*) FROM outbound_mail WHERE due_date < CURDATE() AND status_id IN (SELECT id FROM mailbox_statuses WHERE name != 'closed')")->fetchColumn();
|
||||
$overdue_count += db()->query("SELECT COUNT(*) FROM inbound_mail WHERE due_date < CURDATE() AND status_id IN (SELECT id FROM mailbox_statuses WHERE name NOT IN ('closed', 'مكتمل', 'مؤرشف', 'مؤرشفة'))")->fetchColumn();
|
||||
$overdue_count += db()->query("SELECT COUNT(*) FROM outbound_mail WHERE due_date < CURDATE() AND status_id IN (SELECT id FROM mailbox_statuses WHERE name NOT IN ('closed', 'مكتمل', 'مؤرشف', 'مؤرشفة'))")->fetchColumn();
|
||||
|
||||
if ($overdue_count > 0):
|
||||
?>
|
||||
@ -243,7 +243,7 @@ endif;
|
||||
<td>
|
||||
<small class="text-muted d-block">الموعد النهائي</small>
|
||||
<?php if ($mail['due_date']): ?>
|
||||
<span class="<?= (strtotime($mail['due_date']) < time() && $mail['status_name'] != 'closed') ? 'text-danger fw-bold' : '' ?>">
|
||||
<span class="<?= (strtotime($mail['due_date']) < time() && !in_array($mail['status_name'], ['closed', 'مكتمل', 'مؤرشف', 'مؤرشفة'])) ? 'text-danger fw-bold' : '' ?>">
|
||||
<?= $mail['due_date'] ?>
|
||||
</span>
|
||||
<?php else: ?>
|
||||
@ -304,7 +304,7 @@ endif;
|
||||
<td><?= htmlspecialchars($mail['subject'] ?? '') ?></td>
|
||||
<td>
|
||||
<?php if ($mail['due_date']): ?>
|
||||
<small class="<?= (strtotime($mail['due_date']) < time() && $mail['status_name'] != 'closed') ? 'text-danger fw-bold' : 'text-muted' ?>">
|
||||
<small class="<?= (strtotime($mail['due_date']) < time() && !in_array($mail['status_name'], ['closed', 'مكتمل', 'مؤرشف', 'مؤرشفة'])) ? 'text-danger fw-bold' : 'text-muted' ?>">
|
||||
<?= $mail['due_date'] ?>
|
||||
</small>
|
||||
<?php else: ?>
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
<?php
|
||||
require_once 'includes/header.php';
|
||||
|
||||
// Auto-fix existing records that have NULL created_by/updated_by (e.g. from deployed database before triggers)
|
||||
try {
|
||||
if (db()->query("SELECT COUNT(*) FROM charity_members WHERE created_by IS NULL OR updated_by IS NULL")->fetchColumn() > 0) {
|
||||
db()->query("UPDATE charity_members SET created_by = 1 WHERE created_by IS NULL");
|
||||
db()->query("UPDATE charity_members SET updated_by = 1 WHERE updated_by IS NULL");
|
||||
}
|
||||
} catch (Exception $e) {}
|
||||
|
||||
if (!isAdmin() && !canView('charity_members')) {
|
||||
echo "<div class='alert alert-danger'>غير مصرح لك بالوصول لهذه الصفحة.</div>";
|
||||
require_once 'includes/footer.php';
|
||||
@ -18,8 +26,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$join_date = $_POST['join_date'] ?? date('Y-m-d');
|
||||
$status = $_POST['status'] ?? 'active';
|
||||
|
||||
$stmt = db()->prepare("INSERT INTO charity_members (name, role, phone, email, join_date, status) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$name, $role, $phone, $email, $join_date, $status]);
|
||||
$stmt = db()->prepare("INSERT INTO charity_members (name, role, phone, email, join_date, status, created_by, updated_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$name, $role, $phone, $email, $join_date, $status, $_SESSION['user_id'], $_SESSION['user_id']]);
|
||||
|
||||
$_SESSION['success'] = "تمت إضافة العضو بنجاح.";
|
||||
redirect('charity_members.php');
|
||||
@ -32,8 +40,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$join_date = $_POST['join_date'] ?? date('Y-m-d');
|
||||
$status = $_POST['status'] ?? 'active';
|
||||
|
||||
$stmt = db()->prepare("UPDATE charity_members SET name = ?, role = ?, phone = ?, email = ?, join_date = ?, status = ? WHERE id = ?");
|
||||
$stmt->execute([$name, $role, $phone, $email, $join_date, $status, $id]);
|
||||
$stmt = db()->prepare("UPDATE charity_members SET name = ?, role = ?, phone = ?, email = ?, join_date = ?, status = ?, updated_by = ? WHERE id = ?");
|
||||
$stmt->execute([$name, $role, $phone, $email, $join_date, $status, $_SESSION['user_id'], $id]);
|
||||
|
||||
$_SESSION['success'] = "تم تحديث العضو بنجاح.";
|
||||
redirect('charity_members.php');
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
<?php
|
||||
require_once 'includes/header.php';
|
||||
|
||||
// Auto-fix existing records that have NULL created_by/updated_by
|
||||
try {
|
||||
if (db()->query("SELECT COUNT(*) FROM charity_plans WHERE created_by IS NULL OR updated_by IS NULL")->fetchColumn() > 0) {
|
||||
db()->query("UPDATE charity_plans SET created_by = 1 WHERE created_by IS NULL");
|
||||
db()->query("UPDATE charity_plans SET updated_by = 1 WHERE updated_by IS NULL");
|
||||
}
|
||||
} catch (Exception $e) {}
|
||||
|
||||
if (!isAdmin() && !canView('charity_plans')) {
|
||||
echo "<div class='alert alert-danger'>غير مصرح لك بالوصول لهذه الصفحة.</div>";
|
||||
require_once 'includes/footer.php';
|
||||
@ -17,8 +25,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$achieved_value = (int)($_POST['achieved_value'] ?? 0);
|
||||
$status = $_POST['status'] ?? 'pending';
|
||||
|
||||
$stmt = db()->prepare("INSERT INTO charity_plans (title, description, start_date, end_date, target_value, achieved_value, status) VALUES (?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$title, $description, $start_date, $end_date, $target_value, $achieved_value, $status]);
|
||||
$stmt = db()->prepare("INSERT INTO charity_plans (title, description, start_date, end_date, target_value, achieved_value, status, created_by, updated_by) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$title, $description, $start_date, $end_date, $target_value, $achieved_value, $status, $_SESSION['user_id'], $_SESSION['user_id']]);
|
||||
$_SESSION['success'] = "تمت إضافة الخطة بنجاح.";
|
||||
redirect('charity_plans.php');
|
||||
} elseif (isset($_POST['edit_plan']) && (isAdmin() || canEdit('charity_plans'))) {
|
||||
@ -31,8 +39,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$achieved_value = (int)($_POST['achieved_value'] ?? 0);
|
||||
$status = $_POST['status'] ?? 'pending';
|
||||
|
||||
$stmt = db()->prepare("UPDATE charity_plans SET title = ?, description = ?, start_date = ?, end_date = ?, target_value = ?, achieved_value = ?, status = ? WHERE id = ?");
|
||||
$stmt->execute([$title, $description, $start_date, $end_date, $target_value, $achieved_value, $status, $id]);
|
||||
$stmt = db()->prepare("UPDATE charity_plans SET title = ?, description = ?, start_date = ?, end_date = ?, target_value = ?, achieved_value = ?, status = ?, updated_by = ? WHERE id = ?");
|
||||
$stmt->execute([$title, $description, $start_date, $end_date, $target_value, $achieved_value, $status, $_SESSION['user_id'], $id]);
|
||||
$_SESSION['success'] = "تم تحديث الخطة بنجاح.";
|
||||
redirect('charity_plans.php');
|
||||
} elseif (isset($_POST['delete_plan']) && (isAdmin() || canDelete('charity_plans'))) {
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
|
||||
// Auto-fix existing records that have NULL created_by/updated_by
|
||||
try {
|
||||
if (db()->query("SELECT COUNT(*) FROM committees WHERE created_by IS NULL OR updated_by IS NULL")->fetchColumn() > 0) {
|
||||
db()->query("UPDATE committees SET created_by = 1 WHERE created_by IS NULL");
|
||||
db()->query("UPDATE committees SET updated_by = 1 WHERE updated_by IS NULL");
|
||||
}
|
||||
} catch (Exception $e) {}
|
||||
|
||||
if (!canView('committees')) {
|
||||
redirect('user_dashboard.php');
|
||||
}
|
||||
@ -21,16 +29,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (empty($name)) {
|
||||
$_SESSION['error'] = 'اسم اللجنة مطلوب';
|
||||
} else {
|
||||
$stmt = $db->prepare("INSERT INTO committees (name, description) VALUES (?, ?)");
|
||||
$stmt->execute([$name, $description]);
|
||||
$stmt = $db->prepare("INSERT INTO committees (name, description, created_by, updated_by) VALUES (?, ?, ?, ?)");
|
||||
$stmt->execute([$name, $description, $_SESSION['user_id'], $_SESSION['user_id']]);
|
||||
$_SESSION['success'] = 'تم إضافة اللجنة بنجاح';
|
||||
}
|
||||
} elseif ($action === 'edit' && $id && canEdit('committees')) {
|
||||
if (empty($name)) {
|
||||
$_SESSION['error'] = 'اسم اللجنة مطلوب';
|
||||
} else {
|
||||
$stmt = $db->prepare("UPDATE committees SET name = ?, description = ? WHERE id = ?");
|
||||
$stmt->execute([$name, $description, $id]);
|
||||
$stmt = $db->prepare("UPDATE committees SET name = ?, description = ?, updated_by = ? WHERE id = ?");
|
||||
$stmt->execute([$name, $description, $_SESSION['user_id'], $id]);
|
||||
$_SESSION['success'] = 'تم تحديث اللجنة بنجاح';
|
||||
}
|
||||
}
|
||||
@ -204,4 +212,4 @@ function confirmDelete(id) {
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
12
inbound.php
12
inbound.php
@ -77,7 +77,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||
$total_stmt = db()->query("SELECT COUNT(*) FROM inbound_mail");
|
||||
$total_inbound = $total_stmt->fetchColumn();
|
||||
|
||||
$pending_stmt = db()->prepare("SELECT COUNT(*) FROM inbound_mail WHERE status_id IN (SELECT id FROM mailbox_statuses WHERE is_default = 1 OR name LIKE '%قيد%')");
|
||||
$pending_stmt = db()->prepare("SELECT COUNT(*) FROM inbound_mail WHERE status_id IN (SELECT id FROM mailbox_statuses WHERE is_default = 1 OR name LIKE '%قيد%' OR name = 'in_progress')");
|
||||
$pending_stmt->execute();
|
||||
$pending_inbound = $pending_stmt->fetchColumn();
|
||||
|
||||
@ -125,8 +125,18 @@ $query = "SELECT m.*, s.name as status_name, s.color as status_color, u.full_nam
|
||||
$stmt = db()->prepare($query);
|
||||
$stmt->execute($params);
|
||||
$mails = $stmt->fetchAll();
|
||||
foreach ($mails as &$mail) {
|
||||
if ($mail['status_name'] == 'received') $mail['status_name'] = 'تم الاستلام';
|
||||
if ($mail['status_name'] == 'in_progress') $mail['status_name'] = 'قيد المعالجة';
|
||||
if ($mail['status_name'] == 'closed') $mail['status_name'] = 'مكتمل';
|
||||
} unset($mail);
|
||||
|
||||
$statuses = db()->query("SELECT * FROM mailbox_statuses ORDER BY id ASC")->fetchAll();
|
||||
foreach ($statuses as &$s) {
|
||||
if ($s['name'] == 'received') $s['name'] = 'تم الاستلام';
|
||||
if ($s['name'] == 'in_progress') $s['name'] = 'قيد المعالجة';
|
||||
if ($s['name'] == 'closed') $s['name'] = 'مكتمل';
|
||||
} unset($s);
|
||||
$users = db()->query("SELECT id, full_name, username FROM users ORDER BY full_name ASC")->fetchAll();
|
||||
$default_status_id = db()->query("SELECT id FROM mailbox_statuses WHERE is_default = 1 LIMIT 1")->fetchColumn() ?: ($statuses[0]['id'] ?? null);
|
||||
|
||||
|
||||
12
outbound.php
12
outbound.php
@ -77,7 +77,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
|
||||
$total_stmt = db()->query("SELECT COUNT(*) FROM outbound_mail");
|
||||
$total_outbound = $total_stmt->fetchColumn();
|
||||
|
||||
$completed_stmt = db()->prepare("SELECT COUNT(*) FROM outbound_mail WHERE status_id IN (SELECT id FROM mailbox_statuses WHERE name LIKE '%مكتمل%' OR name LIKE '%منتهي%')");
|
||||
$completed_stmt = db()->prepare("SELECT COUNT(*) FROM outbound_mail WHERE status_id IN (SELECT id FROM mailbox_statuses WHERE name LIKE '%مكتمل%' OR name LIKE '%منتهي%' OR name = 'closed')");
|
||||
$completed_stmt->execute();
|
||||
$completed_outbound = $completed_stmt->fetchColumn();
|
||||
|
||||
@ -121,8 +121,18 @@ $query = "SELECT m.*, s.name as status_name, s.color as status_color, u.full_nam
|
||||
$stmt = db()->prepare($query);
|
||||
$stmt->execute($params);
|
||||
$mails = $stmt->fetchAll();
|
||||
foreach ($mails as &$mail) {
|
||||
if ($mail['status_name'] == 'received') $mail['status_name'] = 'مرسلة';
|
||||
if ($mail['status_name'] == 'in_progress') $mail['status_name'] = 'قيد المعالجة';
|
||||
if ($mail['status_name'] == 'closed') $mail['status_name'] = 'مكتمل';
|
||||
} unset($mail);
|
||||
|
||||
$statuses = db()->query("SELECT * FROM mailbox_statuses ORDER BY id ASC")->fetchAll();
|
||||
foreach ($statuses as &$s) {
|
||||
if ($s['name'] == 'received') $s['name'] = 'مرسلة';
|
||||
if ($s['name'] == 'in_progress') $s['name'] = 'قيد المعالجة';
|
||||
if ($s['name'] == 'closed') $s['name'] = 'مكتمل';
|
||||
} unset($s);
|
||||
$users = db()->query("SELECT id, full_name, username FROM users ORDER BY full_name ASC")->fetchAll();
|
||||
$default_status_id = db()->query("SELECT id FROM mailbox_statuses WHERE is_default = 1 LIMIT 1")->fetchColumn() ?: ($statuses[0]['id'] ?? null);
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ $overdue_items = [];
|
||||
$queries = [];
|
||||
|
||||
if (!$type_filter || $type_filter === 'inbound') {
|
||||
$where = ["m.due_date < CURDATE()", "s.name != 'closed'"];
|
||||
$where = ["m.due_date < CURDATE()", "s.name NOT IN ('closed', 'مكتمل', 'مؤرشف', 'مؤرشفة')"];
|
||||
$params = [];
|
||||
if ($user_filter) {
|
||||
$where[] = "m.assigned_to = ?";
|
||||
@ -30,7 +30,7 @@ if (!$type_filter || $type_filter === 'inbound') {
|
||||
}
|
||||
|
||||
if (!$type_filter || $type_filter === 'outbound') {
|
||||
$where = ["m.due_date < CURDATE()", "s.name != 'closed'"];
|
||||
$where = ["m.due_date < CURDATE()", "s.name NOT IN ('closed', 'مكتمل', 'مؤرشف', 'مؤرشفة')"];
|
||||
$params = [];
|
||||
if ($user_filter) {
|
||||
$where[] = "m.assigned_to = ?";
|
||||
|
||||
@ -22,7 +22,7 @@ foreach (['inbound', 'outbound', 'internal'] as $t) {
|
||||
$stmt->execute([$user_id]);
|
||||
$my_total_assignments += $stmt->fetchColumn();
|
||||
|
||||
$stmt = db()->prepare("SELECT COUNT(*) FROM $table WHERE assigned_to = ? AND status_id IN (SELECT id FROM mailbox_statuses WHERE name != 'closed')");
|
||||
$stmt = db()->prepare("SELECT COUNT(*) FROM $table WHERE assigned_to = ? AND status_id IN (SELECT id FROM mailbox_statuses WHERE name NOT IN ('closed', 'مكتمل', 'مؤرشف', 'مؤرشفة'))");
|
||||
$stmt->execute([$user_id]);
|
||||
$my_pending_tasks += $stmt->fetchColumn();
|
||||
}
|
||||
@ -260,7 +260,7 @@ function getStatusBadge($mail) {
|
||||
<td><?= htmlspecialchars($mail['subject'] ?? '') ?></td>
|
||||
<td>
|
||||
<?php if ($mail['due_date']): ?>
|
||||
<small class="<?= (strtotime($mail['due_date']) < time() && $mail['status_name'] != 'closed') ? 'text-danger fw-bold' : 'text-muted' ?>">
|
||||
<small class="<?= (strtotime($mail['due_date']) < time() && !in_array($mail['status_name'], ['closed', 'مكتمل', 'مؤرشف', 'مؤرشفة'])) ? 'text-danger fw-bold' : 'text-muted' ?>">
|
||||
<?= $mail['due_date'] ?>
|
||||
</small>
|
||||
<?php else: ?>
|
||||
|
||||
@ -249,9 +249,9 @@ if ($type == 'internal') {
|
||||
<label class="text-muted small">الموعد النهائي</label>
|
||||
<p class="fw-bold">
|
||||
<?php if ($mail['due_date']): ?>
|
||||
<span class="<?= (strtotime($mail['due_date']) < time() && $mail['status_name'] != 'closed') ? 'text-danger' : '' ?>">
|
||||
<span class="<?= (strtotime($mail['due_date']) < time() && !in_array($mail['status_name'], ['closed', 'مكتمل', 'مؤرشف', 'مؤرشفة'])) ? 'text-danger' : '' ?>">
|
||||
<?= $mail['due_date'] ?>
|
||||
<?php if (strtotime($mail['due_date']) < time() && $mail['status_name'] != 'closed'): ?>
|
||||
<?php if (strtotime($mail['due_date']) < time() && !in_array($mail['status_name'], ['closed', 'مكتمل', 'مؤرشف', 'مؤرشفة'])): ?>
|
||||
<i class="fas fa-exclamation-triangle ms-1"></i>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user