session.php 5.1 KB

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