session_add.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.admin
  5. * @todo use formvalidator for the form, remove all the select harcoded values
  6. */
  7. // name of the language file that needs to be included
  8. $language_file='admin';
  9. $cidReset=true;
  10. // including the global Chamilo file
  11. require_once '../inc/global.inc.php';
  12. // including additional libraries
  13. require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
  14. require_once '../inc/lib/xajax/xajax.inc.php';
  15. $xajax = new xajax();
  16. //$xajax->debugOn();
  17. $xajax -> registerFunction ('search_coachs');
  18. // setting the section (for the tabs)
  19. $this_section=SECTION_PLATFORM_ADMIN;
  20. api_protect_admin_script(true);
  21. $formSent=0;
  22. $errorMsg='';
  23. $interbreadcrumb[]=array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  24. $interbreadcrumb[]=array('url' => 'session_list.php','name' => get_lang('SessionList'));
  25. // Database Table Definitions
  26. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  27. $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
  28. function search_coachs($needle) {
  29. global $tbl_user;
  30. $xajax_response = new XajaxResponse();
  31. $return = '';
  32. if(!empty($needle)) {
  33. // xajax send utf8 datas... datas in db can be non-utf8 datas
  34. $charset = api_get_system_encoding();
  35. $needle = api_convert_encoding($needle, $charset, 'utf-8');
  36. $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
  37. // search users where username or firstname or lastname begins likes $needle
  38. $sql = 'SELECT username, lastname, firstname FROM '.$tbl_user.' user
  39. WHERE (username LIKE "'.$needle.'%"
  40. OR firstname LIKE "'.$needle.'%"
  41. OR lastname LIKE "'.$needle.'%")
  42. AND status=1'.
  43. $order_clause.
  44. ' LIMIT 10';
  45. global $_configuration;
  46. if ($_configuration['multiple_access_urls']) {
  47. $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
  48. $access_url_id = api_get_current_access_url_id();
  49. if ($access_url_id != -1){
  50. $sql = 'SELECT username, lastname, firstname FROM '.$tbl_user.' user
  51. INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
  52. WHERE access_url_id = '.$access_url_id.' AND (username LIKE "'.$needle.'%"
  53. OR firstname LIKE "'.$needle.'%"
  54. OR lastname LIKE "'.$needle.'%")
  55. AND status=1'.
  56. $order_clause.
  57. ' LIMIT 10';
  58. }
  59. }
  60. $rs = Database::query($sql);
  61. while ($user = Database :: fetch_array($rs)) {
  62. $return .= '<a href="javascript: void(0);" onclick="javascript: fill_coach_field(\''.$user['username'].'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
  63. }
  64. }
  65. $xajax_response -> addAssign('ajax_list_coachs','innerHTML', api_utf8_encode($return));
  66. return $xajax_response;
  67. }
  68. $xajax -> processRequests();
  69. $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/');
  70. $htmlHeadXtra[] = '
  71. <script type="text/javascript">
  72. function fill_coach_field (username) {
  73. document.getElementById("coach_username").value = username;
  74. document.getElementById("ajax_list_coachs").innerHTML = "";
  75. }
  76. </script>';
  77. if ($_POST['formSent']) {
  78. $formSent = 1;
  79. $name = $_POST['name'];
  80. $year_start = $_POST['year_start'];
  81. $month_start = $_POST['month_start'];
  82. $day_start = $_POST['day_start'];
  83. $year_end = $_POST['year_end'];
  84. $month_end = $_POST['month_end'];
  85. $day_end = $_POST['day_end'];
  86. $nb_days_acess_before = $_POST['nb_days_acess_before'];
  87. $nb_days_acess_after = $_POST['nb_days_acess_after'];
  88. //$nolimit = $_POST['nolimit'];
  89. $coach_username = $_POST['coach_username'];
  90. $id_session_category = $_POST['session_category'];
  91. $id_visibility = $_POST['session_visibility'];
  92. $end_limit = $_POST['end_limit'];
  93. $start_limit = $_POST['start_limit'];
  94. if (empty($end_limit) && empty($start_limit)) {
  95. $nolimit = 1;
  96. } else {
  97. $nolimit = null;
  98. }
  99. $return = SessionManager::create_session($name,$year_start,$month_start,$day_start,$year_end,$month_end,$day_end,$nb_days_acess_before,$nb_days_acess_after,$nolimit,$coach_username, $id_session_category,$id_visibility, $start_limit, $end_limit);
  100. if ($return == strval(intval($return))) {
  101. // integer => no error on session creation
  102. header('Location: add_courses_to_session.php?id_session='.$return.'&add=true&msg=');
  103. exit();
  104. }
  105. }
  106. $nb_days_acess_before = 0;
  107. $nb_days_acess_after = 0;
  108. $thisYear=date('Y');
  109. $thisMonth=date('m');
  110. $thisDay=date('d');
  111. $tool_name = get_lang('AddSession');
  112. //display the header
  113. Display::display_header($tool_name);
  114. if (!empty($return)) {
  115. Display::display_error_message($return,false);
  116. }
  117. ?>
  118. <form method="post" name="form" action="<?php echo api_get_self(); ?>" style="margin:0px;">
  119. <input type="hidden" name="formSent" value="1">
  120. <?php
  121. echo '<div class="actions">';
  122. echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'','32').'</a>';
  123. echo '</div>';
  124. //echo '<div class=row><div class="form_header">';
  125. //echo $tool_name;
  126. //echo '</div></div>';
  127. ?>
  128. <table border="0" cellpadding="5" cellspacing="0" width="650">
  129. <tr>
  130. <td width="40%"><?php echo get_lang('SessionName') ?>&nbsp;&nbsp;</td>
  131. <td width="60%"><input type="text" name="name" size="50" maxlength="50" value="<?php if($formSent) echo api_htmlentities($name,ENT_QUOTES,$charset); ?>"></td>
  132. </tr>
  133. <tr>
  134. <td width="40%"><?php echo get_lang('CoachName') ?>&nbsp;&nbsp;</td>
  135. <td width="60%">
  136. <?php
  137. $sql = 'SELECT COUNT(1) FROM '.$tbl_user.' WHERE status=1';
  138. $rs = Database::query($sql);
  139. $count_users = Database::result($rs, 0, 0);
  140. if (intval($count_users)<50) {
  141. $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
  142. $sql="SELECT user_id,lastname,firstname,username FROM $tbl_user WHERE status='1'".$order_clause;
  143. global $_configuration;
  144. if ($_configuration['multiple_access_urls']) {
  145. $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
  146. $access_url_id = api_get_current_access_url_id();
  147. if ($access_url_id != -1){
  148. $sql = 'SELECT username, lastname, firstname FROM '.$tbl_user.' user
  149. INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
  150. WHERE access_url_id = '.$access_url_id.' AND status=1'.$order_clause;
  151. }
  152. }
  153. $result=Database::query($sql);
  154. $Coaches=Database::store_result($result);
  155. ?>
  156. <select name="coach_username" value="true" style="width:350px;">
  157. <option value="0"><?php get_lang('None'); ?></option>
  158. <?php foreach($Coaches as $enreg): ?>
  159. <option value="<?php echo $enreg['username']; ?>" <?php if($sent && $enreg['user_id'] == $id_coach) echo 'selected="selected"'; ?>><?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?></option>
  160. <?php endforeach; ?>
  161. </select>
  162. <?php
  163. echo Display::return_icon('synthese_view.gif',get_lang('ActivityCoach'));
  164. } else {
  165. ?>
  166. <input type="text" name="coach_username" id="coach_username" onkeyup="xajax_search_coachs(document.getElementById('coach_username').value)" /><div id="ajax_list_coachs"></div>
  167. <?php
  168. }
  169. $Categories = SessionManager::get_all_session_category();
  170. ?>
  171. </td>
  172. </tr>
  173. <tr>
  174. <td width="40%"><?php echo get_lang('SessionCategory') ?></td>
  175. <td width="60%">
  176. <select name="session_category" value="true" style="width:350px;">
  177. <option value="0"><?php get_lang('None'); ?></option>
  178. <?php
  179. if (!empty($Categories)) {
  180. foreach($Categories as $Rows) { ?>
  181. <option value="<?php echo $Rows['id']; ?>" <?php if($Rows['id'] == $id_session_category) echo 'selected="selected"'; ?>><?php echo $Rows['name']; ?></option>
  182. <?php }
  183. }
  184. ?>
  185. </select>
  186. </td>
  187. </tr>
  188. <tr>
  189. <td>&nbsp;
  190. </td>
  191. <td>
  192. <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('DefineSessionOptions') ?></a>
  193. <div style="display: <?php if($formSent && ($nb_days_acess_before!=0 || $nb_days_acess_after!=0)) echo 'block'; else echo 'none'; ?>;" id="options">
  194. <br />
  195. <input type="text" name="nb_days_acess_before" value="<?php echo $nb_days_acess_before; ?>" style="width: 30px;">&nbsp;<?php echo get_lang('DaysBefore') ?><br /><br />
  196. <input type="text" name="nb_days_acess_after" value="<?php echo $nb_days_acess_after; ?>" style="width: 30px;">&nbsp;<?php echo get_lang('DaysAfter') ?>
  197. <br />
  198. </div>
  199. </td>
  200. </tr>
  201. <td width="40%"></td>
  202. <td width="60%">
  203. <input id="start_limit" type="checkbox" name="start_limit" onchange="disable_starttime(this)" <?php if ($year_start=="0000") echo "checked"; ?>/>
  204. <label for="start_limit">
  205. <?php echo get_lang('DateStartSession');?>
  206. </label>
  207. <div id="start_date" style="display:none">
  208. <br />
  209. <select name="day_start">
  210. <option value="1">01</option>
  211. <option value="2" <?php if((!$formSent && $thisDay == 2) || ($formSent && $day_start == 2)) echo 'selected="selected"'; ?> >02</option>
  212. <option value="3" <?php if((!$formSent && $thisDay == 3) || ($formSent && $day_start == 3)) echo 'selected="selected"'; ?> >03</option>
  213. <option value="4" <?php if((!$formSent && $thisDay == 4) || ($formSent && $day_start == 4)) echo 'selected="selected"'; ?> >04</option>
  214. <option value="5" <?php if((!$formSent && $thisDay == 5) || ($formSent && $day_start == 5)) echo 'selected="selected"'; ?> >05</option>
  215. <option value="6" <?php if((!$formSent && $thisDay == 6) || ($formSent && $day_start == 6)) echo 'selected="selected"'; ?> >06</option>
  216. <option value="7" <?php if((!$formSent && $thisDay == 7) || ($formSent && $day_start == 7)) echo 'selected="selected"'; ?> >07</option>
  217. <option value="8" <?php if((!$formSent && $thisDay == 8) || ($formSent && $day_start == 8)) echo 'selected="selected"'; ?> >08</option>
  218. <option value="9" <?php if((!$formSent && $thisDay == 9) || ($formSent && $day_start == 9)) echo 'selected="selected"'; ?> >09</option>
  219. <option value="10" <?php if((!$formSent && $thisDay == 10) || ($formSent && $day_start == 10)) echo 'selected="selected"'; ?> >10</option>
  220. <option value="11" <?php if((!$formSent && $thisDay == 11) || ($formSent && $day_start == 11)) echo 'selected="selected"'; ?> >11</option>
  221. <option value="12" <?php if((!$formSent && $thisDay == 12) || ($formSent && $day_start == 12)) echo 'selected="selected"'; ?> >12</option>
  222. <option value="13" <?php if((!$formSent && $thisDay == 13) || ($formSent && $day_start == 13)) echo 'selected="selected"'; ?> >13</option>
  223. <option value="14" <?php if((!$formSent && $thisDay == 14) || ($formSent && $day_start == 14)) echo 'selected="selected"'; ?> >14</option>
  224. <option value="15" <?php if((!$formSent && $thisDay == 15) || ($formSent && $day_start == 15)) echo 'selected="selected"'; ?> >15</option>
  225. <option value="16" <?php if((!$formSent && $thisDay == 16) || ($formSent && $day_start == 16)) echo 'selected="selected"'; ?> >16</option>
  226. <option value="17" <?php if((!$formSent && $thisDay == 17) || ($formSent && $day_start == 17)) echo 'selected="selected"'; ?> >17</option>
  227. <option value="18" <?php if((!$formSent && $thisDay == 18) || ($formSent && $day_start == 18)) echo 'selected="selected"'; ?> >18</option>
  228. <option value="19" <?php if((!$formSent && $thisDay == 19) || ($formSent && $day_start == 19)) echo 'selected="selected"'; ?> >19</option>
  229. <option value="20" <?php if((!$formSent && $thisDay == 20) || ($formSent && $day_start == 20)) echo 'selected="selected"'; ?> >20</option>
  230. <option value="21" <?php if((!$formSent && $thisDay == 21) || ($formSent && $day_start == 21)) echo 'selected="selected"'; ?> >21</option>
  231. <option value="22" <?php if((!$formSent && $thisDay == 22) || ($formSent && $day_start == 22)) echo 'selected="selected"'; ?> >22</option>
  232. <option value="23" <?php if((!$formSent && $thisDay == 23) || ($formSent && $day_start == 23)) echo 'selected="selected"'; ?> >23</option>
  233. <option value="24" <?php if((!$formSent && $thisDay == 24) || ($formSent && $day_start == 24)) echo 'selected="selected"'; ?> >24</option>
  234. <option value="25" <?php if((!$formSent && $thisDay == 25) || ($formSent && $day_start == 25)) echo 'selected="selected"'; ?> >25</option>
  235. <option value="26" <?php if((!$formSent && $thisDay == 26) || ($formSent && $day_start == 26)) echo 'selected="selected"'; ?> >26</option>
  236. <option value="27" <?php if((!$formSent && $thisDay == 27) || ($formSent && $day_start == 27)) echo 'selected="selected"'; ?> >27</option>
  237. <option value="28" <?php if((!$formSent && $thisDay == 28) || ($formSent && $day_start == 28)) echo 'selected="selected"'; ?> >28</option>
  238. <option value="29" <?php if((!$formSent && $thisDay == 29) || ($formSent && $day_start == 29)) echo 'selected="selected"'; ?> >29</option>
  239. <option value="30" <?php if((!$formSent && $thisDay == 30) || ($formSent && $day_start == 30)) echo 'selected="selected"'; ?> >30</option>
  240. <option value="31" <?php if((!$formSent && $thisDay == 31) || ($formSent && $day_start == 31)) echo 'selected="selected"'; ?> >31</option>
  241. </select>
  242. /
  243. <select name="month_start">
  244. <option value="1">01</option>
  245. <option value="2" <?php if((!$formSent && $thisMonth == 2) || ($formSent && $month_start == 2)) echo 'selected="selected"'; ?> >02</option>
  246. <option value="3" <?php if((!$formSent && $thisMonth == 3) || ($formSent && $month_start == 3)) echo 'selected="selected"'; ?> >03</option>
  247. <option value="4" <?php if((!$formSent && $thisMonth == 4) || ($formSent && $month_start == 4)) echo 'selected="selected"'; ?> >04</option>
  248. <option value="5" <?php if((!$formSent && $thisMonth == 5) || ($formSent && $month_start == 5)) echo 'selected="selected"'; ?> >05</option>
  249. <option value="6" <?php if((!$formSent && $thisMonth == 6) || ($formSent && $month_start == 6)) echo 'selected="selected"'; ?> >06</option>
  250. <option value="7" <?php if((!$formSent && $thisMonth == 7) || ($formSent && $month_start == 7)) echo 'selected="selected"'; ?> >07</option>
  251. <option value="8" <?php if((!$formSent && $thisMonth == 8) || ($formSent && $month_start == 8)) echo 'selected="selected"'; ?> >08</option>
  252. <option value="9" <?php if((!$formSent && $thisMonth == 9) || ($formSent && $month_start == 9)) echo 'selected="selected"'; ?> >09</option>
  253. <option value="10" <?php if((!$formSent && $thisMonth == 10) || ($formSent && $month_start == 10)) echo 'selected="selected"'; ?> >10</option>
  254. <option value="11" <?php if((!$formSent && $thisMonth == 11) || ($formSent && $month_start == 11)) echo 'selected="selected"'; ?> >11</option>
  255. <option value="12" <?php if((!$formSent && $thisMonth == 12) || ($formSent && $month_start == 12)) echo 'selected="selected"'; ?> >12</option>
  256. </select>
  257. /
  258. <select name="year_start">
  259. <?php
  260. for ($i=$thisYear-5;$i <= ($thisYear+5);$i++) {
  261. ?>
  262. <option value="<?php echo $i; ?>" <?php if((!$formSent && $thisYear == $i) || ($formSent && $year_start == $i)) echo 'selected="selected"'; ?> ><?php echo $i; ?></option>
  263. <?php
  264. }
  265. ?>
  266. </select>
  267. </div>
  268. </td>
  269. </tr>
  270. <tr>
  271. <td width="40%">&nbsp;&nbsp;</td>
  272. <td width="60%">
  273. <input id="end_limit" type="checkbox" name="end_limit" onchange="disable_endtime(this)" <?php if ($year_end=="0000") echo "checked"; ?>/>
  274. <label for="end_limit">
  275. <?php echo get_lang('DateEndSession') ?>
  276. </label>
  277. <div id="end_date" style="display:none">
  278. <br />
  279. <select name="day_end">
  280. <option value="1">01</option>
  281. <option value="2" <?php if((!$formSent && $thisDay == 2) || ($formSent && $day_end == 2)) echo 'selected="selected"'; ?> >02</option>
  282. <option value="3" <?php if((!$formSent && $thisDay == 3) || ($formSent && $day_end == 3)) echo 'selected="selected"'; ?> >03</option>
  283. <option value="4" <?php if((!$formSent && $thisDay == 4) || ($formSent && $day_end == 4)) echo 'selected="selected"'; ?> >04</option>
  284. <option value="5" <?php if((!$formSent && $thisDay == 5) || ($formSent && $day_end == 5)) echo 'selected="selected"'; ?> >05</option>
  285. <option value="6" <?php if((!$formSent && $thisDay == 6) || ($formSent && $day_end == 6)) echo 'selected="selected"'; ?> >06</option>
  286. <option value="7" <?php if((!$formSent && $thisDay == 7) || ($formSent && $day_end == 7)) echo 'selected="selected"'; ?> >07</option>
  287. <option value="8" <?php if((!$formSent && $thisDay == 8) || ($formSent && $day_end == 8)) echo 'selected="selected"'; ?> >08</option>
  288. <option value="9" <?php if((!$formSent && $thisDay == 9) || ($formSent && $day_end == 9)) echo 'selected="selected"'; ?> >09</option>
  289. <option value="10" <?php if((!$formSent && $thisDay == 10) || ($formSent && $day_end == 10)) echo 'selected="selected"'; ?> >10</option>
  290. <option value="11" <?php if((!$formSent && $thisDay == 11) || ($formSent && $day_end == 11)) echo 'selected="selected"'; ?> >11</option>
  291. <option value="12" <?php if((!$formSent && $thisDay == 12) || ($formSent && $day_end == 12)) echo 'selected="selected"'; ?> >12</option>
  292. <option value="13" <?php if((!$formSent && $thisDay == 13) || ($formSent && $day_end == 13)) echo 'selected="selected"'; ?> >13</option>
  293. <option value="14" <?php if((!$formSent && $thisDay == 14) || ($formSent && $day_end == 14)) echo 'selected="selected"'; ?> >14</option>
  294. <option value="15" <?php if((!$formSent && $thisDay == 15) || ($formSent && $day_end == 15)) echo 'selected="selected"'; ?> >15</option>
  295. <option value="16" <?php if((!$formSent && $thisDay == 16) || ($formSent && $day_end == 16)) echo 'selected="selected"'; ?> >16</option>
  296. <option value="17" <?php if((!$formSent && $thisDay == 17) || ($formSent && $day_end == 17)) echo 'selected="selected"'; ?> >17</option>
  297. <option value="18" <?php if((!$formSent && $thisDay == 18) || ($formSent && $day_end == 18)) echo 'selected="selected"'; ?> >18</option>
  298. <option value="19" <?php if((!$formSent && $thisDay == 19) || ($formSent && $day_end == 19)) echo 'selected="selected"'; ?> >19</option>
  299. <option value="20" <?php if((!$formSent && $thisDay == 20) || ($formSent && $day_end == 20)) echo 'selected="selected"'; ?> >20</option>
  300. <option value="21" <?php if((!$formSent && $thisDay == 21) || ($formSent && $day_end == 21)) echo 'selected="selected"'; ?> >21</option>
  301. <option value="22" <?php if((!$formSent && $thisDay == 22) || ($formSent && $day_end == 22)) echo 'selected="selected"'; ?> >22</option>
  302. <option value="23" <?php if((!$formSent && $thisDay == 23) || ($formSent && $day_end == 23)) echo 'selected="selected"'; ?> >23</option>
  303. <option value="24" <?php if((!$formSent && $thisDay == 24) || ($formSent && $day_end == 24)) echo 'selected="selected"'; ?> >24</option>
  304. <option value="25" <?php if((!$formSent && $thisDay == 25) || ($formSent && $day_end == 25)) echo 'selected="selected"'; ?> >25</option>
  305. <option value="26" <?php if((!$formSent && $thisDay == 26) || ($formSent && $day_end == 26)) echo 'selected="selected"'; ?> >26</option>
  306. <option value="27" <?php if((!$formSent && $thisDay == 27) || ($formSent && $day_end == 27)) echo 'selected="selected"'; ?> >27</option>
  307. <option value="28" <?php if((!$formSent && $thisDay == 28) || ($formSent && $day_end == 28)) echo 'selected="selected"'; ?> >28</option>
  308. <option value="29" <?php if((!$formSent && $thisDay == 29) || ($formSent && $day_end == 29)) echo 'selected="selected"'; ?> >29</option>
  309. <option value="30" <?php if((!$formSent && $thisDay == 30) || ($formSent && $day_end == 30)) echo 'selected="selected"'; ?> >30</option>
  310. <option value="31" <?php if((!$formSent && $thisDay == 31) || ($formSent && $day_end == 31)) echo 'selected="selected"'; ?> >31</option>
  311. </select>
  312. /
  313. <select name="month_end">
  314. <option value="1">01</option>
  315. <option value="2" <?php if((!$formSent && $thisMonth == 2) || ($formSent && $month_end == 2)) echo 'selected="selected"'; ?> >02</option>
  316. <option value="3" <?php if((!$formSent && $thisMonth == 3) || ($formSent && $month_end == 3)) echo 'selected="selected"'; ?> >03</option>
  317. <option value="4" <?php if((!$formSent && $thisMonth == 4) || ($formSent && $month_end == 4)) echo 'selected="selected"'; ?> >04</option>
  318. <option value="5" <?php if((!$formSent && $thisMonth == 5) || ($formSent && $month_end == 5)) echo 'selected="selected"'; ?> >05</option>
  319. <option value="6" <?php if((!$formSent && $thisMonth == 6) || ($formSent && $month_end == 6)) echo 'selected="selected"'; ?> >06</option>
  320. <option value="7" <?php if((!$formSent && $thisMonth == 7) || ($formSent && $month_end == 7)) echo 'selected="selected"'; ?> >07</option>
  321. <option value="8" <?php if((!$formSent && $thisMonth == 8) || ($formSent && $month_end == 8)) echo 'selected="selected"'; ?> >08</option>
  322. <option value="9" <?php if((!$formSent && $thisMonth == 9) || ($formSent && $month_end == 9)) echo 'selected="selected"'; ?> >09</option>
  323. <option value="10" <?php if((!$formSent && $thisMonth == 10) || ($formSent && $month_end == 10)) echo 'selected="selected"'; ?> >10</option>
  324. <option value="11" <?php if((!$formSent && $thisMonth == 11) || ($formSent && $month_end == 11)) echo 'selected="selected"'; ?> >11</option>
  325. <option value="12" <?php if((!$formSent && $thisMonth == 12) || ($formSent && $month_end == 12)) echo 'selected="selected"'; ?> >12</option>
  326. </select>
  327. /
  328. <select name="year_end">
  329. <?php
  330. for ($i=$thisYear-5;$i <= ($thisYear+5);$i++) {
  331. ?>
  332. <option value="<?php echo $i; ?>" <?php if((!$formSent && ($thisYear+1) == $i) || ($formSent && $year_end == $i)) echo 'selected="selected"'; ?> ><?php echo $i; ?></option>
  333. <?php
  334. }
  335. ?>
  336. </select>
  337. <br /> <br />
  338. <?php echo get_lang('SessionVisibility') ?>
  339. <select name="session_visibility" style="width:250px;">
  340. <?php
  341. $visibility_list = array(SESSION_VISIBLE_READ_ONLY=>get_lang('SessionReadOnly'), SESSION_VISIBLE=>get_lang('SessionAccessible'), SESSION_INVISIBLE=>api_ucfirst(get_lang('SessionNotAccessible')));
  342. foreach($visibility_list as $key=>$item): ?>
  343. <option value="<?php echo $key; ?>" <?php if($item == $visibility_id) echo 'selected="selected"'; ?>><?php echo $item; ?></option>
  344. <?php endforeach; ?>
  345. </select>
  346. </div>
  347. </td>
  348. </tr>
  349. <tr>
  350. <td>&nbsp;</td>
  351. <td><button class="save" type="submit" value="<?php echo get_lang('NextStep') ?>"><?php echo get_lang('NextStep') ?></button>
  352. </td>
  353. </tr>
  354. </table>
  355. </form>
  356. <script type="text/javascript">
  357. function setDisable(select){
  358. document.form.day_start.disabled = (select.checked) ? true : false;
  359. document.form.month_start.disabled = (select.checked) ? true : false;
  360. document.form.year_start.disabled = (select.checked) ? true : false;
  361. document.form.day_end.disabled = (select.checked) ? true : false;
  362. document.form.month_end.disabled = (select.checked) ? true : false;
  363. document.form.year_end.disabled = (select.checked) ? true : false;
  364. document.form.session_visibility.disabled = (select.checked) ? true : false;
  365. document.form.session_visibility.selectedIndex = 0;
  366. document.form.start_limit.disabled = (select.checked) ? true : false;
  367. document.form.start_limit.checked = false;
  368. document.form.end_limit.disabled = (select.checked) ? true : false;
  369. document.form.end_limit.checked = false;
  370. var end_div = document.getElementById('end_date');
  371. end_div.style.display = 'none';
  372. var start_div = document.getElementById('start_date');
  373. start_div.style.display = 'none';
  374. }
  375. function disable_endtime(select) {
  376. var end_div = document.getElementById('end_date');
  377. if (end_div.style.display == 'none')
  378. end_div.style.display = 'block';
  379. else
  380. end_div.style.display = 'none';
  381. }
  382. function disable_starttime(select) {
  383. var start_div = document.getElementById('start_date');
  384. if (start_div.style.display == 'none')
  385. start_div.style.display = 'block';
  386. else
  387. start_div.style.display = 'none';
  388. }
  389. </script>
  390. <?php
  391. Display::display_footer();