157 lines
6.6 KiB
PHP
157 lines
6.6 KiB
PHP
<?php
|
|
session_start();
|
|
require_once __DIR__ . '/db/config.php';
|
|
require_once __DIR__ . '/includes/permissions.php';
|
|
require_once __DIR__ . '/includes/settings.php';
|
|
|
|
if (!isLoggedIn() || !canView('committees')) {
|
|
exit("لا توجد صلاحية للوصول لهذه الصفحة.");
|
|
}
|
|
|
|
$settings = get_settings();
|
|
$db = db();
|
|
|
|
$committee_id = $_GET['committee_id'] ?? null;
|
|
|
|
// Build query for activities
|
|
$query = "
|
|
SELECT
|
|
a.id, a.title, a.description, a.activity_date, a.location,
|
|
c.name as committee_name
|
|
FROM committee_activities a
|
|
JOIN committees c ON a.committee_id = c.id
|
|
";
|
|
$params = [];
|
|
|
|
if (!isAdmin()) {
|
|
// Only activities from committees the user is a member of
|
|
$query .= "
|
|
JOIN committee_members m ON c.id = m.committee_id
|
|
JOIN charity_members cm ON m.charity_member_id = cm.id
|
|
JOIN users u ON (u.id = cm.user_id) OR (cm.email != '' AND cm.email = u.email) OR (cm.name = u.full_name) OR (cm.name = u.username)
|
|
WHERE u.id = ?
|
|
";
|
|
$params[] = $_SESSION['user_id'];
|
|
|
|
if ($committee_id) {
|
|
$query .= " AND c.id = ?";
|
|
$params[] = $committee_id;
|
|
}
|
|
} else {
|
|
if ($committee_id) {
|
|
$query .= " WHERE c.id = ?";
|
|
$params[] = $committee_id;
|
|
}
|
|
}
|
|
|
|
$query .= " ORDER BY a.activity_date DESC, c.name ASC";
|
|
|
|
$stmt = $db->prepare($query);
|
|
$stmt->execute($params);
|
|
$activities = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
$report_title = "تقرير الأنشطة والفعاليات";
|
|
if ($committee_id) {
|
|
$stmt_c = $db->prepare("SELECT name FROM committees WHERE id = ?");
|
|
$stmt_c->execute([$committee_id]);
|
|
$committee_name = $stmt_c->fetchColumn();
|
|
if ($committee_name) {
|
|
$report_title .= " - لجنة " . htmlspecialchars($committee_name);
|
|
}
|
|
}
|
|
?>
|
|
<!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($report_title) ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.rtl.min.css" rel="stylesheet">
|
|
<style>
|
|
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700&display=swap');
|
|
body { font-family: 'Tajawal', sans-serif; background-color: #fff; color: #000; }
|
|
.print-header { border-bottom: 2px solid #333; padding-bottom: 20px; margin-bottom: 30px; display: flex; justify-content: space-between; align-items: center; }
|
|
.print-logo { max-height: 80px; }
|
|
table { width: 100%; margin-top: 15px; margin-bottom: 15px; border-collapse: collapse; }
|
|
th, td { border: 1px solid #dee2e6; padding: 12px 8px; text-align: right; vertical-align: top; }
|
|
th { background-color: #f1f3f5; font-weight: bold; }
|
|
.badge-date { background-color: #e9ecef; border: 1px solid #ccc; padding: 4px 8px; border-radius: 4px; font-size: 0.9em; white-space: nowrap; }
|
|
@media print {
|
|
body { margin: 0; padding: 0; }
|
|
.btn-print { display: none !important; }
|
|
@page { margin: 1cm; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container py-4">
|
|
<!-- Print Button -->
|
|
<div class="text-start mb-4 btn-print">
|
|
<button onclick="window.print()" class="btn btn-primary"><i class="fas fa-print me-2"></i> طباعة التقرير</button>
|
|
<button onclick="window.close()" class="btn btn-secondary">إغلاق</button>
|
|
</div>
|
|
|
|
<!-- Header -->
|
|
<div class="print-header">
|
|
<div>
|
|
<h2 class="mb-1 fw-bold"><?= htmlspecialchars($settings['site_name'] ?? '') ?></h2>
|
|
<p class="mb-0 text-muted fs-5"><?= $report_title ?></p>
|
|
<small>تاريخ التقرير: <?= date('Y-m-d') ?></small>
|
|
</div>
|
|
<div>
|
|
<?php if (!empty($settings['site_logo'])): ?>
|
|
<img src="<?= htmlspecialchars($settings['site_logo'] ?? '') ?>" class="print-logo" alt="Logo">
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<h3 class="text-center text-decoration-underline mb-4 fw-bold">سجل الأنشطة والفعاليات المنجزة</h3>
|
|
|
|
<?php if (empty($activities)): ?>
|
|
<div class="alert alert-info text-center">لا توجد أنشطة مسجلة في هذا التقرير.</div>
|
|
<?php else: ?>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th style="width: 50px; text-align: center;">م</th>
|
|
<?php if (!$committee_id): ?>
|
|
<th style="width: 150px;">اللجنة</th>
|
|
<?php endif; ?>
|
|
<th style="width: 250px;">اسم النشاط</th>
|
|
<th>الوصف والتفاصيل</th>
|
|
<th style="width: 120px;">التاريخ</th>
|
|
<th style="width: 150px;">الموقع</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($activities as $index => $a): ?>
|
|
<tr>
|
|
<td style="text-align: center;"><?= $index + 1 ?></td>
|
|
<?php if (!$committee_id): ?>
|
|
<td><strong><?= htmlspecialchars($a['committee_name'] ?? '') ?></strong></td>
|
|
<?php endif; ?>
|
|
<td class="fw-bold" style="color: #0d6efd;"><?= htmlspecialchars($a['title'] ?? '') ?></td>
|
|
<td><?= nl2br(htmlspecialchars($a['description'] ?? '')) ?: '<span class="text-muted fst-italic">لا يوجد وصف</span>' ?></td>
|
|
<td><span class="badge-date"><i class="far fa-calendar-alt me-1"></i> <?= htmlspecialchars($a['activity_date'] ?? '') ?></span></td>
|
|
<td><?= htmlspecialchars($a['location'] ?? '') ?: '<span class="text-muted">-</span>' ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php endif; ?>
|
|
|
|
<!-- Footer -->
|
|
<div class="mt-5 pt-3 border-top text-center text-muted small">
|
|
هذا التقرير معتمد ومستخرج آلياً من نظام الإدارة - <?= htmlspecialchars($settings['site_name'] ?? '') ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Font Awesome for icons -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
|
|
<script>
|
|
// window.onload = function() { window.print(); }
|
|
</script>
|
|
</body>
|
|
</html>
|