TT#64370 - Fix for topup voucher ajax error

* Ajax request failed when vouchers was
	   not set in ngcp_panel.conf under features
	   because it redirected to denied_page;
	   moved redirect to topup_voucher method
	   in Customer.pm because it doesn't work
	   on ajax requests

	 * Also hide the top up voucher button if
	   voucher option is not set under features
	   in ngcp_panel.conf

Change-Id: I888ac46e9634d75163241cdb4b59b00a2ca08b2f
changes/78/33178/2
Flaviu Mates 6 years ago
parent e862ac8446
commit e8441634b2

@ -1193,6 +1193,9 @@ sub topup_cash :Chained('base_restricted') :PathPart('balance/topupcash') :Args(
sub topup_voucher :Chained('base_restricted') :PathPart('balance/topupvoucher') :Args(0) {
my ($self, $c) = @_;
$c->detach('/denied_page')
unless($c->config->{features}->{voucher});
my $contract = $c->stash->{contract};
my $now = $c->stash->{now};
my $posted = ($c->request->method eq 'POST');

@ -19,9 +19,6 @@ sub auto :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRol
my ($self, $c) = @_;
$c->log->debug(__PACKAGE__ . '::auto');
$c->detach('/denied_page')
unless($c->config->{features}->{voucher});
NGCP::Panel::Utils::Navigation::check_redirect_chain(c => $c);
return 1;
}
@ -29,6 +26,9 @@ sub auto :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRol
sub voucher_list :Chained('/') :PathPart('voucher') :CaptureArgs(0) {
my ( $self, $c ) = @_;
$c->detach('/denied_page')
unless($c->config->{features}->{voucher});
my $voucher_rs = $c->model('DB')->resultset('vouchers'); #->search_rs(undef, {
#'join' => { 'customer' => 'contact'},
#'+select' => [

@ -446,7 +446,7 @@ $(function() {
[% IF (c.user.roles == 'admin' || c.user.roles == 'reseller' ||
c.user.roles == 'ccaradmin' || c.user.roles == 'ccare') && !c.user.read_only -%]
<span>
[% IF c.user.billing_data -%]
[% IF c.user.billing_data && c.config.features.voucher -%]
<a class="btn btn-primary btn-large" href="[% c.uri_for_action("/customer/topup_voucher", [contract.id]) %]"><i class="icon-repeat"></i> [% c.loc('Top-up Voucher') %]</a>
[% END -%]
<a class="btn btn-primary btn-large" href="[% c.uri_for_action("/customer/topup_cash", [contract.id]) %]"><i class="icon-repeat"></i> [% c.loc('Top-up Cash') %]</a>

Loading…
Cancel
Save