diff --git a/lib/NGCP/Panel/Controller/Customer.pm b/lib/NGCP/Panel/Controller/Customer.pm index a756f59359..756dbf863a 100644 --- a/lib/NGCP/Panel/Controller/Customer.pm +++ b/lib/NGCP/Panel/Controller/Customer.pm @@ -812,13 +812,30 @@ sub edit_balance :Chained('base') :PathPart('balance/edit') :Args(0) { $c->stash(edit_flag => 1); } -sub invoice :Chained('base') :PathPart('invoice') :CaptureArgs(0) { +sub invoice_data :Chained('base') :PathPart('invoice') :CaptureArgs(0) { my ($self, $c) = @_; - $c->stash(template => 'customer/invoice.tt'); -} + $c->log->debug('invoice_data'); + my $contract_id = $c->stash->{contract}->id; + my $stime = NGCP::Panel::Utils::DateTime::current_local()->truncate(to => 'month'); + my $etime = $stime->clone->add(months => 1); -sub invoice_template_list :Chained('invoice') :PathPart('') :CaptureArgs(0) { + #look, NGCP::Panel::Utils::Contract - it is kind of backend separation here + my $zonecalls_rs = 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()]; + my $i = 1; + $zonecalls_rs = [map{[$i++,$_]} (@$zonecalls_rs) x 21]; + $c->stash(zonecalls_rs => $zonecalls_rs ); +} +#method separated as some day +sub invoice_template_list :Chained('invoice_data') :PathPart('') :CaptureArgs(0) { my ($self, $c) = @_; + $c->log->debug('invoice_template_list'); my($validator,$backend,$in,$out); #this is just copy-paste from method above @@ -861,31 +878,14 @@ sub invoice_template_list :Chained('invoice') :PathPart('') :CaptureArgs(0) { #think about it more #$out->{invoice_template_list} = $backend->getCustomerInvoiceTemplateList( %$in ); - $c->stash(invoice_template_list => $backend->getCustomerInvoiceTemplateList( %$in ) ); + $c->stash( invoice_template_list => $backend->getCustomerInvoiceTemplateList( %$in )->all ); } - -sub invoice_data :Chained('invoice_template_list') :PathPart('') :CaptureArgs(0) { +sub invoice :Chained('invoice_template_list') :PathPart('') :Args(0) { my ($self, $c) = @_; - $c->log->debug('calls_list'); - my $contract_id = $c->stash->{contract}->id; - my $stime = NGCP::Panel::Utils::DateTime::current_local()->truncate(to => 'month'); - 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( - c => $c, - contract_id => $contract_id, - stime => $stime, - etime => $etime, - ); - #FAKE FAKE FAKE FAKE - $zonecalls_rs = [$zonecalls_rs->all()]; - my $i = 1; - $zonecalls_rs = [map{[$i++,$_]} (@$zonecalls_rs) x 21]; - $c->stash(zonecalls_rs => $zonecalls_rs ); + $c->stash(template => 'customer/invoice.tt'); } -sub invoice_template :Chained('invoice_data') :PathPart('') :CaptureArgs(5) { +sub invoice_template :Chained('invoice_data') :PathPart('template') :Args { my ($self, $c) = @_; #$c->log->debug($c->model('DB')); #return; @@ -894,7 +894,7 @@ sub invoice_template :Chained('invoice_data') :PathPart('') :CaptureArgs(5) { #my $contract_id = $in->{contract_id} = ; - #no warnings 'uninitialized'; + no warnings 'uninitialized'; my($validator,$backend,$in,$out); @@ -949,7 +949,8 @@ sub invoice_template :Chained('invoice_data') :PathPart('') :CaptureArgs(5) { }elsif($in->{tt_type} eq 'html'){ $in->{tt_output_type} = 'html'; } - + #use irka; + #use Data::Dumper; #irka::loglong(Dumper($in)); #model logic diff --git a/lib/NGCP/Panel/Form/Customer/InvoiceTemplate.pm b/lib/NGCP/Panel/Form/Customer/InvoiceTemplate.pm index 1cb409bd1a..e3db1948c4 100644 --- a/lib/NGCP/Panel/Form/Customer/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Form/Customer/InvoiceTemplate.pm @@ -56,14 +56,14 @@ has_field 'tt_string' => ( ); has_field 'contract_id' => ( - type => 'Number', + type => 'Text', #default => \& #apply => [ { check => \&validate_tt_string } ], required => 1, ); has_field 'tt_id' => ( - type => 'Number', + type => 'Text', #default => \& #apply => [ { check => \&validate_tt_string } ], required => 0, diff --git a/lib/NGCP/Panel/Model/DB/InvoiceTemplate.pm b/lib/NGCP/Panel/Model/DB/InvoiceTemplate.pm index c304ed0a79..07215f394f 100644 --- a/lib/NGCP/Panel/Model/DB/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Model/DB/InvoiceTemplate.pm @@ -77,5 +77,12 @@ sub storeCustomerInvoiceTemplate{ } }); } - +sub getCustomerInvoiceTemplateList{ + my $self = shift; + my (%params) = @_; + my ($contract_id,$tt_sourcestate,$tt_type, $tt_string, $tt_id) = @params{qw/contract_id tt_sourcestate tt_type tt_string_sanitized tt_id/}; + return $self->schema->resultset('invoice_template')->search({ + reseller_id => $contract_id, + }); +} 1; \ No newline at end of file diff --git a/lib/NGCP/Panel/Utils/InvoiceTemplate.pm b/lib/NGCP/Panel/Utils/InvoiceTemplate.pm index 8e2e1d1e44..116e27b034 100644 --- a/lib/NGCP/Panel/Utils/InvoiceTemplate.pm +++ b/lib/NGCP/Panel/Utils/InvoiceTemplate.pm @@ -1,4 +1,6 @@ package NGCP::Panel::Utils::InvoiceTemplate; +#it should be part of real model, or subcontroller + use strict; use warnings; use Moose; @@ -7,7 +9,7 @@ use Sipwise::Base; sub getDefaultInvoiceTemplate{ my (%in) = @_; #in future may be we will store root default in Db too, but now it is convenient to edit template as file - my $result = $in{c}->view('SVG')->getTemplateContent($in{c}, 'customer/calls_'.$in{type}.'.tt'); + my $result = $in{c}->view('SVG')->getTemplateContent($in{c}, 'customer/invoice_template_'.$in{type}.'.tt'); #$in{c}->log->debug("result=$result;"); diff --git a/lib/NGCP/Panel/View/SVG.pm b/lib/NGCP/Panel/View/SVG.pm index 5ee61f801e..c269d393e8 100644 --- a/lib/NGCP/Panel/View/SVG.pm +++ b/lib/NGCP/Panel/View/SVG.pm @@ -56,7 +56,11 @@ sub getTemplateContent{ } sub getTemplateProcessed{ my ( $self, $c, $template, $stash ) = @_; + #$c->log->debug("getTemplateProcessed: template=$template;"); + #my $result = $self->{template}->context->process($template, $stash); + #$c->log->debug("getTemplateProcessed: result=$result;"); + #return $result return $self->{template}->context->process($template, $stash); } diff --git a/share/templates/customer/details.tt b/share/templates/customer/details.tt index d71cb86101..c816044130 100644 --- a/share/templates/customer/details.tt +++ b/share/templates/customer/details.tt @@ -399,30 +399,20 @@ -[%BLOCK accordion_group_internal %] -
| [% c.loc('Zone') %] | @@ -430,12 +420,12 @@[% c.loc('Duration') %] | [% c.loc('Free time') %] | [% c.loc('Cash') %] | -[% call.get_column('duration')|format('%.3f') %] |
[% call.get_column('free_time')|format('%d') %] |
[% money_format( call.get_column('cost') / 100 ) %] |
- - - | [%END%]
|---|---|---|---|---|
[% total_duration | format('%.3f') %]
| [% total_free_time | format('%d')%]
| [% money_format( total_cost / 100 ) %] |
- - - |
| [% c.loc('Zone') %] | +[% c.loc('Calls amount') %] | +[% c.loc('Duration') %] | +[% c.loc('Free time') %] | +[% c.loc('Cash') %] | ++ |
|---|---|---|---|---|---|
| [% call.get_column('zone') %] | +[% call.get_column('number') %] |
+ [% call.get_column('duration')|format('%.3f') %] |
+ [% call.get_column('free_time')|format('%d') %] |
+ [% money_format( call.get_column('cost') / 100 ) %] |
+ |
| [% c.loc('Total') %] | +[% total_number %] |
+ [% total_duration | format('%.3f') %] |
+ [% total_free_time | format('%d')%] |
+ [% money_format( total_cost / 100 ) %] |
+
| [% c.loc('Active') %] | +[% c.loc('Type') %] | +[%# c.loc('Name') %] | ++ |
|---|---|---|---|
| [% template.get_column('is_active') %] | +[% template.get_column('type') %] | +[%# template.get_column('name') %] | +
+
+ [% IF write_access -%]
+
+ [% c.loc('Edit previewed') %]
+
+
+ [% c.loc('Edit saved') %]
+
+ [%IF !template.is_active%]
+
+ [% c.loc('Make active') %]
+
+ [%END%]
+ [%END%]
+
+ [% c.loc('Download source') %]
+
+
+ [% c.loc('Download invoice') %]
+
+
+ |
+