'type' => 'checkbox',
},
+ {
+ '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',
=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
=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
=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
=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
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; \
-<!-- $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(
" 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
}
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>
print "</TABLE><BR>";
}
+#Time::Duration??
sub pretty_interval {
my $interval = shift;
my %howlong = (
--- /dev/null
+<!-- $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);
+
+%>
-<!-- $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;
#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> ( !.
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)=
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";
}