1 <% include( '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">!;
36 '<BR><INPUT TYPE="button" VALUE="select all" onClick="setAll(true)">'.
37 '<INPUT TYPE="button" VALUE="unselect all" onClick="setAll(false)">'.
38 '<BR><INPUT TYPE="submit" NAME="action" VALUE="Assign to accounts"><BR>'.
39 '<SCRIPT TYPE="text/javascript">'.
40 ' function setAll(setTo) { '.
41 ' theForm = document.timeForm;'.
42 ' for (i=0,n=theForm.elements.length;i<n;i++)'.
43 ' if (theForm.elements[i].name.indexOf("transactionid") != -1)'.
44 ' theForm.elements[i].checked = setTo;'.
54 unless $FS::CurrentUser::CurrentUser->access_right('Time queue');
58 my $transactiontime = "
59 CASE Transactions.Type WHEN 'Set'
60 THEN (TO_NUMBER(NewValue,'999999')-TO_NUMBER(OldValue, '999999')) * 60
65 push @groupby, qw( transactions.type newvalue oldvalue timetaken );
67 my $appliedtimeclause = "COALESCE (SUM(acct_rt_transaction.seconds), 0)";
69 my $appliedtimeselect = "
71 ( SELECT SUM(seconds) FROM acct_rt_transaction
72 WHERE transaction_id = Transactions.id
78 push @groupby, "Transactions.id";
80 my $wheretimeleft = "$transactiontime != $appliedtimeselect";
82 push @groupby, "Tickets.id";
83 push @groupby, "Tickets.Subject";
84 push @groupby, "Transactions.Created";
86 my $groupby = join(',', @groupby);
89 WHERE ObjectType='RT::Ticket'
90 AND ( ( Transactions.Type='Set' AND Field='TimeWorked' )
91 OR Transactions.Type='Create'
92 OR Transactions.Type='Comment'
93 OR Transactions.Type='Correspond'
100 SELECT Tickets.id, Tickets.Subject,
101 TO_CHAR(Transactions.Created, 'Dy Mon DD HH24:MI:SS YYYY'),
102 $transactiontime-$appliedtimeclause,
105 JOIN Tickets ON Transactions.ObjectId = Tickets.id
106 LEFT JOIN acct_rt_transaction
107 ON Transactions.id = acct_rt_transaction.transaction_id
110 ORDER BY Transactions.Created
113 my $count_query = "SELECT COUNT(*) FROM Transactions $where";
115 my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->[0]; } ];