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">!;
35 'html_foot' => $html_foot,
42 unless $FS::CurrentUser::CurrentUser->access_right('Time queue');
46 my $transactiontime = "
47 CASE Transactions.Type WHEN 'Set'
48 THEN ( CASE WHEN NewValue = '' THEN 0 ELSE TO_NUMBER(NewValue,'999999') END
49 -TO_NUMBER(OldValue, '999999')
55 push @groupby, qw( Transactions.Type NewValue OldValue TimeTaken );
57 my $appliedtimeclause = "COALESCE (SUM(acct_rt_transaction.seconds), 0)";
59 my $appliedtimeselect = "
61 ( SELECT SUM(seconds) FROM acct_rt_transaction
62 WHERE transaction_id = Transactions.id
68 push @groupby, "Transactions.id";
70 my $wheretimeleft = "$transactiontime != $appliedtimeselect";
72 push @groupby, "Tickets.id";
73 push @groupby, "Tickets.Subject";
74 push @groupby, "Transactions.Created";
76 my $groupby = join(',', @groupby);
79 WHERE ObjectType='RT::Ticket'
80 AND ( ( Transactions.Type='Set' AND Field='TimeWorked' )
81 OR Transactions.Type='Create'
82 OR Transactions.Type='Comment'
83 OR Transactions.Type='Correspond'
89 my $str2time_sql = str2time_sql;
90 my $closing = str2time_sql_closing;
92 my($begin, $end) = FS::UI::Web::parse_beginning_ending($cgi);
93 $where .= " AND $str2time_sql Transactions.Created $closing >= $begin ".
94 " AND $str2time_sql Transactions.Created $closing <= $end ";
97 SELECT Tickets.id, Tickets.Subject,
98 TO_CHAR(Transactions.Created, 'Dy Mon DD HH24:MI:SS YYYY'),
99 $transactiontime-$appliedtimeclause,
102 JOIN Tickets ON Transactions.ObjectId = Tickets.id
103 LEFT JOIN acct_rt_transaction
104 ON Transactions.id = acct_rt_transaction.transaction_id
107 ORDER BY Transactions.Created
110 my $count_query = "SELECT COUNT(*) FROM Transactions $where";
112 my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->[0]; } ];
115 <INPUT TYPE="hidden" NAME="begin" VALUE="$begin">
116 <INPUT TYPE="hidden" NAME="end" VALUE="$end">
118 <INPUT TYPE="button" VALUE="select all" onClick="setAll(true)">
119 <INPUT TYPE="button" VALUE="unselect all" onClick="setAll(false)">
121 <INPUT TYPE="submit" NAME="action" VALUE="Assign to accounts"><BR>
122 <SCRIPT TYPE="text/javascript">
123 function setAll(setTo) {
124 theForm = document.timeForm;
125 for (i=0,n=theForm.elements.length;i<n;i++)
126 if (theForm.elements[i].name.indexOf("transactionid") != -1)
127 theForm.elements[i].checked = setTo;