attendance_list.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * View (MVC patter) for listing attendances
  5. * @author Christian Fasanando <christian1827@gmail.com>
  6. * @package chamilo.attendance
  7. */
  8. // protect a course script
  9. api_protect_course_script(true);
  10. if (api_is_allowed_to_edit(null, true)) {
  11. $param_gradebook = '';
  12. if (isset($_SESSION['gradebook'])) {
  13. $param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
  14. }
  15. echo '<div class="actions">';
  16. echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=attendance_add">'.
  17. Display::return_icon('new_attendance_list.png',get_lang('CreateANewAttendance'),'',ICON_SIZE_MEDIUM).'</a>';
  18. echo '</div>';
  19. }
  20. $attendance = new Attendance();
  21. if ($attendance->get_number_of_attendances() == 0) {
  22. $attendance->set_name(get_lang('Attendances'));
  23. $attendance->set_description(get_lang('Attendances'));
  24. $attendance->attendance_add();
  25. }
  26. $default_column = isset($default_column) ? $default_column : null;
  27. $parameters = isset($parameters) ? $parameters : null;
  28. $table = new SortableTable(
  29. 'attendance_list',
  30. array('Attendance', 'get_number_of_attendances'),
  31. array('Attendance', 'get_attendance_data'),
  32. $default_column
  33. );
  34. $table->set_additional_parameters($parameters);
  35. $table->set_header(0, '', false, array('style'=>'width:20px;'));
  36. $table->set_header(1, get_lang('Name'), true );
  37. $table->set_header(2, get_lang('Description'), true);
  38. $table->set_header(3, get_lang('CountDoneAttendance'), true, array('style'=>'width:90px;'));
  39. if (api_is_allowed_to_edit(null, true)) {
  40. $table->set_header(4, get_lang('Actions'), false, array('style'=>'text-align:center'));
  41. $actions = array(
  42. 'attendance_set_invisible_select' => get_lang('SetInvisible'),
  43. 'attendance_set_visible_select' => get_lang('SetVisible')
  44. );
  45. $allow = api_get_setting('allow_delete_attendance');
  46. if ($allow === 'true') {
  47. $actions['attendance_delete_select'] = get_lang('DeleteAllSelectedAttendances');
  48. }
  49. $table->set_form_actions($actions);
  50. }
  51. if ($table->get_total_number_of_items() > 0) {
  52. $table->display();
  53. }