invoice_sections_with_taxes per-agent, RT#79636
[freeside.git] / conf / invoice_html
1 <STYLE TYPE="text/css">
2 .invoice {
3   font-family: sans-serif;
4   font-size: 10pt;
5   display: inline-block;
6   padding: 4pt;
7   border: 1px solid black;
8   background-color: white;
9   min-width: 625px;
10   position: relative;
11 }
12 .invoice_header {
13   font-size: 10pt;
14   border-spacing: 4pt;
15 }
16 .invoice_headerright TH { border-top: 2px solid #000000; border-bottom: 2px solid #000000 }
17 .invoice_headerright TD { font-size: 10pt; empty-cells: show }
18 .invoice_summary TH { border-bottom: 2px solid #000000 }
19 .invoice_summary TD { font-size: 10pt; empty-cells: show }
20 .invoice_longtable table { cellspacing: none }
21 .invoice_longtable TH { border-top: 2px solid #000000; border-bottom: 1px solid #000000; padding-left: none; padding-right: none; font-size: 10pt }
22 .invoice_desc TD { border-top: 2px solid #000000; font-weight: bold; font-size: 10pt }
23 .invoice_desc_more TD { font-weight: bold; font-size: 10pt }
24 .invoice_extdesc TD { font-size: 8pt }
25 .invoice_totaldesc TD { font-size: 10pt; empty-cells: show }
26 .allcaps { text-transform:uppercase; font-size: 12pt }
27 .watermark-box {
28   z-index: 10;
29   position: absolute;
30   text-align: center;
31   padding: 0;
32   filter: alpha(opacity=25);
33   opacity: 0.25;
34   width: 100%;
35   height: 100%;
36   display: table;
37   pointer-events: none;
38 }
39 .watermark-content {
40   display: table-cell;
41   vertical-align: middle;
42   font-size: 96pt;
43 }
44 </STYLE>
45
46 <div class="invoice">
47
48   <DIV CLASS="watermark-box"><DIV CLASS="watermark-content">
49       <%= $watermark %>
50   </DIV></DIV>
51
52   <table class="invoice_header" width="100%">
53     <tr>
54      <td align="left"><%= $returnaddress %></td>
55      <td align="left"><img src="<%= $cid ? "cid:$cid" : "cust_bill-logo.cgi?invnum=$invnum;template=$template" %>"></td>
56       <td align="right">
57         <table CLASS="invoice_headerright" cellspacing=0>
58           <tr>
59             <td align="center">
60               <%= emt('Invoice date') %><BR>
61               <B><%= $date %></B>
62             </td>
63             <td>
64             </td>
65             <td align="center">
66               <%= emt('Invoice #') %><BR>
67               <B><%= $invnum %></B>
68             </td>
69             <td>
70             </td>
71             <td align="center">
72               <%= emt('Customer #') %><BR>
73               <B><%= $custnum %></B>
74             </td>
75           </tr>
76           <tr>
77             <th>&nbsp;</th>
78             <th colspan=3 align="center" class="allcaps">
79               <FONT SIZE="+3"><%= substr(emt($notice_name),0,1) %></FONT><FONT SIZE="+2"><%= substr(emt($notice_name),1) %></FONT>
80             </th>
81             <th>&nbsp;</th>
82           </tr>
83         </table>
84       </td>
85     </tr>
86   </table>
87
88   <table class="invoice_header" width="100%">
89     <tr>
90       <td WIDTH="10%">
91       </td>
92       <td align="left">
93         <b><%= $payname %></b><BR>
94         <%= join('<BR>', grep length($_), $company,
95                                           $address1,
96                                           $address2,
97                                           "$city,&nbsp;$state&nbsp;&nbsp;$zip",
98                                           $country,
99                 )
100         %>
101       </td>
102       <%= $ship_enable ? ('<td align="left">'.
103                           join('<BR>',grep length($_), '<b>'.emt('Service Address').'</b>',
104                                                        $ship_company,
105                                                        $ship_address1,
106                                                        $ship_address2,
107                                                        "$ship_city,&nbsp;$ship_state&nbsp;$ship_zip",
108                                                        $ship_country,
109                                                        ' ',
110                                                        ' ',
111                               ).
112                            '</td><tr><td></td><td></td>'
113                          )
114                        : ''
115       %>
116       <td align="right">
117     <%=
118         if($barcode_cid) {
119             $OUT .= qq! <img src="cid:$barcode_cid"><br> !;
120         }
121         elsif($barcode_img) {
122             $OUT .= qq! <img src="cust_bill-barcode.cgi?invnum=$invnum;template=$template"><br> !;
123         }
124     %>
125         <%= $terms ? emt('Terms') . ': ' . emt($terms) : '' %><BR>
126         <%= $po_line %>
127       </td>
128     </tr>
129
130   </table>
131   <%= $summary %>
132   <%=
133       my $notfirst = 0;
134       my $columncount = $unitprices ? 5 : 3;
135       foreach my $section ( grep { !$summary || $_->{description} ne $finance_section } @sections ) {
136         if ($section->{'pretotal'} && !$summary) {
137           $OUT .= '</table>' if $notfirst;
138           $OUT .=
139             '<table width="100%"><tr><td>'.
140             '<p align="right"><b><font size="+1">'.
141             uc(substr($section->{'pretotal'},0,1)).
142             '</font><font size="+0">'. uc(substr($section->{'pretotal'},1)).
143             '</font></b>'.
144             '<p>'.
145             '</td></tr>';
146         }
147         unless ($section->{'summarized'}) {
148           $OUT .= '</table>' if ( $notfirst || $section->{'pretotal'} && !$summary );
149           $OUT .= '<table><tr><td>';
150           $OUT .= '<p class="allcaps"><b>';
151           my $sectionhead;
152           if ( $section->{'location'} ) {
153             $sectionhead .= $section->{'location'}{'label_prefix'}. ': '
154               if length($section->{'location'}{'label_prefix'});
155             $sectionhead = $section->{'location'}{'address1'};
156             $sectionhead .= ', '.$section->{'location'}{'address2'}
157               if length($section->{'location'}{'address2'});
158             $sectionhead .= ', ' .
159                             $section->{'location'}{'city'} . ', ' .
160                             $section->{'location'}{'state'} . ' ' .
161                             $section->{'location'}{'zip'};
162             $OUT .= $sectionhead;
163           } else {
164             $sectionhead = $section->{'description'} || emt('Charges');
165             $OUT .= '<font size="+1">'. substr($sectionhead,0,1).
166               '</font><font size="+0">'. substr($sectionhead,1).
167           
168               '</font>';
169           }
170           $OUT .= '</b></p></td></tr></table>';
171
172           $OUT .=
173             '<table class="invoice_longtable" CELLSPACING=0 WIDTH="100%">'.
174             '<tr>';
175
176           if ($section->{header_generator}) {
177             my $header = &{$section->{header_generator}}();
178             $OUT .= $header;
179             $columncount = scalar(my @array = split /<\/th><th/i, $header);
180           } else {
181             my @headings = ( '', 'Description', 'Amount' );
182             my @aligns = ( 'center', 'left', 'right' );
183             if ( $unitprices ) {
184               splice @headings, 2, 0, 'Unit Price', 'Quantity';
185               splice @aligns,   2, 0, 'right', 'right';
186             }
187             if ( $section->{usage_section} ) {
188               @headings = ( '', 'Description', 'Calls', 'Duration', 'Amount' );
189               @aligns = ( '', 'left', 'right', 'right', 'right' );
190               $columncount = 5;
191             }
192
193             while ( @headings ) {
194               my $heading = shift @headings;
195               $heading = emt($heading) if $heading;
196               my $align = shift @aligns;
197               $OUT .= '
198                 <th align="' . $align . '">' . $heading . '</th>';
199             }
200           }
201
202           $OUT .= '</tr>';
203
204           my $lastref = 0;
205           foreach my $line (
206             grep { ( scalar(@sections) > 1 
207                    ? $section->{'description'} eq $_->{'section'}->{'description'}
208                    : 1
209                  ) }
210             @detail_items )
211           {
212             if ( $section->{description_generator} ) {
213               $OUT .= '<tr class="invoice_desc' .
214                       &{$section->{description_generator}}($line);
215             } elsif ( $section->{usage_section} ) {
216               my $minutes = sprintf('%d', $line->{'duration'} / 60);
217               my $seconds = $line->{'duration'} % 60;
218               $OUT .= '
219                 <tr class="invoice_desc_more">
220                   <td></td>
221                   <td align="left">' . $line->{'description'} . '</td>
222                   <td align="right">' . $line->{'quantity'} . '</td>
223                   <td align="right">' . $minutes . 'm ' . $seconds . 's' . '</td>
224                   <td align="right">' . $line->{'amount'} . '</td>
225                 </tr>';
226             } else {
227               my $class = 'invoice_desc_more';
228               if ( ($line->{'ref'} || 0) ne $lastref ) {
229                 # then it's a new package (not a continuation)
230                 $class = 'invoice_desc';
231               }
232               $OUT .= '<tr class="'.$class.'">
233                        <td align="center">';
234               $OUT .= '</td>
235                        <td align="left">'. $line->{'description'}. '</td>';
236               if ( $unitprices ) {
237                 $OUT .= 
238                   '<td align="right">'. $line->{'unit_amount'}. '</td>'.
239                   '<td align="right">'. $line->{'quantity'}. '</td>';
240               }
241               $OUT .= '<td align="right">'. $line->{'amount'}. '</td>';
242             }
243             $OUT .= '</tr>';
244             $lastref = $line->{'ref'} || 0;
245             if ( @{$line->{'ext_description'} } ) {
246               unless ( $section->{description_generator} ) {
247                 $OUT .= '<tr class="invoice_extdesc"><td></td><td';
248                 $OUT .= $unitprices ? ' colspan=3' : '';
249                 $OUT .= '><table width="100%">';
250               }
251               foreach my $ext_desc ( @{$line->{'ext_description'} } ) {
252                 $OUT .=
253                   '<tr class="invoice_extdesc">'.
254                     ( $section->{'description_generator'} ? '<td></td>' : '' ).
255                     '<td align="left" '.
256                          ( $ext_desc =~ /<\/?TD>/i ? '' : 'colspan=99' ). '>'.
257                       '&nbsp;&nbsp;'. $ext_desc.
258                     '</td>'.
259                   '</tr>'
260               }
261               unless ( $section->{description_generator} ) {
262                 $OUT .= '</table></td><td></td>';
263               }
264               $OUT .= '</tr>';
265             }
266           }
267
268
269           if ($section->{'description'} || $multisection and !$section->{no_subtotal}) {
270             my $style = 'border-top: 3px solid #000000;'.
271                         'border-bottom: 3px solid #000000;';
272             $OUT .=
273               '<tr class="invoice_totaldesc">'.
274               qq(<td style="$style">&nbsp;</td>);
275             if ($section->{total_generator}) {
276               $OUT .= &{$section->{total_generator}}($section);
277             } else {
278               $OUT .= qq(<td align="left" style="$style"). 
279                       ( $unitprices ? ' colspan=3>' : '>' ).
280                       $section->{'description'}. ' ' . emt('Total') . '</td>'.
281                       qq(<td align="right" style="$style">).
282                       $section->{'subtotal'}. '</td>';
283             }
284             $OUT .= '</tr>';
285           }
286         } # if !$section->{summarized}
287         if ($section->{'posttotal'}) {
288           $OUT .= '<tr><td align="right" colspan='. $columncount. '>';
289           $OUT .=
290             '<p><font size="+1">'. $section->{'posttotal'}.
291             '</font>'.
292             '<p>';
293           $OUT .= '</td></tr>';
294         }
295
296         $notfirst++;
297
298       }
299
300       my $style = 'border-top: 3px solid #000000;';
301       my $linenum = 0;
302
303       foreach my $line ( @total_items ) {
304
305         $style .= 'border-bottom: 3px solid #000000;'
306           if ++$linenum == scalar(@total_items) - ( $balance_due_below_line ? 1 : 0 );
307
308         $OUT .=
309           '<tr class="invoice_totaldesc">';
310         if ($section->{total_line_generator}) {
311           $OUT .= &{$section->{total_line_generator}}($line);
312         } else {
313           $OUT .= qq(<td style="$style">&nbsp;</td>).
314                   qq(<td align="left" style="$style" colspan=").
315                     ( $columncount - 2 ). '">'.
316                     $line->{'total_item'}. '</td>'.
317                   qq(<td align="right" style="$style">).
318                     $line->{'total_amount'}. '</td>';
319         }
320         $OUT .= '</tr>';
321
322         $style='';
323
324       }
325
326     %>
327   </table>
328   <br><br>
329
330 <%= length($summary)
331       ? ''
332       : ( $smallernotes
333             ? '<FONT SIZE="-1">'.$notes.'</FONT>'
334             : $notes
335         )
336 %>
337
338   <hr NOSHADE SIZE=2 COLOR="#000000">
339   <p align="center" <%= $smallerfooter ? 'STYLE="font-size:75%;"' : '' %>><%= $footer %>
340
341 </div>