X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Frt_transaction.html;h=be9cd0bc9672e416532430e80aac319d3362d56b;hb=40f436877b2334fc2d4fd34c50d54807ae8777af;hp=fb828af844e08dd9099528905cb1d64da7b67b2b;hpb=64cff83a723d02a3064e08d4e69c13f9b43fed58;p=freeside.git diff --git a/httemplate/search/rt_transaction.html b/httemplate/search/rt_transaction.html index fb828af84..be9cd0bc9 100644 --- a/httemplate/search/rt_transaction.html +++ b/httemplate/search/rt_transaction.html @@ -3,7 +3,7 @@ 'name_singular' => 'transaction', 'query' => $query, 'count_query' => $count_query, - 'count_addl' => [ $format_seconds_sub ],#$format_seconds_sub, ], + 'count_addl' => [ $format_seconds_sub, $format_seconds_sub, ], 'header' => [ 'Ticket #', 'Ticket', 'Date', @@ -47,9 +47,9 @@ die "access denied" #some amount of false laziness w/timeworked.html... my $transactiontime = " - CASE transactions.type when 'Set' - THEN (to_number(newvalue,'999999')-to_number(oldvalue, '999999')) * 60 - ELSE timetaken*60 + CASE Transactions.Type when 'Set' + THEN (to_number(NewValue,'999999')-to_number(OldValue, '999999')) * 60 + ELSE TimeTaken*60 END "; @@ -62,7 +62,7 @@ my $where = " AND ( ( Transactions.Type = 'Set' AND Transactions.Field = 'TimeWorked' AND Transactions.NewValue != Transactions.OldValue ) - OR ( ( Transactions.Type='Create' OR Transactions.Type='Comment' OR Transactions.Type='Correspond' ) + OR ( ( Transactions.Type='Create' OR Transactions.Type='Comment' OR Transactions.Type='Correspond' OR Transactions.Type='Touch' ) AND Transactions.TimeTaken > 0 ) ) @@ -70,6 +70,8 @@ my $where = " #AND transaction_time != 0 #AND $wheretimeleft +my $support = ''; + my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); # TIMESTAMP is Pg-specific... ? if ( $beginning > 0 ) { @@ -86,13 +88,16 @@ if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) { } if ( $cgi->param('ticketid') =~ /^\s*(\d+)\s*$/ ) { - $where .= " AND Tickets.ID = $1"; + $where .= " AND Tickets.Id = $1"; } if ( $cgi->param('svcnum') =~ /^\s*(\d+)\s*$/ ) { $where .= " AND EXISTS( SELECT 1 FROM acct_rt_transaction WHERE acct_rt_transaction.transaction_id = Transactions.id AND svcnum = $1 )"; + $support = "AND svcnum = $1"; } +my $support_time = "( SELECT SUM(support) from acct_rt_transaction where transaction_id = Transactions.id $support )"; + my $query = { 'select' => join(', ', 'Transactions.*', @@ -100,7 +105,7 @@ my $query = { 'Tickets.Subject', 'Users.name AS otaker', "$transactiontime AS transaction_time", - '( SELECT SUM(support) from acct_rt_transaction where transaction_id = Transactions.id ) AS support', + "$support_time AS support", ), 'table' => 'transactions', #Pg-ism #'table' => 'Transactions', @@ -111,7 +116,10 @@ my $query = { my $count_query = #"SELECT COUNT(*), SUM($transactiontime), SUM(acct_rt_transaction.support) FROM Transactions $join $where"; - "SELECT COUNT(*), SUM($transactiontime) FROM Transactions $join $where"; + "SELECT COUNT(*), + SUM($transactiontime), + SUM($support_time) + FROM Transactions $join $where"; my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->get('ticketid'); } ];