diff options
-rw-r--r-- | UI/form-confirmation.html | 16 | ||||
-rw-r--r-- | bin/bp.pl | 49 | ||||
-rw-r--r-- | bin/gl.pl | 48 |
3 files changed, 63 insertions, 50 deletions
diff --git a/UI/form-confirmation.html b/UI/form-confirmation.html new file mode 100644 index 00000000..27256840 --- /dev/null +++ b/UI/form-confirmation.html @@ -0,0 +1,16 @@ +<?lsmb INCLUDE 'ui-header.html' ?> +<?lsmb PROCESS elements.html ?> +<body> +<form method="post" action="<?lsmb form.script ?>"> +<h2 class="confirm"><?lsmb form.title ?></h2> +<h4><?lsmb query ?></h4> +<?lsmb FOREACH hidden IN hiddens.keys; + PROCESS input element_data={ + type => 'hidden', + name => hidden, + value => hiddens.item(hidden) + }; END ?> +<?lsmb FOREACH button IN buttons; PROCESS button element_data=button; END ?> +</form> +</body> +</html> @@ -178,7 +178,8 @@ sub search { sub remove { - $selected = 0; + my $selected = 0; + my %hiddens; for $i ( 1 .. $form->{rowcount} ) { if ( $form->{"checked_$i"} ) { @@ -191,36 +192,30 @@ sub remove { $form->{title} = $locale->text('Confirm!'); - $form->header; - - print qq| -<body> - -<form method=post action=$form->{script}> -|; - for (qw(action header)) { delete $form->{$_} } - - foreach $key ( keys %$form ) { - print qq|<input type=hidden name=$key value="$form->{$key}">\n|; + foreach my $key ( keys %$form ) { + $hiddens{$key} = $form->{$key}; } - print qq| -<h2 class=confirm>$form->{title}</h2> - -<h4>| - . $locale->text( - 'Are you sure you want to remove the marked entries from the queue?') - . qq|</h4> + my $query = $locale->text( + 'Are you sure you want to remove the marked entries from the queue?'); -<button name="action" class="submit" type="submit" value="remove_from_queue">| - . $locale->text('Yes') - . qq|</button> -</form> - -</body> -</html> -|; + my @buttons = ({ + name => 'action', + value => 'remove_from_queue', + text => $locale->text('Yes'), + }); + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'form-confirmation', + ); + $template->render({ + form => $form, + query => $query, + hiddens => \%hiddens, + buttons => \@buttons, + }); } @@ -51,6 +51,7 @@ use LedgerSMB::Template; require "bin/arap.pl"; +$form->{login} = 'test'; 1; # end of main @@ -1267,35 +1268,36 @@ sub form_footer { sub delete { - $form->header; - - print qq| -<body> - -<form method=post action=$form->{script}> -|; - + my %hiddens; delete $form->{action}; + foreach (keys %$form) { + $hiddens{$_} = $form->{$_} unless ref $form->{$_}; + } - $form->hide_form; - - print qq| -<h2 class=confirm>| . $locale->text('Confirm!') . qq|</h2> - -<h4>| - . $locale->text( 'Are you sure you want to delete Transaction [_1]', + $form->{title} = $locale->text('Confirm!'); + my $query = $locale->text( + 'Are you sure you want to delete Transaction [_1]', $form->{reference} ) - . qq|</h4> - -<button name="action" class="submit" type="submit" value="yes">| - . $locale->text('Yes') - . qq|</button> -</form> -|; + my @buttons = ({ + name => 'action', + value => 'delete_transaction', + text => $locale->text('Yes'), + }); + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'form-confirmation', + ); + $template->render({ + form => $form, + query => $query, + hiddens => \%hiddens, + buttons => \@buttons, + }); } -sub yes { +sub delete_transaction { if ( GL->delete_transaction( \%myconfig, \%$form ) ) { $form->redirect( $locale->text('Transaction deleted!') ); |