X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Ftimeworked.html;h=12c7da043683c861b0f0272d7ad3e486b621754c;hp=49173bd08a1023d75fb002573e75f4ff264ab974;hb=1fc8addc56f8daf12397da568eb1ac1b27fd3984;hpb=7043f97e59b35d497e3e4fc66e6f23dbee34ca53 diff --git a/httemplate/search/timeworked.html b/httemplate/search/timeworked.html index 49173bd08..12c7da043 100644 --- a/httemplate/search/timeworked.html +++ b/httemplate/search/timeworked.html @@ -1,7 +1,7 @@ -<% include( 'elements/search.html', +<& elements/search.html, 'title' => 'Time Worked', 'name' => 'time', - 'html_form' => qq!
!, + 'html_form' => $html_form, 'query' => $query, 'count_query' => $count_query, 'header' => [ '#', @@ -32,22 +32,9 @@ '', '', ], - 'html_foot' => sub { - '
'. - ''. - '

'. - ''; - }, - ) - -%> + 'html_foot' => $html_foot, + +&> <%init> die "access denied" @@ -57,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)"; @@ -88,29 +77,76 @@ my $groupby = join(',', @groupby); my $where = " WHERE ObjectType='RT::Ticket' AND ( ( Transactions.Type='Set' AND Field='TimeWorked' ) - OR Transactions.Type='Comment' - OR Transactions.Type='Correspond' + OR Transactions.Type IN ( 'Create', 'Comment', 'Correspond', 'Touch' ) ) AND $wheretimeleft "; #AND $wheretimeleft +my $str2time_sql = str2time_sql; +my $closing = str2time_sql_closing; + + +my($begin, $end) = FS::UI::Web::parse_beginning_ending($cgi); +$where .= " AND $str2time_sql Transactions.Created $closing >= $begin ". + " AND $str2time_sql Transactions.Created $closing <= $end "; + +my $html_form = + qq( ); +if ($cgi->param('category') =~ /^(\w+)$/) { + $where .= " AND ocfv_TimeType.Content = '$1'"; + $html_form .= qq( ); +} + +my $from = " + FROM Transactions + JOIN Tickets ON Transactions.ObjectId = Tickets.id + LEFT JOIN acct_rt_transaction + ON Transactions.id = acct_rt_transaction.transaction_id + LEFT JOIN ( + SELECT DISTINCT ON (ObjectId) + ObjectId, Content + FROM ObjectCustomFieldValues + JOIN CustomFields + ON (ObjectCustomFieldValues.CustomField = CustomFields.Id) + WHERE CustomFields.Name = 'TimeType' + AND ObjectCustomFieldValues.ObjectType = 'RT::Ticket' + AND ObjectCustomFieldValues.Disabled = 0 + ORDER BY ObjectId ASC, ObjectCustomFieldValues.LastUpdated DESC + ) AS ocfv_TimeType ON (Tickets.Id = ocfv_TimeType.ObjectId) +"; + my $query = " SELECT Tickets.id, Tickets.Subject, TO_CHAR(Transactions.Created, 'Dy Mon DD HH24:MI:SS YYYY'), $transactiontime-$appliedtimeclause, Transactions.id - FROM Transactions - JOIN Tickets ON Transactions.ObjectId = Tickets.id - LEFT JOIN acct_rt_transaction - ON Transactions.id = acct_rt_transaction.transaction_id + $from $where GROUP BY $groupby ORDER BY Transactions.Created "; -my $count_query = "SELECT COUNT(*) FROM Transactions $where"; +my $count_query = "SELECT COUNT(*) $from $where"; my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->[0]; } ]; +my $html_foot = qq' + + +
+ + +
+
+ +'; +