From 1c4b8285fbfd5dd21e35aec36087c7e5de400830 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Fri, 4 Aug 2017 17:06:10 +0300 Subject: [PATCH] TT#19656 Add lock level fields to the subscriber forms with status Change-Id: Ie041125174257cb62e210c007fa471c113fae70e --- lib/NGCP/Panel/Controller/Customer.pm | 18 ++++++++++++++++++ lib/NGCP/Panel/Controller/Subscriber.pm | 3 ++- .../Panel/Form/Customer/PbxAdminSubscriber.pm | 2 +- .../Form/Customer/PbxExtensionSubscriber.pm | 2 +- .../Customer/PbxExtensionSubscriberSubadmin.pm | 2 +- lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm | 8 +++++++- .../Panel/Form/Customer/PbxSubscriberEdit.pm | 2 +- lib/NGCP/Panel/Form/Customer/Subscriber.pm | 8 +++++++- lib/NGCP/Panel/Form/Subscriber.pm | 9 +++++++-- 9 files changed, 45 insertions(+), 9 deletions(-) diff --git a/lib/NGCP/Panel/Controller/Customer.pm b/lib/NGCP/Panel/Controller/Customer.pm index 623be26c73..895222db63 100644 --- a/lib/NGCP/Panel/Controller/Customer.pm +++ b/lib/NGCP/Panel/Controller/Customer.pm @@ -846,6 +846,11 @@ sub subscriber_create :Chained('base') :PathPart('subscriber/create') :Args(0) { } my @events_to_create = (); my $event_context = { events_to_create => \@events_to_create }; + + if($form->values->{lock} && ( $form->values->{lock} > 0 ) ){ + $form->values->{status} = 'locked'; + } + $billing_subscriber = NGCP::Panel::Utils::Subscriber::create_subscriber( c => $c, schema => $schema, @@ -855,6 +860,19 @@ sub subscriber_create :Chained('base') :PathPart('subscriber/create') :Args(0) { preferences => $preferences, event_context => $event_context, ); + + if($billing_subscriber->status eq 'locked') { + $form->values->{lock} ||= 4; + } else { + $form->values->{lock} = 0; + } + + NGCP::Panel::Utils::Subscriber::lock_provisoning_voip_subscriber( + c => $c, + prov_subscriber => $billing_subscriber->provisioning_voip_subscriber, + level => $form->values->{lock}, + ) if ($billing_subscriber->provisioning_voip_subscriber); + NGCP::Panel::Utils::ProfilePackages::underrun_lock_subscriber(c => $c, subscriber => $billing_subscriber); if($pbx && !$pbxadmin && $form->value->{alias_select}) { diff --git a/lib/NGCP/Panel/Controller/Subscriber.pm b/lib/NGCP/Panel/Controller/Subscriber.pm index a4993aea89..8b8a67d5bf 100644 --- a/lib/NGCP/Panel/Controller/Subscriber.pm +++ b/lib/NGCP/Panel/Controller/Subscriber.pm @@ -2761,8 +2761,9 @@ sub edit_master :Chained('master') :PathPart('edit') :Args(0) :Does(ACL) :ACLDet ); } - $form->values->{lock} ||= 0; NGCP::Panel::Utils::ProfilePackages::get_contract_balance(c => $c, contract => $subscriber->contract); + + $form->values->{lock} ||= 0; NGCP::Panel::Utils::Subscriber::lock_provisoning_voip_subscriber( c => $c, prov_subscriber => $subscriber->provisioning_voip_subscriber, diff --git a/lib/NGCP/Panel/Form/Customer/PbxAdminSubscriber.pm b/lib/NGCP/Panel/Form/Customer/PbxAdminSubscriber.pm index 78247437ea..cb1f45f46f 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxAdminSubscriber.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxAdminSubscriber.pm @@ -40,7 +40,7 @@ has_field 'domain' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/domain e164 e164range e164range_add display_name email webusername webpassword username password administrative status external_id profile_set/ ], + render_list => [qw/domain e164 e164range e164range_add display_name email webusername webpassword username password administrative lock status external_id profile_set/ ], ); 1; diff --git a/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriber.pm b/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriber.pm index 22b30edd30..cb3e81f05f 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriber.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriber.pm @@ -23,7 +23,7 @@ has_field 'pbx_extension' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/domain group_select alias_select pbx_extension display_name email webusername webpassword username password administrative status external_id timezone profile_set profile/ ], + render_list => [qw/domain group_select alias_select pbx_extension display_name email webusername webpassword username password administrative lock status external_id timezone profile_set profile/ ], ); override 'field_list' => sub { diff --git a/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriberSubadmin.pm b/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriberSubadmin.pm index 635fe8f2b1..1b14990754 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriberSubadmin.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriberSubadmin.pm @@ -17,7 +17,7 @@ has_field 'pbx_extension' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/group_select alias_select pbx_extension display_name email webusername webpassword username password status profile/ ], + render_list => [qw/group_select alias_select pbx_extension display_name email webusername webpassword username password lock status profile/ ], ); sub field_list { diff --git a/lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm b/lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm index 99532290d0..65edf930e4 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm @@ -123,6 +123,12 @@ has_field 'administrative' => ( }, ); +has_field 'lock' => ( + type => '+NGCP::Panel::Field::SubscriberLockSelect', + label => 'Lock Level', + validate_when_empty => 1, +); + has_field 'status' => ( type => '+NGCP::Panel::Field::SubscriberStatusSelect', label => 'Status', @@ -180,7 +186,7 @@ has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], #render_list => [qw/display_name webusername webpassword username password status external_id profile_set timezone profile/ ], - render_list => [qw/e164 display_name email webusername webpassword username password administrative status timezone profile_set profile/ ], + render_list => [qw/e164 display_name email webusername webpassword username password administrative lock status timezone profile_set profile/ ], ); has_block 'actions' => ( diff --git a/lib/NGCP/Panel/Form/Customer/PbxSubscriberEdit.pm b/lib/NGCP/Panel/Form/Customer/PbxSubscriberEdit.pm index 25d293fd85..fb64ce360a 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxSubscriberEdit.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxSubscriberEdit.pm @@ -41,7 +41,7 @@ has_field 'email' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/e164 alias_number alias_number_add email webusername webpassword password external_id administrative status timezone profile_set profile/ ], + render_list => [qw/e164 alias_number alias_number_add email webusername webpassword password external_id administrative lock status timezone profile_set profile/ ], ); has_block 'actions' => ( diff --git a/lib/NGCP/Panel/Form/Customer/Subscriber.pm b/lib/NGCP/Panel/Form/Customer/Subscriber.pm index 45691bf6c7..178122c5b3 100644 --- a/lib/NGCP/Panel/Form/Customer/Subscriber.pm +++ b/lib/NGCP/Panel/Form/Customer/Subscriber.pm @@ -77,6 +77,12 @@ has_field 'password' => ( }, ); +has_field 'lock' => ( + type => '+NGCP::Panel::Field::SubscriberLockSelect', + label => 'Lock Level', + validate_when_empty => 1, +); + has_field 'status' => ( type => '+NGCP::Panel::Field::SubscriberStatusSelect', label => 'Status', @@ -134,7 +140,7 @@ has_field 'save' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/domain e164 email webusername webpassword username password status external_id administrative timezone profile_set/ ], + render_list => [qw/domain e164 email webusername webpassword username password lock status external_id administrative timezone profile_set/ ], ); has_block 'actions' => ( diff --git a/lib/NGCP/Panel/Form/Subscriber.pm b/lib/NGCP/Panel/Form/Subscriber.pm index d34c0a08b9..de291fc12a 100644 --- a/lib/NGCP/Panel/Form/Subscriber.pm +++ b/lib/NGCP/Panel/Form/Subscriber.pm @@ -104,6 +104,12 @@ has_field 'password' => ( }, ); +has_field 'lock' => ( + type => '+NGCP::Panel::Field::SubscriberLockSelect', + label => 'Lock Level', + validate_when_empty => 1, +); + has_field 'status' => ( type => '+NGCP::Panel::Field::SubscriberStatusSelect', label => 'Status', @@ -160,11 +166,10 @@ has_field 'save' => ( label => '', ); - has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/contract domain e164 email webusername webpassword username password status external_id administrative timezone profile_set/ ], + render_list => [qw/contract domain e164 email webusername webpassword username password lock status external_id administrative timezone profile_set/ ], ); has_block 'actions' => (