//============================================================================================ // Load the page requested by the user //============================================================================================ $this_page = "followups"; if (!isset($_GET['page'])) { $count_pending_follow_ups = $dashboard->fetchCountPendingFollowUps($SESSION->student_num); $all_student_follow_ups = $model->listFollowUpsStudent($SESSION->student_num); $l10n->addResource(__DIR__ . '/l10n/header.json'); $l10n->addResource(__DIR__ . '/l10n/follow-ups.json'); require_once FS_PHP . '/header-external.php'; require_once 'views/follow-ups.php'; require_once FS_PHP . '/footer-external.php'; } elseif ($_GET['page'] === "switch") { $model->switchStatus($SESSION->student_num, $_POST['completion_status'], $_POST['follow_up_id']); $loggers['audit']->info("Follow-up completion status changed to {$_POST['completion_status']} for follow-up {$_POST['follow_up_id']}"); } elseif ($_GET['page'] === "fetch") { $follow_up_messages = $model->getFollowUpMessages($_POST['follow_up_id']); foreach ($follow_up_messages as $f) { $insertedOnDate = \DateTime::createFromFormat(DATETIME_MYSQL, $f['inserted_on']); $message_array[] = array('sender_type' => $f['sender_type'], 'sender' => $f['sender'], 'emp_name' => $f['emp_first_name'] . ' ' . $f['emp_last_name'], 'student_name' => $f['first_name'] . ' ' . $f['last_name'], 'inserted_on' => $l10nDate->format($insertedOnDate, 'date_time'), 'inserted_on_stamp' => $insertedOnDate->getTimestamp() * 1000, 'message' => $f['message']); } header('Content-Type: application/json; charset=utf-8'); echo json_encode($message_array); exit; } elseif ($_GET['page'] === "message") { $model->addFollowUpMessage($SESSION->student_num, $_POST['message'], $_POST['follow_up_id']); $loggers['audit']->info("Follow-up message added to follow-up {$_POST['follow_up_id']}"); } else { header('location: https://' . URL_PHP . '/error-external.php?eid=S004'); exit; }