X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fview%2Fcust_main.cgi;h=ee5f86973b6c871ec4a9a350aebbdcd512c51efb;hp=d392f8a39cd8edcacf8b516f649240cb88cbb20d;hb=01ef1d6aa064759bac796f04d999dfdf2ae3f484;hpb=d60478318bc9c3d94703d1845c0b40504c51a8cb diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index d392f8a39..ee5f86973 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -19,9 +19,8 @@ print < .package TH { font-size: medium } .package TR { font-size: smaller } -.package .datehdr TH { font-size: smaller } .package .pkgnum { font-size: medium } -.package .provision { font-size: larger; color: red; font-weight: bold } +.package .provision { font-weight: bold } END @@ -77,7 +76,7 @@ print ''; print "Billing address", &ntable("#cccccc"), "", &ntable("#cccccc",2), - 'Contact name', + 'Contact name', '', $cust_main->last, ', ', $cust_main->first, ''; @@ -106,8 +105,8 @@ print '', $cust_main->country, '', ; - my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; - my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; + my $daytime_label = FS::Msgcat::_gettext('daytime') || 'Day Phone'; + my $night_label = FS::Msgcat::_gettext('night') || 'Night Phone'; print ''. $daytime_label. '', $cust_main->daytime || ' ', '', @@ -167,7 +166,7 @@ print ''; print ''; print &ntable("#cccccc"), "", &ntable("#cccccc",2), - 'Customer number', + 'Customer number', $custnum, '', ; @@ -185,13 +184,13 @@ print ''; my $referral = qsearchs('part_referral', { 'refnum' => $cust_main->refnum } ); - print 'Advertising source', + print 'Advertising source', $referral->refnum, ": ", $referral->referral, ''; } print 'Order taker', $cust_main->otaker, ''; - print 'Referring Customer'; + print 'Referring Customer'; my $referring_cust_main = ''; if ( $cust_main->referral_custnum && ( $referring_cust_main = @@ -221,22 +220,22 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { print "Billing information (", qq!!, "Bill now)", &ntable("#cccccc"), "", &ntable("#cccccc",2), - 'Tax exempt', + 'Tax exempt', $cust_main->tax ? 'yes' : 'no', '', - 'Postal invoices', + 'Postal invoices', ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no', '', - 'Email invoices', + 'Email invoices', join(', ', grep { $_ ne 'POST' } @invoicing_list ) || 'no', '', - 'Billing type', + 'Billing type', ; if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { my $payinfo = $cust_main->payinfo; $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4)); - print 'Credit card ', + print 'Credit card ', ( $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' ), '', 'Card number', @@ -248,7 +247,7 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { ; } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') { my( $account, $aba ) = split('@', $cust_main->payinfo ); - print 'Electronic check', + print 'Electronic check ', ( $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' ), '', 'Account number', @@ -261,7 +260,7 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { } elsif ( $cust_main->payby eq 'LECB' ) { $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/; my $payinfo = "$1-$2-$3"; - print 'Phone bill billing', + print 'Phone bill billing', 'Phone number', $payinfo, '', ; @@ -277,7 +276,7 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { ; } elsif ( $cust_main->payby eq 'COMP' ) { print 'Complimentary', - 'Authorized by', + 'Authorized by', $cust_main->payinfo, '', 'Expiration', $cust_main->paydate, '', @@ -291,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). @@ -371,23 +370,15 @@ print qq!
Packages !, #get package info -my $packages = get_packages($cust_main); +my $packages = get_packages($cust_main, $conf); if ( @$packages ) { %> - - - - - - - - - - - + + + <% foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { @@ -410,15 +401,122 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { <%=$pkg->{pkg}%> - <%=$pkg->{comment}%> ( <%=pkg_details_link($pkg)%> )
<% unless ($pkg->{cancel}) { %> ( <%=pkg_change_link($pkg)%> ) - ( <%=($pkg->{susp}) ? pkg_unsuspend_link($pkg) : pkg_suspend_link($pkg)%> | <%=pkg_cancel_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! \n!; + #foreach (qw(setup last_bill next_bill susp expire cancel)) { + # print qq! \n!; + #} + print "'. + ''; + unless ( $pkg->{setup} ) { + print ''; + } else { + print "'; + print "' + if $pkg->{'last_bill'}; + print "' + if $pkg->{'susp'}; + } + + } else { + + if ( $pkg->{susp} ) { #status: suspended + print ''. + ''; + unless ( $pkg->{setup} ) { + print ''; + } else { + print "'; + } + print "' + if $pkg->{'last_bill'}; + # next bill ?? + print "' + if $pkg->{'expire'}; + print ''; + + } else { #status: active + + unless ( $pkg->{setup} ) { #not setup + + print ''; + print ''; + } + + } else { #setup + + unless ( $pkg->{freq} ) { + print "". + ''; + } else { + print ''. + ''; + } + + } + + print "' + if $pkg->{'last_bill'}; + print "' + if $pkg->{'next_bill'}; + print "' + if $pkg->{'expire'}; + if ( $pkg->{freq} ) { + print ''; + } + + } + + } + + print "
PackageDatesServices
SetupLast billNext billSusp.ExpireCancelPackageStatusServices
! . pkg_datestr($pkg,$_) . qq!! . pkg_datestr($pkg,$_,$conf) . qq!". &itable(''); + + sub freq { + + #false laziness w/edit/part_pkg.cgi + my %freq = ( #move this + '1d' => 'daily', + '1w' => 'weekly', + '2w' => 'biweekly (every 2 weeks)', + '1' => 'monthly', + '2' => 'bimonthly (every 2 months)', + '3' => 'quarterly (every 3 months)', + '6' => 'semiannually (every 6 months)', + '12' => 'annually', + '24' => 'biannually (every 2 years)', + ); + + my $freq = shift; + exists $freq{$freq} ? $freq{$freq} : "every $freq months"; } + #eomove + + if ( $pkg->{cancel} ) { #status: cancelled + + print '
Cancelled '. pkg_datestr($pkg,'cancel',$conf). '
Never billed
Setup ". + pkg_datestr($pkg, 'setup',$conf). '
Last bill ". + pkg_datestr($pkg, 'last_bill',$conf). '
Suspended ". + pkg_datestr($pkg, 'susp',$conf). '
Suspended '. pkg_datestr($pkg,'susp',$conf). '
Never billed
Setup ". + pkg_datestr($pkg, 'setup',$conf). '
Last bill ". + pkg_datestr($pkg, 'last_bill',$conf). '
Expires ". + pkg_datestr($pkg, 'expire',$conf). '
( '. pkg_unsuspend_link($pkg). + ' | '. pkg_cancel_link($pkg). ' )
Not yet billed ('; + unless ( $pkg->{freq} ) { + print 'one-time charge)
( '. pkg_cancel_link($pkg). + ' )'; + } else { + print 'billed '. freq($pkg->{freq}). ')
One-time charge
Billed '. + pkg_datestr($pkg,'setup',$conf). '
Active'. + ', billed '. freq($pkg->{freq}). '
Setup '. + pkg_datestr($pkg, 'setup',$conf). '
Last bill ". + pkg_datestr($pkg, 'last_bill',$conf). '
Next bill ". + pkg_datestr($pkg, 'next_bill',$conf). '
Expires ". + pkg_datestr($pkg, 'expire',$conf). '
( '. pkg_suspend_link($pkg). + ' | '. pkg_cancel_link($pkg). ' )
\n"; + if ($rowspan == 0) { print qq!\n!; next; } my $cnt = 0; @@ -456,6 +554,11 @@ function cust_pay_unapply_areyousure(href) { == true) window.location.href = href; } +function cust_credit_areyousure(href) { + if (confirm("Are you sure you want to delete this credit?") + == true) + window.location.href = href; +} END @@ -530,9 +633,13 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { $cust_credit->reason, time2str("%D", $cust_credit_bill->_date), ); + my $delete = + $cust_credit->closed !~ /^Y/i && $conf->exists('deletecredits') + ? qq! (delete)! + : ''; push @history, "$date\tCredit #$crednum: $reason
". - "(applied to invoice #$invnum on $app_date)\t\t\t$amount\t"; + "(applied to invoice #$invnum on $app_date)$delete\t\t\t$amount\t"; } } @@ -561,12 +668,16 @@ if ( $conf->config('payby-default') ne 'HIDE' ) { qsearch('cust_credit',{'custnum'=>$custnum}); foreach my $credit (@credits) { my($cref)=$credit->hashref; + my $delete = + $credit->closed !~ /^Y/i && $conf->exists('deletecredits') + ? qq! (delete)! + : ''; push @history, $cref->{_date} . "\t" . qq!!. 'Unapplied credit #' . $cref->{crednum} . ": ". - $cref->{reason} . "\t\t\t" . $credit->credited . "\t"; + $cref->{reason} . "$delete\t\t\t" . $credit->credited . "\t"; } my(@refunds)=qsearch('cust_refund',{'custnum'=> $custnum } ); @@ -672,51 +783,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{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; @@ -724,37 +863,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 { @@ -776,10 +916,13 @@ sub pkgsort_pkgnum_cancel { } sub pkg_datestr { - my ($pkg,$field) = (shift,shift) or return ''; - return $pkg->{$field} ? time2str('%D
%l:%M:%S%P %z', - $pkg->{$field}) - : ' '; + my($pkg, $field, $conf) = @_ or return ''; + return ' ' unless $pkg->{$field}; + my $format = $conf->exists('pkg_showtimes') + ? '%D %l:%M:%S%P %z' + : '%b %o, %Y'; + ( my $strip = time2str($format, $pkg->{$field}) ) =~ s/ (\d)/$1/g; + $strip; } sub pkg_details_link { @@ -814,6 +957,7 @@ sub pkg_dates_link { sub pkg_customize_link { my $pkg = shift or return ''; + my $custnum = shift; return qq!Customize!; }