X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fsearch%2Frt_transaction.html;h=ab563634725b2b7ddaf9acb11296b9f11152c777;hp=31ad10d1af002a66be1c7f343641d1b4664889d2;hb=c3da5cf1caa244937d280e0f406927103beef148;hpb=948b8acdd4b9b3864342062d0c397a11f57c5700 diff --git a/httemplate/search/rt_transaction.html b/httemplate/search/rt_transaction.html index 31ad10d1a..ab5636347 100644 --- a/httemplate/search/rt_transaction.html +++ b/httemplate/search/rt_transaction.html @@ -3,11 +3,12 @@ 'name_singular' => 'transaction', 'query' => $query, 'count_query' => $count_query, - 'count_addl' => [ $format_seconds_sub, ], + 'count_addl' => [ $format_seconds_sub, $format_seconds_sub, ], 'header' => [ 'Ticket #', 'Ticket', 'Date', 'Time', + 'Applied', ], 'fields' => [ 'ticketid', sub { encode_entities(shift->get('subject')) }, @@ -15,12 +16,16 @@ sub { my $seconds = shift->get('transaction_time'); &{ $format_seconds_sub }( $seconds ); }, + sub { my $seconds = shift->get('support'); + &{ $format_seconds_sub }( $seconds ); + }, ], 'links' => [ $link, $link, '', '', + '', ], ) %> @@ -28,7 +33,9 @@ my $format_seconds_sub = sub { my $seconds = shift; - (($seconds < 0) ? '-' : '') . concise(duration($seconds)); + #(($seconds < 0) ? '-' : '') . concise(duration($seconds)); + (($seconds < 0) ? '-' : '' ). int(abs($seconds)/3600)."h".sprintf("%02d",(abs( +$seconds)%3600)/60)."m"; }; @@ -47,14 +54,15 @@ my $transactiontime = " "; my $join = 'JOIN Tickets ON Transactions.ObjectId = Tickets.Id '. - 'JOIN Users ON Transactions.Creator = Users.Id '; - + 'JOIN Users ON Transactions.Creator = Users.Id '; #. +# 'LEFT JOIN acct_rt_transaction '. +# ' ON Transactions.Id = acct_rt_transaction.transaction_id'; my $where = " WHERE objecttype='RT::Ticket' AND ( ( Transactions.Type = 'Set' AND Transactions.Field = 'TimeWorked' AND Transactions.NewValue != Transactions.OldValue ) - OR ( ( Transactions.Type='Comment' OR Transactions.Type='Correspond' ) + OR ( ( Transactions.Type='Create' OR Transactions.Type='Comment' OR Transactions.Type='Correspond' ) AND Transactions.TimeTaken > 0 ) ) @@ -62,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 ) { @@ -77,20 +87,40 @@ if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) { $where .= " AND Users.name = '$1' "; } +if ( $cgi->param('ticketid') =~ /^\s*(\d+)\s*$/ ) { + $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' => "Transactions.*, Tickets.Id AS ticketid, Tickets.Subject, Users.name as otaker, $transactiontime AS transaction_time", + 'select' => join(', ', + 'Transactions.*', + 'Tickets.Id AS ticketid', + 'Tickets.Subject', + 'Users.name AS otaker', + "$transactiontime AS transaction_time", + "$support_time AS support", + ), + 'table' => 'transactions', #Pg-ism #'table' => 'Transactions', - 'table' => 'transactions', - 'addl_from' => $join. - 'LEFT JOIN acct_rt_transaction '. - ' ON Transactions.Id = acct_rt_transaction.transaction_id', + 'addl_from' => $join, 'extra_sql' => $where, 'order by' => 'ORDER BY Created', }; my $count_query = - "SELECT COUNT(*), SUM($transactiontime) FROM Transactions $join $where"; + #"SELECT COUNT(*), SUM($transactiontime), SUM(acct_rt_transaction.support) 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('id'); } ]; +my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->get('ticketid'); } ];