================================================================================
  FUNCTION NAME FIXES - ALL FILES CORRECTED
================================================================================

ERROR:
------
Call to undefined function getCurrentSchoolReference()

CAUSE:
------
Multiple files were using the wrong function name.
Correct function: getCurrentSchool()

================================================================================
FILES FIXED (3 FILES):
================================================================================

1. admin/storage/usage.php
   Line 14: getCurrentSchoolReference() → getCurrentSchool()

2. admin/moodle/configure_mapping.php
   Line 12: getCurrentSchoolReference() → getCurrentSchool()

3. admin/moodle/test_mappings.php
   Line 12: getCurrentSchoolReference() → getCurrentSchool()

Also fixed earlier:
4. admin/configure_subjects.php (already fixed)

================================================================================
WHAT THE FUNCTION DOES:
================================================================================

getCurrentSchool() - Returns the current school's reference code

Returns:
  - academy_reference (e.g., "KINE", "SCH002")
  - From $_SESSION['academy_reference']
  - Or null if no school selected

Location: includes/school_context.php

Usage:
  $school_code = getCurrentSchool();
  // Returns: "KINE" (or whatever school is selected)

================================================================================
FILES TO UPLOAD:
================================================================================

PRIORITY 1 (Fixes errors):
[ ] admin/storage/usage.php (FIXED)
[ ] admin/moodle/configure_mapping.php (FIXED)
[ ] admin/moodle/test_mappings.php (FIXED)

These 3 files had the error and are now fixed.

PRIORITY 2 (Features):
[ ] .htaccess (simplified, no more 500 error)
[ ] super_admin/storage/overview.php (collation fix)
[ ] admin/configure_subjects.php (grade selection)
[ ] parent_register.php (session fix)
[ ] parent/make_payment.php (subject filtering)

PRIORITY 3 (New features):
[ ] admin/manage_grades.php (grade selection UI)
[ ] register_student.php (self-registration)
[ ] All other new files

================================================================================
TESTING AFTER UPLOAD:
================================================================================

TEST 1: Storage Usage Page
---------------------------
URL: https://test.melanegroup.com/Multi-Tanent/admin/storage/usage.php

Before: Fatal error - getCurrentSchoolReference() undefined
After: Loads correctly, shows storage dashboard

TEST 2: Moodle Configure Mapping
---------------------------------
URL: https://test.melanegroup.com/Multi-Tanent/admin/moodle/configure_mapping.php

Before: Fatal error - getCurrentSchoolReference() undefined
After: Loads correctly, shows mapping interface

TEST 3: Moodle Test Mappings
-----------------------------
URL: https://test.melanegroup.com/Multi-Tanent/admin/moodle/test_mappings.php

Before: Fatal error - getCurrentSchoolReference() undefined
After: Loads correctly, shows test interface

================================================================================
QUICK DEPLOYMENT:
================================================================================

In cPanel File Manager:

1. Navigate to: Multi-Tanent/admin/storage/
   - Delete: usage.php
   - Upload: usage.php (from C:\xampp\htdocs\Multi-Tanent\admin\storage\)

2. Create folder (if not exists): Multi-Tanent/admin/moodle/

3. Navigate to: Multi-Tanent/admin/moodle/
   - Upload: configure_mapping.php
   - Upload: test_mappings.php

4. Test all 3 URLs above
   - Should load without errors
   - Should show proper interfaces

================================================================================
SUMMARY OF ALL FUNCTION NAME FIXES:
================================================================================

WRONG:    getCurrentSchoolReference()
CORRECT:  getCurrentSchool()

FIXED IN:
  ✓ admin/configure_subjects.php
  ✓ admin/storage/usage.php
  ✓ admin/moodle/configure_mapping.php
  ✓ admin/moodle/test_mappings.php

All files now use the correct function name!

================================================================================
FILES READY:
================================================================================

Windows Explorer showing: admin/storage/usage.php

All fixed files are in:
  C:\xampp\htdocs\Multi-Tanent\admin\

Ready to upload!

================================================================================

Upload these 3 fixed files and all errors will be resolved! ✅

================================================================================

