summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-24 21:36:16 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-10-24 21:36:16 +0000
commitabbbc08b1380943d37cac42c3cfd17aa43d92e1e (patch)
treec528935626332ac459bc0c5841d64b135442d04b
parent9f3d4beeceaedb93d87e0cef30d0811462ff4c97 (diff)
Convert language forms to templates
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1813 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--UI/am-language-form.html33
-rw-r--r--bin/am.pl113
2 files changed, 82 insertions, 64 deletions
diff --git a/UI/am-language-form.html b/UI/am-language-form.html
new file mode 100644
index 00000000..93f6b799
--- /dev/null
+++ b/UI/am-language-form.html
@@ -0,0 +1,33 @@
+<?lsmb INCLUDE 'ui-header.html' ?>
+<?lsmb PROCESS elements.html ?>
+<body>
+<form method="post" action="<?lsmb form.script ?>">
+<table width="100%">
+ <tr><th class="listtop"><?lsmb form.title ?></th></tr>
+ <tr><td> </td></tr>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <th align="right"><?lsmb text('Code') ?></th>
+ <td><?lsmb PROCESS input element_data={name => 'code', size => 10, value => form.code} ?></td>
+ </tr>
+ <tr>
+ <th align="right"><?lsmb text('Description') ?></th>
+ <td><?lsmb PROCESS input element_data={name => 'description', size => 60, value => form.description} ?></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr><td colspan="2"><hr size="3" noshade="noshade" /></td></tr>
+</table>
+<?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>
diff --git a/bin/am.pl b/bin/am.pl
index 1f157780..60c73bf0 100644
--- a/bin/am.pl
+++ b/bin/am.pl
@@ -1135,8 +1135,20 @@ sub add_language {
"$form->{script}?action=add_language&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
unless $form->{callback};
- &language_header;
- &form_footer;
+ my %hiddens;
+ my @buttons;
+ &language_header(\%hiddens);
+ &form_footer_buttons(\%hiddens, \@buttons);
+
+ my $template = LedgerSMB::Template->new_UI(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'am-language-form');
+ $template->render({
+ form => $form,
+ buttons => \@buttons,
+ hiddens => \%hiddens,
+ });
}
@@ -1149,11 +1161,22 @@ sub edit_language {
AM->get_language( \%myconfig, \%$form );
$form->{id} = $form->{code};
+ $form->{orphaned} = 1;
- &language_header;
+ my %hiddens;
+ my @buttons;
+ &language_header(\%hiddens);
+ &form_footer_buttons(\%hiddens, \@buttons);
- $form->{orphaned} = 1;
- &form_footer;
+ my $template = LedgerSMB::Template->new_UI(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'am-language-form');
+ $template->render({
+ form => $form,
+ buttons => \@buttons,
+ hiddens => \%hiddens,
+ });
}
@@ -1233,6 +1256,7 @@ sub list_language {
}
sub language_header {
+ my $hiddens = shift;
$form->{title} = $locale->text("$form->{title} Language");
@@ -1241,34 +1265,8 @@ sub language_header {
for (qw(code description)) { $form->{$_} = $form->quote( $form->{$_} ) }
- $form->header;
-
- print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<input type=hidden name=type value=language>
-<input type=hidden name=id value="$form->{code}">
-
-<table width=100%>
- <tr>
- <th class=listtop colspan=2>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <th align="right">| . $locale->text('Code') . qq|</th>
- <td><input name=code size=10 value="$form->{code}"></td>
- <tr>
- <tr>
- <th align="right">| . $locale->text('Description') . qq|</th>
- <td><input name=description size=60 value="$form->{description}"></td>
- </tr>
- <td colspan=2><hr size=3 noshade></td>
- </tr>
-</table>
-|;
-
+ $hiddens->{type} = 'language';
+ $hiddens->{id} = $form->{code};
}
sub save_language {
@@ -1322,40 +1320,27 @@ sub save_language {
sub delete_language {
$form->{title} = $locale->text('Confirm!');
-
- $form->header;
-
- print qq|
-<body>
-
-<form method=post action=$form->{script}>
-|;
-
for (qw(action nextsub)) { delete $form->{$_} }
- $form->hide_form;
-
- print qq|
-<h2 class=confirm>$form->{title}</h2>
-
-<h4>|
- . $locale->text(
+ my %hiddens;
+ $hiddens{$_} = $form->{$_} foreach keys %$form;
+ my @buttons = ({
+ name => 'action',
+ value => 'yes_delete_language',
+ text => $locale->text('Delete Language'),
+ });
+ my $template = LedgerSMB::Template->new_UI(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'form-confirmation');
+ $template->render({
+ form => $form,
+ buttons => \@buttons,
+ hiddens => \%hiddens,
+ query => $locale->text(
'Deleting a language will also delete the templates for the language [_1]',
- $form->{invnumber}
- )
- . qq|</h4>
-
-<input type=hidden name=action value=continue>
-<input type=hidden name=nextsub value=yes_delete_language>
-<button name="action" class="submit" type="submit" value="continue">|
- . $locale->text('Continue')
- . qq|</button>
-</form>
-
-</body>
-</html>
-|;
-
+ $form->{id}),
+ });
}
sub yes_delete_language {