X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fvoid-cust_pay.cgi;h=784bb9a94a4e76b58bcc6b98349678eae0c91ad2;hb=5da68ff1a7c638e30cbafbc9b0749f1e82b333df;hp=7b484e93eb54f48b2cce72d0ae52e66d58330f4f;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c;p=freeside.git diff --git a/httemplate/misc/void-cust_pay.cgi b/httemplate/misc/void-cust_pay.cgi index 7b484e93e..784bb9a94 100755 --- a/httemplate/misc/void-cust_pay.cgi +++ b/httemplate/misc/void-cust_pay.cgi @@ -1,26 +1,78 @@ -%if ( $error ) { -% errorpage($error); +%if ( $success ) { +<& /elements/header-popup.html, mt("Payment voided") &> + + + %} else { -<% $cgi->redirect($p. "view/cust_main.cgi?". $custnum) %> +<& /elements/header-popup.html, mt('Void payment') &> + +<& /elements/error.html &> + +

<% mt('Void this payment?') |h %> + +

+ + + +<& /elements/tr-select-reason.html, + 'field' => 'reasonnum', + 'reason_class' => 'X', + 'cgi' => $cgi +&> +
+ +
+

+ +         +" onClick="parent.cClick();"> + +

+ + + %} <%init> #untaint paynum -my($query) = $cgi->keywords; -$query =~ /^(\d+)$/ || die "Illegal paynum"; -my $paynum = $1; +my $paynum = $cgi->param('paynum'); +if ($paynum) { + $paynum =~ /^(\d+)$/ || die "Illegal paynum"; +} else { + my($query) = $cgi->keywords; + $query =~ /^(\d+)/ || die "Illegal paynum"; + $paynum = $1; +} -my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum}); +my $cust_pay = qsearchs('cust_pay',{'paynum'=>$paynum}) || die "Payment not found"; -my $right = 'Regular void'; +my $right = 'Void payments'; $right = 'Credit card void' if $cust_pay->payby eq 'CARD'; $right = 'Echeck void' if $cust_pay->payby eq 'CHEK'; die "access denied" unless $FS::CurrentUser::CurrentUser->access_right($right); -my $custnum = $cust_pay->custnum; +my $success = 0; +if ($cgi->param('confirm_void_payment')) { + + #untaint reasonnum / create new reason + my ($reasonnum, $error) = $m->comp('process/elements/reason'); + if (!$reasonnum) { + $error = 'Reason required'; + } else { + my $reason = qsearchs('reason', { 'reasonnum' => $reasonnum }) + || die "Reason num $reasonnum not found in database"; + $error = $cust_pay->void($reason) unless $error; + } -my $error = $cust_pay->void; + if ($error) { + $cgi->param('error',$error); + } else { + $success = 1; + } +}