debugOn(); $xajax -> registerFunction ('search_coachs'); // setting the section (for the tabs) $this_section=SECTION_PLATFORM_ADMIN; api_protect_admin_script(true); api_protect_limit_for_session_admin(); $formSent=0; $errorMsg=''; $interbreadcrumb[]=array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[]=array('url' => 'session_list.php','name' => get_lang('SessionList')); // Database Table Definitions $tbl_user = Database::get_main_table(TABLE_MAIN_USER); function search_coachs($needle) { global $tbl_user; $xajax_response = new XajaxResponse(); $return = ''; if(!empty($needle)) { // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_system_encoding(); $needle = api_convert_encoding($needle, $charset, 'utf-8'); $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; // search users where username or firstname or lastname begins likes $needle $sql = 'SELECT username, lastname, firstname FROM '.$tbl_user.' user WHERE (username LIKE "'.$needle.'%" OR firstname LIKE "'.$needle.'%" OR lastname LIKE "'.$needle.'%") AND status=1'. $order_clause. ' LIMIT 10'; if (api_is_multiple_url_enabled()) { $tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1){ $sql = 'SELECT username, lastname, firstname FROM '.$tbl_user.' user INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id) WHERE access_url_id = '.$access_url_id.' AND (username LIKE "'.$needle.'%" OR firstname LIKE "'.$needle.'%" OR lastname LIKE "'.$needle.'%") AND status=1'. $order_clause. ' LIMIT 10'; } } $rs = Database::query($sql); while ($user = Database :: fetch_array($rs)) { $return .= ''.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')
'; } } $xajax_response -> addAssign('ajax_list_coachs','innerHTML', api_utf8_encode($return)); return $xajax_response; } $xajax -> processRequests(); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = ' '; if (isset($_POST['formSent']) && $_POST['formSent']) { $check = Security::check_token('post'); Security::clear_token(); if ($check) { $formSent = 1; $name = $_POST['name']; $year_start = $_POST['year_start']; $month_start = $_POST['month_start']; $day_start = $_POST['day_start']; $year_end = $_POST['year_end']; $month_end = $_POST['month_end']; $day_end = $_POST['day_end']; $nb_days_acess_before = $_POST['nb_days_acess_before']; $nb_days_acess_after = $_POST['nb_days_acess_after']; $coach_username = $_POST['coach_username']; $id_session_category = $_POST['session_category']; $id_visibility = $_POST['session_visibility']; $end_limit = $_POST['end_limit']; $start_limit = $_POST['start_limit']; $duration = isset($_POST['duration']) ? $_POST['duration'] : null; if (empty($end_limit) && empty($start_limit)) { $nolimit = 1; } else { $nolimit = null; } $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, $duration ); if ($return == strval(intval($return))) { // integer => no error on session creation header('Location: add_courses_to_session.php?id_session=' . $return . '&add=true&msg='); exit(); } } else { header('Location: '.api_get_self()); exit(); } } $token = Security::get_token(); global $_configuration; $defaultBeforeDays = isset($_configuration['session_days_before_coach_access']) ? $_configuration['session_days_before_coach_access'] : 0; $defaultAfterDays = isset($_configuration['session_days_after_coach_access']) ? $_configuration['session_days_after_coach_access'] : 0; $nb_days_acess_before = $defaultBeforeDays; $nb_days_acess_after = $defaultAfterDays; $thisYear=date('Y'); $thisMonth=date('m'); $thisDay=date('d'); $tool_name = get_lang('AddSession'); Display::display_header($tool_name); if (!empty($return)) { Display::display_error_message($return,false); } echo '
'; echo ''.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).''; echo '
'; ?>