summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics
diff options
context:
space:
mode:
authorSimon Rettberg2017-12-07 17:06:33 +0100
committerSimon Rettberg2017-12-07 17:06:33 +0100
commitc94d4ca0cc467f1ded417a9fae1f3128a2fdda54 (patch)
treea16d4a50d9309a1bd79c4d2a1027a9d2f2408b81 /modules-available/statistics
parent[locationinfo] Fixing openingtime in the Summary panel (diff)
downloadslx-admin-c94d4ca0cc467f1ded417a9fae1f3128a2fdda54.tar.gz
slx-admin-c94d4ca0cc467f1ded417a9fae1f3128a2fdda54.tar.xz
slx-admin-c94d4ca0cc467f1ded417a9fae1f3128a2fdda54.zip
[statistics] location filter: Support recursive matching by (ab)using ~ and !~
Diffstat (limited to 'modules-available/statistics')
-rw-r--r--modules-available/statistics/inc/filter.inc.php13
-rw-r--r--modules-available/statistics/page.inc.php2
2 files changed, 11 insertions, 4 deletions
diff --git a/modules-available/statistics/inc/filter.inc.php b/modules-available/statistics/inc/filter.inc.php
index 6e437a71..be6df752 100644
--- a/modules-available/statistics/inc/filter.inc.php
+++ b/modules-available/statistics/inc/filter.inc.php
@@ -208,15 +208,22 @@ class LocationFilter extends Filter
public function whereClause(&$args, &$joins)
{
+ $recursive = (substr($this->operator, -1) === '~');
+ $this->operator = str_replace('~', '=', $this->operator);
+
settype($this->argument, 'int');
+ $neg = $this->operator === '=' ? '' : 'NOT';
if ($this->argument === 0) {
- $neg = $this->operator === '=' ? '' : 'NOT';
return "machine.locationid IS $neg NULL";
} else {
global $unique_key;
$key = $this->column . '_arg' . ($unique_key++);
- $args[$key] = $this->argument;
- return "machine.locationid {$this->operator} :$key";
+ if ($recursive) {
+ $args[$key] = array_keys(Location::getRecursiveFlat($this->argument));
+ } else {
+ $args[$key] = $this->argument;
+ }
+ return "machine.locationid $neg IN (:$key)";
}
}
}
diff --git a/modules-available/statistics/page.inc.php b/modules-available/statistics/page.inc.php
index df12c568..6d48cc66 100644
--- a/modules-available/statistics/page.inc.php
+++ b/modules-available/statistics/page.inc.php
@@ -116,7 +116,7 @@ class Page_Statistics extends Page
];
if (Module::isAvailable('locations')) {
Page_Statistics::$columns['location'] = [
- 'op' => Page_Statistics::$op_nominal,
+ 'op' => Page_Statistics::$op_stringcmp,
'type' => 'enum',
'column' => false,
'values' => array_keys(Location::getLocationsAssoc()),