# Fullscreen Schedule Approvals and Employee Transfers ## Recommended commit ```text feat(admin): add fullscreen schedule approvals and secure cross-brand employee transfers ``` ## Summary This commit improves two administrator workflows: 1. Schedule approvers can review pending requests from the mobile landscape fullscreen schedule without leaving the grid. 2. Admin and Super Admin accounts can assign or transfer employees to another brand and branch through the employee workflow. No payroll behavior or database schema is changed by this commit. ## Fullscreen schedule approvals When a mobile user selects **View Schedule Grid (Landscape)**, the existing fullscreen schedule remains available. - A small arrow handle appears on the right edge of the fullscreen grid. - Selecting the handle opens the pending-approval panel beside the schedule. - Selecting the handle again hides the panel. - The schedule stays fullscreen while the panel opens and closes. - A badge on the closed handle shows the number of pending requests. - Closing fullscreen also resets the approval panel to its hidden state. ### Flow ```mermaid flowchart LR A[Open Shift Management] --> B[View Schedule Grid in Landscape] B --> C[Fullscreen Schedule] C --> D[Select edge arrow] D --> E[Pending Approvals panel opens] E --> F[Approve or reject requests] E --> G[Select edge arrow again] G --> C ``` ## Super Admin employee transfers The Employee page previously failed to recognize the canonical `SUPERADMIN` role. As a result, the Employee modal received `canManageAssignments=false`, which disabled its Brand and Branch controls. This commit normalizes the supported administrator spellings: - `ADMIN` - `SUPERADMIN` - `SUPER_ADMIN` - `Super Admin` The normalized forms grant assignment management only to Admin and Super Admin. `BRAND_ADMIN` does not receive cross-brand transfer permission. ### Security behavior - Employee creation, editing, and reassignment use the authenticated server role when checking cross-brand authority. - The dedicated employee-reassignment endpoint now requires an authenticated admin request. - Client-supplied role values are no longer trusted for assignment authorization. - Non-super-admin users remain restricted from changing an employee to another brand. ### Transfer flow ```mermaid flowchart TD A[Open Employee modal] --> B{Authenticated role} B -- Admin or Super Admin --> C[Enable Brand and Branch fields] B -- Other role --> D[Keep assignment fields locked] C --> E[Select destination brand] E --> F[Select destination branch or Unassigned Branch] F --> G[Submit employee update] G --> H[Server verifies authenticated role] H --> I[Normalize and save assignment] ``` ## Files changed ### Frontend - `frontend/src/components/employees/employees.jsx` - `frontend/src/components/schedule-manager/schedule-manager-components/LayouSMDashboard.jsx` - `frontend/src/components/schedule-manager/schedule-manager-components/components/ScheduleGrid.jsx` ### Backend - `backend/config/employee_assignment_helper.php` - `backend/employee_assignment/reassign_employee_assignment.php` - `backend/employeesSide/add_employee.php` - `backend/employeesSide/update_employee.php` - `backend/tests/run.php` ### Documentation - `docs/position-access-control.md` - `docs/fullscreen-schedule-approvals-and-employee-transfers.md` Runtime authentication logs are intentionally excluded from the commit. ## Verification completed - PHP syntax checks passed for all changed backend PHP files. - Backend unit tests passed: 14 passed, 0 failed. - Focused frontend ESLint completed with 0 errors; existing unrelated warnings remain. - The production frontend build completed successfully. - `git diff --check` completed without whitespace errors. ## Manual verification checklist ### Schedule approvals 1. Open Shift Management on a mobile device. 2. Select **View Schedule Grid (Landscape)**. 3. Confirm the grid remains fullscreen and landscape. 4. Select the right-edge arrow and confirm Pending Approvals opens. 5. Approve or reject a test request. 6. Hide the panel and confirm the grid remains fullscreen. 7. Close fullscreen and confirm the approval drawer resets. ### Employee transfer 1. Sign in as Sonjie or another active `SUPERADMIN` account. 2. Open the Employee page and edit an employee. 3. Confirm Brand and Branch are enabled. 4. Select a different brand and one of its branches. 5. Save and confirm the employee appears under the destination assignment. 6. Repeat with a non-super-admin account and confirm cross-brand assignment remains unavailable. If an account was promoted to Super Admin while already signed in, sign out and sign in again so the authentication token contains the updated role.