session.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2008 Dokeos SPRL
  6. Copyright (c) various contributors
  7. For a full list of contributors, see "credits.txt".
  8. The full license can be read in "license.txt".
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. See the GNU General Public License for more details.
  14. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  15. Mail: info@dokeos.com
  16. ==============================================================================
  17. */
  18. /*
  19. * Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
  20. * Somes fixes by Julio Montoya
  21. */
  22. ob_start();
  23. $nameTools= 'Sessions';
  24. // name of the language file that needs to be included
  25. $language_file = array ('registration', 'index','trad4all','tracking');
  26. $cidReset=true;
  27. require ('../inc/global.inc.php');
  28. require_once (api_get_path(LIBRARY_PATH).'tracking.lib.php');
  29. require_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php');
  30. api_block_anonymous_users();
  31. $this_section = "session_my_space";
  32. api_block_anonymous_users();
  33. $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
  34. Display :: display_header($nameTools);
  35. // Database Table Definitions
  36. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  37. $tbl_sessions = Database :: get_main_table(TABLE_MAIN_SESSION);
  38. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  39. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  40. $export_csv = false;
  41. if (isset($_GET['export']) && $_GET['export'] == 'csv')
  42. {
  43. $export_csv=true;
  44. }
  45. /*
  46. ===============================================================================
  47. FUNCTION
  48. ===============================================================================
  49. */
  50. function count_sessions_coached()
  51. {
  52. global $nb_sessions;
  53. return $nb_sessions;
  54. }
  55. function sort_sessions($a, $b)
  56. {
  57. global $tracking_column;
  58. if($a[$tracking_column] > $b[$tracking_column])
  59. return 1;
  60. else
  61. return -1;
  62. }
  63. /*
  64. ===============================================================================
  65. MAIN CODE
  66. ===============================================================================
  67. */
  68. if(isset($_GET['id_coach']) && $_GET['id_coach']!='')
  69. {
  70. $id_coach=$_GET['id_coach'];
  71. }
  72. else
  73. {
  74. $id_coach=$_user['user_id'];
  75. }
  76. $a_sessions = Tracking :: get_sessions_coached_by_user($id_coach);
  77. $nb_sessions = count($a_sessions);
  78. if($export_csv)
  79. {
  80. $csv_content=array();
  81. }
  82. if($nb_sessions > 0)
  83. {
  84. echo '<div align="right">
  85. <a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
  86. <a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
  87. </div>';
  88. $table = new SortableTable('tracking', 'count_sessions_coached');
  89. $table -> set_header(0, get_lang('Title'));
  90. $table -> set_header(1, get_lang('Status'));
  91. $table -> set_header(2, get_lang('Date'));
  92. $table -> set_header(3, get_lang('Details'),false);
  93. $all_datas = array();
  94. foreach ($a_sessions as $session)
  95. {
  96. $row = array();
  97. $row[] = $session['name'];
  98. $row[] = $session['status'];
  99. if($session['date_start']!='0000-00-00' && $session['date_end']!='0000-00-00')
  100. {
  101. $row[] = get_lang('From').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'),strtotime($session['date_start'])).' '.get_lang('To').' '.format_locale_date(get_lang('DateFormatLongWithoutDay'),strtotime($session['date_end']));
  102. }
  103. else
  104. {
  105. $row[] = ' - ';
  106. }
  107. if($export_csv)
  108. {
  109. $csv_content[]=$row;
  110. }
  111. if(isset($_GET['id_coach']) && $_GET['id_coach']!='')
  112. {
  113. $row[] = '<a href="student.php?id_session='.$session['id'].'&id_coach='.$_GET['id_coach'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
  114. }
  115. else
  116. {
  117. $row[] = '<a href="course.php?id_session='.$session['id'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
  118. }
  119. $all_datas[] = $row;
  120. }
  121. if(!isset($tracking_column))
  122. {
  123. $tracking_column = 0;
  124. }
  125. usort($all_datas, 'sort_sessions');
  126. if($export_csv)
  127. {
  128. usort($csv_content, 'sort_sessions');
  129. }
  130. if($_GET['tracking_direction'] == 'DESC')
  131. {
  132. rsort($all_datas);
  133. }
  134. foreach($all_datas as $row)
  135. {
  136. $table -> addRow($row);
  137. }
  138. $table -> setColAttributes(3,array('align'=>'center'));
  139. $table -> display();
  140. if($export_csv)
  141. {
  142. ob_end_clean();
  143. Export :: export_table_csv($csv_content, 'reporting_student_list');
  144. }
  145. }
  146. else
  147. {
  148. get_lang('NoSession');
  149. }
  150. /*
  151. ==============================================================================
  152. FOOTER
  153. ==============================================================================
  154. */
  155. Display::display_footer();
  156. ?>