diff options
-rw-r--r-- | bin/am.pl | 86 |
1 files changed, 37 insertions, 49 deletions
@@ -493,71 +493,59 @@ sub list_gifi { $form->{title} = $locale->text('GIFI'); # construct callback - $callback = + my $callback = "$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; + $form->{callback} = $callback; - @column_index = qw(accno description); - - $column_header{accno} = - qq|<th class="listheading">| . $locale->text('GIFI') . qq|</a></th>|; - $column_header{description} = - qq|<th class="listheading">| - . $locale->text('Description') - . qq|</a></th>|; - - $form->header; - $colspan = $#column_index + 1; - - print qq| -<body> - -<table width=100%> - <tr> - <th class=listtop colspan=$colspan>$form->{title}</th> - </tr> - <tr height="5"></tr> - <tr class="listheading"> -|; - - for (@column_index) { print "$column_header{$_}\n" } - - print qq| -</tr> -|; + my @column_index = qw(accno description); + my %column_header; + my @rows; - # escape callback - $callback = $form->escape($callback); + $column_header{accno} = $locale->text('GIFI'); + $column_header{description} = $locale->text('Description'); + my $i = 0; foreach $ca ( @{ $form->{ALL} } ) { + my %column_data; $i++; $i %= 2; - - print qq| -<tr valign=top class=listrow$i>|; + $column_data{i} = $i; $accno = $form->escape( $ca->{accno} ); - $column_data{accno} = -qq|<td><a href=$form->{script}?action=edit_gifi&coa=1&accno=$accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ca->{accno}</td>|; - $column_data{description} = qq|<td>$ca->{description} </td>|; - - for (@column_index) { print "$column_data{$_}\n" } + $column_data{accno} = {text => $ca->{accno}, href => + qq|$form->{script}?action=edit_gifi&coa=1&accno=$accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback|}; + $column_data{description} = $ca->{description}; - print "</tr>\n"; + push @rows, \%column_data; } - print qq| - <tr> - <td colspan=$colspan><hr size=3 noshade></td> - </tr> -</table> - -</body> -</html> -|; + my @buttons; + push @buttons, { + name => 'action', + value => 'csv_list_gifi', + text => $locale->text('CSV Report'), + type => 'submit', + class => 'submit', + }; + my $template = LedgerSMB::Template->new( + user => \%myconfig, + locale => $locale, + path => 'UI', + template => 'am-list-accounts', + format => ($form->{action} =~ /^csv/)? 'CSV': 'HTML'); + $template->render({ + form => \%$form, + buttons => \@buttons, + columns => \@column_index, + heading => \%column_header, + rows => \@rows, + }); } +sub csv_list_gifi { &list_gifi } + sub add_gifi { $form->{title} = "Add"; |