summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-05 14:27:19 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-05 14:27:19 +0000
commit7303b29f8eef4c96e8c8dfb4713a321952c427f1 (patch)
tree441e64cee0cd96282142012ac02b4302170e2d79
parentd885a1f0c89a56714f0db7c0e4d8dbf9f30a5ea9 (diff)
Merging am-list-accounts and gl-report templates into form-dynatable
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1701 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--UI/form-dynatable.csv (renamed from UI/am-list-accounts.csv)2
-rw-r--r--UI/form-dynatable.html (renamed from UI/am-list-accounts.html)36
-rw-r--r--UI/form-dynatable.odst (renamed from UI/am-list-accounts.odst)0
-rw-r--r--UI/form-dynatable.xlst (renamed from UI/am-list-accounts.xlst)0
-rw-r--r--UI/gl-report.csv3
-rw-r--r--UI/gl-report.html92
-rw-r--r--bin/am.pl27
-rw-r--r--bin/ca.pl14
-rw-r--r--bin/gl.pl63
9 files changed, 101 insertions, 136 deletions
diff --git a/UI/am-list-accounts.csv b/UI/form-dynatable.csv
index 784c9a8f..9b65baba 100644
--- a/UI/am-list-accounts.csv
+++ b/UI/form-dynatable.csv
@@ -1,3 +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 FOREACH row IN rows ?><?lsmb FOREACH column IN columns ?><?lsmb IF row.$column.text; 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/form-dynatable.html
index 31563563..706942a2 100644
--- a/UI/am-list-accounts.html
+++ b/UI/form-dynatable.html
@@ -20,21 +20,33 @@
<tr>
<th class="listtop" colspan="<?lsmb columns.size ?>"><?lsmb form.title ?></th>
</tr>
- <tr><td colspan="<?lsmb columns.size ?>"></td></tr>
+ <tr>
+ <?lsmb IF options.defined ?>
+ <td><?lsmb FOREACH option IN options; option ?><br /><?lsmb END ?></td>
+ <?lsmb ELSE ?>
+ <td colspan="<?lsmb columns.size ?>"></td></tr>
+ <?lsmb END ?>
+ </tr>
<tr class="listheading">
<?lsmb FOREACH column IN columns ?>
- <th class="listtop"><?lsmb heading.$column ?></th>
+ <th class="listtop">
+ <?lsmb IF heading.$column.href ?><a class="listtop" href="<?lsmb heading.$column.href ?>"><?lsmb heading.$column.text ?></a>
+ <?lsmb ELSE; heading.$column; END ?>
+ </th>
<?lsmb END ?>
</tr>
+ <?lsmb USE dumper(indent=2, pad="<br>") ?>
<?lsmb FOREACH row IN rows ?>
- <?lsmb IF row.heading == 'H'; s = 'th'; c = 'listheading'; ELSE;
- s = 'td'; c = "listrow${row.i}"; END ?>
+<?lsmb IF row.class == 'heading'; s = 'th'; c = 'listheading';
+ ELSIF row.class == 'subtotal'; s = 'th'; c = 'listsubtotal';
+ 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 s ?> class="<?lsmb c ?>" <?lsmb IF (!row.class.defined || row.class != 'heading') && row_alignment.$column ?>align="<?lsmb row_alignment.$column ?>"<?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 ELSIF row.$column.delimiter;
+ FOREACH l IN row.$column.text.split(row.$column.delimiter); l ?><br /><?lsmb END ?>
<?lsmb ELSE; row.$column; END ?>
</<?lsmb s ?>>
<?lsmb END ?>
@@ -53,11 +65,13 @@
<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 ?>
+<?lsmb FOREACH hidden IN hiddens.keys;
+ PROCESS input element_data={
+ type => 'hidden',
+ name => hidden,
+ value => hiddens.$hidden
+ }; END ?>
+<?lsmb FOREACH button IN buttons; PROCESS button element_data=button; END ?>
</form>
</body>
</html>
diff --git a/UI/am-list-accounts.odst b/UI/form-dynatable.odst
index 7a4cdfdc..7a4cdfdc 100644
--- a/UI/am-list-accounts.odst
+++ b/UI/form-dynatable.odst
diff --git a/UI/am-list-accounts.xlst b/UI/form-dynatable.xlst
index 7c00fb67..7c00fb67 100644
--- a/UI/am-list-accounts.xlst
+++ b/UI/form-dynatable.xlst
diff --git a/UI/gl-report.csv b/UI/gl-report.csv
deleted file mode 100644
index b8b42e71..00000000
--- a/UI/gl-report.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-<?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.text; row.$column.text; ELSE; row.$column; END ?><?lsmb IF NOT loop.last ?>,<?lsmb END ?><?lsmb END ?>
-<?lsmb END ?><?lsmb FOREACH column IN columns ?><?lsmb totals.$column ?><?lsmb IF NOT loop.last ?>,<?lsmb END ?><?lsmb END ?>
diff --git a/UI/gl-report.html b/UI/gl-report.html
deleted file mode 100644
index 7ab68933..00000000
--- a/UI/gl-report.html
+++ /dev/null
@@ -1,92 +0,0 @@
-<!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"><?lsmb form.title ?></th>
- </tr>
- <tr><td colspan="<?lsmb columns.size ?>"> </td></tr>
- <tr>
- <td><?lsmb FOREACH option IN options; option ?><br /><?lsmb END ?></td>
- </tr>
- <tr>
- <td>
- <table width="100%">
- <tr class="listheading">
-<?lsmb FOREACH column IN columns ?><?lsmb IF heading.$column.href ?>
-<th class="listheading"><a class="listheading" href="<?lsmb heading.$column.href ?>"><?lsmb heading.$column.text ?></a></th>
-<?lsmb ELSE ?>
-<th class="listheading"><?lsmb heading.$column ?></th>
-<?lsmb END ?>
-<?lsmb END ?>
- </tr>
-
-<?lsmb FOREACH row IN rows ?>
-<?lsmb IF row.is_subtotal ?>
- <tr class="listsubtotal">
- <?lsmb FOREACH column IN columns ?>
- <th align="right" class="listsubtotal"><?lsmb row.$column ?></th>
- <?lsmb END ?>
- </tr>
-<?lsmb ELSE ?>
- <tr class="listrow<?lsmb row.i ?>">
- <?lsmb FOREACH column IN columns ?>
- <?lsmb IF column == 'balance' ?>
- <td align="right">
- <?lsmb ELSIF column == 'debit' ?>
- <td align="right">
- <?lsmb ELSIF column == 'credit' ?>
- <td align="right">
- <?lsmb ELSE ?>
- <td>
- <?lsmb END ?>
-<?lsmb IF row.$column.href ?>
- <a href="<?lsmb row.$column.href?>"><?lsmb row.$column.text ?></a>
-<?lsmb ELSE ?>
- <?lsmb row.$column ?>
-<?lsmb END ?>
- </td>
- <?lsmb END ?>
- </tr>
-<?lsmb END ?>
-<?lsmb END ?>
- <tr class="listtotal">
-<?lsmb FOREACH column IN columns ?>
-<th align="right" class="listtotal"><?lsmb totals.$column ?></th>
-<?lsmb END ?>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size="3" noshade="noshade" /></td>
- </tr>
-</table>
-
-<br />
-
-<form method="post" action="gl.pl">
-<?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 02070cf6..e79a9998 100644
--- a/bin/am.pl
+++ b/bin/am.pl
@@ -403,7 +403,7 @@ sub list_account {
$gifi_accno = $form->escape( $ca->{gifi_accno} );
if ( $ca->{charttype} eq "H" ) {
- $column_data{heading} = 'H';
+ $column_data{class} = 'heading';
$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"};
@@ -429,7 +429,7 @@ sub list_account {
$column_data{description} = $ca->{description};
$column_data{debit} = $ca->{debit};
$column_data{credit} = $ca->{credit};
- $column_data{link} = $ca->{link};
+ $column_data{link} = {text => $ca->{link}, delimiter => ':'};
}
push @rows, \%column_data;
@@ -445,20 +445,30 @@ sub list_account {
class => 'submit',
};
}
+ my %hiddens = (
+ callback => $callback,
+ action => 'list_account',
+ path => $form->{path},
+ login => $form->{login},
+ sessionid => $form->{sessionid},
+ );
+ my %row_alignment = ('credit' => 'right', 'debit' => 'right');
my $format = uc substr($form->{action}, 0, 3);
my $template = LedgerSMB::Template->new(
user => \%myconfig,
locale => $locale,
path => 'UI',
- template => 'am-list-accounts',
+ template => 'form-dynatable',
format => ($format ne 'LIS')? $format: 'HTML');
$template->render({
- form => \%$form,
+ form => $form,
buttons => \@buttons,
+ hiddens => \%hiddens,
columns => \@column_index,
heading => \%column_header,
rows => \@rows,
+ row_alignment => \%row_alignment,
});
}
@@ -496,11 +506,17 @@ sub list_gifi {
AM->gifi_accounts( \%myconfig, \%$form );
$form->{title} = $locale->text('GIFI');
+ my %hiddens;
# construct callback
my $callback =
"$form->{script}?action=list_gifi&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
$form->{callback} = $callback;
+ $hiddens{callback} = $callback;
+ $hiddens{action} = 'list_gifi';
+ $hiddens{path} = $form->{path};
+ $hiddens{login} = $form->{login};
+ $hiddens{sessionid} = $form->{sessionid};
my @column_index = qw(accno description);
my %column_header;
@@ -538,10 +554,11 @@ sub list_gifi {
user => \%myconfig,
locale => $locale,
path => 'UI',
- template => 'am-list-accounts',
+ template => 'form-dynatable',
format => ($form->{action} =~ /^csv/)? 'CSV': 'HTML');
$template->render({
form => \%$form,
+ hiddens => \%hiddens,
buttons => \@buttons,
columns => \@column_index,
heading => \%column_header,
diff --git a/bin/ca.pl b/bin/ca.pl
index 99a7ef66..7b85c73f 100644
--- a/bin/ca.pl
+++ b/bin/ca.pl
@@ -84,6 +84,7 @@ use LedgerSMB::Template;
sub chart_of_accounts {
CA->all_accounts( \%myconfig, \%$form );
+ my %hiddens;
@column_index = qw(accno gifi_accno description debit credit);
@@ -96,6 +97,11 @@ sub chart_of_accounts {
$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}|;
+ $hiddens{callback} = $form->{callback};
+ $hiddens{path} = $form->{path};
+ $hiddens{action} = 'chart_of_accounts';
+ $hiddens{login} = $form->{login};
+ $hiddens{sessionid} = $form->{sessionid};
my @rows;
my $totaldebit = 0;
@@ -110,7 +116,7 @@ sub chart_of_accounts {
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" ) {
- $column_data{heading} = 'H';
+ $column_data{class} = 'heading';
for (qw(accno description)) {
$column_data{$_} = $ca->{$_};
}
@@ -160,15 +166,17 @@ qq|$form->{script}?path=$form->{path}&action=list&accno=$ca->{accno}&login=$form
user => \%myconfig,
locale => $locale,
path => 'UI',
- template => 'am-list-accounts',
+ template => 'form-dynatable',
format => ($form->{action} =~ /^csv/)? 'CSV': 'HTML');
$template->render({
form => \%$form,
buttons => \@buttons,
+ hiddens => \%hiddens,
columns => \@column_index,
heading => \%column_header,
- totals => \%column_data,
+ totals => \%column_data,
rows => \@rows,
+ row_alignment => {'credit' => 'right', 'debit' => 'right'},
});
}
diff --git a/bin/gl.pl b/bin/gl.pl
index d75bac43..dffa4c0a 100644
--- a/bin/gl.pl
+++ b/bin/gl.pl
@@ -445,6 +445,14 @@ sub generate_report {
$callback =
"$form->{script}?action=generate_report&direction=$form->{direction}&oldsort=$form->{oldsort}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
+ my %hiddens = (
+ 'action' => 'generate_report',
+ 'direction' => $form->{direction},
+ 'oldsort' => $form->{oldsort},
+ 'path' => $form->{path},
+ 'login' => $form->{login},
+ 'sessionid' => $form->{sessionid},
+ );
%acctype = (
'A' => $locale->text('Asset'),
'L' => $locale->text('Liability'),
@@ -465,33 +473,39 @@ sub generate_report {
if ( $form->{accno} ) {
$href .= "&accno=" . $form->escape( $form->{accno} );
$callback .= "&accno=" . $form->escape( $form->{accno}, 1 );
+ $hiddens{accno} = $form->{accno};
push @options, $locale->text('Account')
. " : $form->{accno} $form->{account_description}";
}
if ( $form->{gifi_accno} ) {
$href .= "&gifi_accno=" . $form->escape( $form->{gifi_accno} );
$callback .= "&gifi_accno=" . $form->escape( $form->{gifi_accno}, 1 );
+ $hiddens{gifi_accno} = $form->{gifi_accno};
push @options, $locale->text('GIFI')
. " : $form->{gifi_accno} $form->{gifi_account_description}";
}
if ( $form->{source} ) {
$href .= "&source=" . $form->escape( $form->{source} );
$callback .= "&source=" . $form->escape( $form->{source}, 1 );
+ $hiddens{source} = $form->{source};
push @options, $locale->text('Source') . " : $form->{source}";
}
if ( $form->{memo} ) {
$href .= "&memo=" . $form->escape( $form->{memo} );
$callback .= "&memo=" . $form->escape( $form->{memo}, 1 );
+ $hiddens{memo} = $form->{memo};
push @options, $locale->text('Memo') . " : $form->{memo}";
}
if ( $form->{reference} ) {
$href .= "&reference=" . $form->escape( $form->{reference} );
$callback .= "&reference=" . $form->escape( $form->{reference}, 1 );
+ $hiddens{reference} = $form->{reference};
push @options, $locale->text('Reference') . " : $form->{reference}";
}
if ( $form->{department} ) {
$href .= "&department=" . $form->escape( $form->{department} );
$callback .= "&department=" . $form->escape( $form->{department}, 1 );
+ $hiddens{department} = $form->{department};
($department) = split /--/, $form->{department};
push @options, $locale->text('Department') . " : $department";
}
@@ -499,23 +513,27 @@ sub generate_report {
if ( $form->{description} ) {
$href .= "&description=" . $form->escape( $form->{description} );
$callback .= "&description=" . $form->escape( $form->{description}, 1 );
+ $hiddens{description} = $form->{description};
push @options, $locale->text('Description') . " : $form->{description}";
}
if ( $form->{notes} ) {
$href .= "&notes=" . $form->escape( $form->{notes} );
$callback .= "&notes=" . $form->escape( $form->{notes}, 1 );
+ $hiddens{notes} = $form->{notes};
push @options, $locale->text('Notes') . " : $form->{notes}";
}
if ( $form->{datefrom} ) {
$href .= "&datefrom=$form->{datefrom}";
$callback .= "&datefrom=$form->{datefrom}";
+ $hiddens{datefrom} = $form->{datefrom};
push @options, $locale->text('From') . " "
. $locale->date( \%myconfig, $form->{datefrom}, 1 );
}
if ( $form->{dateto} ) {
$href .= "&dateto=$form->{dateto}";
$callback .= "&dateto=$form->{dateto}";
+ $hiddens{dateto} = $form->{dateto};
my $option = $locale->text('To') . " "
. $locale->date( \%myconfig, $form->{dateto}, 1 );
if ( $form->{datefrom} ) {
@@ -529,12 +547,14 @@ sub generate_report {
if ( $form->{amountfrom} ) {
$href .= "&amountfrom=$form->{amountfrom}";
$callback .= "&amountfrom=$form->{amountfrom}";
+ $hiddens{amountfrom} = $form->{amountfrom};
push @options, $locale->text('Amount') . " >= "
. $form->format_amount( \%myconfig, $form->{amountfrom}, 2 );
}
if ( $form->{amountto} ) {
$href .= "&amountto=$form->{amountto}";
$callback .= "&amountto=$form->{amountto}";
+ $hiddens{amountto} = $form->{amountto};
my $option .= $form->format_amount( \%myconfig, $form->{amountto}, 2 );
if ( $form->{amountfrom} ) {
$options[$#options] .= " <= $option";
@@ -571,16 +591,19 @@ sub generate_report {
# add column to href and callback
$callback .= "&l_$item=Y";
$href .= "&l_$item=Y";
+ $hiddens{"l_$item"} = 'Y';
}
}
if ( $form->{l_subtotal} eq 'Y' ) {
$callback .= "&l_subtotal=Y";
$href .= "&l_subtotal=Y";
+ $hiddens{l_subtotal} = 'Y';
}
$callback .= "&category=$form->{category}";
$href .= "&category=$form->{category}";
+ $hiddens{category} = $form->{category};
$column_header{id} =
{text => $locale->text('ID'), href=> "$href&sort=id"};
@@ -609,6 +632,8 @@ sub generate_report {
# add sort to callback
$form->{callback} = "$callback&sort=$form->{sort}";
$callback = $form->escape( $form->{callback} );
+ $hiddens{sort} = $form->{sort};
+ $hiddens{callback} = $form->{callback};
$cml = 1;
@@ -761,7 +786,7 @@ sub generate_report {
text => $locale->text('CSV Report'),
type => 'submit',
class => 'submit',
- };
+ };
##SC: Taking this out for now...
## if ( $form->{lynx} ) {
@@ -769,33 +794,29 @@ sub generate_report {
## &menubar;
## }
- my $template;
- if ($form->{action} eq 'csv_gl_report') {
- $template = LedgerSMB::Template->new(
- user => \%myconfig,
- locale => $locale,
- path => 'UI',
- template => 'gl-report',
- format => 'CSV'
- );
- } else {
- $template = LedgerSMB::Template->new(
- user => \%myconfig,
- locale => $locale,
- path => 'UI',
- template => 'gl-report',
- format => 'HTML',
- # no_escape => 1
+ my %row_alignment = (
+ 'balance' => 'right',
+ 'debit' => 'right',
+ 'credit' => 'right'
);
- }
+ my $template;
+ my $format = uc substr($form->{action}, 0, 3);
+ my $template = LedgerSMB::Template->new(
+ user => \%myconfig,
+ locale => $locale,
+ path => 'UI',
+ template => 'form-dynatable',
+ format => ($format ne 'CSV')? 'HTML': 'CSV');
$template->render({
form => \%$form,
buttons => \@buttons,
+ hiddens => \%hiddens,
options => \@options,
columns => \@column_index,
heading => \%column_header,
rows => \@rows,
- totals => \%column_data
+ row_alignment => \%row_alignment,
+ totals => \%column_data,
});
}
@@ -811,7 +832,7 @@ sub gl_subtotal_tt {
$form->format_amount( \%myconfig, $subtotalcredit, 2, " " );
for (@column_index) { $column_data{$_} = " " }
- $column_data{'is_subtotal'} = 1;
+ $column_data{class} = 'subtotal';
$column_data{debit} = $subtotaldebit;
$column_data{credit} = $subtotalcredit;