From 50a4f9b19d1ea1a55b47bf09c99ddb195f811b02 Mon Sep 17 00:00:00 2001 From: tetragon Date: Sat, 22 Sep 2007 23:25:05 +0000 Subject: Templating business type list git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1650 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/am.pl | 123 ++++++++++++++++++++++---------------------------------------- 1 file changed, 44 insertions(+), 79 deletions(-) (limited to 'bin') 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|| - . $locale->text('Description') - . qq||; - $column_header{discount} = - qq|| . $locale->text('Discount') . qq| %|; - - $form->header; - - print qq| - + my @column_index = qw(description discount); - - - - - - - - - - - -
$form->{title}
- - -|; - - for (@column_index) { print "$column_header{$_}\n" } - - print qq| - -|; - - 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| - -|; - - $discount = - $form->format_amount( \%myconfig, $ref->{discount} * 100, 2, - " " ); - - $column_data{description} = -qq||; - $column_data{discount} = qq||; - - 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| - -|; + push @rows, \%column_data; } - print qq| -
{script}?action=edit_business&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}$discount
-

- -
-
{script}> -|; - $form->{type} = "business"; - $form->hide_form(qw(type callback path login sessionid)); - - print qq| -|; + 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| - -
- - - -|; + 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 { -- cgit v1.2.3