resume_session.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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(true);
  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. $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, session_admin_id
  53. FROM '.$tbl_session.'
  54. LEFT JOIN '.$tbl_user.'
  55. ON id_coach = user_id
  56. WHERE '.$tbl_session.'.id='.$id_session;
  57. $rs = api_sql_query($sql, __FILE__, __LINE__);
  58. $session = api_store_result($rs);
  59. $session = $session[0];
  60. if(!api_is_platform_admin() && $session['session_admin_id']!=$_user['user_id'])
  61. {
  62. api_not_allowed(true);
  63. }
  64. if($_GET['action'] == 'delete')
  65. {
  66. $idChecked = $_GET['idChecked'];
  67. if(is_array($idChecked))
  68. {
  69. $idChecked="'".implode("','",$idChecked)."'";
  70. api_sql_query("DELETE FROM $tbl_session_rel_course WHERE id_session='$id_session' AND course_code IN($idChecked)",__FILE__,__LINE__);
  71. $nbr_affected_rows=mysql_affected_rows();
  72. api_sql_query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code IN($idChecked)",__FILE__,__LINE__);
  73. api_sql_query("UPDATE $tbl_session SET nbr_courses=nbr_courses-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
  74. }
  75. if(!empty($_GET['class'])){
  76. api_sql_query("DELETE FROM $tbl_session_rel_class WHERE session_id='$id_session' AND class_id=".$_GET['class'],__FILE__,__LINE__);
  77. $nbr_affected_rows=mysql_affected_rows();
  78. api_sql_query("UPDATE $tbl_session SET nbr_classes=nbr_classes-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
  79. }
  80. if(!empty($_GET['user'])){
  81. api_sql_query("DELETE FROM $tbl_session_rel_user WHERE id_session='$id_session' AND id_user=".$_GET['user'],__FILE__,__LINE__);
  82. $nbr_affected_rows=mysql_affected_rows();
  83. api_sql_query("UPDATE $tbl_session SET nbr_users=nbr_users-$nbr_affected_rows WHERE id='$id_session'",__FILE__,__LINE__);
  84. api_sql_query("DELETE FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND id_user=".$_GET['user'],__FILE__,__LINE__);
  85. $nbr_affected_rows=mysql_affected_rows();
  86. api_sql_query("UPDATE $tbl_session_rel_course SET nbr_users=nbr_users-$nbr_affected_rows WHERE id_session='$id_session'",__FILE__,__LINE__);
  87. }
  88. }
  89. Display::display_header($tool_name);
  90. api_display_tool_title($tool_name);
  91. ?>
  92. <!-- General properties -->
  93. <table class="data_table" width="100%">
  94. <tr>
  95. <th colspan="2"><?php echo get_lang('GeneralProperties'); ?>
  96. <a href="session_edit.php?page=resume_session.php&id=<?php echo $id_session; ?>"><img src="../img/edit.gif" border="0" align="absmiddle" title="<?php echo get_lang('Edit'); ?>"></a></th>
  97. </th>
  98. </tr>
  99. <tr>
  100. <td><?php echo get_lang('SessionName');?> :</td>
  101. <td><?php echo $session['name'] ?></td>
  102. </tr>
  103. <tr>
  104. <td><?php echo get_lang('GeneralCoach'); ?> :</td>
  105. <td><?php echo $session['lastname'].' '.$session['firstname'].' ('.$session['username'].')' ?></td>
  106. </tr>
  107. <tr>
  108. <td><?php echo ('Dates'); ?> :</td>
  109. <td>
  110. <?php
  111. if($session['date_start']=='00-00-0000')
  112. echo get_lang('NoTimeLimits');
  113. else
  114. echo get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'];
  115. ?>
  116. </td>
  117. </tr>
  118. </table>
  119. <br />
  120. <!--List of courses -->
  121. <table class="data_table" width="100%">
  122. <tr>
  123. <th colspan="4"><?php echo get_lang('CourseList'); ?>
  124. <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="<?php echo get_lang('Edit'); ?>"></a></th>
  125. </th>
  126. </tr>
  127. <tr>
  128. <tr>
  129. <th width="35%"><?php echo get_lang('CourseTitle'); ?></th>
  130. <th width="30%"><?php echo get_lang('CourseCoach'); ?></th>
  131. <th width="20%"><?php echo get_lang('UsersNumber'); ?></th>
  132. <th width="15%"><?php echo get_lang('Actions'); ?></th>
  133. </tr>
  134. </tr>
  135. <?php
  136. if($session['nbr_courses']==0){
  137. echo '
  138. <tr>
  139. <td colspan="4">'.get_lang('NoCoursesForThisSession').'</td>
  140. </tr>';
  141. }
  142. else {
  143. // select the courses
  144. $sql = "SELECT code,title,visual_code, nbr_users, lastname, firstname, username
  145. FROM $tbl_course,$tbl_session_rel_course
  146. LEFT JOIN $tbl_user
  147. ON $tbl_session_rel_course.id_coach = $tbl_user.user_id
  148. WHERE course_code=code
  149. AND id_session='$id_session'
  150. ORDER BY title";
  151. $result=api_sql_query($sql,__FILE__,__LINE__);
  152. $courses=api_store_result($result);
  153. foreach($courses as $course){
  154. //select the number of users
  155. $sql = 'SELECT COUNT(id_user) as nb_users FROM '.$tbl_session_rel_course_rel_user.' WHERE course_code="'.Database::escape_string($course['code']).'" AND id_session='.intval($id_session);
  156. $rs = api_sql_query($sql, __FILE__, __LINE__);
  157. $course['nbr_users'] = mysql_result($rs,0,0);
  158. if(empty($course['username']))
  159. $coach = get_lang('None');
  160. else
  161. $coach = $course['lastname'].' '.$course['firstname'].' ('.$course['username'].')';
  162. echo '
  163. <tr>
  164. <td>'.$course['title'].' ('.$course['visual_code'].')</td>
  165. <td>'.$coach.'</td>
  166. <td>'.$course['nbr_users'].'</td>
  167. <td>
  168. <a href="../tracking/courseLog.php?id_session='.$id_session.'&cidReq='.$course['code'].'"><img src="../img/statistics.gif" border="0" style="vertical-align: middle;" title="'.get_lang('Tracking').'" alt="'.get_lang('Tracking').'"/></a>&nbsp;
  169. <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="'.get_lang('Edit').'"></a>
  170. <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="'.get_lang('Delete').'"></a>
  171. </td>
  172. </tr>';
  173. }
  174. }
  175. ?>
  176. </table>
  177. <br />
  178. <!--List of courses -->
  179. <table class="data_table" width="100%">
  180. <tr>
  181. <th colspan="4"><?php echo get_lang('UserList'); ?>
  182. <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="<?php echo get_lang('Edit'); ?>"></a></th>
  183. </th>
  184. </tr>
  185. </tr>
  186. <?php
  187. if($session['nbr_users']==0){
  188. echo '
  189. <tr>
  190. <td colspan="2">'.get_lang('NoUsersForThisSession').'</td>
  191. </tr>';
  192. }
  193. else {
  194. // classe development, obsolete for the moment
  195. $sql = 'SELECT '.$tbl_user.'.user_id, lastname, firstname, username
  196. FROM '.$tbl_user.'
  197. INNER JOIN '.$tbl_session_rel_user.'
  198. ON '.$tbl_user.'.user_id = '.$tbl_session_rel_user.'.id_user
  199. AND '.$tbl_session_rel_user.'.id_session = '.$id_session.'
  200. ORDER BY lastname, firstname';
  201. $result=api_sql_query($sql,__FILE__,__LINE__);
  202. $users=api_store_result($result);
  203. foreach($users as $user){
  204. echo '<tr>
  205. <td width="90%">
  206. <b>'.$user['lastname'].' '.$user['firstname'].' ('.$user['username'].')</b>
  207. </td>
  208. <td>
  209. <a href="../mySpace/myStudents.php?student='.$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="'.get_lang('Delete').'"></a>
  210. </td>
  211. </tr>';
  212. }
  213. }
  214. ?>
  215. </table>
  216. <?php
  217. /*
  218. ==============================================================================
  219. FOOTER
  220. ==============================================================================
  221. */
  222. Display :: display_footer();
  223. ?>