From: Irina Todeva Date: Thu, 8 Oct 2015 21:45:09 +0000 (-0600) Subject: Changes for being consistent in the payment history GUI on void credit / X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=b5d5f7680d0736ff0150b337cd29026135fb2e34 Changes for being consistent in the payment history GUI on void credit / payment / invoice links renamed httemplate/misc/void-cust_credit.html to .cgi renamed httemplate/misc/void-cust_bill.html to .cgi --- diff --git a/httemplate/elements/tr-select-reason.html b/httemplate/elements/tr-select-reason.html index 125874694..37a34baba 100755 --- a/httemplate/elements/tr-select-reason.html +++ b/httemplate/elements/tr-select-reason.html @@ -199,7 +199,7 @@ if ($class eq 'C') { } elsif ($class eq 'F') { $add_access_right = 'Add on-the-fly refund reason'; } elsif ($class eq 'X') { - $add_access_right = 'Add on-the-fly void credit reason'; + $add_access_right = 'Add on-the-fly void reason'; } else { die "illegal class: $class"; } diff --git a/httemplate/misc/process/void-cust_bill.html b/httemplate/misc/process/void-cust_bill.html index 7773b0ba9..c0f432b70 100755 --- a/httemplate/misc/process/void-cust_bill.html +++ b/httemplate/misc/process/void-cust_bill.html @@ -1,6 +1,6 @@ %if ( $error ) { % $cgi->param('error', $error); -<% $cgi->redirect(popurl(2). "void-cust_bill.html?". $cgi->query_string ) %> +<% $cgi->redirect(popurl(2). "void-cust_bill.cgi?". $cgi->query_string ) %> %} else { <& /elements/header-popup.html, 'Invoice 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; + } +} + + diff --git a/httemplate/misc/void-cust_credit.html b/httemplate/misc/void-cust_credit.html deleted file mode 100755 index 1e71f0030..000000000 --- a/httemplate/misc/void-cust_credit.html +++ /dev/null @@ -1,74 +0,0 @@ -%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; - } -} - - diff --git a/httemplate/misc/void-cust_pay.cgi b/httemplate/misc/void-cust_pay.cgi index 376fb5652..784bb9a94 100755 --- a/httemplate/misc/void-cust_pay.cgi +++ b/httemplate/misc/void-cust_pay.cgi @@ -1,16 +1,52 @@ -%if ( $error ) { -% errorpage($error); +%if ( $success ) { +<& /elements/header-popup.html, mt("Payment voided") &> + + + %} else { -<% $cgi->redirect($p. "view/cust_main.cgi?custnum=". $custnum. ";show=payment_history") %> +<& /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 = 'Void payments'; $right = 'Credit card void' if $cust_pay->payby eq 'CARD'; @@ -19,8 +55,24 @@ $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; + } +} diff --git a/httemplate/view/cust_bill.cgi b/httemplate/view/cust_bill.cgi index 8884ddea4..6d139747a 100755 --- a/httemplate/view/cust_bill.cgi +++ b/httemplate/view/cust_bill.cgi @@ -9,13 +9,30 @@ function areyousure(href, message) { } -% if ( !$cust_bill->closed && $curuser->access_right('Void invoices') ) { +% if ( !$cust_bill->closed ) { # otherwise allow no changes +% my $can_delete = $conf->exists('deleteinvoices') +% && $curuser->access_right('Delete invoices'); +% my $can_void = $curuser->access_right('Void invoices'); +% if ( $can_void ) { <& /elements/popup_link.html, 'label' => emt('Void this invoice'), 'actionlabel' => emt('Void this invoice'), - 'action' => $p.'misc/void-cust_bill.html?invnum='.$invnum, + 'action' => $p.'misc/void-cust_bill.cgi?invnum='.$invnum, &> -

+% } +% if ( $can_void and $can_delete ) { +  |  +% } +% if ( $can_delete ) { + \ + <% emt('Delete this invoice') |h %> +% } +% if ( $can_void or $can_delete ) { +

+% } % } % if ( $cust_bill->owed > 0 diff --git a/httemplate/view/cust_main/payment_history/credit.html b/httemplate/view/cust_main/payment_history/credit.html index db2e5e582..81be1cd7a 100644 --- a/httemplate/view/cust_main/payment_history/credit.html +++ b/httemplate/view/cust_main/payment_history/credit.html @@ -130,7 +130,7 @@ my $void = ''; $void = ' ('. include( '/elements/popup_link.html', 'label' => emt('void'), - 'action' => "${p}misc/void-cust_credit.html?". + 'action' => "${p}misc/void-cust_credit.cgi?". $cust_credit->crednum, 'actionlabel' => emt('Void credit'), ). diff --git a/httemplate/view/cust_main/payment_history/invoice.html b/httemplate/view/cust_main/payment_history/invoice.html index 613936e00..ca59c15fd 100644 --- a/httemplate/view/cust_main/payment_history/invoice.html +++ b/httemplate/view/cust_main/payment_history/invoice.html @@ -27,7 +27,7 @@ if ( $cust_bill->closed !~ /^Y/i && $opt{'Void invoices'} ) { $void = ' ('. include('/elements/popup_link.html', 'label' => emt('void'), - 'action' => "${p}misc/void-cust_bill.html?;invnum=". + 'action' => "${p}misc/void-cust_bill.cgi?;invnum=". $cust_bill->invnum, 'actionlabel' => emt('Void Invoice'), ). diff --git a/httemplate/view/cust_main/payment_history/payment.html b/httemplate/view/cust_main/payment_history/payment.html index d72e34b38..77013140e 100644 --- a/httemplate/view/cust_main/payment_history/payment.html +++ b/httemplate/view/cust_main/payment_history/payment.html @@ -169,8 +169,9 @@ if ( $cust_pay->closed !~ /^Y/i && scalar(@refund_right) ) { my $refundtitle = ($cust_pay->payby =~ /^(CARD|CHEK)$/) - ? emt('Send a refund for this payment to the payment gateway') - : emt('Record a refund for this payment'); + ? emt('Send a refund for this payment to the payment gateway') + : emt('Record a refund for this payment'); + $refund = qq! (payby =~ /^(CARD|CHEK|TOKN)$/ ? ' (' . emt('do not send anything to the payment gateway').')' : ''; -$void = areyousure_link("${p}misc/void-cust_pay.cgi?".$cust_pay->paynum, - emt('Are you sure you want to void this payment?'), - emt('Void this payment from the database') . $voidmsg, - emt('void') - ) +$void = ' ('. + include( '/elements/popup_link.html', + 'label' => emt('void'), + 'action' => "${p}misc/void-cust_pay.cgi?".$cust_pay->paynum, + 'actionlabel' => emt('Void payment'), + ). + ')' if $cust_pay->closed !~ /^Y/i && ( ( $cust_pay->payby eq 'CARD' && $opt{'Credit card void'} ) || ( $cust_pay->payby eq 'CHEK' && $opt{'Echeck void'} )