summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UI/am-list-departments.html54
-rw-r--r--bin/am.pl125
2 files changed, 98 insertions, 81 deletions
diff --git a/UI/am-list-departments.html b/UI/am-list-departments.html
new file mode 100644
index 00000000..ea29f6ef
--- /dev/null
+++ b/UI/am-list-departments.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title><?lsmb form.titlebar ?></title>
+ <meta http-equiv="Pragma" content="no-cache" />
+ <meta http-equiv="Expires" content="-1" />
+ <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
+ <link rel="stylesheet" href="css/<?lsmb form.stylesheet ?>" type="text/css" title="LedgerSMB stylesheet" />
+
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+ <meta name="robots" content="noindex,nofollow" />
+
+</head>
+<?lsmb PROCESS elements.html ?>
+
+<body>
+
+<table width="100%">
+ <tr>
+ <th class="listtop" colspan="<?lsmb columns.size ?>"><?lsmb form.title ?></th>
+ </tr>
+ <tr><td colspan="<?lsmb columns.size ?>"></td></tr>
+ <tr class="listheading">
+<?lsmb FOREACH column IN columns ?>
+ <th class="listheading"<?lsmb IF column == 'description' ?> width="90%"<?lsmb END ?>><?lsmb IF heading.$column.href ?><a class="listheading" href="<?lsmb heading.$column.href ?>"><?lsmb heading.$column.text ?></a><?lsmb ELSE; heading.$column; END ?></th>
+<?lsmb END ?>
+ </tr>
+<?lsmb FOREACH row IN rows ?>
+ <?lsmb c = "listrow${row.i}" ?>
+<tr class="<?lsmb c ?>">
+ <?lsmb FOREACH column IN columns ?>
+ <td class="<?lsmb c ?>" <?lsmb IF (column == 'cost' || column == 'profit') ?>align="center"<?lsmb END ?>>
+ <?lsmb IF row.$column.href ?>
+ <a href="<?lsmb row.$column.href?>"><?lsmb row.$column.text ?></a>
+ <?lsmb ELSE; row.$column; END ?>
+ </td>
+ <?lsmb END ?>
+</tr>
+<?lsmb END ?>
+ <tr><td colspan="<?lsmb columns.size ?>"><hr size="3" /></td></tr>
+</table>
+
+<br />
+
+<form method="post" action="<?lsmb form.script ?>">
+<?lsmb FOREACH hidden IN hiddens ?>
+<?lsmb PROCESS input element_data={type => 'hidden', name => hidden, value => form.$hidden} ?>
+<?lsmb END ?>
+
+<?lsmb FOREACH button IN buttons ?><?lsmb PROCESS button element_data=button ?><?lsmb END ?>
+</form>
+</body>
+</html>
diff --git a/bin/am.pl b/bin/am.pl
index 12b36db9..9582cecf 100644
--- a/bin/am.pl
+++ b/bin/am.pl
@@ -723,7 +723,7 @@ sub list_department {
AM->departments( \%myconfig, \%$form );
- $href =
+ my $href =
"$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
$form->sort_order();
@@ -731,105 +731,68 @@ sub list_department {
$form->{callback} =
"$form->{script}?action=list_department&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
- $callback = $form->escape( $form->{callback} );
+ my $callback = $form->escape( $form->{callback} );
$form->{title} = $locale->text('Departments');
- @column_index = qw(description cost profit);
-
- $column_header{description} =
- qq|<th width=90%><a class="listheading" href=$href>|
- . $locale->text('Description')
- . qq|</a></th>|;
- $column_header{cost} =
- qq|<th class="listheading" nowrap>|
- . $locale->text('Cost Center')
- . qq|</th>|;
- $column_header{profit} =
- qq|<th class="listheading" nowrap>|
- . $locale->text('Profit Center')
- . qq|</th>|;
-
- $form->header;
-
- print qq|
-<body>
-
-<table width=100%>
- <tr>
- <th class=listtop>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <td>
- <table width=100%>
- <tr class="listheading">
-|;
+ my @column_index = qw(description cost profit);
+ my %column_header;
- for (@column_index) { print "$column_header{$_}\n" }
+ $column_header{description} = { text => $locale->text('Description'),
+ href => $href};
+ $column_header{cost} = $locale->text('Cost Center');
+ $column_header{profit} = $locale->text('Profit Center');
- print qq|
- </tr>
-|;
- foreach $ref ( @{ $form->{ALL} } ) {
+ my @rows;
+ my $i = 0;
+ foreach my $ref ( @{ $form->{ALL} } ) {
+ my %column_data;
$i++;
$i %= 2;
+ $column_data{i} = $i;
- print qq|
- <tr valign=top class=listrow$i>
-|;
-
- $costcenter = ( $ref->{role} eq "C" ) ? "*" : "&nbsp;";
- $profitcenter = ( $ref->{role} eq "P" ) ? "*" : "&nbsp;";
-
- $column_data{description} =
-qq|<td><a href=$form->{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}</td>|;
- $column_data{cost} = qq|<td align=center>$costcenter</td>|;
- $column_data{profit} = qq|<td align=center>$profitcenter</td>|;
+ $column_data{cost} = ( $ref->{role} eq "C" ) ? "*" : " ";
+ $column_data{profit} = ( $ref->{role} eq "P" ) ? "*" : " ";
- for (@column_index) { print "$column_data{$_}\n" }
+ $column_data{description} = { text => $ref->{description},
+ href => qq|$form->{script}?action=edit_department&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback|,};
- print qq|
- </tr>
-|;
+ push @rows, \%column_data;
}
- print qq|
- </table>
- </td>
- </tr>
- <tr>
- <td><hr size=3 noshade></td>
- </tr>
-</table>
-
-<br>
-<form method=post action=$form->{script}>
-|;
-
$form->{type} = "department";
- $form->hide_form(qw(type callback path login sessionid));
-
- print qq|
-<button class="submit" type="submit" name="action" value="add_department">|
- . $locale->text('Add Department')
- . qq|"</button>|;
+ my @hiddens = qw(type callback path login sessionid);
- if ( $form->{lynx} ) {
- require "bin/menu.pl";
- &menubar;
- }
+ ## SC: removing this for now
+ #if ( $form->{lynx} ) {
+ # require "bin/menu.pl";
+ # &menubar;
+ #}
- print qq|
- </form>
-
- </body>
- </html>
-|;
+ my @buttons;
+ push @buttons, {
+ name => 'action',
+ value => 'add_department',
+ text => $locale->text('Add Department'),
+ type => 'submit',
+ class => 'submit',
+ };
+ my $template = LedgerSMB::Template->new_UI(
+ user => \%myconfig,
+ locale => $locale,
+ template => 'am-list-departments');
+ $template->render({
+ form => $form,
+ buttons => \@buttons,
+ columns => \@column_index,
+ heading => \%column_header,
+ rows => \@rows,
+ hiddens => \@hiddens,
+ });
}
sub department_header {