$PAGE->navbar->add(get_string('attendances', 'local_attendance'));
$PAGE->navbar->add(get_string('viewattendance', 'local_attendance'));
$PAGE->navbar->add(get_string('bystudents', 'local_attendance'), "/local/attendance/viewstudentrecord.php?courseid={$courseid}");
$action = optional_param('action', 'view_by_student', PARAM_TEXT);
echo $OUTPUT->header();
$toprow = array();
$toprow[] = new tabobject("bystudent", new moodle_url('/local/attendance/viewstudentrecord.php', array('courseid' => $courseid)), get_string('bystudents', 'local_attendance'));
$toprow[] = new tabobject("bysession", new moodle_url('/local/attendance/viewsessionrecord.php', array('courseid' => $courseid)), get_string('bysessions', 'local_attendance'));
echo $OUTPUT->tabtree($toprow, "bystudent");
if ($action == 'view_by_student') {
    $title = $courseName->fullname . ' - ' . get_string('attendancerecord', 'local_attendance');
    echo $OUTPUT->heading($title);
    echo '<br>';
    echo '<div id="filter"><strong>' . get_string('filter', 'local_attendance') . ': </strong> <input type="text"></div>';
    echo '<br>';
    $table = tables::getAssistByStudent($courseid);
    echo html_writer::table($table);
    $back = new moodle_url('/course/view.php?id=' . $courseid);
    echo $OUTPUT->single_button($back, get_string('back', 'local_attendance'));
}
if ($action == 'modify_student_attendance') {
    $subject = get_string('attendancemodified', 'local_attendance');
    $subjectTosend = $courseName->shortname . ': ' . $subject;
    $userid = required_param('userid', PARAM_INT);
    $actionsForm = new actionsForStudent();
    $username = $DB->get_record('user', array('id' => $userid));
    $table = new html_table();
    $table->head = array(get_string('sessionname', 'local_attendance'), get_string('changes', 'local_attendance'), get_string('report', 'local_attendance'));
    if ($fromform = $actionsForm->get_data()) {
        if (isset($_POST["sessions"])) {
            if ($fromform->action_for_checked == 'mark_as_absent') {