+
+ // makeGroupByXmlTag creates an xml tag for a totals only report using group_by1,
+ // group_by2, and group_by3 values passed in $options.
+ static function makeGroupByXmlTag($options) {
+ if ($options['group_by1'] != null && $options['group_by1'] != 'no_grouping') {
+ // We have group_by1.
+ $tag .= '_'.$options['group_by1'];
+ }
+ if ($options['group_by2'] != null && $options['group_by2'] != 'no_grouping') {
+ // We have group_by2.
+ $tag .= '_'.$options['group_by2'];
+ }
+ if ($options['group_by3'] != null && $options['group_by3'] != 'no_grouping') {
+ // We have group_by3.
+ $tag .= '_'.$options['group_by3'];
+ }
+ $tag = ltrim($tag, '_');
+ return $tag;
+ }
+
+ // makeGroupByLabel builds a label for one row in a "Totals only" report of grouped by items.
+ // It does one thing: if we are grouping by date, the date format is converted for user.
+ static function makeGroupByLabel($key, $options) {
+ if (!ttReportHelper::groupingBy('date', $options))
+ return $key; // No need to format.
+
+ global $user;
+ if ($user->date_format == DB_DATEFORMAT)
+ return $key; // No need to format.
+
+ $label = $key;
+ if (preg_match('/\d\d\d\d-\d\d-\d\d/', $key, $matches)) {
+ // Replace the first found match of a date in DB_DATEFORMAT.
+ // This is not entirely clean but better than nothing for a label in a row.
+ $userDate = ttDateToUserFormat($matches[0]);
+ $label = str_replace($matches[0], $userDate, $key);
+ }
+ return $label;
+ }