resume_session.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?php
  2. // $Id: course_list.php,v 1.15.2.1 2005/10/31 09:15:57 olivierb78 Exp $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2004 Dokeos S.A.
  7. Copyright (c) 2003 Ghent University (UGent)
  8. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9. Copyright (c) Olivier Brouckaert
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. @author Bart Mollet
  23. * @package dokeos.admin
  24. ==============================================================================
  25. */
  26. /*
  27. ==============================================================================
  28. INIT SECTION
  29. ==============================================================================
  30. */
  31. // name of the language file that needs to be included
  32. $language_file = 'admin';
  33. $cidReset = true;
  34. require ('../inc/global.inc.php');
  35. // setting the section (for the tabs)
  36. $this_section=SECTION_PLATFORM_ADMIN;
  37. api_protect_admin_script();
  38. $tool_name = get_lang('SessionOverview');
  39. $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
  40. $interbreadcrumb[]=array('url' => "session_list.php","name" => get_lang('SessionList'));
  41. // Database Table Definitions
  42. $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
  43. $tbl_session_rel_class = Database::get_main_table(TABLE_MAIN_SESSION_CLASS);
  44. $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
  45. $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
  46. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  47. $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
  48. $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
  49. $tbl_class = Database::get_main_table(TABLE_MAIN_CLASS);
  50. $tbl_class_rel_user = Database::get_main_table(TABLE_MAIN_CLASS_USER);
  51. $id_session = $_GET['id_session'];
  52. if($_GET['action'] == 'delete')
  53. {
  54. $idChecked = $_GET['idChecked'];
  55. if(is_array($idChecked))
  56. {
  57. $idChecked="'".implode("','",$idChecked)."'";
  58. api_sql_query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code IN($idChecked)",__FILE__,__LINE__);
  59. $nbr_affected_rows=mysql_affected_rows();
  60. api_sql_query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code IN($idChecked)",__FILE__,__LINE__);
  61. api_sql_query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
  62. }
  63. if(!empty($_GET['class'])){
  64. api_sql_query("DELETE FROM $tbl_session_rel_class WHERE session_id='$id_session' AND class_id=".$_GET['class'],__FILE__,__LINE__);
  65. $nbr_affected_rows=mysql_affected_rows();
  66. api_sql_query("UPDATE $tbl_session SET nbr_classes=nbr_classes-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
  67. }
  68. if(!empty($_GET['user'])){
  69. api_sql_query("DELETE FROM $tbl_session_rel_user WHERE id_session='$id_session' AND id_user=".$_GET['user'],__FILE__,__LINE__);
  70. $nbr_affected_rows=mysql_affected_rows();
  71. api_sql_query("UPDATE $tbl_session SET nbr_users=nbr_users-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
  72. api_sql_query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND id_user=".$_GET['user'],__FILE__,__LINE__);
  73. $nbr_affected_rows=mysql_affected_rows();
  74. api_sql_query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session'",__FILE__,__LINE__);
  75. }
  76. }
  77. $sql = 'SELECT name, nbr_courses, nbr_users, nbr_classes, DATE_FORMAT(date_start,"%d-%m-%Y") as date_start, DATE_FORMAT(date_end,"%d-%m-%Y") as date_end, lastname, firstname, username
  78. FROM '.$tbl_session.'
  79. LEFT JOIN '.$tbl_user.'
  80. ON id_coach = user_id
  81. WHERE '.$tbl_session.'.id='.$id_session;
  82. $rs = api_sql_query($sql, __FILE__, __LINE__);
  83. $session = api_store_result($rs);
  84. $session = $session[0];
  85. Display::display_header($tool_name);
  86. api_display_tool_title($tool_name);
  87. ?>
  88. <!-- General properties -->
  89. <table class="data_table" width="100%">
  90. <tr>
  91. <th colspan="2"><?php echo get_lang('GeneralProperties'); ?>
  92. <a href="session_edit.php?page=resume_session.php&id=<?php echo $id_session; ?>"><img src="../img/edit.gif" border="0" align="absmiddle" title="Editer"></a></th>
  93. </th>
  94. </tr>
  95. <tr>
  96. <td><?php echo get_lang('SessionName');?> :</td>
  97. <td><?php echo $session['name'] ?></td>
  98. </tr>
  99. <tr>
  100. <td><?php echo get_lang('GeneralCoach'); ?> :</td>
  101. <td><?php echo $session['lastname'].' '.$session['firstname'].' ('.$session['username'].')' ?></td>
  102. </tr>
  103. <tr>
  104. <td><?php echo ('Dates'); ?> :</td>
  105. <td>
  106. <?php
  107. if($session['date_start']=='00-00-0000')
  108. echo get_lang('NoTimeLimits');
  109. else
  110. echo 'Du '.$session['date_start'].' au '.$session['date_end'];
  111. ?>
  112. </td>
  113. </tr>
  114. </table>
  115. <br />
  116. <!--List of courses -->
  117. <table class="data_table" width="100%">
  118. <tr>
  119. <th colspan="4"><?php echo get_lang('CourseList'); ?>
  120. <a href="add_courses_to_session.php?page=resume_session.php&id_session=<?php echo $id_session; ?>"><img src="../img/edit.gif" border="0" align="absmiddle" title="Editer"></a></th>
  121. </th>
  122. </tr>
  123. <tr>
  124. <tr>
  125. <th width="35%"><?php echo get_lang('CourseTitle'); ?></th>
  126. <th width="30%"><?php echo get_lang('CourseCoach'); ?></th>
  127. <th width="20%"><?php echo get_lang('UsersNumber'); ?></th>
  128. <th width="15%"><?php echo get_lang('Actions'); ?></th>
  129. </tr>
  130. </tr>
  131. <?php
  132. if($session['nbr_courses']==0){
  133. echo '
  134. <tr>
  135. <td colspan="4">Pas de cours pour cette session</td>
  136. </tr>';
  137. }
  138. else {
  139. $sql = "SELECT code,title,nbr_users, lastname, firstname, username
  140. FROM $tbl_course,$tbl_session_rel_course
  141. LEFT JOIN $tbl_user
  142. ON $tbl_session_rel_course.id_coach = $tbl_user.user_id
  143. WHERE course_code=code
  144. AND id_session='$id_session'
  145. ORDER BY title";
  146. $result=api_sql_query($sql,__FILE__,__LINE__);
  147. $courses=api_store_result($result);
  148. foreach($courses as $course){
  149. if(empty($course['username']))
  150. $coach = 'Aucun';
  151. else
  152. $coach = $course['lastname'].' '.$course['firstname'].' ('.$course['username'].')';
  153. echo '
  154. <tr>
  155. <td>'.$course['title'].' ('.$course['code'].')</td>
  156. <td>'.$coach.'</td>
  157. <td>'.$course['nbr_users'].'</td>
  158. <td>
  159. <a href="../tracking/courseLog.php?cidReq='.$course['code'].'"><img src="../img/statistics.gif" border="0" style="vertical-align: middle;" title="'.get_lang('Tracking').'" alt="'.get_lang('Tracking').'"/></a>&nbsp;
  160. <a href="session_course_edit.php?id_session='.$id_session.'&page=resume_session.php&course_code='.$course['code'].'"><img src="../img/edit.gif" border="0" align="absmiddle" title="Editer"></a>
  161. <a href="'.api_get_self().'?id_session='.$id_session.'&action=delete&idChecked[]='.$course['code'].'" onclick="javascript:if(!confirm(\''.get_lang('ConfirmYourChoice').'\')) return false;"><img src="../img/delete.gif" border="0" align="absmiddle" title="Effacer"></a>
  162. </td>
  163. </tr>';
  164. }
  165. }
  166. ?>
  167. </table>
  168. <br />
  169. <!--List of courses -->
  170. <table class="data_table" width="100%">
  171. <tr>
  172. <th colspan="4"><?php echo get_lang('UserList'); ?>
  173. <a href="add_users_to_session.php?page=resume_session.php&id_session=<?php echo $id_session; ?>"><img src="../img/edit.gif" border="0" align="absmiddle" title="Editer"></a></th>
  174. </th>
  175. </tr>
  176. </tr>
  177. <?php
  178. if($session['nbr_users']==0){
  179. echo '
  180. <tr>
  181. <td colspan="2">Pas d\'utilisateurs pour cette session</td>
  182. </tr>';
  183. }
  184. else {
  185. // classe development, obsolete for the moment
  186. $sql = 'SELECT '.$tbl_user.'.user_id, lastname, firstname, username
  187. FROM '.$tbl_user.'
  188. INNER JOIN '.$tbl_session_rel_user.'
  189. ON '.$tbl_user.'.user_id = '.$tbl_session_rel_user.'.id_user
  190. AND '.$tbl_session_rel_user.'.id_session = '.$id_session.'
  191. ORDER BY lastname, firstname';
  192. $result=api_sql_query($sql,__FILE__,__LINE__);
  193. $users=api_store_result($result);
  194. foreach($users as $user){
  195. echo '<tr>
  196. <td width="90%">
  197. <b>'.$user['lastname'].' '.$user['firstname'].' ('.$user['username'].')</b>
  198. </td>
  199. <td>
  200. <a href="../mySpace/student.php?user_id='.$user['user_id'].'"><img src="../img/statistics.gif" border="0" style="vertical-align: middle;" title="'.get_lang('Reporting').'" alt="'.get_lang('Reporting').'"/></a>&nbsp;<a href="'.api_get_self().'?id_session='.$id_session.'&action=delete&user='.$user['user_id'].'" onclick="javascript:if(!confirm(\''.get_lang('ConfirmYourChoice').'\')) return false;"><img src="../img/delete.gif" border="0" align="absmiddle" title="Effacer"></a>
  201. </td>
  202. </tr>';
  203. }
  204. }
  205. ?>
  206. </table>
  207. <?php
  208. /*
  209. ==============================================================================
  210. FOOTER
  211. ==============================================================================
  212. */
  213. Display :: display_footer();
  214. ?>