student.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?php
  2. /*
  3. * Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
  4. */
  5. ob_start();
  6. $nameTools= 'Students';
  7. $langFile = array ('registration', 'index','trad4all', 'tracking');
  8. $cidReset=true;
  9. require ('../inc/global.inc.php');
  10. $this_section = "session_my_space";
  11. api_block_anonymous_users();
  12. $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
  13. Display :: display_header($nameTools);
  14. $tbl_course = Database :: get_main_table(MAIN_COURSE_TABLE);
  15. $tbl_user = Database :: get_main_table(MAIN_USER_TABLE);
  16. $tbl_session = Database :: get_main_table(MAIN_SESSION_TABLE);
  17. $tbl_session_course = Database :: get_main_table(MAIN_SESSION_COURSE_TABLE);
  18. $tbl_session_rel_user = Database :: get_main_table(MAIN_SESSION_USER_TABLE);
  19. /*
  20. ===============================================================================
  21. FUNCTION
  22. ===============================================================================
  23. */
  24. function exportCsv($a_header,$a_data)
  25. {
  26. global $archiveDirName;
  27. $fileName = 'students.csv';
  28. $archivePath = api_get_path(SYS_PATH).$archiveDirName.'/';
  29. $archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
  30. if(!$open = fopen($archivePath.$fileName,'w+'))
  31. {
  32. $message = get_lang('noOpen');
  33. }
  34. else
  35. {
  36. $info = '';
  37. foreach($a_header as $header)
  38. {
  39. $info .= $header.';';
  40. }
  41. $info .= "\r\n";
  42. foreach($a_data as $data)
  43. {
  44. foreach($data as $infos)
  45. {
  46. $info .= $infos.';';
  47. }
  48. $info .= "\r\n";
  49. }
  50. fwrite($open,$info);
  51. fclose($open);
  52. chmod($fileName,0777);
  53. header("Location:".$archiveURL.$fileName);
  54. }
  55. return $message;
  56. }
  57. /*
  58. ===============================================================================
  59. MAIN CODE
  60. ===============================================================================
  61. */
  62. $sqlStudent = " SELECT user_id,lastname,firstname,email
  63. FROM $tbl_user
  64. WHERE status = 5
  65. ORDER BY lastname ASC
  66. ";
  67. $resultStudent = api_sql_query($sqlStudent);
  68. $a_header[]=get_lang('Lastname');
  69. $a_header[]=get_lang('Firstname');
  70. $a_header[]=get_lang('Email');
  71. $a_header[]=get_lang('Tutor');
  72. $a_data=array();
  73. if(mysql_num_rows($resultStudent)>0)
  74. {
  75. echo '<table class="data_table">
  76. <tr>
  77. <th>
  78. '.get_lang('Lastname').'
  79. </th>
  80. <th>
  81. '.get_lang('Firstname').'
  82. </th>
  83. <th>
  84. '.get_lang('Email').'
  85. </th>
  86. <th>
  87. '.get_lang('Tutor').'
  88. </th>
  89. <th>
  90. '.get_lang('TakenSessions').'
  91. </th>
  92. </tr>
  93. ';
  94. while($a_student= mysql_fetch_array($resultStudent))
  95. {
  96. if($i%2==0){
  97. $s_css_class="row_odd";
  98. if($i%20==0 && $i!=0){
  99. echo '<tr>
  100. <th>
  101. '.get_lang('Lastname').'
  102. </th>
  103. <th>
  104. '.get_lang('Firstname').'
  105. </th>
  106. <th>
  107. '.get_lang('Email').'
  108. </th>
  109. <th>
  110. '.get_lang('Tutor').'
  111. </th>
  112. <th>
  113. '.get_lang('TakenSessions').'
  114. </th>
  115. </tr>';
  116. }
  117. }
  118. else{
  119. $s_css_class="row_even";
  120. }
  121. $i++;
  122. echo '<tr class="'.$s_css_class.'">
  123. <td>
  124. ';
  125. echo $a_student['lastname'];
  126. echo ' </td>
  127. <td>
  128. '.$a_student['firstname'].'
  129. </td>
  130. <td>
  131. ';
  132. if(!empty($a_student['email']))
  133. {
  134. echo '<a href="mailto:'.$s_email.'">'.$a_student['email'].'</a>';
  135. }
  136. else
  137. {
  138. //echo get_lang('NoEmail');
  139. }
  140. echo ' </td>
  141. <td>
  142. <a href="coaches.php?id_student='.$a_student['user_id'].'">-></a>
  143. </td>
  144. <td align="center">
  145. <a href="'.$_SERVER['PHP_SELF'].'?student='.$a_student['user_id'].'#sessionSuivie"> -> </a>
  146. </td>
  147. </tr>
  148. ';
  149. $a_data[$a_student['user_id']]["lastname"]=$a_student['lastname'];
  150. $a_data[$a_student['user_id']]["firstname"]=$a_student['firstname'];
  151. $a_data[$a_student['user_id']]["email"]=$a_student['email'];
  152. $a_data[$a_student['user_id']]["coach"]="";
  153. }
  154. echo '</table>';
  155. }
  156. else
  157. {
  158. echo get_lang('NoStudent');
  159. }
  160. if(isset($_POST['export'])){
  161. exportCsv($a_header,$a_data);
  162. }
  163. echo "<br /><br />";
  164. echo "<form method='post' action='student.php'>
  165. <input type='submit' name='export' value='".get_lang('exportExcel')."'/>
  166. <form>";
  167. if(!empty($_GET['student']))
  168. {
  169. $sqlSessionSuivie = " SELECT session.name
  170. FROM $tbl_session as session
  171. INNER JOIN $tbl_session_rel_user as relUser
  172. ON session.id = relUser.id_session
  173. AND relUser.id_user = ".$_GET['student']
  174. ;
  175. $resultSessionSuivie = api_sql_query($sqlSessionSuivie);
  176. echo "<br /><br />";
  177. echo "<a name='sessionSuivie'></a>";
  178. if(mysql_num_rows($resultSessionSuivie)>0)
  179. {
  180. echo "<table class='data_table'>
  181. <tr class='tableName'>
  182. <td colspan='2'>
  183. <strong>".get_lang('TakenSessions')."</strong>
  184. </td>
  185. </tr>
  186. <tr>
  187. <th>
  188. ".get_lang('Session')."
  189. </th>
  190. <th>
  191. ".get_lang('FollowUp')."
  192. </th>
  193. </tr>
  194. ";
  195. while($a_sessionSuivie = mysql_fetch_array($resultSessionSuivie))
  196. {
  197. echo "<tr>
  198. <td>
  199. ".$a_sessionSuivie['name']."
  200. </td>
  201. <td align='center'>
  202. <a href='../../myStudents.php?student=".$_GET['student']."#infosStudent'> -> </a>
  203. </td>
  204. </tr>
  205. ";
  206. }
  207. echo "</table>";
  208. }
  209. else
  210. {
  211. echo "<h4>".get_lang('TakenSessions')."</h4><br />";
  212. echo get_lang('NoSession');
  213. }
  214. }
  215. /*
  216. ==============================================================================
  217. FOOTER
  218. ==============================================================================
  219. */
  220. Display :: display_footer();
  221. ?>