]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttReportHelper.class.php
Some fixes associated with renaming the group_by field.
[timetracker.git] / WEB-INF / lib / ttReportHelper.class.php
index 019293207c26e6cf2b208878e67e0ca5db515814..538830c3c4bee6694a7fe24b91b1811b9920192c 100644 (file)
@@ -127,7 +127,7 @@ class ttReportHelper {
     $canViewReports = $user->can('view_reports') || $user->can('view_all_reports');
     $isClient = $user->isClient();
 
-    $group_by_option = $options['group_by'];
+    $group_by_option = $options['group_by1'];
     $convertTo12Hour = ('%I:%M %p' == $user->time_format) && ($options['show_start'] || $options['show_end']);
 
     // Prepare a query for time items in tt_log table.
@@ -394,7 +394,7 @@ class ttReportHelper {
   static function getSubtotals($options) {
     global $user;
 
-    $group_by_option = $options['group_by'];
+    $group_by_option = $options['group_by1'];
     if ('no_grouping' == $group_by_option) return null;
 
     $mdb2 = getConnection();
@@ -667,7 +667,7 @@ class ttReportHelper {
     $isClient = $user->isClient();
 
     $items = ttReportHelper::getItems($options);
-    $group_by = $options['group_by'];
+    $group_by = $options['group_by1'];
     if ($group_by && 'no_grouping' != $group_by)
       $subtotals = ttReportHelper::getSubtotals($options);
     $totals = ttReportHelper::getTotals($options);
@@ -962,11 +962,34 @@ class ttReportHelper {
   {
     $items = ttReportHelper::getItems($options);
 
-    $condition = str_replace('count', '', $condition);
-    $count_required = (int) trim(str_replace('>', '', $condition));
+    $condition = trim(str_replace('count', '', $condition));
 
-    if (count($items) > $count_required)
-      return true; // Condition ok.
+    $greater_or_equal = ttStartsWith($condition, '>=');
+    if ($greater_or_equal) $condition = trim(str_replace('>=', '', $condition));
+
+    $less_or_equal = ttStartsWith($condition, '<=');
+    if ($less_or_equal) $condition = trim(str_replace('<=', '', $condition));
+
+    $not_equal = ttStartsWith($condition, '<>');
+    if ($not_equal) $condition = trim(str_replace('<>', '', $condition));
+
+    $greater = ttStartsWith($condition, '>');
+    if ($greater) $condition = trim(str_replace('>', '', $condition));
+
+    $less = ttStartsWith($condition, '<');
+    if ($less) $condition = trim(str_replace('<', '', $condition));
+
+    $equal = ttStartsWith($condition, '=');
+    if ($equal) $condition = trim(str_replace('=', '', $condition));
+
+    $count_required = (int) $condition;
+
+    if ($greater && count($items) > $count_required) return true;
+    if ($greater_or_equal && count($items) >= $count_required) return true;
+    if ($less && count($items) < $count_required) return true;
+    if ($less_or_equal && count($items) <= $count_required) return true;
+    if ($equal && count($items) == $count_required) return true;
+    if ($not_equal && count($items) <> $count_required) return true;
 
     return false;
   }
@@ -1039,7 +1062,7 @@ class ttReportHelper {
     $options['show_custom_field_1'] = $bean->getAttribute('chcf_1');
     $options['show_work_units'] = $bean->getAttribute('chunits');
     $options['show_totals_only'] = $bean->getAttribute('chtotalsonly');
-    $options['group_by'] = $bean->getAttribute('group_by');
+    $options['group_by1'] = $bean->getAttribute('group_by1');
     return $options;
   }