From dbf2b5414aa39b76b1184470a4ad84241f48bf93 Mon Sep 17 00:00:00 2001 From: Irina Peshinskaya Date: Sun, 13 Apr 2014 21:42:02 +0300 Subject: [PATCH] MT#5879 Templates alignments. --- lib/NGCP/Panel/Controller/Reseller.pm | 15 ++- share/static/js/libs/svg-edit/sanitize.js | 2 +- share/templates/invoice/invoice.tt | 25 ++--- .../invoice/invoice_details_calls_list.tt | 19 ++-- .../templates/invoice/invoice_template_aux.tt | 98 ++++++++----------- .../templates/invoice/invoice_template_svg.tt | 60 ++++++------ share/templates/reseller/details.tt | 8 +- 7 files changed, 113 insertions(+), 114 deletions(-) diff --git a/lib/NGCP/Panel/Controller/Reseller.pm b/lib/NGCP/Panel/Controller/Reseller.pm index 7a5982dabf..4d9f9eac52 100644 --- a/lib/NGCP/Panel/Controller/Reseller.pm +++ b/lib/NGCP/Panel/Controller/Reseller.pm @@ -11,10 +11,12 @@ use NGCP::Panel::Utils::Contract; use NGCP::Panel::Utils::DateTime; use NGCP::Panel::Utils::Message; use NGCP::Panel::Utils::Navigation; + use NGCP::Panel::Form::InvoiceTemplate::Basic; use NGCP::Panel::Model::DB::InvoiceTemplate; use NGCP::Panel::Utils::InvoiceTemplate; use JSON; +use Number::Phone; sub auto { my ($self, $c) = @_; @@ -471,11 +473,20 @@ sub invoice_details_calls :Chained('invoice_details_zones') :PathPart('') :Captu stime => $stime, etime => $etime, ); + #$invoice_details_calls #TODO: FAKE FAKE FAKE FAKE my $invoice_details_calls_raw = $invoice_details_calls; + #foreach my $call(@$invoice_details_calls_raw) { + # next unless($call->source_cli && $call->source_cli =~ /^\d{5,}$/ && + # $call->destination_user_in && $call->destination_user_in =~ /^\d{5,}$/); + # my $s = Number::Phone->new($call->source_cli); + # my $d = Number::Phone->new($call->destination_user_in); + # next unless($s && $d); + #} + $invoice_details_calls = [$invoice_details_calls_raw->all()]; my $i = 1; - $invoice_details_calls = [map{[$i++,$_]} (@$invoice_details_calls) x 21]; + $invoice_details_calls = [map{[$i++,$_]} (@$invoice_details_calls) x 1]; $c->stash( invoice_details_calls => $invoice_details_calls ); $c->stash( invoice_details_calls_raw => $invoice_details_calls_raw ); } @@ -695,7 +706,7 @@ sub invoice_template_delete :Chained('base') :PathPart('invoice_template/delete' $c->forward( 'invoice_template_list' ); } -sub invoice_template_list_data :Chained('invoice_details_zones') :PathPart('') :CaptureArgs(0) { +sub invoice_template_list_data :Chained('invoice_details_calls') :PathPart('') :CaptureArgs(0) { my ($self, $c) = @_; $c->log->debug('invoice_template_list_data'); my($validator,$backend,$in,$out); diff --git a/share/static/js/libs/svg-edit/sanitize.js b/share/static/js/libs/svg-edit/sanitize.js index 417941cc82..f4e4feaac1 100644 --- a/share/static/js/libs/svg-edit/sanitize.js +++ b/share/static/js/libs/svg-edit/sanitize.js @@ -36,7 +36,7 @@ var svgWhiteList_ = { "feGaussianBlur": ["class", "color-interpolation-filters", "id", "requiredFeatures", "stdDeviation"], "filter": ["class", "color-interpolation-filters", "filterRes", "filterUnits", "height", "id", "primitiveUnits", "requiredFeatures", "width", "x", "xlink:href", "y"], "foreignObject": ["class", "font-size", "height", "id", "opacity", "requiredFeatures", "style", "transform", "width", "x", "y"], - "g": ["class", "clip-path", "clip-rule", "id", "display", "fill", "fill-opacity", "fill-rule", "filter", "mask", "opacity", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "transform", "font-family", "font-size", "font-style", "font-weight", "text-anchor", "rows"], + "g": ["class", "clip-path", "clip-rule", "id", "display", "fill", "fill-opacity", "fill-rule", "filter", "mask", "opacity", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "transform", "font-family", "font-size", "font-style", "font-weight", "text-anchor", "rows", "zone-rows", "call-rows", "rows-interval", "zone-rows-interval", "call-rows-interval"], "image": ["class", "clip-path", "clip-rule", "filter", "height", "id", "mask", "opacity", "requiredFeatures", "style", "systemLanguage", "transform", "width", "x", "xlink:href", "xlink:title", "y"], "line": ["class", "clip-path", "clip-rule", "fill", "fill-opacity", "fill-rule", "filter", "id", "marker-end", "marker-mid", "marker-start", "mask", "opacity", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "transform", "x1", "x2", "y1", "y2"], "linearGradient": ["class", "id", "gradientTransform", "gradientUnits", "requiredFeatures", "spreadMethod", "systemLanguage", "x1", "x2", "xlink:href", "y1", "y2"], diff --git a/share/templates/invoice/invoice.tt b/share/templates/invoice/invoice.tt index 236adfbb4f..0a57814d43 100644 --- a/share/templates/invoice/invoice.tt +++ b/share/templates/invoice/invoice.tt @@ -85,7 +85,7 @@ var uriForAction = function( data, type ){
@@ -116,30 +116,31 @@ var uriForAction = function( data, type ){
-
+
[% clearHelper(); - helper.name = c.loc('Invoice Details'); + helper.name = c.loc('Invoice Calls'); helper.dt_columns = [ + { name => 'start_time', title => c.loc('Start time'), search=> 1 }, + { name => 'duration', title => c.loc('Duration') }, + { name => 'destination_user', title => c.loc('Destination') }, + { name => 'call_type', title => c.loc('Type') }, { 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') }, + { name => 'source_customer_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 ] ) ; + helper.name_single = c.loc('Invoice calls'); + helper.identifier = 'invoice_details_calls_raw'; + helper.ajax_uri = c.uri_for_action( '/reseller/invoice_details_calls_ajax', [ contract.id ] ) ; initHelperAuto(); PROCESS 'helpers/datatables.tt'; -%] - [%PROCESS 'invoice/invoice_details_zones_list.tt' %] + [%PROCESS 'invoice/invoice_details_calls_list.tt' %]
diff --git a/share/templates/invoice/invoice_details_calls_list.tt b/share/templates/invoice/invoice_details_calls_list.tt index 4fd1088431..4fab71f731 100644 --- a/share/templates/invoice/invoice_details_calls_list.tt +++ b/share/templates/invoice/invoice_details_calls_list.tt @@ -1,4 +1,6 @@ [%# USE Dumper %] +[% USE date %] +[% USE Math %] [%# Dumper.dump(invoice_details_zones)%] [%# invoice_details_zones.size%] @@ -12,31 +14,28 @@ [% c.loc('Type') %] [% c.loc('Zone/Details') %] [% c.loc('Cash') %] - [%# Dumper.dump_html(invoice_details_zones.as_query)%] - [% FOR call IN invoice_details_zones -%] + [% FOR call IN invoice_details_calls -%] [%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') %] + [% total_cost = total_cost + call.get_column('source_customer_cost') / 100 %] [% row_number %] -
[% call.get_column('start_time') %]
+
[% date.format(Math.int(call.get_column('start_time')),'%Y-%m-%d %H:%M:%S') %]
[% call.get_column('duration')|format('%.3f') %]
-
[% call.get_column('destination')%][%#to mscro or view .replace('(.*?)\d{4}$','$1****') %]
+
[% call.get_column('destination_user_in').replace('(.*?)\d{4}$','$1****') %][%#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 ) %]
+ [% call.get_column('zone') _ '/' _ call.get_column('zone_detail') %] +
[% money_format( call.get_column('source_customer_cost') / 100 ) %]
[%END%] [% c.loc('Total') %] -
[% total_number %]
[% total_duration | format('%.3f') %]
-
[% total_free_time | format('%d')%]
-
[% money_format( total_cost / 100 ) %]
+
[% money_format( total_cost ) %]
diff --git a/share/templates/invoice/invoice_template_aux.tt b/share/templates/invoice/invoice_template_aux.tt index 9b72309054..0b1a041cd5 100644 --- a/share/templates/invoice/invoice_template_aux.tt +++ b/share/templates/invoice/invoice_template_aux.tt @@ -1,14 +1,8 @@ [%USE Dumper%] [%USE Math%] +[%USE date%] [% total = {perpage => [], global => {} } -%] -[%MACRO row_y_re(tt_type) BLOCK -%] - [% IF tt_type == 'svg' -%] - [% y_re = '(?s)(]*\s+y\s?=.*?)(\d+)(.*)' -%] - [%END%] - [%y_re%] -[%END%] - [%MACRO if(prefix, value) BLOCK -%] [%value_clear = value.replace('[ ,]','')%] [% IF value_clear -%] @@ -16,23 +10,6 @@ [%END%] [%END%] -[%MACRO page_rows_re(tt_type) BLOCK -%] - [% IF tt_type == 'svg' -%] - [%# page_rows_re = '(?si)]*(?:\s+rows\s*=.*?(\d+))?[^>]*\s+id\s*=.*?(?:page_invoicedetails)[^>]*(?:\s+rows\s*=.*?(\d+))?[^>]*>' -%] - [% page_rows_re = 'rows="([0-9]+)"' -%] - [%END%] - [%page_rows_re%] -[%END%] - -[%MACRO page_g_y_and_height_re(tt_type) BLOCK -%] -[%#macro intended to be used when no rows specified in data table grouping g %] -[%#all 0 ) ? rows_interval_in : row_vertical_interval%] [% row = get_row(data, rowtype) %] [% IF tt_type == 'svg' -%] [% y_re = '(?s)(<(?:text)[^>]*\s+y\s?=.*?)(\d+)(.*)' -%] [%END%] [% matches = row.match( y_re ) -%] [% IF matches.size > 0 -%] - [% y = matches.1 + ( row_vertical_interval * ( rownumber - 1 ) ) %] + [% y = matches.1 + ( rows_interval * ( rownumber - 1 ) ) %] [% row = matches.0 _ y _ matches.2 %] [%END -%] [%row%] [%END -%] -[%MACRO list_calls(callsdata, page, rowtype, total, tt_type, row_vertical_interval) BLOCK-%] +[%MACRO list_zones(callsdata, page, rowtype, total, tt_type, rows_interval) BLOCK-%] [% FOR call IN callsdata -%][%#invoice_details%] [% total.global.number = total.number + call.get_column('number') -%] [% total.global.duration = total.duration + call.get_column('duration') -%] @@ -83,17 +60,23 @@ [% total.perpage.${page}.duration = total.duration + call.get_column('duration') -%] [% total.perpage.${page}.free_time = total.free_time + call.get_column('free_time') -%] [% total.perpage.${page}.cost = total.cost + call.get_column('cost') -%] - [% adjustrow(call, page, rowtype, tt_type, row_vertical_interval, loop.count) -%] + [% adjustrow(call, page, rowtype, tt_type, rows_interval, loop.count) -%] + [%END -%] +[%END -%] +[%MACRO list_calls(callsdata, page, rowtype, total, tt_type, rows_interval) BLOCK-%] + [% FOR call IN callsdata -%][%#invoice_details%] + [% total.global.duration = total.duration + call.get_column('duration') -%] + [% total.global.cost = total.cost + call.get_column('source_customer_cost') -%] + [% total.perpage.${page}.duration = total.duration + call.get_column('duration') -%] + [% total.perpage.${page}.cost = total.cost + call.get_column('source_customer_cost') -%] + [% adjustrow(call, page, rowtype, tt_type, rows_interval, loop.count) -%] [%END -%] [%END -%] -[%MACRO get_page_zonerows_number(pagetype, tt_type, row_vertical_interval) BLOCK-%] - [%#doesn't work %] - [% page_zonerows_re = page_zonerows_re(tt_type) %] - +[%MACRO get_page_rows_number(pagetype, tt_type, rows_type) BLOCK-%] [% IF tt_type == 'svg' -%] - [%# page_rows_re = '(?si)]*(?:\s+rows\s*=.*?(\d+))?[^>]*\s+id\s*=.*?(?:page_invoicedetails)[^>]*(?:\s+rows\s*=.*?(\d+))?[^>]*>' -%] - [% page_rows_re = 'zonerows="([0-9]+)"' -%] + [% rows_type = rows_type ? rows_type _ '-' : '' %] + [% page_rows_re = rows_type _ 'rows="([0-9]+)"' -%] [%END%] [% page = get_page(pagetype) %] @@ -104,29 +87,30 @@ [%rows%] [%END -%] -[%MACRO get_page_callrows_number(pagetype, tt_type, row_vertical_interval) BLOCK-%] - [%#doesn't work %] - [% page_rows_re = page_rows_re(tt_type) %] - +[%MACRO get_page_interval(pagetype, tt_type, interval_type) BLOCK-%] [% IF tt_type == 'svg' -%] - [%# page_rows_re = '(?si)]*(?:\s+rows\s*=.*?(\d+))?[^>]*\s+id\s*=.*?(?:page_invoicedetails)[^>]*(?:\s+rows\s*=.*?(\d+))?[^>]*>' -%] - [% page_rows_re = 'callrows="([0-9]+)"' -%] + [% interval_type = interval_type ? interval_type _ '-' : '' %] + [% page_interval_re = interval_type _ 'rows-interval="([0-9]+)"' -%] + ==[%page_interval_re%]== [%END%] [% page = get_page(pagetype) %] - [% matches = page.match( page_rows_re ) -%] + [% matches = page.match( page_interval_re ) -%] - [%rows = matches.0 || matches.1 %] - [%rows = Math.int(rows)%] - [%rows%] + [%interval = matches.0 || matches.1 %] + [%interval = Math.int(rows)%] + [%interval%] [%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 %] + [% titlezonerows = get_page_rows_number('titlepage','svg','zone') %] + [% midzonerows = get_page_rows_number('zonepage','svg') %] + [% titlezoneinterval = get_page_interval('titlepage','svg','zone') %] + [% midzoneinterval = get_page_interval('zonepage','svg') %] + [% midzonerows = get_page_rows_number('zonepage','svg') %] + [% midzonerows = ( midzonerows < 1 ) ? 30 : midzonerows %] [% allzonepages = ( (allzonerowsnumber - titlezonerows) / midzonerows )|format('%d') %] [% allmidzonerows = allzonepages * midzonerows %] @@ -134,9 +118,11 @@ [% allcallrowsnumber = invoice_details_calls.size() %] - [% titlecallrows = get_page_callrows_number('titlepage','svg') %] - [% midcallrows = get_page_callrows_number('callpage','svg') %] + [% titlecallrows = get_page_rows_number('titlepage','svg','call') %] + [% midcallrows = get_page_rows_number('callpage','svg') %] [% midcallrows = ( midcallrows < 1 ) ? 30 : midcallrows %] + [% titlecallinterval = get_page_interval('titlepage','svg', 'call') %] + [% midcallinterval = get_page_interval('callpage','svg') %] [% allcallpages = ( (allcallrowsnumber - titlecallrows) / midcallrows )|format('%d') %] [% allmidcallrows = allcallpages * midcallrows %] [% lastcallrows = allcallrowsnumber - allmidcallrows - titlecallrows %] @@ -150,7 +136,9 @@ ( 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 + pagenum, + titlezoneinterval + titlecallinterval ) -%] [% bgpage(pagenum) -%] [% document_footer()%] @@ -161,7 +149,7 @@ [% pagerowsstart = titlezonerows + midzonerows * ( pagenum - 1 )%] [% pagerowsend = titlezonerows + midzonerows * pagenum - 1 %] [% document_header()%] - [% zonepage( invoice_details_zones.slice( pagerowsstart, pagerowsend ), pagenum + 1 ) -%] + [% zonepage( invoice_details_zones.slice( pagerowsstart, pagerowsend ), pagenum + 1, midzoneinterval ) -%] [%#+1 because of 1 for titlepage %] [% bgpage(pagenum + 1) -%] [% document_footer()%] @@ -170,7 +158,7 @@ [%#2 because zonepages started from 1, not from 0, and we need add 1 for titlepage %] [% pagenum = 2 + allzonepages %] [% document_header()%] - [% zonepage( invoice_details_zones.slice( allzonerowsnumber - lastzonerows, allzonerowsnumber ), pagenum ) -%] + [% zonepage( invoice_details_zones.slice( allzonerowsnumber - lastzonerows, allzonerowsnumber ), pagenum, midzoneinterval ) -%] [% bgpage(pagenum) -%] [% document_footer()%] [%END-%] @@ -181,7 +169,7 @@ [% pagerowsstart = titlecallrows + midcallrows * ( pagenum - 1 )%] [% pagerowsend = titlecallrows + midcallrows * pagenum - 1 %] [% document_header()%] - [% callpage( invoice_details_calls.slice( pagerowsstart, pagerowsend ), pagenum + 1 ) -%] + [% callpage( invoice_details_calls.slice( pagerowsstart, pagerowsend ), pagenum + 1, midcallinterval ) -%] [%#+1 because of 1 for titlepage %] [% bgpage(pagenum + allzonepages + 1) -%] [% document_footer()%] @@ -190,7 +178,7 @@ [%#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 ) -%] + [% callpage( invoice_details_calls.slice( allcallrowsnumber - lastcallrows, allcallrowsnumber ), pagenum, midcallinterval ) -%] [% bgpage(pagenum) -%] [% document_footer()%] [%END-%] diff --git a/share/templates/invoice/invoice_template_svg.tt b/share/templates/invoice/invoice_template_svg.tt index 4f6a306526..9363255734 100644 --- a/share/templates/invoice/invoice_template_svg.tt +++ b/share/templates/invoice/invoice_template_svg.tt @@ -27,6 +27,9 @@ g, text, tspan { .bgpage{ font-size:2pt; } +.widedatarow tspan{ + font-size:2pt; +} ]]> @@ -86,7 +89,7 @@ g, text, tspan { - + ZonePage @@ -105,7 +108,7 @@ g, text, tspan { - + 1 Example zone @@ -125,8 +128,8 @@ g, text, tspan { - - + + @@ -134,50 +137,48 @@ g, text, tspan { - + CallPage - + - # - Start time - Duration - Destination - Type - Zone/Detail - Amount EUR + # + Start time + Duration + Destination + Type + Zone/Detail + Amount EUR - - 1 + + 1 - 0001/01/31 23:59:59 - 0.000 - +00000000**** - call - Example zone/Fixed - 0.00 + 0001-01-31 23:59:59 + 0.000 + +00000000**** + call + Example zone/Fixed + 0.00 - Total: - 0 - 0.000 - 0.0 - 0.00 + Total: + 0.000 + 0.00 - - + + @@ -191,7 +192,7 @@ g, text, tspan { - [%provider.company%] [%if(', ', provider.street )%] [%if(', ', provider.postcode _ ' ' _ provider.city _ ' ' _ provider.country)%] + [%provider.company%] [%if(', ', provider.street )%] [%if(', ', provider.postcode _ ' ' _ provider.city _ ' ' _ provider.country ) %] [%if('FN ', provider.fn )%] [%if('VAT ', provider.vat )%] [%provider.atu%] [%if('IBAN ', provider.iban )%] [%if('BIC ', provider.bic )%] [%if('Phone: ', provider.phone _' ' _ provider.mobile)%] [%if('Fax: ', provider.fax)%] [%provider.url%] [%provider.email%] @@ -210,5 +211,4 @@ g, text, tspan { - diff --git a/share/templates/reseller/details.tt b/share/templates/reseller/details.tt index ce8294f132..baad03126f 100644 --- a/share/templates/reseller/details.tt +++ b/share/templates/reseller/details.tt @@ -221,23 +221,23 @@