summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UI/am-list-departments.html2
-rw-r--r--bin/am.pl123
2 files changed, 45 insertions, 80 deletions
diff --git a/UI/am-list-departments.html b/UI/am-list-departments.html
index ea29f6ef..51c5f155 100644
--- a/UI/am-list-departments.html
+++ b/UI/am-list-departments.html
@@ -30,7 +30,7 @@
<?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 ?>>
+ <td class="<?lsmb c ?>" <?lsmb IF (column == 'cost' || column == 'profit') ?>align="center"<?lsmb ELSIF column == 'discount' ?>align="right"<?lsmb END ?>>
<?lsmb IF row.$column.href ?>
<a href="<?lsmb row.$column.href?>"><?lsmb row.$column.text ?></a>
<?lsmb ELSE; row.$column; END ?>
diff --git a/bin/am.pl b/bin/am.pl
index 9582cecf..5f1dc3bb 100644
--- a/bin/am.pl
+++ b/bin/am.pl
@@ -895,7 +895,7 @@ sub list_business {
AM->business( \%myconfig, \%$form );
- $href =
+ my $href =
"$form->{script}?action=list_business&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}";
$form->sort_order();
@@ -903,100 +903,65 @@ sub list_business {
$form->{callback} =
"$form->{script}?action=list_business&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('Type of Business');
- @column_index = qw(description discount);
-
- $column_header{description} =
- qq|<th width=90%><a class="listheading" href=$href>|
- . $locale->text('Description')
- . qq|</a></th>|;
- $column_header{discount} =
- qq|<th class="listheading">| . $locale->text('Discount') . qq| %</th>|;
-
- $form->header;
-
- print qq|
-<body>
+ my @column_index = qw(description discount);
-<table width=100%>
- <tr>
- <th class=listtop>$form->{title}</th>
- </tr>
- <tr height="5"></tr>
- <tr>
- <td>
- <table width=100%>
- <tr class="listheading">
-|;
-
- for (@column_index) { print "$column_header{$_}\n" }
-
- print qq|
- </tr>
-|;
-
- foreach $ref ( @{ $form->{ALL} } ) {
+ my %column_header;
+ $column_header{description} = { text => $locale->text('Description'),
+ href => $href };
+ $column_header{discount} = $locale->text('Discount %');
+ my @rows;
+ $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>
-|;
-
- $discount =
- $form->format_amount( \%myconfig, $ref->{discount} * 100, 2,
- "&nbsp" );
-
- $column_data{description} =
-qq|<td><a href=$form->{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}</td>|;
- $column_data{discount} = qq|<td align="right">$discount</td>|;
-
- for (@column_index) { print "$column_data{$_}\n" }
+ $column_data{discount} =
+ $form->format_amount( \%myconfig, $ref->{discount} * 100, 2, " " );
+ $column_data{description} = { text => $ref->{description}, href =>
+ qq|$form->{script}?action=edit_business&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} = "business";
- $form->hide_form(qw(type callback path login sessionid));
-
- print qq|
-<button class="submit" type="submit" name="action" value="add_business">|
- . $locale->text('Add Business')
- . qq|</button>|;
+ my @hiddens = qw(type callback path login sessionid);
- if ( $form->{lynx} ) {
- require "bin/menu.pl";
- &menubar;
- }
+## SC: Temporary removal
+## if ( $form->{lynx} ) {
+## require "bin/menu.pl";
+## &menubar;
+## }
- print qq|
-
- </form>
-
- </body>
- </html>
-|;
+ my @buttons;
+ push @buttons, {
+ name => 'action',
+ value => 'add_business',
+ text => $locale->text('Add Business'),
+ 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 business_header {