X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fcust_main%2Fpackages.html;h=383c2a75e93d05827d1887a32e18b11e26474697;hb=a363a49c213f1e64add5c34a8a2bd17d154adfd3;hp=c5a0706d65b42418e9c8cd7520e39788b97c50ba;hpb=c21b6e69583bec632de7fcd340c29982c868f73d;p=freeside.git
diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html
index c5a0706d6..383c2a75e 100755
--- a/httemplate/view/cust_main/packages.html
+++ b/httemplate/view/cust_main/packages.html
@@ -1,350 +1,184 @@
-<%
- my( $cust_main ) = @_;
- my $conf = new FS::Conf;
-
- my $packages = get_packages($cust_main, $conf);
-%>
-
-Packages
-( Bulk order and cancel packages (preserves services) )
-
-<% if ( @$packages ) { %>
-
-
-
- Package |
- Status |
- Services |
-
-
-<%
-foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) {
- my $rowspan = 0;
-
- if ($pkg->{cancel}) {
- $rowspan = 0;
- } else {
- foreach my $svcpart (@{$pkg->{svcparts}}) {
- $rowspan += $svcpart->{count};
- $rowspan++ if ($svcpart->{count} < $svcpart->{quantity});
- }
- }
-%>
-
-
-
- >
- <%=$pkg->{pkgnum}%>:
- <%=$pkg->{pkg}%> - <%=$pkg->{comment}%>
-<% unless ($pkg->{cancel}) { %>
- ( <%=pkg_change_link($pkg)%> )
- ( <%=pkg_dates_link($pkg)%> | <%=pkg_customize_link($pkg,$cust_main->custnum)%> )
-<% } %>
- |
-<%
- #foreach (qw(setup last_bill next_bill susp expire cancel)) {
- # print qq! ! . pkg_datestr($pkg,$_,$conf) . qq! | \n!;
- #}
- print "". &itable('');
-
- sub myfreq {
- my $part_pkg = shift;
- my $freq = $part_pkg->freq_pretty;
- $freq =~ s/ / /g;
- $freq;
- }
-
- if ( $pkg->{cancel} ) { #status: cancelled
-
- print ' |
Cancelled | '.
- ''. pkg_datestr($pkg,'cancel',$conf). ' |
';
- unless ( $pkg->{setup} ) {
- print 'Never billed |
';
- } else {
- print "Setup | ".
- pkg_datestr($pkg, 'setup',$conf). ' |
';
- print "Last bill | ".
- pkg_datestr($pkg, 'last_bill',$conf). ' |
'
- if $pkg->{'last_bill'};
- print "Suspended | ".
- pkg_datestr($pkg, 'susp',$conf). ' |
'
- if $pkg->{'susp'};
- }
-
- } else {
-
- if ( $pkg->{susp} ) { #status: suspended
- print 'Suspended | '.
- ''. pkg_datestr($pkg,'susp',$conf). ' |
';
- unless ( $pkg->{setup} ) {
- print 'Never billed |
';
- } else {
- print "Setup | ".
- pkg_datestr($pkg, 'setup',$conf). ' |
';
- }
- print "Last bill | ".
- pkg_datestr($pkg, 'last_bill',$conf). ' |
'
- if $pkg->{'last_bill'};
- # next bill ??
- print "Expires | ".
- pkg_datestr($pkg, 'expire',$conf). ' |
'
- if $pkg->{'expire'};
- print '( '. pkg_unsuspend_link($pkg).
- ' | '. pkg_cancel_link($pkg). ' ) |
';
-
- } else { #status: active
-
- unless ( $pkg->{setup} ) { #not setup
-
- print 'Not yet billed (';
- unless ( $pkg->{freq} ) {
- print 'one-time charge) |
';
- print '( '. pkg_cancel_link($pkg).
- ' ) | ';
- } else {
- print 'billed '. myfreq($pkg->{part_pkg}). ')
';
- }
-
- } else { #setup
-
- unless ( $pkg->{freq} ) {
- print "One-time charge |
".
- 'Billed | '.
- pkg_datestr($pkg,'setup',$conf). ' |
';
- } else {
- print 'Active'.
- ', billed '. myfreq($pkg->{part_pkg}). ' |
'.
- 'Setup | '.
- pkg_datestr($pkg, 'setup',$conf). ' |
';
- }
-
- }
-
- print "Last bill | ".
- pkg_datestr($pkg, 'last_bill',$conf). ' |
'
- if $pkg->{'last_bill'};
- print "Next bill | ".
- pkg_datestr($pkg, 'next_bill',$conf). ' |
'
- if $pkg->{'next_bill'};
- print "Expires | ".
- pkg_datestr($pkg, 'expire',$conf). ' |
'
- if $pkg->{'expire'};
- if ( $pkg->{freq} ) {
- print '( '. pkg_suspend_link($pkg).
- ' | '. pkg_cancel_link($pkg). ' ) |
';
- }
-
- }
-
- }
-
- print "
\n";
-
- if ($rowspan == 0) { print qq!\n!; next; }
-
- my $cnt = 0;
- foreach my $svcpart (sort {$a->{svcpart} <=> $b->{svcpart}} @{$pkg->{svcparts}}) {
- foreach my $service (@{$svcpart->{services}}) {
- print '
+
+
+
+% if ( @$packages ) {
+
+Current packages
+% }
+% if ( $cust_main->num_cancelled_pkgs ) {
+% if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
+% || ( $conf->exists('hidecancelledpackages')
+% && ! $cgi->param('showcancelledpackages')
+% )
+% )
+% {
+% my $prev = $cgi->param('showcancelledpackages');
+% $cgi->param('showcancelledpackages', 1);
+ ( show
+% $cgi->param('showcancelledpackages', $prev);
+% } else {
+% $cgi->param('showcancelledpackages', 0);
+ ( hide
+% $cgi->param('showcancelledpackages', 1);
+% }
+
+ cancelled packages )
+% }
+% if ( $num_old_packages ) {
+% $cgi->param('showoldpackages', 1);
+ ( show old packages )
+% } elsif ( $cgi->param('showoldpackages') ) {
+% $cgi->param('showoldpackages', 0);
+ ( hide old packages )
+% }
+
+ |
+
+ Package reports
+% if ( $curuser->access_right('Qualify service') ) {
+ | View Qualifications
+% }
+
+ Service reports:
+ accounts
+ Usage reports:
+ CDRs
+ |
+
+
+
+
+% if ( $conf->exists('cust_pkg-group_by_location') and $show_location ) {
+<% include('locations.html',
+ 'cust_main' => $cust_main,
+ 'packages' => $packages,
+) %>
+% }
+% else {
+% # in this format, put all packages in one section
+<% include('/elements/table-grid.html') %>
+<% include('packages/section.html',
+ 'packages' => $packages,
+ 'show_location' => $show_location,
+) %>
+ |
+% }
+
+
+
+% if ( $cgi->param('fragment') =~ /^cust_pkg(\d+)$/ ) {
+
+% }
+
+<%init>
+
+my $cust_main = shift;
+my %opt = @_;
+my $conf = new FS::Conf;
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+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';
+
+my $countrydefault = scalar($conf->config('countrydefault')) || 'US';
#subroutines
sub get_packages {
my $cust_main = shift or return undef;
my $conf = shift;
-
- my @packages = ();
-
- foreach my $cust_pkg (
- $conf->exists('hidecancelledpackages')
- ? $cust_main->ncancelled_pkgs
- : $cust_main->all_pkgs
- ) {
-
- my $part_pkg = $cust_pkg->part_pkg;
-
- my %pkg = ();
- #to get back to the original object... should use it in the first place!!
- $pkg{cust_pkg} = $cust_pkg;
- $pkg{part_pkg} = $part_pkg;
-
- $pkg{pkgnum} = $cust_pkg->pkgnum;
- $pkg{pkg} = $part_pkg->pkg;
- $pkg{pkgpart} = $part_pkg->pkgpart;
- $pkg{comment} = $part_pkg->getfield('comment');
- $pkg{freq} = $part_pkg->freq;
- $pkg{setup} = $cust_pkg->getfield('setup');
- $pkg{last_bill} = $cust_pkg->getfield('last_bill');
- $pkg{next_bill} = $cust_pkg->getfield('bill');
- $pkg{susp} = $cust_pkg->getfield('susp');
- $pkg{expire} = $cust_pkg->getfield('expire');
- $pkg{cancel} = $cust_pkg->getfield('cancel');
-
-
- my %svcparts = map {
- $_->svcpart => {
- $_->part_svc->hash,
- 'quantity' => $_->quantity,
- 'count' => $cust_pkg->num_cust_svc($_->svcpart),
- #'services' => [],
- };
- } $part_pkg->pkg_svc;
-
- foreach my $cust_svc ( $cust_pkg->cust_svc ) {
- #warn "svcnum ". $cust_svc->svcnum. " / svcpart ". $cust_svc->svcpart. "\n";
- my $svc = {
- 'svcnum' => $cust_svc->svcnum,
- 'label' => ($cust_svc->label)[1],
- };
-
- #false laziness with above, to catch extraneous services. whole
- #damn thing should be OO...
- my $svcpart = ( $svcparts{$cust_svc->svcpart} ||= {
- $cust_svc->part_svc->hash,
- 'quantity' => 0,
- 'count' => $cust_pkg->num_cust_svc($cust_svc->svcpart),
- #'services' => [],
- } );
-
- push @{$svcpart->{services}}, $svc;
-
- }
-
- $pkg{svcparts} = [ values %svcparts ];
-
- push @packages, \%pkg;
-
+ my $method;
+ if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me
+ || ( $conf->exists('hidecancelledpackages')
+ && ! $cgi->param('showcancelledpackages') )
+ )
+ {
+ $method = 'ncancelled_pkgs';
+ } else {
+ $method = 'all_pkgs';
}
-
- return \@packages;
-}
+ my $cust_pkg_fields =
+ join(', ', map { "cust_pkg.$_ AS $_" } fields('cust_pkg') );
-sub svc_link {
+ my $part_pkg_fields =
+ join(', ', map { "part_pkg.$_ AS part_pkg_$_" } fields('part_pkg') );
- my ($svcpart, $svc) = (shift,shift) or return '';
- return qq!