- if (scalar(@sections) > 1) {
- my $style = 'border-top: 3px solid #000000;'.
- 'border-bottom: 3px solid #000000;';
- $OUT .=
- '<tr class="invoice_totaldesc">'.
- qq(<td style="$style"> </td>).
- qq(<td align="left" style="$style" colspan=2>).
- $section->{'description'}. ' Total </td>'.
- qq(<td align="right" style="$style">).
- $section->{'subtotal'}. '</td>'.
- '</tr>'
- ;
- }
+ my $lastref = 0;
+ foreach my $line (
+ grep { ( scalar(@sections) > 1
+ ? $section->{'description'} eq $_->{'section'}->{'description'}
+ : 1
+ ) }
+ @detail_items )
+ {
+ if ( $section->{description_generator} ) {
+ $OUT .= '<tr class="invoice_desc' .
+ &{$section->{description_generator}}($line);
+ } elsif ( $section->{usage_section} ) {
+ my $minutes = sprintf('%d', $line->{'duration'} / 60);
+ my $seconds = $line->{'duration'} % 60;
+ $OUT .= '
+ <tr class="invoice_desc_more">
+ <td></td>
+ <td align="left">' . $line->{'description'} . '</td>
+ <td align="right">' . $line->{'quantity'} . '</td>
+ <td align="right">' . $minutes . 'm ' . $seconds . 's' . '</td>
+ <td align="right">' . $line->{'amount'} . '</td>
+ </tr>';
+ } else {
+ my $class = 'invoice_desc_more';
+ if ( ($line->{'ref'} || 0) ne $lastref ) {
+ # then it's a new package (not a continuation)
+ $class = 'invoice_desc';
+ }
+ $OUT .= '<tr class="'.$class.'">
+ <td align="center">';
+ $OUT .= '</td>
+ <td align="left">'. $line->{'description'}. '</td>';
+ if ( $unitprices ) {
+ $OUT .=
+ '<td align="right">'. $line->{'unit_amount'}. '</td>'.
+ '<td align="right">'. $line->{'quantity'}. '</td>';
+ }
+ $OUT .= '<td align="right">'. $line->{'amount'}. '</td>';
+ }
+ $OUT .= '</tr>';
+ $lastref = $line->{'ref'} || 0;
+ 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>';
+ }
+ }