attendance_list.php 1.9 KB

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