1 <% include('elements/search.html',
2 'title' => 'Time worked',
3 'name_singular' => 'transaction',
5 'count_query' => $count_query,
6 'count_addl' => [ $format_seconds_sub, ],
7 'header' => [ 'Ticket #',
12 'fields' => [ 'ticketid',
13 sub { encode_entities(shift->get('subject')) },
15 sub { my $seconds = shift->get('transaction_time');
16 &{ $format_seconds_sub }( $seconds );
29 my $format_seconds_sub = sub {
31 (($seconds < 0) ? '-' : '') . concise(duration($seconds));
38 unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
40 #some amount of false laziness w/timeworked.html...
42 my $transactiontime = "
43 CASE transactions.type when 'Set'
44 THEN (to_number(newvalue,'999999')-to_number(oldvalue, '999999')) * 60
49 my $join = 'JOIN Tickets ON Transactions.ObjectId = Tickets.Id '.
50 'JOIN Users ON Transactions.Creator = Users.Id ';
53 WHERE objecttype='RT::Ticket'
54 AND ( ( Transactions.Type = 'Set'
55 AND Transactions.Field = 'TimeWorked'
56 AND Transactions.NewValue != Transactions.OldValue )
57 OR ( ( Transactions.Type='Create' OR Transactions.Type='Comment' OR Transactions.Type='Correspond' )
58 AND Transactions.TimeTaken > 0
62 #AND transaction_time != 0
65 my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
66 # TIMESTAMP is Pg-specific... ?
67 if ( $beginning > 0 ) {
68 $beginning = "TIMESTAMP '". time2str('%Y-%m-%d %X', $beginning). "'";
69 $where .= " AND Transactions.Created >= $beginning ";
71 if ( $ending < 4294967295 ) {
72 $ending = "TIMESTAMP '". time2str('%Y-%m-%d %X', $ending). "'";
73 $where .= " AND Transactions.Created <= $ending ";
76 if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) {
77 $where .= " AND Users.name = '$1' ";
81 'select' => "Transactions.*, Tickets.Id AS ticketid, Tickets.Subject, Users.name as otaker, $transactiontime AS transaction_time",
82 #'table' => 'Transactions',
83 'table' => 'transactions',
85 'LEFT JOIN acct_rt_transaction '.
86 ' ON Transactions.Id = acct_rt_transaction.transaction_id',
87 'extra_sql' => $where,
88 'order by' => 'ORDER BY Created',
92 "SELECT COUNT(*), SUM($transactiontime) FROM Transactions $join $where";
94 my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->get('id'); } ];