From 18b86b3ffde642e527187975939d910ba89f63da Mon Sep 17 00:00:00 2001 From: Irka Date: Sun, 27 Jul 2014 01:25:34 +0300 Subject: [PATCH] MT#5879 Remove template active as logic changed to invoice per customer. --- lib/NGCP/Panel/Controller/InvoiceTemplate.pm | 22 ------------------- lib/NGCP/Panel/Controller/Reseller.pm | 1 - lib/NGCP/Panel/Field/InvoiceTemplate.pm | 4 ++-- lib/NGCP/Panel/Form/Invoice/TemplateAdmin.pm | 2 +- .../Panel/Form/Invoice/TemplateReseller.pm | 12 +--------- 5 files changed, 4 insertions(+), 37 deletions(-) diff --git a/lib/NGCP/Panel/Controller/InvoiceTemplate.pm b/lib/NGCP/Panel/Controller/InvoiceTemplate.pm index 7674978994..f3d21327f6 100644 --- a/lib/NGCP/Panel/Controller/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Controller/InvoiceTemplate.pm @@ -33,7 +33,6 @@ sub template_list :Chained('/') :PathPart('invoicetemplate') :CaptureArgs(0) :Do { name => 'reseller.name', search => 1, title => $c->loc('Reseller') }, { name => 'name', search => 1, title => $c->loc('Name') }, { name => 'type', search => 1, title => $c->loc('Type') }, - { name => 'is_active', search => 1, title => $c->loc('Active') }, ]); $c->stash(template => 'invoice/template_list.tt'); @@ -152,15 +151,6 @@ sub create :Chained('template_list') :PathPart('create') :Args() { $tmpl_params->{data} //= NGCP::Panel::Utils::InvoiceTemplate::svg_content($c, $tmpl_params->{data}); my $tmpl = $c->stash->{tmpl_rs}->create($tmpl_params); - # deactivate other templates if this one got active - if($tmpl->is_active) { - $c->model('DB')->resultset('invoice_templates')->search({ - reseller_id => $tmpl->reseller_id, - is_active => 1, - id => { '!=' => $tmpl->id }, - })->update({ is_active => 0 }); - } - delete $c->session->{created_objects}->{reseller}; }); $c->flash(messages => [{type => 'success', text => $c->loc('Invoice template successfully created')}]); @@ -225,20 +215,8 @@ sub edit_info :Chained('base') :PathPart('editinfo') { die( ["Template name should be unique", "showdetails"] ); } - my $old_active = $tmpl->is_active; $tmpl->update($form->params); - # deactivate other templates if this one got active - if($tmpl->is_active && !$old_active) { - $c->model('DB')->resultset('invoice_templates')->search({ - reseller_id => $tmpl->reseller_id, - is_active => 1, - id => { '!=' => $tmpl->id }, - })->update({ is_active => 0 }); - } - # we don't promote another one as active, as we don't know - # for sure which one - delete $c->session->{created_objects}->{reseller}; }); $c->flash(messages => [{type => 'success', text => $c->loc('Invoice template successfully updated')}]); diff --git a/lib/NGCP/Panel/Controller/Reseller.pm b/lib/NGCP/Panel/Controller/Reseller.pm index 64ed11f964..8b33f4fb65 100644 --- a/lib/NGCP/Panel/Controller/Reseller.pm +++ b/lib/NGCP/Panel/Controller/Reseller.pm @@ -158,7 +158,6 @@ sub base :Chained('list_reseller') :PathPart('') :CaptureArgs(1) { { name => 'id', search => 1, title => $c->loc('#') }, { name => 'name', search => 1, title => $c->loc('Name') }, { name => 'type', search => 1, title => $c->loc('Type') }, - { name => 'is_active', search => 1, title => $c->loc('Active') }, ]); diff --git a/lib/NGCP/Panel/Field/InvoiceTemplate.pm b/lib/NGCP/Panel/Field/InvoiceTemplate.pm index 05ffb5140d..d1c47e653e 100644 --- a/lib/NGCP/Panel/Field/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Field/InvoiceTemplate.pm @@ -10,8 +10,8 @@ has_field 'id' => ( required => 1, ajax_src => '/invoicetemplate/ajax', template => 'helpers/datatables_field.tt', - table_titles => ['#', 'Reseller', 'Name', 'Active'], - table_fields => ['id', 'reseller_name', 'name', 'is_active'], + table_titles => ['#', 'Reseller', 'Name'], + table_fields => ['id', 'reseller_name', 'name'], ); 1; diff --git a/lib/NGCP/Panel/Form/Invoice/TemplateAdmin.pm b/lib/NGCP/Panel/Form/Invoice/TemplateAdmin.pm index a0c0ac062b..70307357f8 100644 --- a/lib/NGCP/Panel/Form/Invoice/TemplateAdmin.pm +++ b/lib/NGCP/Panel/Form/Invoice/TemplateAdmin.pm @@ -17,7 +17,7 @@ has_field 'reseller' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/reseller name type is_active/], + render_list => [qw/reseller name type/], ); 1; diff --git a/lib/NGCP/Panel/Form/Invoice/TemplateReseller.pm b/lib/NGCP/Panel/Form/Invoice/TemplateReseller.pm index 1017861a46..54c5191541 100644 --- a/lib/NGCP/Panel/Form/Invoice/TemplateReseller.pm +++ b/lib/NGCP/Panel/Form/Invoice/TemplateReseller.pm @@ -34,16 +34,6 @@ has_field 'type' => ( }, ); -has_field 'is_active' => ( - type => 'Boolean', - label => 'Active', - required => 0, - element_attr => { - rel => ['tooltip'], - title => ['Whether this template is used to generate invoices for this reseller.'], - }, -); - has_field 'save' => ( type => 'Submit', value => 'Save', @@ -54,7 +44,7 @@ has_field 'save' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/name type is_active/], + render_list => [qw/name type/], ); has_block 'actions' => (