* @author Julio Montoya reworked 2010 * @package chamilo.attendance */ // protect a course script api_protect_course_script(true); if (api_is_allowed_to_edit(null, true) || api_is_coach(api_get_session_id(), api_get_course_int_id())) { $param_gradebook = ''; if (isset($_SESSION['gradebook'])) { $param_gradebook = '&gradebook='.$_SESSION['gradebook']; } $form = new FormValidator('filter', 'post', 'index.php?action=attendance_sheet_list&'.api_get_cidreq().$param_gradebook.'&attendance_id='.$attendance_id, null, array('class' => 'form-search pull-left')); $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) { if ($today == $attendance_date['date']) { $exists_attendance_today = true; } $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')); $form->addElement('style_submit_button', null, get_lang('Filter'), 'class="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->setElementTemplate('{label} {element} '); $form->setDefaults(array('filter'=>$default_filter)); if (!$is_locked_attendance || api_is_platform_admin()) { echo '
'; echo ''. Display::return_icon('attendance_calendar.png',get_lang('AttendanceCalendar'),'',ICON_SIZE_MEDIUM).''; if (count($users_in_course) > 0) { $form->display(); } echo ''. Display::return_icon('pdf.png',get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).''; 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); if (count($users_in_course) > 0) { foreach ($attendance_states as $id => $state) { echo $attendance_obj->get_attendance_state_button($id, true).' '; } ?>
'; echo ''; echo ''; $result = null; if (count($attendant_calendar) > 0 ) { foreach ($attendant_calendar as $calendar) { $date = $calendar['date']; $time = $calendar['time']; $datetime = $date.'
'.$time; $datetime = api_format_date($calendar['date_time'], DATE_FORMAT_NUMBER_NO_YEAR); $img_lock = Display::return_icon('lock.gif',get_lang('DateUnLock'),array('class'=>'img_lock','id'=>'datetime_column_'.$calendar['id'])); if (!empty($calendar['done_attendance'])){ $datetime = ''.$datetime.''; } $disabled_check = 'disabled = "true"'; if ($next_attendance_calendar_id == $calendar['id']) { $input_hidden = ''; $disabled_check = ''; $img_lock = Display::return_icon('unlock.gif',get_lang('DateLock'),array('class'=>'img_unlock','id'=>'datetime_column_'.$calendar['id'])); } else { $input_hidden = ''; } $result .= ''; } } } } else { $result = ''; } echo ''; echo $result; echo ''; echo ''; echo $result; echo ''; echo ''; echo ''; $i = 0; $default_presence_value = $attendance_obj->get_default_attendance_state(); 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) { $presence = $default_presence_value; if (isset($users_presence[$user['user_id']][$calendar['id']]['presence'])) { $presence = isset($users_presence[$user['user_id']][$calendar['id']]['presence']) ? $users_presence[$user['user_id']][$calendar['id']]['presence'] : $default_presence_value; } 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) { $presence = $default_presence_value; } } $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 { 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('AttendanceCalendar'),'',ICON_SIZE_MEDIUM).' '.get_lang('GoToAttendanceCalendar').'
'; echo '
'; if (api_is_allowed_to_edit(null, true)) { if (!$is_locked_attendance || api_is_platform_admin()) { //echo ''; foreach ($attendance_states as $key => $state) { $input_checked = null; if ($key == $presence) { $input_checked = " checked=checked"; } //echo Display::tag('label', ' '.$state, array('class'=> 'checkbox')); } $link_id = 'link_'.$key.'_'.$user['user_id'].'_'.$calendar['id']; $attributes = array('id' => $link_id, 'class' => 'switch '.$disabled); echo $attendance_obj->get_attendance_state_button($presence, false, $attributes); echo ''; echo ''; } else { echo $presence ? Display::return_icon('checkbox_on.gif',get_lang('Presence')) : Display::return_icon('checkbox_off.gif',get_lang('Presence')); } } 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('NotAttended')); break; case -1: //echo Display::return_icon('warning.png',get_lang('NotAttended')); break; } } echo '
'; echo '
'; echo '
'; echo '
 
'; echo '
'; ?>
'.get_lang('ThereAreNoRegisteredLearnersInsidetheCourse').'', false); } } else { echo Display::page_header(get_lang('AttendanceSheetReport')); // View for students ?>
get_attendance_state_button($presence['presence']); //echo $presence['presence']?Display::return_icon('checkbox_on.gif',get_lang('Presence')):Display::return_icon('checkbox_off.gif',get_lang('Presence')) echo "  ".$presence['date_time'] ?>