* @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() ) || api_is_drh(); if (api_is_allowed_to_edit(null, true) || api_is_coach(api_get_session_id(), api_get_course_int_id()) || $isDrhOfCourse ) { $groupId = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null; $form = new FormValidator( 'filter', 'post', 'index.php?action=attendance_sheet_list&'.api_get_cidreq().'&attendance_id='.$attendance_id, null, [], 'inline' ); $values = [ 'all' => get_lang('All'), 'today' => get_lang('Today'), 'all_done' => get_lang('All done'), 'all_not_done' => get_lang('All not done'), ]; $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) { echo Display::return_message( get_lang('There is no class scheduled today, try picking another day or add your attendance entry yourself using the action icons.'), 'warning' ); } $form->addSelect( 'filter', get_lang('Filter'), $values, ['id' => 'filter_id', 'onchange' => 'submit();'] ); $groupList = GroupManager::get_group_list(null, null, 1); $groupIdList = ['--']; foreach ($groupList as $group) { $groupIdList[$group['id']] = $group['name']; } if (!empty($groupList)) { $form->addSelect('group_id', get_lang('Group'), $groupIdList); } 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( [ 'filter' => $default_filter, 'group_id' => $groupId, ] ); if (!$is_locked_attendance || api_is_platform_admin()) { $actionsLeft = ''. Display::return_icon('attendance_calendar.png', get_lang('Attendance calendar'), '', ICON_SIZE_MEDIUM).''; $actionsLeft .= ''. Display::return_icon('pdf.png', get_lang('Export to PDF'), '', ICON_SIZE_MEDIUM).''; $actionsRight = $form->returnForm(); $toolbar = Display::toolbarAction('toolbar-attendance', [$actionsLeft, $actionsRight]); echo $toolbar; } $message_information = get_lang('The attendance sheets allow you to specify a list of dates in which you will report attendance to your courses'); if (!empty($message_information)) { $message = ''.get_lang('Information').'
'; $message .= $message_information; echo Display::return_message($message, 'normal', false); } if ($is_locked_attendance) { echo Display::return_message(get_lang('The attendance sheet is locked.'), 'warning', false); } $param_filter = '&filter='.Security::remove_XSS($default_filter).'&group_id='.$groupId; if (count($users_in_course) > 0) { ?>
'; echo ''; echo ''; $result = null; if (count($attendant_calendar) > 0) { foreach ($attendant_calendar as $calendar) { $date = $calendar['date']; $time = $calendar['time']; $datetime = '
'.$date.' - '.$time.'
'; $img_lock = Display::return_icon( 'lock-closed.png', get_lang('Unlock date'), ['class' => 'img_lock', 'id' => 'datetime_column_'.$calendar['id']] ); if (!empty($calendar['done_attendance'])) { $datetime = '
'.$date.' - '.$time.'
'; } $disabled_check = 'disabled = "true"'; $input_hidden = ''; if ($next_attendance_calendar_id == $calendar['id']) { $input_hidden = ''; $disabled_check = ''; $img_lock = Display::return_icon('lock-closed.png', get_lang('Lock date'), ['class' => 'img_unlock', 'id' => 'datetime_column_'.$calendar['id']]); } $result .= ''; } } } } else { $result = ''; } echo ''; echo $result; echo ''; echo ''; echo $result; echo ''; echo ''; echo ''; $i = 0; foreach ($users_in_course as $user) { $class = ''; if ($i % 2 == 0) { $class = 'row_even'; } else { $class = 'row_odd'; } echo ''; if (count($attendant_calendar) > 0) { foreach ($attendant_calendar as $calendar) { $checked = 'checked'; $presence = -1; if (isset($users_presence[$user['user_id']][$calendar['id']]['presence'])) { $presence = $users_presence[$user['user_id']][$calendar['id']]['presence']; if (intval($presence) == 1) { $checked = 'checked'; } else { $checked = ''; } } else { //if the user wasn't registered at that time, consider unchecked if ($next_attendance_calendar_datetime == 0 || $calendar['date_time'] < $next_attendance_calendar_datetime ) { $checked = ''; } } $disabled = 'disabled'; $style_td = ''; if ($next_attendance_calendar_id == $calendar['id']) { if ($i % 2 == 0) { $style_td = 'background-color:#eee;'; } else { $style_td = 'background-color:#dcdcdc;'; } $disabled = ''; } echo ''; } } else { $calendarClass = null; if (isset($calendar)) { $calendarClass = "checkboxes_col_".$calendar['id']; } echo ''; } echo ''; $i++; } echo '
'; $result .= '
'.$datetime.' '; if (api_is_allowed_to_edit(null, true)) { $result .= ''.(!$is_locked_attendance || api_is_platform_admin() ? $img_lock : '').''; } if ($is_locked_attendance == false) { if (api_is_allowed_to_edit(null, true)) { $result .= ''.$input_hidden.'
'; $result .= Display::return_icon('attendance_calendar.png', get_lang('Attendance calendar'), '', ICON_SIZE_MEDIUM).' '.get_lang('GoTo attendance calendar').'
'; echo '
'; if (api_is_allowed_to_edit(null, true)) { if (!$is_locked_attendance || api_is_platform_admin()) { echo ''; echo ''; } else { echo $presence ? Display::return_icon('checkbox_on.png', get_lang('Assistance'), null, ICON_SIZE_TINY) : Display::return_icon('checkbox_off.png', get_lang('Assistance'), null, ICON_SIZE_TINY); } } else { switch ($presence) { case 1: echo Display::return_icon('accept.png', get_lang('Attended')); break; case 0: echo Display::return_icon('exclamation.png', get_lang('Not attended')); break; case -1: //echo Display::return_icon('warning.png',get_lang('Not attended')); break; } } echo '
'; echo '
'; echo '
'; echo '
 
'; echo '
'; ?>
'. get_lang('There are no registered learners inside the course').'', 'warning', false ); } } else { echo Display::page_header(get_lang('Report of attendance sheets')); // View for students?>