summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics_reporting
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics_reporting')
-rw-r--r--modules-available/statistics_reporting/page.inc.php30
-rw-r--r--modules-available/statistics_reporting/templates/columnChooser.html7
2 files changed, 33 insertions, 4 deletions
diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php
index f0614d35..51c137f6 100644
--- a/modules-available/statistics_reporting/page.inc.php
+++ b/modules-available/statistics_reporting/page.inc.php
@@ -87,11 +87,12 @@ class Page_Statistics_Reporting extends Page
'days' => array()
);
+ $forceOn = (Request::get('type') === false);
foreach ($this->COLUMNS as $column) {
$data['columns'][] = array(
'id' => 'col_' . $column,
'name' => Dictionary::translateFile('template-tags', 'lang_' . $column, true),
- 'checked' => Request::get($column, 'on', 'string') === 'on' ? 'checked' : '',
+ 'checked' => ($forceOn || Request::get('col_' . $column, 'off', 'string') !== 'off') ? 'checked' : '',
);
}
@@ -162,7 +163,32 @@ class Page_Statistics_Reporting extends Page
$flags |= GETDATA_PRINTABLE;
}
$res = $this->fetchData($flags);
- // TODO: Filter unwanted columns
+ // Filter unwanted columns
+ if (isset($res[0])) {
+ foreach ($this->COLUMNS as $column) {
+ if (Request::get('col_' . $column, 'delete', 'string') === 'delete') {
+ foreach ($res as &$row) {
+ unset($row[$column], $row[$column . '_s']);
+ if ($column === 'location') {
+ unset($row['locationId']);
+ }
+ }
+ } elseif ($printable && isset($row[0][$column . '_s'])) {
+ foreach ($res as &$row) {
+ unset($row[$column]);
+ }
+ } elseif ($column === 'location' && (isset($res[0]['location']) || isset($res[0]['locationId']))) {
+ foreach ($res as &$row) {
+ if ($printable) {
+ unset($row['locationId']);
+ } else {
+ unset($row['location']);
+ }
+ }
+ }
+ }
+ unset($row);
+ }
Header('Content-Disposition: attachment; filename=' . 'statistics-' . date('Y.m.d-H.i.s') . '.' . $format);
switch ($format) {
case 'json':
diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html
index 75dfb34f..f08daf1c 100644
--- a/modules-available/statistics_reporting/templates/columnChooser.html
+++ b/modules-available/statistics_reporting/templates/columnChooser.html
@@ -34,9 +34,8 @@
<div class="col-md-12 form-inline">
<div><strong class="text-capitalize">{{lang_displayColumns}}</strong></div>
{{#columns}}
- <input type="hidden" name="{{id}}" value="off">
<div class="checkbox">
- <input id="id_{{id}}" name="{{id}}" type="checkbox" class="column-toggle form-control" {{checked}}>
+ <input id="id_{{id}}" name="{{id}}" value="on" type="checkbox" class="column-toggle form-control" {{checked}}>
<label for="id_{{id}}">{{name}}</label>
</div>
{{/columns}}
@@ -142,6 +141,10 @@
$('.column-toggle').each(function () {
var box = $(this);
if ($('.' + box.attr('name')).length === 0) {
+ if (!box.is(':checked')) {
+ box.attr('value', 'off');
+ box.prop('checked', true);
+ }
box.parent().hide();
} else {
updateColumn(box);