Add extra field filter in the my space/session page see BT#15670

pull/2913/head
Julio Montoya 7 years ago
parent 6871eceaee
commit 903d04aafe
  1. 81
      main/inc/ajax/model.ajax.php
  2. 131
      main/inc/lib/sessionmanager.lib.php
  3. 50
      main/inc/lib/tracking.lib.php
  4. 214
      main/mySpace/session.php
  5. 32
      main/session/session_list.php

@ -136,7 +136,7 @@ $accessStartDate = '';
$accessEndDate = '';
$overwriteColumnHeaderExport = [];
if (!empty($searchString)) {
if (!empty($search)) {
$search = 'true';
}
@ -153,18 +153,19 @@ if (($search || $forceSearch) && ($search !== 'false')) {
$whereCondition .= ' ('.$whereConditionInForm.') ';
}
$filters = isset($_REQUEST['filters']) && !is_array($_REQUEST['filters']) ? json_decode($_REQUEST['filters']) : false;
//echo($filters); exit;
if (isset($_REQUEST['filters2'])) {
$filters = json_decode($_REQUEST['filters2']);
}
if (!empty($filters)) {
if (in_array($action, ['get_questions', 'get_sessions'])) {
if (in_array($action, ['get_questions', 'get_sessions', 'get_sessions_tracking'])) {
switch ($action) {
case 'get_questions':
$type = 'question';
break;
case 'get_sessions':
case 'get_sessions_tracking':
$type = 'session';
break;
}
@ -177,11 +178,11 @@ if (($search || $forceSearch) && ($search !== 'false')) {
if (empty($data)) {
continue;
}
if ($data->field == 'extra_access_start_date') {
if ($data->field === 'extra_access_start_date') {
$accessStartDate = $data->data;
}
if ($data->field == 'extra_access_end_date') {
if ($data->field === 'extra_access_end_date') {
$accessEndDate = $data->data;
}
@ -193,7 +194,6 @@ if (($search || $forceSearch) && ($search !== 'false')) {
$extra_fields = $result['extra_fields'];
$condition_array = $result['condition_array'];
$extraCondition = '';
if (!empty($condition_array)) {
$extraCondition = $filters->groupOp.' ( ';
@ -656,7 +656,8 @@ switch ($action) {
false,
null,
$keyword,
$description
$description,
['where' => $whereCondition, 'extra' => $extra_fields]
);
} else {
// Sessions for the coach
@ -666,7 +667,10 @@ switch ($action) {
null,
true,
$keyword,
$description
$description,
null,
null,
['where' => $whereCondition, 'extra' => $extra_fields]
);
}
break;
@ -1477,7 +1481,8 @@ switch ($action) {
false,
$orderBy,
$keyword,
$description
$description,
['where' => $whereCondition, 'extra' => $extra_fields]
);
} else {
// Sessions for the coach
@ -1489,17 +1494,13 @@ switch ($action) {
$keyword,
$description,
$sidx,
$sord
$sord,
['where' => $whereCondition, 'extra' => $extra_fields]
);
}
$columns = [
'name',
'date',
'course_per_session',
'student_per_session',
'details',
];
$session_columns = SessionManager::getGridColumns('my_space');
$columns = $session_columns['simple_column_name'];
$result = [];
if (!empty($sessions)) {
@ -1543,7 +1544,7 @@ switch ($action) {
api_get_path(WEB_CODE_PATH).'mySpace/course.php?session_id='.$session['id']
);
$result[] = [
$item = [
'name' => Display::url(
$session['name'],
api_get_path(WEB_CODE_PATH).'mySpace/course.php?session_id='.$session['id']
@ -1551,8 +1552,15 @@ switch ($action) {
'date' => $dateToString,
'course_per_session' => $count_courses_in_session,
'student_per_session' => $count_users_in_session,
'details' => implode(' ', $detailButtons),
'actions' => implode(' ', $detailButtons),
];
if (!empty($extra_fields)) {
foreach ($extra_fields as $extraField) {
$item[$extraField['field']] = $extraField['data'];
}
}
$result[] = $item;
}
}
break;
@ -1582,41 +1590,6 @@ switch ($action) {
);
}
break;
/*
$columns = array(
'name',
'nbr_courses',
'nbr_users',
'category_name',
'access_start_date',
'access_end_date',
'coach_name',
'session_active',
'visibility'
);
if (SessionManager::allowToManageSessions()) {
if (SessionManager::allowOnlyMySessions()) {
$whereCondition .= ' AND s.id_coach = '.api_get_user_id();
}
// Rename Category_name
$whereCondition = str_replace(
'category_name',
'sc.name',
$whereCondition
);
$result = SessionManager::get_sessions_admin(
array(
'where' => $whereCondition,
'order' => "$sidx $sord",
'limit' => "$start , $limit"
)
);
}
*/
break;
case 'get_exercise_progress':
$sessionId = (int) $_GET['session_id'];
$courseId = (int) $_GET['course_id'];

@ -480,7 +480,7 @@ class SessionManager
if (!api_is_platform_admin()) {
if (api_is_session_admin() &&
api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false'
api_get_setting('allow_session_admins_to_manage_all_sessions') === 'false'
) {
$where .= " AND s.session_admin_id = $userId ";
}
@ -488,7 +488,7 @@ class SessionManager
if (!api_is_platform_admin() &&
api_is_teacher() &&
api_get_setting('allow_teachers_to_create_sessions') == 'true'
api_get_setting('allow_teachers_to_create_sessions') === 'true'
) {
$where .= " AND s.id_coach = $userId ";
}
@ -505,8 +505,8 @@ class SessionManager
$isMakingOrder = false;
$showCountUsers = false;
if ($getCount == true) {
$select = " SELECT count(DISTINCT s.id) as total_rows";
if ($getCount === true) {
$select = ' SELECT count(DISTINCT s.id) as total_rows ';
} else {
if (!empty($columns['column_model'])) {
foreach ($columns['column_model'] as $column) {
@ -623,7 +623,6 @@ class SessionManager
}
$userId = api_get_user_id();
$sessions = self::getSessionsForAdmin($userId, $options, $getCount, $columns);
if ($getCount) {
@ -648,7 +647,7 @@ class SessionManager
$session['users'] = self::get_users_by_session($session['id'], 0, true);
}
$url = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$session['id'];
if (api_is_drh() || $extraFieldsToLoad) {
if ($extraFieldsToLoad || api_is_drh()) {
$url = api_get_path(WEB_PATH).'session/'.$session['id'].'/about/';
}
@ -3671,6 +3670,7 @@ class SessionManager
* @param string $orderCondition
* @param string $keyword
* @param string $description
* @param array $options
*
* @return array sessions
*/
@ -3683,7 +3683,8 @@ class SessionManager
$getSql = false,
$orderCondition = null,
$keyword = '',
$description = ''
$description = '',
$options = []
) {
return self::getSessionsFollowedByUser(
$userId,
@ -3695,7 +3696,8 @@ class SessionManager
$getSql,
$orderCondition,
$keyword,
$description
$description,
$options
);
}
@ -3712,6 +3714,7 @@ class SessionManager
* @param string $orderCondition
* @param string $keyword
* @param string $description
* @param array $options
*
* @return array sessions
*/
@ -3725,7 +3728,8 @@ class SessionManager
$getSql = false,
$orderCondition = null,
$keyword = '',
$description = ''
$description = '',
$options = []
) {
// Database Table Definitions
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
@ -3733,15 +3737,26 @@ class SessionManager
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$extraFieldModel = new ExtraFieldModel('session');
$conditions = $extraFieldModel->parseConditions($options);
$sqlInjectJoins = $conditions['inject_joins'];
$extraFieldsConditions = $conditions['where'];
$sqlInjectWhere = $conditions['inject_where'];
$injectExtraFields = $conditions['inject_extra_fields'];
if (!empty($injectExtraFields)) {
$injectExtraFields = ' , '.$injectExtraFields.' s.id';
}
$userId = (int) $userId;
$select = " SELECT DISTINCT * ";
$select = ' SELECT DISTINCT * '.$injectExtraFields;
if ($getCount) {
$select = " SELECT count(DISTINCT(s.id)) as count ";
$select = ' SELECT count(DISTINCT(s.id)) as count ';
}
if ($getOnlySessionId) {
$select = " SELECT DISTINCT(s.id) ";
$select = ' SELECT DISTINCT(s.id) ';
}
$limitCondition = null;
@ -3750,7 +3765,7 @@ class SessionManager
}
if (empty($orderCondition)) {
$orderCondition = " ORDER BY s.name ";
$orderCondition = ' ORDER BY s.name ';
}
$whereConditions = null;
@ -3799,15 +3814,19 @@ class SessionManager
$whereConditions .= $keywordCondition;
$subQuery = $sessionQuery.$courseSessionQuery;
$sql = " $select FROM $tbl_session s
$sql = " $select
FROM $tbl_session s
INNER JOIN $tbl_session_rel_access_url a
ON (s.id = a.session_id)
$sqlInjectJoins
WHERE
access_url_id = ".api_get_current_access_url_id()." AND
s.id IN (
$subQuery
)
$whereConditions
$extraFieldsConditions
$sqlInjectWhere
$orderCondition
$limitCondition";
@ -8040,13 +8059,13 @@ SQL;
}
/**
* @param string $list_type
* @param string $listType
* @param array $extraFields
*
* @return array
*/
public static function getGridColumns(
$list_type = 'simple',
$listType = 'simple',
$extraFields = []
) {
$showCount = api_get_configuration_value('session_list_show_count_users');
@ -8054,7 +8073,36 @@ SQL;
$operators = ['cn', 'nc'];
$date_operators = ['gt', 'ge', 'lt', 'le'];
switch ($list_type) {
switch ($listType) {
case 'my_space':
$columns = [
get_lang('Title'),
get_lang('Date'),
get_lang('NbCoursesPerSession'),
get_lang('NbStudentPerSession'),
get_lang('Details'),
];
$columnModel = [
['name' => 'name', 'index' => 'name', 'width' => '255', 'align' => 'left'],
['name' => 'date', 'index' => 'access_start_date', 'width' => '150', 'align' => 'left'],
[
'name' => 'course_per_session',
'index' => 'course_per_session',
'width' => '150',
'sortable' => 'false',
'search' => 'false',
],
[
'name' => 'student_per_session',
'index' => 'student_per_session',
'width' => '100',
'sortable' => 'false',
'search' => 'false',
],
['name' => 'actions', 'index' => 'actions', 'width' => '100', 'sortable' => 'false', 'search' => 'false'],
];
break;
case 'simple':
$columns = [
'#',
@ -8062,13 +8110,10 @@ SQL;
get_lang('Category'),
get_lang('SessionDisplayStartDate'),
get_lang('SessionDisplayEndDate'),
//get_lang('Coach'),
//get_lang('Status'),
//get_lang('CourseTitle'),
get_lang('Visibility'),
];
$column_model = [
$columnModel = [
[
'name' => 'id',
'index' => 's.id',
@ -8124,7 +8169,7 @@ SQL;
if ($showCount) {
$columns[] = get_lang('Users');
$column_model[] = [
$columnModel[] = [
'name' => 'users',
'index' => 'users',
'width' => '20',
@ -8143,7 +8188,7 @@ SQL;
get_lang('Visibility'),
get_lang('CourseTitle'),
];
$column_model = [
$columnModel = [
['name' => 'name', 'index' => 's.name', 'width' => '200', 'align' => 'left', 'search' => 'true', 'searchoptions' => ['sopt' => $operators]],
['name' => 'display_start_date', 'index' => 'display_start_date', 'width' => '70', 'align' => 'left', 'search' => 'true', 'searchoptions' => ['dataInit' => 'date_pick_today', 'sopt' => $date_operators]],
['name' => 'display_end_date', 'index' => 'display_end_date', 'width' => '70', 'align' => 'left', 'search' => 'true', 'searchoptions' => ['dataInit' => 'date_pick_one_month', 'sopt' => $date_operators]],
@ -8165,7 +8210,7 @@ SQL;
if (!empty($extraFields)) {
foreach ($extraFields as $field) {
$columns[] = $field['display_text'];
$column_model[] = [
$columnModel[] = [
'name' => $field['variable'],
'index' => $field['variable'],
'width' => '80',
@ -8177,30 +8222,34 @@ SQL;
// Inject extra session fields
$session_field = new ExtraFieldModel('session');
$rules = $session_field->getRules($columns, $column_model);
$column_model[] = [
'name' => 'actions',
'index' => 'actions',
'width' => '80',
'align' => 'left',
'formatter' => 'action_formatter',
'sortable' => 'false',
'search' => 'false',
];
$columns[] = get_lang('Actions');
$rules = $session_field->getRules($columns, $columnModel);
if (!in_array('actions', array_column($columnModel, 'name'))) {
$columnModel[] = [
'name' => 'actions',
'index' => 'actions',
'width' => '80',
'align' => 'left',
'formatter' => 'action_formatter',
'sortable' => 'false',
'search' => 'false',
];
$columns[] = get_lang('Actions');
}
foreach ($column_model as $col_model) {
$simple_column_name[] = $col_model['name'];
$columnName = [];
foreach ($columnModel as $col_model) {
$columnName[] = $col_model['name'];
}
$return_array = [
$return = [
'columns' => $columns,
'column_model' => $column_model,
'column_model' => $columnModel,
'rules' => $rules,
'simple_column_name' => $simple_column_name,
'simple_column_name' => $columnName,
];
return $return_array;
return $return;
}
/**

@ -9,6 +9,7 @@ use ChamiloSession as Session;
use CpChart\Cache as pCache;
use CpChart\Data as pData;
use CpChart\Image as pImage;
use ExtraField as ExtraFieldModel;
/**
* Class Tracking.
@ -3767,7 +3768,7 @@ class Tracking
/**
* Get sessions coached by user.
*
* @param $coach_id
* @param int $coach_id
* @param int $start
* @param int $limit
* @param bool $getCount
@ -3775,6 +3776,7 @@ class Tracking
* @param string $description
* @param string $orderByName
* @param string $orderByDirection
* @param array $options
*
* @return mixed
*/
@ -3786,16 +3788,17 @@ class Tracking
$keyword = '',
$description = '',
$orderByName = '',
$orderByDirection = ''
$orderByDirection = '',
$options = []
) {
// 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 = (int) $coach_id;
$select = " SELECT * FROM ";
$select = ' SELECT * FROM ';
if ($getCount) {
$select = " SELECT count(DISTINCT id) as count FROM ";
$select = ' SELECT count(DISTINCT id) as count FROM ';
}
$limitCondition = null;
@ -3804,7 +3807,6 @@ class Tracking
}
$keywordCondition = null;
if (!empty($keyword)) {
$keyword = Database::escape_string($keyword);
$keywordCondition = " AND (name LIKE '%$keyword%' ) ";
@ -3815,6 +3817,14 @@ class Tracking
}
}
$extraFieldModel = new ExtraFieldModel('session');
$conditions = $extraFieldModel->parseConditions($options);
$sqlInjectJoins = $conditions['inject_joins'];
$extraFieldsConditions = $conditions['where'];
$sqlInjectWhere = $conditions['inject_where'];
$injectExtraFields = $conditions['inject_extra_fields'];
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
@ -3831,34 +3841,42 @@ class Tracking
$select
(
SELECT DISTINCT
session.id,
s.id,
name,
$injectExtraFields
access_start_date,
access_end_date
FROM $tbl_session session
FROM $tbl_session s
INNER JOIN $tbl_session_rel_access_url session_rel_url
ON (session.id = session_rel_url.session_id)
ON (s.id = session_rel_url.session_id)
$sqlInjectJoins
WHERE
id_coach = $coach_id AND
access_url_id = $access_url_id
$keywordCondition
$extraFieldsConditions
$sqlInjectWhere
UNION
SELECT DISTINCT
session.id,
session.name,
session.access_start_date,
session.access_end_date
FROM $tbl_session as session
s.id,
s.name,
$injectExtraFields
s.access_start_date,
s.access_end_date
FROM $tbl_session as s
INNER JOIN $tbl_session_course_user as session_course_user
ON
session.id = session_course_user.session_id AND
s.id = session_course_user.session_id AND
session_course_user.user_id = $coach_id AND
session_course_user.status = 2
INNER JOIN $tbl_session_rel_access_url session_rel_url
ON (session.id = session_rel_url.session_id)
INNER JOIN $tbl_session_rel_access_url session_rel_url
ON (s.id = session_rel_url.session_id)
$sqlInjectJoins
WHERE
access_url_id = $access_url_id
$keywordCondition
$extraFieldsConditions
$sqlInjectWhere
) as sessions $limitCondition $orderBy
";

@ -1,11 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
use ExtraField as ExtraFieldModel;
/**
* Sessions reporting.
*
* @package chamilo.reporting
*/
ob_start();
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -14,13 +17,13 @@ api_block_anonymous_users();
$this_section = SECTION_TRACKING;
$export_csv = false;
if (isset($_GET['export']) && $_GET['export'] == 'csv') {
if (isset($_REQUEST['export']) && $_REQUEST['export'] == 'csv') {
$export_csv = true;
}
$id_coach = api_get_user_id();
if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
$id_coach = (int) $_GET['id_coach'];
if (isset($_REQUEST['id_coach']) && $_REQUEST['id_coach'] != '') {
$id_coach = (int) $_REQUEST['id_coach'];
}
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
@ -121,7 +124,7 @@ if (api_is_platform_admin(true, true)) {
$form = new FormValidator(
'search_course',
'get',
'post',
api_get_path(WEB_CODE_PATH).'mySpace/session.php'
);
$form->addElement('text', 'keyword', get_lang('Keyword'));
@ -132,48 +135,183 @@ if ($form->validate()) {
}
$form->setDefaults(['keyword' => $keyword]);
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions_tracking&keyword='.Security::remove_XSS($keyword);
$columns = [
get_lang('Title'),
get_lang('Date'),
get_lang('NbCoursesPerSession'),
get_lang('NbStudentPerSession'),
get_lang('Details'),
];
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions_tracking&_search=true&_force_search=true&filters=&keyword='.Security::remove_XSS($keyword);
// Column config
$columnModel = [
['name' => 'name', 'index' => 'name', 'width' => '255', 'align' => 'left'],
['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'],
];
$extraParams = [
'autowidth' => 'true',
'height' => 'auto',
];
$js = '<script>
$(function() {
'.Display::grid_js(
'session_tracking',
$url,
$columns,
$columnModel,
$extraParams,
[],
null,
true
).'
});
</script>';
echo $js;
$result = SessionManager::getGridColumns('my_space');
$columns = $result['columns'];
$columnModel = $result['column_model'];
$extraParams['postData'] = [
'filters' => [
'groupOp' => 'AND',
'rules' => $result['rules'],
],
];
$urlAjaxExtraField = api_get_path(WEB_AJAX_PATH).'extra_field.ajax.php?1=1';
$allowOrder = api_get_configuration_value('session_list_order');
$orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
?>
<script>
function setSearchSelect(columnName) {
$("#sessions").jqGrid('setColProp', columnName, {
});
}
var added_cols = [];
var original_cols = [];
function clean_cols(grid, added_cols) {
// Cleaning
for (key in added_cols) {
grid.hideCol(key);
};
grid.showCol('name');
grid.showCol('display_start_date');
grid.showCol('display_end_date');
grid.showCol('course_title');
}
function show_cols(grid, added_cols) {
grid.showCol('name').trigger('reloadGrid');
for (key in added_cols) {
grid.showCol(key);
};
}
var second_filters = [];
$(function() {
date_pick_today = function(elem) {
$(elem).datetimepicker({dateFormat: "yy-mm-dd"});
$(elem).datetimepicker('setDate', (new Date()));
}
date_pick_one_month = function(elem) {
$(elem).datetimepicker({dateFormat: "yy-mm-dd"});
next_month = Date.today().next().month();
$(elem).datetimepicker('setDate', next_month);
}
// Great hack
register_second_select = function(elem) {
second_filters[$(elem).val()] = $(elem);
}
fill_second_select = function(elem) {
$(elem).on("change", function() {
composed_id = $(this).val();
field_id = composed_id.split("#")[0];
id = composed_id.split("#")[1];
$.ajax({
url: "<?php echo $urlAjaxExtraField; ?>&a=get_second_select_options",
dataType: "json",
data: "type=session&field_id="+field_id+"&option_value_id="+id,
success: function(data) {
my_select = second_filters[field_id];
my_select.empty();
$.each(data, function(index, value) {
my_select.append($("<option/>", {
value: index,
text: value
}));
});
}
});
});
}
<?php
echo Display::grid_js(
'sessions',
$url,
$columns,
$columnModel,
$extraParams,
[],
null,
true
);
?>
setSearchSelect("status");
var grid = $("#sessions"),
prmSearch = {
multipleSearch : true,
overlay : false,
width: 'auto',
caption: '<?php echo addslashes(get_lang('Search')); ?>',
formclass:'data_table',
onSearch : function() {
var postdata = grid.jqGrid('getGridParam', 'postData');
if (postdata && postdata.filters) {
filters = jQuery.parseJSON(postdata.filters);
clean_cols(grid, added_cols);
added_cols = [];
$.each(filters, function(key, value) {
if (key == 'rules') {
$.each(value, function(subkey, subvalue) {
added_cols[subvalue.field] = subvalue.field;
});
}
});
show_cols(grid, added_cols);
}
},
onReset: function() {
clean_cols(grid, added_cols);
}
};
original_cols = grid.jqGrid('getGridParam', 'colModel');
grid.jqGrid('navGrid','#sessions_pager',
{edit:false,add:false,del:false},
{height:280,reloadAfterSubmit:false}, // edit options
{height:280,reloadAfterSubmit:false}, // add options
{reloadAfterSubmit:false},// del options
prmSearch
);
<?php
// Create the searching dialog.
echo 'grid.searchGrid(prmSearch);';
?>
// Fixes search table.
var searchDialogAll = $("#fbox_"+grid[0].id);
searchDialogAll.addClass("table");
var searchDialog = $("#searchmodfbox_"+grid[0].id);
searchDialog.addClass("ui-jqgrid ui-widget ui-widget-content ui-corner-all");
searchDialog.css({position:"adsolute", "z-index":"100", "float":"left", "top":"55%", "left" : "25%", "padding" : "5px", "border": "1px solid #CCC"})
var gbox = $("#gbox_"+grid[0].id);
gbox.before(searchDialog);
gbox.css({clear:"left"});
// Select first elements by default
$('.input-elm').each(function() {
$(this).find('option:first').attr('selected', 'selected');
});
$('.delete-rule').each(function(){
$(this).click(function(){
$('.input-elm').each(function(){
$(this).find('option:first').attr('selected', 'selected');
});
});
});
});
</script>
<?php
$form->display();
echo Display::grid_html('session_tracking');
echo Display::grid_html('sessions');
Display::display_footer();

@ -133,13 +133,8 @@ $extra_params['height'] = 'auto';
if (!isset($_GET['keyword'])) {
$extra_params['postData'] = [
'filters' => [
"groupOp" => "AND",
"rules" => $result['rules'],
/*array(
array( "field" => "display_start_date", "op" => "gt", "data" => ""),
array( "field" => "display_end_date", "op" => "gt", "data" => "")
),*/
//'groups' => $groups
'groupOp' => 'AND',
'rules' => $result['rules'],
],
];
}
@ -164,23 +159,14 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
<script>
function setSearchSelect(columnName) {
$("#sessions").jqGrid('setColProp', columnName, {
/*searchoptions:{
dataInit:function(el){
$("option[value='1']",el).attr("selected", "selected");
setTimeout(function(){
$(el).trigger('change');
}, 1000);
}
}*/
});
}
var added_cols = [];
var original_cols = [];
function clean_cols(grid, added_cols) {
//Cleaning
// Cleaning
for (key in added_cols) {
//console.log('hide: ' + key);
grid.hideCol(key);
};
grid.showCol('name');
@ -192,7 +178,6 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
function show_cols(grid, added_cols) {
grid.showCol('name').trigger('reloadGrid');
for (key in added_cols) {
//console.log('show: ' + key);
grid.showCol(key);
};
}
@ -268,17 +253,12 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
filters = jQuery.parseJSON(postdata.filters);
clean_cols(grid, added_cols);
added_cols = [];
$.each(filters, function(key, value){
//console.log('key: ' + key );
$.each(filters, function(key, value) {
if (key == 'rules') {
$.each(value, function(subkey, subvalue) {
if (subvalue.data == undefined) {
}
//if (added_cols[value.field] == undefined) {
added_cols[subvalue.field] = subvalue.field;
//}
//grid.showCol(value.field);
});
}
});
@ -308,10 +288,10 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
});
orderList = JSON.stringify(orderList);
$.get("<?php echo $orderUrl; ?>", "order="+orderList, function (result) {
//console.log(result);
});
}
};
// Sortable rows
grid.jqGrid('sortableRows', options);
<?php
@ -342,7 +322,7 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
gbox.before(searchDialog);
gbox.css({clear:"left"});
//Select first elements by default
// Select first elements by default
$('.input-elm').each(function(){
$(this).find('option:first').attr('selected', 'selected');
});

Loading…
Cancel
Save