@ -5,21 +5,19 @@
* @package chamilo.reporting
*/
ob_start();
$nameTools= 'Sessions';
// name of the language file that needs to be included
$language_file = array('registration', 'index', 'trad4all', 'tracking', 'admin');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
api_block_anonymous_users();
$this_section = SECTION_TRACKING;
api_block_anonymous_users();
$htmlHeadXtra[] = api_get_jqgrid_js();
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
Display :: display_header($nameTools );
Display::display_header(get_lang('Sessions') );
$export_csv = false;
@ -119,73 +117,38 @@ if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
$a_sessions = Tracking :: get_sessions_coached_by_user($id_coach);
}
$nb_sessions = count($a_sessions);
if ($export_csv) {
$csv_content = array();
}
if ($nb_sessions > 0) {
$table = new SortableTable('tracking', 'count_sessions_coached');
$table->set_header(0, get_lang('Title'));
$table->set_header(1, get_lang('Date'));
$table->set_header(2, get_lang('NbCoursesPerSession'));
$table->set_header(3, get_lang('Details'), false);
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_sessions_tracking';
$all_data = array();
foreach ($a_sessions as $session) {
$row = array();
$row[] = $session['name'];
if ($session['date_start'] != '0000-00-00' & & $session['date_end'] != '0000-00-00') {
$row[] = get_lang('From').' '. api_convert_and_format_date($session['date_start'], DATE_FORMAT_SHORT, date_default_timezone_get()).' '.get_lang('To').' '.api_convert_and_format_date($session['date_end'], DATE_FORMAT_SHORT, date_default_timezone_get());
} else {
$row[] = ' - ';
}
$row[] = count(Tracking::get_courses_list_from_session($session['id']));
if ($export_csv) {
$csv_content[] = $row;
}
if (isset($_GET['id_coach']) & & $_GET['id_coach'] != '') {
$row[] = '< a href = "student.php?id_session='.$session['id'].'&id_coach='.intval($_GET['id_coach']).'" >
< img src = "'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border = "0" / > < / a > ';
} else {
$row[] = '< a href = "course.php?id_session='.$session['id'].'" >
< img src = "'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border = "0" / > < / a > ';
}
$all_data[] = $row;
}
if (!isset($tracking_column)) {
$tracking_column = 0;
}
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(
get_lang('Title'),
get_lang('Date'),
get_lang('NbCoursesPerSession'),
get_lang('NbStudentPerSession'),
get_lang('Details')
);
if ($_GET['tracking_direction'] == 'DESC') {
usort($all_data, 'rsort_sessions');
} else {
usort($all_data, 'sort_sessions');
}
// Column config
$columnModel = array(
array('name'=>'name', 'index'=>'name', 'width'=>'255', 'align'=>'left'),
array('name'=>'date', 'index'=>'date', 'width'=>'150', 'align'=>'left','sortable'=>'false'),
array('name'=>'course_per_session', 'index'=>'course_per_session', 'width'=>'150','sortable'=>'false'),
array('name'=>'student_per_session', 'index'=>'student_per_session', 'width'=>'100','sortable'=>'false'),
array('name'=>'details', 'index'=>'details', 'width'=>'100','sortable'=>'false'),
);
if ($export_csv) {
usort($csv_content, 'sort_sessions');
}
$extraParams = array(
'autowidth' => 'true',
'height' => 'auto'
);
foreach ($all_data as $row) {
$table->addRow($row);
}
$js = '< script >
$(function() {
'.Display::grid_js('session_tracking', $url, $columns, $columnModel, $extraParams, array(), null, true).'
});
< / script > ';
$table -> display();
echo $js;
echo Display::grid_html('session_tracking');
if ($export_csv) {
ob_end_clean();
Export :: export_table_csv($csv_content, 'reporting_student_list');
exit;
}
} else {
echo get_lang('NoSession');
}
Display::display_footer();