diff --git a/lib/NGCP/Panel/Controller/Customer.pm b/lib/NGCP/Panel/Controller/Customer.pm index 756dbf863a..fb8293e03f 100644 --- a/lib/NGCP/Panel/Controller/Customer.pm +++ b/lib/NGCP/Panel/Controller/Customer.pm @@ -820,17 +820,17 @@ sub invoice_data :Chained('base') :PathPart('invoice') :CaptureArgs(0) { my $etime = $stime->clone->add(months => 1); #look, NGCP::Panel::Utils::Contract - it is kind of backend separation here - my $zonecalls_rs = NGCP::Panel::Utils::Contract::get_contract_calls_rs( + my $invoice_details = NGCP::Panel::Utils::Contract::get_contract_calls_rs( c => $c, contract_id => $contract_id, stime => $stime, etime => $etime, ); #FAKE FAKE FAKE FAKE - $zonecalls_rs = [$zonecalls_rs->all()]; + $invoice_details = [$invoice_details->all()]; my $i = 1; - $zonecalls_rs = [map{[$i++,$_]} (@$zonecalls_rs) x 21]; - $c->stash(zonecalls_rs => $zonecalls_rs ); + $invoice_details = [map{[$i++,$_]} (@$invoice_details) x 21]; + $c->stash(invoice_details => $invoice_details ); } #method separated as some day sub invoice_template_list :Chained('invoice_data') :PathPart('') :CaptureArgs(0) { diff --git a/share/templates/customer/invoice.tt b/share/templates/customer/invoice.tt index 7e226a8359..344f49559e 100644 --- a/share/templates/customer/invoice.tt +++ b/share/templates/customer/invoice.tt @@ -1,3 +1,9 @@ +[% USE Dumper %] + +[%PROCESS 'helpers/datatables_vars.tt' + no_auto_helper = 1 +-%] + [% IF c.user.roles == "subscriber" || c.user.roles == "subscriberadmin" -%] [% site_config.title = c.loc('Invoice template manager') -%] [% ELSE -%] @@ -8,18 +14,6 @@ [% write_access = 1 %] [%END%] - -
- - [% c.loc('Back') %] - -
-
-[% back_created = 1 -%] - - -[% USE Dumper %] - +
+ + [% c.loc('Back') %] + +
+
+[% back_created = 1 -%]
@@ -148,6 +110,17 @@ function handleSaveSvgData(data, error) {
+ + +[% + clearHelper(); + helper.name = c.loc('Invoice Details'); + helper.name_single = c.loc('Invoice Record'); + helper.identifier = 'invoice_details'; + initHelperAuto(); + PROCESS 'helpers/datatables.tt'; +-%] + diff --git a/share/templates/helpers/datatables_vars.tt b/share/templates/helpers/datatables_vars.tt index 3481ec890d..2c0d63f19c 100644 --- a/share/templates/helpers/datatables_vars.tt +++ b/share/templates/helpers/datatables_vars.tt @@ -2,26 +2,35 @@ #USE Dumper; #we can't use DEFAULT directive - it treats false the same as undefined, which doesn't allow to keep default filled values and switch them off by customization +MACRO clearHelper() BLOCK; + FOREACH identifier in [ 'messages', 'length_change', 'dt_columns', 'close_target', 'create_flag', 'form_object', 'ajax_uri' ]; + helper.${identifier} = ''; + END +END; MACRO initHelper(var,value) BLOCK; # Dumper.dump(helper); - UNLESS helper.${var}.defined; helper.${var} = value || ${var}; END; + identifier = "${helper.identifier}" _ "_" _ var; + UNLESS helper.${var}.defined; helper.${var} = helper.${var} || value || ${"${identifier}"} || ${var}; END; END; -initHelper('messages'); -initHelper('length_change'); -initHelper('dt_columns', ${"${helper.identifier}_dt_columns"} ); -initHelper('close_target'); -initHelper('create_flag'); -initHelper('form_object',form); -initHelper('ajax_uri', c.uri_for( c.controller.action_for('ajax') )); - -#here we can generate couple of variants, selection of proper variant will be exact view responsibility -UNLESS c.user.read_only; - initHelper('dt_buttons',[ - { name = c.loc('Edit'), uri = "/${helper.identifier}'+full[\"id\"]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' }, - ] ); - initHelper('top_buttons',[ - { name = c.loc("Create ${helper.name_single}"), uri = c.uri_for("/${helper.identifier}/create"), icon = 'icon-star' }, - ] ); +MACRO initHelperAuto() BLOCK; + FOREACH identifier in [ 'messages', 'length_change', 'dt_columns', 'close_target', 'create_flag' ]; + initHelper(identifier); + END + initHelper('form_object',form); + initHelper('ajax_uri', c.uri_for( c.controller.action_for('ajax') )); END; +IF !no_auto_helper; + clearHelper(); + initHelperAuto(); + #here we can generate couple of variants, selection of proper variant will be exact view responsibility + UNLESS c.user.read_only; + initHelper('dt_buttons',[ + { name = c.loc('Edit'), uri = "/${helper.identifier}'+full[\"id\"]+'/edit", class = 'btn-small btn-primary', icon = 'icon-edit' }, + ] ); + initHelper('top_buttons',[ + { name = c.loc("Create ${helper.name_single}"), uri = c.uri_for("/${helper.identifier}/create"), icon = 'icon-star' }, + ] ); + END; +END; -%] \ No newline at end of file