summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-22 15:34:16 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-09-22 15:34:16 +0000
commit5ed2e96253b5cac400ac80e782d3e146c6edb421 (patch)
treefe1fa30f4b158cac0dd5aeeb2d9ace5e2c19144e /bin
parent37aa30e2a8219b52aae29ecb5db53ecd892b72b5 (diff)
Converting list_gifi to templates
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1644 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'bin')
-rw-r--r--bin/am.pl86
1 files changed, 37 insertions, 49 deletions
diff --git a/bin/am.pl b/bin/am.pl
index e41b9b59..12b36db9 100644
--- a/bin/am.pl
+++ b/bin/am.pl
@@ -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}&nbsp;</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";