From 481b05ee19cafa2ac0a632cabe51021012ed0c19 Mon Sep 17 00:00:00 2001 From: tetragon Date: Mon, 15 Oct 2007 18:00:54 +0000 Subject: Convert till_closing to templates git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1759 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/rc.pl | 157 +++++++++++++++++++------------------------------------------- 1 file changed, 48 insertions(+), 109 deletions(-) (limited to 'bin') diff --git a/bin/rc.pl b/bin/rc.pl index c79fa8cf..8f331a3b 100644 --- a/bin/rc.pl +++ b/bin/rc.pl @@ -209,6 +209,7 @@ sub reconciliation { sub continue { &{ $form->{nextsub} } } sub till_closing { + my %hiddens; $form->{callback} = "$form->{script}?path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; @@ -222,31 +223,16 @@ sub till_closing { $form->{title} = $locale->text( "Closing Till For [_1]", $form->{login} ); require "pos.conf.pl"; RC->getposlines( \%myconfig, \%$form ); - $form->header; - print qq| - - -
{script}> -{path}> -{login}> -{sessionid}> - - - - - - -
$form->{title}
- -|; + $hiddens{path} = $form->{path}; + $hiddens{login} = $form->{login}; + $hiddens{sessionid} = $form->{sessionid}; + $hiddens{callback} = $form->{callback}; + $hiddens{sum} = "$form->{sum}" * -1; - print ""; - map { print ""; } - @colheadings; - print ""; my $j; my $source; + my @sources; foreach $source ( sort keys %pos_sources ) { $amount = 0; foreach $ref ( @{ $form->{TB} } ) { @@ -257,103 +243,56 @@ sub till_closing { } ++$j; $j = $j % 2; - print qq| - - - |; + push @sources, {i => $j, + label => $pos_sources{$source}, + source => $source, + currenamount => "${curren}${amount}", + }; + $hiddens{"expected_$source"} = "$amount"; } - print qq| - - -
" . $locale->text($_) . "
| . $pos_sources{$source} . qq| - ${curren}$amount 
-|; + my @units; foreach my $unit ( @{ $pos_config{'breakdown'} } ) { # XXX Needs to take into account currencies that don't use 2 dp my $calcval = $form->parse_amount( \%pos_config, $unit ); $calcval = sprintf( '%03d', $calcval * 100 ) if $calcval < 1; my $subval = 'sub_' . $calcval; + my $unit_name = $calcval; $calcval = 'calc_' . $calcval; - print qq| - - - - |; + push @units, { + unit => $unit, + unit_name => "$unit_name", + currenunit => "${curren}${unit}", + quantity => {name => $calcval, value => $form->{$calcval}}, + value => {name => $subval, value => $form->{$subval}}, + }; } - print qq| - - - - -
X ${curren}${unit} =
 | . $locale->text("Subtotal") . qq|:
- -|; - print qq||; - print qq| -
- - - -|; + my @buttons = ({ + name => 'calculate', + value => 'Calculate', + type => 'button', + text => $locale->text('Calculate'), + attributes => {onclick => 'custom_calc_total()'}, + }, { + name => 'action', + value => 'close_till', + text => $locale->text('Close Till'), + }); + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'rc-till-closing', + ); + $template->render({ + form => $form, + user => \%myconfig, + 'pos' => \%pos_config, + hiddens => \%hiddens, + columns => \@colheadings, + sources => \@sources, + units => \@units, + buttons => \@buttons, + }); } sub close_till { -- cgit v1.2.3