session.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Sessions reporting.
  5. *
  6. * @package chamilo.reporting
  7. */
  8. ob_start();
  9. $cidReset = true;
  10. require_once __DIR__.'/../inc/global.inc.php';
  11. api_block_anonymous_users();
  12. $this_section = SECTION_TRACKING;
  13. $export_csv = false;
  14. if (isset($_GET['export']) && $_GET['export'] == 'csv') {
  15. $export_csv = true;
  16. }
  17. $id_coach = api_get_user_id();
  18. if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
  19. $id_coach = (int) $_GET['id_coach'];
  20. }
  21. $allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
  22. if (!$allowToTrack) {
  23. api_not_allowed(true);
  24. }
  25. $htmlHeadXtra[] = api_get_jqgrid_js();
  26. $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
  27. Display::display_header(get_lang('Sessions'));
  28. if (api_is_platform_admin(true, true)) {
  29. $a_sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
  30. if (!api_is_session_admin()) {
  31. $menu_items[] = Display::url(
  32. Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
  33. api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
  34. );
  35. $menu_items[] = Display::url(
  36. Display::return_icon('user.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
  37. 'index.php?view=drh_students&amp;display=yourstudents'
  38. );
  39. $menu_items[] = Display::url(
  40. Display::return_icon('teacher.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
  41. 'teachers.php'
  42. );
  43. $menu_items[] = Display::url(
  44. Display::return_icon('course.png', get_lang('Courses'), [], ICON_SIZE_MEDIUM),
  45. 'course.php'
  46. );
  47. $menu_items[] = Display::url(
  48. Display::return_icon('session_na.png', get_lang('Sessions'), [], ICON_SIZE_MEDIUM),
  49. '#'
  50. );
  51. }
  52. $menu_items[] = Display::url(
  53. Display::return_icon('works.png', get_lang('WorksReport'), [], ICON_SIZE_MEDIUM),
  54. api_get_path(WEB_CODE_PATH).'mySpace/works_in_session_report.php'
  55. );
  56. $menu_items[] = Display::url(
  57. Display::return_icon('clock.png', get_lang('TeacherTimeReportBySession'), [], ICON_SIZE_MEDIUM),
  58. api_get_path(WEB_CODE_PATH).'admin/teachers_time_by_session_report.php'
  59. );
  60. if (!api_is_session_admin()) {
  61. $menu_items[] = Display::url(
  62. Display::return_icon('1day.png', get_lang('SessionsPlanCalendar'), [], ICON_SIZE_MEDIUM),
  63. api_get_path(WEB_CODE_PATH)."calendar/planification.php"
  64. );
  65. }
  66. $actionsLeft = '';
  67. $nb_menu_items = count($menu_items);
  68. if ($nb_menu_items > 1) {
  69. foreach ($menu_items as $key => $item) {
  70. $actionsLeft .= $item;
  71. }
  72. }
  73. $actionsRight = '';
  74. if (count($a_sessions) > 0) {
  75. $actionsRight = Display::url(
  76. Display::return_icon('printer.png', get_lang('Print'), [], 32),
  77. 'javascript: void(0);',
  78. ['onclick' => 'javascript: window.print();']
  79. );
  80. $actionsRight .= Display::url(
  81. Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), [], 32),
  82. api_get_self().'?export=csv'
  83. );
  84. }
  85. $toolbar = Display::toolbarAction(
  86. 'toolbar-session',
  87. [$actionsLeft, $actionsRight]
  88. );
  89. echo $toolbar;
  90. echo Display::page_header(get_lang('YourSessionsList'));
  91. } elseif (api_is_teacher()) {
  92. $actionsRight = Display::url(
  93. Display::return_icon('clock.png', get_lang('TeacherTimeReportBySession'), [], ICON_SIZE_MEDIUM),
  94. api_get_path(WEB_CODE_PATH).'admin/teachers_time_by_session_report.php'
  95. );
  96. $toolbar = Display::toolbarAction(
  97. 'toolbar-session',
  98. ['', $actionsRight]
  99. );
  100. echo $toolbar;
  101. echo Display::page_header(get_lang('YourSessionsList'));
  102. } else {
  103. $a_sessions = Tracking::get_sessions_coached_by_user($id_coach);
  104. }
  105. $form = new FormValidator(
  106. 'search_course',
  107. 'get',
  108. api_get_path(WEB_CODE_PATH).'mySpace/session.php'
  109. );
  110. $form->addElement('text', 'keyword', get_lang('Keyword'));
  111. $form->addButtonSearch(get_lang('Search'));
  112. $keyword = '';
  113. if ($form->validate()) {
  114. $keyword = $form->getSubmitValue('keyword');
  115. }
  116. $form->setDefaults(['keyword' => $keyword]);
  117. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions_tracking&keyword='.Security::remove_XSS($keyword);
  118. $columns = [
  119. get_lang('Title'),
  120. get_lang('Date'),
  121. get_lang('NbCoursesPerSession'),
  122. get_lang('NbStudentPerSession'),
  123. get_lang('Details'),
  124. ];
  125. // Column config
  126. $columnModel = [
  127. ['name' => 'name', 'index' => 'name', 'width' => '255', 'align' => 'left'],
  128. ['name' => 'date', 'index' => 'access_start_date', 'width' => '150', 'align' => 'left'],
  129. ['name' => 'course_per_session', 'index' => 'course_per_session', 'width' => '150', 'sortable' => 'false'],
  130. ['name' => 'student_per_session', 'index' => 'student_per_session', 'width' => '100', 'sortable' => 'false'],
  131. ['name' => 'details', 'index' => 'details', 'width' => '100', 'sortable' => 'false'],
  132. ];
  133. $extraParams = [
  134. 'autowidth' => 'true',
  135. 'height' => 'auto',
  136. ];
  137. $js = '<script>
  138. $(function() {
  139. '.Display::grid_js(
  140. 'session_tracking',
  141. $url,
  142. $columns,
  143. $columnModel,
  144. $extraParams,
  145. [],
  146. null,
  147. true
  148. ).'
  149. });
  150. </script>';
  151. echo $js;
  152. $form->display();
  153. echo Display::grid_html('session_tracking');
  154. Display::display_footer();