session_add.php 22 KB

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