session.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. /*
  3. * Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
  4. */
  5. ob_start();
  6. $nameTools= 'Sessions';
  7. // name of the language file that needs to be included
  8. $language_file = array ('registration', 'index','trad4all','tracking');
  9. $cidReset=true;
  10. require ('../inc/global.inc.php');
  11. require_once (api_get_path(LIBRARY_PATH).'tracking.lib.php');
  12. require_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php');
  13. api_block_anonymous_users();
  14. $this_section = "session_my_space";
  15. api_block_anonymous_users();
  16. $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
  17. Display :: display_header($nameTools);
  18. // Database Table Definitions
  19. $tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  20. $tbl_sessions = Database :: get_main_table(TABLE_MAIN_SESSION);
  21. $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
  22. $tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  23. $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
  24. if($export_csv)
  25. {
  26. ob_start();
  27. $csv_content = array();
  28. }
  29. /*
  30. ===============================================================================
  31. FUNCTION
  32. ===============================================================================
  33. */
  34. function count_sessions_coached()
  35. {
  36. global $nb_sessions;
  37. return $nb_sessions;
  38. }
  39. function sort_sessions($a, $b)
  40. {
  41. global $tracking_column;
  42. if($a[$tracking_column] > $b[$tracking_column])
  43. return 1;
  44. else
  45. return -1;
  46. }
  47. /*
  48. ===============================================================================
  49. MAIN CODE
  50. ===============================================================================
  51. */
  52. if(isset($_GET['id_coach']) && $_GET['id_coach']!=''){
  53. $id_coach=$_GET['id_coach'];
  54. }
  55. else{
  56. $id_coach=$_user['user_id'];
  57. }
  58. $a_sessions = Tracking :: get_sessions_coached_by_user ($id_coach);
  59. $nb_sessions = count($a_sessions);
  60. if($nb_sessions > 0)
  61. {
  62. echo '<div align="right">
  63. <a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
  64. <a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
  65. </div>';
  66. $table = new SortableTable('tracking', 'count_sessions_coached');
  67. $table -> set_header(0, get_lang('Title'));
  68. $table -> set_header(1, get_lang('Status'));
  69. $table -> set_header(2, get_lang('Date'));
  70. $table -> set_header(3, get_lang('Details'),false);
  71. $all_datas = array();
  72. foreach ($a_sessions as $session)
  73. {
  74. $row = array();
  75. $row[] = $session['name'];
  76. $row[] = $session['status'];
  77. if($session['date_start']!='0000-00-00' && $session['date_end']!='0000-00-00'){
  78. $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']));
  79. }
  80. else{
  81. $row[] = ' - ';
  82. }
  83. if($export_csv)
  84. {
  85. $csv_content[] = $row;
  86. }
  87. if(isset($_GET['id_coach']) && $_GET['id_coach']!=''){
  88. $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>';
  89. }
  90. else{
  91. $row[] = '<a href="course.php?id_session='.$session['id'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
  92. }
  93. $all_datas[] = $row;
  94. }
  95. if(!isset($tracking_column))
  96. $tracking_column = 0;
  97. usort($all_datas, 'sort_sessions');
  98. if($_GET['tracking_direction'] == 'DESC')
  99. {
  100. rsort($all_datas);
  101. }
  102. if($export_csv)
  103. {
  104. usort($csv_content, 'sort_sessions');
  105. }
  106. foreach($all_datas as $row)
  107. {
  108. $table -> addRow($row);
  109. }
  110. $table -> setColAttributes(3,array('align'=>'center'));
  111. $table -> display();
  112. if($export_csv)
  113. {
  114. ob_end_clean();
  115. Export :: export_table_csv($csv_content, 'reporting_student_list');
  116. }
  117. }
  118. else
  119. {
  120. get_lang('NoSession');
  121. }
  122. /*
  123. ==============================================================================
  124. FOOTER
  125. ==============================================================================
  126. */
  127. Display::display_footer();
  128. ?>