include elements/search.html the right way to avoid problems with XLS download, ...
[freeside.git] / httemplate / search / timeworked.html
index 1d877e6..fa4b895 100644 (file)
@@ -1,4 +1,4 @@
-<% include( 'elements/search.html',
+<& elements/search.html,
                  'title'       => 'Time Worked',
                  'name'        => 'time',
                 'html_form'   => qq!<FORM NAME="timeForm" ACTION="${p}misc/timeworked.html" METHOD="POST">!,
@@ -33,9 +33,8 @@
                    '',
                  ],
                  'html_foot' => $html_foot,
-             )
-
-%>
+             
+&>
 <%init>
 
 die "access denied"
@@ -45,12 +44,14 @@ my @groupby = ();
 
 my $transactiontime = "
   CASE Transactions.Type WHEN 'Set'
-    THEN (TO_NUMBER(NewValue,'999999')-TO_NUMBER(OldValue, '999999')) * 60
+    THEN (  CASE WHEN NewValue = '' THEN 0 ELSE TO_NUMBER(NewValue,'999999') END
+           -TO_NUMBER(OldValue, '999999')
+          ) * 60
     ELSE TimeTaken*60
   END
 ";
 
-push @groupby, qw( transactions.type newvalue oldvalue timetaken );
+push @groupby, qw( Transactions.Type NewValue OldValue TimeTaken );
 
 my $appliedtimeclause = "COALESCE (SUM(acct_rt_transaction.seconds), 0)";
 
@@ -76,9 +77,7 @@ my $groupby = join(',', @groupby);
 my $where = "
   WHERE ObjectType='RT::Ticket'
     AND ( ( Transactions.Type='Set' AND Field='TimeWorked' )
-          OR Transactions.Type='Create'
-          OR Transactions.Type='Comment'
-          OR Transactions.Type='Correspond'
+          OR Transactions.Type IN ( 'Create', 'Comment', 'Correspond', 'Touch' )
         )
     AND $wheretimeleft
 ";