charity update
This commit is contained in:
parent
2603d90a7f
commit
f53406cd95
@ -522,3 +522,4 @@ body {
|
||||
color: #fff;
|
||||
}
|
||||
.group-meetings { color: #20c997 !important; } /* Teal */
|
||||
.group-committees { color: #8e24aa !important; } /* Purple */
|
||||
|
||||
260
charity_members.php
Normal file
260
charity_members.php
Normal file
@ -0,0 +1,260 @@
|
||||
<?php
|
||||
require_once 'includes/header.php';
|
||||
|
||||
if (!isAdmin() && !canView('committees')) {
|
||||
echo "<div class='alert alert-danger'>غير مصرح لك بالوصول لهذه الصفحة.</div>";
|
||||
require_once 'includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
$action = $_GET['action'] ?? 'list';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['add_member']) && (isAdmin() || canAdd('committees'))) {
|
||||
$name = $_POST['name'] ?? '';
|
||||
$role = $_POST['role'] ?? '';
|
||||
$phone = $_POST['phone'] ?? '';
|
||||
$email = $_POST['email'] ?? '';
|
||||
$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]);
|
||||
|
||||
$_SESSION['success'] = "تمت إضافة العضو بنجاح.";
|
||||
redirect('charity_members.php');
|
||||
} elseif (isset($_POST['edit_member']) && (isAdmin() || canEdit('committees'))) {
|
||||
$id = $_POST['id'];
|
||||
$name = $_POST['name'] ?? '';
|
||||
$role = $_POST['role'] ?? '';
|
||||
$phone = $_POST['phone'] ?? '';
|
||||
$email = $_POST['email'] ?? '';
|
||||
$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]);
|
||||
|
||||
$_SESSION['success'] = "تم تحديث العضو بنجاح.";
|
||||
redirect('charity_members.php');
|
||||
} elseif (isset($_POST['delete_member']) && (isAdmin() || canDelete('committees'))) {
|
||||
$id = $_POST['id'];
|
||||
$stmt = db()->prepare("DELETE FROM charity_members WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
|
||||
$_SESSION['success'] = "تم حذف العضو بنجاح.";
|
||||
redirect('charity_members.php');
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch members
|
||||
$stmt = db()->query("SELECT * FROM charity_members ORDER BY name ASC");
|
||||
$members = $stmt->fetchAll();
|
||||
?>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="h4 mb-0"><i class="fas fa-users text-primary me-2"></i> أعضاء الجمعية</h2>
|
||||
<?php if (isAdmin() || canAdd('committees')): ?>
|
||||
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addMemberModal">
|
||||
<i class="fas fa-plus me-2"></i> إضافة عضو جديد
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (isset($_SESSION['success'])): ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= htmlspecialchars($_SESSION['success']) ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php unset($_SESSION['success']); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>الاسم</th>
|
||||
<th>الدور/الصفة</th>
|
||||
<th>رقم الجوال</th>
|
||||
<th>البريد الإلكتروني</th>
|
||||
<th>تاريخ الانضمام</th>
|
||||
<th>الحالة</th>
|
||||
<th class="text-end">الإجراءات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($members as $member): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="bg-primary bg-opacity-10 text-primary rounded-circle d-flex align-items-center justify-content-center me-3" style="width: 40px; height: 40px;">
|
||||
<i class="fas fa-user"></i>
|
||||
</div>
|
||||
<div>
|
||||
<div class="fw-bold"><?= htmlspecialchars($member['name']) ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td><?= htmlspecialchars($member['role']) ?></td>
|
||||
<td><?= htmlspecialchars($member['phone']) ?></td>
|
||||
<td><?= htmlspecialchars($member['email']) ?></td>
|
||||
<td><?= htmlspecialchars($member['join_date']) ?></td>
|
||||
<td>
|
||||
<?php if ($member['status'] === 'active'): ?>
|
||||
<span class="badge bg-success bg-opacity-10 text-success px-3 py-2 rounded-pill">نشط</span>
|
||||
<?php else: ?>
|
||||
<span class="badge bg-secondary bg-opacity-10 text-secondary px-3 py-2 rounded-pill">غير نشط</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<?php if (isAdmin() || canEdit('committees')): ?>
|
||||
<button class="btn btn-sm btn-outline-primary me-2" data-bs-toggle="modal" data-bs-target="#editMemberModal<?= $member['id'] ?>">
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (isAdmin() || canDelete('committees')): ?>
|
||||
<button class="btn btn-sm btn-outline-danger" data-bs-toggle="modal" data-bs-target="#deleteMemberModal<?= $member['id'] ?>">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Edit Modal -->
|
||||
<div class="modal fade" id="editMemberModal<?= $member['id'] ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content border-0 shadow">
|
||||
<div class="modal-header bg-light">
|
||||
<h5 class="modal-title">تعديل بيانات العضو</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<form method="POST">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="id" value="<?= $member['id'] ?>">
|
||||
<input type="hidden" name="edit_member" value="1">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الاسم</label>
|
||||
<input type="text" class="form-control" name="name" value="<?= htmlspecialchars($member['name']) ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الدور/الصفة في الجمعية</label>
|
||||
<input type="text" class="form-control" name="role" value="<?= htmlspecialchars($member['role']) ?>" placeholder="مثال: عضو مجلس الإدارة، مدير عام...">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">رقم الجوال</label>
|
||||
<input type="text" class="form-control" name="phone" value="<?= htmlspecialchars($member['phone']) ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">البريد الإلكتروني</label>
|
||||
<input type="email" class="form-control" name="email" value="<?= htmlspecialchars($member['email']) ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">تاريخ الانضمام</label>
|
||||
<input type="date" class="form-control" name="join_date" value="<?= htmlspecialchars($member['join_date']) ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الحالة</label>
|
||||
<select class="form-select" name="status">
|
||||
<option value="active" <?= $member['status'] == 'active' ? 'selected' : '' ?>>نشط</option>
|
||||
<option value="inactive" <?= $member['status'] == 'inactive' ? 'selected' : '' ?>>غير نشط</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-primary">حفظ التغييرات</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete Modal -->
|
||||
<div class="modal fade" id="deleteMemberModal<?= $member['id'] ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content border-0 shadow">
|
||||
<div class="modal-header bg-light">
|
||||
<h5 class="modal-title">تأكيد الحذف</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body text-center p-4">
|
||||
<i class="fas fa-exclamation-triangle text-danger fa-3x mb-3"></i>
|
||||
<h4 class="mb-3">هل أنت متأكد؟</h4>
|
||||
<p class="text-muted">هل تريد حقاً حذف العضو "<?= htmlspecialchars($member['name']) ?>"؟ لا يمكن التراجع عن هذا الإجراء وسيتم حذفه من أي لجان مرتبط بها.</p>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-center border-0">
|
||||
<form method="POST">
|
||||
<input type="hidden" name="id" value="<?= $member['id'] ?>">
|
||||
<input type="hidden" name="delete_member" value="1">
|
||||
<button type="button" class="btn btn-light px-4" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-danger px-4">نعم، احذف</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($members)): ?>
|
||||
<tr>
|
||||
<td colspan="7" class="text-center text-muted py-4">لا يوجد أعضاء مضافين حتى الآن</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Modal -->
|
||||
<div class="modal fade" id="addMemberModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content border-0 shadow">
|
||||
<div class="modal-header bg-light">
|
||||
<h5 class="modal-title">إضافة عضو جديد</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<form method="POST">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="add_member" value="1">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الاسم</label>
|
||||
<input type="text" class="form-control" name="name" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الدور/الصفة في الجمعية</label>
|
||||
<input type="text" class="form-control" name="role" placeholder="مثال: عضو مجلس الإدارة، مدير عام...">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">رقم الجوال</label>
|
||||
<input type="text" class="form-control" name="phone">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">البريد الإلكتروني</label>
|
||||
<input type="email" class="form-control" name="email">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">تاريخ الانضمام</label>
|
||||
<input type="date" class="form-control" name="join_date" value="<?= date('Y-m-d') ?>">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الحالة</label>
|
||||
<select class="form-select" name="status">
|
||||
<option value="active">نشط</option>
|
||||
<option value="inactive">غير نشط</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-primary">إضافة العضو</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once 'includes/footer.php'; ?>
|
||||
357
charity_plans.php
Normal file
357
charity_plans.php
Normal file
@ -0,0 +1,357 @@
|
||||
<?php
|
||||
require_once 'includes/header.php';
|
||||
|
||||
if (!isAdmin() && !canView('committees')) {
|
||||
echo "<div class='alert alert-danger'>غير مصرح لك بالوصول لهذه الصفحة.</div>";
|
||||
require_once 'includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['add_plan']) && (isAdmin() || canAdd('committees'))) {
|
||||
$title = $_POST['title'];
|
||||
$description = $_POST['description'] ?? '';
|
||||
$start_date = $_POST['start_date'] ?? date('Y-m-d');
|
||||
$end_date = $_POST['end_date'] ?? date('Y-m-d', strtotime('+1 month'));
|
||||
$target_value = (int)$_POST['target_value'];
|
||||
$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]);
|
||||
$_SESSION['success'] = "تمت إضافة الخطة بنجاح.";
|
||||
redirect('charity_plans.php');
|
||||
} elseif (isset($_POST['edit_plan']) && (isAdmin() || canEdit('committees'))) {
|
||||
$id = $_POST['id'];
|
||||
$title = $_POST['title'];
|
||||
$description = $_POST['description'] ?? '';
|
||||
$start_date = $_POST['start_date'] ?? date('Y-m-d');
|
||||
$end_date = $_POST['end_date'] ?? date('Y-m-d');
|
||||
$target_value = (int)$_POST['target_value'];
|
||||
$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]);
|
||||
$_SESSION['success'] = "تم تحديث الخطة بنجاح.";
|
||||
redirect('charity_plans.php');
|
||||
} elseif (isset($_POST['delete_plan']) && (isAdmin() || canDelete('committees'))) {
|
||||
$id = $_POST['id'];
|
||||
$stmt = db()->prepare("DELETE FROM charity_plans WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$_SESSION['success'] = "تم حذف الخطة بنجاح.";
|
||||
redirect('charity_plans.php');
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = db()->query("SELECT * FROM charity_plans ORDER BY created_at DESC");
|
||||
$plans = $stmt->fetchAll();
|
||||
|
||||
$total_plans = count($plans);
|
||||
$completed_plans = 0;
|
||||
$total_target = 0;
|
||||
$total_achieved = 0;
|
||||
|
||||
foreach ($plans as $plan) {
|
||||
if ($plan['status'] === 'completed') {
|
||||
$completed_plans++;
|
||||
}
|
||||
$total_target += $plan['target_value'];
|
||||
$total_achieved += $plan['achieved_value'];
|
||||
}
|
||||
|
||||
$completion_rate = $total_plans > 0 ? round(($completed_plans / $total_plans) * 100) : 0;
|
||||
$kpi_score = $total_target > 0 ? min(100, round(($total_achieved / $total_target) * 100)) : 0;
|
||||
$overall_score = round(($completion_rate * 0.4) + ($kpi_score * 0.6));
|
||||
|
||||
$status_colors = [
|
||||
'pending' => 'secondary',
|
||||
'in_progress' => 'warning',
|
||||
'completed' => 'success',
|
||||
'cancelled' => 'danger'
|
||||
];
|
||||
$status_labels = [
|
||||
'pending' => 'قيد الانتظار',
|
||||
'in_progress' => 'قيد التنفيذ',
|
||||
'completed' => 'مكتمل',
|
||||
'cancelled' => 'ملغي'
|
||||
];
|
||||
?>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h2 class="h4 mb-0"><i class="fas fa-chart-line text-success me-2"></i> خطط وتقييم الجمعية (KPI)</h2>
|
||||
<?php if (isAdmin() || canAdd('committees')): ?>
|
||||
<button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#addPlanModal">
|
||||
<i class="fas fa-plus me-2"></i> إضافة خطة/هدف جديد
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if (isset($_SESSION['success'])): ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= htmlspecialchars($_SESSION['success']) ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php unset($_SESSION['success']); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- KPI Dashboard -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-4 mb-3 mb-md-0">
|
||||
<div class="card border-0 shadow-sm h-100 bg-primary text-white text-center p-4">
|
||||
<h5 class="opacity-75">التقييم العام للجمعية</h5>
|
||||
<h1 class="display-3 fw-bold mb-0"><?= $overall_score ?>%</h1>
|
||||
<div class="mt-3">
|
||||
<?php if ($overall_score >= 85): ?>
|
||||
<i class="fas fa-medal fa-2x text-warning"></i> <span class="ms-2">أداء متميز</span>
|
||||
<?php elseif ($overall_score >= 60): ?>
|
||||
<i class="fas fa-thumbs-up fa-2x text-info"></i> <span class="ms-2">أداء جيد</span>
|
||||
<?php else: ?>
|
||||
<i class="fas fa-exclamation-circle fa-2x text-danger"></i> <span class="ms-2">بحاجة لتحسين</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 mb-3 mb-md-0">
|
||||
<div class="card border-0 shadow-sm h-100 text-center p-4">
|
||||
<h5 class="text-muted">معدل الإنجاز (المستهدف)</h5>
|
||||
<div class="position-relative mx-auto mt-3" style="width: 120px; height: 120px;">
|
||||
<svg viewBox="0 0 36 36" class="circular-chart text-success" style="width: 100%; height: 100%;">
|
||||
<path class="circle-bg" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="#eee" stroke-width="3"/>
|
||||
<path class="circle" stroke-dasharray="<?= $kpi_score ?>, 100" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="currentColor" stroke-width="3" />
|
||||
<text x="18" y="20.35" class="percentage" font-size="8" text-anchor="middle" fill="currentColor"><?= $kpi_score ?>%</text>
|
||||
</svg>
|
||||
</div>
|
||||
<p class="small text-muted mt-2">إجمالي المحقق: <?= $total_achieved ?> من <?= $total_target ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card border-0 shadow-sm h-100 text-center p-4">
|
||||
<h5 class="text-muted">إنجاز الخطط (الحالة)</h5>
|
||||
<div class="position-relative mx-auto mt-3" style="width: 120px; height: 120px;">
|
||||
<svg viewBox="0 0 36 36" class="circular-chart text-info" style="width: 100%; height: 100%;">
|
||||
<path class="circle-bg" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="#eee" stroke-width="3"/>
|
||||
<path class="circle" stroke-dasharray="<?= $completion_rate ?>, 100" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="currentColor" stroke-width="3" />
|
||||
<text x="18" y="20.35" class="percentage" font-size="8" text-anchor="middle" fill="currentColor"><?= $completion_rate ?>%</text>
|
||||
</svg>
|
||||
</div>
|
||||
<p class="small text-muted mt-2">خطط مكتملة: <?= $completed_plans ?> من <?= $total_plans ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Plans List -->
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-header bg-white border-bottom-0 pt-4 pb-0">
|
||||
<h5 class="mb-0">سجل الخطط والأهداف</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>عنوان الخطة / الهدف</th>
|
||||
<th>الفترة</th>
|
||||
<th>المستهدف</th>
|
||||
<th>المحقق</th>
|
||||
<th>النسبة</th>
|
||||
<th>الحالة</th>
|
||||
<th class="text-end">الإجراءات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($plans as $plan):
|
||||
$plan_rate = $plan['target_value'] > 0 ? min(100, round(($plan['achieved_value'] / $plan['target_value']) * 100)) : 0;
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="fw-bold"><?= htmlspecialchars($plan['title']) ?></div>
|
||||
<div class="small text-muted text-truncate" style="max-width: 250px;"><?= htmlspecialchars($plan['description']) ?></div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="small"><i class="fas fa-calendar-alt text-muted me-1"></i> من: <?= $plan['start_date'] ?></div>
|
||||
<div class="small"><i class="fas fa-flag-checkered text-muted me-1"></i> إلى: <?= $plan['end_date'] ?></div>
|
||||
</td>
|
||||
<td class="fw-bold"><?= number_format($plan['target_value']) ?></td>
|
||||
<td class="fw-bold text-success"><?= number_format($plan['achieved_value']) ?></td>
|
||||
<td>
|
||||
<div class="progress" style="height: 8px; width: 80px;" title="<?= $plan_rate ?>%">
|
||||
<div class="progress-bar bg-success" role="progressbar" style="width: <?= $plan_rate ?>%"></div>
|
||||
</div>
|
||||
<div class="small text-muted mt-1"><?= $plan_rate ?>%</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-<?= $status_colors[$plan['status']] ?> bg-opacity-10 text-<?= $status_colors[$plan['status']] ?> px-3 py-2 rounded-pill">
|
||||
<?= $status_labels[$plan['status']] ?>
|
||||
</span>
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<?php if (isAdmin() || canEdit('committees')): ?>
|
||||
<button class="btn btn-sm btn-outline-primary me-2" data-bs-toggle="modal" data-bs-target="#editPlanModal<?= $plan['id'] ?>">
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (isAdmin() || canDelete('committees')): ?>
|
||||
<button class="btn btn-sm btn-outline-danger" data-bs-toggle="modal" data-bs-target="#deletePlanModal<?= $plan['id'] ?>">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Edit Modal -->
|
||||
<div class="modal fade" id="editPlanModal<?= $plan['id'] ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content border-0 shadow">
|
||||
<div class="modal-header bg-light">
|
||||
<h5 class="modal-title">تحديث الخطة والهدف</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<form method="POST">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="id" value="<?= $plan['id'] ?>">
|
||||
<input type="hidden" name="edit_plan" value="1">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">العنوان</label>
|
||||
<input type="text" class="form-control" name="title" value="<?= htmlspecialchars($plan['title']) ?>" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الوصف</label>
|
||||
<textarea class="form-control" name="description" rows="2"><?= htmlspecialchars($plan['description']) ?></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">تاريخ البداية</label>
|
||||
<input type="date" class="form-control" name="start_date" value="<?= $plan['start_date'] ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">تاريخ النهاية المتوقع</label>
|
||||
<input type="date" class="form-control" name="end_date" value="<?= $plan['end_date'] ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">الرقم المستهدف (KPI)</label>
|
||||
<input type="number" class="form-control" name="target_value" value="<?= $plan['target_value'] ?>" required min="1">
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">الرقم المحقق الفعلي</label>
|
||||
<input type="number" class="form-control" name="achieved_value" value="<?= $plan['achieved_value'] ?>" required min="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الحالة</label>
|
||||
<select class="form-select" name="status">
|
||||
<?php foreach ($status_labels as $k => $v): ?>
|
||||
<option value="<?= $k ?>" <?= $plan['status'] == $k ? 'selected' : '' ?>><?= $v ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-primary">حفظ التحديث</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete Modal -->
|
||||
<div class="modal fade" id="deletePlanModal<?= $plan['id'] ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content border-0 shadow">
|
||||
<div class="modal-header bg-light">
|
||||
<h5 class="modal-title">تأكيد الحذف</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body text-center p-4">
|
||||
<i class="fas fa-exclamation-triangle text-danger fa-3x mb-3"></i>
|
||||
<h4 class="mb-3">هل أنت متأكد؟</h4>
|
||||
<p class="text-muted">لن تتمكن من استعادة هذه الخطة بعد حذفها.</p>
|
||||
</div>
|
||||
<div class="modal-footer justify-content-center border-0">
|
||||
<form method="POST">
|
||||
<input type="hidden" name="id" value="<?= $plan['id'] ?>">
|
||||
<input type="hidden" name="delete_plan" value="1">
|
||||
<button type="button" class="btn btn-light px-4" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-danger px-4">نعم، احذف</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php if (empty($plans)): ?>
|
||||
<tr>
|
||||
<td colspan="7" class="text-center text-muted py-4">لا توجد خطط مضافة حتى الآن</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Modal -->
|
||||
<div class="modal fade" id="addPlanModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content border-0 shadow">
|
||||
<div class="modal-header bg-light">
|
||||
<h5 class="modal-title">إضافة خطة/هدف جديد</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<form method="POST">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="add_plan" value="1">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">العنوان</label>
|
||||
<input type="text" class="form-control" name="title" required placeholder="مثال: كفالة 100 يتيم خلال العام">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الوصف</label>
|
||||
<textarea class="form-control" name="description" rows="2"></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">تاريخ البداية</label>
|
||||
<input type="date" class="form-control" name="start_date" value="<?= date('Y-m-d') ?>" required>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">تاريخ النهاية المتوقع</label>
|
||||
<input type="date" class="form-control" name="end_date" value="<?= date('Y-m-d', strtotime('+1 year')) ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">الرقم المستهدف (KPI)</label>
|
||||
<input type="number" class="form-control" name="target_value" value="100" required min="1">
|
||||
<div class="form-text">مثال: 100 (للتعبير عن 100 يتيم أو 100%)</div>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">الرقم المحقق الفعلي</label>
|
||||
<input type="number" class="form-control" name="achieved_value" value="0" required min="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">الحالة</label>
|
||||
<select class="form-select" name="status">
|
||||
<option value="pending">قيد الانتظار</option>
|
||||
<option value="in_progress">قيد التنفيذ</option>
|
||||
<option value="completed">مكتمل</option>
|
||||
<option value="cancelled">ملغي</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-light" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-primary">إضافة الخطة</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once 'includes/footer.php'; ?>
|
||||
211
committee_reports.php
Normal file
211
committee_reports.php
Normal file
@ -0,0 +1,211 @@
|
||||
<?php
|
||||
require_once 'includes/header.php';
|
||||
|
||||
if (!canView('committees')) {
|
||||
echo "<div class='alert alert-danger'>لا توجد صلاحية للوصول لهذه الصفحة.</div>";
|
||||
require_once 'includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// Fetch all committees and calculate stats
|
||||
$stmt = db()->query("
|
||||
SELECT
|
||||
c.id, c.name,
|
||||
(SELECT COUNT(*) FROM committee_members WHERE committee_id = c.id) as members_count,
|
||||
(SELECT COUNT(*) FROM committee_plans WHERE committee_id = c.id) as total_plans,
|
||||
(SELECT COUNT(*) FROM committee_plans WHERE committee_id = c.id AND status = 'completed') as completed_plans,
|
||||
(SELECT COUNT(*) FROM committee_activities WHERE committee_id = c.id) as activities_count
|
||||
FROM committees c
|
||||
ORDER BY c.name ASC
|
||||
");
|
||||
$committees = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Overall stats
|
||||
$total_committees = count($committees);
|
||||
$total_members = 0;
|
||||
$total_plans = 0;
|
||||
$total_completed = 0;
|
||||
$total_activities = 0;
|
||||
|
||||
foreach ($committees as &$c) {
|
||||
$total_members += $c['members_count'];
|
||||
$total_plans += $c['total_plans'];
|
||||
$total_completed += $c['completed_plans'];
|
||||
$total_activities += $c['activities_count'];
|
||||
|
||||
// Calculate performance score (smart assessment)
|
||||
// Score based on: Completed plans (weight 60%) + Activities done (weight 40%)
|
||||
// Let's make a simple normalized score out of 100 for visual assessment
|
||||
$plan_completion_rate = $c['total_plans'] > 0 ? ($c['completed_plans'] / $c['total_plans']) * 100 : 0;
|
||||
|
||||
// Assume an "active" committee should have at least 1 activity per month (say 5 is a good baseline for 100% activity score)
|
||||
$activity_score = min(100, $c['activities_count'] * 20);
|
||||
|
||||
// Final composite score
|
||||
$score = ($plan_completion_rate * 0.6) + ($activity_score * 0.4);
|
||||
$c['score'] = $score;
|
||||
|
||||
// Determine badge
|
||||
if ($score >= 80) {
|
||||
$c['badge'] = '<span class="badge bg-success">ممتاز</span>';
|
||||
$c['color'] = 'success';
|
||||
} elseif ($score >= 50) {
|
||||
$c['badge'] = '<span class="badge bg-primary">جيد</span>';
|
||||
$c['color'] = 'primary';
|
||||
} elseif ($score > 0) {
|
||||
$c['badge'] = '<span class="badge bg-warning text-dark">يحتاج تحسين</span>';
|
||||
$c['color'] = 'warning';
|
||||
} else {
|
||||
$c['badge'] = '<span class="badge bg-danger">غير نشط</span>';
|
||||
$c['color'] = 'danger';
|
||||
}
|
||||
}
|
||||
unset($c);
|
||||
|
||||
// Sort by score descending to rank them
|
||||
usort($committees, function($a, $b) {
|
||||
return $b['score'] <=> $a['score'];
|
||||
});
|
||||
|
||||
?>
|
||||
|
||||
<div class="container-fluid py-4">
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h4 class="mb-0"><i class="fas fa-chart-pie text-primary me-2"></i> تقييم وتقارير اللجان</h4>
|
||||
<div>
|
||||
<a href="print_committees_report.php" target="_blank" class="btn btn-outline-primary btn-sm me-2">
|
||||
<i class="fas fa-print me-1"></i> طباعة تقرير اللجان والأعضاء
|
||||
</a>
|
||||
<a href="committees.php" class="btn btn-outline-secondary btn-sm">
|
||||
<i class="fas fa-arrow-right me-1"></i> عودة لإدارة اللجان
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Overview Cards -->
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-md-3">
|
||||
<div class="card bg-primary text-white h-100 shadow-sm border-0">
|
||||
<div class="card-body d-flex flex-column justify-content-center align-items-center">
|
||||
<i class="fas fa-users fa-2x mb-2 opacity-75"></i>
|
||||
<h5 class="card-title">إجمالي اللجان</h5>
|
||||
<h2 class="mb-0 fw-bold"><?= $total_committees ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card bg-success text-white h-100 shadow-sm border-0">
|
||||
<div class="card-body d-flex flex-column justify-content-center align-items-center">
|
||||
<i class="fas fa-tasks fa-2x mb-2 opacity-75"></i>
|
||||
<h5 class="card-title">إنجاز الخطط</h5>
|
||||
<h2 class="mb-0 fw-bold">
|
||||
<?= $total_plans > 0 ? round(($total_completed / $total_plans) * 100) : 0 ?>%
|
||||
</h2>
|
||||
<small><?= $total_completed ?> من <?= $total_plans ?> خطة مكتملة</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card bg-info text-white h-100 shadow-sm border-0">
|
||||
<div class="card-body d-flex flex-column justify-content-center align-items-center">
|
||||
<i class="fas fa-calendar-check fa-2x mb-2 opacity-75"></i>
|
||||
<h5 class="card-title">إجمالي الأنشطة</h5>
|
||||
<h2 class="mb-0 fw-bold"><?= $total_activities ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card bg-warning text-dark h-100 shadow-sm border-0">
|
||||
<div class="card-body d-flex flex-column justify-content-center align-items-center">
|
||||
<i class="fas fa-user-friends fa-2x mb-2 opacity-75"></i>
|
||||
<h5 class="card-title">إجمالي الأعضاء</h5>
|
||||
<h2 class="mb-0 fw-bold"><?= $total_members ?></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Committees Ranking Table -->
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-header bg-white">
|
||||
<h5 class="mb-0"><i class="fas fa-trophy text-warning me-2"></i> ترتيب وتقييم أداء اللجان (الأعلى أداءً)</h5>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th class="ps-4">الترتيب</th>
|
||||
<th>اللجنة</th>
|
||||
<th class="text-center">الأعضاء</th>
|
||||
<th class="text-center">إنجاز الخطط</th>
|
||||
<th class="text-center">الأنشطة المنجزة</th>
|
||||
<th style="width: 250px;">مؤشر الأداء (KPI)</th>
|
||||
<th class="text-center">التقييم</th>
|
||||
<th class="pe-4"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (empty($committees)): ?>
|
||||
<tr><td colspan="8" class="text-center p-4">لا توجد لجان مضافة حتى الآن.</td></tr>
|
||||
<?php else: ?>
|
||||
<?php foreach ($committees as $index => $c): ?>
|
||||
<tr>
|
||||
<td class="ps-4">
|
||||
<?php if ($index == 0 && $c['score'] > 0): ?>
|
||||
<i class="fas fa-medal text-warning fa-2x"></i>
|
||||
<?php elseif ($index == 1 && $c['score'] > 0): ?>
|
||||
<i class="fas fa-medal text-secondary fa-2x"></i>
|
||||
<?php elseif ($index == 2 && $c['score'] > 0): ?>
|
||||
<i class="fas fa-medal fa-2x" style="color: #cd7f32;"></i>
|
||||
<?php else: ?>
|
||||
<span class="text-muted fw-bold ms-2">#<?= $index + 1 ?></span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="fw-bold fs-6"><?= htmlspecialchars($c['name']) ?></td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-light text-dark border p-2 rounded-circle fs-6"><?= $c['members_count'] ?></span>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<div class="d-inline-flex flex-column align-items-center w-75">
|
||||
<small class="mb-1"><?= $c['completed_plans'] ?> / <?= $c['total_plans'] ?></small>
|
||||
<div class="progress w-100" style="height: 6px;">
|
||||
<?php $plan_percent = $c['total_plans'] > 0 ? ($c['completed_plans'] / $c['total_plans']) * 100 : 0; ?>
|
||||
<div class="progress-bar bg-<?= $c['color'] ?>" role="progressbar" style="width: <?= $plan_percent ?>%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="badge bg-light text-dark border p-2 rounded-circle fs-6"><?= $c['activities_count'] ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="d-flex justify-content-between mb-1 align-items-center">
|
||||
<span class="text-muted small">نسبة الإنجاز:</span>
|
||||
<span class="fw-bold <?= 'text-' . $c['color'] ?>"><?= round($c['score']) ?>%</span>
|
||||
</div>
|
||||
<div class="progress shadow-sm" style="height: 10px; border-radius: 5px;">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated bg-<?= $c['color'] ?>" role="progressbar" style="width: <?= round($c['score']) ?>%"></div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?= $c['badge'] ?>
|
||||
</td>
|
||||
<td class="text-end pe-4">
|
||||
<a href="view_committee.php?id=<?= $c['id'] ?>" class="btn btn-sm btn-outline-primary rounded-pill px-3">
|
||||
<i class="fas fa-chart-line"></i> تقرير مفصل
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php require_once 'includes/footer.php'; ?>
|
||||
203
committees.php
Normal file
203
committees.php
Normal file
@ -0,0 +1,203 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
|
||||
if (!canView('committees')) {
|
||||
redirect('index.php');
|
||||
}
|
||||
|
||||
$error = '';
|
||||
$success = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['action'])) {
|
||||
$action = $_POST['action'];
|
||||
$id = $_POST['id'] ?? 0;
|
||||
$name = trim($_POST['name'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
|
||||
try {
|
||||
$db = db();
|
||||
if ($action === 'add' && canAdd('committees')) {
|
||||
if (empty($name)) {
|
||||
$_SESSION['error'] = 'اسم اللجنة مطلوب';
|
||||
} else {
|
||||
$stmt = $db->prepare("INSERT INTO committees (name, description) VALUES (?, ?)");
|
||||
$stmt->execute([$name, $description]);
|
||||
$_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]);
|
||||
$_SESSION['success'] = 'تم تحديث اللجنة بنجاح';
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$_SESSION['error'] = 'حدث خطأ: ' . $e->getMessage();
|
||||
}
|
||||
redirect('committees.php');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['action']) && $_GET['action'] === 'delete' && isset($_GET['id'])) {
|
||||
if (!canDelete('committees')) redirect('committees.php');
|
||||
$id = $_GET['id'];
|
||||
try {
|
||||
$db = db();
|
||||
$stmt = $db->prepare("DELETE FROM committees WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$_SESSION['success'] = 'تم حذف اللجنة بنجاح';
|
||||
} catch (PDOException $e) {
|
||||
$_SESSION['error'] = 'حدث خطأ: ' . $e->getMessage();
|
||||
}
|
||||
redirect('committees.php');
|
||||
}
|
||||
|
||||
$committees = db()->query("SELECT * FROM committees ORDER BY id DESC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (isset($_SESSION['success'])) {
|
||||
$success = $_SESSION['success'];
|
||||
unset($_SESSION['success']);
|
||||
}
|
||||
if (isset($_SESSION['error'])) {
|
||||
$error = $_SESSION['error'];
|
||||
unset($_SESSION['error']);
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">اللجان</h1>
|
||||
<?php if (canAdd('committees')): ?>
|
||||
<button type="button" class="btn btn-primary shadow-sm" onclick="openModal('add')">
|
||||
<i class="fas fa-plus"></i> إضافة لجنة جديدة
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($success): ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= $success ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= $error ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="ps-4" style="width: 80px;">الرقم</th>
|
||||
<th>اسم اللجنة</th>
|
||||
<th>الوصف</th>
|
||||
<th class="text-center">الإجراءات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (count($committees) > 0): ?>
|
||||
<?php foreach ($committees as $committee): ?>
|
||||
<tr>
|
||||
<td class="ps-4"><?= htmlspecialchars($committee['id']) ?></td>
|
||||
<td class="fw-bold"><?= htmlspecialchars($committee['name']) ?></td>
|
||||
<td><?= htmlspecialchars($committee['description'] ?? '') ?></td>
|
||||
<td class="text-center">
|
||||
<a href="view_committee.php?id=<?= $committee['id'] ?>" class="btn btn-sm btn-outline-info me-1" title="إدارة اللجنة"><i class="fas fa-cog"></i> إدارة</a>
|
||||
<?php if (canEdit('committees')): ?>
|
||||
<button class="btn btn-sm btn-outline-primary me-1" onclick='openModal("edit", <?= json_encode($committee, JSON_HEX_APOS | JSON_HEX_QUOT) ?>)'>
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (canDelete('committees')): ?>
|
||||
<a href="javascript:void(0)" onclick="confirmDelete(<?= $committee['id'] ?>)" class="btn btn-sm btn-outline-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="4" class="text-center py-4 text-muted">لا توجد لجان مضافة حتى الآن.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="committeeModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-primary text-white">
|
||||
<h5 class="modal-title" id="modalTitle">إضافة لجنة جديدة</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<form method="POST" action="committees.php">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="action" id="modalAction" value="add">
|
||||
<input type="hidden" name="id" id="modalId" value="0">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">اسم اللجنة <span class="text-danger">*</span></label>
|
||||
<input type="text" name="name" id="modalName" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">الوصف</label>
|
||||
<textarea name="description" id="modalDescription" class="form-control" rows="4"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-primary">حفظ</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let committeeModal;
|
||||
|
||||
function openModal(action, data = null) {
|
||||
if (!committeeModal) {
|
||||
committeeModal = new bootstrap.Modal(document.getElementById('committeeModal'));
|
||||
}
|
||||
|
||||
document.getElementById('modalAction').value = action;
|
||||
const title = document.getElementById('modalTitle');
|
||||
|
||||
if (action === 'add') {
|
||||
title.textContent = 'إضافة لجنة جديدة';
|
||||
document.getElementById('modalId').value = 0;
|
||||
document.getElementById('modalName').value = '';
|
||||
document.getElementById('modalDescription').value = '';
|
||||
} else {
|
||||
title.textContent = 'تعديل بيانات اللجنة';
|
||||
document.getElementById('modalId').value = data.id;
|
||||
document.getElementById('modalName').value = data.name;
|
||||
document.getElementById('modalDescription').value = data.description || '';
|
||||
}
|
||||
|
||||
committeeModal.show();
|
||||
}
|
||||
|
||||
function confirmDelete(id) {
|
||||
if (confirm('هل أنت متأكد من حذف هذه اللجنة؟ لا يمكن التراجع عن هذا الإجراء.')) {
|
||||
window.location.href = 'committees.php?action=delete&id=' + id;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
7
db/migrations/030_add_committees_module.sql
Normal file
7
db/migrations/030_add_committees_module.sql
Normal file
@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS `committees` (
|
||||
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`description` TEXT,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
35
db/migrations/031_add_committee_details.sql
Normal file
35
db/migrations/031_add_committee_details.sql
Normal file
@ -0,0 +1,35 @@
|
||||
CREATE TABLE IF NOT EXISTS committee_members (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
committee_id INT NOT NULL,
|
||||
user_id INT NOT NULL,
|
||||
role VARCHAR(100) DEFAULT 'عضو',
|
||||
joined_at DATE,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (committee_id) REFERENCES committees(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
UNIQUE KEY unique_member (committee_id, user_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS committee_plans (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
committee_id INT NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
start_date DATE,
|
||||
end_date DATE,
|
||||
status ENUM('pending', 'in_progress', 'completed', 'cancelled') DEFAULT 'pending',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (committee_id) REFERENCES committees(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS committee_activities (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
committee_id INT NOT NULL,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
activity_date DATE,
|
||||
location VARCHAR(255),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (committee_id) REFERENCES committees(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
38
db/migrations/032_add_charity_members_plans.sql
Normal file
38
db/migrations/032_add_charity_members_plans.sql
Normal file
@ -0,0 +1,38 @@
|
||||
CREATE TABLE IF NOT EXISTS charity_members (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
role VARCHAR(100),
|
||||
phone VARCHAR(50),
|
||||
email VARCHAR(100),
|
||||
join_date DATE,
|
||||
status ENUM('active', 'inactive') DEFAULT 'active',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS charity_plans (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
description TEXT,
|
||||
start_date DATE,
|
||||
end_date DATE,
|
||||
target_value INT DEFAULT 100,
|
||||
achieved_value INT DEFAULT 0,
|
||||
status ENUM('pending', 'in_progress', 'completed', 'cancelled') DEFAULT 'pending',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
DROP TABLE IF EXISTS committee_members;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS committee_members (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
committee_id INT NOT NULL,
|
||||
charity_member_id INT NOT NULL,
|
||||
role VARCHAR(100) DEFAULT 'عضو',
|
||||
joined_at DATE,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (committee_id) REFERENCES committees(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (charity_member_id) REFERENCES charity_members(id) ON DELETE CASCADE,
|
||||
UNIQUE KEY unique_member (committee_id, charity_member_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
@ -1,6 +1,12 @@
|
||||
<?php
|
||||
require_once 'includes/header.php';
|
||||
require 'vendor/autoload.php';
|
||||
$autoloadPath = __DIR__ . '/vendor/autoload.php';
|
||||
if (!file_exists($autoloadPath)) {
|
||||
echo "<div class='container mt-5'><div class='alert alert-danger shadow-sm border-0 border-start border-danger border-4'><i class='fas fa-exclamation-triangle me-2'></i> <strong>خطأ:</strong> مجلد <code>vendor</code> غير موجود على الاستضافة. يرجى التأكد من رفع مجلد المكتبات (vendor) مع باقي ملفات النظام، أو تنفيذ أمر <code>composer install</code> إذا كنت تستخدم سطر الأوامر.</div></div>";
|
||||
require_once 'includes/footer.php';
|
||||
exit;
|
||||
}
|
||||
require $autoloadPath;
|
||||
|
||||
use Rats\Zkteco\Lib\ZKTeco;
|
||||
|
||||
|
||||
@ -73,6 +73,13 @@ $is_stock_open = in_array($cp, $stock_pages);
|
||||
$expenses_pages = ['expenses.php', 'expense_categories.php', 'expense_reports.php'];
|
||||
$is_expenses_open = in_array($cp, $expenses_pages);
|
||||
|
||||
$charity_pages = ['charity_members.php', 'charity_plans.php'];
|
||||
$is_charity_open = in_array($cp, $charity_pages);
|
||||
|
||||
$committees_pages = ["committees.php", "view_committee.php", "committee_reports.php", "print_committees_report.php"];
|
||||
$is_committees_open = in_array($cp, $committees_pages);
|
||||
|
||||
|
||||
$meetings_pages = ['meetings.php'];
|
||||
$is_meetings_open = in_array($cp, $meetings_pages);
|
||||
|
||||
@ -470,6 +477,59 @@ $is_admin_open = in_array($cp, $admin_pages);
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<!-- Charity Group -->
|
||||
<?php if (canView('committees') || isAdmin()): ?>
|
||||
<li class="nav-item">
|
||||
<button class="sidebar-group-btn <?= $is_charity_open ? '' : 'collapsed' ?>" type="button" data-bs-toggle="collapse" data-bs-target="#menu-charity" aria-expanded="<?= $is_charity_open ? 'true' : 'false' ?>">
|
||||
<span class="group-content group-charity" style="color: #20c997;">
|
||||
<i class="fas fa-hand-holding-heart"></i> الجمعية
|
||||
</span>
|
||||
<i class="fas fa-chevron-down arrow-icon"></i>
|
||||
</button>
|
||||
<div class="collapse <?= $is_charity_open ? 'show' : '' ?>" id="menu-charity">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?= $cp == 'charity_members.php' ? 'active' : '' ?>" href="charity_members.php">
|
||||
أعضاء الجمعية
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?= $cp == 'charity_plans.php' ? 'active' : '' ?>" href="charity_plans.php">
|
||||
خطط وتقييم الجمعية
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Committees Group -->
|
||||
<?php if (canView('committees') || isAdmin()): ?>
|
||||
<li class="nav-item">
|
||||
<button class="sidebar-group-btn <?= $is_committees_open ? '' : 'collapsed' ?>" type="button" data-bs-toggle="collapse" data-bs-target="#menu-committees" aria-expanded="<?= $is_committees_open ? 'true' : 'false' ?>">
|
||||
<span class="group-content group-committees" style="color: #0dcaf0;">
|
||||
<i class="fas fa-users"></i> اللجان
|
||||
</span>
|
||||
<i class="fas fa-chevron-down arrow-icon"></i>
|
||||
</button>
|
||||
<div class="collapse <?= $is_committees_open ? 'show' : '' ?>" id="menu-committees">
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?= $cp == 'committees.php' ? 'active' : '' ?>" href="committees.php">
|
||||
إدارة اللجان
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?= $cp == 'committee_reports.php' ? 'active' : '' ?>" href="committee_reports.php">
|
||||
تقييم وتقارير
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<!-- Meetings Group -->
|
||||
<?php if (canView('meetings')): ?>
|
||||
<li class="nav-item">
|
||||
|
||||
165
print_committees_report.php
Normal file
165
print_committees_report.php
Normal file
@ -0,0 +1,165 @@
|
||||
<?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();
|
||||
|
||||
// Fetch committees and members
|
||||
$committees_query = $db->query("
|
||||
SELECT
|
||||
c.id, c.name, c.description,
|
||||
(SELECT COUNT(*) FROM committee_plans WHERE committee_id = c.id) as total_plans,
|
||||
(SELECT COUNT(*) FROM committee_plans WHERE committee_id = c.id AND status = 'completed') as completed_plans,
|
||||
(SELECT COUNT(*) FROM committee_activities WHERE committee_id = c.id) as activities_count
|
||||
FROM committees c
|
||||
ORDER BY c.name ASC
|
||||
");
|
||||
$committees = $committees_query->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
foreach ($committees as &$c) {
|
||||
// Calculate performance score
|
||||
$plan_completion_rate = $c['total_plans'] > 0 ? ($c['completed_plans'] / $c['total_plans']) * 100 : 0;
|
||||
$activity_score = min(100, $c['activities_count'] * 20);
|
||||
$c['score'] = ($plan_completion_rate * 0.6) + ($activity_score * 0.4);
|
||||
|
||||
// Fetch members for this committee
|
||||
$members_stmt = $db->prepare("
|
||||
SELECT cm.role, u.name as full_name, u.phone
|
||||
FROM committee_members cm
|
||||
JOIN charity_members u ON cm.charity_member_id = u.id
|
||||
WHERE cm.committee_id = ?
|
||||
ORDER BY cm.id DESC
|
||||
");
|
||||
$members_stmt->execute([$c['id']]);
|
||||
$c['members'] = $members_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
unset($c);
|
||||
|
||||
// Sort by score descending
|
||||
usort($committees, function($a, $b) {
|
||||
return $b['score'] <=> $a['score'];
|
||||
});
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ar" dir="rtl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<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; }
|
||||
.committee-section { margin-bottom: 40px; page-break-inside: avoid; }
|
||||
.committee-title { background-color: #f8f9fa; padding: 10px; border-radius: 5px; border: 1px solid #ddd; font-weight: bold; }
|
||||
.score-badge { display: inline-block; padding: 5px 10px; border-radius: 20px; background: #e9ecef; border: 1px solid #ccc; font-size: 0.9em; }
|
||||
table { width: 100%; margin-top: 15px; margin-bottom: 15px; border-collapse: collapse; }
|
||||
th, td { border: 1px solid #dee2e6; padding: 8px; text-align: right; }
|
||||
th { background-color: #f1f3f5; }
|
||||
@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">تقرير اللجان وتقييم الأداء العام</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($committees)): ?>
|
||||
<div class="alert alert-info text-center">لا توجد لجان مسجلة في النظام.</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($committees as $index => $c): ?>
|
||||
<div class="committee-section">
|
||||
<div class="committee-title d-flex justify-content-between align-items-center">
|
||||
<span class="fs-5">
|
||||
<?= $index + 1 ?>. <?= htmlspecialchars($c['name']) ?>
|
||||
</span>
|
||||
<div class="score-badge">
|
||||
مؤشر الأداء (KPI): <strong><?= round($c['score']) ?>%</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="text-muted small mt-2 mb-2 px-2">
|
||||
<?= htmlspecialchars($c['description']) ?: 'لا يوجد وصف' ?>
|
||||
</p>
|
||||
|
||||
<div class="px-2 mb-3 small text-secondary">
|
||||
<span class="me-3">إجمالي الخطط: <strong><?= $c['total_plans'] ?></strong></span>
|
||||
<span class="me-3">الخطط المكتملة: <strong><?= $c['completed_plans'] ?></strong></span>
|
||||
<span>إجمالي الأنشطة: <strong><?= $c['activities_count'] ?></strong></span>
|
||||
</div>
|
||||
|
||||
<?php if (count($c['members']) > 0): ?>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 50px; text-align: center;">م</th>
|
||||
<th>اسم العضو</th>
|
||||
<th>الدور في اللجنة</th>
|
||||
<th style="width: 150px;">رقم الهاتف</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($c['members'] as $m_index => $m): ?>
|
||||
<tr>
|
||||
<td style="text-align: center;"><?= $m_index + 1 ?></td>
|
||||
<td><strong><?= htmlspecialchars($m['full_name']) ?></strong></td>
|
||||
<td><?= htmlspecialchars($m['role']) ?></td>
|
||||
<td dir="ltr" style="text-align: right;"><?= htmlspecialchars($m['phone'] ?? '-') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<div class="text-muted fst-italic px-2 py-3 border-bottom border-start border-end mb-4">لا يوجد أعضاء مسجلين في هذه اللجنة حالياً.</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?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>
|
||||
@ -32,7 +32,8 @@ $modules = [
|
||||
'stock_settings' => 'المخزون - الإعدادات',
|
||||
'expenses' => 'المصروفات',
|
||||
'expense_settings' => 'المصروفات - الإعدادات',
|
||||
'meetings' => 'الاجتماعات'
|
||||
'meetings' => 'الاجتماعات',
|
||||
'committees' => 'اللجان'
|
||||
];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
|
||||
600
view_committee.php
Normal file
600
view_committee.php
Normal file
@ -0,0 +1,600 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/includes/header.php';
|
||||
|
||||
if (!canView('committees')) {
|
||||
redirect('index.php');
|
||||
}
|
||||
|
||||
$id = $_GET['id'] ?? 0;
|
||||
if (!$id) {
|
||||
redirect('committees.php');
|
||||
}
|
||||
|
||||
$db = db();
|
||||
$stmt = $db->prepare("SELECT * FROM committees WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$committee = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$committee) {
|
||||
redirect('committees.php');
|
||||
}
|
||||
|
||||
$tab = $_GET['tab'] ?? 'members';
|
||||
$allowed_tabs = ['members', 'plans', 'activities'];
|
||||
if (!in_array($tab, $allowed_tabs)) {
|
||||
$tab = 'members';
|
||||
}
|
||||
|
||||
$error = '';
|
||||
$success = '';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$action = $_POST['action'] ?? '';
|
||||
|
||||
try {
|
||||
if ($action === 'add_member' && canAdd('committees')) {
|
||||
$charity_member_id = $_POST['charity_member_id'] ?? 0;
|
||||
$role = trim($_POST['role'] ?? 'عضو');
|
||||
if ($charity_member_id) {
|
||||
$stmt = $db->prepare("INSERT INTO committee_members (committee_id, charity_member_id, role, joined_at) VALUES (?, ?, ?, CURDATE())");
|
||||
$stmt->execute([$id, $charity_member_id, $role]);
|
||||
$_SESSION['success'] = 'تم إضافة العضو بنجاح';
|
||||
}
|
||||
} elseif ($action === 'edit_member' && canEdit('committees')) {
|
||||
$member_id = $_POST['member_id'] ?? 0;
|
||||
$role = trim($_POST['role'] ?? 'عضو');
|
||||
if ($member_id) {
|
||||
$stmt = $db->prepare("UPDATE committee_members SET role = ? WHERE id = ?");
|
||||
$stmt->execute([$role, $member_id]);
|
||||
$_SESSION['success'] = 'تم تحديث دور العضو بنجاح';
|
||||
}
|
||||
} elseif ($action === 'delete_member' && canDelete('committees')) {
|
||||
$member_id = $_POST['member_id'] ?? 0;
|
||||
if ($member_id) {
|
||||
$stmt = $db->prepare("DELETE FROM committee_members WHERE id = ?");
|
||||
$stmt->execute([$member_id]);
|
||||
$_SESSION['success'] = 'تم حذف العضو بنجاح';
|
||||
}
|
||||
} elseif ($action === 'add_plan' && canAdd('committees')) {
|
||||
$title = trim($_POST['title'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$start_date = $_POST['start_date'] ?: null;
|
||||
$end_date = $_POST['end_date'] ?: null;
|
||||
if ($title) {
|
||||
$stmt = $db->prepare("INSERT INTO committee_plans (committee_id, title, description, start_date, end_date) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$id, $title, $description, $start_date, $end_date]);
|
||||
$_SESSION['success'] = 'تم إضافة الخطة بنجاح';
|
||||
}
|
||||
} elseif ($action === 'edit_plan' && canEdit('committees')) {
|
||||
$plan_id = $_POST['plan_id'] ?? 0;
|
||||
$title = trim($_POST['title'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$start_date = $_POST['start_date'] ?: null;
|
||||
$end_date = $_POST['end_date'] ?: null;
|
||||
$status = $_POST['status'] ?? 'pending';
|
||||
if ($plan_id && $title) {
|
||||
$stmt = $db->prepare("UPDATE committee_plans SET title = ?, description = ?, start_date = ?, end_date = ?, status = ? WHERE id = ?");
|
||||
$stmt->execute([$title, $description, $start_date, $end_date, $status, $plan_id]);
|
||||
$_SESSION['success'] = 'تم تحديث الخطة بنجاح';
|
||||
}
|
||||
} elseif ($action === 'delete_plan' && canDelete('committees')) {
|
||||
$plan_id = $_POST['plan_id'] ?? 0;
|
||||
if ($plan_id) {
|
||||
$stmt = $db->prepare("DELETE FROM committee_plans WHERE id = ?");
|
||||
$stmt->execute([$plan_id]);
|
||||
$_SESSION['success'] = 'تم حذف الخطة بنجاح';
|
||||
}
|
||||
} elseif ($action === 'add_activity' && canAdd('committees')) {
|
||||
$title = trim($_POST['title'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$activity_date = $_POST['activity_date'] ?: null;
|
||||
$location = trim($_POST['location'] ?? '');
|
||||
if ($title) {
|
||||
$stmt = $db->prepare("INSERT INTO committee_activities (committee_id, title, description, activity_date, location) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$id, $title, $description, $activity_date, $location]);
|
||||
$_SESSION['success'] = 'تم إضافة النشاط بنجاح';
|
||||
}
|
||||
} elseif ($action === 'edit_activity' && canEdit('committees')) {
|
||||
$activity_id = $_POST['activity_id'] ?? 0;
|
||||
$title = trim($_POST['title'] ?? '');
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$activity_date = $_POST['activity_date'] ?: null;
|
||||
$location = trim($_POST['location'] ?? '');
|
||||
if ($activity_id && $title) {
|
||||
$stmt = $db->prepare("UPDATE committee_activities SET title = ?, description = ?, activity_date = ?, location = ? WHERE id = ?");
|
||||
$stmt->execute([$title, $description, $activity_date, $location, $activity_id]);
|
||||
$_SESSION['success'] = 'تم تحديث النشاط بنجاح';
|
||||
}
|
||||
} elseif ($action === 'delete_activity' && canDelete('committees')) {
|
||||
$activity_id = $_POST['activity_id'] ?? 0;
|
||||
if ($activity_id) {
|
||||
$stmt = $db->prepare("DELETE FROM committee_activities WHERE id = ?");
|
||||
$stmt->execute([$activity_id]);
|
||||
$_SESSION['success'] = 'تم حذف النشاط بنجاح';
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
$_SESSION['error'] = 'حدث خطأ: ' . $e->getMessage();
|
||||
}
|
||||
redirect("view_committee.php?id=$id&tab=$tab");
|
||||
}
|
||||
|
||||
if (isset($_SESSION['success'])) {
|
||||
$success = $_SESSION['success'];
|
||||
unset($_SESSION['success']);
|
||||
}
|
||||
if (isset($_SESSION['error'])) {
|
||||
$error = $_SESSION['error'];
|
||||
unset($_SESSION['error']);
|
||||
}
|
||||
|
||||
// Fetch tab data
|
||||
$members = [];
|
||||
$plans = [];
|
||||
$activities = [];
|
||||
|
||||
if ($tab === 'members') {
|
||||
$stmt = $db->prepare("SELECT cm.*, u.name as full_name, u.email, u.phone FROM committee_members cm JOIN charity_members u ON cm.charity_member_id = u.id WHERE cm.committee_id = ? ORDER BY cm.id DESC");
|
||||
$stmt->execute([$id]);
|
||||
$members = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Get available users to add
|
||||
$member_ids = array_column($members, 'charity_member_id');
|
||||
$not_in = count($member_ids) > 0 ? implode(',', array_map('intval', $member_ids)) : '0';
|
||||
$available_users = $db->query("SELECT id, name as full_name, email FROM charity_members WHERE status = 'active' AND id NOT IN ($not_in) ORDER BY full_name ASC")->fetchAll(PDO::FETCH_ASSOC);
|
||||
} elseif ($tab === 'plans') {
|
||||
$stmt = $db->prepare("SELECT * FROM committee_plans WHERE committee_id = ? ORDER BY id DESC");
|
||||
$stmt->execute([$id]);
|
||||
$plans = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} elseif ($tab === 'activities') {
|
||||
$stmt = $db->prepare("SELECT * FROM committee_activities WHERE committee_id = ? ORDER BY activity_date DESC, id DESC");
|
||||
$stmt->execute([$id]);
|
||||
$activities = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">إدارة اللجنة: <?= htmlspecialchars($committee['name']) ?></h1>
|
||||
<a href="committees.php" class="btn btn-secondary shadow-sm">
|
||||
<i class="fas fa-arrow-right"></i> عودة للجان
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php if ($success): ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= $success ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= $error ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="lead text-muted"><?= nl2br(htmlspecialchars($committee['description'])) ?></p>
|
||||
|
||||
<ul class="nav nav-tabs mb-4">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?= $tab === 'members' ? 'active' : '' ?>" href="view_committee.php?id=<?= $id ?>&tab=members">
|
||||
<i class="fas fa-users"></i> الأعضاء
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?= $tab === 'plans' ? 'active' : '' ?>" href="view_committee.php?id=<?= $id ?>&tab=plans">
|
||||
<i class="fas fa-tasks"></i> الخطط
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?= $tab === 'activities' ? 'active' : '' ?>" href="view_committee.php?id=<?= $id ?>&tab=activities">
|
||||
<i class="fas fa-calendar-alt"></i> الأنشطة والفعاليات
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<?php if ($tab === 'members'): ?>
|
||||
<div class="card shadow-sm border-0 mb-4">
|
||||
<div class="card-header bg-white d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">أعضاء اللجنة</h5>
|
||||
<?php if (canAdd('committees')): ?>
|
||||
<button class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#addMemberModal">
|
||||
<i class="fas fa-plus"></i> إضافة عضو
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="ps-4">الاسم</th>
|
||||
<th>البريد الإلكتروني</th>
|
||||
<th>الهاتف</th>
|
||||
<th>الدور</th>
|
||||
<th>تاريخ الانضمام</th>
|
||||
<th class="text-center">الإجراءات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (count($members) > 0): ?>
|
||||
<?php foreach ($members as $m): ?>
|
||||
<tr>
|
||||
<td class="ps-4 fw-bold"><?= htmlspecialchars($m['full_name']) ?></td>
|
||||
<td><?= htmlspecialchars($m['email']) ?></td>
|
||||
<td><a href="tel:<?= htmlspecialchars($m['phone'] ?? '') ?>"><?= htmlspecialchars($m['phone'] ?? '-' ) ?></a></td>
|
||||
<td><span class="badge bg-info text-dark"><?= htmlspecialchars($m['role']) ?></span></td>
|
||||
<td><?= $m['joined_at'] ?></td>
|
||||
<td class="text-center">
|
||||
<?php if (canEdit('committees')): ?>
|
||||
<button class="btn btn-sm btn-outline-primary me-1" onclick='editMember(<?= json_encode($m, JSON_HEX_APOS | JSON_HEX_QUOT) ?>)'>
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (canDelete('committees')): ?>
|
||||
<form method="POST" class="d-inline" onsubmit="return confirm('هل أنت متأكد من الحذف؟');">
|
||||
<input type="hidden" name="action" value="delete_member">
|
||||
<input type="hidden" name="member_id" value="<?= $m['id'] ?>">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr><td colspan="5" class="text-center py-4 text-muted">لا يوجد أعضاء في هذه اللجنة حالياً.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Add Member Modal -->
|
||||
<div class="modal fade" id="addMemberModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="add_member">
|
||||
<div class="modal-header bg-primary text-white">
|
||||
<h5 class="modal-title">إضافة عضو جديد</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">المستخدم <span class="text-danger">*</span></label>
|
||||
<select name="charity_member_id" class="form-select" required>
|
||||
<option value="">-- اختر مستخدم --</option>
|
||||
<?php foreach ($available_users as $u): ?>
|
||||
<option value="<?= $u['id'] ?>"><?= htmlspecialchars($u['full_name']) ?> (<?= htmlspecialchars($u['email']) ?>)</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">الدور في اللجنة</label>
|
||||
<input type="text" name="role" class="form-control" placeholder="مثال: رئيس اللجنة، عضو، سكرتير" value="عضو">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-primary">إضافة</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Edit Member Modal -->
|
||||
<div class="modal fade" id="editMemberModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" value="edit_member">
|
||||
<input type="hidden" name="member_id" id="edit_member_id">
|
||||
<div class="modal-header bg-primary text-white">
|
||||
<h5 class="modal-title">تعديل دور العضو</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">الدور في اللجنة</label>
|
||||
<input type="text" name="role" id="edit_member_role" class="form-control" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-primary">حفظ</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function editMember(member) {
|
||||
document.getElementById('edit_member_id').value = member.id;
|
||||
document.getElementById('edit_member_role').value = member.role;
|
||||
new bootstrap.Modal(document.getElementById('editMemberModal')).show();
|
||||
}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if ($tab === 'plans'): ?>
|
||||
<div class="card shadow-sm border-0 mb-4">
|
||||
<div class="card-header bg-white d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">خطط اللجنة</h5>
|
||||
<?php if (canAdd('committees')): ?>
|
||||
<button class="btn btn-sm btn-primary" onclick="openPlanModal('add')">
|
||||
<i class="fas fa-plus"></i> إضافة خطة
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="ps-4">عنوان الخطة</th>
|
||||
<th>تاريخ البداية</th>
|
||||
<th>تاريخ النهاية</th>
|
||||
<th>الحالة</th>
|
||||
<th class="text-center">الإجراءات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$status_colors = [
|
||||
'pending' => 'secondary',
|
||||
'in_progress' => 'primary',
|
||||
'completed' => 'success',
|
||||
'cancelled' => 'danger'
|
||||
];
|
||||
$status_labels = [
|
||||
'pending' => 'قيد الانتظار',
|
||||
'in_progress' => 'قيد التنفيذ',
|
||||
'completed' => 'مكتملة',
|
||||
'cancelled' => 'ملغاة'
|
||||
];
|
||||
if (count($plans) > 0): ?>
|
||||
<?php foreach ($plans as $p): ?>
|
||||
<tr>
|
||||
<td class="ps-4 fw-bold">
|
||||
<?= htmlspecialchars($p['title']) ?>
|
||||
<div class="small text-muted text-truncate" style="max-width: 200px;"><?= htmlspecialchars($p['description'] ?? '') ?></div>
|
||||
</td>
|
||||
<td><?= $p['start_date'] ?: '-' ?></td>
|
||||
<td><?= $p['end_date'] ?: '-' ?></td>
|
||||
<td><span class="badge bg-<?= $status_colors[$p['status']] ?>"><?= $status_labels[$p['status']] ?></span></td>
|
||||
<td class="text-center">
|
||||
<?php if (canEdit('committees')): ?>
|
||||
<button class="btn btn-sm btn-outline-primary me-1" onclick='openPlanModal("edit", <?= json_encode($p, JSON_HEX_APOS | JSON_HEX_QUOT) ?>)'>
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (canDelete('committees')): ?>
|
||||
<form method="POST" class="d-inline" onsubmit="return confirm('هل أنت متأكد من الحذف؟');">
|
||||
<input type="hidden" name="action" value="delete_plan">
|
||||
<input type="hidden" name="plan_id" value="<?= $p['id'] ?>">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr><td colspan="5" class="text-center py-4 text-muted">لا توجد خطط مضافة حالياً.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Plan Modal -->
|
||||
<div class="modal fade" id="planModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" id="planAction" value="add_plan">
|
||||
<input type="hidden" name="plan_id" id="planId" value="0">
|
||||
<div class="modal-header bg-primary text-white">
|
||||
<h5 class="modal-title" id="planModalTitle">إضافة خطة جديدة</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">عنوان الخطة <span class="text-danger">*</span></label>
|
||||
<input type="text" name="title" id="planTitle" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">الوصف</label>
|
||||
<textarea name="description" id="planDescription" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label fw-bold">تاريخ البداية</label>
|
||||
<input type="date" name="start_date" id="planStart" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label fw-bold">تاريخ النهاية</label>
|
||||
<input type="date" name="end_date" id="planEnd" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3" id="planStatusDiv" style="display:none;">
|
||||
<label class="form-label fw-bold">الحالة</label>
|
||||
<select name="status" id="planStatus" class="form-select">
|
||||
<option value="pending">قيد الانتظار</option>
|
||||
<option value="in_progress">قيد التنفيذ</option>
|
||||
<option value="completed">مكتملة</option>
|
||||
<option value="cancelled">ملغاة</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-primary">حفظ</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let planModal;
|
||||
function openPlanModal(action, data = null) {
|
||||
if (!planModal) planModal = new bootstrap.Modal(document.getElementById('planModal'));
|
||||
document.getElementById('planAction').value = action === 'add' ? 'add_plan' : 'edit_plan';
|
||||
document.getElementById('planModalTitle').textContent = action === 'add' ? 'إضافة خطة جديدة' : 'تعديل الخطة';
|
||||
|
||||
if (action === 'add') {
|
||||
document.getElementById('planId').value = '';
|
||||
document.getElementById('planTitle').value = '';
|
||||
document.getElementById('planDescription').value = '';
|
||||
document.getElementById('planStart').value = '';
|
||||
document.getElementById('planEnd').value = '';
|
||||
document.getElementById('planStatusDiv').style.display = 'none';
|
||||
} else {
|
||||
document.getElementById('planId').value = data.id;
|
||||
document.getElementById('planTitle').value = data.title;
|
||||
document.getElementById('planDescription').value = data.description || '';
|
||||
document.getElementById('planStart').value = data.start_date || '';
|
||||
document.getElementById('planEnd').value = data.end_date || '';
|
||||
document.getElementById('planStatus').value = data.status;
|
||||
document.getElementById('planStatusDiv').style.display = 'block';
|
||||
}
|
||||
planModal.show();
|
||||
}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php if ($tab === 'activities'): ?>
|
||||
<div class="card shadow-sm border-0 mb-4">
|
||||
<div class="card-header bg-white d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0">أنشطة وفعاليات اللجنة</h5>
|
||||
<?php if (canAdd('committees')): ?>
|
||||
<button class="btn btn-sm btn-primary" onclick="openActivityModal('add')">
|
||||
<i class="fas fa-plus"></i> إضافة نشاط
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="ps-4">النشاط</th>
|
||||
<th>التاريخ</th>
|
||||
<th>الموقع</th>
|
||||
<th class="text-center">الإجراءات</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (count($activities) > 0): ?>
|
||||
<?php foreach ($activities as $a): ?>
|
||||
<tr>
|
||||
<td class="ps-4 fw-bold">
|
||||
<?= htmlspecialchars($a['title']) ?>
|
||||
<div class="small text-muted text-truncate" style="max-width: 200px;"><?= htmlspecialchars($a['description'] ?? '') ?></div>
|
||||
</td>
|
||||
<td><?= $a['activity_date'] ?: '-' ?></td>
|
||||
<td><?= htmlspecialchars($a['location'] ?? '-') ?></td>
|
||||
<td class="text-center">
|
||||
<?php if (canEdit('committees')): ?>
|
||||
<button class="btn btn-sm btn-outline-primary me-1" onclick='openActivityModal("edit", <?= json_encode($a, JSON_HEX_APOS | JSON_HEX_QUOT) ?>)'>
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if (canDelete('committees')): ?>
|
||||
<form method="POST" class="d-inline" onsubmit="return confirm('هل أنت متأكد من الحذف؟');">
|
||||
<input type="hidden" name="action" value="delete_activity">
|
||||
<input type="hidden" name="activity_id" value="<?= $a['id'] ?>">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr><td colspan="4" class="text-center py-4 text-muted">لا توجد أنشطة مضافة حالياً.</td></tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Activity Modal -->
|
||||
<div class="modal fade" id="activityModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="POST">
|
||||
<input type="hidden" name="action" id="activityAction" value="add_activity">
|
||||
<input type="hidden" name="activity_id" id="activityId" value="0">
|
||||
<div class="modal-header bg-primary text-white">
|
||||
<h5 class="modal-title" id="activityModalTitle">إضافة نشاط جديد</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">عنوان النشاط <span class="text-danger">*</span></label>
|
||||
<input type="text" name="title" id="activityTitle" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-bold">الوصف</label>
|
||||
<textarea name="description" id="activityDescription" class="form-control" rows="3"></textarea>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label fw-bold">تاريخ النشاط</label>
|
||||
<input type="date" name="activity_date" id="activityDate" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label fw-bold">الموقع / المكان</label>
|
||||
<input type="text" name="location" id="activityLocation" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">إلغاء</button>
|
||||
<button type="submit" class="btn btn-primary">حفظ</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let activityModal;
|
||||
function openActivityModal(action, data = null) {
|
||||
if (!activityModal) activityModal = new bootstrap.Modal(document.getElementById('activityModal'));
|
||||
document.getElementById('activityAction').value = action === 'add' ? 'add_activity' : 'edit_activity';
|
||||
document.getElementById('activityModalTitle').textContent = action === 'add' ? 'إضافة نشاط جديد' : 'تعديل النشاط';
|
||||
|
||||
if (action === 'add') {
|
||||
document.getElementById('activityId').value = '';
|
||||
document.getElementById('activityTitle').value = '';
|
||||
document.getElementById('activityDescription').value = '';
|
||||
document.getElementById('activityDate').value = '';
|
||||
document.getElementById('activityLocation').value = '';
|
||||
} else {
|
||||
document.getElementById('activityId').value = data.id;
|
||||
document.getElementById('activityTitle').value = data.title;
|
||||
document.getElementById('activityDescription').value = data.description || '';
|
||||
document.getElementById('activityDate').value = data.activity_date || '';
|
||||
document.getElementById('activityLocation').value = data.location || '';
|
||||
}
|
||||
activityModal.show();
|
||||
}
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
Loading…
x
Reference in New Issue
Block a user