parent
61eb05dd13
commit
b95daedc79
@ -0,0 +1,88 @@
|
||||
package NGCP::Panel::Field::E164Range;
|
||||
use HTML::FormHandler::Moose;
|
||||
extends 'HTML::FormHandler::Field::Compound';
|
||||
|
||||
|
||||
#has 'label' => ( default => 'E164 Number');
|
||||
|
||||
has_field 'cc' => (
|
||||
type => '+NGCP::Panel::Field::PosInteger',
|
||||
element_attr => {
|
||||
class => ['ngcp_e164_cc'],
|
||||
rel => ['tooltip'],
|
||||
title => ['Country Code, e.g. 1 for US or 43 for Austria']
|
||||
},
|
||||
do_label => 0,
|
||||
do_wrapper => 0,
|
||||
);
|
||||
|
||||
has_field 'ac' => (
|
||||
type => '+NGCP::Panel::Field::PosInteger',
|
||||
element_attr => {
|
||||
class => ['ngcp_e164_ac'],
|
||||
rel => ['tooltip'],
|
||||
title => ['Area Code, e.g. 212 for NYC or 1 for Vienna']
|
||||
},
|
||||
do_label => 0,
|
||||
do_wrapper => 0,
|
||||
);
|
||||
|
||||
has_field 'snbase' => (
|
||||
type => '+NGCP::Panel::Field::PosInteger',
|
||||
element_attr => {
|
||||
class => ['ngcp_e164_snbase'],
|
||||
rel => ['tooltip'],
|
||||
title => ['Subscriber Base, e.g. 12345']
|
||||
},
|
||||
do_label => 0,
|
||||
do_wrapper => 0,
|
||||
);
|
||||
|
||||
has_field 'snlength' => (
|
||||
type => '+NGCP::Panel::Field::PosInteger',
|
||||
element_attr => {
|
||||
class => ['ngcp_e164_snlength'],
|
||||
rel => ['tooltip'],
|
||||
title => ['Subscriber Number Range Length (e.g. 2 for 1-212-12345xx']
|
||||
},
|
||||
do_label => 0,
|
||||
do_wrapper => 0,
|
||||
);
|
||||
|
||||
sub validate {
|
||||
my $self = shift;
|
||||
my $cc = $self->field('cc')->value;
|
||||
my $sn = $self->field('snbase')->value;
|
||||
my $snlen = $self->field('snlength')->value;
|
||||
|
||||
my %sub_errors = map {$_, 1} (
|
||||
@{ $self->field('cc')->errors },
|
||||
@{ $self->field('ac')->errors },
|
||||
@{ $self->field('snbase')->errors },
|
||||
@{ $self->field('snlength')->errors } );
|
||||
for my $sub_error( keys %sub_errors ) {
|
||||
$self->add_error($sub_error);
|
||||
}
|
||||
$self->field('cc')->clear_errors if $self->field('cc');
|
||||
$self->field('ac')->clear_errors if $self->field('ac');
|
||||
$self->field('snbase')->clear_errors if $self->field('snbase');
|
||||
$self->field('snlength')->clear_errors if $self->field('snlength');
|
||||
|
||||
if ($self->has_errors) {
|
||||
#dont add more errors
|
||||
} elsif (defined $cc && $cc ne '' && (!defined $sn || $sn eq '')) {
|
||||
my $err_msg = 'Subscriber Number required if Country Code is set';
|
||||
$self->add_error($err_msg);
|
||||
} elsif(defined $sn && $sn ne '' && (!defined $cc || $cc eq '')) {
|
||||
my $err_msg = 'Country Code required if Subscriber Number is set';
|
||||
$self->add_error($err_msg);
|
||||
}
|
||||
if(defined $sn && $sn ne '' && (!defined $snlen || $snlen eq '')) {
|
||||
my $err_msg = 'Subscriber Number Range Length required if Subscriber Base is set';
|
||||
$self->add_error($err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# vim: set tabstop=4 expandtab:
|
||||
@ -0,0 +1,29 @@
|
||||
package NGCP::Panel::Field::E164RangeRepeat;
|
||||
use HTML::FormHandler::Moose;
|
||||
extends 'HTML::FormHandler::Field::Repeatable';
|
||||
|
||||
has_field 'id' => (
|
||||
type => 'Hidden',
|
||||
);
|
||||
|
||||
has_field 'e164range' => (
|
||||
type => '+NGCP::Panel::Field::E164Range',
|
||||
order => 99,
|
||||
required => 0,
|
||||
label => 'Number Range',
|
||||
do_label => 1,
|
||||
do_wrapper => 1,
|
||||
wrapper_class => [qw/hfh-rep-field/],
|
||||
);
|
||||
|
||||
has_field 'rm' => (
|
||||
type => 'RmElement',
|
||||
value => 'Remove',
|
||||
order => 100,
|
||||
element_class => [qw/btn btn-primary pull-right/],
|
||||
);
|
||||
|
||||
|
||||
1;
|
||||
|
||||
# vim: set tabstop=4 expandtab:
|
||||
@ -1,73 +0,0 @@
|
||||
package NGCP::Panel::Form::Customer::PbxExtensionSubscriberEdit;
|
||||
|
||||
use HTML::FormHandler::Moose;
|
||||
use NGCP::Panel::Field::PosInteger;
|
||||
extends 'NGCP::Panel::Form::Customer::PbxSubscriber';
|
||||
|
||||
has_field 'group' => (
|
||||
type => '+NGCP::Panel::Field::PbxGroup',
|
||||
label => 'Group',
|
||||
validate_when_empty => 1,
|
||||
);
|
||||
|
||||
has_field 'pbx_extension' => (
|
||||
type => '+NGCP::Panel::Field::PosInteger',
|
||||
element_attr => {
|
||||
rel => ['tooltip'],
|
||||
title => ['Extension Number, e.g. 101']
|
||||
},
|
||||
required => 1,
|
||||
label => 'Extension',
|
||||
);
|
||||
|
||||
has_block 'fields' => (
|
||||
tag => 'div',
|
||||
class => [qw/modal-body/],
|
||||
render_list => [qw/group pbx_extension email webusername webpassword password status external_id profile/ ],
|
||||
);
|
||||
|
||||
sub update_fields {
|
||||
my $self = shift;
|
||||
my $c = $self->ctx;
|
||||
my $pkg = __PACKAGE__;
|
||||
$c->log->debug("my form: $pkg");
|
||||
|
||||
my $group = $self->field('group');
|
||||
$group->field('id')->ajax_src(
|
||||
$c->uri_for_action('/customer/pbx_group_ajax', [$c->stash->{customer_id}])->as_string
|
||||
);
|
||||
|
||||
my $profile_set = $c->stash->{subscriber}->provisioning_voip_subscriber->voip_subscriber_profile_set;
|
||||
if($profile_set && $self->field('profile')) {
|
||||
$self->field('profile')->field('id')->ajax_src(
|
||||
$c->uri_for_action('/subscriberprofile/profile_ajax', [$profile_set->id])->as_string
|
||||
);
|
||||
}
|
||||
|
||||
$self->field('password')->required(0); # optional on edit
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
NGCP::Panel::Form::Subscriber
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Form to modify a subscriber.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gerhard Jungwirth
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
This library is free software. You can redistribute it and/or modify
|
||||
it under the same terms as Perl itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set tabstop=4 expandtab:
|
||||
@ -1,82 +0,0 @@
|
||||
package NGCP::Panel::Form::Customer::PbxExtensionSubscriberEditAdmin;
|
||||
|
||||
use HTML::FormHandler::Moose;
|
||||
use NGCP::Panel::Field::PosInteger;
|
||||
extends 'NGCP::Panel::Form::Customer::PbxExtensionSubscriberEdit';
|
||||
|
||||
with 'NGCP::Panel::Render::RepeatableJs';
|
||||
|
||||
has_field 'alias_number' => (
|
||||
type => '+NGCP::Panel::Field::AliasNumber',
|
||||
setup_for_js => 1,
|
||||
do_wrapper => 1,
|
||||
do_label => 0,
|
||||
tags => {
|
||||
controls_div => 1,
|
||||
},
|
||||
wrapper_class => [qw/hfh-rep/],
|
||||
);
|
||||
|
||||
has_field 'alias_number_add' => (
|
||||
type => 'AddElement',
|
||||
repeatable => 'alias_number',
|
||||
value => 'Add another number',
|
||||
element_class => [qw/btn btn-primary pull-right/],
|
||||
);
|
||||
|
||||
has_block 'fields' => (
|
||||
tag => 'div',
|
||||
class => [qw/modal-body/],
|
||||
render_list => [qw/group pbx_extension alias_number alias_number_add email webusername webpassword password status external_id profile_set profile/ ],
|
||||
);
|
||||
|
||||
sub field_list {
|
||||
my ($self) = @_;
|
||||
|
||||
my $c = $self->ctx;
|
||||
return unless($c);
|
||||
|
||||
print "+++++++++++++++++++++++++++++ PbxExtensionSubscriberEditAdmin field_list\n";
|
||||
|
||||
my $profile_set = $self->field('profile_set');
|
||||
if($profile_set) {
|
||||
$profile_set->field('id')->ajax_src(
|
||||
$c->uri_for_action('/subscriberprofile/set_ajax_reseller', [$c->stash->{subscriber}->contract->contact->reseller_id])->as_string
|
||||
);
|
||||
}
|
||||
|
||||
my $set_id = $c->stash->{subscriber}->provisioning_voip_subscriber->profile_set_id;
|
||||
if($set_id) {
|
||||
my $profile = $self->field('profile');
|
||||
if($profile) {
|
||||
$profile->field('id')->ajax_src(
|
||||
$c->uri_for_action('/subscriberprofile/profile_ajax', [$set_id])->as_string
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
NGCP::Panel::Form::Subscriber
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Form to modify a subscriber.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Gerhard Jungwirth
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
This library is free software. You can redistribute it and/or modify
|
||||
it under the same terms as Perl itself.
|
||||
|
||||
=cut
|
||||
|
||||
# vim: set tabstop=4 expandtab:
|
||||
Loading…
Reference in new issue