+ = $assigned_count ?>
+
+
+ = h(current_lang() === 'ar' ? $row['description_ar'] : $row['description_en']) ?>
+
+
+
+PHP;
+$td_new = <<
+ = $assigned_count ?>
+
+ / = h($row['max_students']) ?>
+
+
+
+ = h(current_lang() === 'ar' ? $row['description_ar'] : $row['description_en']) ?>
+
+
+
+ = h(t('Open', 'مفتوح')) ?>
+
+ = h(t('Closed', 'مغلق')) ?>
+
+
+
+
+PHP;
+$content = str_replace($td_orig, $td_new, $content);
+
+// 7. Modals
+$edit_modal_orig = <<
+ = h(t('Price', 'السعر')) ?>
+
+
+
+
+ = h(t('Max Students', 'الحد الأقصى للطلاب')) ?>
+
+
+
+
= h(t('Picture', 'صورة')) ?>
+
+PHP;
+$content = str_replace($edit_modal_orig, $edit_modal_new, $content);
+
+$edit_modal_orig2 = <<
+ = h(t('Status', 'الحالة')) ?>
+
+ >= h(t('Active', 'نشط')) ?>
+ >= h(t('Inactive', 'غير نشط')) ?>
+
+
+PHP;
+$edit_modal_new2 = <<
+ = h(t('Status', 'الحالة')) ?>
+
+ >= h(t('Active', 'نشط')) ?>
+ >= h(t('Inactive', 'غير نشط')) ?>
+
+
+
+
+ />
+ = h(t('Registration Open', 'التسجيل مفتوح')) ?>
+
+
+PHP;
+$content = str_replace($edit_modal_orig2, $edit_modal_new2, $content);
+
+$add_modal_orig = <<
+ = h(t('Price', 'السعر')) ?>
+
+
+
+
+ = h(t('Max Students', 'الحد الأقصى للطلاب')) ?>
+
+
+
+
= h(t('Picture', 'صورة')) ?>
+
+PHP;
+$content = str_replace($add_modal_orig, $add_modal_new, $content);
+
+$add_modal_orig2 = <<
+ = h(t('Status', 'الحالة')) ?>
+
+ = h(t('Active', 'نشط')) ?>
+ = h(t('Inactive', 'غير نشط')) ?>
+
+
+PHP;
+$add_modal_new2 = <<
+ = h(t('Status', 'الحالة')) ?>
+
+ = h(t('Active', 'نشط')) ?>
+ = h(t('Inactive', 'غير نشط')) ?>
+
+
+
+
+
+ = h(t('Registration Open', 'التسجيل مفتوح')) ?>
+
+
+PHP;
+$content = str_replace($add_modal_orig2, $add_modal_new2, $content);
+
+
+file_put_contents('admin_courses.php', $content);
+echo "Done";
+?>
diff --git a/patch_admin.py b/patch_admin.py
new file mode 100644
index 0000000..8f90dac
--- /dev/null
+++ b/patch_admin.py
@@ -0,0 +1,160 @@
+import sys
+import re
+
+with open('admin_courses.php', 'r') as f:
+ content = f.read()
+
+# 1. Add post actions
+content = content.replace(
+ " if ($post_action === 'edit' || $post_action === 'add') {",
+ """ if ($post_action === 'close_all_registration') {
+ db()->query(\"UPDATE courses SET registration_open = 0\");
+ header('Location: ' . app_url('admin.php', ['page' => 'courses']));
+ exit;
+ }
+ if ($post_action === 'open_all_registration') {
+ db()->query(\"UPDATE courses SET registration_open = 1\");
+ header('Location: ' . app_url('admin.php', ['page' => 'courses']));
+ exit;
+ }
+ if ($post_action === 'reset_all_students') {
+ db()->query(\"TRUNCATE TABLE course_students\");
+ header('Location: ' . app_url('admin.php', ['page' => 'courses']));
+ exit;
+ }
+
+ if ($post_action === 'edit' || $post_action === 'add') {"""
+)
+
+# 2. Add max_students and registration_open to post
+content = content.replace(
+ """ $status = $_POST['status'] ?? 'active';
+ $price = (float)($_POST['price'] ?? 0);""",
+ """ $status = $_POST['status'] ?? 'active';
+ $price = (float)($_POST['price'] ?? 0);
+ $max_students = (isset($_POST['max_students']) && $_POST['max_students'] !== '') ? (int)$_POST['max_students'] : null;
+ $registration_open = isset($_POST['registration_open']) ? 1 : 0;"""
+)
+
+# 3. Update query edit
+content = content.replace(
+ '$stmt = db()->prepare("UPDATE courses SET name_en=?, name_ar=?, description_en=?, description_ar=?, status=?, price=?, picture=? WHERE id=?");\n $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $post_id]);',
+ '$stmt = db()->prepare("UPDATE courses SET name_en=?, name_ar=?, description_en=?, description_ar=?, status=?, price=?, picture=?, max_students=?, registration_open=? WHERE id=?");\n $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $max_students, $registration_open, $post_id]);'
+)
+
+# 4. Update query add
+content = content.replace(
+ '$stmt = db()->prepare("INSERT INTO courses (name_en, name_ar, description_en, description_ar, status, price, picture) VALUES (?, ?, ?, ?, ?, ?, ?)");\n $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture]);',
+ '$stmt = db()->prepare("INSERT INTO courses (name_en, name_ar, description_en, description_ar, status, price, picture, max_students, registration_open) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");\n $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $max_students, $registration_open]);'
+)
+
+# 5. Add bulk buttons
+content = content.replace(
+ """
+
?= h(t('Courses', 'الدورات')) ?>
+
+ + ?= h(t('Add Course', 'إضافة دورة')) ?>
+
+
+
+",
+ """
+
?= h(t('Courses', 'الدورات')) ?>
+
+
+
+
+ + ?= h(t('Add Course', 'إضافة دورة')) ?>
+
+
+
+
+"""
+)
+
+# 6. Modal edit
+content = content.replace(
+ """
+ ?= h(t('Price', 'السعر')) ?>
+ \">
+
""",
+ """
+ ?= h(t('Price', 'السعر')) ?>
+ \">
+
+
+ ?= h(t('Max Students', 'الحد الأقصى للطلاب')) ?>
+ \" value=\"= h($row['max_students']) ?>\">
+
+
+
+ \" value=\"1\" = $row['registration_open'] ? 'checked' : '' ?>/>
+ \">?= h(t('Registration Open', 'التسجيل مفتوح')) ?>
+
+
"""
+)
+
+# 7. Modal add
+content = content.replace(
+ """
+ ?= h(t('Price', 'السعر')) ?>
+
+
""",
+ """
+ ?= h(t('Price', 'السعر')) ?>
+
+
+
+ ?= h(t('Max Students', 'الحد الأقصى للطلاب')) ?>
+ \">
+
+
+
+
+ ?= h(t('Registration Open', 'التسجيل مفتوح')) ?>
+
+
"""
+)
+
+# 8. update list to show registration status
+content = content.replace(
+ """
?= h(t('Assigned', 'مخصص')) ?>
+
?= h(t('Actions', 'الإجراءات')) ?> """,
+ """
?= h(t('Assigned', 'مخصص')) ?>
+
?= h(t('Reg Status', 'حالة التسجيل')) ?>
+
?= h(t('Actions', 'الإجراءات')) ?> """
+)
+
+content = content.replace(
+ """
+ ?= h($assigned_count) ?> = h(t('Students', 'طلاب')) ?>
+
+
+""",
+ """
+ ?= h($assigned_count) ?> = h(t('Students', 'طلاب')) ?>
+
+ / = h($row['max_students']) ?>
+
+
+
+
+ ?= h(t('Open', 'مفتوح')) ?>
+
+ ?= h(t('Closed', 'مغلق')) ?>
+
+
+
+"""
+)
+
+with open('admin_courses.php', 'w') as f:
+ f.write(content)
+
+print("Done")
diff --git a/patch_admin_courses.php b/patch_admin_courses.php
new file mode 100644
index 0000000..4517cd5
--- /dev/null
+++ b/patch_admin_courses.php
@@ -0,0 +1,31 @@
+query("UPDATE courses SET registration_open = 0");
+ header('Location: ' . app_url('admin.php', ['page' => 'courses']));
+ exit;
+ }
+ if ($post_action === 'open_all_registration') {
+ db()->query("UPDATE courses SET registration_open = 1");
+ header('Location: ' . app_url('admin.php', ['page' => 'courses']));
+ exit;
+ }
+
+ if ($post_action === 'edit' || $post_action === 'add') {
+PHP;
+$content = str_replace(" if ($post_action === 'edit' || $post_action === 'add') {", $new_actions, $content);
+
+// 2. Add max_students and registration_open to post
+$vars = <<<'PHP'
+ $status = $_POST['status'] ?? 'active';
+ $price = (float)($_POST['price'] ?? 0);
+ $max_students = (isset($_POST['max_students']) && $_POST['max_students'] !== '') ? (int)$_POST['max_students'] : null;
+ $registration_open = isset($_POST['registration_open']) ? 1 : 0;
+PHP;
+$content = preg_replace("/\$status = \\\\[_POST\['status'\] \\\\] \\\\\? \\\\[\\\\] 'active';\\\\\s*\\\\[_price = \\\\[(float)\\\\[_POST\['price'\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \**PHP**
+ if ($post_action === 'close_all_registration') {
+ db()->query(
\ No newline at end of file
diff --git a/patch_checkout.php b/patch_checkout.php
new file mode 100644
index 0000000..463696d
--- /dev/null
+++ b/patch_checkout.php
@@ -0,0 +1,29 @@
+ 0) {
+ $course = db()->query("SELECT * FROM courses WHERE id = $courseIdForView")->fetch();
+ if ($course) {
+ if (! $course['registration_open']) {
+ die(t('Registration for this course is currently closed.', 'التسجيل في هذه الدورة مغلق حالياً.'));
+ }
+ if ($course['max_students'] > 0) {
+ $enrolled = db()->query("SELECT COUNT(*) FROM course_students WHERE course_id = $courseIdForView")->fetchColumn();
+ if ($enrolled >= $course['max_students']) {
+ die(t('This course has reached its maximum number of students.', 'لقد وصلت هذه الدورة إلى الحد الأقصى لعدد الطلاب.'));
+ }
+ }
+ } else {
+ die('Course not found');
+ }
+}
+PHP;
+
+$content = preg_replace("/if \(\\$courseIdForView > 0\) \{\\s*\\\$course = db\(\)->query\(\"SELECT \* FROM courses WHERE id = \\\$courseIdForView\"\)->fetch\(\);\\s*\}", $limit_check, $content);
+
+file_put_contents($file, $content);
+echo "Done\n";
+
diff --git a/patch_checkout.py b/patch_checkout.py
new file mode 100644
index 0000000..294a324
--- /dev/null
+++ b/patch_checkout.py
@@ -0,0 +1,34 @@
+import sys
+
+with open('checkout.php', 'r') as f:
+ content = f.read()
+
+old_code = """if ($courseIdForView > 0) {
+ $course = db()->query("SELECT * FROM courses WHERE id = $courseIdForView")->fetch();
+}"""
+
+new_code = """if ($courseIdForView > 0) {
+ $course = db()->query("SELECT * FROM courses WHERE id = $courseIdForView")->fetch();
+ if ($course) {
+ if (!$course['registration_open']) {
+ $msg = current_lang() === 'ar' ? 'التسجيل في هذه الدورة/الدفعة مغلق حالياً.' : 'Registration for this course/batch is currently closed.';
+ die("");
+ }
+ if ($course['max_students'] > 0) {
+ $enrolled = db()->query("SELECT COUNT(*) FROM course_students WHERE course_id = $courseIdForView")->fetchColumn();
+ if ($enrolled >= $course['max_students']) {
+ $msg = current_lang() === 'ar' ? 'لقد وصلت هذه الدورة إلى الحد الأقصى لعدد الطلاب.' : 'This course has reached its maximum capacity.';
+ die("");
+ }
+ }
+ } else {
+ die('Course not found');
+ }
+}"""
+
+content = content.replace(old_code, new_code)
+
+with open('checkout.php', 'w') as f:
+ f.write(content)
+
+print("Done")
diff --git a/patch_index.py b/patch_index.py
new file mode 100644
index 0000000..c298819
--- /dev/null
+++ b/patch_index.py
@@ -0,0 +1,29 @@
+import sys
+
+with open('index.php', 'r') as f:
+ content = f.read()
+
+old_button = """= h(t('Enroll Now', 'سجل الآن')) ?> """
+
+new_button = """ 0) {
+ $enrolled = db()->query("SELECT COUNT(*) FROM course_students WHERE course_id = " . $course['id'])->fetchColumn();
+ if ($enrolled >= $course['max_students']) {
+ $isFull = true;
+ }
+ }
+ if ($isClosed || $isFull):
+ ?>
+ = h($isClosed ? t('Registration Closed', 'التسجيل مغلق') : t('Class Full', 'مكتمل العدد')) ?>
+
+ = h(t('Enroll Now', 'سجل الآن')) ?>
+ """
+
+content = content.replace(old_button, new_button)
+
+with open('index.php', 'w') as f:
+ f.write(content)
+
+print("Done")