', $cust_main->comments,
+ print " Comments". &ntable("#cccccc"). "".
+ &ntable("#cccccc",2).
+ ' | '.
+ encode_entities($cust_main->comments).
' | ';
}
@@ -255,30 +297,56 @@ print ' '.
qq!!.
' ';
-print ' '.
- qq! !;
+if ( $conf->config('payby-default') ne 'HIDE' ) {
+
+ print ' '.
+ qq! !;
+
+}
print <
function cust_pkg_areyousure(href) {
- if (confirm("Permanantly delete included services and cancel this package?") == true)
+ if (confirm("Permanently delete included services and cancel this package?") == true)
+ window.location.href = href;
+}
+function svc_areyousure(href) {
+ if (confirm("Permanently unprovision and delete this service?") == true)
window.location.href = href;
}
@@ -291,17 +359,6 @@ print qq! Packages !,
#display packages
-#formatting
-print qq!!, &table(), "\n",
- qq!Package | !,
- qq!Dates | Services | \n!,
- qq!Setup | !,
- qq!Next bill!,
- qq! | Susp. | Expire!,
- qq! | !,
- qq!Cancel | !,
- qq! \n!;
-
#get package info
my @packages;
if ( $conf->exists('hidecancelledpackages') ) {
@@ -310,6 +367,26 @@ if ( $conf->exists('hidecancelledpackages') ) {
@packages = sort { $a->pkgnum <=> $b->pkgnum } ($cust_main->all_pkgs);
}
+if ( @packages ) {
+ #formatting
+
+ my $colspan = $packages[0]->dbdef_table->column('last_bill') ? 6 : 5;
+
+ print &table(), "\n",
+ qq!Package | !,
+ qq!Dates | Services | \n!,
+ qq!Setup | !;
+
+ print qq!Last bill | !
+ if $packages[0]->dbdef_table->column('last_bill');
+
+ print qq!Next bill | !,
+ qq!Susp. | !,
+ qq!Expire | !,
+ qq!Cancel | !,
+ qq! \n!;
+}
+
my $n1 = '';
foreach my $package (@packages) {
my $pkgnum = $package->pkgnum;
@@ -350,6 +427,10 @@ foreach my $package (@packages) {
#false laziness with view/cust_pkg.cgi, but i'm trying to make that go away so
unless ( $package->getfield('cancel') ) {
+
+ print qq! ( !.
+ 'Change package )';
+
print ' ( ';
if ( $package->getfield('susp') ) {
print qq!Unsuspend!;
@@ -369,7 +450,11 @@ foreach my $package (@packages) {
}
print '';
- for ( qw( setup bill susp expire cancel ) ) {
+ my @fields = qw( setup );
+ push @fields, qw( last_bill ) if $package->dbdef_table->column('last_bill');
+ push @fields, qw( bill susp expire cancel);
+
+ for ( @fields ) {
print "", ( $package->getfield($_)
? time2str("%D %l:%M:%S%P %z",
$package->getfield($_) )
@@ -383,6 +468,7 @@ foreach my $package (@packages) {
#foreach my $cust_svc ( @cust_svc ) {
foreach my $svcpart ( sort { $a<=>$b } keys %pkg_svc ) {
my $svc = qsearchs('part_svc',{'svcpart'=>$svcpart})->getfield('svc');
+ $svc =~ s/ / /g;
my(@cust_svc)=qsearch('cust_svc',{'pkgnum'=>$pkgnum,
'svcpart'=>$svcpart,
});
@@ -393,13 +479,13 @@ foreach my $package (@packages) {
my($svcnum) = $cust_svc->svcnum;
my($sview) = popurl(2). "view";
print $n2,qq! | $label | !,
- qq!$value | !;
+ qq!$value ( Unprovision ) | !;
} else {
print $n2, qq!!.
- qq!Provision $svc!;
+ qq!Provision $svc!;
print qq! !.
- qq!Link to legacy $svc!
+ qq!Link to legacy $svc!
if $conf->exists('legacy_link');
print ' | ';
@@ -415,6 +501,7 @@ print " ";
#formatting
print "";
+
print <
function cust_pay_areyousure(href) {
@@ -422,52 +509,145 @@ function cust_pay_areyousure(href) {
== true)
window.location.href = href;
}
+function cust_pay_unapply_areyousure(href) {
+ if (confirm("Are you sure you want to unapply this payment?")
+ == true)
+ window.location.href = href;
+}
END
-#formatting
-print qq!
Payment History!.
- qq! ( !.
- qq!!.
- qq!Post payment | !.
- qq!!.
- qq!Post credit )!;
-
-#get payment history
-#
-# major problem: this whole thing is way too sloppy.
-# minor problem: the description lines need better formatting.
-
-my @history = (); #needed for mod_perl :)
-
-my %target = ();
-
-my @bills = qsearch('cust_bill',{'custnum'=>$custnum});
-foreach my $bill (@bills) {
- my($bref)=$bill->hashref;
- my $bpre = ( $bill->owed > 0 )
- ? ' Open '
- : '';
- my $bpost = ( $bill->owed > 0 ) ? '' : '';
- push @history,
- $bref->{_date} . qq!\t${bpre}Invoice #! . $bref->{invnum} .
- qq! (Balance \$! . $bill->owed . qq!)$bpost\t! .
- $bref->{charged} . qq!\t\t\t!;
-
- my(@cust_bill_pay)=qsearch('cust_bill_pay',{'invnum'=> $bref->{invnum} } );
-# my(@payments)=qsearch('cust_pay',{'invnum'=> $bref->{invnum} } );
-# my($payment);
-# foreach $payment (@payments) {
- foreach my $cust_bill_pay (@cust_bill_pay) {
- my $payment = $cust_bill_pay->cust_pay;
- my($date,$invnum,$payby,$payinfo,$paid)=($payment->_date,
- $cust_bill_pay->invnum,
- $payment->payby,
- $payment->payinfo,
- $cust_bill_pay->amount,
- );
- $payinfo = substr($payinfo,0,4). 'x'x(length($payinfo)-4)
+if ( $conf->config('payby-default') ne 'HIDE' ) {
+
+ #formatting
+ print qq!
Payment History!.
+ qq! ( !.
+ qq!!.
+ qq!Post payment | !.
+ qq!!.
+ qq!Post credit )!;
+
+ #get payment history
+ #
+ # major problem: this whole thing is way too sloppy.
+ # minor problem: the description lines need better formatting.
+
+ my @history = (); #needed for mod_perl :)
+
+ my %target = ();
+
+ my @bills = qsearch('cust_bill',{'custnum'=>$custnum});
+ foreach my $bill (@bills) {
+ my($bref)=$bill->hashref;
+ my $bpre = ( $bill->owed > 0 )
+ ? ' Open '
+ : '';
+ my $bpost = ( $bill->owed > 0 ) ? '' : '';
+ push @history,
+ $bref->{_date} . qq!\t${bpre}Invoice #! . $bref->{invnum} .
+ qq! (Balance \$! . $bill->owed . qq!)$bpost\t! .
+ $bref->{charged} . qq!\t\t\t!;
+
+ my(@cust_bill_pay)=qsearch('cust_bill_pay',{'invnum'=> $bref->{invnum} } );
+ # my(@payments)=qsearch('cust_pay',{'invnum'=> $bref->{invnum} } );
+ # my($payment);
+ foreach my $cust_bill_pay (@cust_bill_pay) {
+ my $payment = $cust_bill_pay->cust_pay;
+ my($date,$invnum,$payby,$payinfo,$paid)=($payment->_date,
+ $cust_bill_pay->invnum,
+ $payment->payby,
+ $payment->payinfo,
+ $cust_bill_pay->amount,
+ );
+ $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4))
+ if $payby eq 'CARD';
+ my $target = "$payby$payinfo";
+ $payby =~ s/^BILL$/Check #/ if $payinfo;
+ $payby =~ s/^(CARD|COMP)$/$1 /;
+ my $delete = $payment->closed !~ /^Y/i && $conf->exists('deletepayments')
+ ? qq! (delete)!
+ : '';
+ my $unapply =
+ $payment->closed !~ /^Y/i && $conf->exists('unapplypayments')
+ ? qq! (unapply)!
+ : '';
+ push @history,
+ "$date\tPayment, Invoice #$invnum ($payby$payinfo)$delete$unapply\t\t$paid\t\t\t$target";
+ }
+
+ my(@cust_credit_bill)=
+ qsearch('cust_credit_bill', { 'invnum'=> $bref->{invnum} } );
+ foreach my $cust_credit_bill (@cust_credit_bill) {
+ my $cust_credit = $cust_credit_bill->cust_credit;
+ my($date, $invnum, $crednum, $amount, $reason, $app_date ) = (
+ $cust_credit->_date,
+ $cust_credit_bill->invnum,
+ $cust_credit_bill->crednum,
+ $cust_credit_bill->amount,
+ $cust_credit->reason,
+ time2str("%D", $cust_credit_bill->_date),
+ );
+ push @history,
+ "$date\tCredit #$crednum: $reason ".
+ "(applied to invoice #$invnum on $app_date)\t\t\t$amount\t";
+ }
+ }
+
+ my @credits = grep { scalar(my @array = $_->cust_credit_refund) }
+ qsearch('cust_credit',{'custnum'=>$custnum});
+ foreach my $credit (@credits) {
+ my($cref)=$credit->hashref;
+ my(@cust_credit_refund)=
+ qsearch('cust_credit_refund', { 'crednum'=> $cref->{crednum} } );
+ foreach my $cust_credit_refund (@cust_credit_refund) {
+ my $cust_refund = $cust_credit_refund->cust_credit;
+ my($date, $crednum, $amount, $reason, $app_date ) = (
+ $credit->_date,
+ $credit->crednum,
+ $cust_credit_refund->amount,
+ $credit->reason,
+ time2str("%D", $cust_credit_refund->_date),
+ );
+ push @history,
+ "$date\tCredit #$crednum: $reason ".
+ "(applied to refund on $app_date)\t\t\t$amount\t";
+ }
+ }
+
+ @credits = grep { $_->credited > 0 }
+ qsearch('cust_credit',{'custnum'=>$custnum});
+ foreach my $credit (@credits) {
+ my($cref)=$credit->hashref;
+ push @history,
+ $cref->{_date} . "\t" .
+ qq!!.
+ 'Unapplied credit #' .
+ $cref->{crednum} . ": ".
+ $cref->{reason} . "\t\t\t" . $credit->credited . "\t";
+ }
+
+ my(@refunds)=qsearch('cust_refund',{'custnum'=> $custnum } );
+ foreach my $refund (@refunds) {
+ my($rref)=$refund->hashref;
+ my($refundnum) = (
+ $refund->refundnum,
+ );
+
+ push @history,
+ $rref->{_date} . "\tRefund #$refundnum, (" .
+ $rref->{payby} . " " . $rref->{payinfo} . ") by " .
+ $rref->{otaker} . " - ". $rref->{reason} . "\t\t\t\t" .
+ $rref->{refund};
+ }
+
+ my @unapplied_payments =
+ grep { $_->unapplied > 0 } qsearch('cust_pay', { 'custnum' => $custnum } );
+ foreach my $payment (@unapplied_payments) {
+ my $payby = $payment->payby;
+ my $payinfo = $payment->payinfo;
+ #false laziness w/above
+ $payinfo = 'x'x(length($payinfo)-4). substr($payinfo,(length($payinfo)-4))
if $payby eq 'CARD';
my $target = "$payby$payinfo";
$payby =~ s/^BILL$/Check #/ if $payinfo;
@@ -476,161 +656,72 @@ foreach my $bill (@bills) {
? qq! (delete)!
: '';
push @history,
- "$date\tPayment, Invoice #$invnum ($payby$payinfo)$delete\t\t$paid\t\t\t$target";
+ $payment->_date. "\t".
+ 'Unapplied payment #' .
+ $payment->paynum . " ($payby$payinfo) ".
+ '('.
+ "apply)$delete".
+ "\t\t" . $payment->unapplied . "\t\t\t$target";
}
-
- my(@cust_credit_bill)=
- qsearch('cust_credit_bill', { 'invnum'=> $bref->{invnum} } );
- foreach my $cust_credit_bill (@cust_credit_bill) {
- my $cust_credit = $cust_credit_bill->cust_credit;
- my($date, $invnum, $crednum, $amount, $reason, $app_date ) = (
- $cust_credit->_date,
- $cust_credit_bill->invnum,
- $cust_credit_bill->crednum,
- $cust_credit_bill->amount,
- $cust_credit->reason,
- time2str("%D", $cust_credit_bill->_date),
- );
- push @history,
- "$date\tCredit #$crednum: $reason ".
- "(applied to invoice #$invnum on $app_date)\t\t\t$amount\t";
- }
-}
-
-my @credits = grep { scalar(my @array = $_->cust_credit_refund) }
- qsearch('cust_credit',{'custnum'=>$custnum});
-foreach my $credit (@credits) {
- my($cref)=$credit->hashref;
- my(@cust_credit_refund)=
- qsearch('cust_credit_refund', { 'crednum'=> $cref->{crednum} } );
- foreach my $cust_credit_refund (@cust_credit_refund) {
- my $cust_refund = $cust_credit_refund->cust_credit;
- my($date, $crednum, $amount, $reason, $app_date ) = (
- $credit->_date,
- $credit->crednum,
- $cust_credit_refund->amount,
- $credit->reason,
- time2str("%D", $cust_credit_refund->_date),
- );
- push @history,
- "$date\tCredit #$crednum: $reason ".
- "(applied to refund on $app_date)\t\t\t$amount\t";
- }
-}
-
-@credits = grep { $_->credited > 0 }
- qsearch('cust_credit',{'custnum'=>$custnum});
-foreach my $credit (@credits) {
- my($cref)=$credit->hashref;
- push @history,
- $cref->{_date} . "\t" .
- qq!!.
- 'Unapplied credit #' .
- $cref->{crednum} . ": ".
- $cref->{reason} . "\t\t\t" . $credit->credited . "\t";
-}
-
-my(@refunds)=qsearch('cust_refund',{'custnum'=> $custnum } );
-foreach my $refund (@refunds) {
- my($rref)=$refund->hashref;
- my($refundnum) = (
- $refund->refundnum,
- );
-
- push @history,
- $rref->{_date} . "\tRefund #$refundnum, (" .
- $rref->{payby} . " " . $rref->{payinfo} . ") by " .
- $rref->{otaker} . " - ". $rref->{reason} . "\t\t\t\t" .
- $rref->{refund};
-}
-
-my @unapplied_payments =
- grep { $_->unapplied > 0 } qsearch('cust_pay', { 'custnum' => $custnum } );
-foreach my $payment (@unapplied_payments) {
- my $payby = $payment->payby;
- my $payinfo = $payment->payinfo;
- #false laziness w/above
- $payinfo = substr($payinfo,0,4). 'x'x(length($payinfo)-4)
- if $payby eq 'CARD';
- my $target = "$payby$payinfo";
- $payby =~ s/^BILL$/Check #/ if $payinfo;
- $payby =~ s/^(CARD|COMP)$/$1 /;
- my $delete = $payment->closed !~ /^Y/i && $conf->exists('deletepayments')
- ? qq! (delete)!
- : '';
- push @history,
- $payment->_date. "\t".
- 'Unapplied payment #' .
- $payment->paynum . " ($payby$payinfo) ".
- '('.
- "apply)$delete".
- "\t\t" . $payment->unapplied . "\t\t\t$target";
-}
-
- #formatting
- print &table(), <
- Date |
- Description |
- Charge |
- Payment |
- In-house Credit |
- Refund |
- Balance |
- |
+
+ #formatting
+ print &table(), <