diff --git a/share/templates/invoice/invoice_template_aux.tt b/share/templates/invoice/invoice_template_aux.tt index 0b1a041cd5..e642684faa 100644 --- a/share/templates/invoice/invoice_template_aux.tt +++ b/share/templates/invoice/invoice_template_aux.tt @@ -3,6 +3,23 @@ [%USE date%] [% total = {perpage => [], global => {} } -%] +[%MACRO date_format(dateval) BLOCK%] +[%date.format(dateval,'%B')%] [%ordinate(date.format(dateval,'%e'))%] [%date.format(dateval,'%Y')%] +[%END%] + +[%MACRO ordinate(num) BLOCK -%] + [% IF num.search('(? 0 ) ? rows_interval_in : row_vertical_interval%] - [% row = get_row(data, rowtype) %] + [%IF rowtype == 'datarow' %] + [%row = datarow(data)%] + [%ELSIF rowtype == 'totalrow' %] + ===[%Dumper.dump(data)%] + [%row = totalrow( (pagelocal == pageslocalnum) ? data.global : data.perpage.${pagelocal} )%] + [%END%] [% IF tt_type == 'svg' -%] - [% y_re = '(?s)(<(?:text)[^>]*\s+y\s?=.*?)(\d+)(.*)' -%] + [% y_re = '(?s)(<(?:text)[^>]*\s+y\s*=.*?)([-\d\.,]+)(.*)' -%] [%END%] [% matches = row.match( y_re ) -%] [% IF matches.size > 0 -%] - [% y = matches.1 + ( rows_interval * ( rownumber - 1 ) ) %] + [% y_old = Math.int(matches.1) %] + [% y = y_old + ( rows_interval * ( rownumber - 1 ) ) %] [% row = matches.0 _ y _ matches.2 %] + [% matches_other = row.match('(<.*?\s+y\s*=.*?)([-\d\.,]+)', 1) %] + [% i = 0 %] + [%#matches_other[%Dumper.dump_html(matches_other)%] + [% WHILE i*2 < matches_other.size() %] + [%IF !matches_other.item(i*2).search(' invoice_details_zones.size() - 1 ? invoice_details_zones.size() - 1 : pagerowsend %] [% document_header()%] - [% zonepage( invoice_details_zones.slice( pagerowsstart, pagerowsend ), pagenum + 1, midzoneinterval ) -%] + [% zonepage( invoice_details_zones.slice( pagerowsstart, pagerowsend ), total, pagenum + 1, pagenum, allzonepages, midzoneinterval ) -%] [%#+1 because of 1 for titlepage %] - [% bgpage(pagenum + 1) -%] + [% bgpage(pagenum + 1, pagenum, allzonepages) -%] [% 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 %] + [% pagenum = 2 + allmidzonepages %] [% document_header()%] - [% zonepage( invoice_details_zones.slice( allzonerowsnumber - lastzonerows, allzonerowsnumber ), pagenum, midzoneinterval ) -%] - [% bgpage(pagenum) -%] + [% zonepage( invoice_details_zones.slice( allzonerowsnumber - lastzonerows ), total, pagenum, allzonepages, allzonepages, midzoneinterval ) -%] + [% bgpage(pagenum, allzonepages, allzonepages) -%] [% document_footer()%] [%END-%] [%END-%] [%IF ( pagetype == 'call' || pagetype=='all' )%] - [% pages = pagenum_in ? [ pagenum_in ] : [ 1 .. allcallpages ] %] + [% pages = pagenum_in ? [ pagenum_in ] : [ 1 .. allmidcallpages ] %] [%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, midcallinterval ) -%] + [% callpage( invoice_details_calls.slice( pagerowsstart, pagerowsend ), total, pagenum + 1 + allzonepages, pagenum, allcallpages, midcallinterval ) -%] [%#+1 because of 1 for titlepage %] - [% bgpage(pagenum + allzonepages + 1) -%] + [% bgpage(pagenum + 1 + allzonepages, pagenum, allcallpages ) -%] [% 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 %] + [% pagenum = 2 + allmidcallpages + ( allzonepages ? 1 : 0 ) %] [% document_header()%] - [% callpage( invoice_details_calls.slice( allcallrowsnumber - lastcallrows, allcallrowsnumber ), pagenum, midcallinterval ) -%] - [% bgpage(pagenum) -%] + [% callpage( invoice_details_calls.slice( allcallrowsnumber - lastcallrows ), total, pagenum, allcallpages, allcallpages, midcallinterval ) -%] + [% bgpage(pagenum, allcallpages, allcallpages) -%] [% document_footer()%] [%END-%] [%END-%] diff --git a/share/templates/invoice/invoice_template_editor_form.tt b/share/templates/invoice/invoice_template_editor_form.tt index 447c55350c..1604a426e4 100644 --- a/share/templates/invoice/invoice_template_editor_form.tt +++ b/share/templates/invoice/invoice_template_editor_form.tt @@ -36,6 +36,13 @@ function formSerialize(){ contract_id: '[%contract.id%]', });void(0);">[% c.loc('Load default')%] + + [% c.loc('Load saved')%] + +
+ + [% c.loc('Previewed SVG')%] + + + [% c.loc('Previewed PDF')%] + + + [% c.loc('Saved SVG')%] + + + [% c.loc('Saved PDF')%] + [%initial = 'default'%]