X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fview%2Fcust_main.cgi;h=fb3f0f11129d01a192fa04c9fd58d929ccae3e61;hp=e820143aac9df2cf3d9b261769e2eb816d7951d4;hb=c0e55cc3cd861b082b1318829cdd0780fe8b934c;hpb=75500e2f75a32b3735999eaf5edde3e871911226 diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index e820143aa..fb3f0f111 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -20,7 +20,7 @@ print < END @@ -290,7 +290,7 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { print ''; if ( defined $cust_main->dbdef_table->column('comments') - && $cust_main->comments ) + && $cust_main->comments =~ /[^\s\n\r]/ ) { print "
Comments". &ntable("#cccccc"). "". &ntable("#cccccc",2). @@ -370,7 +370,7 @@ print qq!
Packages !, #get package info -my $packages = get_packages($cust_main); +my $packages = get_packages($cust_main, $conf); if ( @$packages ) { %> @@ -401,27 +401,27 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { <%=$pkg->{pkg}%> - <%=$pkg->{comment}%> ( <%=pkg_details_link($pkg)%> )
<% unless ($pkg->{cancel}) { %> ( <%=pkg_change_link($pkg)%> ) - ( <%=pkg_dates_link($pkg)%> | <%=pkg_customize_link($pkg)%> ) + ( <%=pkg_dates_link($pkg)%> | <%=pkg_customize_link($pkg,$custnum)%> ) <% } %> <% #foreach (qw(setup last_bill next_bill susp expire cancel)) { - # print qq! ! . pkg_datestr($pkg,$_) . qq!\n!; + # print qq! ! . pkg_datestr($pkg,$_,$conf) . qq!\n!; #} print "". &itable(''); - #move - my %freq = ( - 1 => 'monthly', - 2 => 'bi-monthly', - 3 => 'quarterly', - 6 => 'semi-annually', - 12 => 'annually', - 24 => 'bi-annually', - 36 => 'tri-annually', - ); - sub freq { + + my %freq = ( #move this + 1 => 'monthly', + 2 => 'bi-monthly', + 3 => 'quarterly', + 6 => 'semi-annually', + 12 => 'annually', + 24 => 'bi-annually', + 36 => 'tri-annually', + ); + my $freq = shift; exists $freq{$freq} ? $freq{$freq} : "every $freq months"; } @@ -430,38 +430,38 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { if ( $pkg->{cancel} ) { #status: cancelled - print 'Cancelled '. - pkg_datestr($pkg,'cancel'). ''; + print 'Cancelled '. + ''. pkg_datestr($pkg,'cancel',$conf). ''; unless ( $pkg->{setup} ) { print 'Never billed'; } else { print "Setup ". - pkg_datestr($pkg, 'setup'). ''; + pkg_datestr($pkg, 'setup',$conf). ''; print "Last bill ". - pkg_datestr($pkg, 'last_bill'). '' + pkg_datestr($pkg, 'last_bill',$conf). '' if $pkg->{'last_bill'}; print "Suspended ". - pkg_datestr($pkg, 'susp'). '' + pkg_datestr($pkg, 'susp',$conf). '' if $pkg->{'susp'}; } } else { if ( $pkg->{susp} ) { #status: suspended - print 'Suspended '. - pkg_datestr($pkg,'susp'). ''; + print 'Suspended '. + ''. pkg_datestr($pkg,'susp',$conf). ''; unless ( $pkg->{setup} ) { print 'Never billed'; } else { print "Setup ". - pkg_datestr($pkg, 'setup'). ''; + pkg_datestr($pkg, 'setup',$conf). ''; } print "Last bill ". - pkg_datestr($pkg, 'last_bill'). '' + pkg_datestr($pkg, 'last_bill',$conf). '' if $pkg->{'last_bill'}; # next bill ?? print "Expires ". - pkg_datestr($pkg, 'expire'). '' + pkg_datestr($pkg, 'expire',$conf). '' if $pkg->{'expire'}; print '( '. pkg_unsuspend_link($pkg). ' | '. pkg_cancel_link($pkg). ' )'; @@ -484,24 +484,24 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { unless ( $pkg->{freq} ) { print "One-time charge". 'Billed '. - pkg_datestr($pkg,'setup'). ''; + pkg_datestr($pkg,'setup',$conf). ''; } else { - print 'Active, '. - 'billed '. freq($pkg->{freq}). ''. + print 'Active'. + ', billed '. freq($pkg->{freq}). ''. 'Setup '. - pkg_datestr($pkg, 'setup'). ''; + pkg_datestr($pkg, 'setup',$conf). ''; } } print "Last bill ". - pkg_datestr($pkg, 'last_bill'). '' + pkg_datestr($pkg, 'last_bill',$conf). '' if $pkg->{'last_bill'}; print "Next bill ". - pkg_datestr($pkg, 'next_bill'). '' + pkg_datestr($pkg, 'next_bill',$conf). '' if $pkg->{'next_bill'}; print "Expires ". - pkg_datestr($pkg, 'expire'). '' + pkg_datestr($pkg, 'expire',$conf). '' if $pkg->{'expire'}; if ( $pkg->{freq} ) { print '( '. pkg_suspend_link($pkg). @@ -767,52 +767,79 @@ sub keyfield_numerically { (split(/\t/,$a))[0] <=> (split(/\t/,$b))[0]; } 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 = (); + $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 = (); -my $cust_main = shift or return undef; - -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 = (); - $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'); - - $pkg{svcparts} = []; - - foreach my $pkg_svc (qsearch('pkg_svc', { 'pkgpart' => $part_pkg->pkgpart })) { - - next if ($pkg_svc->quantity == 0); - - my $part_svc = qsearchs('part_svc', { 'svcpart' => $pkg_svc->svcpart }); - - my $svcpart = {}; - $svcpart->{svcpart} = $part_svc->svcpart; - $svcpart->{svc} = $part_svc->svc; - $svcpart->{svcdb} = $part_svc->svcdb; - $svcpart->{quantity} = $pkg_svc->quantity; - $svcpart->{count} = 0; + foreach my $pkg_svc ( + qsearch('pkg_svc', { 'pkgpart' => $part_pkg->pkgpart }) + ) { + + next if ($pkg_svc->quantity == 0); + + my $part_svc = qsearchs('part_svc', { 'svcpart' => $pkg_svc->svcpart }); + + my $svcpart = {}; + $svcpart->{svcpart} = $part_svc->svcpart; + $svcpart->{svc} = $part_svc->svc; + $svcpart->{svcdb} = $part_svc->svcdb; + $svcpart->{quantity} = $pkg_svc->quantity; + $svcpart->{count} = 0; + + $svcpart->{services} = []; - $svcpart->{services} = []; + $svcparts{$svcpart->{svcpart}} = $svcpart; - foreach my $cust_svc (qsearch('cust_svc', { 'pkgnum' => $cust_pkg->pkgnum, - 'svcpart' => $part_svc->svcpart } )) { + } - my $svc = {}; - $svc->{svcnum} = $cust_svc->svcnum; - $svc->{label} = ($cust_svc->label)[1]; + foreach my $cust_svc ( + qsearch( 'cust_svc', { + 'pkgnum' => $cust_pkg->pkgnum, + #'svcpart' => $part_svc->svcpart, + } + ) + ) { + + 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} ||= { + 'svcpart' => $cust_svc->svcpart, + 'svc' => $cust_svc->part_svc->svc, + 'svcdb' => $cust_svc->part_svc->svcdb, + 'quantity' => 0, + 'count' => 0, + 'services' => [], + } ); push @{$svcpart->{services}}, $svc; @@ -820,37 +847,38 @@ foreach my $cust_pkg (($conf->exists('hidecancelledpackages') ? ($cust_main->nca } - push @{$pkg{svcparts}}, $svcpart; + $pkg{svcparts} = [ values %svcparts ]; + push @packages, \%pkg; + } - - push @packages, \%pkg; - -} - -return \@packages; + + return \@packages; } sub svc_link { - my ($svcpart, $svc) = (shift,shift) or return ''; - return qq!$svcpart->{svc}!; + my ($svcpart, $svc) = (shift,shift) or return ''; + return qq!$svcpart->{svc}!; } sub svc_label_link { - my ($svcpart, $svc) = (shift,shift) or return ''; - return qq!$svc->{label}!; + my ($svcpart, $svc) = (shift,shift) or return ''; + return qq!$svc->{label}!; } sub svc_provision_link { my ($pkg, $svcpart) = (shift,shift) or return ''; - return qq!! . - qq!Provision $svcpart->{svc} (! . ($svcpart->{quantity} - $svcpart->{count}) . qq!)!; + "Provision $svc_nbsp (". + ($svcpart->{quantity} - $svcpart->{count}). + ')'; } sub svc_unprovision_link { @@ -872,7 +900,7 @@ sub pkgsort_pkgnum_cancel { } sub pkg_datestr { - my($pkg, $field) = @_ or return ''; + my($pkg, $field, $conf) = @_ or return ''; return ' ' unless $pkg->{$field}; my $format = $conf->exists('pkg_showtimes') ? '%D %l:%M:%S%P %z' @@ -913,6 +941,7 @@ sub pkg_dates_link { sub pkg_customize_link { my $pkg = shift or return ''; + my $custnum = shift; return qq!Customize!; }