refactor print_*; invoice sections by package class; could still stand some more...
[freeside.git] / conf / invoice_html
index b13b08f..9d97243 100644 (file)
 
   </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_extdesc">'.
-              '<td></td>'.
-              '<td align="left">-&nbsp;'. $ext_desc. '</td>'.
-              '<td></td>'.
+            '<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_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>'
+        ;
         }
       }