diff options
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/cust_bill_pay.pm | 10 | ||||
-rw-r--r-- | FS/FS/cust_pay.pm | 36 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rwxr-xr-x | httemplate/browse/agent_type.cgi | 6 | ||||
-rwxr-xr-x | httemplate/browse/nas.cgi | 1 | ||||
-rwxr-xr-x | httemplate/misc/delete-cust_pay.cgi | 17 | ||||
-rwxr-xr-x | httemplate/view/cust_main.cgi | 25 |
8 files changed, 91 insertions, 14 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index cc91e82..873ee75 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -268,6 +268,13 @@ httemplate/docs/config.html }, { + 'key' => 'deletepayments', + 'section' => 'UI', + 'description' => 'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments.', + 'type' => 'checkbox', + }, + + { 'key' => 'dirhash', 'section' => 'shell', 'description' => 'Optional numeric value to control directory hashing. If positive, hashes directories for the specified number of levels from the front of the username. If negative, hashes directories for the specified number of levels from the end of the username. Some examples: <ul><li>1: user -> <a href="#home">/home</a>/u/user<li>2: user -> <a href="#home">/home</a>/u/s/user<li>-1: user -> <a href="#home">/home</a>/r/user<li>-2: user -> <a href="#home">home</a>/r/e/user</ul>', diff --git a/FS/FS/cust_bill_pay.pm b/FS/FS/cust_bill_pay.pm index 1c838b9..913704b 100644 --- a/FS/FS/cust_bill_pay.pm +++ b/FS/FS/cust_bill_pay.pm @@ -125,12 +125,16 @@ sub insert { =item delete -Currently unimplemented (accounting reasons). +Deletes this payment application, unless the closed flag for the parent payment +(see L<FS::cust_pay>) is set. =cut sub delete { - return "Can't (yet?) delete cust_bill_pay records!"; + my $self = shift; + return "Can't delete application for closed payment" + if $self->cust_pay->closed =~ /^Y/i; + $self->SUPER::delete(@_); } =item replace OLD_RECORD @@ -195,7 +199,7 @@ sub cust_bill { =head1 VERSION -$Id: cust_bill_pay.pm,v 1.11 2002-01-24 16:58:47 ivan Exp $ +$Id: cust_bill_pay.pm,v 1.12 2002-02-07 22:29:34 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 51c7b29..839571a 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -211,14 +211,44 @@ sub upgrade_replace { #1.3.x->1.4.x =item delete -Currently unimplemented (accounting reasons). +Deletes this payment and all associated applications (see L<FS::cust_bill_pay>), +unless the closed flag is set. =cut sub delete { my $self = shift; return "Can't delete closed payment" if $self->closed =~ /^Y/i; - $self->SUPER::delete(@_); + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + foreach my $cust_bill_pay ( $self->cust_bill_pay ) { + my $error = $cust_bill_pay->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + + my $error = $self->SUPER::delete(@_); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + + ''; + } =item replace OLD_RECORD @@ -318,7 +348,7 @@ sub unapplied { =head1 VERSION -$Id: cust_pay.pm,v 1.15 2002-01-29 16:33:15 ivan Exp $ +$Id: cust_pay.pm,v 1.16 2002-02-07 22:29:34 ivan Exp $ =head1 BUGS @@ -34,7 +34,8 @@ aspdocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* cp -pr httemplate aspdocs touch aspdocs -masondocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/* +#masondocs: htmlman httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/* +masondocs: httemplate/* httemplate/*/* httemplate/*/*/* httemplate/*/*/*/* httemplate/*/*/*/*/* rm -rf masondocs cp -pr httemplate masondocs ( cd masondocs; \ diff --git a/httemplate/browse/agent_type.cgi b/httemplate/browse/agent_type.cgi index 8321048..d75c450 100755 --- a/httemplate/browse/agent_type.cgi +++ b/httemplate/browse/agent_type.cgi @@ -1,4 +1,4 @@ -<!-- $Id: agent_type.cgi,v 1.7 2002-01-30 14:18:08 ivan Exp $ --> +<!-- $Id: agent_type.cgi,v 1.8 2002-02-07 22:29:34 ivan Exp $ --> <% print header("Agent Type Listing", menubar( @@ -7,7 +7,7 @@ print header("Agent Type Listing", menubar( " particular agents.<BR><BR>", &table(), <<END; <TR> <TH COLSPAN=2>Agent Type</TH> - <TH COLSPAN="2">Packages</TH> + <TH COLSPAN=2>Packages</TH> </TR> END @@ -47,7 +47,7 @@ END } print <<END; - <TR><TD COLSPAN=2><I><A HREF="${p}edit/agent_type.cgi">Add a new agent type</A></I></TD></TR> + <TR><TD COLSPAN=4><I><A HREF="${p}edit/agent_type.cgi">Add a new agent type</A></I></TD></TR> </TABLE> </BODY> </HTML> diff --git a/httemplate/browse/nas.cgi b/httemplate/browse/nas.cgi index b392dc0..2bac990 100755 --- a/httemplate/browse/nas.cgi +++ b/httemplate/browse/nas.cgi @@ -45,6 +45,7 @@ foreach my $nas ( sort { $a->nasnum <=> $b->nasnum } qsearch( 'nas', {} ) ) { print "</TABLE><BR>"; } +#Time::Duration?? sub pretty_interval { my $interval = shift; my %howlong = ( diff --git a/httemplate/misc/delete-cust_pay.cgi b/httemplate/misc/delete-cust_pay.cgi new file mode 100755 index 0000000..3fb786d --- /dev/null +++ b/httemplate/misc/delete-cust_pay.cgi @@ -0,0 +1,17 @@ +<!-- $Id: delete-cust_pay.cgi,v 1.1 2002-02-07 22:29:35 ivan Exp $ --> +<% + +#untaint paynum +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/ || die "Illegal paynum"; +my $paynum = $1; + +my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum}); +my $custnum = $cust_pay->custnum; + +my $error = $cust_pay->delete; +eidiot($error) if $error; + +print $cgi->redirect($p. "view/cust_main.cgi?". $custnum); + +%> diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index 9595a07..dc4760d 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -1,4 +1,4 @@ -<!-- $Id: cust_main.cgi,v 1.19 2002-01-30 14:18:09 ivan Exp $ --> +<!-- $Id: cust_main.cgi,v 1.20 2002-02-07 22:29:35 ivan Exp $ --> <% my $conf = new FS::Conf; @@ -324,6 +324,16 @@ print "</TR>"; #formatting print "</TABLE>"; +print <<END; +<SCRIPT> +function areyousure(href) { + if (confirm("Are you sure you want to delete this payment?") + == true) + window.location.href = href; +} +</SCRIPT> +END + #formatting print qq!<BR><BR><A NAME="history">Payment History!. qq!</A> ( !. @@ -371,8 +381,11 @@ foreach my $bill (@bills) { 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! (<A HREF="javascript:areyousure('${p}misc/delete-cust_pay.cgi?!. $payment->paynum. qq!')">delete</A>)! + : ''; push @history, - "$date\tPayment, Invoice #$invnum ($payby$payinfo)\t\t$paid\t\t\t$target"; + "$date\tPayment, Invoice #$invnum ($payby$payinfo)$delete\t\t$paid\t\t\t$target"; } my(@cust_credit_bill)= @@ -430,11 +443,15 @@ foreach my $payment (@unapplied_payments) { 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! (<A HREF="javascript:areyousure('${p}misc/delete-cust_pay.cgi?!. $payment->paynum. qq!')">delete</A>)! + : ''; push @history, $payment->_date. "\t". - '<A HREF="'. popurl(2). 'edit/cust_bill_pay.cgi?'. $payment->paynum. '">'. '<b><font size="+1" color="#ff0000">Unapplied payment #' . - $payment->paynum . " ($payby$payinfo)</font></b></A>". + $payment->paynum . " ($payby$payinfo)</font></b> ". + '(<A HREF="'. popurl(2). 'edit/cust_bill_pay.cgi?'. $payment->paynum. '">'. + "apply</A>)$delete". "\t\t" . $payment->unapplied . "\t\t\t$target"; } |