[freeside-commits] freeside/httemplate/view/cust_main packages.html, 1.49, 1.50
Ivan,,,
ivan at wavetail.420.am
Sun Mar 29 16:44:14 PDT 2009
Update of /home/cvs/cvsroot/freeside/httemplate/view/cust_main
In directory wavetail.420.am:/tmp/cvs-serv4447/httemplate/view/cust_main
Modified Files:
packages.html
Log Message:
hide over 2 (or configured) cancelled and one-time charge packages, RT#5083
Index: packages.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/view/cust_main/packages.html,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- packages.html 29 Mar 2009 09:38:29 -0000 1.49
+++ packages.html 29 Mar 2009 23:44:12 -0000 1.50
@@ -53,6 +53,13 @@
cancelled packages</a> )
% }
+% if ( $num_old_packages ) {
+% $cgi->param('showoldpackages', 1);
+ ( <a href="<% $cgi->self_url %>">show old packages</a> )
+% } elsif ( $cgi->param('showoldpackages') ) {
+% $cgi->param('showoldpackages', 0);
+ ( <a href="<% $cgi->self_url %>">hide old packages</a> )
+% }
% if ( @$packages ) {
<% include('/elements/table-grid.html') %>
@@ -119,7 +126,7 @@
my $curuser = $FS::CurrentUser::CurrentUser;
-my $packages = get_packages($cust_main, $conf);
+my( $packages, $num_old_packages ) = get_packages($cust_main, $conf);
my $show_location = $conf->exists('cust_pkg-always_show_location')
|| ( grep $_->locationnum, @$packages ); # ? '1' : '0';
@@ -146,8 +153,7 @@
sub get_packages {
my $cust_main = shift or return undef;
my $conf = shift;
-
- my @packages = ();
+
my $method;
if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
|| ( $conf->exists('hidecancelledpackages')
@@ -159,7 +165,26 @@
$method = 'all_pkgs';
}
- [ $cust_main->$method() ];
+ my @packages = $cust_main->$method();
+ my $num_old_packages = scalar(@packages);
+
+ unless ( $cgi->param('showoldpackages') ) {
+ my $years = $conf->config('cust_main-packages-years') || 2;
+ my $seconds = 31556926; #60*60*24*365.2422 is close enough
+ my $then = time - $seconds;
+
+ my %hide = ( 'cancelled' => 'cancel',
+ 'one-time charge' => 'setup',
+ );
+
+ @packages =
+ grep { !exists($hide{$_->status}) or $_->get($hide{$_->status}) > $then }
+ @packages;
+ }
+
+ $num_old_packages -= scalar(@packages);
+
+ ( \@packages, $num_old_packages );
}
</%init>
More information about the freeside-commits
mailing list