From e2b0202cff81f02ce9a7e6a1cddf463704ebacf1 Mon Sep 17 00:00:00 2001 From: tetragon Date: Wed, 24 Oct 2007 22:21:31 +0000 Subject: Converting forms that use warehouse_header to templates git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1814 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/am.pl | 186 +++++++++++++++++++++++++------------------------------------- 1 file changed, 76 insertions(+), 110 deletions(-) (limited to 'bin/am.pl') diff --git a/bin/am.pl b/bin/am.pl index 60c73bf0..3bb2468f 100644 --- a/bin/am.pl +++ b/bin/am.pl @@ -1985,8 +1985,21 @@ sub add_warehouse { "$form->{script}?action=add_warehouse&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}" unless $form->{callback}; - &warehouse_header; - &form_footer; + my %hiddens; + my @buttons; + my $rows = &warehouse_header(\%hiddens); + &form_footer_buttons(\%hiddens, \@buttons); + + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'am-warehouse-form'); + $template->render({ + form => $form, + row_count => $rows, + buttons => \@buttons, + hiddens => \%hiddens, + }); } @@ -1996,16 +2009,29 @@ sub edit_warehouse { AM->get_warehouse( \%myconfig, \%$form ); - &warehouse_header; - &form_footer; + my %hiddens; + my @buttons; + my $rows = &warehouse_header(\%hiddens); + &form_footer_buttons(\%hiddens, \@buttons); + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'am-warehouse-form'); + $template->render({ + form => $form, + row_count => $rows, + buttons => \@buttons, + hiddens => \%hiddens, + }); } sub list_warehouse { AM->warehouses( \%myconfig, \%$form ); + my %hiddens; - $href = + my $href = "$form->{script}?action=list_warehouse&direction=$form->{direction}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}"; $form->sort_order(); @@ -2013,95 +2039,64 @@ sub list_warehouse { $form->{callback} = "$form->{script}?action=list_warehouse&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('Warehouses'); - @column_index = qw(description); - - $column_header{description} = - qq|| - . $locale->text('Description') - . qq||; - - $form->header; - - print qq| - - - - - - - - - - - - - -
$form->{title}
- - -|; - - for (@column_index) { print "$column_header{$_}\n" } - - print qq| - -|; + my @column_index = qw(description); + my %column_header; + $column_header{description} = { + href => $href, + text => $locale->text('Description'), + }; - foreach $ref ( @{ $form->{ALL} } ) { + my @rows; + my $i; + foreach my $ref ( @{ $form->{ALL} } ) { + my %column_data; $i++; $i %= 2; + $column_data{i} = $i; - print qq| - -|; - - $column_data{description} = -qq||; - - for (@column_index) { print "$column_data{$_}\n" } + $column_data{description} = { + href => "$form->{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback", + text => $ref->{description}, + }; - print qq| - -|; + push @rows, \%column_data; } - print qq| -
{script}?action=edit_warehouse&id=$ref->{id}&path=$form->{path}&login=$form->{login}&sessionid=$form->{sessionid}&callback=$callback>$ref->{description}
-

- -
-
{script}> -|; - $form->{type} = "warehouse"; + $hiddens{$_} = $form->{$_} foreach qw(type callback path login sessionid); - $form->hide_form(qw(type callback path login sessionid)); - - print qq| -|; - - if ( $form->{lynx} ) { - require "bin/menu.pl"; - &menubar; - } - - print qq| -
- - - -|; +##SC: Temporary commenting +## if ( $form->{lynx} ) { +## require "bin/menu.pl"; +## &menubar; +## } + my @buttons = ({ + name => 'action', + value => 'add_warehouse', + text => $locale->text('Add Warehouse'), + }); + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'form-dynatable'); + $template->render({ + form => $form, + buttons => \@buttons, + hiddens => \%hiddens, + columns => \@column_index, + heading => \%column_header, + rows => \@rows, + }); } sub warehouse_header { + my $hiddens = shift; $form->{title} = $locale->text("$form->{title} Warehouse"); @@ -2110,40 +2105,11 @@ sub warehouse_header { $form->{description} = $form->quote( $form->{description} ); - if ( ( $rows = $form->numtextrows( $form->{description}, 60 ) ) > 1 ) { - $description = -qq||; - } - else { - $description = - qq||; - } - - $form->header; - - print qq| - - -
{script}> - -{id}> - - - - - - - - - - - - - - -
$form->{title}
| . $locale->text('Description') . qq|$description

-|; + $hiddens->{id} = $form->{id}; + $hiddens->{type} = 'warehouse'; + my $rows = $form->numtextrows( $form->{description}, 60 ); + $rows; } sub save_warehouse { -- cgit v1.2.3