From 4ab6ff3e1e200e1069bb8ed8bf2fab771a956565 Mon Sep 17 00:00:00 2001 From: Gerhard Jungwirth Date: Thu, 10 Dec 2015 15:56:16 +0100 Subject: [PATCH] MT#16467 only show PBX customers for soundset creation Change-Id: I9cff379aa6b67d666ede7c32acbc6b2af708409a --- lib/NGCP/Panel/Controller/Customer.pm | 7 ++++++ lib/NGCP/Panel/Field/PbxCustomerContract.pm | 28 +++++++++++++++++++++ lib/NGCP/Panel/Form/Sound/AdminSet.pm | 10 -------- lib/NGCP/Panel/Form/Sound/ResellerSet.pm | 6 ++++- 4 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 lib/NGCP/Panel/Field/PbxCustomerContract.pm diff --git a/lib/NGCP/Panel/Controller/Customer.pm b/lib/NGCP/Panel/Controller/Customer.pm index df4a5ba942..d526020305 100644 --- a/lib/NGCP/Panel/Controller/Customer.pm +++ b/lib/NGCP/Panel/Controller/Customer.pm @@ -137,6 +137,13 @@ sub ajax_package_filter :Chained('list_customer') :PathPart('ajax/package') :Arg $c->detach( $c->view("JSON") ); } +sub ajax_pbx_only :Chained('list_customer') :PathPart('ajax_pbx_only') :Args(0) { + my ($self, $c) = @_; + my $res = $c->stash->{contract_select_rs}->search_rs({'product.class' => 'pbxaccount'}); + NGCP::Panel::Utils::Datatables::process($c, $res, $c->stash->{contract_dt_columns}); + $c->detach( $c->view("JSON") ); +} + sub create :Chained('list_customer') :PathPart('create') :Args(0) { my ($self, $c) = @_; diff --git a/lib/NGCP/Panel/Field/PbxCustomerContract.pm b/lib/NGCP/Panel/Field/PbxCustomerContract.pm new file mode 100644 index 0000000000..cf351ca1c3 --- /dev/null +++ b/lib/NGCP/Panel/Field/PbxCustomerContract.pm @@ -0,0 +1,28 @@ +package NGCP::Panel::Field::PbxCustomerContract; +use Moose; +use HTML::FormHandler::Moose; +extends 'HTML::FormHandler::Field::Compound'; + +has_field 'id' => ( + type => '+NGCP::Panel::Field::DataTable', + label => 'Customer', + do_label => 0, + do_wrapper => 0, + required => 1, + template => 'helpers/datatables_field.tt', + ajax_src => '/customer/ajax_pbx_only', + table_titles => ['#', 'Reseller', 'Contact Email', 'External #', 'Status'], + table_fields => ['id', 'contact_reseller_name', 'contact_email', 'external_id', 'status'], +); + +has_field 'create' => ( + type => 'Button', + do_label => 0, + value => 'Create Contract', + element_class => [qw/btn btn-tertiary pull-right/], +); + +no Moose; +1; + +# vim: set tabstop=4 expandtab: diff --git a/lib/NGCP/Panel/Form/Sound/AdminSet.pm b/lib/NGCP/Panel/Form/Sound/AdminSet.pm index 052ca2f234..78e024e097 100644 --- a/lib/NGCP/Panel/Form/Sound/AdminSet.pm +++ b/lib/NGCP/Panel/Form/Sound/AdminSet.pm @@ -13,16 +13,6 @@ has_field 'reseller' => ( }, ); -has_field 'contract' => ( - type => '+NGCP::Panel::Field::CustomerContract', - label => 'Customer', - validate_when_empty => 0, - element_attr => { - rel => ['tooltip'], - title => ['The contract this sound set belongs to. If set, the sound set becomes a customer sound set instead of a system sound set.'], - }, -); - has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], diff --git a/lib/NGCP/Panel/Form/Sound/ResellerSet.pm b/lib/NGCP/Panel/Form/Sound/ResellerSet.pm index 9b3a6685f0..5d956bea8c 100644 --- a/lib/NGCP/Panel/Form/Sound/ResellerSet.pm +++ b/lib/NGCP/Panel/Form/Sound/ResellerSet.pm @@ -12,9 +12,13 @@ sub build_render_list {[qw/submitid fields actions/]} sub build_form_element_class {[qw(form-horizontal)]} has_field 'contract' => ( - type => '+NGCP::Panel::Field::CustomerContract', + type => '+NGCP::Panel::Field::PbxCustomerContract', label => 'Customer', validate_when_empty => 0, + element_attr => { + rel => ['tooltip'], + title => ['The contract this sound set belongs to. If set, the sound set becomes a customer sound set instead of a system sound set.'], + }, ); has_field 'name' => (