modify total items for balance below line and current charges above line with configu...
[freeside.git] / conf / invoice_html
1 <STYLE TYPE="text/css">
2 .invoice { font-family: sans-serif; font-size: 10pt }
3 .invoice_header { font-size: 10pt }
4 .invoice_headerright TH { border-top: 2px solid #000000; border-bottom: 2px solid #000000 }
5 .invoice_headerright TD { font-size: 10pt; empty-cells: show }
6 .invoice_summary TH { border-bottom: 2px solid #000000 }
7 .invoice_summary TD { font-size: 10pt; empty-cells: show }
8 .invoice_longtable table { cellspacing: none }
9 .invoice_longtable TH { border-top: 2px solid #000000; border-bottom: 1px solid #000000; padding-left: none; padding-right: none; font-size: 10pt }
10 .invoice_desc TD { border-top: 2px solid #000000; font-weight: bold; font-size: 10pt }
11 .invoice_desc_more TD { font-weight: bold; font-size: 10pt }
12 .invoice_extdesc TD { font-size: 8pt }
13 .invoice_totaldesc TD { font-size: 10pt; empty-cells: show }
14 </STYLE>
15
16 <table class="invoice" bgcolor="#ffffff" WIDTH=625 CELLSPACING=8><tr><td>
17
18   <table class="invoice_header" width="100%">
19     <tr>
20      <td><img src="<%= $cid ? "cid:$cid" : "cust_bill-logo.cgi?invnum=$invnum;template=$template" %>"></td>
21      <td align="left"><%= $returnaddress %></td>
22       <td align="right">
23         <table CLASS="invoice_headerright" cellspacing=0>
24           <tr>
25             <td align="center">
26               Invoice&nbsp;date<BR>
27               <B><%= $date %></B>
28             </td>
29             <td>
30             </td>
31             <td align="center">
32               Invoice&nbsp;#<BR>
33               <B><%= $invnum %></B>
34             </td>
35             <td>
36             </td>
37             <td align="center">
38               Customer #<BR>
39               <B><%= $custnum %></B>
40             </td>
41           </tr>
42           <tr>
43             <th>&nbsp;</th>
44             <th colspan=3 align="center">
45               <FONT SIZE="+3"><%= $notice_name ? substr($notice_name, 0, 1) : 'I' %></FONT><FONT SIZE="+2"><%= $notice_name ? uc(substr($notice_name, 1)) : 'NVOICE' %></FONT>
46             </th>
47             <th>&nbsp;</th>
48           </tr>
49         </table>
50       </td>
51     </tr>
52
53     <tr>
54       <td>
55       </td>
56       <td align="left">
57         <b><%= $payname %></b><BR>
58         <%= join('<BR>', grep length($_), $company,
59                                           $address1,
60                                           $address2,
61                                           "$city,&nbsp;$state&nbsp;&nbsp;$zip",
62                                           $country,
63                 )
64         %>
65       </td>
66       <%= $ship_enable ? ('<td align="left">'.
67                           join('<BR>',grep length($_), '<b>Service Address</b>',
68                                                        $ship_company,
69                                                        $ship_address1,
70                                                        $ship_address2,
71                                                        "$ship_city,&nbsp;$ship_state&nbsp;$ship_zip",
72                                                        $ship_country,
73                                                        ' ',
74                                                        ' ',
75                               ).
76                            '</td><tr><td></td><td></td>'
77                          )
78                        : ''
79       %>
80       <td align="right">
81         Terms: <%= $terms %><BR>
82         <%= $po_line %>
83       </td>
84     </tr>
85
86   </table>
87   <%= $summary %>
88   <%=
89       my $notfirst = 0;
90       foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
91         if ($section->{'pretotal'} && !$summary) {
92           $OUT .= '</table>' if $notfirst;
93           $OUT .=
94             '<table width="100%"><tr><td>'.
95             '<p align="right"><b><font size="+1">'.
96             uc(substr($section->{'pretotal'},0,1)).
97             '</font><font size="+0">'. uc(substr($section->{'pretotal'},1)).
98             '</font></b>'.
99             '<p>'.
100             '</td></tr>';
101         }
102         unless ($section->{'summarized'}) {
103           $OUT .= '</table>' if ( $notfirst || $section->{'pretotal'} && !$summary );
104           $OUT .= '<table><tr><td>';
105           if ($section->{'description'}) {
106             $OUT .=
107               '<p><b><font size="+1">'. uc(substr($section->{'description'},0,1)).
108               '</font><font size="+0">'. uc(substr($section->{'description'},1)).
109               '</font></b>'.
110               '<p>';
111           }else{
112             $OUT .=
113               '<p><b><font size="+1">C</font><font size="+0">HARGES</font></b>'.
114               '<p>';
115           }
116           $OUT .= '</td></tr></table>';
117
118           $OUT .=
119             '<table class="invoice_longtable" CELLSPACING=0 WIDTH="100%">'.
120             '<tr>';
121
122           if ($section->{header_generator}) {
123             $OUT .= &{$section->{header_generator}}();
124           } else {
125             $OUT .=  '<th align="center">Ref</th>'.
126                      '<th align="left">Description</th>'.
127                         ( $unitprices 
128                           ? '<th align="left">Unit Price</th>'.
129                             '<th align="left">Quantity</th>'
130                           : ''
131                         ). 
132                       '<th align="right">Amount</th>';
133           }
134             $OUT .= '</tr>';
135
136           my $lastref = 0;
137           foreach my $line (
138             grep { ( scalar(@sections) > 1 
139                    ? $section->{'description'} eq $_->{'section'}->{'description'}
140                    : 1
141                  ) }
142             @detail_items )
143           {
144             $OUT .=
145               '<tr class="invoice_desc';
146             if ( $section->{description_generator} ) {
147               $OUT .= &{$section->{description_generator}}($line);
148             } else {
149               $OUT .=  ( ($line->{'ref'} && $line->{'ref'} ne $lastref) ? '' : '_more' ).
150                        '">'.
151                        '<td align="center">'. 
152                        ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ). '</td>'.
153                        '<td align="left">'. $line->{'description'}. '</td>'.
154                        ( $unitprices 
155                            ? '<td align="left">'. $line->{'unit_amount'}. '</td>'.
156                              '<td align="left">'. $line->{'quantity'}. '</td>'
157                            : ''
158                        ).
159
160                        '<td align="right">'. $line->{'amount'}. '</td>';
161             }
162             $OUT .= '</tr>';
163             $lastref = $line->{'ref'};
164             if ( @{$line->{'ext_description'} } ) {
165               $OUT .= '<tr class="invoice_extdesc"><td></td><td';
166               $OUT .= $unitprices ? ' colspan=3>' : '>';
167               $OUT .= '<table width="100%">';
168               foreach my $ext_desc ( @{$line->{'ext_description'} } ) {
169                 $OUT .=
170                   '<tr class="invoice_extdesc">'.
171                     '<td align="left" '.
172                          ( $ext_desc =~ /<\/?TD>/i ? '' : 'colspan=99' ). '>'.
173                       '&nbsp;&nbsp;'. $ext_desc.
174                     '</td>'.
175                   '</tr>'
176               }
177               $OUT .= '</table></td><td></td></tr>';
178             }
179           }
180
181
182           if ($section->{'description'} || $multisection) {
183             my $style = 'border-top: 3px solid #000000;'.
184                         'border-bottom: 3px solid #000000;';
185             $OUT .=
186               '<tr class="invoice_totaldesc">'.
187               qq(<td style="$style">&nbsp;</td>);
188             if ($section->{total_generator}) {
189               $OUT .= &{$section->{total_generator}}($section);
190             } else {
191               $OUT .= qq(<td align="left" style="$style"). 
192                       ( $unitprices ? ' colspan=3>' : '>' ).
193                       $section->{'description'}. ' Total </td>'.
194                       qq(<td align="right" style="$style">).
195                       $section->{'subtotal'}. '</td>';
196             }
197             $OUT .= '</tr>';
198           }
199         } 
200         if ($section->{'posttotal'}) {
201           $OUT .= '<tr><td align="right" colspan=5>';
202           $OUT .=
203             '<p><font size="+1">'. $section->{'posttotal'}.
204             '</font>'.
205             '<p>';
206           $OUT .= '</td></tr>';
207         }
208
209         $notfirst++;
210
211       }
212
213       my $style = 'border-top: 3px solid #000000;';
214       my $linenum = 0;
215
216       foreach my $line ( @total_items ) {
217
218         $style .= 'border-bottom: 3px solid #000000;'
219           if ++$linenum == scalar(@total_items) - ( $balance_due_below_line ? 1 : 0 );
220
221         $OUT .=
222           '<tr class="invoice_totaldesc">';
223         if ($section->{total_line_generator}) {
224           $OUT .= &{$section->{total_line_generator}}($line);
225         } else {
226           $OUT .= qq(<td style="$style">&nbsp;</td>).
227                   qq(<td align="left" style="$style").
228                   ( $unitprices ? ' colspan=3>' : '>' ).
229                     $line->{'total_item'}. '</td>'.
230                   qq(<td align="right" style="$style">).
231                     $line->{'total_amount'}. '</td>';
232         }
233         $OUT .= '</tr>';
234
235         $style='';
236
237       }
238
239     %>
240   </table>
241   <br><br>
242
243 <%= length($summary)
244       ? ''
245       : ( $smallernotes
246             ? '<FONT SIZE="-1">'.$notes.'</FONT>'
247             : $notes
248         )
249 %>
250
251   <hr NOSHADE SIZE=2 COLOR="#000000">
252   <p align="center" <%= $smallerfooter ? 'STYLE="font-size:75%;"' : '' %>><%= $footer %>
253
254 </td></tr></table>