Fix export Course Resources report to CSV - refs BT#13109

pull/2487/head
Angel Fernando Quiroz Campos 7 years ago
parent 51a016a2bf
commit 062280cc10
  1. 7
      main/inc/lib/tracking.lib.php
  2. 40
      main/tracking/course_log_resources.php

@ -6656,9 +6656,10 @@ class TrackingCourseLog
}
$from = intval($from);
$number_of_items = intval($number_of_items);
$sql .= " LIMIT $from, $number_of_items ";
if ($from) {
$number_of_items = intval($number_of_items);
$sql .= " LIMIT $from, $number_of_items ";
}
$res = Database::query($sql);
$resources = array();

@ -30,10 +30,46 @@ if (!$is_allowedToTrack) {
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$exportXls = isset($_GET['export']) && $_GET['export'] == 'xls' ? true : false;
$session_id = intval($_REQUEST['id_session']);
if ($export_csv) {
ob_start();
if ($export_csv || $exportXls) {
$csvData = TrackingCourseLog::get_item_resources_data(0, 0, '', '');
array_walk(
$csvData,
function (&$item) {
$item[0] = strip_tags($item[0]);
$item[2] = strip_tags(preg_replace('/\<br(\s*)?\/?\>/i', PHP_EOL, $item[2]));
$item[3] = strip_tags($item[3]);
$item[4] = strip_tags($item[4]);
unset(
$item['col0'],
$item['col1'],
$item['ref'],
$item['col3'],
$item['col6'],
$item['user_id'],
$item['col7']
);
}
);
array_unshift(
$csvData,
[
get_lang('Tool'),
get_lang('EventType'),
get_lang('Session'),
get_lang('UserName'),
get_lang('IPAddress'),
get_lang('Document'),
get_lang('Date')
]
);
Export::arrayToCsv($csvData);
die;
}
if (empty($session_id)) {

Loading…
Cancel
Save