[REF] l10n_ch - refactor bank.py
[odoo/odoo.git] / addons / l10n_ch / report / bvr.mako
1 <html>
2 <head>
3        <style type="text/css">
4            @font-face {
5                 font-family: "bvrocrb";
6                 font-style: normal;
7                 font-weight: normal;
8                 src: url(${police_absolute_path('ocrbb.ttf')}) format("truetype");
9            }
10            .ocrbb{
11              text-align:right;
12              font-family:bvrocrb;
13              font-size:${str(company.bvr_scan_line_font_size or '0.0').replace(',','.')}pt;
14              position:absolute;top:${str(company.bvr_scan_line_vert or '0.0').replace(',','.')}mm;
15              left:${str(company.bvr_scan_line_horz or '0.0').replace(',','.')}mm;
16              z-index:4;
17              letter-spacing:str(company.bvr_scan_line_letter_spacing or '0.0').replace(',','.')
18            }
19         ${css}
20     </style>
21        </style>
22
23    </head>
24    <body topmargin="0px">
25        <script type="text/javascript">
26            function sortfunction(a, b){
27             return (a.offsetTop - b.offsetTop) ;
28            }
29            function place_element2() {
30                //This script was done to be inserted in any document mono or multi page some rounding problem may appear on mor than 10 page long report
31                try{
32                    //height of bvr in mm
33                    var xpos = 105 + ${company.bvr_delta_horz or '0'};
34                    //height of A4 page in bvr
35                    var a4height = 297 ;
36                    //should be insert a page
37                    var insert_page = false; //will insert a blank page if true
38                    // should we insert bvr background
39                    var insert_bvrimg = ${str(company.bvr_background).lower()};
40                    //horiz decalage
41                    var vert_decalage = ${company.bvr_delta_vert or '0'};
42                    // height of header
43                    var headheight = ${headheight()};
44                    //dpi resolution has found in wkhtmltopdf doc if you want to calculate it just create a div with one inch of width and retrieve is with in px
45                    var res = 94; 
46                    //we retriev all the bvr frame on the dom
47                    var els_node_list = document.getElementsByName('bvrframe');
48                    //we put them on an array
49                    var els = [];
50                    for(var i=0, len = els_node_list.length; i < len; i++)  
51                    {  
52                        els.push(els_node_list[i]);  
53                    }
54                    //we sort on y postiton values
55                    els.sort(sortfunction);
56                    for (var i=0; i<els.length; i++) {
57                       var el = els[i];
58                       var el_height_mm = el.offsetTop/(res/25.4);
59                       // we insert the white page only if the BVR in not alleready on a separated page
60                        //so we insert the white page only if the difference bettween the old posisition and the new posisition is < 297 mm
61                       if(insert_page){
62                              el_height_mm = el_height_mm + a4height;
63                       }
64                       
65                       if(el_height_mm % xpos){
66                           var el_xpos = Math.ceil(el_height_mm/a4height)*a4height;
67                           //We compute the page  position of the a4 page on wich is the element.
68                           // we substact the bvr height and the height of header*the number of pages and we add the vertical decalage
69                           var ypos = (el_xpos-xpos)-(Math.ceil(el_height_mm/a4height)*headheight);
70
71                           el.style.top = (ypos+vert_decalage)+"mm";
72                           el.style.position = "absolute";
73                  
74                       } 
75                       //This will propbely never happen but how knows ?
76                       else {
77                           var el_height_mm = el.offsetTop/(res/25.4);
78                           el.style.top = (el_height_mm+vert_decalage)+"mm";
79                           if(insert_page){
80                               el.style.top = el.style.top + a4height
81                           }
82                       }
83                       //we place the image if needed
84                       if(insert_bvrimg){
85                             img = document.getElementById("bvrimg_"+el.id);
86                             img.style.top = el.style.top;
87                             img.style.position = "absolute";
88                       }
89                    }
90                } catch(err){
91                //console.log(err)
92               //document.getElementById("debug").textContent = document.getElementById("debug").textContent +"<br/>"+'-ERROR-'+err;
93                }
94            }
95            window.onload=foo
96            function foo() {
97            place_element2();
98            
99            }
100        </script>
101        %for inv in objects :
102        <% setLang(inv.partner_id.lang) %>
103        <!--adresses + info block -->
104             <table class="dest_address"  style="position:absolute;top:6mm;left:15mm">
105                <tr><td ><b>${inv.partner_id.title.name or ''|entity}  ${inv.partner_id.name |entity}</b></td></tr>
106                <tr><td>${inv.address_invoice_id.street or ''|entity}</td></tr>
107                <tr><td>${inv.address_invoice_id.street2 or ''|entity}</td></tr>
108                <tr><td>${inv.address_invoice_id.zip or ''|entity} ${inv.address_invoice_id.city or ''|entity}</td></tr>
109                %if inv.address_invoice_id.country_id :
110                <tr><td>${inv.address_invoice_id.country_id.name or ''|entity} </td></tr>
111                %endif
112                %if inv.address_invoice_id.phone :
113                <tr><td>${_("Tel") |entity}: ${inv.address_invoice_id.phone|entity}</td></tr>
114                %endif
115                %if inv.address_invoice_id.fax :
116                <tr><td>${_("Fax") |entity}: ${inv.address_invoice_id.fax|entity}</td></tr>
117                %endif
118                %if inv.address_invoice_id.email :
119                <tr><td>${_("E-mail") |entity}: ${inv.address_invoice_id.email|entity}</td></tr>
120                %endif
121                %if inv.partner_id.vat :
122                <tr><td>${_("VAT") |entity}: ${inv.partner_id.vat|entity}</td></tr>
123                %endif
124            </table>
125        
126        <div style="position:absolute;top:60mm; left:20mm">
127            ${_('Invoice')} - ${inv.number or ''|entity}
128            <br/>
129            <br/>
130            ${_('Here is the BVR to allow you to pay the invoice %s - %s') % (inv.name or '', inv.number or '',)}
131            <br/>
132            ${_('Regards')}
133        </div>
134        
135        <div colspan="2" class="ocrbb">${mod10r('01'+str('%.2f' % inv.amount_total).replace('.','').rjust(10,'0'))}&gt;${_get_ref(inv)}+${inv.partner_bank_id.post_number.split('-')[0]+(str(inv.partner_bank_id.post_number.split('-')[1])).rjust(6,'0')+inv.partner_bank_id.post_number.split('-')[2]}&gt;</div>
136        <div id="cont_${inv.id}" style="padding-left:20mm;padding-top:0;padding-bottom:10;height:180mm">
137         <!-- Your communication message here -->
138        </div>
139     %if company.bvr_background:
140     <img name="bvrimg" id="bvrimg_${inv.id}" alt="bvr" src="${bvr_absolute_path()}" style="width:210mm;height:106mm;border:0;margin:0;position:absolute;top:0" />
141     %endif
142     <table name="bvrframe"  id="${inv.id}" style="width:210mm;height:106mm;border-collapse:collapse;padding-left:3mm;font-family:Helvetica;font-size:8pt;border-width:0px" border="0" CELLPADDING="0" CELLSPACING="0"> <!--border-width:1px;border-style:solid;border-color:black;-->
143         <tr style="height:16.933333mm;vertical-align:bottom;padding-bottom:3mm"><td style="width:60.14mm;padding-bottom:3mm"><div style="padding-left:3mm;">${inv.partner_bank_id and inv.partner_bank_id.print_bank and inv.partner_bank_id.bank and inv.partner_bank_id.bank.name or ''}</div></td><td style="width:60.96mm;padding-bottom:3mm"><div style="padding-left:3mm;">${inv.partner_bank_id and inv.partner_bank_id.print_bank and inv.partner_bank_id.bank and inv.partner_bank_id.bank.name or ''}</div></td><td style="width:88.9mm"></td></tr>
144         <tr style="height:12.7mm;vertical-align:bottom;padding-bottom:3mm"><td style="width:60.14mm;padding-bottom:3mm"><div style="padding-left:3mm;"><b>${user.company_id.partner_id.name}</b></div></td><td style="width:60.96mm;padding-bottom:3mm"><div style="padding-left:3mm;"><b>${user.company_id.partner_id.name}</b></div></td><td style="width:88.9mm"></td></tr>
145         <tr style="height:16.933333mm;vertical-align:bottom;padding-bottom:0"><td><table style="padding-left:3mm;font-family:Helvetica;font-size:8pt" height="100%"><tr style="vertical-align:top;padding-bottom:0"><td>${user.company_id.partner_id.address[0].street}<br/> ${user.company_id.partner_id.address[0].zip} ${user.company_id.partner_id.address[0].city}</td></tr><tr style="vertical-align:bottom;padding-bottom:0"><td><div style="padding-left:30.48mm;">${inv.partner_bank_id.print_account and inv.partner_bank_id.post_number or ''}</div></td></tr></table></td><td style="padding-left:3mm"><table style="padding-left:3mm;font-family:Helvetica;font-size:8pt" height="100%"><tr style="vertical-align:top;padding-bottom:0"><td>${user.company_id.partner_id.address[0].street}<br/>${user.company_id.partner_id.address[0].zip} ${user.company_id.partner_id.address[0].city}</td></tr><tr style="vertical-align:bottom;padding-bottom:0"><td><div style="padding-left:30.48mm;">${inv.partner_bank_id.print_account and inv.partner_bank_id.post_number or ''}</div></td></tr></table></td><td style="text-align: right;padding-right:4mm;padding-bottom:8mm;font-size:11pt">${_space(_get_ref(inv))}</td></tr>
146         <tr style="height:8.4666667mm;vertical-align:bottom;padding-bottom:0"> <td><table  style="width:100%" CELLPADDING="0" CELLSPACING="0"><td  style="width:4mm"></td><td style="width:40mm;text-align: right" >${_space(('%.2f' % inv.amount_total)[:-3], 1)}</td><td style="width:6mm"></td><td style="width:10mm;text-align: right">${ _space(('%.2f' % inv.amount_total)[-2:], 1)}</td><td style="width:3mm;text-align: right"></td></table></td><td><table  style="width:100%" CELLPADDING="0" CELLSPACING="0"><td  style="width:4mm"></td><td style="width:40mm;text-align: right" >${_space(('%.2f' % inv.amount_total)[:-3], 1)}</td><td style="width:6mm"></td><td style="width:10mm;text-align: right">${ _space(('%.2f' % inv.amount_total)[-2:], 1)}</td><td style="width:3mm;text-align: right"></td></table></td><td></td></tr>
147         <tr style="height:21.166667mm"><td></td><td></td><td></td></tr>
148         <tr style="height:8.4666667mm"> <td></td><td></td><td></td></tr>
149         <tr style="height:21.166667mm;vertical-align:top"><td></td><td></td></tr>
150     </table>
151     %endfor
152 </body>
153 </html>