my $last_row_set;
while (my $arg = shift) {
+ my $row_set;
+
if ('ARRAY' eq ref $arg) {
- push @{ $self->{data} }, $arg;
- $last_row_set = $arg;
+ $row_set = $arg;
} elsif ('HASH' eq ref $arg) {
- my $row_set = [ $arg ];
- push @{ $self->{data} }, $row_set;
- $last_row_set = $row_set;
+ $row_set = [ $arg ];
} else {
$self->{form}->error('Incorrect usage -- expecting hash or array ref');
}
+
+ foreach my $row (@{ $row_set }) {
+ foreach my $field (qw(data link)) {
+ map { $row->{$_}->{$field} = [ $row->{$_}->{$field} ] if (ref $row->{$_}->{$field} ne 'ARRAY') } keys %{ $row };
+ }
+ }
+
+ push @{ $self->{data} }, $row_set;
+ $last_row_set = $row_set;
}
return $last_row_set;
foreach my $row (@{ $row_set }) {
$inner_idx++;
- map { $row->{$_}->{data} = $self->html_format($row->{$_}->{data}) } @visible_columns;
+ foreach my $col_name (@visible_columns) {
+ my $col = $row->{$col_name};
+ $col->{CELL_ROWS} = [ ];
+ foreach my $i (0 .. scalar(@{ $col->{data} })) {
+ push @{ $col->{CELL_ROWS} }, {
+ 'data' => $self->html_format($col->{data}->[$i]),
+ 'link' => $col->{link}->[$i],
+ };
+ };
+ }
my $row_data = {
'COLUMNS' => [ map { $row->{$_} } @visible_columns ],
foreach my $row_set (@{ $self->{data} }) {
next if ('ARRAY' ne ref $row_set);
foreach my $row (@{ $row_set }) {
- map { $row->{$_}->{data} =~ s/\r?\n/$eol/g } @visible_columns;
- $csv->print($stdout, [ map { $row->{$_}->{data} } @visible_columns ]);
+ my @data;
+ foreach my $col (@visible_columns) {
+ push @data, join($eol, map { s/\r?\n/$eol/g; $_ } @{ $row->{$col}->{data} });
+ }
+ $csv->print($stdout, \@data);
}
}
}
map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description source notes);
- map { $row->{$_}->{data} = join "\n", @{ $rows{$_} }; } qw(transdate debit credit);
-
- map { $row->{$_}->{data} = join "\n", @{ $rows{$_} } if ($ref->{"${_}_accno"} ne "") } qw(debit_tax credit_tax);
+ map { $row->{$_}->{data} = \@{ $rows{$_} }; } qw(transdate debit credit debit_accno credit_accno debit_tax_accno credit_tax_accno);
foreach my $col (qw(debit_accno credit_accno debit_tax_accno credit_tax_accno)) {
- if (lc $report->{options}->{output_format} eq 'html') {
- $row->{$col}->{raw_data} = join "<br>", map { "<a href=\"${callback}&accno=" . E($_) . "\">$_</a>" } @{ $rows{$col} };
- } else {
- $row->{$col}->{data} = join "\n", @{ $rows{$col} };
- }
+ $row->{$col}->{link} = [ map { "${callback}&accno=" . E($_) } @{ $rows{$col} } ];
}
+ map { $row->{$_}->{data} = \@{ $rows{$_} } if ($ref->{"${_}_accno"} ne "") } qw(debit_tax credit_tax);
+
$row->{reference}->{link} = build_std_url("script=$ref->{module}.pl", 'action=edit', 'id=' . E($ref->{id}), 'callback');
my $row_set = [ $row ];
<TMPL_IF IS_SEPARATOR><tr><td colspan="<TMPL_VAR NUM_COLUMNS>"><hr size="3" noshade></td></tr></TMPL_IF>
<TMPL_ELSE>
<tr class="listrow<TMPL_VAR outer_idx_odd>">
- <TMPL_LOOP COLUMNS><td<TMPL_IF align> align="<TMPL_VAR align>"</TMPL_IF><TMPL_IF valign> valign="<TMPL_VAR valign>"</TMPL_IF><TMPL_IF class> class="<TMPL_VAR class>"</TMPL_IF>><TMPL_IF raw_data><TMPL_VAR raw_data></TMPL_IF><TMPL_IF data><TMPL_IF link><a href="<TMPL_VAR link>"></TMPL_IF><TMPL_VAR data><TMPL_IF link></a></TMPL_IF></TMPL_IF></td>
+ <TMPL_LOOP COLUMNS><td<TMPL_IF align> align="<TMPL_VAR align>"</TMPL_IF><TMPL_IF valign> valign="<TMPL_VAR valign>"</TMPL_IF><TMPL_IF class> class="<TMPL_VAR class>"</TMPL_IF>><TMPL_IF raw_data><TMPL_VAR raw_data></TMPL_IF><TMPL_LOOP CELL_ROWS><TMPL_IF data><TMPL_IF link><a href="<TMPL_VAR link>"></TMPL_IF><TMPL_VAR data><TMPL_IF link></a></TMPL_IF></TMPL_IF><TMPL_UNLESS __last__><br></TMPL_UNLESS></TMPL_LOOP></td>
</TMPL_LOOP>
</tr>
</TMPL_IF>
<TMPL_IF IS_SEPARATOR><tr><td colspan="<TMPL_VAR NUM_COLUMNS>"><hr size="3" noshade></td></tr></TMPL_IF>
<TMPL_ELSE>
<tr class="listrow<TMPL_VAR outer_idx_odd>">
- <TMPL_LOOP COLUMNS><td<TMPL_IF align> align="<TMPL_VAR align>"</TMPL_IF><TMPL_IF valign> valign="<TMPL_VAR valign>"</TMPL_IF><TMPL_IF class> class="<TMPL_VAR class>"</TMPL_IF>><TMPL_IF raw_data><TMPL_VAR raw_data></TMPL_IF><TMPL_IF data><TMPL_IF link><a href="<TMPL_VAR link>"></TMPL_IF><TMPL_VAR data><TMPL_IF link></a></TMPL_IF></TMPL_IF></td>
+ <TMPL_LOOP COLUMNS><td<TMPL_IF align> align="<TMPL_VAR align>"</TMPL_IF><TMPL_IF valign> valign="<TMPL_VAR valign>"</TMPL_IF><TMPL_IF class> class="<TMPL_VAR class>"</TMPL_IF>><TMPL_IF raw_data><TMPL_VAR raw_data></TMPL_IF><TMPL_LOOP CELL_ROWS><TMPL_IF data><TMPL_IF link><a href="<TMPL_VAR link>"></TMPL_IF><TMPL_VAR data><TMPL_IF link></a></TMPL_IF></TMPL_IF><TMPL_UNLESS __last__><br></TMPL_UNLESS></TMPL_LOOP></td>
</TMPL_LOOP>
</tr>
</TMPL_IF>