session_category_edit.php 16 KB

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