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