+ if ($section->{header_generator}) {
+ my $header = &{$section->{header_generator}}();
+ $OUT .= $header;
+ $columncount = scalar(my @array = split /<\/th><th/i, $header);
+ } else {
+ $OUT .= '<th align="center">' . emt('Ref') . '</th>'.
+ '<th align="left">' . emt('Description') . '</th>'.
+ ( $unitprices
+ ? '<th align="left">' . emt('Unit Price') . '</th>'.
+ '<th align="left">' . emt('Quantity') . '</th>'
+ : '' ).
+ '<th align="right">' . emt('Amount') . '</th>';
+ }
+ $OUT .= '</tr>';
+
+ my $lastref = 0;
+ foreach my $line (
+ grep { ( scalar(@sections) > 1
+ ? $section->{'description'} eq $_->{'section'}->{'description'}
+ : 1
+ ) }
+ @detail_items )
+ {
+ $OUT .=
+ '<tr class="invoice_desc';
+ if ( $section->{description_generator} ) {
+ $OUT .= &{$section->{description_generator}}($line);
+ } else {
+ $OUT .= ( ($line->{'ref'} && $line->{'ref'} ne $lastref) ? '' : '_more' ).
+ '">'.
+ '<td align="center">'.
+ ( $line->{'ref'} ne $lastref ? $line->{'ref'} : '' ). '</td>'.
+ '<td align="left">'. $line->{'description'}. '</td>'.
+ ( $unitprices
+ ? '<td align="left">'. $line->{'unit_amount'}. '</td>'.
+ '<td align="left">'. $line->{'quantity'}. '</td>'
+ : ''
+ ).
+
+ '<td align="right">'. $line->{'amount'}. '</td>';
+ }
+ $OUT .= '</tr>';
+ $lastref = $line->{'ref'};
+ if ( @{$line->{'ext_description'} } ) {
+ unless ( $section->{description_generator} ) {
+ $OUT .= '<tr class="invoice_extdesc"><td></td><td';
+ $OUT .= $unitprices ? ' colspan=3' : '';
+ $OUT .= '><table width="100%">';
+ }
+ foreach my $ext_desc ( @{$line->{'ext_description'} } ) {
+ $OUT .=
+ '<tr class="invoice_extdesc">'.
+ ( $section->{'description_generator'} ? '<td></td>' : '' ).
+ '<td align="left" '.
+ ( $ext_desc =~ /<\/?TD>/i ? '' : 'colspan=99' ). '>'.
+ ' '. $ext_desc.
+ '</td>'.
+ '</tr>'
+ }
+ unless ( $section->{description_generator} ) {
+ $OUT .= '</table></td><td></td>';
+ }
+ $OUT .= '</tr>';
+ }
+ }
+
+
+ if ($section->{'description'} || $multisection and !$section->{no_subtotal}) {
+ my $style = 'border-top: 3px solid #000000;'.
+ 'border-bottom: 3px solid #000000;';
+ $OUT .=
+ '<tr class="invoice_totaldesc">'.
+ qq(<td style="$style"> </td>);
+ if ($section->{total_generator}) {
+ $OUT .= &{$section->{total_generator}}($section);
+ } else {
+ $OUT .= qq(<td align="left" style="$style").
+ ( $unitprices ? ' colspan=3>' : '>' ).
+ $section->{'description'}. ' ' . emt('Total') . '</td>'.
+ qq(<td align="right" style="$style">).
+ $section->{'subtotal'}. '</td>';
+ }
+ $OUT .= '</tr>';
+ }
+ }
+ if ($section->{'posttotal'}) {
+ $OUT .= '<tr><td align="right" colspan='. $columncount. '>';