planet telecom rate import, RT#83146
[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           if ( $notfirst || $section->{'pretotal'} && !$summary ) {
149             $OUT .= '</table>';
150             $notfirst = 1;
151           }
152           $OUT .= '<table><tr><td>';
153           $OUT .= '<p class="allcaps"><b>';
154           my $sectionhead;
155           if ( $section->{'location'} ) {
156             $sectionhead .= $section->{'location'}{'label_prefix'}. ': '
157               if length($section->{'location'}{'label_prefix'});
158             $sectionhead = $section->{'location'}{'address1'};
159             $sectionhead .= ', '.$section->{'location'}{'address2'}
160               if length($section->{'location'}{'address2'});
161             $sectionhead .= ', ' .
162                             $section->{'location'}{'city'} . ', ' .
163                             $section->{'location'}{'state'} . ' ' .
164                             $section->{'location'}{'zip'};
165             $OUT .= $sectionhead;
166           } else {
167             $sectionhead = $section->{'description'} || emt('Charges');
168             $OUT .= '<font size="+1">'. substr($sectionhead,0,1).
169               '</font><font size="+0">'. substr($sectionhead,1).
170           
171               '</font>';
172           }
173           $OUT .= '</b></p></td></tr></table>';
174
175           $OUT .=
176             '<table class="invoice_longtable" CELLSPACING=0 WIDTH="100%">'.
177             '<tr>';
178
179           if ($section->{header_generator}) {
180             my $header = &{$section->{header_generator}}();
181             $OUT .= $header;
182             $columncount = scalar(my @array = split /<\/th><th/i, $header);
183           } else {
184             my @headings = ( '', 'Description', 'Amount' );
185             my @aligns = ( 'center', 'left', 'right' );
186             if ( $unitprices ) {
187               splice @headings, 2, 0, 'Unit Price', 'Quantity';
188               splice @aligns,   2, 0, 'right', 'right';
189             }
190             if ( $section->{usage_section} ) {
191               @headings = ( '', 'Description', 'Calls', 'Duration', 'Amount' );
192               @aligns = ( '', 'left', 'right', 'right', 'right' );
193               $columncount = 5;
194             }
195
196             while ( @headings ) {
197               my $heading = shift @headings;
198               $heading = emt($heading) if $heading;
199               my $align = shift @aligns;
200               $OUT .= '
201                 <th align="' . $align . '">' . $heading . '</th>';
202             }
203           }
204
205           $OUT .= '</tr>';
206
207           my $lastref = 0;
208           foreach my $line (
209             grep { ( scalar(@sections) > 1 
210                    ? $section->{'description'} eq $_->{'section'}->{'description'}
211                    : 1
212                  ) }
213             @detail_items )
214           {
215             if ( $section->{description_generator} ) {
216               $OUT .= '<tr class="invoice_desc' .
217                       &{$section->{description_generator}}($line);
218             } elsif ( $section->{usage_section} ) {
219               my $minutes = sprintf('%d', $line->{'duration'} / 60);
220               my $seconds = $line->{'duration'} % 60;
221               $OUT .= '
222                 <tr class="invoice_desc_more">
223                   <td></td>
224                   <td align="left">' . $line->{'description'} . '</td>
225                   <td align="right">' . $line->{'quantity'} . '</td>
226                   <td align="right">' . $minutes . 'm ' . $seconds . 's' . '</td>
227                   <td align="right">' . $line->{'amount'} . '</td>
228                 </tr>';
229             } else {
230               my $class = 'invoice_desc_more';
231               if ( ($line->{'ref'} || 0) ne $lastref ) {
232                 # then it's a new package (not a continuation)
233                 $class = 'invoice_desc';
234               }
235               $OUT .= '<tr class="'.$class.'">
236                        <td align="center">';
237               $OUT .= '</td>
238                        <td align="left">'. $line->{'description'}. '</td>';
239               if ( $unitprices ) {
240                 $OUT .= 
241                   '<td align="right">'. $line->{'unit_amount'}. '</td>'.
242                   '<td align="right">'. $line->{'quantity'}. '</td>';
243               }
244               $OUT .= '<td align="right">'. $line->{'amount'}. '</td>';
245             }
246             $OUT .= '</tr>';
247             $lastref = $line->{'ref'} || 0;
248             if ( @{$line->{'ext_description'} } ) {
249               unless ( $section->{description_generator} ) {
250                 $OUT .= '<tr class="invoice_extdesc"><td></td><td';
251                 $OUT .= $unitprices ? ' colspan=3' : '';
252                 $OUT .= '><table width="100%">';
253               }
254               foreach my $ext_desc ( @{$line->{'ext_description'} } ) {
255                 $OUT .=
256                   '<tr class="invoice_extdesc">'.
257                     ( $section->{'description_generator'} ? '<td></td>' : '' ).
258                     '<td align="left" '.
259                          ( $ext_desc =~ /<\/?TD>/i ? '' : 'colspan=99' ). '>'.
260                       '&nbsp;&nbsp;'. $ext_desc.
261                     '</td>'.
262                   '</tr>'
263               }
264               unless ( $section->{description_generator} ) {
265                 $OUT .= '</table></td><td></td>';
266               }
267               $OUT .= '</tr>';
268             }
269           }
270
271
272           if ($section->{'description'} || $multisection and !$section->{no_subtotal}) {
273             my $style = 'border-top: 3px solid #000000;'.
274                         'border-bottom: 3px solid #000000;';
275             $OUT .=
276               '<tr class="invoice_totaldesc">'.
277               qq(<td style="$style">&nbsp;</td>);
278             if ($section->{total_generator}) {
279               $OUT .= &{$section->{total_generator}}($section);
280             } else {
281               $OUT .= qq(<td align="left" style="$style"). 
282                       ( $unitprices ? ' colspan=3>' : '>' ).
283                       $section->{'description'}. ' ' . emt('Total') . '</td>'.
284                       qq(<td align="right" style="$style">).
285                       $section->{'subtotal'}. '</td>';
286             }
287             $OUT .= '</tr>';
288           }
289         } # if !$section->{summarized}
290         if ($section->{'posttotal'}) {
291           $OUT .= '<tr><td align="right" colspan='. $columncount. '>';
292           $OUT .=
293             '<p><font size="+1">'. $section->{'posttotal'}.
294             '</font>'.
295             '<p>';
296           $OUT .= '</td></tr>';
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 <%=
331
332   my @location_summary_sections =
333     grep {
334       ref $_->{location}
335       && $_->{locationnum}
336       && $_->{description}
337       && $_->{description} ne $finance_section
338     } @sections;
339
340   if ( $multisection eq 'location' && scalar(@location_summary_sections) > 1 ) {
341
342     $OUT .= '
343       <hr>
344       <table width="100%">
345         <tr>
346           <td>
347             <p class="allcaps">
348               <b>'.emt('Summary Of New Charges By Location').'</b>
349             <p>
350           </td>
351         </tr>
352       </table>
353
354       <table class="invoice_longtable" cellspacing="0" width="100%">
355       <thead>
356         <tr>
357           <th></th>
358           <th align="left">'.emt('Location').'</th>
359           <th align="right">'.emt('Amount').'</th>
360         </tr>
361       </thead>
362       <tbody>
363     ';
364
365     for my $section (@location_summary_sections) {
366       next unless $section->{description};
367       $OUT .= '
368         <tr class="invoice_desc_more">
369           <td></td>
370           <td>'.$section->{description}.'</td>
371           <td align="right">'. $section->{subtotal} .'</td>
372         </tr>
373       ';
374     }
375
376     $OUT .= '
377       <tr class="invoice_desc"><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
378       </tbody>
379       </table>
380       <br><br>
381     ';
382
383 } %>
384
385 <%= length($summary)
386       ? ''
387       : ( $smallernotes
388             ? '<FONT SIZE="-1">'.$notes.'</FONT>'
389             : $notes
390         )
391 %>
392
393   <hr NOSHADE SIZE=2 COLOR="#000000">
394   <p align="center" <%= $smallerfooter ? 'STYLE="font-size:75%;"' : '' %>><%= $footer %>
395
396 </div>