1 <& elements/search.html,
2 'title' => 'Time Worked',
4 'html_form' => qq!<FORM NAME="timeForm" ACTION="${p}misc/timeworked.html" METHOD="POST">!,
6 'count_query' => $count_query,
13 'fields' => [ sub { shift->[0] },
14 sub { encode_entities(shift->[1]) },
16 sub { my $seconds = shift->[3];
17 (($seconds < 0) ? '-' : '') .
18 concise(duration($seconds));
22 my $seconds = $row->[3];
24 qq!<INPUT NAME="transactionid$id" TYPE="checkbox" VALUE="1">!.
25 qq!<INPUT NAME="seconds$id" TYPE="hidden" VALUE="$seconds">!;
35 'html_foot' => $html_foot,
41 unless $FS::CurrentUser::CurrentUser->access_right('Time queue');
45 my $transactiontime = "
46 CASE Transactions.Type WHEN 'Set'
47 THEN ( CASE WHEN NewValue = '' THEN 0 ELSE TO_NUMBER(NewValue,'999999') END
48 -TO_NUMBER(OldValue, '999999')
54 push @groupby, qw( Transactions.Type NewValue OldValue TimeTaken );
56 my $appliedtimeclause = "COALESCE (SUM(acct_rt_transaction.seconds), 0)";
58 my $appliedtimeselect = "
60 ( SELECT SUM(seconds) FROM acct_rt_transaction
61 WHERE transaction_id = Transactions.id
67 push @groupby, "Transactions.id";
69 my $wheretimeleft = "$transactiontime != $appliedtimeselect";
71 push @groupby, "Tickets.id";
72 push @groupby, "Tickets.Subject";
73 push @groupby, "Transactions.Created";
75 my $groupby = join(',', @groupby);
78 WHERE ObjectType='RT::Ticket'
79 AND ( ( Transactions.Type='Set' AND Field='TimeWorked' )
80 OR Transactions.Type IN ( 'Create', 'Comment', 'Correspond', 'Touch' )
86 my $str2time_sql = str2time_sql;
87 my $closing = str2time_sql_closing;
89 my($begin, $end) = FS::UI::Web::parse_beginning_ending($cgi);
90 $where .= " AND $str2time_sql Transactions.Created $closing >= $begin ".
91 " AND $str2time_sql Transactions.Created $closing <= $end ";
94 SELECT Tickets.id, Tickets.Subject,
95 TO_CHAR(Transactions.Created, 'Dy Mon DD HH24:MI:SS YYYY'),
96 $transactiontime-$appliedtimeclause,
99 JOIN Tickets ON Transactions.ObjectId = Tickets.id
100 LEFT JOIN acct_rt_transaction
101 ON Transactions.id = acct_rt_transaction.transaction_id
104 ORDER BY Transactions.Created
107 my $count_query = "SELECT COUNT(*) FROM Transactions $where";
109 my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->[0]; } ];
112 <INPUT TYPE="hidden" NAME="begin" VALUE="$begin">
113 <INPUT TYPE="hidden" NAME="end" VALUE="$end">
115 <INPUT TYPE="button" VALUE="select all" onClick="setAll(true)">
116 <INPUT TYPE="button" VALUE="unselect all" onClick="setAll(false)">
118 <INPUT TYPE="submit" NAME="action" VALUE="Assign to accounts"><BR>
119 <SCRIPT TYPE="text/javascript">
120 function setAll(setTo) {
121 theForm = document.timeForm;
122 for (i=0,n=theForm.elements.length;i<n;i++)
123 if (theForm.elements[i].name.indexOf("transactionid") != -1)
124 theForm.elements[i].checked = setTo;