From 1aaa9fe478fc2e9ea0fa744edb704ccacf46d07b Mon Sep 17 00:00:00 2001 From: einhverfr Date: Thu, 13 Nov 2008 01:15:47 +0000 Subject: Correcting issues with draft editing. Moving AA::post_transaction to use strict. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2392 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/aa.pl | 24 +++++++++++++++++++++++- bin/gl.pl | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/aa.pl b/bin/aa.pl index 858ac849..e3b869dd 100644 --- a/bin/aa.pl +++ b/bin/aa.pl @@ -883,7 +883,16 @@ sub form_footer { { ndx => 8, key => 'D', value => $locale->text('Delete') }, ); if (!$form->{approved} && !$form->{batch_id}){ - $button{approve} = { ndx => 3, key => 'O', value => $locale->text('Post') }; + $button{approve} = { + ndx => 3, + key => 'O', + value => $locale->text('Post as Saved') }; + if (grep /^lsmb_$form->{company}__draft_modify$/, @{$form->{_roles}}){ + $button{edit_and_approve} = { + ndx => 4, + key => 'O', + value => $locale->text('Post as Shown') }; + } delete $button{post_as_new}; delete $button{print_and_post_as_new}; delete $button{post}; @@ -942,6 +951,18 @@ sub form_footer { } +sub edit_and_approve { + use LedgerSMB::DBObject::Draft; + use LedgerSMB; + my $lsmb = LedgerSMB->new(); + $lsmb->merge($form); + my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb}); + $draft->delete(); + delete $form->{id}; + AA->post_transaction( \%myconfig, \%$form ); + approve(); +} + sub approve { use LedgerSMB::DBObject::Draft; use LedgerSMB; @@ -1150,6 +1171,7 @@ sub post { if ( $form->{printandpost} ) { &{"print_$form->{formname}"}( $old_form, 1 ); } + print STDERR "Redirecting\n"; $form->redirect( $locale->text('Transaction posted!') ); } else { diff --git a/bin/gl.pl b/bin/gl.pl index 5581259c..ef33a0b7 100644 --- a/bin/gl.pl +++ b/bin/gl.pl @@ -92,6 +92,39 @@ sub pos_adjust { $form->{accno_3} = $pos_config{'coa_prefix'}; } +sub edit_and_approve { + use LedgerSMB::DBObject::Draft; + use LedgerSMB; + my $lsmb = LedgerSMB->new(); + $lsmb->merge($form); + my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb}); + $draft->delete(); + GL->post_transaction( \%myconfig, \%$form ); + approve(); +} + +sub approve { + use LedgerSMB::DBObject::Draft; + use LedgerSMB; + my $lsmb = LedgerSMB->new(); + $lsmb->merge($form); + + my $draft = LedgerSMB::DBObject::Draft->new({base => $lsmb}); + + $draft->approve(); + if ($form->{callback}){ + print "Location: $form->{callback}\n"; + print "Status: 302 Found\n\n"; + print ""; + my $url = $form->{callback}; + print qq|If you are not redirected automatically, click | + . qq|here.|; + + } else { + $form->info($locale->text('Draft Posted')); + } +} + sub add_pos_adjust { $form->{pos_adjust} = 1; $form->{reference} = @@ -1283,6 +1316,22 @@ sub form_footer { for ( "update", "post", "schedule" ) { $a{$_} = 1 } } } + if (!$form->{approved} && !$form->{batch_id}){ + $button{approve} = { + ndx => 3, + key => 'S', + value => $locale->text('Post as Saved') }; + $a{approve} = 1; + $a{edit_and_approve} = 1; + if (grep /^lsmb_$form->{company}__draft_modify$/, @{$form->{_roles}}){ + $button{edit_and_approve} = { + ndx => 4, + key => 'O', + value => $locale->text('Post as Shown') }; + } + delete $button{post_as_new}; + delete $button{post}; + } for ( keys %button ) { delete $button{$_} if !$a{$_} } for ( sort { $button{$a}->{ndx} <=> $button{$b}->{ndx} } keys %button ) -- cgit v1.2.3