summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UI/am-list-accounts.html7
-rw-r--r--UI/ca-list-selector.html79
-rw-r--r--UI/ca-list-transactions.csv3
-rw-r--r--UI/ca-list-transactions.html94
-rw-r--r--bin/ca.pl370
5 files changed, 311 insertions, 242 deletions
diff --git a/UI/am-list-accounts.html b/UI/am-list-accounts.html
index 286f550e..31563563 100644
--- a/UI/am-list-accounts.html
+++ b/UI/am-list-accounts.html
@@ -12,7 +12,6 @@
<meta name="robots" content="noindex,nofollow" />
</head>
-
<?lsmb PROCESS elements.html ?>
<body>
@@ -54,10 +53,8 @@
<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 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 ?>
diff --git a/UI/ca-list-selector.html b/UI/ca-list-selector.html
new file mode 100644
index 00000000..0931dcdc
--- /dev/null
+++ b/UI/ca-list-selector.html
@@ -0,0 +1,79 @@
+<!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>
+
+<form method="post" action="ca.pl">
+
+<?lsmb FOREACH hidden IN ['accno', 'description', 'sort', 'oldsort', 'accounttype', 'gifi_accno', 'gifi_description'];
+ PROCESS input element_data={type => 'hidden', name => hidden, value => form.$hidden}; END ?>
+
+<table border="0" width="100%">
+ <tr><th class="listtop"><?lsmb form.title ?></th></tr>
+ <tr height="5"></tr>
+ <tr valign="top">
+ <td>
+ <table>
+
+ <tr>
+ <th align="right"><?lsmb text('From') ?></th>
+ <td><?lsmb PROCESS input element_data={class => 'date', name => 'fromdate' size => '11', title="yyyy-mm-dd"} ?></td>
+ <th align="right"><?lsmb text('To') ?></th>
+ <td><?lsmb PROCESS input element_data={class => 'date', name => 'todate' size => '11', title="yyyy-mm-dd"} ?></td>
+ </tr>
+
+<?lsmb IF form.all_department ?>
+ <tr>
+ <th align="right"><?lsmb text('Department') ?></th>
+ <td colspan="3">
+ <?lsmb PROCESS select element_data=selectdepartment ?></td>
+ </tr>
+<?lsmb END ?>
+<?lsmb IF form.all_years ?>
+ <tr>
+ <th align="right"><?lsmb text('Period') ?></th>
+ <td colspan="3">
+ <?lsmb PROCESS select element_data=selectmonth ?>
+ <?lsmb PROCESS select element_data=selectyear ?>
+ <?lsmb FOREACH button IN intervals ?>
+ <?lsmb PROCESS input element_data=button; button.text ?>
+ <?lsmb END ?>
+ </td>
+ </tr>
+<?lsmb END ?>
+
+ <tr>
+ <th align="right"><?lsmb text('Include in Report') ?></th>
+ <td colspan="3">
+ <?lsmb FOREACH check IN includes;
+ PROCESS input element_data=check; check.text; END ?>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr><td><hr size=3 noshade></td></tr>
+</table>
+
+<?lsmb FOREACH hidden IN ['login', 'path', 'sessionid'];
+ PROCESS input element_data={type => 'hidden', name => hidden, value => form.$hidden}; END ?>
+
+<br />
+<?lsmb PROCESS button element_data={class => "submit", name => "action", value => "list_transactions", text => text('List Transactions')} ?>
+</form>
+
+</body>
+</html>
diff --git a/UI/ca-list-transactions.csv b/UI/ca-list-transactions.csv
new file mode 100644
index 00000000..1b62b75c
--- /dev/null
+++ b/UI/ca-list-transactions.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.text; row.$column.text; ELSIF column == 'accno'; accs = []; FOREACH account IN row.accno; accs.push(account.text); END; accs.join(':'); 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/ca-list-transactions.html b/UI/ca-list-transactions.html
new file mode 100644
index 00000000..01647731
--- /dev/null
+++ b/UI/ca-list-transactions.html
@@ -0,0 +1,94 @@
+<!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; IF option.text ?><a href="<?lsmb option.href ?>"><?lsmb option.text ?></a><?lsmb ELSE; option ?><br /><?lsmb END; 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 column == 'accno'; FOREACH link IN row.accno ?>
+ <a href="<?lsmb link.href ?>"><?lsmb link.text ?></a>
+ <?lsmb END; ELSIF 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="ca.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/ca.pl b/bin/ca.pl
index 09cc8dbe..68ffdc5f 100644
--- a/bin/ca.pl
+++ b/bin/ca.pl
@@ -190,114 +190,69 @@ sub list {
# get departments
$form->all_departments( \%myconfig );
+ my $selectdepartment;
if ( @{ $form->{all_department} } ) {
- $form->{selectdepartment} = "<option>\n";
-
+ $selectdepartment = {name => 'department', options => []};
for ( @{ $form->{all_department} } ) {
- $form->{selectdepartment} .=
-qq|<option value="$_->{description}--$_->{id}">$_->{description}\n|;
+ push @{$selectdepartment->{options}}, {
+ value => "$_->{description}--$_->{id}",
+ text => $_->{description}};
}
}
- $department = qq|
- <tr>
- <th align=right nowrap>| . $locale->text('Department') . qq|</th>
- <td colspan=3><select name=department>$form->{selectdepartment}</select></td>
- </tr>
-| if $form->{selectdepartment};
-
+ my $selectmonth;
+ my $selectyear;
+ my $interval;
if ( @{ $form->{all_years} } ) {
# accounting years
- $form->{selectaccountingyear} = "<option>\n";
+ $selectyear = {name => 'year', options => []};
for ( @{ $form->{all_years} } ) {
- $form->{selectaccountingyear} .= qq|<option>$_\n|;
+ push @{$selectyear->{options}}, {value => $_, text => $_};
}
- $form->{selectaccountingmonth} = "<option>\n";
+
+ $selectmonth = {name => 'month', options => []};
for ( sort keys %{ $form->{all_month} } ) {
- $form->{selectaccountingmonth} .=
- qq|<option value=$_>|
- . $locale->text( $form->{all_month}{$_} ) . qq|\n|;
+ push @{$selectmonth->{options}}, {value => $_,
+ text => $locale->text($form->{all_month}{$_})};
}
-
- $selectfrom = qq|
- <tr>
- <th align=right>| . $locale->text('Period') . qq|</th>
- <td colspan=3>
- <select name=month>$form->{selectaccountingmonth}</select>
- <select name=year>$form->{selectaccountingyear}</select>
- <input name=interval class=radio type=radio value=0 checked>&nbsp;|
- . $locale->text('Current') . qq|
- <input name=interval class=radio type=radio value=1>&nbsp;|
- . $locale->text('Month') . qq|
- <input name=interval class=radio type=radio value=3>&nbsp;|
- . $locale->text('Quarter') . qq|
- <input name=interval class=radio type=radio value=12>&nbsp;|
- . $locale->text('Year') . qq|
- </td>
- </tr>
-|;
+ $intervals = [
+ {type => 'radio', name => 'interval', value => '0',
+ checked => 'checked', text => $locale->text('Current')},
+ {type => 'radio', name => 'interval', value => '1',
+ text => $locale->text('Month')},
+ {type => 'radio', name => 'interval', value => '3',
+ text => $locale->text('Quarter')},
+ {type => 'radio', name => 'interval', value => '12',
+ text => $locale->text('Year')}];
}
- $form->header;
-
- print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<input type=hidden name=accno value=$form->{accno}>
-<input type=hidden name=description value="$form->{description}">
-
-<input type=hidden name=sort value=transdate>
-<input type=hidden name=oldsort value=transdate>
-
-<input type=hidden name=accounttype value=$form->{accounttype}>
-<input type=hidden name=gifi_accno value=$form->{gifi_accno}>
-<input type=hidden name=gifi_description value="$form->{gifi_description}">
-
-<table border=0 width=100%>
- <tr><th class=listtop>$form->{title}</th></tr>
- <tr height="5"></tr>
- <tr valign=top>
- <td>
- <table>
- $department
- <tr>
- <th align=right>| . $locale->text('From') . qq|</th>
- <td><input class="date" name=fromdate size=11 title="$myconfig{dateformat}"></td>
- <th align=right>| . $locale->text('To') . qq|</th>
- <td><input class="date" name=todate size=11 title="$myconfig{dateformat}"></td>
- </tr>
- $selectfrom
- <tr>
- <th align=right>| . $locale->text('Include in Report') . qq|</th>
- <td colspan=3>
- <input name=l_accno class=checkbox type=checkbox value=Y>&nbsp;|
- . $locale->text('AR/AP') . qq|
- <input name=l_subtotal class=checkbox type=checkbox value=Y>&nbsp;|
- . $locale->text('Subtotal') . qq|
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr><td><hr size=3 noshade></td></tr>
-</table>
-
-<input type="hidden" name="login" value="$form->{login}">
-<input type="hidden" name="path" value="$form->{path}">
-<input type="hidden" name="sessionid" value="$form->{sessionid}">
-
-<br><button class="submit" type="submit" name="action" value="list_transactions">|
- . $locale->text('List Transactions')
- . qq|</button>
-</form>
-
-</body>
-</html>
-|;
-
+ my @includes = ({
+ type => 'checkbox',
+ name => 'l_accno',
+ value => 'Y',
+ text => $locale->text('AR/AP'),
+ },{
+ type => 'checkbox',
+ name => 'l_subtotal',
+ value => 'Y',
+ text => $locale->text('Subtotal'),
+ });
+ $form->{sort} ||= ''; #SC: blah. Find out why this breaks when undef
+ my $template = LedgerSMB::Template->new(
+ user => \%myconfig,
+ locale => $locale,
+ path => 'UI',
+ template => 'ca-list-selector',
+ format => 'HTML');
+ $template->render({
+ form => $form,
+ includes => \@includes,
+ selectmonth => $selectmonth,
+ selectyear => $selectyear,
+ selectdepartment => $selectdepartment,
+ intervals => $intervals,
+ });
}
sub list_transactions {
@@ -332,30 +287,21 @@ sub list_transactions {
$drilldown .= "&prevreport=" . $form->escape( $form->{prevreport} );
# figure out which column comes first
- $column_header{transdate} =
- qq|<th><a class=listheading href=$href&sort=transdate>|
- . $locale->text('Date')
- . qq|</a></th>|;
- $column_header{reference} =
- qq|<th><a class=listheading href=$href&sort=reference>|
- . $locale->text('Reference')
- . qq|</a></th>|;
- $column_header{description} =
- qq|<th><a class=listheading href=$href&sort=description>|
- . $locale->text('Description')
- . qq|</a></th>|;
- $column_header{cleared} =
- qq|<th class=listheading>| . $locale->text('R') . qq|</th>|;
- $column_header{source} =
- qq|<th class=listheading>| . $locale->text('Source') . qq|</th>|;
- $column_header{debit} =
- qq|<th class=listheading>| . $locale->text('Debit') . qq|</th>|;
- $column_header{credit} =
- qq|<th class=listheading>| . $locale->text('Credit') . qq|</th>|;
- $column_header{balance} =
- qq|<th class=listheading>| . $locale->text('Balance') . qq|</th>|;
- $column_header{accno} =
- qq|<th class=listheading>| . $locale->text('AR/AP') . qq|</th>|;
+ $column_header{transdate} = {
+ text => $locale->text('Date'),
+ href => "$href&sort=transdate"};
+ $column_header{reference} = {
+ text => $locale->text('Reference'),
+ href => "$href&sort=reference"};
+ $column_header{description} = {
+ text => $locale->text('Description'),
+ href => "$href&sort=description"};
+ $column_header{cleared} = $locale->text('R');
+ $column_header{source} = $locale->text('Source');
+ $column_header{debit} = $locale->text('Debit');
+ $column_header{credit} = $locale->text('Credit');
+ $column_header{balance} = $locale->text('Balance');
+ $column_header{accno} = $locale->text('AR/AP');
@columns = qw(transdate reference description debit credit);
if ( $form->{link} =~ /_paid/ ) {
@@ -379,13 +325,14 @@ sub list_transactions {
$form->{title} .= " $form->{accno} - $form->{description}";
+ my @options;
if ( $form->{department} ) {
($department) = split /--/, $form->{department};
- $options = $locale->text('Department') . " : $department<br>";
+ push @options, $locale->text('Department') . " : $department";
}
if ( $form->{projectnumber} ) {
($projectnumber) = split /--/, $form->{projectnumber};
- $options .= $locale->text('Project Number') . " : $projectnumber<br>";
+ push @options, $locale->text('Project Number') . " : $projectnumber";
}
if ( $form->{fromdate} || $form->{todate} ) {
@@ -404,10 +351,11 @@ sub list_transactions {
$locale->date( \%myconfig, $form->current_date( \%myconfig ), 1 );
}
- $form->{period} = "<a href=$form->{prevreport}>$form->{period}</a>"
- if $form->{prevreport};
+ if ($form->{prevreport}) {
+ push @options, {text => $form->{period}, href=> $form->{prevreport}};
+ $form->{period} = "<a href=$form->{prevreport}>$form->{period}</a>";
+ }
- $options .= $form->{period};
# construct callback
$department = $form->escape( $form->{department}, 1 );
@@ -424,35 +372,11 @@ sub list_transactions {
$form->{callback} .= "&$_=$form->{$_}";
}
- $form->header;
-
- print qq|
-<body>
-
-<table width=100%>
- <tr>
- <th class=listtop>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <td>$options</td>
- </tr>
- <tr>
- <td>
- <table width=100%>
- <tr class=listheading>
-|;
-
- for (@column_index) { print "$column_header{$_}\n" }
-
- print qq|
- </tr>
-|;
-
# add sort to callback
$form->{callback} =
$form->escape( $form->{callback} . "&sort=$form->{sort}" );
+ my @rows;
if ( @{ $form->{CA} } ) {
$sameitem = $form->{CA}->[0]->{ $form->{sort} };
}
@@ -461,53 +385,38 @@ sub list_transactions {
$ml *= -1 if $form->{contra};
if ( $form->{accno} && $form->{balance} ) {
+ my %column_data;
- for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
+ for (@column_index) { $column_data{$_} = " " }
$column_data{balance} =
- "<td align=right>"
- . $form->format_amount( \%myconfig, $form->{balance} * $ml, 2, 0 )
- . "</td>";
+ $form->format_amount( \%myconfig, $form->{balance} * $ml, 2, 0 );
$i++;
$i %= 2;
- print qq|
- <tr class=listrow$i>
-|;
- for (@column_index) { print "$column_data{$_}\n" }
- print qq|
- </tr>
-|;
+ $column_data{i} = $i;
+ push @rows, \%column_data;
}
- foreach $ca ( @{ $form->{CA} } ) {
+ foreach my $ca ( @{ $form->{CA} } ) {
+ my %column_data;
if ( $form->{l_subtotal} eq 'Y' ) {
if ( $sameitem ne $ca->{ $form->{sort} } ) {
- &ca_subtotal;
+ push @rows, &ca_subtotal;
}
}
- # construct link to source
- $href =
-"<a href=$ca->{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$form->{callback}>$ca->{reference}</a>";
-
$column_data{debit} =
- "<td align=right>"
- . $form->format_amount( \%myconfig, $ca->{debit}, 2, "&nbsp;" )
- . "</td>";
+ $form->format_amount( \%myconfig, $ca->{debit}, 2, " " );
$column_data{credit} =
- "<td align=right>"
- . $form->format_amount( \%myconfig, $ca->{credit}, 2, "&nbsp;" )
- . "</td>";
+ $form->format_amount( \%myconfig, $ca->{credit}, 2, " " );
$form->{balance} += $ca->{amount};
$column_data{balance} =
- "<td align=right>"
- . $form->format_amount( \%myconfig, $form->{balance} * $ml, 2, 0 )
- . "</td>";
+ $form->format_amount( \%myconfig, $form->{balance} * $ml, 2, 0 );
$subtotaldebit += $ca->{debit};
$subtotalcredit += $ca->{credit};
@@ -515,19 +424,21 @@ sub list_transactions {
$totaldebit += $ca->{debit};
$totalcredit += $ca->{credit};
- $column_data{transdate} = qq|<td>$ca->{transdate}</td>|;
- $column_data{reference} = qq|<td>$href</td>|;
- $column_data{description} = qq|<td>$ca->{description}&nbsp;</td>|;
+ $column_data{transdate} = $ca->{transdate};
+ $column_data{reference} = {
+ text => $ca->{reference},
+ href => "$ca->{module}.pl?path=$form->{path}&action=edit&id=$ca->{id}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$form->{callback}"};
+
+ $column_data{description} = $ca->{description};
$column_data{cleared} =
- ( $ca->{cleared} ) ? qq|<td>*</td>| : qq|<td>&nbsp;</td>|;
- $column_data{source} = qq|<td>$ca->{source}&nbsp;</td>|;
+ ( $ca->{cleared} ) ? "*" : " ";
+ $column_data{source} = $ca->{source};
- $column_data{accno} = qq|<td>|;
+ $column_data{accno} = [];
for ( @{ $ca->{accno} } ) {
- $column_data{accno} .= "<a href=$drilldown&accno=$_>$_</a> ";
+ push @{$column_data{accno}}, {text => $_, href=> "$drilldown&accno=$_>"};
}
- $column_data{accno} .= qq|&nbsp;</td>|;
if ( $ca->{id} != $sameid ) {
$i++;
@@ -535,84 +446,69 @@ sub list_transactions {
}
$sameid = $ca->{id};
- print qq|
- <tr class=listrow$i>
-|;
-
- for (@column_index) { print "$column_data{$_}\n" }
-
- print qq|
- </tr>
-|;
+ $column_data{i} = $i;
+ push @rows, \%column_data;
}
if ( $form->{l_subtotal} eq 'Y' ) {
- &ca_subtotal;
+ push @rows, &ca_subtotal;
}
- for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
+ for (@column_index) { $column_data{$_} = " " }
$column_data{debit} =
- "<th align=right class=listtotal>"
- . $form->format_amount( \%myconfig, $totaldebit, 2, "&nbsp;" ) . "</th>";
+ $form->format_amount( \%myconfig, $totaldebit, 2, " " );
$column_data{credit} =
- "<th align=right class=listtotal>"
- . $form->format_amount( \%myconfig, $totalcredit, 2, "&nbsp;" ) . "</th>";
+ $form->format_amount( \%myconfig, $totalcredit, 2, " " );
$column_data{balance} =
- "<th align=right class=listtotal>"
- . $form->format_amount( \%myconfig, $form->{balance} * $ml, 2, 0 )
- . "</th>";
-
- print qq|
- <tr class=listtotal>
-|;
-
- for (@column_index) { print "$column_data{$_}\n" }
-
- print qq|
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-
-</body>
-</html>
-|;
+ $form->format_amount( \%myconfig, $form->{balance} * $ml, 2, 0 );
+
+ my @buttons;
+ push @buttons, {
+ name => 'action',
+ value => 'csv_list_transactions',
+ text => $locale->text('CSV Report'),
+ type => 'submit',
+ class => 'submit',
+ };
+ $form->{callback} = $form->unescape($form->{callback});
+ my $template = LedgerSMB::Template->new(
+ user => \%myconfig,
+ locale => $locale,
+ path => 'UI',
+ template => 'ca-list-transactions',
+ format => ($form->{action} =~ /^csv/)? 'CSV': 'HTML');
+ $template->render({
+ form => \%$form,
+ options => \@options,
+ buttons => \@buttons,
+ columns => \@column_index,
+ heading => \%column_header,
+ totals => \%column_data,
+ rows => \@rows,
+ });
}
+sub csv_list_transactions { &list_transactions }
+
sub ca_subtotal {
- for (@column_index) { $column_data{$_} = "<td>&nbsp;</td>" }
+ my %column_data;
+ for (@column_index) { $column_data{$_} = " " }
$column_data{debit} =
- "<th align=right class=listsubtotal>"
- . $form->format_amount( \%myconfig, $subtotaldebit, 2, "&nbsp;" )
- . "</th>";
+ $form->format_amount( \%myconfig, $subtotaldebit, 2, " " );
$column_data{credit} =
- "<th align=right class=listsubtotal>"
- . $form->format_amount( \%myconfig, $subtotalcredit, 2, "&nbsp;" )
- . "</th>";
+ $form->format_amount( \%myconfig, $subtotalcredit, 2, " " );
$subtotaldebit = 0;
$subtotalcredit = 0;
$sameitem = $ca->{ $form->{sort} };
+ $column_data{is_subtotal} = 1;
- print qq|
- <tr class=listsubtotal>
-|;
-
- for (@column_index) { print "$column_data{$_}\n" }
-
- print qq|
- </tr>
-|;
-
+ return \%column_data;
}