]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttReportHelper.class.php
Fixed creation of group by tag for XML report export.
[timetracker.git] / WEB-INF / lib / ttReportHelper.class.php
index 7a4ba2664c2a9e29154bb71e53197ab51295778b..60cac07903d607bb19e2ccbb776e0b81fb56c344 100644 (file)
@@ -468,11 +468,6 @@ class ttReportHelper {
     $res = $mdb2->query($sql);
     if (is_a($res, 'PEAR_Error')) die($res->getMessage());
     while ($val = $res->fetchRow()) {
-// TODO: consider writing a function that properly formats a date part in a multi-part key.
-//
-//      if ('date' == $group_by_option) {
-//        $val['group_field'] = ttDateToUserFormat($val['group_field']);
-//      }
       $time = $val['time'] ? sec_to_time_fmt_hm($val['time']) : null;
       $rowLabel = ttReportHelper::makeGroupByLabel($val['group_field'], $options);
       if ($options['show_cost']) {
@@ -1478,6 +1473,25 @@ class ttReportHelper {
     return $group_by_header;
   }
 
+  // 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) {