parseToken($token); if (!$payload) { return $this->respondHtml('Sorry, this link is invalid or has expired.', 400); } $email = trim((string)($payload['email'] ?? '')); $fullName = trim((string)($payload['name'] ?? '')); if ($email === '') { return $this->respondHtml('Unable to notify the requester because their email was not included.', 400); } $dates = (string)($payload['dates'] ?? '-'); $role = (string)($payload['role'] ?? 'staff'); $reason = (string)($payload['reason'] ?? ''); $reasonType = (string)($payload['reason_type'] ?? ''); $submittedAt = (string)($payload['submitted_at'] ?? ''); $origin = (string)($payload['origin'] ?? 'staff portal'); try { $mailer = \Config\Services::emailService(); $subject = 'TimeOff Request - Principal Acknowledgment'; $body = '
Dear ' . esc($fullName ?: 'Staff Member') . ',
' . 'This is a courtesy confirmation that your time-off request submitted via the ' . esc($origin) . ' has been reviewed by the principal.
' . '| Role | ' . esc($role) . ' |
| Dates | ' . esc($dates ?: '-') . ' |
| Reason Type | ' . esc($reasonType ?: '-') . ' |
| Reason | ' . esc($reason ?: '-') . ' |
| Submitted At | ' . esc($submittedAt) . ' |
If you have any follow-up questions, please contact the principal\'s office directly.
' . 'Thank you,
Al Rahma School Administration
' . esc($message) . '
' . ''; return $this->response ->setStatusCode($statusCode) ->setHeader('Content-Type', 'text/html; charset=UTF-8') ->setBody($html); } }