add barcodes to invoices, HTML part, RT10698
[freeside.git] / conf / invoice_html
index df4674b..fc553d5 100644 (file)
                        : ''
       %>
       <td align="right">
+    <%=
+       if($barcode_cid) {
+           $OUT .= qq! <img src="cid:$barcode_cid"><br> !;
+       }
+       elsif($barcode_img) {
+           $OUT .= qq! <img src="cust_bill-barcode.cgi?invnum=$invnum;template=$template"><br> !;
+       }
+    %>
         Terms: <%= $terms %><BR>
         <%= $po_line %>
       </td>
   </table>
   <%= $summary %>
   <%=
+      my $notfirst = 0;
+      my $columncount = $unitprices ? 5 : 3;
       foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
         if ($section->{'pretotal'} && !$summary) {
+          $OUT .= '</table>' if $notfirst;
           $OUT .=
             '<table width="100%"><tr><td>'.
             '<p align="right"><b><font size="+1">'.
             '</font><font size="+0">'. uc(substr($section->{'pretotal'},1)).
             '</font></b>'.
             '<p>'.
-            '</td></tr></table>';
+            '</td></tr>';
         }
         unless ($section->{'summarized'}) {
+          $OUT .= '</table>' if ( $notfirst || $section->{'pretotal'} && !$summary );
           $OUT .= '<table><tr><td>';
           if ($section->{'description'}) {
             $OUT .=
             '<tr>';
 
           if ($section->{header_generator}) {
-            $OUT .= &{$section->{header_generator}}();
+            my $header = &{$section->{header_generator}}();
+            $OUT .= $header;
+            $columncount = scalar(my @array = split /<\/th><th/i, $header);
           } else {
             $OUT .=  '<th align="center">Ref</th>'.
                      '<th align="left">Description</th>'.
                         ). 
                       '<th align="right">Amount</th>';
           }
-            '</tr>';
+            $OUT .= '</tr>';
 
           my $lastref = 0;
           foreach my $line (
             $OUT .= '</tr>';
             $lastref = $line->{'ref'};
             if ( @{$line->{'ext_description'} } ) {
-              $OUT .= '<tr class="invoice_extdesc"><td></td><td';
-              $OUT .= $unitprices ? ' colspan=3>' : '>';
-              $OUT .= '<table width="100%">';
+              unless ( $section->{description_generator} ) {
+                $OUT .= '<tr class="invoice_extdesc"><td></td><td';
+                $OUT .= $unitprices ? ' colspan=3' : '';
+                $OUT .= '><table width="100%">';
+              }
               foreach my $ext_desc ( @{$line->{'ext_description'} } ) {
                 $OUT .=
                   '<tr class="invoice_extdesc">'.
+                    ( $section->{'description_generator'} ? '<td></td>' : '' ).
                     '<td align="left" '.
                          ( $ext_desc =~ /<\/?TD>/i ? '' : 'colspan=99' ). '>'.
                       '&nbsp;&nbsp;'. $ext_desc.
                     '</td>'.
                   '</tr>'
               }
-              $OUT .= '</table></td><td></td></tr>';
+              unless ( $section->{description_generator} ) {
+                $OUT .= '</table></td><td></td>';
+              }
+              $OUT .= '</tr>';
             }
           }
 
 
-          if (scalar(@sections) > 1) {
+          if ($section->{'description'} || $multisection) {
             my $style = 'border-top: 3px solid #000000;'.
                         'border-bottom: 3px solid #000000;';
             $OUT .=
           }
         } 
         if ($section->{'posttotal'}) {
-          $OUT .= '<tr><td align="right" colspan=5>';
+          $OUT .= '<tr><td align="right" colspan='. $columncount. '>';
           $OUT .=
             '<p><font size="+1">'. $section->{'posttotal'}.
             '</font>'.
           $OUT .= '</td></tr>';
         }
 
+        $notfirst++;
+
       }
 
       my $style = 'border-top: 3px solid #000000;';
       foreach my $line ( @total_items ) {
 
         $style .= 'border-bottom: 3px solid #000000;'
-          if ++$linenum == scalar(@total_items);
+          if ++$linenum == scalar(@total_items) - ( $balance_due_below_line ? 1 : 0 );
 
         $OUT .=
           '<tr class="invoice_totaldesc">';
           $OUT .= &{$section->{total_line_generator}}($line);
         } else {
           $OUT .= qq(<td style="$style">&nbsp;</td>).
-                  qq(<td align="left" style="$style").
-                  ( $unitprices ? ' colspan=3>' : '>' ).
+                  qq(<td align="left" style="$style" colspan=").
+                    ( $columncount - 2 ). '">'.
                     $line->{'total_item'}. '</td>'.
                   qq(<td align="right" style="$style">).
                     $line->{'total_amount'}. '</td>';