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. * @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. echo '<div class="actions">';
  12. echo '<a href="index.php?'.api_get_cidreq().'&action=attendance_add">'.
  13. Display::return_icon('new_attendance_list.png', get_lang('CreateANewAttendance'), '', ICON_SIZE_MEDIUM).'</a>';
  14. echo '</div>';
  15. }
  16. $attendance = new Attendance();
  17. if ($attendance->get_number_of_attendances() == 0) {
  18. $attendance->set_name(get_lang('Attendances'));
  19. $attendance->set_description(get_lang('Attendances'));
  20. $attendance->attendance_add();
  21. }
  22. $default_column = isset($default_column) ? $default_column : null;
  23. $parameters = isset($parameters) ? $parameters : null;
  24. $table = new SortableTable(
  25. 'attendance_list',
  26. array('Attendance', 'get_number_of_attendances'),
  27. array('Attendance', 'get_attendance_data'),
  28. $default_column
  29. );
  30. $table->set_additional_parameters($parameters);
  31. $table->set_header(0, '', false, array('style'=>'width:20px;'));
  32. $table->set_header(1, get_lang('Name'), true);
  33. $table->set_header(2, get_lang('Description'), true);
  34. $table->set_header(3, get_lang('CountDoneAttendance'), true, array('style'=>'width:90px;'));
  35. if (api_is_allowed_to_edit(null, true)) {
  36. $table->set_header(4, get_lang('Actions'), false, array('style'=>'text-align:center'));
  37. $actions = array(
  38. 'attendance_set_invisible_select' => get_lang('SetInvisible'),
  39. 'attendance_set_visible_select' => get_lang('SetVisible')
  40. );
  41. $allow = api_get_setting('allow_delete_attendance');
  42. if ($allow === 'true') {
  43. $actions['attendance_delete_select'] = get_lang('DeleteAllSelectedAttendances');
  44. }
  45. $table->set_form_actions($actions);
  46. }
  47. if ($table->get_total_number_of_items() > 0) {
  48. $table->display();
  49. }