2 <& /elements/header-popup.html, mt("Payment voided") &>
3 <SCRIPT TYPE="text/javascript">
4 window.top.location.reload();
9 <& /elements/header-popup.html, mt('Void payment') &>
11 <& /elements/error.html &>
13 <P ALIGN="center"><B><% mt('Void this payment?') |h %></B>
15 <FORM action="<% ${p} %>misc/void-cust_pay.html">
16 <INPUT TYPE="hidden" NAME="paynum" VALUE="<% $paynum %>">
18 <TABLE BGCOLOR="#cccccc" BORDER="0" CELLSPACING="2" STYLE="margin-left:auto; margin-right:auto">
19 <& /elements/tr-select-reason.html,
20 'field' => 'reasonnum',
21 'reason_class' => 'P',
28 <INPUT TYPE="submit" NAME="confirm_void_payment" VALUE="<% mt('Void payment') |h %>">
29
30 <INPUT TYPE="BUTTON" VALUE="<% mt("Don't void payment") |h %>" onClick="parent.cClick();">
40 my $paynum = $cgi->param('paynum');
42 $paynum =~ /^(\d+)$/ || die "Illegal paynum";
44 my($query) = $cgi->keywords;
45 $query =~ /^(\d+)/ || die "Illegal paynum";
49 my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum}) || die "Payment not found";
51 my $right = 'Void payments';
52 $right = 'Credit card void' if $cust_pay->payby eq 'CARD';
53 $right = 'Echeck void' if $cust_pay->payby eq 'CHEK';
56 unless $FS::CurrentUser::CurrentUser->access_right($right);
59 if ($cgi->param('confirm_void_payment')) {
61 #untaint reasonnum / create new reason
62 my ($reasonnum, $error) = $m->comp('process/elements/reason');
64 $error = 'Reason required';
66 my $reason = qsearchs('reason', { 'reasonnum' => $reasonnum })
67 || die "Reason num $reasonnum not found in database";
68 $error = $cust_pay->void($reason) unless $error;
72 $cgi->param('error',$error);