You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
227 lines
9.1 KiB
227 lines
9.1 KiB
15 years ago
|
<?php
|
||
15 years ago
|
/* For licensing terms, see /license.txt */
|
||
12 years ago
|
/**
|
||
|
* List sessions in an efficient and usable way
|
||
|
* @package chamilo.admin
|
||
|
*/
|
||
15 years ago
|
$cidReset = true;
|
||
15 years ago
|
|
||
15 years ago
|
require_once '../inc/global.inc.php';
|
||
15 years ago
|
$this_section = SECTION_PLATFORM_ADMIN;
|
||
15 years ago
|
|
||
15 years ago
|
api_protect_admin_script(true);
|
||
|
|
||
13 years ago
|
//Add the JS needed to use the jqgrid
|
||
13 years ago
|
$htmlHeadXtra[] = api_get_jqgrid_js();
|
||
15 years ago
|
|
||
11 years ago
|
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
|
||
|
$idChecked = isset($_REQUEST['idChecked']) ? $_REQUEST['idChecked'] : null;
|
||
13 years ago
|
|
||
15 years ago
|
if ($action == 'delete') {
|
||
10 years ago
|
SessionManager::delete($idChecked);
|
||
13 years ago
|
header('Location: session_list.php');
|
||
15 years ago
|
exit();
|
||
14 years ago
|
} elseif ($action == 'copy') {
|
||
|
SessionManager::copy_session($idChecked);
|
||
13 years ago
|
header('Location: session_list.php');
|
||
14 years ago
|
exit();
|
||
15 years ago
|
}
|
||
|
|
||
|
$interbreadcrumb[]=array("url" => "index.php","name" => get_lang('PlatformAdmin'));
|
||
|
|
||
13 years ago
|
$tool_name = get_lang('SessionList');
|
||
|
Display::display_header($tool_name);
|
||
|
|
||
10 years ago
|
$error_message = '';
|
||
|
// Avoid conflict with the global variable $error_msg (array type) in add_course.conf.php.
|
||
13 years ago
|
if (isset($_GET['action']) && $_GET['action'] == 'show_message') {
|
||
|
$error_message = Security::remove_XSS($_GET['message']);
|
||
|
}
|
||
|
|
||
|
if (!empty($error_message)) {
|
||
|
Display::display_normal_message($error_message, false);
|
||
|
}
|
||
|
|
||
10 years ago
|
$sessionFilter = new FormValidator('course_filter', 'get', '', '', array(), FormValidator::LAYOUT_INLINE);
|
||
11 years ago
|
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_course';
|
||
|
$courseList = array();
|
||
|
$courseId = isset($_GET['course_id']) ? $_GET['course_id'] : null;
|
||
|
if (!empty($courseId)) {
|
||
|
$courseInfo = api_get_course_info_by_id($courseId);
|
||
11 years ago
|
$parents = getParentsToString($courseInfo['categoryCode']);
|
||
10 years ago
|
$courseList[] = array('id' => $courseInfo['code'], 'text' => $parents.$courseInfo['title']);
|
||
11 years ago
|
}
|
||
10 years ago
|
|
||
11 years ago
|
$sessionFilter->addElement('select_ajax', 'course_name', get_lang('SearchCourse'), null, array('url' => $url, 'defaults' => $courseList));
|
||
|
$url = api_get_self();
|
||
|
$actions = '
|
||
|
<script>
|
||
|
$(function() {
|
||
|
$("#course_name").on("change", function() {
|
||
|
var courseId = $(this).val();
|
||
|
window.location = "'.$url.'?course_id="+courseId;
|
||
|
});
|
||
|
});
|
||
|
</script>';
|
||
|
|
||
|
// jqgrid will use this URL to do the selects
|
||
|
if (!empty($courseId)) {
|
||
|
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&course_id='.$courseId;
|
||
|
} else {
|
||
|
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions';
|
||
|
}
|
||
|
|
||
11 years ago
|
|
||
13 years ago
|
if (isset($_REQUEST['keyword'])) {
|
||
|
//Begin with see the searchOper param
|
||
11 years ago
|
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&_force_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=s.name&searchString='.Security::remove_XSS($_REQUEST['keyword']).'&searchOper=bw';
|
||
13 years ago
|
}
|
||
|
|
||
11 years ago
|
if (isset($_REQUEST['id_category'])) {
|
||
|
$sessionCategory = SessionManager::get_session_category($_REQUEST['id_category']);
|
||
|
if (!empty($sessionCategory)) {
|
||
|
//Begin with see the searchOper param
|
||
11 years ago
|
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions&_force_search=true&rows=20&page=1&sidx=&sord=asc&filters=&searchField=sc.name&searchString='.Security::remove_XSS($sessionCategory['name']).'&searchOper=bw';
|
||
11 years ago
|
}
|
||
|
}
|
||
|
|
||
11 years ago
|
//The order is important you need to check the the $column variable in the model.ajax.php file
|
||
11 years ago
|
$columns = array(
|
||
|
get_lang('Name'),
|
||
|
get_lang('NumberOfCourses'),
|
||
|
get_lang('NumberOfUsers'),
|
||
|
get_lang('SessionCategoryName'),
|
||
|
get_lang('StartDate'),
|
||
|
get_lang('EndDate'),
|
||
|
get_lang('Coach'),
|
||
|
get_lang('Status'),
|
||
|
get_lang('Visibility'),
|
||
|
get_lang('Actions')
|
||
|
);
|
||
13 years ago
|
|
||
|
//Column config
|
||
|
$column_model = array(
|
||
11 years ago
|
array('name'=>'name', 'index'=>'s.name', 'width'=>'160', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
|
||
11 years ago
|
array('name'=>'nbr_courses', 'index'=>'nbr_courses', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
|
||
|
array('name'=>'nbr_users', 'index'=>'nbr_users', 'width'=>'30', 'align'=>'left', 'search' => 'true'),
|
||
11 years ago
|
array('name'=>'category_name', 'index'=>'sc.name', 'width'=>'70', 'align'=>'left', 'search' => 'true'),
|
||
11 years ago
|
array('name'=>'date_start', 'index'=>'s.date_start', 'width'=>'40', 'align'=>'left', 'search' => 'true'),
|
||
|
array('name'=>'date_end', 'index'=>'s.date_end', 'width'=>'40', 'align'=>'left', 'search' => 'true'),
|
||
11 years ago
|
array('name'=>'coach_name', 'index'=>'coach_name', 'width'=>'80', 'align'=>'left', 'search' => 'false'),
|
||
10 years ago
|
array('name'=>'status', 'index'=>'session_active','width'=>'45',
|
||
|
'align'=>'left', 'search' => 'true', 'stype'=>'select',
|
||
11 years ago
|
//for the bottom bar
|
||
|
'searchoptions' => array(
|
||
11 years ago
|
'defaultValue' => ':',
|
||
|
'value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive')
|
||
11 years ago
|
),
|
||
|
//for the top bar
|
||
|
'editoptions' => array(
|
||
|
'value' => ':'.get_lang('All').';1:'.get_lang('Active').';0:'.get_lang('Inactive')
|
||
|
)
|
||
|
),
|
||
10 years ago
|
array('name'=>'visibility', 'index'=>'visibility', 'width'=>'45', 'align'=>'left', 'search' => 'false'),
|
||
|
array('name'=>'actions', 'index'=>'actions', 'width'=>'90',
|
||
|
'align'=>'left','formatter'=>'action_formatter','sortable'=>'false', 'search' => 'false')
|
||
11 years ago
|
);
|
||
10 years ago
|
|
||
11 years ago
|
//Autowidth
|
||
13 years ago
|
$extra_params['autowidth'] = 'true';
|
||
13 years ago
|
|
||
11 years ago
|
//height auto
|
||
13 years ago
|
$extra_params['height'] = 'auto';
|
||
|
|
||
|
//With this function we can add actions to the jgrid (edit, delete, etc)
|
||
|
$action_links = 'function action_formatter(cellvalue, options, rowObject) {
|
||
11 years ago
|
return \'<a href="session_edit.php?page=resume_session.php&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
|
||
|
' <a href="add_users_to_session.php?page=session_list.php&id_session=\'+options.rowId+\'">'.Display::return_icon('user_subscribe_session.png',get_lang('SubscribeUsersToSession'),'',ICON_SIZE_SMALL).'</a>'.
|
||
|
' <a href="add_courses_to_session.php?page=session_list.php&id_session=\'+options.rowId+\'">'.Display::return_icon('courses_to_session.png',get_lang('SubscribeCoursesToSession'),'',ICON_SIZE_SMALL).'</a>'.
|
||
|
' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="session_list.php?action=copy&idChecked=\'+options.rowId+\'">'.Display::return_icon('copy.png',get_lang('Copy'),'',ICON_SIZE_SMALL).'</a>'.
|
||
|
' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="session_list.php?action=delete&idChecked=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
|
||
|
'\';
|
||
|
}';
|
||
13 years ago
|
?>
|
||
|
<script>
|
||
13 years ago
|
|
||
11 years ago
|
function setSearchSelect(columnName) {
|
||
|
$("#sessions").jqGrid(
|
||
|
'setColProp',
|
||
|
columnName,
|
||
|
{
|
||
|
searchoptions: {
|
||
|
dataInit:function(el) {
|
||
11 years ago
|
$("option[value='2']",el).attr("selected", "selected");
|
||
11 years ago
|
setTimeout(function() {
|
||
|
$(el).trigger('change');
|
||
|
}, 1000);
|
||
|
}
|
||
13 years ago
|
}
|
||
|
}
|
||
11 years ago
|
);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
$(function() {
|
||
11 years ago
|
<?php
|
||
11 years ago
|
echo Display::grid_js('sessions', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
|
||
13 years ago
|
?>
|
||
11 years ago
|
|
||
|
setSearchSelect("status");
|
||
|
|
||
11 years ago
|
$("#sessions").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
|
||
|
{ width:500 } // search options
|
||
13 years ago
|
);
|
||
11 years ago
|
|
||
13 years ago
|
/*
|
||
|
// add custom button to export the data to excel
|
||
|
jQuery("#sessions").jqGrid('navButtonAdd','#sessions_pager',{
|
||
11 years ago
|
caption:"",
|
||
|
onClickButton : function () {
|
||
13 years ago
|
jQuery("#sessions").excelExport();
|
||
11 years ago
|
}
|
||
13 years ago
|
});
|
||
11 years ago
|
|
||
13 years ago
|
jQuery('#sessions').jqGrid('navButtonAdd','#sessions_pager',{id:'pager_csv',caption:'',title:'Export To CSV',onClickButton : function(e)
|
||
|
{
|
||
|
try {
|
||
|
jQuery("#sessions").jqGrid('excelExport',{tag:'csv', url:'grid.php'});
|
||
|
} catch (e) {
|
||
|
window.location= 'grid.php?oper=csv';
|
||
|
}
|
||
|
},buttonicon:'ui-icon-document'})
|
||
|
*/
|
||
11 years ago
|
|
||
11 years ago
|
// Adding search options
|
||
13 years ago
|
var options = {
|
||
|
'stringResult': true,
|
||
|
'autosearch' : true,
|
||
11 years ago
|
'searchOnEnter':false
|
||
13 years ago
|
}
|
||
11 years ago
|
|
||
|
jQuery("#sessions").jqGrid('filterToolbar', options);
|
||
13 years ago
|
var sgrid = $("#sessions")[0];
|
||
|
sgrid.triggerToolbar();
|
||
13 years ago
|
});
|
||
13 years ago
|
</script>
|
||
13 years ago
|
<div class="actions">
|
||
11 years ago
|
<?php
|
||
11 years ago
|
|
||
13 years ago
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_add.php">'.Display::return_icon('new_session.png',get_lang('AddSession'),'',ICON_SIZE_MEDIUM).'</a>';
|
||
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/add_many_session_to_category.php">'.Display::return_icon('session_to_category.png',get_lang('AddSessionsInCategories'),'',ICON_SIZE_MEDIUM).'</a>';
|
||
|
echo '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_list.php">'.Display::return_icon('folder.png',get_lang('ListSessionCategory'),'',ICON_SIZE_MEDIUM).'</a>';
|
||
11 years ago
|
|
||
|
echo $actions;
|
||
|
echo '<div class="pull-right">';
|
||
|
echo $sessionFilter->return_form();
|
||
|
echo '</div>';
|
||
13 years ago
|
echo '</div>';
|
||
|
echo Display::grid_html('sessions');
|
||
12 years ago
|
Display::display_footer();
|
||
11 years ago
|
|
||
|
|