From 0d782a73e55e47aa7a2fda31bd51c31ecfc814cb Mon Sep 17 00:00:00 2001 From: tetragon Date: Sat, 3 Nov 2007 22:06:16 +0000 Subject: Template select_item git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1848 4979c152-3d1c-0410-bac9-87ea11338e46 --- bin/ct.pl | 147 +++++++++++++++++++++----------------------------------------- 1 file changed, 50 insertions(+), 97 deletions(-) (limited to 'bin') diff --git a/bin/ct.pl b/bin/ct.pl index 7e57b1cf..770e0960 100644 --- a/bin/ct.pl +++ b/bin/ct.pl @@ -2203,8 +2203,7 @@ sub update { &select_item; exit; - } - else { + } else { $sellprice = $form->{"sellprice_$i"}; $pricebreak = $form->{"pricebreak_$i"}; @@ -2271,129 +2270,83 @@ sub update { } sub select_item { + my %hiddens; - @column_index = + my @column_index = qw(ndx partnumber description partsgroup unit sellprice lastcost); - $column_data{ndx} = qq| |; - $column_data{partnumber} = - qq|| . $locale->text('Number') . qq||; - $column_data{description} = - qq|| . $locale->text('Description') . qq||; - $column_data{partsgroup} = - qq|| . $locale->text('Group') . qq||; - $column_data{unit} = - qq|| . $locale->text('Unit') . qq||; - $column_data{sellprice} = - qq|| . $locale->text('Sell Price') . qq||; - $column_data{lastcost} = - qq|| . $locale->text('Cost') . qq||; - - $form->header; - - $title = $locale->text('Select items'); - - print qq| - - -
- - - - - - - - - - - - - - - -
$title
$option
- - |; - - for (@column_index) { print "\n$column_data{$_}" } + my %column_data; + $column_data{ndx} = ' '; + $column_data{partnumber} = locale->text('Number'); + $column_data{description} = $locale->text('Description'); + $column_data{partsgroup} = $locale->text('Group'); + $column_data{unit} = $locale->text('Unit'); + $column_data{sellprice} = $locale->text('Sell Price'); + $column_data{lastcost} = $locale->text('Cost'); - print qq| - -|; + $form->{title} = $locale->text('Select items'); my $i = 0; + my @rows; foreach $ref ( @{ $form->{item_list} } ) { $i++; + my %column_data; for (qw(partnumber description unit)) { $ref->{$_} = $form->quote( $ref->{$_} ); } - $column_data{ndx} = -qq||; - - for (qw(partnumber description partsgroup unit)) { - $column_data{$_} = qq||; - } + $column_data{ndx} = {input => { + name => "ndx_$i", + type => 'checkbox', + value => $i, + }}; + $column_data{$_} = $ref->{$_} foreach + qw(partnumber description partsgroup unit); $column_data{sellprice} = - qq||; + $form->format_amount( \%myconfig, $ref->{sellprice}, 2, ' ' ); $column_data{lastcost} = - qq||; + $form->format_amount( \%myconfig, $ref->{lastcost}, 2, ' ' ); $j++; $j %= 2; + $column_data{i} = $j; - print qq| - |; - - for (@column_index) { print "\n$column_data{$_}" } - - print qq| - -|; + push @rows, \%column_data; - for ( - qw(partnumber description partsgroup partsgroup_id sellprice lastcost unit id) - ) - { - print - qq|\n|; - } + $hiddens{"new_${_}_$i"} = $ref->{$_} foreach + qw(partnumber description partsgroup partsgroup_id sellprice lastcost unit id); } - print qq| -
$ref->{$_} | - . $form->format_amount( \%myconfig, $ref->{sellprice}, 2, " " ) - . qq|| - . $form->format_amount( \%myconfig, $ref->{lastcost}, 2, " " ) - . qq|
-

- - - -|; - # delete action variable for (qw(nextsub item_list)) { delete $form->{$_} } - $form->{action} = "item_selected"; - $form->hide_form; - - print qq| - - -
- -
+ $hiddens{$_} = $form->{$_} foreach sort keys %$form; + $hiddens{nextsub} = 'item_selected'; + $hiddens{lastndx} = $i; - - -|; + my @buttons = ({ + name => 'action', + value => 'item_selected', + text => $locale->text('Continue'), + }); + my $template = LedgerSMB::Template->new_UI( + user => \%myconfig, + locale => $locale, + template => 'form-dynatable', + ); + $template->render({ + form => $form, + user => \%myconfig, + hiddens => \%hiddens, + buttons => \@buttons, + options => \@options, + rows => \@rows, + columns => \@column_index, + heading => \%column_header, + }); } sub item_selected { -- cgit v1.2.3