diff --git a/src/admin/manage_courses.php b/src/admin/manage_courses.php
index df1f726f..3809bc4b 100644
--- a/src/admin/manage_courses.php
+++ b/src/admin/manage_courses.php
@@ -61,7 +61,8 @@ if ($course_id) {
@@ -151,4 +152,70 @@ if ($course_id) {
});
+
+
diff --git a/src/processors/process_course.php b/src/processors/process_course.php
index 5c93080a..be546a78 100644
--- a/src/processors/process_course.php
+++ b/src/processors/process_course.php
@@ -43,6 +43,22 @@ try {
throw new Exception('Invalid date format');
}
+ // If code not provided, generate from type + date using ABBR_MMDD format
+ if (empty($code)) {
+ $abbrMap = [
+ 'driver_training' => 'DRVTRN',
+ 'bush_mechanics' => 'BUSHMEC',
+ 'rescue_recovery' => 'RESREC',
+ 'ladies_driver_training' => 'LADYTRN'
+ ];
+
+ $abbr = $abbrMap[$course_type] ?? strtoupper(preg_replace('/[^A-Z0-9]/', '', $course_type));
+ // ensure abbr fits (reserve 1 char for underscore and 4 for MMDD)
+ $abbr = substr($abbr, 0, 7);
+ $mmdd = date('md', strtotime($date));
+ $code = strtoupper(substr($abbr . '_' . $mmdd, 0, 12));
+ }
+
if ($capacity <= 0) {
throw new Exception('Capacity must be greater than 0');
}