From 251d07aa41b6830a0a2f2a51c14fa94586d843c2 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Mon, 16 Feb 2015 13:53:20 -0600 Subject: RT#27710: Credit voiding --- httemplate/misc/unvoid-cust_credit_void.cgi | 21 ++++++++ httemplate/misc/void-cust_credit.html | 74 +++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100755 httemplate/misc/unvoid-cust_credit_void.cgi create mode 100755 httemplate/misc/void-cust_credit.html (limited to 'httemplate/misc') diff --git a/httemplate/misc/unvoid-cust_credit_void.cgi b/httemplate/misc/unvoid-cust_credit_void.cgi new file mode 100755 index 000000000..5f8d9d548 --- /dev/null +++ b/httemplate/misc/unvoid-cust_credit_void.cgi @@ -0,0 +1,21 @@ +%if ( $error ) { +% errorpage($error); +%} else { +<% $cgi->redirect($p. "view/cust_main.cgi?custnum=". $custnum .";show=payment_history") %> +%} +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Unvoid credit'); + +#untaint crednum +my($query) = $cgi->keywords; +$query =~ /^(\d+)$/ || die "Illegal crednum"; +my $crednum = $1; + +my $cust_credit_void = qsearchs('cust_credit_void', { 'crednum' => $crednum } ); +my $custnum = $cust_credit_void->custnum; + +my $error = $cust_credit_void->unvoid; + + diff --git a/httemplate/misc/void-cust_credit.html b/httemplate/misc/void-cust_credit.html new file mode 100755 index 000000000..1e71f0030 --- /dev/null +++ b/httemplate/misc/void-cust_credit.html @@ -0,0 +1,74 @@ +%if ( $success ) { +<& /elements/header-popup.html, mt("Credit voided") &> + + + +%} else { +<& /elements/header-popup.html, mt('Void credit') &> + +<& /elements/error.html &> + +

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

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

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

+ + + +%} +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Void credit'); + +#untaint crednum +my $crednum = $cgi->param('crednum'); +if ($crednum) { + $crednum =~ /^(\d+)$/ || die "Illegal crednum"; +} else { + my($query) = $cgi->keywords; + $query =~ /^(\d+)/ || die "Illegal crednum"; + $crednum = $1; +} + +my $cust_credit = qsearchs('cust_credit',{'crednum'=>$crednum}) || die "Credit not found"; + +my $success = 0; +if ($cgi->param('confirm_void_credit')) { + + #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_credit->void($reason) unless $error; + } + + if ($error) { + $cgi->param('error',$error); + } else { + $success = 1; + } +} + + -- cgit v1.2.1