[freeside-commits] freeside/httemplate/search report_rt_ticket.html, NONE, 1.1.2.2 report_rt_transaction.html, 1.3, 1.3.4.1 rt_ticket.html, NONE, 1.1.2.2 rt_transaction.html, 1.8, 1.8.2.1
Ivan,,,
ivan at wavetail.420.am
Sat Nov 20 15:00:46 PST 2010
Update of /home/cvs/cvsroot/freeside/httemplate/search
In directory wavetail.420.am:/tmp/cvs-serv28268/httemplate/search
Modified Files:
Tag: FREESIDE_2_1_BRANCH
report_rt_transaction.html rt_transaction.html
Added Files:
Tag: FREESIDE_2_1_BRANCH
report_rt_ticket.html rt_ticket.html
Log Message:
time worked summary report, RT#7573
--- NEW FILE: rt_ticket.html ---
<% include('elements/search.html',
'title' => 'Time worked summary',
'name_singular' => 'ticket',
'query' => $query,
'count_query' => $count_query,
'count_addl' => [ $format_seconds_sub, $format_seconds_sub, ],
'header' => [ 'Ticket #',
'Ticket',
'Time',
'Applied',
],
'fields' => [ 'ticketid',
sub { encode_entities(shift->get('subject')) },
sub { my $seconds = shift->get('transaction_time');
&{ $format_seconds_sub }( $seconds );
},
sub { my $seconds = shift->get('support');
&{ $format_seconds_sub }( $seconds );
},
],
'links' => [
$link,
$link,
'',
'',
],
)
%>
<%once>
my $format_seconds_sub = sub {
my $seconds = shift;
#(($seconds < 0) ? '-' : '') . concise(duration($seconds));
(($seconds < 0) ? '-' : '' ). int(abs($seconds)/3600)."h".sprintf("%02d",(abs(
$seconds)%3600)/60)."m";
};
</%once>
<%init>
#all sorts of false laziness w/rt_transaction.html
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 Users ON Transactions.Creator = Users.Id '; #.
# 'LEFT JOIN acct_rt_transaction '.
# ' ON Transactions.Id = acct_rt_transaction.transaction_id';
my $twhere = "
WHERE objecttype='RT::Ticket'
AND Transactions.ObjectId = Tickets.Id
AND ( ( Transactions.Type = 'Set'
AND Transactions.Field = 'TimeWorked'
AND Transactions.NewValue != Transactions.OldValue )
OR ( ( Transactions.Type='Create' OR Transactions.Type='Comment' OR Transactions.Type='Correspond' )
AND Transactions.TimeTaken > 0
)
)
";
#AND transaction_time != 0
#AND $wheretimeleft
my $support = '';
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). "'";
$twhere .= " AND Transactions.Created >= $beginning ";
}
if ( $ending < 4294967295 ) {
$ending = "TIMESTAMP '". time2str('%Y-%m-%d %X', $ending). "'";
$twhere .= " AND Transactions.Created <= $ending ";
}
if ( $cgi->param('otaker') && $cgi->param('otaker') =~ /^([\w\.\-]+)$/ ) {
$twhere .= " AND Users.name = '$1' ";
}
if ( $cgi->param('svcnum') =~ /^\s*(\d+)\s*$/ ) {
$twhere .= " AND EXISTS( SELECT 1 FROM acct_rt_transaction WHERE acct_rt_transaction.transaction_id = Transactions.id AND svcnum = $1 )";
$support = "AND svcnum = $1";
}
my $transactions = "FROM Transactions $join $twhere";
my $where = "WHERE EXISTS ( SELECT 1 $transactions )";
my $transaction_time = "( SELECT SUM($transactiontime) $transactions )";
my $support_time = "( SELECT SUM(support) FROM acct_rt_transaction LEFT JOIN Transactions ON ( transaction_id = Id ) $twhere $support )";
my $query = {
'select' => join(', ',
'Tickets.Id AS ticketid',
'Tickets.Subject',
"$transaction_time AS transaction_time",
"$support_time AS support",
),
'table' => 'tickets', #Pg-ism
#'table' => 'Tickets',
'addl_from' => '', #$join,
'extra_sql' => $where,
'order by' => 'ORDER BY Created',
};
my $count_query =
#"SELECT COUNT(*), SUM($transactiontime), SUM(acct_rt_transaction.support) FROM Transactions $join $where";
#"SELECT COUNT(*), ( SUM($transactiontime) $transactions ) FROM Tickets"; # $join $where";
"SELECT COUNT(*),
SUM( $transaction_time ),
SUM( $support_time )
FROM Tickets $where"; # $join $where";
my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->get('ticketid'); } ];
</%init>
--- NEW FILE: report_rt_ticket.html ---
<% include('/elements/header.html', 'Time worked summary report criteria' ) %>
<FORM ACTION="rt_ticket.html" METHOD="GET">
<TABLE>
<% include ( '/elements/tr-input-beginning_ending.html' ) %>
<% include ( '/elements/tr-select-otaker.html' ) %>
<TR>
<TD>Account</TD>
<TD>
<SELECT NAME="svcnum">
<OPTION VALUE="">(all)
% foreach my $svc_acct (@svc_acct) {
<OPTION VALUE="<% $svc_acct->svcnum %>"><% $svc_acct->username %></OPTION>
% }
</SELECT>
</TD>
</TR>
</TABLE>
<BR>
<INPUT TYPE="submit" VALUE="Search">
</FORM>
<% include('/elements/footer.html') %>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
my $conf = new FS::Conf;
my @pkgparts = $conf->config('support_packages');
my @svc_acct = ();
if ( @pkgparts ) {
@svc_acct = qsearch({
'table' => 'svc_acct',
'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
' LEFT JOIN cust_pkg USING ( pkgnum ) ',
'extra_sql' => 'WHERE pkgpart IN ('. join(',', @pkgparts). ')',
'order_by' => 'ORDER BY username',
});
}
</%init>
Index: report_rt_transaction.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/report_rt_transaction.html,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -u -w -d -r1.3 -r1.3.4.1
--- report_rt_transaction.html 15 Jun 2010 06:06:54 -0000 1.3
+++ report_rt_transaction.html 20 Nov 2010 23:00:44 -0000 1.3.4.1
@@ -50,6 +50,7 @@
'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
' LEFT JOIN cust_pkg USING ( pkgnum ) ',
'extra_sql' => 'WHERE pkgpart IN ('. join(',', @pkgparts). ')',
+ 'order_by' => 'ORDER BY username',
});
}
Index: rt_transaction.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/rt_transaction.html,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -w -d -r1.8 -r1.8.2.1
--- rt_transaction.html 29 Sep 2010 19:54:55 -0000 1.8
+++ rt_transaction.html 20 Nov 2010 23:00:44 -0000 1.8.2.1
@@ -3,7 +3,7 @@
'name_singular' => 'transaction',
'query' => $query,
'count_query' => $count_query,
- 'count_addl' => [ $format_seconds_sub ],#$format_seconds_sub, ],
+ 'count_addl' => [ $format_seconds_sub, $format_seconds_sub, ],
'header' => [ 'Ticket #',
'Ticket',
'Date',
@@ -70,6 +70,8 @@
#AND transaction_time != 0
#AND $wheretimeleft
+my $support = '';
+
my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
# TIMESTAMP is Pg-specific... ?
if ( $beginning > 0 ) {
@@ -86,13 +88,16 @@
}
if ( $cgi->param('ticketid') =~ /^\s*(\d+)\s*$/ ) {
- $where .= " AND Tickets.ID = $1";
+ $where .= " AND Tickets.Id = $1";
}
if ( $cgi->param('svcnum') =~ /^\s*(\d+)\s*$/ ) {
$where .= " AND EXISTS( SELECT 1 FROM acct_rt_transaction WHERE acct_rt_transaction.transaction_id = Transactions.id AND svcnum = $1 )";
+ $support = "AND svcnum = $1";
}
+my $support_time = "( SELECT SUM(support) from acct_rt_transaction where transaction_id = Transactions.id $support )";
+
my $query = {
'select' => join(', ',
'Transactions.*',
@@ -100,7 +105,7 @@
'Tickets.Subject',
'Users.name AS otaker',
"$transactiontime AS transaction_time",
- '( SELECT SUM(support) from acct_rt_transaction where transaction_id = Transactions.id ) AS support',
+ "$support_time AS support",
),
'table' => 'transactions', #Pg-ism
#'table' => 'Transactions',
@@ -111,7 +116,10 @@
my $count_query =
#"SELECT COUNT(*), SUM($transactiontime), SUM(acct_rt_transaction.support) FROM Transactions $join $where";
- "SELECT COUNT(*), SUM($transactiontime) FROM Transactions $join $where";
+ "SELECT COUNT(*),
+ SUM($transactiontime),
+ SUM($support_time)
+ FROM Transactions $join $where";
my $link = [ "${p}rt/Ticket/Display.html?id=", sub { shift->get('ticketid'); } ];
More information about the freeside-commits
mailing list