Skip to content

Commit

Permalink
Add param 'export_filename' to set the export filename see BT#13187
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Nov 23, 2017
1 parent 0b497b8 commit 2646dca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
14 changes: 9 additions & 5 deletions main/inc/ajax/model.ajax.php
Expand Up @@ -13,6 +13,7 @@
$limit = intval($_REQUEST['rows']); //quantity of rows
$sidx = $_REQUEST['sidx']; //index (field) to filter
$sord = $_REQUEST['sord']; //asc or desc
$exportFilename = isset($_REQUEST['export_filename']) ? $_REQUEST['export_filename'] : '';

if (strpos(strtolower($sidx), 'asc') !== false) {
$sidx = str_replace(array('asc', ','), '', $sidx);
Expand Down Expand Up @@ -2077,22 +2078,25 @@ function getWhereClause($col, $oper, $val)
}
$j++;
}
$fileName = !empty($action) ? $action : 'company_report';
if (!empty($exportFilename)) {
$fileName = $exportFilename;
}

switch ($exportFormat) {
case 'xls':
//TODO add date if exists
$file_name = (!empty($action)) ? $action : 'company_report';
$browser = new Browser();
if ($browser->getPlatform() == Browser::PLATFORM_WINDOWS) {
Export::export_table_xls_html($array, $file_name, 'ISO-8859-15');
Export::export_table_xls_html($array, $fileName, 'ISO-8859-15');
} else {
Export::export_table_xls_html($array, $file_name);
Export::export_table_xls_html($array, $fileName);
}
break;
case 'csv':
default:
//TODO add date if exists
$file_name = (!empty($action)) ? $action : 'company_report';
Export::arrayToCsv($array, $file_name);
Export::arrayToCsv($array, $fileName);
break;
}
exit;
Expand Down
3 changes: 2 additions & 1 deletion main/mySpace/exercise_category_report.php
Expand Up @@ -86,7 +86,8 @@
$values = $form->getSubmitValues();
$exerciseId = isset($values['exercise_id']) ? $values['exercise_id'] : 0;
$startDate = Security::remove_XSS($values['start_date']);
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results_report&exercise_id='.$exerciseId.'&start_date='.$startDate.'&cidReq='.$courseInfo['code'];
$exportFilename = 'exercise_results_report_'.$exerciseId;
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_results_report&exercise_id='.$exerciseId.'&start_date='.$startDate.'&cidReq='.$courseInfo['code'].'&export_filename='.$exportFilename;

$categoryList = TestCategory::getListOfCategoriesIDForTest($exerciseId, $courseId);
$columns = array(
Expand Down

0 comments on commit 2646dca

Please sign in to comment.