|
|
|
|
@ -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)(<text[^>]*\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)<g\s+[^>]*(?:\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 <g y and heights supposed to be taken and from them attempted to define free place for data row%]
|
|
|
|
|
[% IF tt_type == 'svg' -%]
|
|
|
|
|
[% page_rows_re = '(?s)<g [^>]*\s+\s?=.*?(\d+)[^>]*>' -%]
|
|
|
|
|
[%END%]
|
|
|
|
|
[%page_rows_re%]
|
|
|
|
|
[%END%]
|
|
|
|
|
|
|
|
|
|
[%MACRO get_row(data, rowtype) BLOCK -%]
|
|
|
|
|
[%#use this macro until no symbolic references in tt %]
|
|
|
|
|
[%#data can be empty, if we just need y - it doesn't depend on data %]
|
|
|
|
|
@ -58,22 +35,22 @@
|
|
|
|
|
[%page%]
|
|
|
|
|
[%END%]
|
|
|
|
|
|
|
|
|
|
[%MACRO adjustrow(data, page, rowtype, tt_type, row_vertical_interval, rownumber) BLOCK -%]
|
|
|
|
|
[%MACRO adjustrow(data, page, rowtype, tt_type, rows_interval_in, rownumber) BLOCK -%]
|
|
|
|
|
[%# y_re = row_y_re(tt_type) %]
|
|
|
|
|
|
|
|
|
|
[% rows_interval = ( rows_interval_in > 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)<g\s+[^>]*(?:\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)<g\s+[^>]*(?:\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-%]
|
|
|
|
|
|