session.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /*
  4. * Sessions reporting
  5. * @package chamilo.reporting
  6. */
  7. ob_start();
  8. // name of the language file that needs to be included
  9. $language_file = array('registration', 'index', 'trad4all', 'tracking', 'admin');
  10. $cidReset = true;
  11. require_once '../inc/global.inc.php';
  12. require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
  13. api_block_anonymous_users();
  14. $this_section = SECTION_TRACKING;
  15. api_block_anonymous_users();
  16. $htmlHeadXtra[] = api_get_jqgrid_js();
  17. $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
  18. Display::display_header(get_lang('Sessions'));
  19. $export_csv = false;
  20. if (isset($_GET['export']) && $_GET['export'] == 'csv') {
  21. $export_csv = true;
  22. }
  23. /* MAIN CODE */
  24. if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
  25. $id_coach = intval($_GET['id_coach']);
  26. } else {
  27. $id_coach = api_get_user_id();
  28. }
  29. if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
  30. $a_sessions = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
  31. if (!api_is_session_admin()) {
  32. $menu_items[] = Display::url(
  33. Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
  34. api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
  35. );
  36. $menu_items[] = Display::url(
  37. Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM),
  38. "index.php?view=drh_students&amp;display=yourstudents"
  39. );
  40. $menu_items[] = Display::url(
  41. Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM),
  42. 'teachers.php'
  43. );
  44. $menu_items[] = Display::url(
  45. Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM),
  46. 'course.php'
  47. );
  48. $menu_items[] = Display::url(
  49. Display::return_icon('session_na.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM),
  50. '#'
  51. );
  52. }
  53. echo '<div class="actions">';
  54. $nb_menu_items = count($menu_items);
  55. if ($nb_menu_items > 1) {
  56. foreach ($menu_items as $key => $item) {
  57. echo $item;
  58. }
  59. }
  60. if (count($a_sessions) > 0) {
  61. echo '<span style="float:right">';
  62. echo Display::url(
  63. Display::return_icon('printer.png', get_lang('Print'), array(), 32),
  64. 'javascript: void(0);',
  65. array('onclick'=>'javascript: window.print();')
  66. );
  67. echo Display::url(
  68. Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), 32),
  69. api_get_self().'?export=csv'
  70. );
  71. echo '</span>';
  72. }
  73. echo '</div>';
  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('search_course', 'get', api_get_path(WEB_CODE_PATH).'mySpace/session.php');
  79. $form->addElement('text', 'keyword', get_lang('Keyword'));
  80. $form->addElement('button', 'submit', get_lang('Search'));
  81. $form->addElement('hidden', 'session_id', $sessionId);
  82. $keyword = null;
  83. if ($form->validate()) {
  84. $keyword = $form->getSubmitValue('keyword');
  85. }
  86. $form->setDefaults(array('keyword' => $keyword));
  87. $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions_tracking&keyword='.Security::remove_XSS($keyword);
  88. $columns = array(
  89. get_lang('Title'),
  90. get_lang('Date'),
  91. get_lang('NbCoursesPerSession'),
  92. get_lang('NbStudentPerSession'),
  93. get_lang('Details')
  94. );
  95. // Column config
  96. $columnModel = array(
  97. array('name'=>'name', 'index'=>'name', 'width'=>'255', 'align'=>'left'),
  98. array('name'=>'date', 'index'=>'date', 'width'=>'150', 'align'=>'left','sortable'=>'false'),
  99. array('name'=>'course_per_session', 'index'=>'course_per_session', 'width'=>'150','sortable'=>'false'),
  100. array('name'=>'student_per_session', 'index'=>'student_per_session', 'width'=>'100','sortable'=>'false'),
  101. array('name'=>'details', 'index'=>'details', 'width'=>'100','sortable'=>'false')
  102. );
  103. $extraParams = array(
  104. 'autowidth' => 'true',
  105. 'height' => 'auto'
  106. );
  107. $js = '<script>
  108. $(function() {
  109. '.Display::grid_js(
  110. 'session_tracking',
  111. $url,
  112. $columns,
  113. $columnModel,
  114. $extraParams,
  115. array(),
  116. null,
  117. true
  118. ).'
  119. });
  120. </script>';
  121. echo $js;
  122. $form->display();
  123. echo Display::grid_html('session_tracking');
  124. Display::display_footer();