diff --git a/lib/NGCP/Panel/Controller/Reseller.pm b/lib/NGCP/Panel/Controller/Reseller.pm index d8a49773da..7a5982dabf 100644 --- a/lib/NGCP/Panel/Controller/Reseller.pm +++ b/lib/NGCP/Panel/Controller/Reseller.pm @@ -318,8 +318,10 @@ sub _handle_reseller_status_change { sub details :Chained('base') :PathPart('details') :Args(0) :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) { my ($self, $c) = @_; #didn't find a way to make it correct with chain - $c->forward('invoice_details'); - #$self->invoice_details($c); + $c->forward('invoice_details_zones'); + $c->forward('invoice_details_calls'); + #$self->invoice_details_zones($c); + #$self->invoice_details_calles($c); $c->stash(template => 'reseller/details.tt'); return; } @@ -429,9 +431,9 @@ sub messages :Chained('list_reseller') :PathPart('messages') :Args(0) { $c->log->debug('messages'); $c->stash( messages => $c->flash->{messages} ); $c->stash( template => 'helpers/ajax_messages.tt' ); - $c->detach( $c->view('SVG') ); + $c->detach( $c->view('SVG') );#no wrapper view } -sub invoice_details :Chained('base') :PathPart('invoice') :CaptureArgs(0) { +sub invoice_details_zones :Chained('base') :PathPart('invoice') :CaptureArgs(0) { my ($self, $c) = @_; $c->log->debug('invoice_details'); my $contract_id = $c->stash->{contract}->id; @@ -440,29 +442,63 @@ sub invoice_details :Chained('base') :PathPart('invoice') :CaptureArgs(0) { #look, NGCP::Panel::Utils::Contract - it is kind of backend separation here #my $form = NGCP::Panel::Form::InvoiceTemplate::Basic->new( ); - my $invoice_details = NGCP::Panel::Utils::Contract::get_contract_calls_rs( + my $invoice_details_zones = NGCP::Panel::Utils::Contract::get_contract_zonesfees_rs( + c => $c, + contract_id => $contract_id, + stime => $stime, + etime => $etime, + ); + #TODO: FAKE FAKE FAKE FAKE + my $invoice_details_zones_raw = $invoice_details_zones; + $invoice_details_zones = [$invoice_details_zones_raw->all()]; + my $i = 1; + $invoice_details_zones = [map{[$i++,$_]} (@$invoice_details_zones) x 21]; + $c->stash( invoice_details_zones => $invoice_details_zones ); + $c->stash( invoice_details_zones_raw => $invoice_details_zones_raw ); +} +sub invoice_details_calls :Chained('invoice_details_zones') :PathPart('') :CaptureArgs(0) { + my ($self, $c) = @_; + $c->log->debug('invoice_details_calls'); + 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 $form = NGCP::Panel::Form::InvoiceTemplate::Basic->new( ); + my $invoice_details_calls = NGCP::Panel::Utils::Contract::get_contract_calls_rs( c => $c, contract_id => $contract_id, stime => $stime, etime => $etime, ); #TODO: FAKE FAKE FAKE FAKE - my $invoice_details_raw = $invoice_details; - $invoice_details = [$invoice_details_raw->all()]; + my $invoice_details_calls_raw = $invoice_details_calls; + $invoice_details_calls = [$invoice_details_calls_raw->all()]; my $i = 1; - $invoice_details = [map{[$i++,$_]} (@$invoice_details) x 21]; - $c->stash( invoice_details => $invoice_details ); - $c->stash( invoice_details_raw => $invoice_details_raw ); + $invoice_details_calls = [map{[$i++,$_]} (@$invoice_details_calls) x 21]; + $c->stash( invoice_details_calls => $invoice_details_calls ); + $c->stash( invoice_details_calls_raw => $invoice_details_calls_raw ); +} +sub invoice_details_zones_ajax :Chained('base') :PathPart('invoice/details/zones/ajax') :Args(0) { + my ($self, $c) = @_; + my $dt_columns_json = $c->request->parameters->{dt_columns}; + #use irka; + #use Data::Dumper; + #irka::loglong(Dumper($dt_columns)); + $c->forward( 'invoice_details_zones' ); + my $dt_columns = from_json($dt_columns_json); + NGCP::Panel::Utils::Datatables::process($c, $c->stash->{invoice_details_zones_raw}, $dt_columns ); + $c->detach( $c->view("JSON") ); } -sub invoice_details_ajax :Chained('base') :PathPart('invoice/details/ajax') :Args(0) { +sub invoice_details_calls_ajax :Chained('base') :PathPart('invoice/details/calls/ajax') :Args(0) { my ($self, $c) = @_; my $dt_columns_json = $c->request->parameters->{dt_columns}; #use irka; #use Data::Dumper; #irka::loglong(Dumper($dt_columns)); - $c->forward( 'invoice_details' ); + $c->forward( 'invoice_details_calls' ); my $dt_columns = from_json($dt_columns_json); - NGCP::Panel::Utils::Datatables::process($c, $c->stash->{invoice_details_raw}, $dt_columns ); + NGCP::Panel::Utils::Datatables::process($c, $c->stash->{invoice_details_calls_raw}, $dt_columns ); $c->detach( $c->view("JSON") ); } sub invoice_template_info :Chained('base') :PathPart('invoice/template/info') :Args(0) { @@ -659,7 +695,7 @@ sub invoice_template_delete :Chained('base') :PathPart('invoice_template/delete' $c->forward( 'invoice_template_list' ); } -sub invoice_template_list_data :Chained('invoice_details') :PathPart('') :CaptureArgs(0) { +sub invoice_template_list_data :Chained('invoice_details_zones') :PathPart('') :CaptureArgs(0) { my ($self, $c) = @_; $c->log->debug('invoice_template_list_data'); my($validator,$backend,$in,$out); @@ -681,7 +717,7 @@ sub invoice :Chained('invoice_template_list_data') :PathPart('') :Args(0) { $c->stash(template => 'invoice/invoice.tt'); } -sub invoice_template :Chained('invoice_details') :PathPart('template') :Args { +sub invoice_template :Chained('invoice_details_calls') :PathPart('template') :Args { my ($self, $c) = @_; $c->log->debug('invoice_template'); no warnings 'uninitialized'; diff --git a/lib/NGCP/Panel/Utils/Contract.pm b/lib/NGCP/Panel/Utils/Contract.pm index 2f6dd247cc..2212e45a72 100644 --- a/lib/NGCP/Panel/Utils/Contract.pm +++ b/lib/NGCP/Panel/Utils/Contract.pm @@ -260,7 +260,7 @@ sub get_contract_calls_rs{ # source_user_id => { 'in' => [ map {$_->uuid} @{$contract->{subscriber}} ] }, call_status => 'ok', source_user_id => { '!=' => '0' }, - source_account_id => $contract_id, +# source_account_id => $contract_id, # start_time => # [ -and => # { '>=' => $stime->epoch}, @@ -282,8 +282,10 @@ sub get_contract_calls_rs{ { sum => 'me.duration', -as => 'duration' }, { count => '*', -as => 'number' }, 'source_customer_billing_zones_history.zone', + 'source_customer_billing_zones_history.detail', ], - 'as' => [qw/cost free_time duration number zone/], + '+as' => [qw/cost free_time duration number zone zone_detail/], + #alias => join => 'source_customer_billing_zones_history', group_by => 'source_customer_billing_zones_history.zone', } ); diff --git a/share/static/js/libs/svg-edit/extensions/allowedMimeTypes.php b/share/static/js/libs/svg-edit/extensions/allowedMimeTypes.php deleted file mode 100644 index 1e932b841b..0000000000 --- a/share/static/js/libs/svg-edit/extensions/allowedMimeTypes.php +++ /dev/null @@ -1,11 +0,0 @@ - 'image/svg+xml;charset=utf-8', - 'png' => 'image/png', - 'jpeg' => 'image/jpeg', - 'bmp' => 'image/bmp', - 'webp' => 'image/webp' -); - -?> \ No newline at end of file diff --git a/share/static/js/libs/svg-edit/extensions/fileopen.php b/share/static/js/libs/svg-edit/extensions/fileopen.php deleted file mode 100644 index f0ae937ba5..0000000000 --- a/share/static/js/libs/svg-edit/extensions/fileopen.php +++ /dev/null @@ -1,49 +0,0 @@ - - - -
- - - - diff --git a/share/static/js/libs/svg-edit/extensions/filesave.php b/share/static/js/libs/svg-edit/extensions/filesave.php deleted file mode 100644 index 84d7300a40..0000000000 --- a/share/static/js/libs/svg-edit/extensions/filesave.php +++ /dev/null @@ -1,60 +0,0 @@ - 0) { - $file = $_POST['filename'] . $suffix; -} else { - $file = 'image' . $suffix; -} - -if ($suffix == '.svg') { - $contents = $_POST['output_svg']; -} else { - $contents = $_POST['output_img']; - $pos = (strpos($contents, 'base64,') + 7); - $contents = base64_decode(substr($contents, $pos)); -} - -header("Cache-Control: public"); -header("Content-Description: File Transfer"); - -// See http://tools.ietf.org/html/rfc6266#section-4.1 -header("Content-Disposition: attachment; filename*=UTF-8''" . encodeRFC5987ValueChars( - // preg_replace('@[\\\\/:*?"<>|]@', '', $file) // If we wanted to strip Windows-disallowed characters server-side (but not a security issue, so we can strip client-side instead) - $file -)); -header("Content-Type: " . $mime); -header("Content-Transfer-Encoding: binary"); - -echo $contents; - -?> \ No newline at end of file diff --git a/share/static/js/libs/svg-edit/extensions/savefile.php b/share/static/js/libs/svg-edit/extensions/savefile.php deleted file mode 100644 index 2efd90b459..0000000000 --- a/share/static/js/libs/svg-edit/extensions/savefile.php +++ /dev/null @@ -1,16 +0,0 @@ -|]@u', '_', $_POST['filename']) : 'saved') . '.svg'; // These characters are indicated as prohibited by Windows - - $fh = fopen($filename, 'w') or die("Can't open file"); - fwrite($fh, $svg); - fclose($fh); -?> diff --git a/share/templates/invoice/invoice.tt b/share/templates/invoice/invoice.tt index 1d068ba6b5..236adfbb4f 100644 --- a/share/templates/invoice/invoice.tt +++ b/share/templates/invoice/invoice.tt @@ -85,10 +85,41 @@ var uriForAction = function( data, type ){| [% c.loc('Num') %] | +[% c.loc('Start time') %] | +[% c.loc('Duration') %] | +[% c.loc('Destination') %] | +[% c.loc('Type') %] | +[% c.loc('Zone/Details') %] | +[% c.loc('Cash') %] | ++ |
|---|---|---|---|---|---|---|---|
| [% row_number %] | +[% call.get_column('start_time') %] |
+ [% call.get_column('duration')|format('%.3f') %] |
+ [% call.get_column('destination')%][%#to mscro or view .replace('(.*?)\d{4}$','$1****') %] |
+ [% call.get_column('call_type') %] |
+ [% call.get_column('zone') _ '/' _ call.get_column('detail') %] | +[% 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('Num') %] | -[% c.loc('Zone') %] | -[% c.loc('Calls amount') %] | -[% c.loc('Duration') %] | +[% c.loc('Zone/Details') %] | +[% c.loc('Calls') %] | +[% c.loc('Usage') %] | [% c.loc('Free time') %] | [% c.loc('Cash') %] | |
|---|---|---|---|---|---|---|---|---|---|
| [% row_number %] | -[% call.get_column('zone') %] | +[% call.get_column('zone') _ '/' _ call.get_column('zone_detail') %] | [% call.get_column('number') %] |
[% call.get_column('duration')|format('%.3f') %] |
[% call.get_column('free_time')|format('%d') %] |
diff --git a/share/templates/invoice/invoice_template_aux.tt b/share/templates/invoice/invoice_template_aux.tt
index b1b339c86c..9b72309054 100644
--- a/share/templates/invoice/invoice_template_aux.tt
+++ b/share/templates/invoice/invoice_template_aux.tt
@@ -50,10 +50,10 @@
[%#data can be empty, if we just need y - it doesn't depend on data %]
[%IF pagetype == 'titlepage' %]
[%page = titlepage()%]
- [%ELSIF pagetype == 'midpage' %]
- [%page = midpage()%]
- [%ELSIF pagetype == 'lastpage' %]
- [%page = lastpage()%]
+ [%ELSIF pagetype == 'zonepage' %]
+ [%page = zonepage()%]
+ [%ELSIF pagetype == 'callpage' %]
+ [%page = callpage()%]
[%END%]
[%page%]
[%END%]
@@ -87,66 +87,112 @@
[%END -%]
[%END -%]
-[%MACRO get_page_rows_number(pagetype, tt_type, row_vertical_interval) BLOCK-%]
+[%MACRO get_page_zonerows_number(pagetype, tt_type, row_vertical_interval) BLOCK-%]
[%#doesn't work %]
- [% page_rows_re = page_rows_re(tt_type) %]
+ [% page_zonerows_re = page_zonerows_re(tt_type) %]
[% IF tt_type == 'svg' -%]
[%# page_rows_re = '(?si)