diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/vouchers.pl | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/scripts/vouchers.pl b/scripts/vouchers.pl index 34305139..7e131bc2 100644 --- a/scripts/vouchers.pl +++ b/scripts/vouchers.pl @@ -16,7 +16,7 @@ use strict; sub create_batch { my ($request) = @_; $request->{hidden} = [ - batch_type => $request->{batch_type}, + {name => "batch_type", value => $request->{batch_type}}, ]; my $template = LedgerSMB::Template->new( user =>$request->{_user}, @@ -33,15 +33,40 @@ sub create_vouchers { # This is because these scripts import all functions into the *current* # namespace. People using fastcgi and modperl should *not* cache this # module at the moment. -- CT - my %vouchers_dispatch = ( + my ($request) = shift @_; + use LedgerSMB::Form; + + my $batch = LedgerSMB::Batch->new({base => $request}); + $batch->create; + + my $vouchers_dispatch = + { payable => {script => 'bin/ap.pl', function => sub {add()}}, receivable => {script => 'bin/ar.pl', function => sub {add()}}, payments => {script => 'bin/cp.pl', function => sub {payments()}}, receipts => {script => 'bin/cp.pl', function => sub {receipts()}}, - gl => {script => 'bin/gl.pl'. function => sub {add()}}, - ) - require $vouchers_dispatch{$request->{batch_type}}{script} - $vouchers_dispatch{$request->{batch_type}}{function}(); + gl => {script => 'bin/gl.pl', function => sub {add()}}, + }; + + # Note that the line below is generally considered incredibly bad form. + # However, the code we are including is going to require it for now. + no strict; + our $form = new Form; + our $locale = $request->{_locale}; + for (keys %$request){ + $form->{$_} = $request->{$_}; + } + + $form->{approved} = 0; + $form->{transdate} = $request->{batch_date}; + print STDERR "$request->{batch_type}\n"; + require $vouchers_dispatch->{$request->{batch_type}}{script}; + + my $script = $vouchers_dispatch->{$request->{batch_type}}{script}; + $script =~ s|.*/||; + $form->{script} = $script; + +\ $vouchers_dispatch->{$request->{batch_type}}{function}(); } sub list_vouchers { |