X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fview%2Fcust_main.cgi;h=9aa00896988f46d24652610535b6be0eb19a91cb;hb=6fe8172b11d0369d0b1274d6825ec0c57afe8001;hp=a34ddc429ed83c499416d5636f52bfc5230d61ee;hpb=4ae85517a9c3a8a2f61e87bc27a74eb616e396a4;p=freeside.git diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index a34ddc429..9aa008969 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -300,13 +300,25 @@ if ( defined $cust_main->dbdef_table->column('comments') ''; } -print ''; +%> -print '
'. - '
'. - qq!!. - ' +

'; +
+ +<% if ( $conf->config('payby-default') ne 'HIDE' ) { @@ -397,27 +411,13 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { #} print "". &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"; + sub myfreq { + my $part_pkg = shift; + my $freq = $part_pkg->freq_pretty; + $freq =~ s/ / /g; + $freq; } - #eomove - if ( $pkg->{cancel} ) { #status: cancelled print 'Cancelled '. @@ -466,7 +466,7 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { print '( '. pkg_cancel_link($pkg). ' )'; } else { - print 'billed '. freq($pkg->{freq}). ')'; + print 'billed '. myfreq($pkg->{part_pkg}). ')'; } } else { #setup @@ -477,7 +477,7 @@ foreach my $pkg (sort pkgsort_pkgnum_cancel @$packages) { pkg_datestr($pkg,'setup',$conf). ''; } else { print 'Active'. - ', billed '. freq($pkg->{freq}). ''. + ', billed '. myfreq($pkg->{part_pkg}). ''. 'Setup '. pkg_datestr($pkg, 'setup',$conf). ''; } @@ -570,6 +570,7 @@ print ''; my $target = "$payby$payinfo"; $payby =~ s/^BILL$/Check #/ if $payinfo; + $payby =~ s/^CHEK$/Electronic check /; $payby =~ s/^BILL$//; $payby =~ s/^(CARD|COMP)$/$1 /; my $info = $payby ? " ($payby$payinfo)" : ''; @@ -625,17 +626,17 @@ print ''; my $refund = ''; my $refund_days = $conf->config('card_refund-days') || 120; if ( $cust_pay->closed !~ /^Y/i - && $cust_pay->payby eq 'CARD' + && $cust_pay->payby =~ /^(CARD|CHEK)$/ && time-$cust_pay->_date < $refund_days*86400 && $cust_pay->unrefunded > 0 ) { - $refund = qq! (paynum. qq!">refund)!; } my $void = ''; if ( $cust_pay->closed !~ /^Y/i - && $cust_pay->payby ne 'CARD' + && $cust_pay->payby !~ /^(CARD|CHEK)$/ ) { $void = qq! ( $cust_pay_void->_date, - 'desc' => "Payment $info voided ". + 'desc' => "Payment $info voided ". time2str("%D", $cust_pay_void->void_date). " by ". $cust_pay_void->otaker. '', 'void_payment' => $cust_pay_void->paid, @@ -783,6 +785,7 @@ print ''; : $cust_refund->payinfo; $payby =~ s/^BILL$/Check #/ if $payinfo; + $payby =~ s/^CHEK$/Electronic check /; $payby =~ s/^(CARD|COMP)$/$1 /; push @history, { @@ -883,8 +886,13 @@ sub get_packages { ) { 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; @@ -896,29 +904,16 @@ sub get_packages { $pkg{susp} = $cust_pkg->getfield('susp'); $pkg{expire} = $cust_pkg->getfield('expire'); $pkg{cancel} = $cust_pkg->getfield('cancel'); - - my %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; - - $svcpart->{services} = []; - - $svcparts{$svcpart->{svcpart}} = $svcpart; - - } + 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"; @@ -930,18 +925,14 @@ sub get_packages { #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, + $cust_svc->part_svc->hash, 'quantity' => 0, - 'count' => 0, - 'services' => [], + 'count' => $cust_pkg->num_cust_svc($cust_svc->svcpart), + #'services' => [], } ); push @{$svcpart->{services}}, $svc; - $svcpart->{count}++; - } $pkg{svcparts} = [ values %svcparts ]; @@ -971,11 +962,21 @@ sub svc_label_link { sub svc_provision_link { my ($pkg, $svcpart, $conf) = @_; ( my $svc_nbsp = $svcpart->{svc} ) =~ s/\s+/ /g; - my $pkgnum_svcpart = "pkgnum$pkg->{pkgnum}-svcpart$svcpart->{svcpart}"; my $num_left = $svcpart->{quantity} - $svcpart->{count}; + my $pkgnum_svcpart = "pkgnum$pkg->{pkgnum}-svcpart$svcpart->{svcpart}"; - my $link = qq!!. + my $url; + if ( $svcpart->{svcdb} eq 'svc_external' + && $conf->exists('svc_external-skip_manual') + ) { + $url = "${p}edit/process/$svcpart->{svcdb}.cgi?". + "pkgnum=$pkg->{pkgnum}&". + "svcpart=$svcpart->{svcpart}"; + } else { + $url = "${p}edit/$svcpart->{svcdb}.cgi?$pkgnum_svcpart"; + } + + my $link = qq!!. "Provision $svc_nbsp ($num_left)"; if ( $conf->exists('legacy_link') ) { $link .= '
'.