session_category_edit.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Edition script for sessions categories
  5. * @package chamilo.admin
  6. */
  7. /**
  8. * Code
  9. */
  10. // name of the language file that needs to be included
  11. $language_file ='admin';
  12. $cidReset=true;
  13. ////require_once '../inc/global.inc.php';
  14. // setting the section (for the tabs)
  15. $this_section=SECTION_PLATFORM_ADMIN;
  16. api_protect_admin_script(true);
  17. $id=intval($_GET['id']);
  18. $formSent=0;
  19. $errorMsg='';
  20. // Database Table Definitions
  21. $tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
  22. $tool_name = get_lang('EditSessionCategory');
  23. $interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
  24. $interbreadcrumb[]=array('url' => "session_category_list.php","name" => get_lang('ListSessionCategory'));
  25. $sql = "SELECT * FROM $tbl_session_category WHERE id='".$id."' ORDER BY name";
  26. $result=Database::query($sql);
  27. if (!$infos=Database::fetch_array($result)) {
  28. header('Location: session_list.php');
  29. exit();
  30. }
  31. list($year_start,$month_start,$day_start)=explode('-',$infos['date_start']);
  32. list($year_end,$month_end,$day_end)=explode('-',$infos['date_end']);
  33. if (!api_is_platform_admin() && $infos['session_admin_id']!=$_user['user_id'] && !api_is_session_admin()) {
  34. api_not_allowed(true);
  35. }
  36. if ($_POST['formSent']) {
  37. $formSent=1;
  38. $name= $_POST['name'];
  39. $year_start= $_POST['year_start'];
  40. $month_start=$_POST['month_start'];
  41. $day_start=$_POST['day_start'];
  42. $year_end=$_POST['year_end'];
  43. $month_end=$_POST['month_end'];
  44. $day_end=$_POST['day_end'];
  45. $return = SessionManager::edit_category_session($id, $name, $year_start, $month_start, $day_start, $year_end, $month_end, $day_end);
  46. if ($return == strval(intval($return))) {
  47. header('Location: session_category_list.php?action=show_message&message='.urlencode(get_lang('SessionCategoryUpdate')));
  48. exit();
  49. }
  50. }
  51. $thisYear=date('Y');
  52. $thisMonth=date('m');
  53. $thisDay=date('d');
  54. // display the header
  55. Display::display_header($tool_name);
  56. if (!empty($return)) {
  57. Display::display_error_message($return,false);
  58. }
  59. ?>
  60. <form method="post" name="form" action="<?php echo api_get_self(); ?>?page=<?php echo Security::remove_XSS($_GET['page']) ?>&id=<?php echo $id; ?>" style="margin:0px;">
  61. <input type="hidden" name="formSent" value="1">
  62. <legend><?php echo $tool_name;?> </legend>
  63. <table border="0" cellpadding="5" cellspacing="0" width="550">
  64. <tr>
  65. <td width="30%"><?php echo get_lang('SessionName') ?>&nbsp;&nbsp;</td>
  66. <td width="70%"><input type="text" name="name" size="50" maxlength="50" value="<?php if($formSent) echo api_htmlentities($name,ENT_QUOTES,$charset); else echo api_htmlentities($infos['name'],ENT_QUOTES,$charset); ?>"></td>
  67. </tr>
  68. <td colspan="2">
  69. <a href="javascript://" onclick="if(document.getElementById('options').style.display == 'none'){document.getElementById('options').style.display = 'block';}else{document.getElementById('options').style.display = 'none';}"><?php echo get_lang('EditTimeLimit') ?></a>
  70. <div style="display: <?php if($formSent && ($nb_days_acess_before!=0 || $nb_days_acess_after!=0)) echo 'block'; else echo 'none'; ?>;" id="options">
  71. <br>
  72. <div>
  73. <table border="0" cellpadding="5" cellspacing="0" width="100%">
  74. <tr><td colspan="2"><?php echo get_lang('TheTimeLimitsAreReferential');?></td>
  75. </tr>
  76. <tr>
  77. <td width="20%"><?php echo get_lang('DateStart') ?>&nbsp;&nbsp;</td>
  78. <td width="80%">
  79. <select name="day_start">
  80. <option value="1">01</option>
  81. <option value="2" <?php if($day_start == 2) echo 'selected="selected"'; ?> >02</option>
  82. <option value="3" <?php if($day_start == 3) echo 'selected="selected"'; ?> >03</option>
  83. <option value="4" <?php if($day_start == 4) echo 'selected="selected"'; ?> >04</option>
  84. <option value="5" <?php if($day_start == 5) echo 'selected="selected"'; ?> >05</option>
  85. <option value="6" <?php if($day_start == 6) echo 'selected="selected"'; ?> >06</option>
  86. <option value="7" <?php if($day_start == 7) echo 'selected="selected"'; ?> >07</option>
  87. <option value="8" <?php if($day_start == 8) echo 'selected="selected"'; ?> >08</option>
  88. <option value="9" <?php if($day_start == 9) echo 'selected="selected"'; ?> >09</option>
  89. <option value="10" <?php if($day_start == 10) echo 'selected="selected"'; ?> >10</option>
  90. <option value="11" <?php if($day_start == 11) echo 'selected="selected"'; ?> >11</option>
  91. <option value="12" <?php if($day_start == 12) echo 'selected="selected"'; ?> >12</option>
  92. <option value="13" <?php if($day_start == 13) echo 'selected="selected"'; ?> >13</option>
  93. <option value="14" <?php if($day_start == 14) echo 'selected="selected"'; ?> >14</option>
  94. <option value="15" <?php if($day_start == 15) echo 'selected="selected"'; ?> >15</option>
  95. <option value="16" <?php if($day_start == 16) echo 'selected="selected"'; ?> >16</option>
  96. <option value="17" <?php if($day_start == 17) echo 'selected="selected"'; ?> >17</option>
  97. <option value="18" <?php if($day_start == 18) echo 'selected="selected"'; ?> >18</option>
  98. <option value="19" <?php if($day_start == 19) echo 'selected="selected"'; ?> >19</option>
  99. <option value="20" <?php if($day_start == 20) echo 'selected="selected"'; ?> >20</option>
  100. <option value="21" <?php if($day_start == 21) echo 'selected="selected"'; ?> >21</option>
  101. <option value="22" <?php if($day_start == 22) echo 'selected="selected"'; ?> >22</option>
  102. <option value="23" <?php if($day_start == 23) echo 'selected="selected"'; ?> >23</option>
  103. <option value="24" <?php if($day_start == 24) echo 'selected="selected"'; ?> >24</option>
  104. <option value="25" <?php if($day_start == 25) echo 'selected="selected"'; ?> >25</option>
  105. <option value="26" <?php if($day_start == 26) echo 'selected="selected"'; ?> >26</option>
  106. <option value="27" <?php if($day_start == 27) echo 'selected="selected"'; ?> >27</option>
  107. <option value="28" <?php if($day_start == 28) echo 'selected="selected"'; ?> >28</option>
  108. <option value="29" <?php if($day_start == 29) echo 'selected="selected"'; ?> >29</option>
  109. <option value="30" <?php if($day_start == 30) echo 'selected="selected"'; ?> >30</option>
  110. <option value="31" <?php if($day_start == 31) echo 'selected="selected"'; ?> >31</option>
  111. </select>
  112. /
  113. <select name="month_start">
  114. <option value="1">01</option>
  115. <option value="2" <?php if($month_start == 2) echo 'selected="selected"'; ?> >02</option>
  116. <option value="3" <?php if($month_start == 3) echo 'selected="selected"'; ?> >03</option>
  117. <option value="4" <?php if($month_start == 4) echo 'selected="selected"'; ?> >04</option>
  118. <option value="5" <?php if($month_start == 5) echo 'selected="selected"'; ?> >05</option>
  119. <option value="6" <?php if($month_start == 6) echo 'selected="selected"'; ?> >06</option>
  120. <option value="7" <?php if($month_start == 7) echo 'selected="selected"'; ?> >07</option>
  121. <option value="8" <?php if($month_start == 8) echo 'selected="selected"'; ?> >08</option>
  122. <option value="9" <?php if($month_start == 9) echo 'selected="selected"'; ?> >09</option>
  123. <option value="10" <?php if($month_start == 10) echo 'selected="selected"'; ?> >10</option>
  124. <option value="11" <?php if($month_start == 11) echo 'selected="selected"'; ?> >11</option>
  125. <option value="12" <?php if($month_start == 12) echo 'selected="selected"'; ?> >12</option>
  126. </select>
  127. /
  128. <select name="year_start">
  129. <?php
  130. for($i=$thisYear-5;$i <= ($thisYear+5);$i++)
  131. { ?>
  132. <option value="<?php echo $i; ?>" <?php if($year_start == $i) echo 'selected="selected"'; ?> ><?php echo $i; ?></option>
  133. <?php
  134. } ?>
  135. </select>
  136. </td>
  137. </tr>
  138. <tr>
  139. <td width="20%"><?php echo get_lang('DateEnd') ?>&nbsp;&nbsp;</td>
  140. <td width="80%">
  141. <select name="day_end">
  142. <option value="0">--</option>
  143. <option value="1" <?php if($day_end == 1) echo 'selected="selected"'; ?> >01</option>
  144. <option value="2" <?php if($day_end == 2) echo 'selected="selected"'; ?> >02</option>
  145. <option value="3" <?php if($day_end == 3) echo 'selected="selected"'; ?> >03</option>
  146. <option value="4" <?php if($day_end == 4) echo 'selected="selected"'; ?> >04</option>
  147. <option value="5" <?php if($day_end == 5) echo 'selected="selected"'; ?> >05</option>
  148. <option value="6" <?php if($day_end == 6) echo 'selected="selected"'; ?> >06</option>
  149. <option value="7" <?php if($day_end == 7) echo 'selected="selected"'; ?> >07</option>
  150. <option value="8" <?php if($day_end == 8) echo 'selected="selected"'; ?> >08</option>
  151. <option value="9" <?php if($day_end == 9) echo 'selected="selected"'; ?> >09</option>
  152. <option value="10" <?php if($day_end == 10) echo 'selected="selected"'; ?> >10</option>
  153. <option value="11" <?php if($day_end == 11) echo 'selected="selected"'; ?> >11</option>
  154. <option value="12" <?php if($day_end == 12) echo 'selected="selected"'; ?> >12</option>
  155. <option value="13" <?php if($day_end == 13) echo 'selected="selected"'; ?> >13</option>
  156. <option value="14" <?php if($day_end == 14) echo 'selected="selected"'; ?> >14</option>
  157. <option value="15" <?php if($day_end == 15) echo 'selected="selected"'; ?> >15</option>
  158. <option value="16" <?php if($day_end == 16) echo 'selected="selected"'; ?> >16</option>
  159. <option value="17" <?php if($day_end == 17) echo 'selected="selected"'; ?> >17</option>
  160. <option value="18" <?php if($day_end == 18) echo 'selected="selected"'; ?> >18</option>
  161. <option value="19" <?php if($day_end == 19) echo 'selected="selected"'; ?> >19</option>
  162. <option value="20" <?php if($day_end == 20) echo 'selected="selected"'; ?> >20</option>
  163. <option value="21" <?php if($day_end == 21) echo 'selected="selected"'; ?> >21</option>
  164. <option value="22" <?php if($day_end == 22) echo 'selected="selected"'; ?> >22</option>
  165. <option value="23" <?php if($day_end == 23) echo 'selected="selected"'; ?> >23</option>
  166. <option value="24" <?php if($day_end == 24) echo 'selected="selected"'; ?> >24</option>
  167. <option value="25" <?php if($day_end == 25) echo 'selected="selected"'; ?> >25</option>
  168. <option value="26" <?php if($day_end == 26) echo 'selected="selected"'; ?> >26</option>
  169. <option value="27" <?php if($day_end == 27) echo 'selected="selected"'; ?> >27</option>
  170. <option value="28" <?php if($day_end == 28) echo 'selected="selected"'; ?> >28</option>
  171. <option value="29" <?php if($day_end == 29) echo 'selected="selected"'; ?> >29</option>
  172. <option value="30" <?php if($day_end == 30) echo 'selected="selected"'; ?> >30</option>
  173. <option value="31" <?php if($day_end == 31) echo 'selected="selected"'; ?> >31</option>
  174. </select>
  175. /
  176. <select name="month_end">
  177. <option value="0">--</option>
  178. <option value="1" <?php if($month_end == 1) echo 'selected="selected"'; ?> >01</option>
  179. <option value="2" <?php if($month_end == 2) echo 'selected="selected"'; ?> >02</option>
  180. <option value="3" <?php if($month_end == 3) echo 'selected="selected"'; ?> >03</option>
  181. <option value="4" <?php if($month_end == 4) echo 'selected="selected"'; ?> >04</option>
  182. <option value="5" <?php if($month_end == 5) echo 'selected="selected"'; ?> >05</option>
  183. <option value="6" <?php if($month_end == 6) echo 'selected="selected"'; ?> >06</option>
  184. <option value="7" <?php if($month_end == 7) echo 'selected="selected"'; ?> >07</option>
  185. <option value="8" <?php if($month_end == 8) echo 'selected="selected"'; ?> >08</option>
  186. <option value="9" <?php if($month_end == 9) echo 'selected="selected"'; ?> >09</option>
  187. <option value="10" <?php if($month_end == 10) echo 'selected="selected"'; ?> >10</option>
  188. <option value="11" <?php if($month_end == 11) echo 'selected="selected"'; ?> >11</option>
  189. <option value="12" <?php if($month_end == 12) echo 'selected="selected"'; ?> >12</option>
  190. </select>
  191. /
  192. <select name="year_end">
  193. <option value="0">----</option>
  194. <?php
  195. for($i=$thisYear-5;$i <= ($thisYear+5);$i++)
  196. { ?>
  197. <option value="<?php echo $i; ?>" <?php if($year_end == $i) echo 'selected="selected"'; ?> ><?php echo $i; ?></option>
  198. <?php
  199. } ?>
  200. </select>
  201. </td>
  202. </tr>
  203. </table>
  204. </div>
  205. <br>
  206. </div>
  207. </td>
  208. </tr>
  209. <tr>
  210. <td>&nbsp;</td>
  211. <td>
  212. <button class="save" type="submit" value="<?php echo get_lang('ModifyThisSession') ?>"><?php echo get_lang('ModifyThisSession') ?></button>
  213. </td>
  214. </tr>
  215. </table>
  216. </form>
  217. <script>
  218. <?php if($year_start=="0000") echo "setDisable(document.form.nolimit);\r\n"; ?>
  219. function setDisable(select){
  220. document.form.day_start.disabled = (select.checked) ? true : false;
  221. document.form.month_start.disabled = (select.checked) ? true : false;
  222. document.form.year_start.disabled = (select.checked) ? true : false;
  223. document.form.day_end.disabled = (select.checked) ? true : false;
  224. document.form.month_end.disabled = (select.checked) ? true : false;
  225. document.form.year_end.disabled = (select.checked) ? true : false;
  226. }
  227. </script>
  228. <?php
  229. Display::display_footer();