diff --git a/charity_members.php b/charity_members.php index 78994ad..4324042 100644 --- a/charity_members.php +++ b/charity_members.php @@ -1,6 +1,14 @@ 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 "
غير مصرح لك بالوصول لهذه الصفحة.
"; 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'); diff --git a/charity_plans.php b/charity_plans.php index d5c73cc..726bdcd 100644 --- a/charity_plans.php +++ b/charity_plans.php @@ -1,6 +1,14 @@ 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 "
غير مصرح لك بالوصول لهذه الصفحة.
"; 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'))) { diff --git a/committees.php b/committees.php index 8e148db..67e7caa 100644 --- a/committees.php +++ b/committees.php @@ -1,6 +1,14 @@ 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) { } - + \ No newline at end of file