session.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. //quire_once '../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. $actionsLeft = '';
  51. $nb_menu_items = count($menu_items);
  52. if ($nb_menu_items > 1) {
  53. foreach ($menu_items as $key => $item) {
  54. $actionsLeft .= $item;
  55. }
  56. }
  57. $actionsRight = '';
  58. if (count($a_sessions) > 0) {
  59. $actionsRight = Display::url(
  60. Display::return_icon('printer.png', get_lang('Print'), array(), 32),
  61. 'javascript: void(0);',
  62. array('onclick'=>'javascript: window.print();')
  63. );
  64. $actionsRight .= Display::url(
  65. Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), 32),
  66. api_get_self().'?export=csv'
  67. );
  68. }
  69. $toolbar = Display::toolbarAction(
  70. 'toolbar-session',
  71. $content = array(0 => $actionsLeft, 1 => $actionsRight)
  72. );
  73. echo $toolbar;
  74. echo Display::page_header(get_lang('YourSessionsList'));
  75. } else {
  76. $a_sessions = Tracking::get_sessions_coached_by_user($id_coach);
  77. }
  78. $form = new FormValidator(
  79. 'search_course',
  80. 'get',
  81. api_get_path(WEB_CODE_PATH).'mySpace/session.php'
  82. );
  83. $form->addElement('text', 'keyword', get_lang('Keyword'));
  84. $form->addButtonSearch(get_lang('Search'));
  85. $keyword = '';
  86. if ($form->validate()) {
  87. $keyword = $form->getSubmitValue('keyword');
  88. }
  89. $form->setDefaults(array('keyword' => $keyword));
  90. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions_tracking&keyword='.Security::remove_XSS($keyword);
  91. $columns = array(
  92. get_lang('Title'),
  93. get_lang('Date'),
  94. get_lang('NbCoursesPerSession'),
  95. get_lang('NbStudentPerSession'),
  96. get_lang('Details')
  97. );
  98. // Column config
  99. $columnModel = array(
  100. array('name'=>'name', 'index'=>'name', 'width'=>'255', 'align'=>'left'),
  101. array('name'=>'date', 'index'=>'date', 'width'=>'150', 'align'=>'left','sortable'=>'false'),
  102. array('name'=>'course_per_session', 'index'=>'course_per_session', 'width'=>'150','sortable'=>'false'),
  103. array('name'=>'student_per_session', 'index'=>'student_per_session', 'width'=>'100','sortable'=>'false'),
  104. array('name'=>'details', 'index'=>'details', 'width'=>'100','sortable'=>'false')
  105. );
  106. $extraParams = array(
  107. 'autowidth' => 'true',
  108. 'height' => 'auto'
  109. );
  110. $js = '<script>
  111. $(function() {
  112. '.Display::grid_js(
  113. 'session_tracking',
  114. $url,
  115. $columns,
  116. $columnModel,
  117. $extraParams,
  118. array(),
  119. null,
  120. true
  121. ).'
  122. });
  123. </script>';
  124. echo $js;
  125. $form->display();
  126. echo Display::grid_html('session_tracking');
  127. Display::display_footer();