|
|
|
|
@ -47,7 +47,7 @@ sub getbyid : Local {
|
|
|
|
|
|
|
|
|
|
if($c->model('Provisioning')->call_prov( $c, 'billing', 'get_voip_account_by_id',
|
|
|
|
|
{ id => $account_id },
|
|
|
|
|
\$c->session->{voip_account}
|
|
|
|
|
undef
|
|
|
|
|
))
|
|
|
|
|
{
|
|
|
|
|
$c->response->redirect("/account/detail?account_id=$account_id");
|
|
|
|
|
@ -75,15 +75,15 @@ sub detail : Local {
|
|
|
|
|
my ( $self, $c ) = @_;
|
|
|
|
|
$c->stash->{template} = 'tt/account_detail.tt';
|
|
|
|
|
|
|
|
|
|
my $voip_account;
|
|
|
|
|
my $account_id = $c->request->params->{account_id} || undef;
|
|
|
|
|
if(defined $account_id) {
|
|
|
|
|
return unless $c->model('Provisioning')->call_prov( $c, 'billing', 'get_voip_account_by_id',
|
|
|
|
|
{ id => $account_id },
|
|
|
|
|
\$c->session->{voip_account}
|
|
|
|
|
\$voip_account
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
delete $c->session->{voip_account};
|
|
|
|
|
$c->session->{voip_account}{customer_id} = $c->request->params->{customer_id} || undef;
|
|
|
|
|
$$voip_account{customer_id} = $c->request->params->{customer_id} || undef;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$c->stash->{edit_account} = $c->request->params->{edit_account};
|
|
|
|
|
@ -92,28 +92,28 @@ sub detail : Local {
|
|
|
|
|
if(defined $account_id) {
|
|
|
|
|
return unless $c->model('Provisioning')->call_prov( $c, 'billing', 'get_voip_account_balance',
|
|
|
|
|
{ id => $account_id },
|
|
|
|
|
\$c->session->{voip_account}{balance}
|
|
|
|
|
\$$voip_account{balance}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$c->session->{voip_account}{balance}{cash_balance} = 0
|
|
|
|
|
unless defined $c->session->{voip_account}{balance}{cash_balance};
|
|
|
|
|
$c->session->{voip_account}{balance}{cash_balance_interval} = 0
|
|
|
|
|
unless defined $c->session->{voip_account}{balance}{cash_balance_interval};
|
|
|
|
|
$c->session->{voip_account}{balance}{free_time_balance} = 0
|
|
|
|
|
unless defined $c->session->{voip_account}{balance}{free_time_balance};
|
|
|
|
|
$c->session->{voip_account}{balance}{free_time_balance_interval} = 0
|
|
|
|
|
unless defined $c->session->{voip_account}{balance}{free_time_balance_interval};
|
|
|
|
|
|
|
|
|
|
$c->session->{voip_account}{balance}{cash_balance} =
|
|
|
|
|
sprintf "%.2f", $c->session->{voip_account}{balance}{cash_balance} / 100;
|
|
|
|
|
$c->session->{voip_account}{balance}{cash_balance_interval} =
|
|
|
|
|
sprintf "%.2f", $c->session->{voip_account}{balance}{cash_balance_interval} / 100;
|
|
|
|
|
$$voip_account{balance}{cash_balance} = 0
|
|
|
|
|
unless defined $$voip_account{balance}{cash_balance};
|
|
|
|
|
$$voip_account{balance}{cash_balance_interval} = 0
|
|
|
|
|
unless defined $$voip_account{balance}{cash_balance_interval};
|
|
|
|
|
$$voip_account{balance}{free_time_balance} = 0
|
|
|
|
|
unless defined $$voip_account{balance}{free_time_balance};
|
|
|
|
|
$$voip_account{balance}{free_time_balance_interval} = 0
|
|
|
|
|
unless defined $$voip_account{balance}{free_time_balance_interval};
|
|
|
|
|
|
|
|
|
|
$$voip_account{balance}{cash_balance} =
|
|
|
|
|
sprintf "%.2f", $$voip_account{balance}{cash_balance} / 100;
|
|
|
|
|
$$voip_account{balance}{cash_balance_interval} =
|
|
|
|
|
sprintf "%.2f", $$voip_account{balance}{cash_balance_interval} / 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ref $c->session->{restore_account_input} eq 'HASH') {
|
|
|
|
|
$c->session->{voip_account}{product} = $c->session->{restore_account_input}{product};
|
|
|
|
|
$c->session->{voip_account}{billing_profile} = $c->session->{restore_account_input}{billing_profile};
|
|
|
|
|
$c->session->{voip_account}{customer_id} = $c->session->{restore_account_input}{customer_id};
|
|
|
|
|
$$voip_account{product} = $c->session->{restore_account_input}{product};
|
|
|
|
|
$$voip_account{billing_profile} = $c->session->{restore_account_input}{billing_profile};
|
|
|
|
|
$$voip_account{customer_id} = $c->session->{restore_account_input}{customer_id};
|
|
|
|
|
delete $c->session->{restore_account_input};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -147,34 +147,34 @@ sub detail : Local {
|
|
|
|
|
eval { @$billing_profiles }
|
|
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
if(defined $c->session->{voip_account}{product}) {
|
|
|
|
|
if(defined $$voip_account{product}) {
|
|
|
|
|
my $product;
|
|
|
|
|
return unless $c->model('Provisioning')->call_prov( $c, 'billing', 'get_product',
|
|
|
|
|
{ handle => $c->session->{voip_account}{product} },
|
|
|
|
|
{ handle => $$voip_account{product} },
|
|
|
|
|
\$product
|
|
|
|
|
);
|
|
|
|
|
$c->session->{voip_account}{product_name} = $$product{data}{name};
|
|
|
|
|
$$voip_account{product_name} = $$product{data}{name};
|
|
|
|
|
}
|
|
|
|
|
if(defined $c->session->{voip_account}{billing_profile}) {
|
|
|
|
|
if(defined $$voip_account{billing_profile}) {
|
|
|
|
|
my $profile;
|
|
|
|
|
return unless $c->model('Provisioning')->call_prov( $c, 'billing', 'get_billing_profile',
|
|
|
|
|
{ handle => $c->session->{voip_account}{billing_profile} },
|
|
|
|
|
{ handle => $$voip_account{billing_profile} },
|
|
|
|
|
\$profile
|
|
|
|
|
);
|
|
|
|
|
$c->session->{voip_account}{billing_profile_name} = $$profile{data}{name};
|
|
|
|
|
$$voip_account{billing_profile_name} = $$profile{data}{name};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$c->stash->{billing_features} = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete $c->session->{voip_account}{subscribers}
|
|
|
|
|
if exists $c->session->{voip_account}{subscribers}
|
|
|
|
|
and !defined $c->session->{voip_account}{subscribers}
|
|
|
|
|
or ref $c->session->{voip_account}{subscribers} ne 'ARRAY'
|
|
|
|
|
or $#{$c->session->{voip_account}{subscribers}} == -1;
|
|
|
|
|
delete $$voip_account{subscribers}
|
|
|
|
|
if exists $$voip_account{subscribers}
|
|
|
|
|
and !defined $$voip_account{subscribers}
|
|
|
|
|
or ref $$voip_account{subscribers} ne 'ARRAY'
|
|
|
|
|
or $#{$$voip_account{subscribers}} == -1;
|
|
|
|
|
|
|
|
|
|
foreach my $vas (eval { @{$c->session->{voip_account}{subscribers}} }) {
|
|
|
|
|
foreach my $vas (eval { @{$$voip_account{subscribers}} }) {
|
|
|
|
|
my $regcon;
|
|
|
|
|
return unless $c->model('Provisioning')->call_prov( $c, 'voip', 'get_registered_contacts',
|
|
|
|
|
{ username => $$vas{username},
|
|
|
|
|
@ -185,8 +185,8 @@ sub detail : Local {
|
|
|
|
|
$$vas{registered_contacts} = join ", ", map { $$_{user_agent} } @$regcon if eval { @$regcon };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$c->stash->{account} = $c->session->{voip_account};
|
|
|
|
|
$c->stash->{account}{is_locked} = 1 if $c->session->{voip_account}{status} eq 'locked';
|
|
|
|
|
$c->stash->{account} = $voip_account;
|
|
|
|
|
$c->stash->{account}{is_locked} = 1 if $$voip_account{status} eq 'locked';
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|