registerFunction ('search_courses'); // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; // Access restrictions api_protect_admin_script(true); // setting breadcrumbs $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'user_list.php','name' => get_lang('UserList')); // Database Table Definitions $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_course_rel_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); // setting the name of the tool $tool_name= get_lang('AssignCoursesToHumanResourcesManager'); // initializing variables $id_session=intval($_GET['id_session']); $hrm_id = intval($_GET['user']); $hrm_info = api_get_user_info($hrm_id); $user_anonymous = api_get_anonymous_id(); $current_user_id = api_get_user_id(); $add_type = 'multiple'; if(isset($_GET['add_type']) && $_GET['add_type']!=''){ $add_type = Security::remove_XSS($_REQUEST['add_type']); } if (!api_is_platform_admin()) { api_not_allowed(true); } function search_courses($needle,$type) { global $tbl_course, $tbl_course_rel_user, $hrm_id; $xajax_response = new XajaxResponse(); $return = ''; if(!empty($needle) && !empty($type)) { // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_setting('platform_charset'); $needle = api_convert_encoding($needle, $charset, 'utf-8'); $assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($hrm_id); $assigned_courses_code = array_keys($assigned_courses_to_hrm); foreach ($assigned_courses_code as &$value) { $value = "'".$value."'"; } $without_assigned_courses = ''; if (count($assigned_courses_code) > 0) { $without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")"; } $sql = "SELECT c.code, c.title FROM $tbl_course c WHERE c.code LIKE '$needle%' $without_assigned_courses "; $rs = Database::query($sql); $course_list = array(); $return .= ''; $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); } $_SESSION['course_list'] = $course_list; return $xajax_response; } $xajax -> processRequests(); $htmlHeadXtra[] = $xajax->getJavascript('../inc/lib/xajax/'); $htmlHeadXtra[] = ' '; $formSent=0; $errorMsg = $firstLetterCourse = ''; $UserList = array(); $msg = ''; if (intval($_POST['formSent']) == 1) { $courses_list = $_POST['CoursesList']; $affected_rows = CourseManager::suscribe_courses_to_hr_manager($hrm_id,$courses_list); if ($affected_rows) { $msg = get_lang('AssignedCoursesHaveBeenUpdatedSuccessfully'); } } // display the dokeos header Display::display_header($tool_name); //echo '
'.get_lang('AssignedCoursesTo').' '.api_get_person_name($hrm_info['firstname'], $hrm_info['lastname']).'

'; echo '
'.Display::return_icon('add_user_big.gif', get_lang('AssignUsers'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignUsers').' '.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignSessions').' '.get_lang('AssignedUsersTo').' '.api_get_person_name($hrm_info['firstname'], $hrm_info['lastname']).'
'; // ******************* $assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($hrm_id); $assigned_courses_code = array_keys($assigned_courses_to_hrm); foreach ($assigned_courses_code as &$value) { $value = "'".$value."'"; } $without_assigned_courses = ''; if (count($assigned_courses_code) > 0) { $without_assigned_courses = " AND c.code NOT IN(".implode(',',$assigned_courses_code).")"; } $needle = '%'; if (isset($_POST['firstLetterCourse'])) { $needle = Database::escape_string($_POST['firstLetterCourse']); $needle = "$needle%"; } $sql = " SELECT c.code, c.title FROM $tbl_course c WHERE c.code LIKE '$needle' $without_assigned_courses "; $result = Database::query($sql); ?>
>
 
:   :
:  








'.get_lang('AssignCoursesToHumanResourcesManager').''; ?>