diff options
author | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-22 23:15:54 +0000 |
---|---|---|
committer | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-09-22 23:15:54 +0000 |
commit | 09d4792a5a453e2efdf1fc4afa8d440b4d4f11a8 (patch) | |
tree | 5d09cfc57f4576e815f6a69b66a715f99a53d958 /bin | |
parent | d30faec429417478db8b643f82ba5f82f57d172a (diff) |
Templating the department list
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1649 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'bin')
-rw-r--r-- | bin/am.pl | 125 |
1 files changed, 44 insertions, 81 deletions
@@ -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" ) ? "*" : " "; - $profitcenter = ( $ref->{role} eq "P" ) ? "*" : " "; - - $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 { |