summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UI/am-list-accounts.csv3
-rw-r--r--UI/am-list-accounts.html66
-rw-r--r--bin/am.pl140
-rw-r--r--bin/ca.pl134
4 files changed, 194 insertions, 149 deletions
diff --git a/UI/am-list-accounts.csv b/UI/am-list-accounts.csv
new file mode 100644
index 00000000..784c9a8f
--- /dev/null
+++ b/UI/am-list-accounts.csv
@@ -0,0 +1,3 @@
+<?lsmb FOREACH column IN columns ?><?lsmb IF heading.$column.text; heading.$column.text; ELSE; heading.$column; END ?><?lsmb IF NOT loop.last ?>,<?lsmb END ?><?lsmb END ?>
+<?lsmb FOREACH row IN rows ?><?lsmb FOREACH column IN columns ?><?lsmb IF row.$column.href; row.$column.text; ELSE; row.$column; END ?><?lsmb IF NOT loop.last ?>,<?lsmb END ?><?lsmb END ?>
+<?lsmb END ?><?lsmb IF totals; t = []; FOREACH column IN columns; t.push(totals.$column); END; t.join(','); END ?>
diff --git a/UI/am-list-accounts.html b/UI/am-list-accounts.html
new file mode 100644
index 00000000..286f550e
--- /dev/null
+++ b/UI/am-list-accounts.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title><?lsmb form.titlebar ?></title>
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Expires" content="-1" />
+ <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
+ <link rel="stylesheet" href="css/<?lsmb form.stylesheet ?>" type="text/css" title="LedgerSMB stylesheet" />
+
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <meta name="robots" content="noindex,nofollow" />
+
+</head>
+
+<?lsmb PROCESS elements.html ?>
+
+<body>
+
+<table width="100%">
+ <tr>
+ <th class="listtop" colspan="<?lsmb columns.size ?>"><?lsmb form.title ?></th>
+ </tr>
+ <tr><td colspan="<?lsmb columns.size ?>"></td></tr>
+ <tr class="listheading">
+<?lsmb FOREACH column IN columns ?>
+ <th class="listtop"><?lsmb heading.$column ?></th>
+<?lsmb END ?>
+ </tr>
+<?lsmb FOREACH row IN rows ?>
+ <?lsmb IF row.heading == 'H'; s = 'th'; c = 'listheading'; ELSE;
+ s = 'td'; c = "listrow${row.i}"; END ?>
+<tr class="<?lsmb c ?>">
+ <?lsmb FOREACH column IN columns ?>
+ <<?lsmb s ?> class="<?lsmb c ?>" <?lsmb IF (!row.heading && (column == 'credit' || column == 'debit')) ?>align="right"<?lsmb END ?>>
+ <?lsmb IF row.$column.href ?>
+ <a href="<?lsmb row.$column.href?>"><?lsmb row.$column.text ?></a>
+ <?lsmb ELSIF column == 'link'; FOREACH l IN row.link.split(':'); l ?><br /><?lsmb END ?>
+ <?lsmb ELSE; row.$column; END ?>
+ </<?lsmb s ?>>
+ <?lsmb END ?>
+</tr>
+<?lsmb END ?>
+<?lsmb IF totals ?>
+<tr class="listtotal">
+ <?lsmb FOREACH column IN columns ?>
+ <th class="listtotal" align="right"><?lsmb totals.$column ?></th>
+ <?lsmb END ?>
+</tr>
+<?lsmb END ?>
+ <tr><td colspan="<?lsmb columns.size ?>"><hr size="3" /></td></tr>
+</table>
+
+<br />
+
+<form method="post" action="<?lsmb form.script ?>">
+<?lsmb FOREACH pair IN form.callback.split('&amp;') ?><?lsmb hidden = pair.split('=') ?>
+<?lsmb IF NOT loop.first ?>
+<?lsmb PROCESS input element_data={type => 'hidden', name => hidden.0, value => hidden.1} ?>
+<?lsmb END ?><?lsmb END ?>
+<?lsmb PROCESS input element_data={type => 'hidden', name => 'callback', value => form.callback} ?>
+
+<?lsmb FOREACH button IN buttons ?><?lsmb PROCESS button element_data=button ?><?lsmb END ?>
+</form>
+</body>
+</html>
diff --git a/bin/am.pl b/bin/am.pl
index 8acd0c0f..e41b9b59 100644
--- a/bin/am.pl
+++ b/bin/am.pl
@@ -38,6 +38,7 @@ use LedgerSMB::Form;
use LedgerSMB::User;
use LedgerSMB::RP;
use LedgerSMB::GL;
+use LedgerSMB::Template;
1;
@@ -368,106 +369,97 @@ sub list_account {
$callback =
"$form->{script}?action=list_account&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
+ $form->{callback} = $callback;
@column_index = qw(accno gifi_accno description debit credit link);
- $column_header{accno} =
- qq|<th class=listtop>| . $locale->text('Account') . qq|</a></th>|;
- $column_header{gifi_accno} =
- qq|<th class=listtop>| . $locale->text('GIFI') . qq|</a></th>|;
- $column_header{description} =
- qq|<th class=listtop>| . $locale->text('Description') . qq|</a></th>|;
- $column_header{debit} =
- qq|<th class=listtop>| . $locale->text('Debit') . qq|</a></th>|;
- $column_header{credit} =
- qq|<th class=listtop>| . $locale->text('Credit') . qq|</a></th>|;
- $column_header{link} =
- qq|<th class=listtop>| . $locale->text('Link') . 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>
-|;
+ $column_header{accno} = $locale->text('Account');
+ $column_header{gifi_accno} = $locale->text('GIFI');
+ $column_header{description} = $locale->text('Description');
+ $column_header{debit} = $locale->text('Debit');
+ $column_header{credit} = $locale->text('Credit');
+ $column_header{link} = $locale->text('Link');
# escape callback
$callback = $form->escape($callback);
- foreach $ca ( @{ $form->{CA} } ) {
+ my @rows;
+ foreach my $ca ( @{ $form->{CA} } ) {
- $ca->{debit} = "&nbsp;";
- $ca->{credit} = "&nbsp;";
+ my %column_data;
+ $ca->{debit} = " ";
+ $ca->{credit} = " ";
if ( $ca->{amount} > 0 ) {
$ca->{credit} =
- $form->format_amount( \%myconfig, $ca->{amount}, 2, "&nbsp;" );
+ $form->format_amount( \%myconfig, $ca->{amount}, 2, " " );
}
if ( $ca->{amount} < 0 ) {
$ca->{debit} =
- $form->format_amount( \%myconfig, -$ca->{amount}, 2, "&nbsp;" );
+ $form->format_amount( \%myconfig, -$ca->{amount}, 2, " " );
}
- $ca->{link} =~ s/:/<br>/og;
+ #$ca->{link} =~ s/:/<br>/og;
$gifi_accno = $form->escape( $ca->{gifi_accno} );
if ( $ca->{charttype} eq "H" ) {
- print qq|<tr class="listheading">|;
-
- $column_data{accno} =
-qq|<th><a class="listheading" href="$form->{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback">$ca->{accno}</a></th>|;
- $column_data{gifi_accno} =
-qq|<th class="listheading"><a href="$form->{script}?action=edit_gifi&accno=$gifi_accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback">$ca->{gifi_accno}</a>&nbsp;</th>|;
- $column_data{description} =
- qq|<th class="listheading">$ca->{description}&nbsp;</th>|;
- $column_data{debit} = qq|<th>&nbsp;</th>|;
- $column_data{credit} = qq| <th>&nbsp;</th>|;
- $column_data{link} = qq|<th>&nbsp;</th>|;
+ $column_data{heading} = 'H';
+ $column_data{accno} = {
+ text => $ca->{accno},
+ href => "$form->{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback"};
+ $column_data{gifi_accno} = {
+ text => $ca->{gifi_accno},
+ href => "$form->{script}?action=edit_gifi&accno=$gifi_accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback"};
+ $column_data{description} = $ca->{description};
+ $column_data{debit} = " ";
+ $column_data{credit} = " ";
+ $column_data{link} = " ";
}
else {
$i++;
$i %= 2;
- print qq|
-<tr valign=top class="listrow$i">|;
- $column_data{accno} =
-qq|<td><a href="$form->{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback">$ca->{accno}</a></td>|;
- $column_data{gifi_accno} =
-qq|<td><a href="$form->{script}?action=edit_gifi&accno=$gifi_accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback">$ca->{gifi_accno}</a>&nbsp;</td>|;
- $column_data{description} = qq|<td>$ca->{description}&nbsp;</td>|;
- $column_data{debit} = qq|<td align="right">$ca->{debit}</td>|;
- $column_data{credit} = qq|<td align="right">$ca->{credit}</td>|;
- $column_data{link} = qq|<td>$ca->{link}&nbsp;</td>|;
+ $column_data{i} = $i;
+ $column_data{accno} = {
+ text => $ca->{accno},
+ href => "$form->{script}?action=edit_account&id=$ca->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback"};
+ $column_data{gifi_accno} = {
+ text => $ca->{gifi_accno},
+ href => "$form->{script}?action=edit_gifi&accno=$gifi_accno&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback"};
+ $column_data{description} = $ca->{description};
+ $column_data{debit} = $ca->{debit};
+ $column_data{credit} = $ca->{credit};
+ $column_data{link} = $ca->{link};
}
-
- for (@column_index) { print "$column_data{$_}\n" }
-
- print "</tr>\n";
- }
-
- print qq|
- <tr><td colspan="$colspan"><hr size="3" noshade /></td></tr>
-</table>
-
-</body>
-</html>
-|;
-
-}
+ push @rows, \%column_data;
+ }
+
+ my @buttons;
+ push @buttons, {
+ name => 'action',
+ value => 'csv_list_account',
+ 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_account { &list_account }
sub delete_account {
diff --git a/bin/ca.pl b/bin/ca.pl
index d606d8a5..09cc8dbe 100644
--- a/bin/ca.pl
+++ b/bin/ca.pl
@@ -47,6 +47,7 @@
#======================================================================
use LedgerSMB::CA;
+use LedgerSMB::Template;
1;
@@ -86,110 +87,93 @@ sub chart_of_accounts {
@column_index = qw(accno gifi_accno description debit credit);
- $column_header{accno} =
- qq|<th class=listtop>| . $locale->text('Account') . qq|</th>\n|;
- $column_header{gifi_accno} =
- qq|<th class=listtop>| . $locale->text('GIFI') . qq|</th>\n|;
- $column_header{description} =
- qq|<th class=listtop>| . $locale->text('Description') . qq|</th>\n|;
- $column_header{debit} =
- qq|<th class=listtop>| . $locale->text('Debit') . qq|</th>\n|;
- $column_header{credit} =
- qq|<th class=listtop>| . $locale->text('Credit') . qq|</th>\n|;
+ $column_header{accno} = $locale->text('Account');
+ $column_header{gifi_accno} = $locale->text('GIFI');
+ $column_header{description} = $locale->text('Description');
+ $column_header{debit} = $locale->text('Debit');
+ $column_header{credit} = $locale->text('Credit');
$form->{title} = $locale->text('Chart of Accounts');
+ $form->{callback} =
+ qq|$form->{script}?path=$form->{path}&action=chart_of_accounts&login=$form->{login}&sessionid=$form->{sessionid}|;
- $colspan = $#column_index + 1;
-
- $form->header;
-
- print qq|
-<body>
-
-<table border=0 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{$_} }
-
- print qq|
- </tr>
-|;
+ my @rows;
+ my $totaldebit = 0;
+ my $totalcredit = 0;
+ foreach my $ca ( @{ $form->{CA} } ) {
+ my %column_data;
- foreach $ca ( @{ $form->{CA} } ) {
+ my $description = $form->escape( $ca->{description} );
+ my $gifi_description = $form->escape( $ca->{gifi_description} );
- $description = $form->escape( $ca->{description} );
- $gifi_description = $form->escape( $ca->{gifi_description} );
-
- $href =
+ my $href =
qq|$form->{script}?path=$form->{path}&action=list&accno=$ca->{accno}&login=$form->{login}&sessionid=$form->{sessionid}&description=$description&gifi_accno=$ca->{gifi_accno}&gifi_description=$gifi_description|;
if ( $ca->{charttype} eq "H" ) {
- print qq|<tr class=listheading>|;
+ $column_data{heading} = 'H';
for (qw(accno description)) {
- $column_data{$_} = "<th class=listheading>$ca->{$_}</th>";
+ $column_data{$_} = $ca->{$_};
}
- $column_data{gifi_accno} =
- "<th class=listheading>$ca->{gifi_accno}&nbsp;</th>";
+ $column_data{gifi_accno} = $ca->{gifi_accno};
}
else {
$i++;
$i %= 2;
- print qq|<tr class=listrow$i>|;
- $column_data{accno} = "<td><a href=$href>$ca->{accno}</a></td>";
- $column_data{gifi_accno} =
-"<td><a href=$href&accounttype=gifi>$ca->{gifi_accno}</a>&nbsp;</td>";
- $column_data{description} = "<td>$ca->{description}</td>";
+ $column_data{i} = $i;
+ $column_data{accno} = {
+ text => $ca->{accno},
+ href => $href};
+ $column_data{gifi_accno} = {
+ text => $ca->{gifi_accno},
+ href => "$href&accounttype=gifi"};
+ $column_data{description} = $ca->{description};
}
$column_data{debit} =
- "<td align=right>"
- . $form->format_amount( \%myconfig, $ca->{debit}, 2, "&nbsp;" )
- . "</td>\n";
+ $form->format_amount( \%myconfig, $ca->{debit}, 2, " " );
$column_data{credit} =
- "<td align=right>"
- . $form->format_amount( \%myconfig, $ca->{credit}, 2, "&nbsp;" )
- . "</td>\n";
+ $form->format_amount( \%myconfig, $ca->{credit}, 2, " " );
$totaldebit += $ca->{debit};
$totalcredit += $ca->{credit};
- for (@column_index) { print "$column_data{$_}\n" }
-
- print qq|
-</tr>
-|;
+ push @rows, \%column_data;
}
for (qw(accno gifi_accno description)) {
- $column_data{$_} = "<td>&nbsp;</td>";
+ $column_data{$_} = " ";
}
- $column_data{debit} =
- "<th align=right class=listtotal>"
- . $form->format_amount( \%myconfig, $totaldebit, 2, 0 ) . "</th>";
- $column_data{credit} =
- "<th align=right class=listtotal>"
- . $form->format_amount( \%myconfig, $totalcredit, 2, 0 ) . "</th>";
-
- print "<tr class=listtotal>";
-
- for (@column_index) { print "$column_data{$_}\n" }
-
- print qq|
-</tr>
-<tr>
- <td colspan=$colspan><hr size=3 noshade></td>
-</tr>
-</table>
-
-</body>
-</html>
-|;
-
+ $column_data{debit} = $form->format_amount( \%myconfig, $totaldebit, 2, 0 );
+ $column_data{credit} = $form->format_amount(\%myconfig, $totalcredit, 2, 0);
+
+ my @buttons;
+ push @buttons, {
+ name => 'action',
+ value => 'csv_chart_of_accounts',
+ 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,
+ totals => \%column_data,
+ rows => \@rows,
+ });
}
+sub csv_chart_of_accounts { &chart_of_accounts }
+
sub list {
$form->{title} = $locale->text('List Transactions');