ROCKVIEW UNIVERSITY — STUDENT NUMBER TO UNIT AUTHORISATION

PURPOSE
Staff must assign every student number to one of the operational units already
created in Manage Units. The register stores the student number against the
project_units record. It does not use departments to decide the SLPS team.

AUTOMATIC ASSIGNMENT ON REGISTRATION
When the student registers successfully, the system creates the account and, in
the same database transaction, inserts the account into project_unit_members for
the exact unit selected by Staff. The number is then marked as registered and
cannot be reused. This causes the student to appear in that unit's My Unit page.

The existing Academic Department field remains separate because the students
table requires department_id for academic records. It does NOT select the SLPS
team. The SLPS Unit is always derived from the staff-authorised student number.
The student's campus is derived from the campus belonging to the assigned unit.

STAFF WORKFLOW
1. Create and confirm the operational units in Manage Units first.
2. Open Student Number & Unit Assignment from Staff or Top Management navigation.
3. Choose an existing unit from the Unit selector.
4. Add one student number, or paste up to 1,000 numbers from an Excel column.
5. Review the register: Awaiting registration, Registered, or Revoked.
6. Pending numbers can be corrected/reassigned to another unit by Staff. Registered
   numbers cannot be reassigned here.

STUDENT WORKFLOW
1. Enter the issued student number during registration.
2. Click Verify number (or continue; the form verifies automatically).
3. The system displays the assigned SLPS unit and the unit's campus.
4. Complete the other registration fields and submit.
5. The final server endpoint checks the student-number/unit assignment again while
   holding a database lock. An unassigned, revoked, inactive-unit, or already-used
   number is rejected even if the browser verification step is bypassed.
6. Successful registration automatically places the student in the assigned unit.

INSTALLATION ORDER
1. Back up the SLPS database and files.
2. Confirm the existing migration database/migrations/20261101_project_units.sql
   has already been applied. The project_units and project_unit_members tables
   must exist (Manage Units must already be operational).
3. Import this new migration once:
   database/migrations/20261101_student_number_unit_authorisations.sql
4. Extract this patch into the SLPS project root, preserving the slps/ folder path.
   Overwrite the listed existing files and add the listed new files.
5. Hard-refresh your browser with Ctrl+F5.
6. Staff must enter the approved student number/unit assignments before students
   attempt registration.

PATCH FILES
Modified:
- authentication/api/register.php
- authentication/views/register.php
- authentication/js/register.js
- authentication/css/register.css
- shared/views/module_shell.php
- staff/views/dashboard.html
- management/views/dashboard.html

New:
- database/migrations/20261101_student_number_unit_authorisations.sql
- authentication/api/verify_student_unit.php
- shared/api/student_unit_authorisations.php
- shared/views/modules/student-unit-authorisations.php
- shared/views/student_unit_authorisations_workspace.php
- shared/js/student-unit-authorisations.js
- shared/css/student-unit-authorisations.css

IMPORTANT
Use this unit-based patch instead of the earlier department-authorisation patch.
This package does not use student_number_authorisations or department_id for unit
assignment. If the older department-authorisation table was already created, this
patch leaves it unused; no automatic deletion is performed.

VALIDATION COMPLETED
- PHP syntax checks passed for the changed and new PHP files.
- JavaScript syntax checks passed for registration and staff workspace scripts.
- CSS parsing completed with zero syntax errors.
- Integration checks confirmed the staff API reads project_units, and registration
  writes project_unit_members and consumes the authorisation in one transaction.
- Live MySQL and browser testing still needs to be completed on the hosted system.
