MT#5879 Draft of calls pages in template

1. Add calls templates, data methods.
2. Complete new invoices look.
3. Remove php files from svg edit
ipeshinskaya/InvoiceTemplate5
Irina Peshinskaya 12 years ago committed by Victor Seva
parent e9083ac5b2
commit 5e30919042

@ -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';

@ -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',
} );

@ -1,11 +0,0 @@
<?php
$allowedMimeTypesBySuffix = array(
'svg' => 'image/svg+xml;charset=utf-8',
'png' => 'image/png',
'jpeg' => 'image/jpeg',
'bmp' => 'image/bmp',
'webp' => 'image/webp'
);
?>

@ -1,49 +0,0 @@
<!DOCTYPE html>
<?php
/*
* fileopen.php
* To be used with ext-server_opensave.js for SVG-edit
*
* Licensed under the MIT License
*
* Copyright(c) 2010 Alexis Deveria
*
*/
// Very minimal PHP file, all we do is Base64 encode the uploaded file and
// return it to the editor
$type = $_REQUEST['type'];
if (!in_array($type, array('load_svg', 'import_svg', 'import_img'))) {
exit;
}
require('allowedMimeTypes.php');
$file = $_FILES['svg_file']['tmp_name'];
$output = file_get_contents($file);
$prefix = '';
// Make Data URL prefix for import image
if ($type == 'import_img') {
$info = getimagesize($file);
if (!in_array($info['mime'], $allowedMimeTypesBySuffix)) {
exit;
}
$prefix = 'data:' . $info['mime'] . ';base64,';
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<script>
top.svgEditor.processFile("<?php
// This should be safe since SVG edit does its own filtering (e.g., if an SVG file contains scripts)
echo $prefix . base64_encode($output);
?>", "<?php echo $type; ?>");
</script>
</head><body></body>
</html>

@ -1,60 +0,0 @@
<?php
/*
* filesave.php
* To be used with ext-server_opensave.js for SVG-edit
*
* Licensed under the MIT License
*
* Copyright(c) 2010 Alexis Deveria
*
*/
function encodeRFC5987ValueChars ($str) {
// See http://tools.ietf.org/html/rfc5987#section-3.2.1
// For better readability within headers, add back the characters escaped by rawurlencode but still allowable
// Although RFC3986 reserves "!" (%21), RFC5987 does not
return preg_replace_callback('@%(2[1346B]|5E|60|7C)@', function ($matches) {
return chr('0x' . $matches[1]);
}, rawurlencode($str));
}
require('allowedMimeTypes.php');
$mime = !isset($_POST['mime']) || !in_array($_POST['mime'], $allowedMimeTypesBySuffix) ? 'image/svg+xml;charset=UTF-8' : $_POST['mime'];
if (!isset($_POST['output_svg']) && !isset($_POST['output_img'])) {
die('post fail');
}
$file = '';
$suffix = '.' . array_search($mime, $allowedMimeTypesBySuffix);
if (isset($_POST['filename']) && strlen($_POST['filename']) > 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;
?>

@ -1,16 +0,0 @@
<?php
// You must first create a file "savefile_config.php" in this extensions directory and do whatever
// checking of user credentials, etc. that you wish; otherwise anyone will be able to post SVG
// files to your server which may cause disk space or possibly security problems
require('savefile_config.php');
if (!isset($_POST['output_svg'])) {
print "You must supply output_svg";
exit;
}
$svg = $_POST['output_svg'];
$filename = (isset($_POST['filename']) && !empty($_POST['filename']) ? preg_replace('@[\\\\/:*?"<>|]@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);
?>

@ -85,10 +85,41 @@ var uriForAction = function( data, type ){
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#customer_invoice_template" href="#collapse_invoice_details">[% c.loc('Invoice details') %]</a>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#customer_invoice_template" href="#collapse_invoice_details_zones">[% c.loc('Invoice details') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_invoice_details">
<div class="accordion-body collapse" id="collapse_invoice_details_zones">
<div class="accordion-inner" style="overflow:auto; height: 300px;">
[%
clearHelper();
helper.name = c.loc('Invoice Connection Fees');
helper.dt_columns = [
{ name => 'source_customer_billing_zones_history.zone', title => c.loc('Zone'), search=> 1 },
{ name => 'number', title => c.loc('Calls') },
{ name => 'duration', title => c.loc('Usage') },
{ name => 'free_time', title => c.loc('Free time') },
{ name => 'cost', title => c.loc('Amount EUR') },
];
helper.name_single = c.loc('Invoice Connections Records');
helper.identifier = 'invoice_details_zones_raw';
helper.ajax_uri = c.uri_for_action( '/reseller/invoice_details_zones_ajax', [ contract.id ] ) ;
initHelperAuto();
PROCESS 'helpers/datatables.tt';
-%]
[%PROCESS 'invoice/invoice_details_zones_list.tt' %]
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#customer_invoice_template" href="#collapse_invoice_details_zones">[% c.loc('Invoice details') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_invoice_details_zones">
<div class="accordion-inner" style="overflow:auto; height: 300px;">
@ -96,19 +127,19 @@ var uriForAction = function( data, type ){
clearHelper();
helper.name = c.loc('Invoice Details');
helper.dt_columns = [
{ name => 'zone', title => c.loc('Zone'), search=> 1 },
{ name => 'number', title => c.loc('Calls amount') },
{ name => 'duration', title => c.loc('Duration') },
{ name => 'source_customer_billing_zones_history.zone', title => c.loc('Zone'), search=> 1 },
{ name => 'number', title => c.loc('Calls') },
{ name => 'duration', title => c.loc('Usage') },
{ name => 'free_time', title => c.loc('Free time') },
{ name => 'cost', title => c.loc('Cash') },
{ name => 'cost', title => c.loc('Amount EUR') },
];
helper.name_single = c.loc('Invoice Record');
helper.identifier = 'invoice_details_raw';
helper.ajax_uri = c.uri_for_action( '/reseller/invoice_details_ajax', [ contract.id ] ) ;
helper.name_single = c.loc('Invoice Connections Records');
helper.identifier = 'invoice_details_zones_raw';
helper.ajax_uri = c.uri_for_action( '/reseller/invoice_details_zones_ajax', [ contract.id ] ) ;
initHelperAuto();
PROCESS 'helpers/datatables.tt';
-%]
[%PROCESS 'invoice/invoice_details_list.tt' %]
[%PROCESS 'invoice/invoice_details_zones_list.tt' %]
</div>
</div>

@ -0,0 +1,42 @@
[%# USE Dumper %]
[%# Dumper.dump(invoice_details_zones)%]
[%# invoice_details_zones.size%]
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
<th>[% c.loc('Num') %]</th>
<th>[% c.loc('Start time') %]</th>
<th>[% c.loc('Duration') %]</th>
<th>[% c.loc('Destination') %]</th>
<th>[% c.loc('Type') %]</th>
<th>[% c.loc('Zone/Details') %]</th>
<th>[% c.loc('Cash') %]</th>
<th class="ngcp-actions-column"></th>
</tr>
</thead>
<tbody>
[%# Dumper.dump_html(invoice_details_zones.as_query)%]
[% FOR call IN invoice_details_zones -%]
[%IF call.1; row_number = call.0; call = call.1; END%]
[% total_duration = total_duration + call.get_column('duration') %]
[% total_cost = total_cost + call.get_column('cost') %]
<tr class="sw_action_row">
<td>[% row_number %]</td>
<td><div class="pull-right">[% call.get_column('start_time') %]</div></td>
<td><div class="pull-right">[% call.get_column('duration')|format('%.3f') %]</div></td>
<td><div class="pull-right">[% call.get_column('destination')%][%#to mscro or view .replace('(.*?)\d{4}$','$1****') %]</div></td>
<td><div class="pull-right">[% call.get_column('call_type') %]</div></td>
<td>[% call.get_column('zone') _ '/' _ call.get_column('detail') %]</td>
<td><div class="pull-right">[% money_format( call.get_column('cost') / 100 ) %]</div></td>
</tr>
[%END%]
<tr>
<td colspan="2">[% c.loc('Total') %]</td>
<td><div class="pull-right">[% total_number %]</div></td>
<td><div class="pull-right">[% total_duration | format('%.3f') %]</div></td>
<td><div class="pull-right">[% total_free_time | format('%d')%]</div></td>
<td><div class="pull-right">[% money_format( total_cost / 100 ) %]</div></td>
</tr>
</tbody>
</table>

@ -1,22 +1,22 @@
[%# USE Dumper %]
[%# Dumper.dump(invoice_details)%]
[%# invoice_details.size%]
[%# Dumper.dump(invoice_details_zones)%]
[%# invoice_details_zones.size%]
<table class="table table-bordered table-striped table-highlight table-hover">
<thead>
<tr>
<th>[% c.loc('Num') %]</th>
<th>[% c.loc('Zone') %]</th>
<th>[% c.loc('Calls amount') %]</th>
<th>[% c.loc('Duration') %]</th>
<th>[% c.loc('Zone/Details') %]</th>
<th>[% c.loc('Calls') %]</th>
<th>[% c.loc('Usage') %]</th>
<th>[% c.loc('Free time') %]</th>
<th>[% c.loc('Cash') %]</th>
<th class="ngcp-actions-column"></th>
</tr>
</thead>
<tbody>
[%# Dumper.dump_html(invoice_details.as_query)%]
[% FOR call IN invoice_details -%]
[%# Dumper.dump_html(invoice_details_zones.as_query)%]
[% FOR call IN invoice_details_zones -%]
[%IF call.1; row_number = call.0; call = call.1; END%]
[% total_number = total_number + call.get_column('number') %]
[% total_duration = total_duration + call.get_column('duration') %]
@ -24,7 +24,7 @@
[% total_cost = total_cost + call.get_column('cost') %]
<tr class="sw_action_row">
<td>[% row_number %]</td>
<td>[% call.get_column('zone') %]</td>
<td>[% call.get_column('zone') _ '/' _ call.get_column('zone_detail') %]</td>
<td><div class="pull-right">[% call.get_column('number') %]</div></td>
<td><div class="pull-right">[% call.get_column('duration')|format('%.3f') %]</div></td>
<td><div class="pull-right">[% call.get_column('free_time')|format('%d') %]</div></td>

@ -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)<g\s+[^>]*(?:\s+rows\s*=.*?(\d+))?[^>]*\s+id\s*=.*?(?:page_invoicedetails)[^>]*(?:\s+rows\s*=.*?(\d+))?[^>]*>' -%]
[% page_rows_re = 'rows="([0-9]+)"' -%]
[% page_rows_re = 'zonerows="([0-9]+)"' -%]
[%END%]
[% page = get_page(pagetype) %]
[% matches = page.match( page_rows_re ) -%]
[%#page=Dumper.dump(page)%]
[%#page_rows_re=Dumper.dump(page_rows_re)%]
[%#matches=Dumper.dump(matches)%]
[% rows = matches.0 || matches.1 %]
[%#IF !rows%]
[%# all_g_y_re = page_y_re(tt_type) %]
[%# matches = page.match( page_rows_re ) -%]
[%#END%]
[%#IF ! rows %][%# rows = 10%][%#END%]
[%rows = matches.0 || matches.1 %]
[%rows = Math.int(rows)%]
[%rows%]
[%END -%]
[%MACRO show_pages(invoice_details, pagetype, pagenum_in) BLOCK-%]
[% allrowsnumber = invoice_details.size() %]
[% titlerows = get_page_rows_number('titlepage','svg') %]
[%#IF titlerows== 0 ; titlerows = 10; END%]
[% midrows = get_page_rows_number('midpage','svg') %]
[%IF midrows == 0 ; midrows = 30 ; END%]
[% allmidpages = ( (allrowsnumber - titlerows) / midrows )|format('%d') %]
[% allmidrows = allmidpages * midrows %]
[% lastrows = allrowsnumber - allmidrows - titlerows %]
[%MACRO get_page_callrows_number(pagetype, tt_type, row_vertical_interval) BLOCK-%]
[%#doesn't work %]
[% page_rows_re = page_rows_re(tt_type) %]
[% IF tt_type == 'svg' -%]
[%# page_rows_re = '(?si)<g\s+[^>]*(?:\s+rows\s*=.*?(\d+))?[^>]*\s+id\s*=.*?(?:page_invoicedetails)[^>]*(?:\s+rows\s*=.*?(\d+))?[^>]*>' -%]
[% page_rows_re = 'callrows="([0-9]+)"' -%]
[%END%]
[% page = get_page(pagetype) %]
[% matches = page.match( page_rows_re ) -%]
[%rows = matches.0 || matches.1 %]
[%rows = Math.int(rows)%]
[%rows%]
[%END -%]
[%MACRO show_pages(invoice_details_zones, invoice_details_calls, pagetype, pagenum_in) BLOCK-%]
[%#todo: remove copypast with some macro, later%]
[% allzonerowsnumber = invoice_details_zones.size() %]
[% titlezonerows = get_page_zonerows_number('titlepage','svg') %]
[% midzonerows = get_page_zonerows_number('zonepage','svg') %]
[% midzonerows = ( midzonerows == 0 ) ? 30 : midzonerows %]
[% allzonepages = ( (allzonerowsnumber - titlezonerows) / midzonerows )|format('%d') %]
[% allmidzonerows = allzonepages * midzonerows %]
[% lastzonerows = allzonerowsnumber - allmidzonerows - titlezonerows %]
[% allcallrowsnumber = invoice_details_calls.size() %]
[% titlecallrows = get_page_callrows_number('titlepage','svg') %]
[% midcallrows = get_page_callrows_number('callpage','svg') %]
[% midcallrows = ( midcallrows < 1 ) ? 30 : midcallrows %]
[% allcallpages = ( (allcallrowsnumber - titlecallrows) / midcallrows )|format('%d') %]
[% allmidcallrows = allcallpages * midcallrows %]
[% lastcallrows = allcallrowsnumber - allmidcallrows - titlecallrows %]
[%IF ( pagetype == 'title' || pagetype=='all') %]
[% pagenum = 1%]
[% document_header()%]
[% titlepage( titlerows > 0 ? invoice_details.slice(0, titlerows - 1 ) : [], pagenum) -%]
[% titlepage(
( titlezonerows > 0 && invoice_details_zones.size > 0 ) ? invoice_details_zones.slice(0, titlezonerows - 1 ) : [],
( titlecallrows > 0 && invoice_details_calls.size > 0 ) ? invoice_details_calls.slice(0, titlecallrows - 1 ) : [],
pagenum
) -%]
[% bgpage(pagenum) -%]
[% document_footer()%]
[%END-%]
[%IF ( pagetype == 'mid' || pagetype=='all' ) && allmidrows %]
[% pages = pagenum_in ? [ pagenum_in ] : [ 1 .. allmidpages ] %]
[%IF ( pagetype == 'zone' || pagetype=='all' ) && allmidzonerows %]
[% pages = pagenum_in ? [ pagenum_in ] : [ 1 .. allzonepages ] %]
[%FOREACH pagenum IN pages %]
[% pagerowsstart = titlerows + midrows * ( pagenum - 1 )%]
[% pagerowsend = titlerows + midrows * pagenum - 1 %]
[% pagerowsstart = titlezonerows + midzonerows * ( pagenum - 1 )%]
[% pagerowsend = titlezonerows + midzonerows * pagenum - 1 %]
[% document_header()%]
[% zonepage( invoice_details_zones.slice( pagerowsstart, pagerowsend ), pagenum + 1 ) -%]
[%#+1 because of 1 for titlepage %]
[% bgpage(pagenum + 1) -%]
[% document_footer()%]
[%END-%]
[%IF lastzonerows > 0 %]
[%#2 because zonepages started from 1, not from 0, and we need add 1 for titlepage %]
[% pagenum = 2 + allzonepages %]
[% document_header()%]
[% midpage( invoice_details.slice( pagerowsstart, pagerowsend ), pagenum + 1 ) -%]
[% bgpage(pagenum + 1s) -%]
[% zonepage( invoice_details_zones.slice( allzonerowsnumber - lastzonerows, allzonerowsnumber ), pagenum ) -%]
[% bgpage(pagenum) -%]
[% document_footer()%]
[%END-%]
[%END-%]
[%IF ( pagetype == 'last' || pagetype=='all' )%]
[%#2 because midpages started from 1, and we need add 1 for titlepage %]
[% pagenum = 2 + allmidpages %]
[% document_header()%]
[% lastpage( invoice_details.slice( allrowsnumber - lastrows, allrowsnumber ), pagenum ) -%]
[% bgpage(pagenum) -%]
[% document_footer()%]
[%IF ( pagetype == 'call' || pagetype=='all' )%]
[% pages = pagenum_in ? [ pagenum_in ] : [ 1 .. allcallpages ] %]
[%FOREACH pagenum IN pages %]
[% pagerowsstart = titlecallrows + midcallrows * ( pagenum - 1 )%]
[% pagerowsend = titlecallrows + midcallrows * pagenum - 1 %]
[% document_header()%]
[% callpage( invoice_details_calls.slice( pagerowsstart, pagerowsend ), pagenum + 1 ) -%]
[%#+1 because of 1 for titlepage %]
[% bgpage(pagenum + allzonepages + 1) -%]
[% document_footer()%]
[%END-%]
[%IF lastcallrows > 0 %]
[%#2 because callpages started from 1, not from 0, and we need add 1 for titlepage %]
[% pagenum = 2 + allcallpages %]
[% document_header()%]
[% callpage( invoice_details_calls.slice( allcallrowsnumber - lastcallrows, allcallrowsnumber ), pagenum ) -%]
[% bgpage(pagenum) -%]
[% document_footer()%]
[%END-%]
[%END-%]
[%END-%]

@ -1,5 +1,3 @@
[%#It can be separated later to form template and loaded with ajax and fillinform template::toolkit plugin. %]
[%#It is reliable and easy to implement solution, but requires additional modules. For now populate small form with jquery.%]
[%# USE FillInForm %]
<script>
function getTtIdVal(){

@ -33,7 +33,7 @@ g, text, tspan {
<!--pageSet-->
<!--{[%END-%]}-->
<!--{[%MACRO titlepage(callsdata, page) BLOCK-%]}-->
<!--{[%MACRO titlepage(zonesdata, callsdata, page) BLOCK-%]}-->
<!--page-->
<g y="0" x="0" width="215" height="297" id="titlepage" display="none">
@ -61,7 +61,7 @@ g, text, tspan {
<text x="195" y="140" text-anchor="end">[%invoice.serviceallowance%]</text>
<text x="15" y="150">Cloud PBX Account [%date.month_start%] - [%date.month_end%] [%date.year%]</text>
<text x="195" y="150" text-anchor="end">[%invoice.cloud_pbx_amount%]</text>
<text x="15" y="160">Discount (12M reduced Service Fee)</text>
<text x="15" y="160">Discount (12M reduced Service Fee):</text>
<text x="195" y="160" text-anchor="end">[%invoice.discount%]</text>
<text x="15" y="170">Voice Termination Fees [%date.month_start%] - [%date.month_end%] [%date.year%]</text>
<text x="195" y="170" text-anchor="end">[%invoice.voice_termination_fees%]</text>
@ -82,87 +82,46 @@ g, text, tspan {
<text x="15" y="255">More details can be found online at www.sipwise.net in My Account.</text>
<text x="15" y="260">With best regards,</text>
<text x="15" y="265">Your Sipwise Team</text>
<g y="265" x="10" width="195" height="150" id="titlepage_invoicedetails" transform="translate(10, 265)" rows="0" style="display:none;">
<!--{[%MACRO titlerow BLOCK-%]}-->
<text id="titlepage_calls_title" text-anchor="end">
<tspan x="5" id="titlepage_calls_number" text-anchor="start">#</tspan>
<tspan x="15" id="titlepage_calls_zone" text-anchor="start">Zone</tspan>
<tspan x="95" id="titlepage_calls_number">Number</tspan>
<tspan x="130" id="titlepage_calls_duration">Duration</tspan>
<tspan x="160" id="titlepage_calls_freetime">Free time</tspan>
<tspan x="190" id="titlepage_calls_cost">Cost</tspan>
</text>
<!--{[%END-%]}-->
<!--{[%MACRO datarow(call) BLOCK-%]}-->
<text y="10" text-anchor="end" id="titlepage_calls[%loop.count-%]_text" class="datarow">
<tspan x="5" id="titlepage_calls_number[%loop.count-%]" text-anchor="start"><!--{[% call.0 %]}--><!--{[%#}-->1<!--{%]}--></tspan>
<!--{[%IF call.1; call = call.1; END%]}-->
<tspan x="15" id="titlepage_calls_zone[%loop.count-%]" text-anchor="start"><!--{[% call.get_column('zone') %]}--><!--{[%#}-->Example zone<!--{%]}--></tspan>
<tspan x="95" id="titlepage_calls_number[%loop.count-%]"><!--{[% call.get_column('number') %]}--><!--{[%#}-->0<!--{%]}--></tspan>
<tspan x="130" id="titlepage_calls_duration[%loop.count-%]"><!--{[% call.get_column('duration')|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="160" id="titlepage_calls_freetime[%loop.count-%]"><!--{[% call.get_column('free_time')|format('%d') %]}--><!--{[%#}-->0.0<!--{%]}--></tspan>
<tspan x="190" id="titlepage_calls_cost[%loop.count-%]"><!--{[% ( call.get_column('cost') / 100 ) |format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
</text>
<!--{[%END-%]}-->
<!--{[%MACRO totalrow BLOCK-%]}-->
<text y="20" text-anchor="end" id="titlepage_calls_total" class="datarow">
<tspan x="5" id="titlepage_calls_total_title" text-anchor="start">Total:</tspan>
<tspan x="95" id="titlepage_calls_total_number"><!--{[% total_number %]}--><!--{[%#}-->0<!--{%]}--></tspan>
<tspan x="130" id="titlepage_calls_total_duration"><!--{[% total_duration|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="160" id="titlepage_calls_total_freetime"><!--{[% total_free_time|format('%d') %]}--><!--{[%#}-->0.0<!--{%]}--></tspan>
<tspan x="190" id="titlepage_calls_total_cost"><!--{[% ( total_cost / 100 )|format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
</text>
<!--{[%END-%]}-->
<!--{[%IF callsdata.size%]}-->
<!--{[% titlerow(page) -%]}-->
<!--{[% list_calls(callsdata, page, 'datarow', total, 'svg', row_vertical_interval) -%]}-->
<!--{[% adjustrow (total, page, 'totalrow', 'svg', row_vertical_interval, callsdata.size) -%]}-->
<!--{[%END%]}-->
</g>
</g>
<!--/page-->
<!--{[%END-%]}-->
<!--{[%MACRO midpage(callsdata, page) BLOCK-%]}-->
<!--{[%MACRO zonepage(callsdata, page) BLOCK-%]}-->
<!--page-->
<g id="midpage" display="none">
<title>MidPage</title>
<g id="zonepage" display="none">
<title>ZonePage</title>
<g y="15" x="10" width="195" height="150" id="midpage_invoicedetails" transform="translate(10, 15)" rows="15">
<g y="50" x="10" width="195" height="150" id="zonepage_invoicedetails" transform="translate(10, 50)" zonerows="20">
<!--{[%MACRO titlerow BLOCK-%]}-->
<text id="midpage_calls_title" text-anchor="end">
<tspan x="5" id="midpage_calls_number" text-anchor="start">#</tspan>
<tspan x="15" id="midpage_calls_zone" text-anchor="start">Zone</tspan>
<tspan x="95" id="midpage_calls_number">Number</tspan>
<tspan x="130" id="midpage_calls_duration">Duration</tspan>
<tspan x="160" id="midpage_calls_freetime">Free time</tspan>
<tspan x="190" id="midpage_calls_cost">Cost</tspan>
<!--path stroke="#888888" stroke-width="0.25" fill="none" d="m5,45l200,0"/>
<path stroke="#888888" stroke-width="0.25" fill="none" d="m5,245l200,0"/-->
<text id="zonepage_calls_title" text-anchor="end">
<tspan x="5" id="zonepage_calls_num" text-anchor="start">#</tspan>
<tspan x="15" id="zonepage_calls_zone" text-anchor="start">Zone</tspan>
<tspan x="95" id="zonepage_calls_number">Calls</tspan>
<tspan x="130" id="zonepage_calls_duration">Usage</tspan>
<tspan x="160" id="zonepage_calls_freetime">Free time</tspan>
<tspan x="190" id="zonepage_calls_cost">Amount EUR</tspan>
</text>
<!--{[%END-%]}-->
<!--{[%MACRO datarow(call) BLOCK-%]}-->
<text y="10" text-anchor="end" id="midpage_calls[%loop.count-%]" class="datarow">
<tspan x="5" id="midpage_calls_number[%loop.count-%]" text-anchor="start"><!--{[% call.0 %]}--><!--{[%#}-->1<!--{%]}--></tspan>
<text y="10" text-anchor="end" id="zonepage_calls[%loop.count-%]" class="datarow">
<tspan x="5" id="zonepage_calls_num[%loop.count-%]" text-anchor="start"><!--{[% call.0 %]}--><!--{[%#}-->1<!--{%]}--></tspan>
<!--{[%IF call.1; call = call.1; END%]}-->
<tspan x="15" id="midpage_calls_zone[%loop.count-%]" text-anchor="start"><!--{[% call.get_column('zone') %]}--><!--{[%#}-->Example zone<!--{%]}--></tspan>
<tspan x="95" id="midpage_calls_number[%loop.count-%]"><!--{[% call.get_column('number') %]}--><!--{[%#}-->0<!--{%]}--></tspan>
<tspan x="130" id="midpage_calls_duration[%loop.count-%]"><!--{[% call.get_column('duration')|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="160" id="midpage_calls_freetime[%loop.count-%]"><!--{[% call.get_column('free_time')|format('%d') %]}--><!--{[%#}-->0.0<!--{%]}--></tspan>
<tspan x="190" id="midpage_calls_cost[%loop.count-%]"><!--{[% ( call.get_column('cost') / 100 ) |format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
<tspan x="15" id="zonepage_calls_zone[%loop.count-%]" text-anchor="start"><!--{[% call.get_column('zone') %]}--><!--{[%#}-->Example zone<!--{%]}--></tspan>
<tspan x="95" id="zonepage_calls_number[%loop.count-%]"><!--{[% call.get_column('number') %]}--><!--{[%#}-->0<!--{%]}--></tspan>
<tspan x="130" id="zonepage_calls_duration[%loop.count-%]"><!--{[% call.get_column('duration')|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="160" id="zonepage_calls_freetime[%loop.count-%]"><!--{[% call.get_column('free_time')|format('%d') %]}--><!--{[%#}-->0.0<!--{%]}--></tspan>
<tspan x="190" id="zonepage_calls_cost[%loop.count-%]"><!--{[% ( call.get_column('cost') / 100 ) |format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
</text>
<!--{[%END-%]}-->
<!--{[%MACRO totalrow BLOCK-%]}-->
<text y="20" text-anchor="end" id="midpage_calls_total" class="datarow">
<tspan x="5" id="midpage_calls_total_title" text-anchor="start">Total:</tspan>
<tspan x="95" id="midpage_calls_total_number"><!--{[% total_number %]}--><!--{[%#}-->0<!--{%]}--></tspan>
<tspan x="130" id="midpage_calls_total_duration"><!--{[% total_duration|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="160" id="midpage_calls_total_freetime"><!--{[% total_free_time|format('%d') %]}--><!--{[%#}-->0.0<!--{%]}--></tspan>
<tspan x="190" id="midpage_calls_total_cost"><!--{[% ( total_cost / 100 )|format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
<text y="20" text-anchor="end" id="zonepage_calls_total" class="datarow">
<tspan x="5" id="zonepage_calls_total_title" text-anchor="start">Total:</tspan>
<tspan x="95" id="zonepage_calls_total_number"><!--{[% total_number %]}--><!--{[%#}-->0<!--{%]}--></tspan>
<tspan x="130" id="zonepage_calls_total_duration"><!--{[% total_duration|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="160" id="zonepage_calls_total_freetime"><!--{[% total_free_time|format('%d') %]}--><!--{[%#}-->0.0<!--{%]}--></tspan>
<tspan x="190" id="zonepage_calls_total_cost"><!--{[% ( total_cost / 100 )|format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
</text>
<!--{[%END-%]}-->
<!--{[% titlerow(page) -%]}-->
@ -175,41 +134,43 @@ g, text, tspan {
<!--{[%END-%]}-->
<!--{[%MACRO lastpage(callsdata, page) BLOCK-%]}-->
<!--{[%MACRO callpage(callsdata, page) BLOCK-%]}-->
<!--page-->
<g id="lastpage" display="none">
<title>LastPage</title>
<g y="15" x="10" width="195" height="150" id="lastpage_invoicedetails" transform="translate(10, 15)">
<g id="callpage" display="none">
<title>CallPage</title>
<g y="50" x="10" width="195" height="150" id="callpage_invoicedetails" transform="translate(10, 50)">
<!--{[%MACRO titlerow BLOCK-%]}-->
<text id="lastpage_calls_title" text-anchor="end">
<tspan x="5" id="lastpage_calls_number" text-anchor="start">#</tspan>
<tspan x="15" id="lastpage_calls_zone" text-anchor="start">Zone</tspan>
<tspan x="95" id="lastpage_calls_number">Number</tspan>
<tspan x="130" id="lastpage_calls_duration">Duration</tspan>
<tspan x="160" id="lastpage_calls_freetime">Free time</tspan>
<tspan x="190" id="lastpage_calls_cost">Cost</tspan>
<text id="callpage_calls_title" text-anchor="end">
<tspan x="5" id="callpage_calls_num" text-anchor="start">#</tspan>
<tspan x="15" id="callpage_calls_starttime" text-anchor="start">Start time</tspan>
<tspan x="70" id="callpage_calls_duration">Duration</tspan>
<tspan x="110" id="callpage_calls_destination">Destination</tspan>
<tspan x="150" id="callpage_calls_type">Type</tspan>
<tspan x="180" id="callpage_calls_zone" text-anchor="start">Zone/Detail</tspan>
<tspan x="200" id="callpage_calls_cost">Amount EUR</tspan>
</text>
<!--{[%END-%]}-->
<!--{[%MACRO datarow(call) BLOCK-%]}-->
<text y="10" text-anchor="end" id="lastpage_calls[%loop.count-%]" class="datarow">
<tspan x="5" id="lastpage_calls_number[%loop.count-%]" text-anchor="start"><!--{[% call.0 %]}--><!--{[%#}-->1<!--{%]}--></tspan>
<text y="10" text-anchor="end" id="callpage_calls[%loop.count-%]" class="datarow">
<tspan x="5" id="callpage_calls_num[%loop.count-%]" text-anchor="start"><!--{[% call.0 %]}--><!--{[%#}-->1<!--{%]}--></tspan>
<!--{[%IF call.1; call = call.1; END%]}-->
<tspan x="15" id="lastpage_calls_zone[%loop.count-%]" text-anchor="start"><!--{[% call.get_column('zone') %]}--><!--{[%#}-->Example zone<!--{%]}--></tspan>
<tspan x="95" id="lastpage_calls_number[%loop.count-%]"><!--{[% call.get_column('number') %]}--><!--{[%#}-->0<!--{%]}--></tspan>
<tspan x="130" id="lastpage_calls_duration[%loop.count-%]"><!--{[% call.get_column('duration')|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="160" id="lastpage_calls_freetime[%loop.count-%]"><!--{[% call.get_column('free_time')|format('%d') %]}--><!--{[%#}-->0.0<!--{%]}--></tspan>
<tspan x="190" id="lastpage_calls_cost[%loop.count-%]"><!--{[% ( call.get_column('cost') / 100 ) |format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
<tspan x="15" id="callpage_calls_start_time%loop.count-%]"><!--{[% call.get_column('start_time') %]}--><!--{[%#}-->0001/01/31 23:59:59<!--{%]}--></tspan>
<tspan x="70" id="callpage_calls_duration[%loop.count-%]"><!--{[% call.get_column('duration')|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="110" id="callpage_calls_destination[%loop.count-%]"><!--{[% call.get_column('destination').replace('(.*?)\d{4}$','$1****') %]}--><!--{[%#}-->+00000000****<!--{%]}--></tspan>
<tspan x="150" id="callpage_calls_type[%loop.count-%]"><!--{[% call.get_column('call_type') %]}--><!--{[%#}-->call<!--{%]}--></tspan>
<tspan x="180" id="callpage_calls_zone[%loop.count-%]" text-anchor="start"><!--{[% call.get_column('zone') _ '/' _ call.get_column('zone_detail') %]}--><!--{[%#}-->Example zone/Fixed<!--{%]}--></tspan>
<tspan x="200" id="callpage_calls_cost[%loop.count-%]"><!--{[% ( call.get_column('cost') / 100 ) |format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
</text>
<!--{[%END-%]}-->
<!--{[%MACRO totalrow BLOCK-%]}-->
<text y="20" text-anchor="end" id="lastpage_calls_total" class="datarow">
<tspan x="5" id="lastpage_calls_total_title" text-anchor="start">Total:</tspan>
<tspan x="95" id="lastpage_calls_total_number"><!--{[% total_number %]}--><!--{[%#}-->0<!--{%]}--></tspan>
<tspan x="130" id="lastpage_calls_total_duration"><!--{[% total_duration|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="160" id="lastpage_calls_total_freetime"><!--{[% total_free_time|format('%d') %]}--><!--{[%#}-->0.0<!--{%]}--></tspan>
<tspan x="190" id="lastpage_calls_total_cost"><!--{[% ( total_cost / 100 )|format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
<text y="20" text-anchor="end" id="callpage_calls_total" class="datarow">
<tspan x="5" id="callpage_calls_total_title" text-anchor="start">Total:</tspan>
<tspan x="95" id="callpage_calls_total_number"><!--{[% total_number %]}--><!--{[%#}-->0<!--{%]}--></tspan>
<tspan x="130" id="callpage_calls_total_duration"><!--{[% total_duration|format('%.3f') %]}--><!--{[%#}-->0.000<!--{%]}--></tspan>
<tspan x="160" id="callpage_calls_total_freetime"><!--{[% total_free_time|format('%d') %]}--><!--{[%#}-->0.0<!--{%]}--></tspan>
<tspan x="190" id="callpage_calls_total_cost"><!--{[% ( total_cost / 100 )|format('%.2f') %]}--><!--{[%#}-->0.00<!--{%]}--></tspan>
</text>
<!--{[%END-%]}-->
@ -247,6 +208,7 @@ g, text, tspan {
<!--{[%END-%]}-->
<!--{[%# show_pages(invoice_details,'title')-%]}-->
<!--{[%# show_pages('mid',3)-%]}-->
<!--{[%# show_pages('zone',3)-%]}-->
<!--{[%# show_pages('last')-%]}-->
<!--{[% show_pages( invoice_details,'all' )-%]}-->
<!--{[%invoice_details_calls = []%]}-->
<!--{[% show_pages( invoice_details_zones, invoice_details_calls, 'all' )-%]}-->

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 21 KiB

@ -219,6 +219,22 @@
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#reseller_details" href="#collapse_zones">[% c.loc('Balance details') %]</a>
</div>
<div class="accordion-body collapse" id="collapse_zones">
<div class="accordion-inner" style="height: 300px; overflow: auto;">
<span>
<a class="btn btn-primary btn-large" href="[% c.uri_for_action('/reseller/invoice', [contract.id]) %]">[% c.loc('Invoice Connections Fees')%] <i class="icon-edit"></i></a>
</span>
<div class="ngcp-separator"></div>
[%PROCESS 'invoice/invoice_details_zones_list.tt' %]
</div>
</div>
</div>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#reseller_details" href="#collapse_calls">[% c.loc('Balance details') %]</a>
@ -230,7 +246,7 @@
</span>
<div class="ngcp-separator"></div>
[%PROCESS 'invoice/invoice_details_list.tt' %]
[%PROCESS 'invoice/invoice_details_calls_list.tt' %]
</div>
</div>

Loading…
Cancel
Save