From ce405c1d3133f2e4b0c5936b498ab908cc1f95a9 Mon Sep 17 00:00:00 2001 From: tetragon Date: Sat, 3 Nov 2007 16:53:36 +0000 Subject: Template display_form git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1844 4979c152-3d1c-0410-bac9-87ea11338e46 --- UI/rc-display-form.html | 126 ++++++++++++++++ bin/rc.pl | 378 ++++++++++++++++-------------------------------- 2 files changed, 249 insertions(+), 255 deletions(-) create mode 100644 UI/rc-display-form.html diff --git a/UI/rc-display-form.html b/UI/rc-display-form.html new file mode 100644 index 00000000..b29a80e0 --- /dev/null +++ b/UI/rc-display-form.html @@ -0,0 +1,126 @@ + + + + +
+ + + + + + + + + + + + + + + +

+ + + + + + + + + + + < class="" align=""> + + +
+ + + > + + + + + + + + + + +
+ + +
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + +
+ 'statementbalance', + size => '11', + value => form.statementbalance, + } -?> +
text('Under'), value => 'under'}, + {text => text('Over'), value => 'over'}]; + IF form.over_under == 'under'; + options.0.selected = 'selected'; + ELSIF form.over_under == 'over'; + options.1.selected = 'selected'; + END; + PROCESS select element_data={ + name => 'over_under', + options => options, + } ?> + 'null', + size => '11', + value => form.null2, + } ?>
+ 'null', + size => '11', + value => hiddens.difference, + } ?>
+
+ + +
+ +
+ 'hidden', + name => hidden, + value => hiddens.item(hidden) + }; END ?> + + +
+ + diff --git a/bin/rc.pl b/bin/rc.pl index 68bcd9ca..618ff2dc 100644 --- a/bin/rc.pl +++ b/bin/rc.pl @@ -435,7 +435,10 @@ sub get_payments { } sub display_form { + my %hiddens; + my @buttons; + my @column_index; if ( $form->{report} ) { @column_index = qw(transdate source name cleared debit credit); } @@ -443,99 +446,57 @@ sub display_form { @column_index = qw(transdate source name cleared debit credit balance); } - $column_header{cleared} = qq|| . $locale->text('R') . qq||; - $column_header{source} = - "" . $locale->text('Source') . ""; - $column_header{name} = - "" . $locale->text('Description') . ""; - $column_header{transdate} = - "" . $locale->text('Date') . ""; - - $column_header{debit} = - "" . $locale->text('Debit') . ""; - $column_header{credit} = - "" . $locale->text('Credit') . ""; - $column_header{balance} = - "" . $locale->text('Balance') . ""; + my %column_header; + $column_header{cleared} = $locale->text('R'); + $column_header{source} = $locale->text('Source'); + $column_header{name} = $locale->text('Description'); + $column_header{transdate} = $locale->text('Date'); + $column_header{debit} = $locale->text('Debit'); + $column_header{credit} = $locale->text('Credit'); + $column_header{balance} = $locale->text('Balance'); + my @options; if ( $form->{fromdate} ) { - $option .= "\n
" if ($option); - $option .= - $locale->text('From') . " " - . $locale->date( \%myconfig, $form->{fromdate}, 1 ); + push @options, + $locale->text('From [_1]', + $locale->date( \%myconfig, $form->{fromdate}, 1 )); } if ( $form->{todate} ) { - $option .= "\n
" if ($option); - $option .= - $locale->text('To') . " " - . $locale->date( \%myconfig, $form->{todate}, 1 ); + push @options, + $locale->text('To [_1]', + $locale->date( \%myconfig, $form->{todate}, 1 )); } $form->{title} = "$form->{accno}--$form->{account}"; - $form->header; - - print qq| - - -
{script}> + $hiddens{source} = $form->{source}; + $hiddens{cumulative_error} = $form->{cumulative_error}; - - - - - - - - - - - - - -|; - if ( $form->{'pos'} ) { - $close_next = qq||; - $done = ""; - } - else { - $close_next = ""; - $done = qq||; + push @buttons, { + name => 'action', + value => 'close_next', + text => $locale->text('Close Next') + }; + } else { + push @buttons, { + name => 'action', + value => 'done', + text => $locale->text('Done') + }; } + + $hiddens{difference} = $difference; if ( $form->{'pos'} ) { - $difference = qq| - - - - - - - |; - if ( $form->{'over_under'} ) { - $o_u = $form->{'over_under'}; - $difference =~ s/(value=$o_u)/SELECTED $1/g; - } + $hiddens{'pos'} = 'true'; } - else { - $difference = qq| - - - - - - |; - } - - if ( $form->{report} ) { - print qq| - -
$form->{title}
$option
- - -|; - - for (@column_index) { print "\n$column_header{$_}" } - - print qq| - -|; - - $ml = ( $form->{category} eq 'A' ) ? -1 : 1; + my $ml = ( $form->{category} eq 'A' ) ? -1 : 1; $form->{beginningbalance} *= $ml; $form->{fx_balance} *= $ml; if ( !$form->{fx_transaction} ) { $form->{beginningbalance} -= $form->{fx_balance}; } - $balance = $form->{beginningbalance}; + my $balance = $form->{beginningbalance}; - $i = 0; - $j = 0; - - for (qw(cleared transdate source debit credit)) { - $column_data{$_} = ""; - } + my $i = 0; + my $j = 0; + my @rows; if ( !$form->{report} ) { - $column_data{name} = - qq||; - $column_data{balance} = - ""; - print qq| - -|; - - for (@column_index) { print "\n$column_data{$_}" } - - print qq| - -|; + my %column_data; + for (qw(cleared transdate source debit credit)) { + $column_data{$_} = ' '; + } + $column_data{name} = $locale->text('Beginning Balance'); + $column_data{balance} = $form->format_amount(\%myconfig, $balance, 2, 0); + $column_data{i} = $j; + push @rows, \%column_data; } - foreach $ref ( @{ $form->{PR} } ) { + foreach my $ref ( @{ $form->{PR} } ) { $i++; @@ -543,129 +504,93 @@ sub display_form { next if $ref->{fx_transaction}; } - $checked = ( $ref->{cleared} ) ? "checked" : ""; + my %column_data; + my $checked = ( $ref->{cleared} ) ? "checked" : undef; - %temp = (); + my %temp = (); if ( !$ref->{fx_transaction} ) { for (qw(name source transdate)) { $temp{$_} = $ref->{$_} } } - $column_data{name} = ""; - $column_data{source} = qq| - {id}>|; + $column_data{name}{delimiter} = "|"; + for ( @{ $temp{name} } ) { $column_data{name}{text} .= "$_|" } - $column_data{debit} = ""; - $column_data{credit} = ""; + $column_data{source} = $temp{source}; + + $column_data{debit} = ' '; + $column_data{credit} = ' '; $balance += $ref->{amount} * $ml; + $hiddens{"id_$i"} = $ref->{id}; if ( $ref->{amount} < 0 ) { - $totaldebits += $ref->{amount} * -1; - - $column_data{debit} = ""; - - } - else { - + $column_data{debit} = + $form->format_amount(\%myconfig, $ref->{amount} * -1, 2, ' '); + } else { $totalcredits += $ref->{amount}; - $column_data{credit} = - ""; - + $form->format_amount(\%myconfig, $ref->{amount}, 2, ' '); } - $column_data{balance} = - ""; + $column_data{balance} = $form->format_amount(\%myconfig, $balance, 2, 0); if ( $ref->{fx_transaction} ) { - $column_data{cleared} = - ($clearfx) ? qq|| : qq||; + ($clearfx) ? '*': ' '; $cleared += $ref->{amount} * $ml if $clearfx; - - } - else { - + } else { if ( $form->{report} ) { - if ( $ref->{cleared} ) { - $column_data{cleared} = qq||; + $column_data{cleared} = '*'; $clearfx = 1; - } - else { - $column_data{cleared} = qq||; + } else { + $column_data{cleared} = ' '; $clearfx = 0; } - - } - else { - + } else { if ( $ref->{oldcleared} ) { $cleared += $ref->{amount} * $ml; $clearfx = 1; - $column_data{cleared} = qq| - {cleared}> - {oldcleared}> - - |; - } - else { + $hiddens{"cleared_$i"} = $ref->{cleared}; + $hiddens{"oldcleared_$i"} = $ref->{oldcleared}; + $hiddens{"source_$i"} = $ref->{source}; + $hiddens{"amount_$i"} = $ref->{amount}; + $column_data{cleared} = '*'; + } else { $cleared += $ref->{amount} * $ml if $checked; $clearfx = ($checked) ? 1 : 0; - $column_data{cleared} = -qq||; + $hiddens{"source_$i"} = $ref->{source}; + $hiddens{"amount_$i"} = $ref->{amount}; + $column_data{cleared} = {input => { + type => 'checkbox', + value => 1, + name => "cleared_$i", + $checked => $checked, + }}; } - } } - $column_data{transdate} = qq| - {transdate}>|; + $hiddens{"transdate_$i"} = $ref->{transdate}; + $column_data{transdate} = $temp{transdate}; $j++; $j %= 2; - print qq| - -|; - - for (@column_index) { print "\n$column_data{$_}" } - - print qq| - -|; + $column_data{i} = $j; + push @rows, \%column_data; } - $form->{rowcount} = $i; # print totals - for (@column_index) { $column_data{$_} = "" } + my %column_data; + for (@column_index) { $column_data{$_} = ' ' } $column_data{debit} = - ""; + $form->format_amount( \%myconfig, $totaldebits, 2, ' ' ); $column_data{credit} = - ""; - - print qq| - -|; - - for (@column_index) { print "\n$column_data{$_}" } + $form->format_amount( \%myconfig, $totalcredits, 2, ' ' ); $form->{statementbalance} = $form->parse_amount( \%myconfig, $form->{statementbalance} ); @@ -679,119 +604,62 @@ qq| -
 | . $locale->text('Beginning Balance') . qq|" - . $form->format_amount( \%myconfig, $balance, 2, 0 ) . "
"; - for ( @{ $temp{name} } ) { $column_data{name} .= "$_
" } - $column_data{name} .= "
$temp{source}   " - . $form->format_amount( \%myconfig, $ref->{amount} * -1, - 2, " " ) - . "" - . $form->format_amount( \%myconfig, $ref->{amount}, 2, " " ) - . "" - . $form->format_amount( \%myconfig, $balance, 2, 0 ) . "* * * - - - $temp{transdate} 
 " - . $form->format_amount( \%myconfig, $totaldebits, 2, " " ) . "" - . $form->format_amount( \%myconfig, $totalcredits, 2, " " ) - . "
{statementbalance} = $form->format_amount( \%myconfig, $form->{statementbalance}, 2, 0 ); - print qq| -
-
-
| . $locale->text('Difference') . qq|
-|; + if (! $form->{report} ) { + $hiddens{$_} = $form->{$_} foreach + qw(fx_transaction summary rowcount accno account fromdate todate path login sessionid); + unshift @buttons, { + name => 'action', + value => 'select_all', + text => $locale->text('Select all'), + }; + unshift @buttons, { + name => 'action', + value => 'update', + text => $locale->text('Update'), + }; } - else { - print qq| - - - - - - - -
- - - - - - - $difference -
| . $locale->text('Statement Balance') . qq|{statementbalance}>
-
- - - -
- - -|; +##SC: Temporary removal +## if ( $form->{lynx} ) { +## require "bin/menu.pl"; +## &menubar; +## } - $form->hide_form( - qw(fx_transaction summary rowcount accno account fromdate todate path login sessionid) + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'rc-display-form', ); - - print qq| -
- - - $done - $close_next |; - } - - if ( $form->{lynx} ) { - require "bin/menu.pl"; - &menubar; - } - - print qq| -
- - - -|; - + $template->render({ + form => $form, + hiddens => \%hiddens, + options => \@options, + rows => \@rows, + totals => \%column_data, + columns => \@column_index, + heading => \%column_header, + buttons => \@buttons, + }); } sub update { -- cgit v1.2.3