refactor print_*; invoice sections by package class; could still stand some more...
[freeside.git] / conf / invoice_html
index fde0e15..9d97243 100644 (file)
             </td>
             <td>
             </td>
-            <td align="left">
-              Invoice&nbsp;number<BR>
+            <td align="center">
+              Invoice&nbsp;#<BR>
               <B><%= $invnum %></B>
             </td>
+            <td>
+            </td>
+            <td align="center">
+              Customer #<BR>
+              <B><%= $custnum %></B>
+            </td>
           </tr>
           <tr>
+            <th>&nbsp;</th>
             <th colspan=3 align="center">
               <FONT SIZE="+3">I</FONT><FONT SIZE="+2">NVOICE</FONT>
             </th>
+            <th>&nbsp;</th>
           </tr>
         </table>
       </td>
 
   </table>
 
-  <p><b><font size="+1">C</font><font size="+0">HARGES</font></b>
-  <p>
-  <table class="invoice_longtable" CELLSPACING=0 WIDTH="100%">
-    <tr>
-      <th align="center">Ref</th>
-      <th align="left">Description</th>
-      <th align="right">Amount</th>
-    </tr>
-    <%=
+  <%=
+      foreach my $section ( @sections ) {
+        $OUT .= '<table><tr><td>';
+        if ($section->{'description'}) {
+          $OUT .=
+            '<p><b><font size="+1">'. uc(substr($section->{'description'},0,1)).
+            '</font><font size="+0">'. uc(substr($section->{'description'},1)).
+            '</font></b>'.
+            '<p>';
+        }else{
+          $OUT .=
+            '<p><b><font size="+1">C</font><font size="+0">HARGES</font></b>'.
+            '<p>';
+        }
+        $OUT .= '</td></tr></table>';
 
-      foreach my $line ( @detail_items ) {
         $OUT .=
-          '<tr class="invoice_desc">'.
-            '<td align="center">'. $line->{'ref'}. '</td>'.
-            '<td align="left">'. $line->{'description'}. '</td>'.
-            '<td align="right">'. $line->{'amount'}. '</td>'.
-          '</tr>'
-        ;
-        foreach my $ext_desc ( @{$line->{'ext_description'} } ) {
+          '<table class="invoice_longtable" CELLSPACING=0 WIDTH="100%">'.
+          '<tr>'.
+            '<th align="center">Ref</th>'.
+            '<th align="left">Description</th>'.
+            '<th align="right">Amount</th>'.
+          '</tr>';
+
+        foreach my $line (
+          grep { ( scalar(@sections) > 1 
+                 ? $section->{'description'} eq $_->{'section'}->{'description'}
+                 : 1
+               ) }
+          @detail_items )
+        {
+          $OUT .=
+            '<tr class="invoice_desc">'.
+              '<td align="center">'. $line->{'ref'}. '</td>'.
+              '<td align="left">'. $line->{'description'}. '</td>'.
+              '<td align="right">'. $line->{'amount'}. '</td>'.
+            '</tr>'
+          ;
+          foreach my $ext_desc ( @{$line->{'ext_description'} } ) {
+            $OUT .=
+              '<tr class="invoice_extdesc">'.
+                '<td></td>'.
+                '<td align="left">-&nbsp;'. $ext_desc. '</td>'.
+                '<td></td>'.
+              '</tr>'
+          }
+        }
+
+
+        if (scalar(@sections) > 1) {
+          my $style = 'border-top: 3px solid #000000;'.
+                      'border-bottom: 3px solid #000000;';
           $OUT .=
-            '<tr class="invoice_extdesc">'.
-              '<td></td>'.
-              '<td align="left">-&nbsp;'. $ext_desc. '</td>'.
-              '<td></td>'.
+            '<tr class="invoice_totaldesc">'.
+              qq(<td style="$style">&nbsp;</td>).
+              qq(<td align="left" style="$style">).
+                $section->{'description'}. ' Total </td>'.
+              qq(<td align="right" style="$style">).
+                $section->{'subtotal'}. '</td>'.
             '</tr>'
+        ;
         }
       }
 
   </table>
   <br><br>
 
-<!--  <p><b><font size="+1">N</font><font size="+0">OTES</font></b>
-
-  <ol>
-    <li>Please make your check payable to <b>Ivan Kohler</b>
-    <li>If you have any questions please email or telephone.
-  </ol>
--->
 <%= $notes %>
 
   <hr NOSHADE SIZE=2 COLOR="#000000">