summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UI/am-department-form.html54
-rw-r--r--bin/am.pl79
2 files changed, 87 insertions, 46 deletions
diff --git a/UI/am-department-form.html b/UI/am-department-form.html
new file mode 100644
index 00000000..04b166ae
--- /dev/null
+++ b/UI/am-department-form.html
@@ -0,0 +1,54 @@
+<?lsmb INCLUDE 'ui-header.html' ?>
+<?lsmb PROCESS elements.html ?>
+<body>
+<form method="post" action="<?lsmb form.script ?>">
+<table width="100%">
+ <tr><th class="listtop" colspan="2"><?lsmb form.title ?></th></tr>
+ <tr><td colspan="2"> </td></tr>
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <th align="right"><?lsmb text('Description') ?></th>
+<?lsmb IF row_count > 1 ?>
+ <td><?lsmb PROCESS textarea element_data={name => 'description', cols => 60, rows => row_count, text => form.description} ?></td>
+<?lsmb ELSE ?>
+ <td><?lsmb PROCESS input element_data={name => 'description', size => 60, value => form.description} ?></td>
+<?lsmb END ?>
+ </tr>
+ <tr><td> </td>
+ <td><?lsmb IF form.role == 'C';
+ cost = 'checked';
+ ELSIF form.role == 'P';
+ profit = 'checked';
+ END;
+ PROCESS input element_data={
+ name => 'role',
+ type => 'radio',
+ value => 'C',
+ label => text('Cost Center'),
+ ${cost} => cost,
+ };
+ PROCESS input element_data={
+ name => 'role',
+ type => 'radio',
+ value => 'P',
+ label => text('Profit Center'),
+ ${profit} => profit,
+ }; -?></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 96442c6f..17cb3acb 100644
--- a/bin/am.pl
+++ b/bin/am.pl
@@ -642,9 +642,21 @@ sub add_department {
"$form->{script}?action=add_department&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"
unless $form->{callback};
- &department_header;
- &form_footer;
+ my %hiddens;
+ my @buttons;
+ my $rows = &department_header(\%hiddens);
+ &form_footer_buttons(\%hiddens, \@buttons);
+ my $template = LedgerSMB::Template->new_UI(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'am-department-form');
+ $template->render({
+ form => $form,
+ row_count => $rows,
+ buttons => \@buttons,
+ hiddens => \%hiddens,
+ });
}
sub edit_department {
@@ -653,9 +665,21 @@ sub edit_department {
AM->get_department( \%myconfig, \%$form );
- &department_header;
- &form_footer;
+ my %hiddens;
+ my @buttons;
+ my $rows = &department_header(\%hiddens);
+ &form_footer_buttons(\%hiddens, \@buttons);
+ my $template = LedgerSMB::Template->new_UI(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'am-department-form');
+ $template->render({
+ form => $form,
+ row_count => $rows,
+ buttons => \@buttons,
+ hiddens => \%hiddens,
+ });
}
sub list_department {
@@ -735,6 +759,7 @@ sub list_department {
}
sub department_header {
+ my $hiddens = shift;
$form->{title} = $locale->text("$form->{title} Department");
@@ -743,50 +768,12 @@ sub department_header {
$form->{description} = $form->quote( $form->{description} );
- if ( ( $rows = $form->numtextrows( $form->{description}, 60 ) ) > 1 ) {
- $description =
-qq|<textarea name="description" rows=$rows cols=60 wrap=soft>$form->{description}</textarea>|;
- }
- else {
- $description =
- qq|<input name=description size=60 value="$form->{description}">|;
- }
-
- $costcenter = "checked" if $form->{role} eq "C";
- $profitcenter = "checked" if $form->{role} eq "P";
-
- $form->header;
-
- print qq|
-<body>
-
-<form method=post action=$form->{script}>
-
-<input type=hidden name=id value=$form->{id}>
-<input type=hidden name=type value=department>
+ my $rows = $form->numtextrows( $form->{description}, 60 );
-<table width=100%>
- <tr>
- <th class=listtop colspan=2>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <th align="right">| . $locale->text('Description') . qq|</th>
- <td>$description</td>
- </tr>
- <tr>
- <td></td>
- <td><input type=radio style=radio name=role value="C" $costcenter> |
- . $locale->text('Cost Center') . qq|
- <input type=radio style=radio name=role value="P" $profitcenter> |
- . $locale->text('Profit Center') . qq|
- </td>
- <tr>
- <td colspan=2><hr size=3 noshade></td>
- </tr>
-</table>
-|;
+ $hiddens->{id} = $form->{id};
+ $hiddens->{type} = 'department';
+ $rows;
}
sub save_department {