function selectAll(idCheck,numRows,action) {
for(i = 0; i < numRows; i++) {
idcheck = document.getElementById(idCheck + "_" + i);
idcheck.checked = action == "true";
}
}
';
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$page = isset($_GET['page']) ? intval($_GET['page']) : null;
$action = isset($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']) : null;
$sort = isset($_GET['sort']) && in_array($_GET['sort'], array('name', 'nbr_session', 'date_start', 'date_end')) ? Security::remove_XSS($_GET['sort']) : 'name';
$idChecked = isset($_REQUEST['idChecked']) ? Security::remove_XSS($_REQUEST['idChecked']) : null;
$order = isset($_REQUEST['order']) ? Security::remove_XSS($_REQUEST['order']) : 'ASC';
if ($action == 'delete_on_session' || $action == 'delete_off_session') {
$delete_session = ($action == 'delete_on_session') ? true : false;
SessionManager::delete_session_category($idChecked, $delete_session);
Display::addFlash(Display::return_message(get_lang('SessionCategoryDelete')));
header('Location: '.api_get_self().'?sort='.$sort);
exit();
}
//$interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array('url' => 'session_list.php','name' => get_lang('SessionList'));
if (isset($_GET['search']) && $_GET['search'] == 'advanced') {
$interbreadcrumb[] = array("url" => 'session_category_list.php', "name" => get_lang('ListSessionCategory'));
$tool_name = get_lang('SearchASession');
Display :: display_header($tool_name);
$form = new FormValidator('advanced_search', 'get');
$form->addElement('header', '', $tool_name);
$active_group = array();
$active_group[] = $form->createElement('checkbox', 'active', '', get_lang('Active'));
$active_group[] = $form->createElement('checkbox', 'inactive', '', get_lang('Inactive'));
$form->addGroup($active_group, '', get_lang('ActiveSession'), '
', false);
$form->addButtonSearch(get_lang('SearchUsers'));
$defaults['active'] = 1;
$defaults['inactive'] = 1;
$form->setDefaults($defaults);
$form->display();
} else {
$limit = 20;
$from = $page * $limit;
//if user is crfp admin only list its sessions
$where = null;
if (!api_is_platform_admin()) {
$where .= (empty($_REQUEST['keyword']) ? "" : " WHERE name LIKE '%".Database::escape_string(trim($_REQUEST['keyword']))."%'");
} else {
$where .= (empty($_REQUEST['keyword']) ? "" : " WHERE name LIKE '%".Database::escape_string(trim($_REQUEST['keyword']))."%'");
}
if (empty($where)) {
$where = " WHERE access_url_id = ".api_get_current_access_url_id()." ";
} else {
$where .= " AND access_url_id = ".api_get_current_access_url_id()." ";
}
$table_access_url_rel_session= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$query = "SELECT sc.*, (
SELECT count(s.id) FROM $tbl_session s
INNER JOIN $table_access_url_rel_session us
ON (s.id = us.session_id)
WHERE
s.session_category_id = sc.id AND
access_url_id = ".api_get_current_access_url_id()."
) as nbr_session
FROM $tbl_session_category sc
$where
ORDER BY $sort $order
LIMIT $from,".($limit + 1);
$query_rows = "SELECT count(*) as total_rows FROM $tbl_session_category sc $where ";
$order = ($order == 'ASC') ? 'DESC' : 'ASC';
$result_rows = Database::query($query_rows);
$recorset = Database::fetch_array($result_rows);
$num = $recorset['total_rows'];
$result = Database::query($query);
$Sessions = Database::store_result($result);
$nbr_results = sizeof($Sessions);
$tool_name = get_lang('ListSessionCategory');
Display::display_header($tool_name);
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
?>