session_add.php 25 KB

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