From ba6b03c35894ebe16900fc3099aec319152fac4b Mon Sep 17 00:00:00 2001 From: jeff Date: Fri, 28 Dec 2007 18:58:22 +0000 Subject: [PATCH] advanced account reports (RT#2954) --- httemplate/elements/menu.html | 6 +++ httemplate/search/report_svc_acct.html | 91 ++++++++++++++++++++++++++++++++++ httemplate/search/svc_acct.cgi | 44 +++++++++++++++- 3 files changed, 139 insertions(+), 2 deletions(-) create mode 100755 httemplate/search/report_svc_acct.html diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index d813a82b4..84787321a 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -105,6 +105,7 @@ foreach my $svcdb ( FS::part_svc->svc_tables() ) { my $name = "FS::$svcdb"->table_info->{'name_plural'} || PL( "FS::$svcdb"->table_info->{'name'} ); my $lcname = lc($name); + my $lcsname = lc("FS::$svcdb"->table_info->{'name'}); my $longname = "FS::$svcdb"->table_info->{'longname_plural'} || $name; my $lclongname = lc($longname); my $sorts = "FS::$svcdb"->table_info->{'sorts'} || [ 'svcnum' ]; @@ -142,6 +143,11 @@ foreach my $svcdb ( FS::part_svc->svc_tables() ) { ]; } + if ( $svcdb eq 'svc_acct' ) { + $report_svc{"Advanced $lcsname reports"} = + [ $fsurl."search/report_$svcdb.html", '' ]; + } + $report_services{$name} = [ \%report_svc, $longname ]; } diff --git a/httemplate/search/report_svc_acct.html b/httemplate/search/report_svc_acct.html new file mode 100755 index 000000000..f5a0ff903 --- /dev/null +++ b/httemplate/search/report_svc_acct.html @@ -0,0 +1,91 @@ +<% include('/elements/header.html', 'Account Report' ) %> + +
+ + + + + + + + <% include( '/elements/tr-select-agent.html', + ($cgi->param('agentnum') || ''), + ) + %> + + +% foreach my $field (qw( last_login last_logout )) { +% my $invert = $field."_invert"; + + + + + + +% } + + <% include( '/elements/tr-selectmultiple-part_pkg.html' ) %> + + + + + <% include( '/elements/tr-select-cust-fields.html' ) %> + +
Search options
+ + + + + +
"> + <% $label{$field} %> + + + Invert +
+
+ + <% include( '/elements/tr-input-beginning_ending.html', + prefix => $field, + layout => 'horiz', + ) + %> +
+
Display options
+ +
+ + +
+ +<% include('/elements/footer.html') %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('List packages'); + + +<%once> + +my %label = ( + 'last_login' => 'Last login', + 'last_logout' => 'Last logout', +); + + diff --git a/httemplate/search/svc_acct.cgi b/httemplate/search/svc_acct.cgi index 62b276748..a7826e122 100755 --- a/httemplate/search/svc_acct.cgi +++ b/httemplate/search/svc_acct.cgi @@ -9,7 +9,9 @@ 'Account', 'UID', 'Last Login', - FS::UI::Web::cust_header(), + FS::UI::Web::cust_header( + $cgi->param('cust_fields') + ), ], 'fields' => [ 'svcnum', 'svc', @@ -24,7 +26,9 @@ $link, $link, ( map { $_ ne 'Cust. Status' ? $link_cust : '' } - FS::UI::Web::cust_header() + FS::UI::Web::cust_header( + $cgi->param('cust_fields') + ) ), ], 'align' => 'rlllr'. FS::UI::Web::cust_aligns(), @@ -90,6 +94,42 @@ if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) { $orderby = "ORDER BY $sortby"; } +} elsif ( $cgi->param('magic') =~ /^advanced$/ ) { + $orderby = ""; + + if ( $cgi->param('agentnum') =~ /^(\d+)$/ and $1 ) { + push @extra_sql, "agentnum = $1"; + } + + my $pkgpart = join (' OR cust_pkg.pkgpart=', + grep {$_} map { /^(\d+)$/; } ($cgi->param('pkgpart'))); + push @extra_sql, '(cust_pkg.pkgpart=' . $pkgpart . ')' if $pkgpart; + + foreach my $field (qw( last_login last_logout )) { + + my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field); + + next if $beginning == 0 && $ending == 4294967295; + + if ($cgi->param($field."_invert")) { + push @extra_sql, + "(svc_acct.$field IS NULL OR ". + "svc_acct.$field < $beginning AND ". + "svc_acct.$field > $ending)"; + } else { + push @extra_sql, + "svc_acct.$field IS NOT NULL", + "svc_acct.$field >= $beginning", + "svc_acct.$field <= $ending"; + } + + $orderby ||= "ORDER BY svc_acct.$field" . + ($cgi->param($field."_invert") ? ' DESC' : ''); + + } + + $orderby ||= "ORDER BY svcnum"; + } elsif ( $cgi->param('popnum') =~ /^(\d+)$/ ) { push @extra_sql, "popnum = $1"; $orderby = "ORDER BY LOWER(username)"; -- 2.11.0