session.php 4.2 KB

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