[freeside-commits] freeside/httemplate/search report_cust_credit.html, 1.12, 1.13 report_rt_transaction.html, NONE, 1.1 rt_transaction.html, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Tue Dec 4 12:51:54 PST 2007
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail:/tmp/cvs-serv25475/httemplate/search
Modified Files:
report_cust_credit.html
Added Files:
report_rt_transaction.html rt_transaction.html
Log Message:
add some time-worked reporting
Index: report_cust_credit.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_cust_credit.html,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- report_cust_credit.html 1 Aug 2007 22:26:45 -0000 1.12
+++ report_cust_credit.html 4 Dec 2007 20:51:51 -0000 1.13
@@ -4,18 +4,12 @@
<INPUT TYPE="hidden" NAME="magic" VALUE="_date">
<TABLE>
- <TR>
- <TD ALIGN="right">Credits by employee: </TD>
- <TD>
- <SELECT NAME="otaker">
- <OPTION VALUE="">all</OPTION>
-% foreach my $otaker ( @otakers ) {
- <OPTION VALUE="<% $otaker %>"><% $otaker %></OPTION>
-% }
- </SELECT>
- </TD>
- </TR>
+ <% include( '/elements/tr-select-otaker.html',
+ 'label' => 'Credits by employee: ',
+ 'otakers' => \@otakers,
+ )
+ %>
<% include( '/elements/tr-select-agent.html',
'curr_value' => scalar( $cgi->param('agentnum') ),
--- NEW FILE: report_rt_transaction.html ---
<% include('/elements/header.html', 'Time worked report criteria' ) %>
<FORM ACTION="rt_transaction.html" METHOD="GET">
<TABLE>
<% include ( '/elements/tr-input-beginning_ending.html' ) %>
<% include ( '/elements/tr-select-otaker.html' ) %>
</TABLE>
<BR>
<INPUT TYPE="submit" VALUE="Search">
<% include('/elements/footer.html') %>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
</%init>
--- NEW FILE: rt_transaction.html ---
<% include('elements/search.html',
'title' => 'Time worked',
'name_singular' => 'transaction',
'query' => $query,
'count_query' => $count_query,
'count_addl' => [ $format_seconds_sub, ],
'header' => [ 'Ticket #',
'Ticket',
'Date',
'Time',
],
'fields' => [ 'ticketid',
sub { encode_entities(shift->get('subject')) },
'created',
sub { my $seconds = shift->get('transaction_time');
&{ $format_seconds_sub }( $seconds );
},
],
'links' => [
$link,
$link,
'',
'',
],
)
%>
<%once>
my $format_seconds_sub = sub {
my $seconds = shift;
(($seconds < 0) ? '-' : '') . concise(duration($seconds));
};
</%once>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
#some amount of false laziness w/timeworked.html...
my $transactiontime = "
CASE transactions.type when 'Set'
THEN (to_number(newvalue,'999999')-to_number(oldvalue, '999999')) * 60
ELSE timetaken*60
END
";
my $join = 'JOIN Tickets ON Transactions.ObjectId = Tickets.Id '.
'JOIN Users ON Transactions.Creator = Users.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' )
AND Transactions.TimeTaken > 0
)
)
";
#AND transaction_time != 0
#AND $wheretimeleft
my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
# TIMESTAMP is Pg-specific... ?
if ( $beginning > 0 ) {
$beginning = "TIMESTAMP '". time2str('%Y-%m-%d %X', $beginning). "'";
$where .= " AND Transactions.Created >= $beginning ";
}
if ( $ending < 4294967295 ) {
$ending = "TIMESTAMP '". time2str('%Y-%m-%d %X', $ending). "'";
$where .= " AND Transactions.Created <= $ending ";
}
if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) {
$where .= " AND Users.name = '$1' ";
}
my $query = {
'select' => "Transactions.*, Tickets.Id AS ticketid, Tickets.Subject, Users.name as otaker, $transactiontime AS transaction_time",
#'table' => 'Transactions',
'table' => 'transactions',
'addl_from' => $join.
'LEFT JOIN acct_rt_transaction '.
' ON Transactions.Id = acct_rt_transaction.transaction_id',
'extra_sql' => $where,
'order by' => 'ORDER BY Created',
};
my $count_query =
"SELECT COUNT(*), SUM($transactiontime) FROM Transactions $join $where";
my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->get('id'); } ];
</%init>
More information about the freeside-commits
mailing list