Fix column order table buttons see BT#15219

pull/2782/head
Julio Montoya 7 years ago
parent 7ca20397af
commit fcece68887
  1. 11
      main/inc/ajax/model.ajax.php
  2. 26
      main/inc/lib/tracking.lib.php
  3. 17
      main/mySpace/session.php

@ -850,7 +850,7 @@ switch ($action) {
'*',
$object->table,
[
'where' => ["session_id = ? " => $sessionId],
'where' => ['session_id = ? ' => $sessionId],
'order' => "$sidx $sord",
'LIMIT' => "$start , $limit", ]
);
@ -1433,6 +1433,9 @@ switch ($action) {
break;
case 'get_sessions_tracking':
if (api_is_drh() || api_is_session_admin()) {
$orderByName = Database::escape_string($sidx);
$orderByName = in_array($orderByName, ['name', 'access_start_date']) ? $orderByName : 'name';
$orderBy = " ORDER BY $orderByName $sord";
$sessions = SessionManager::get_sessions_followed_by_drh(
api_get_user_id(),
$start,
@ -1440,7 +1443,7 @@ switch ($action) {
false,
false,
false,
null,
$orderBy,
$keyword,
$description
);
@ -1452,7 +1455,9 @@ switch ($action) {
$limit,
false,
$keyword,
$description
$description,
$sidx,
$sord
);
}

@ -3734,12 +3734,14 @@ class Tracking
/**
* Get sessions coached by user.
*
* @param $coach_id
* @param $coach_id
* @param int $start
* @param int $limit
* @param bool $getCount
* @param string $keyword
* @param string $description
* @param string $orderByName
* @param string $orderByDirection
*
* @return mixed
*/
@ -3749,12 +3751,14 @@ class Tracking
$limit = 0,
$getCount = false,
$keyword = '',
$description = ''
$description = '',
$orderByName = '',
$orderByDirection = ''
) {
// table definition
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$coach_id = intval($coach_id);
$coach_id = (int) $coach_id;
$select = " SELECT * FROM ";
if ($getCount) {
@ -3781,6 +3785,15 @@ class Tracking
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
$orderBy = '';
if (!empty($orderByName)) {
if (in_array($orderByName, ['name', 'access_start_date'])) {
$orderByDirection = in_array(strtolower($orderByDirection), ['asc', 'desc']) ? $orderByDirection : 'asc';
$orderByName = Database::escape_string($orderByName);
$orderBy .= " ORDER BY $orderByName $orderByDirection";
}
}
$sql = "
$select
(
@ -3813,7 +3826,7 @@ class Tracking
WHERE
access_url_id = $access_url_id
$keywordCondition
) as sessions $limitCondition
) as sessions $limitCondition $orderBy
";
$rs = Database::query($sql);
@ -3825,7 +3838,7 @@ class Tracking
$sessions = [];
while ($row = Database::fetch_array($rs)) {
if ($row['access_start_date'] == '0000-00-00 00:00:00') {
if ($row['access_start_date'] === '0000-00-00 00:00:00') {
$row['access_start_date'] = null;
}
@ -3834,8 +3847,7 @@ class Tracking
if (!empty($sessions)) {
foreach ($sessions as &$session) {
if (empty($session['access_start_date'])
) {
if (empty($session['access_start_date'])) {
$session['status'] = get_lang('SessionActive');
} else {
$time_start = api_strtotime($session['access_start_date'], 'UTC');

@ -13,19 +13,14 @@ require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
$this_section = SECTION_TRACKING;
api_block_anonymous_users();
$export_csv = false;
if (isset($_GET['export']) && $_GET['export'] == 'csv') {
$export_csv = true;
}
$id_coach = api_get_user_id();
if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
$id_coach = intval($_GET['id_coach']);
} else {
$id_coach = api_get_user_id();
$id_coach = (int) $_GET['id_coach'];
}
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
@ -35,7 +30,7 @@ if (!$allowToTrack) {
}
$htmlHeadXtra[] = api_get_jqgrid_js();
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')];
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
Display::display_header(get_lang('Sessions'));
if (api_is_platform_admin(true, true)) {
@ -44,11 +39,11 @@ if (api_is_platform_admin(true, true)) {
if (!api_is_session_admin()) {
$menu_items[] = Display::url(
Display::return_icon('statistics.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
api_get_path(WEB_CODE_PATH).'auth/my_progress.php'
);
$menu_items[] = Display::url(
Display::return_icon('user.png', get_lang('Students'), [], ICON_SIZE_MEDIUM),
"index.php?view=drh_students&display=yourstudents"
'index.php?view=drh_students&display=yourstudents'
);
$menu_items[] = Display::url(
Display::return_icon('teacher.png', get_lang('Trainers'), [], ICON_SIZE_MEDIUM),
@ -143,7 +138,7 @@ $columns = [
// Column config
$columnModel = [
['name' => 'name', 'index' => 'name', 'width' => '255', 'align' => 'left'],
['name' => 'date', 'index' => 'date', 'width' => '150', 'align' => 'left', 'sortable' => 'false'],
['name' => 'date', 'index' => 'access_start_date', 'width' => '150', 'align' => 'left'],
['name' => 'course_per_session', 'index' => 'course_per_session', 'width' => '150', 'sortable' => 'false'],
['name' => 'student_per_session', 'index' => 'student_per_session', 'width' => '100', 'sortable' => 'false'],
['name' => 'details', 'index' => 'details', 'width' => '100', 'sortable' => 'false'],

Loading…
Cancel
Save