* @author Julio Montoya reworked 2010
* @package chamilo.attendance
*/
// Protect a course script
api_protect_course_script(true);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
api_get_user_id(),
api_get_course_info()
);
if (api_is_allowed_to_edit(null, true) ||
api_is_coach(api_get_session_id(), api_get_course_int_id()) ||
$isDrhOfCourse
) {
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.$_SESSION['gradebook'];
}
$groupId = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
$form = new FormValidator(
'filter',
'post',
'index.php?action=attendance_sheet_list&' . api_get_cidreq() . $param_gradebook . '&attendance_id=' . $attendance_id,
null,
array(),
FormValidator::LAYOUT_INLINE
);
$values = array(
'all' => get_lang('All'),
'today' => get_lang('Today'),
'all_done' => get_lang('AllDone'),
'all_not_done' => get_lang('AllNotDone')
);
$today = api_convert_and_format_date(null, DATE_FORMAT_SHORT);
$exists_attendance_today = false;
if (!empty($attendant_calendar_all)) {
$values[''] = '---------------';
foreach ($attendant_calendar_all as $attendance_date) {
$includeCalendar = true;
if (isset($attendance_date['groups']) && !empty($groupId)) {
foreach ($attendance_date['groups'] as $group) {
if ($groupId == $group['group_id']) {
$includeCalendar = true;
break;
} else {
$includeCalendar = false;
}
}
}
if ($today == $attendance_date['date']) {
$exists_attendance_today = true;
}
if ($includeCalendar) {
$values[$attendance_date['id']] = $attendance_date['date_time'];
}
}
}
if (!$exists_attendance_today) {
Display::display_warning_message(get_lang('ThereIsNoClassScheduledTodayTryPickingAnotherDay'));
}
$form->addElement('select', 'filter', get_lang('Filter'), $values, array('id' => 'filter_id'));
$groupList = GroupManager::get_group_list(null, null, 1);
$groupIdList = array('--');
foreach ($groupList as $group) {
$groupIdList[$group['id']] = $group['name'];
}
if (!empty($groupList)) {
$form->addSelect('group_id', get_lang('Group'), $groupIdList);
}
$form->addButtonFilter(get_lang('Filter'));
if (isset($_REQUEST['filter'])) {
if (in_array($_REQUEST['filter'], array_keys($values))) {
$default_filter = $_REQUEST['filter'];
}
} else {
$default_filter = 'today';
}
$renderer = $form->defaultRenderer();
$renderer->setCustomElementTemplate('{label} {element} ');
$form->setDefaults(
array(
'filter' => $default_filter,
'group_id' => $groupId
)
);
if (!$is_locked_attendance || api_is_platform_admin()) {
echo '
';
}
$message_information = get_lang('AttendanceSheetDescription');
if (!empty($message_information)) {
$message = ''.get_lang('Information').'
';
$message .= $message_information;
Display::display_normal_message($message, false);
}
if ($is_locked_attendance) {
Display::display_warning_message(get_lang('TheAttendanceSheetIsLocked'), false);
}
$param_filter = '&filter='.Security::remove_XSS($default_filter).'&group_id='.$groupId;
if (count($users_in_course) > 0) {
?>
'.get_lang('ThereAreNoRegisteredLearnersInsidetheCourse').'', false);
}
} else {
echo Display::page_header(get_lang('AttendanceSheetReport'));
// View for students
?>