Advertisement
Guest User

ERPNext Custom Print

a guest
Dec 8th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.  
  3. function addRow() {
  4.             var table = document.getElementById("container");
  5.             var heig = table.offsetHeight;
  6.             var count = "{{ doc.entries|length }}";
  7.             var rowCount = table.rows.length;
  8.             var cont2 = document.getElementById("container2")
  9.             var row = table.insertRow(rowCount);
  10.             var cell1 = row.insertCell(0);
  11.             var cell2 = row.insertCell(1);
  12.             var cell3 = row.insertCell(2);
  13.             var cell4 = row.insertCell(3);
  14.             var cell5 = row.insertCell(4);
  15.             var cell6 = row.insertCell(5);
  16.             var controll = document.getElementById("test");
  17.             controll = "1";
  18.            
  19.             if (heig < 560 ){            
  20.             row.className = "dontdo";
  21.             cell1.innerHTML = "{{ item.idx }}";
  22.             cell2.innerHTML = "{{ item.item_code }}";
  23.             cell3.innerHTML = "{{ item.item_name }}<br>{{ item.item_description }}";
  24.             cell4.innerHTML = "{{ item.qty }}";
  25.             cell5.innerHTML = '{{ item.get_formatted("price_list_rate") }}{%- if item.discount_percentage -%}<br>- {{ item.discount_percentage }} %{%- endif -%}';
  26.             cell6.innerHTML = '{{ item.get_formatted("amount") }}';
  27.             controll.innerHTML = "1"
  28.             }else if (heig > 560){
  29.             if (controll == 1 ){
  30.             cont2.innerHTML = '</table><br><br><br><br><br><br><table  width="100%" id="container3"><thead style="border-top:1px solid #DDDDDD;border-bottom:1px solid #DDDDDD;"<tr><th width="5%">Pos.</b></th><th width="10%">Art. Nr.</b></th><th width="54%">Beschreibung</b></th><th width="7%" class="text-right">Menge</th><th width="12%" class="text-right">Preis</th><th width="12%" class="text-right">Gesamt</th></tr></thead>'
  31.             var table2 = document.getElementById("container3");
  32.             var rowCount2 = table2.rows.length;
  33.             var row2 = table2.insertRow(rowCount2);
  34.             var cell1_1 = row2.insertCell(0);
  35.             var cell2_2 = row2.insertCell(1);
  36.             var cell3_3 = row2.insertCell(2);
  37.             var cell4_4 = row2.insertCell(3);
  38.             var cell5_5 = row2.insertCell(4);
  39.             var cell6_6 = row2.insertCell(5);
  40.             row2.className = "break";
  41.             cell1_1.innerHTML = "{{ item.idx }}";
  42.             cell2_2.innerHTML = "{{ item.item_code }}";
  43.             cell3_3.innerHTML = "{{ item.item_name }}<br>{{ item.item_description }}";
  44.             cell4_4.innerHTML = "{{ item.qty }}";
  45.             cell5_5.innerHTML = '{{ item.get_formatted("price_list_rate") }}{%- if item.discount_percentage -%}<br>- {{ item.discount_percentage }} %{%- endif -%}';
  46.             cell6_6.innerHTML = '{{ item.get_formatted("amount") }}';
  47.             controll.innerHTML = "2";
  48.             }else if (controll == 2){
  49.             var table2 = document.getElementById("container3");
  50.             var rowCount2 = table2.rows.length;
  51.             var row2 = table2.insertRow(rowCount2);
  52.             var cell1_1 = row2.insertCell(0);
  53.             var cell2_2 = row2.insertCell(1);
  54.             var cell3_3 = row2.insertCell(2);
  55.             var cell4_4 = row2.insertCell(3);
  56.             var cell5_5 = row2.insertCell(4);
  57.             var cell6_6 = row2.insertCell(5);
  58.             row2.className = "dontdo";
  59.             cell1_1.innerHTML = "{{ item.idx }}";
  60.             cell2_2.innerHTML = "{{ item.item_code }}";
  61.             cell3_3.innerHTML = "{{ item.item_name }}<br>{{ item.item_description }}";
  62.             cell4_4.innerHTML = "{{ item.qty }}";
  63.             cell5_5.innerHTML = '{{ item.get_formatted("price_list_rate") }}{%- if item.discount_percentage -%}<br>- {{ item.discount_percentage }} %{%- endif -%}';
  64.             cell6_6.innerHTML = '{{ item.get_formatted("amount") }}';
  65.             controll.innerHTML = "2";
  66.             }
  67.            
  68.            
  69.             }
  70.            
  71.            
  72.  
  73.         }
  74.  
  75. </script>
  76. <!--
  77. cell1.innerHTML =;
  78.  
  79.            
  80.             cell2.innerHTML = rowCount + 1;
  81.  
  82.             var cell3 = row.insertCell(2);
  83.             -->
  84.  
  85.  
  86. <style>
  87.     .print-format table, .print-format tr,
  88.     .print-format td, .print-format div, .print-format p {
  89.         font-family: Helvetica;
  90.         line-height: 200%;
  91.         vertical-align: middle;
  92.     }
  93.     .break
  94.     {
  95.     page-break-after: always;
  96.     page-break-before: always;
  97.     page-break-inside: avoid;
  98.     border-top: none;
  99.     border-bottom:1px solid #DDDDDD !important;
  100.     }
  101.     .dontdo
  102.     {
  103.     page-break-after: avoid;
  104.     page-break-before: avoid;
  105.     page-break-inside: avoid;
  106.     border-top: none;
  107.     border-bottom:1px solid #DDDDDD !important;
  108.         }
  109.  
  110. @media print and (width: 21cm) and (height: 29.7cm) {
  111.         @page {
  112.             margin: 2cm;
  113.         }
  114.     }
  115.    
  116.    
  117. </style>
  118.  
  119. <!-- 560 px dürfen es sein -->
  120.  
  121. <body class="abstand" onLoad="">
  122. <table width="100%">
  123. <tr>
  124.     <td width="60%">
  125.         <p style="line-height:145%;">{{ doc.customer_name }}<br>{{ doc.address_display }}<br>
  126.         <div id="test" style="display:none;"></div>
  127.         </p>
  128.        
  129.     </td>
  130.     <td width="40%">
  131.         <!-- Rechnungsnummer und so -->
  132.        
  133.         <table style="line-height:145%;" width="100%">
  134.         <tr>
  135.             <td width="50%">Rechnungsnr.</td>
  136.             <td width="50%" style="text-align:right;">{{ doc.name }}</td>
  137.         </tr>
  138.                
  139.         </table>
  140.     </td>
  141. </tr>
  142. </table>
  143.  
  144. <br><br>
  145. <table width="100%">
  146.     <tr>
  147.         <td width="50%">
  148.     <div id="Rechnung">
  149.     </div>
  150.        
  151.             <big><big><big><big>Rechnung</big></big></big></big>
  152.         </td>
  153.         <td width="50%" style="text-align:right; valign:top;">
  154.             <b>Datum:</b> {{ doc.get_formatted("posting_date") }}<br>
  155.         </td>
  156.     </tr>
  157. </table>
  158.  
  159. <br><br>
  160. <table class="" width="100%" id="container">
  161.     <thead style="border-top:1px solid #DDDDDD;border-bottom:1px solid #DDDDDD;">
  162.         <tr>
  163.             <th width="5%">Pos.</b></th>
  164.             <th width="10%">Art. Nr.</b></th>
  165.             <th width="54%">Beschreibung</b></th>
  166.             <th width="7%" class="text-right">Menge</th>
  167.             <th width="12%" class="text-right">Preis</th>
  168.             <th width="12%" class="text-right">Gesamt</th>
  169.         </tr>
  170.     </thead>
  171.    
  172.    
  173.          {%- for item in doc.entries -%}
  174.         <div onLoad="addRow()" id="container2">
  175.         <!-- content goes here -->
  176.        
  177.         </div>     
  178.        
  179.        
  180.          {%- endfor -%}    
  181.        
  182.         <!--<tr style="border-top: none; border-bottom:1px solid #DDDDDD !important;">
  183.             <td>{{ item.idx }}</td>
  184.             <td>
  185.                 {{ item.item_code }}
  186.             </td>
  187.             <td>{{ item.item_name }}<br>{{ item.description }}</td>
  188.             <td class="text-right">{{ item.qty }}</td>
  189.             <td class="text-right">{{ item.get_formatted("price_list_rate") }}{%- if item.discount_percentage -%}<br>- {{ item.discount_percentage }} %{%- endif -%}
  190. </td>
  191.             <td class="text-right">{{ item.get_formatted("amount") }}</td>
  192.         </tr>
  193.         -->
  194.        
  195.    
  196.  
  197. </table>
  198.  
  199. <table width="100%" padding="0" margin="0">
  200. <tr>
  201. <td width="50%" style="padding:0px !important;">
  202. <br>
  203. <table width="100%">
  204. <tr>
  205. <td width="40%">Lieferbedingungen</td>
  206. <td width="60%">{{ doc.shipping_rule }}</td>
  207. </tr>
  208. <tr>
  209. <td width="40%">Zahlungsbedingungen</td>
  210. <td width="60%">{{ doc.mode_of_payment }}</td>
  211. </tr>
  212. <tr>
  213. <td width="40%">Fälligkeitsdatum</td>
  214. <td width="60%">{{ doc.due_date }}</td>
  215. </tr>
  216. </table>
  217.  
  218. </td>
  219. <td width="50%" style="padding:0px !important;">
  220.  
  221. <table width="100%">
  222.    
  223.         <tr>
  224.             <td class="text-right" style="width: 70%">
  225.                 Zwischensumme
  226.             </td>
  227.             <td class="text-right">
  228.                 {{ doc.get_formatted("net_total_export") }}
  229.             </td>
  230.         </tr>
  231.     {%- for row in doc.other_charges -%}
  232.         {%- if row.included_in_print_rate -%}
  233.         <tr style="border-bottom:1px solid #DDDDDD;">
  234.             <td class="text-right" style="width: 70%">
  235.                 MwSt.
  236.             </td>
  237.             <td class="text-right">
  238.                 {{ row.get_formatted("tax_amount", doc) }}
  239.             </td>
  240.         <tr>
  241.         {%- endif -%}
  242.         {%- endfor -%}
  243.         {%- if doc.discount_amount -%}
  244.         <tr>
  245.             <td class="text-right" style="width: 70%">
  246.                 Gesamtrabatt
  247.             </td>
  248.             <td class="text-right">
  249.                 {{ doc.get_formatted("discount_amount") }}
  250.             </td>
  251.         </tr>
  252.         {%- endif -%}
  253.         <tr>
  254.             <td class="text-right" style="width: 70%">
  255.                 <b>Rechnungsbetrag</b>
  256.             </td>
  257.             <td class="text-right">
  258.                 {{ doc.get_formatted("grand_total_export") }}
  259.             </td>
  260.         </tr>
  261.    
  262. </table>
  263.  
  264.  
  265. </td>
  266. </tr>
  267. </table>
  268.  
  269.  
  270.  
  271. <p>{{ doc.terms or "" }}</p></body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement