From: Thomas Heck Date: Fri, 31 Aug 2012 15:27:32 +0000 (+0200) Subject: SL::Template::Plugin::L::select_tag und SL::Template::Plugin::L::options_for_select... X-Git-Tag: release-3.0.0beta1~254 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5896615180704b3dddba46f4064a47ff1f094c3c;p=kivitendo-erp.git SL::Template::Plugin::L::select_tag und SL::Template::Plugin::L::options_for_select fusionieren. --- diff --git a/SL/Template/Plugin/L.pm b/SL/Template/Plugin/L.pm index fdb22b31a..f90a948d8 100644 --- a/SL/Template/Plugin/L.pm +++ b/SL/Template/Plugin/L.pm @@ -86,13 +86,122 @@ sub html_tag { sub select_tag { my $self = shift; my $name = shift; - my $options_str = shift; + my $collection = shift; my %attributes = _hashify(@_); $attributes{id} ||= $self->name_to_id($name); - $options_str = $self->options_for_select($options_str) if ref $options_str; - return $self->html_tag('select', $options_str, %attributes, name => $name); + my $value_key = delete($attributes{value_key}) || 'id'; + my $title_key = delete($attributes{title_key}) || $value_key; + my $default_key = delete($attributes{default_key}) || 'selected'; + + + my $value_title_sub = delete($attributes{value_title_sub}); + + my $value_sub = delete($attributes{value_sub}); + my $title_sub = delete($attributes{title_sub}); + my $default_sub = delete($attributes{default_sub}); + + + my %selected; + + if ( ref($attributes{default}) eq 'ARRAY' ) { + + foreach my $entry (@{$attributes{default}}) { + $selected{$entry} = 1; + } + } elsif ( defined($attributes{default}) ) { + $selected{$attributes{default}} = 1; + } + + delete($attributes{default}); + + + my @options; + + if ( delete($attributes{with_empty}) ) { + push(@options, [undef, $attributes{empty_title} || '']); + } + + my $normalize_entry = sub { + + my ($type, $entry, $sub, $key) = @_; + + if ( $sub ) { + return $sub->($entry); + } + + my $ref = ref($entry); + + if ( !$ref ) { + + if ( $type eq 'value' || $type eq 'title' ) { + return $entry; + } + + return 0; + } + + if ( $ref eq 'ARRAY' ) { + + if ( $type eq 'value' ) { + return $entry->[0]; + } + + if ( $type eq 'title' ) { + return $entry->[1]; + } + + return $entry->[2]; + } + + if ( $ref eq 'HASH' ) { + return $entry->{$key}; + } + + if ( $type ne 'default' || $entry->can($key) ) { + return $entry->$key; + } + + return undef; + }; + + foreach my $entry ( @{ $collection } ) { + my $value; + my $title; + + if ( $value_title_sub ) { + ($value, $title) = $value_title_sub->($entry); + } else { + + $value = $normalize_entry->('value', $entry, $value_sub, $value_key); + $title = $normalize_entry->('title', $entry, $title_sub, $title_key); + } + + my $default = $normalize_entry->('default', $entry, $default_sub, $default_key); + + push(@options, [$value, $title, $default]); + } + + foreach my $entry (@options) { + if ( exists($selected{$entry->[0]}) ) { + $entry->[2] = 1; + } + } + + my $code = ''; + + foreach my $entry (@options) { + my %args = (value => $entry->[0]); + + $args{selected} = $entry->[2]; + + $code .= $self->html_tag('option', _H($entry->[1]), %args); + } + + $code = $self->html_tag('select', $code, %attributes, name => $name); + + return $code; } sub textarea_tag { @@ -207,57 +316,11 @@ sub button_tag { return $self->html_tag('input', undef, %attributes, value => $value, onclick => $onclick); } -sub options_for_select { - my $self = shift; - my $collection = shift; - my %options = _hashify(@_); - - my $value_key = $options{value} || 'id'; - my $title_key = $options{title} || $value_key; - - my $value_sub = $options{value_sub}; - my $title_sub = $options{title_sub}; - - my $value_title_sub = $options{value_title_sub}; - - my %selected = map { ( $_ => 1 ) } @{ ref($options{default}) eq 'ARRAY' ? $options{default} : defined($options{default}) ? [ $options{default} ] : [] }; - - my $access = sub { - my ($element, $index, $key, $sub) = @_; - my $ref = ref $element; - return $sub ? $sub->($element) - : !$ref ? $element - : $ref eq 'ARRAY' ? $element->[$index] - : $ref eq 'HASH' ? $element->{$key} - : $element->$key; - }; - - my @elements = (); - push @elements, [ undef, $options{empty_title} || '' ] if $options{with_empty}; - push @elements, map [ - $value_title_sub ? @{ $value_title_sub->($_) } : ( - $access->($_, 0, $value_key, $value_sub), - $access->($_, 1, $title_key, $title_sub), - ) - ], @{ $collection } if $collection && ref $collection eq 'ARRAY'; - - my $code = ''; - foreach my $result (@elements) { - my %attributes = ( value => $result->[0] ); - $attributes{selected} = 'selected' if $selected{ defined($result->[0]) ? $result->[0] : '' }; - - $code .= $self->html_tag('option', _H($result->[1]), %attributes); - } - - return $code; -} - sub yes_no_tag { my ($self, $name, $value) = splice @_, 0, 3; my %attributes = _hashify(@_); - my $options = $self->options_for_select([ [ 1, $::locale->text('Yes') ], [ 0, $::locale->text('No') ] ], default => $value ? 1 : 0); - return $self->select_tag($name, $options, %attributes); + return $self->select_tag($name, [ [ 1 => $::locale->text('Yes') ], [ 0 => $::locale->text('No') ] ], default => $value ? 1 : 0, %attributes); } sub javascript { @@ -356,12 +419,12 @@ sub vendor_selector { my $actual_vendor_id = (defined $::form->{"$name"})? ((ref $::form->{"$name"}) ? $::form->{"$name"}->id : $::form->{"$name"}) : (ref $value && $value->can('id')) ? $value->id : ''; - my $options_str = $self->options_for_select(SL::DB::Manager::Vendor->get_all(), - default => $actual_vendor_id, - title_sub => sub { $_[0]->vendornumber . " : " . $_[0]->name }, - 'with_empty' => 1); - return $self->select_tag($name, $options_str, %params); + return $self->select_tag($name, SL::DB::Manager::Vendor->get_all(), + default => $actual_vendor_id, + title_sub => sub { $_[0]->vendornumber . " : " . $_[0]->name }, + 'with_empty' => 1, + %params); } @@ -371,12 +434,12 @@ sub part_selector { my $actual_part_id = (defined $::form->{"$name"})? ((ref $::form->{"$name"})? $::form->{"$name"}->id : $::form->{"$name"}) : (ref $value && $value->can('id')) ? $value->id : ''; - my $options_str = $self->options_for_select(SL::DB::Manager::Part->get_all(), - default => $actual_part_id, - title_sub => sub { $_[0]->partnumber . " : " . $_[0]->description }, - 'with_empty' => 1); - return $self->select_tag($name, $options_str, %params); + return $self->select_tag($name, SL::DB::Manager::Part->get_all(), + default => $actual_part_id, + title_sub => sub { $_[0]->partnumber . " : " . $_[0]->description }, + with_empty => 1, + %params); } @@ -619,11 +682,15 @@ Usage from a template: [% USE L %] - [% L.select_tag('direction', [ [ 'left', 'To the left' ], [ 'right', 'To the right' ] ]) %] + [% L.select_tag('direction', [ [ 'left', 'To the left' ], [ 'right', 'To the right', 1 ] ]) %] - [% L.select_tag('direction', L.options_for_select([ { direction => 'left', display => 'To the left' }, - { direction => 'right', display => 'To the right' } ], - value => 'direction', title => 'display', default => 'right')) %] + [% L.select_tag('direction', [ { direction => 'left', display => 'To the left' }, + { direction => 'right', display => 'To the right' } ], + value_key => 'direction', title_key => 'display', default => 'right')) %] + + [% L.select_tag('direction', [ { direction => 'left', display => 'To the left' }, + { direction => 'right', display => 'To the right', selected => 1 } ], + value_key => 'direction', title_key => 'display')) %] =head1 DESCRIPTION @@ -661,21 +728,60 @@ C<$content_string> is not HTML escaped. =over 4 -=item C +=item C + +Creates a HTML 'select' tag named C<$name> with the contents of one +'EoptionE' tag for each element in C<\@collection> and with arbitrary +HTML attributes from C<%attributes>. The value +to use and the title to display are extracted from the elements in +C<\@collection>. Each element can be one of four things: + +=over 12 + +=item 1. An array reference with at least two elements. The first element is +the value, the second element is its title. The third element is optional and and should contain a boolean. +If it is true, than the element will be used as default. + +=item 2. A scalar. The scalar is both the value and the title. + +=item 3. A hash reference. In this case C<%attributes> must contain +I, I and may contain I keys that name the keys in the element to use +for the value, title and default respectively. + +=item 4. A blessed reference. In this case C<%attributes> must contain +I, I and may contain I keys that name functions called on the blessed +reference whose return values are used as the value, title and default +respectively. + +=back + +For cases 3 and 4 C<$attributes{value_key}> defaults to C, +C<$attributes{title_key}> defaults to C<$attributes{value_key}> +and C<$attributes{default_key}> defaults to C. + +In addition to pure keys/method you can also provide coderefs as I +and/or I and/or I. If present, these take precedence over keys or methods, +and are called with the element as first argument. It must return the value, title or default. + +Lastly a joint coderef I may be provided, which in turn takes +precedence over the C and C subs. It will only be called once for each +element and must return a list of value and title. + +If the option C is set then an empty element (value +C) will be used as the first element. The title to display for +this element can be set with the option C and defaults to +an empty string. -Creates a HTML 'select' tag named C<$name> with the contents -C<$options_string> and with arbitrary HTML attributes from -C<%attributes>. The tag's C defaults to C. +The option C can be either a scalar or an array reference +containing the values of the options which should be set to be +selected. -The C<$options_string> is usually created by the -L function. If C<$options_string> is an array -reference then it will be passed to L -automatically. +The tag's C defaults to C. =item C Creates a HTML 'select' tag with the two entries C and C by -calling L and L. C<$value> determines +calling L. C<$value> determines which entry is selected. The C<%attributes> are passed through to L. @@ -909,52 +1015,6 @@ overview and further usage instructions. =over 4 -=item C - -Creates a string suitable for a HTML 'select' tag consisting of one -'EoptionE' tag for each element in C<\@collection>. The value -to use and the title to display are extracted from the elements in -C<\@collection>. Each element can be one of four things: - -=over 12 - -=item 1. An array reference with at least two elements. The first element is -the value, the second element is its title. - -=item 2. A scalar. The scalar is both the value and the title. - -=item 3. A hash reference. In this case C<%options> must contain -I and I keys that name the keys in the element to use -for the value and title respectively. - -=item 4. A blessed reference. In this case C<%options> must contain -I<value> and I<title> keys that name functions called on the blessed -reference whose return values are used as the value and title -respectively. - -=back - -For cases 3 and 4 C<$options{value}> defaults to C<id> and -C<$options{title}> defaults to C<$options{value}>. - -In addition to pure keys/method you can also provide coderefs as I<value_sub> -and/or I<title_sub>. If present, these take precedence over keys or methods, -and are called with the element as first argument. It must return the value or -title. - -Lastly a joint coderef I<value_title_sub> may be provided, which in turn takes -precedence over each individual sub. It will only be called once for each -element and must return a list of value and title. - -If the option C<with_empty> is set then an empty element (value -C<undef>) will be used as the first element. The title to display for -this element can be set with the option C<empty_title> and defaults to -an empty string. - -The option C<default> can be either a scalar or an array reference -containing the values of the options which should be set to be -selected. - =item C<tab, description, target, %PARAMS> Creates a tab for C<tabbed>. The description will be used as displayed name. diff --git a/templates/webpages/admin/edit_group.html b/templates/webpages/admin/edit_group.html index bacf5b3a2..3114b62e3 100644 --- a/templates/webpages/admin/edit_group.html +++ b/templates/webpages/admin/edit_group.html @@ -17,7 +17,7 @@ <h3 class="listheading">[%- LxERP.t8('Edit membership') %]</h3> <div class="clearfix"> - [% L.select_tag("user_ids[]", L.options_for_select(ALL_USERS, value => 'id', title => 'login', default => USER_IDS_IN_GROUP), 'multiple' => 'multiple') %] + [% L.select_tag('user_ids[]', ALL_USERS, value_key = 'id', title_key = 'login', default = USER_IDS_IN_GROUP, multiple = 1) %] </div> <h3 class="listheading">[% 'Edit rights' | $T8 %]</h3> diff --git a/templates/webpages/admin/edit_user.html b/templates/webpages/admin/edit_user.html index 77ed62ee4..6d72ca03f 100644 --- a/templates/webpages/admin/edit_user.html +++ b/templates/webpages/admin/edit_user.html @@ -109,12 +109,12 @@ <table> <tr> <th align="right">[% 'Date Format' | $T8 %]</th> - <td>[% L.select_tag('user.dateformat', L.options_for_select(all_dateformats, default=user.dateformat)) %]</td> + <td>[% L.select_tag('user.dateformat', all_dateformats, default = user.dateformat) %]</td> </tr> <tr> <th align="right">[% 'Number Format' | $T8 %]</th> - <td>[% L.select_tag('user.numberformat', L.options_for_select(all_numberformats, default=user.numberformat)) %]</td> + <td>[% L.select_tag('user.numberformat', all_numberformats, default = user.numberformat) %]</td> </tr> <tr> @@ -124,12 +124,12 @@ <tr> <th align="right">[% 'Language' | $T8 %]</th> - <td>[% L.select_tag('user.countrycode', L.options_for_select(all_countrycodes, title='title', default=user.countrycode)) %]</td> + <td>[% L.select_tag('user.countrycode', all_countrycodes, title_key = 'title', default = user.countrycode) %]</td> </tr> <tr> <th align="right">[% 'Stylesheet' | $T8 %]</th> - <td>[% L.select_tag('user.stylesheet', L.options_for_select(all_stylesheets, default=user.stylesheet)) %]</td> + <td>[% L.select_tag('user.stylesheet', all_stylesheets, default = user.stylesheet) %]</td> </tr> <tr> @@ -138,7 +138,7 @@ </tr> <tr> <th align="right">[% 'Use Templates' | $T8 %]</th> - <td>[% L.select_tag('usetemplates', L.options_for_select(all_templates, default=user.templates)) %]</td> + <td>[% L.select_tag('usetemplates', all_templates, default = user.templates) %]</td> </tr> <tr> <th align="right">[% 'New Templates' | $T8 %]</th> @@ -146,11 +146,11 @@ </tr> <tr> <th align="right">[% 'Setup Templates' | $T8 %]</th> - <td>[% L.select_tag('mastertemplates', L.options_for_select(all_master_templates, default='German')) %]</td> + <td>[% L.select_tag('mastertemplates', all_master_templates, default = 'German') %]</td> </tr> <tr> <th align="right">[% 'Setup Menu' | $T8 %]</th> - <td>[% L.select_tag('user.menustyle', L.options_for_select(all_menustyles, title='title', default=user.menustyle)) %]</td> + <td>[% L.select_tag('user.menustyle', all_menustyles, title_key = 'title', default = user.menustyle) %]</td> </tr> <tr> <th align='right'>[% 'Mandatory Departments' | $T8 %]</th> diff --git a/templates/webpages/admin_printer/_login_form.html b/templates/webpages/admin_printer/_login_form.html index 411661cba..4789d1294 100644 --- a/templates/webpages/admin_printer/_login_form.html +++ b/templates/webpages/admin_printer/_login_form.html @@ -1,4 +1,4 @@ [%- USE T8 %] [%- USE L %] -<p>[% 'Please select a user' | $T8 %]: [% L.select_tag('login', L.options_for_select(users, value => 'login', title => 'login', default => login)) %]</p> +<p>[% 'Please select a user' | $T8 %]: [% L.select_tag('login', users, value_key = 'login', title_key = 'login', default = login) %]</p> diff --git a/templates/webpages/am/buchungsgruppe_header.html b/templates/webpages/am/buchungsgruppe_header.html index 59c311069..2da736fe1 100644 --- a/templates/webpages/am/buchungsgruppe_header.html +++ b/templates/webpages/am/buchungsgruppe_header.html @@ -19,7 +19,7 @@ [%- IF INSTANCE_CONF.get_inventory_system == 'perpetual' %] <tr> <th align=right>[% 'Inventory' | $T8 %]</th> - <td>[% L.select_tag('inventory_accno_id', L.options_for_select(accounts.IC, title_sub=\account_label, default=invetory_accno_id)) %]</td> + <td>[% L.select_tag('inventory_accno_id', accounts.IC, title_sub=\account_label, default=invetory_accno_id) %]</td> </tr> [%- ELSE %] <tr style='display:none'> @@ -28,35 +28,35 @@ [%- END %] <tr> <th align=right>[% 'National Revenues' | $T8 %]</th> - <td>[% L.select_tag('income_accno_id_0', L.options_for_select(accounts.IC_income, title_sub=\account_label, default=income_accno_id_0)) %]</td> + <td>[% L.select_tag('income_accno_id_0', accounts.IC_income, title_sub=\account_label, default=income_accno_id_0) %]</td> </tr> <tr> <th align=right>[% 'National Expenses' | $T8 %]</th> - <td>[% L.select_tag('expense_accno_id_0', L.options_for_select(accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_0)) %]</td> + <td>[% L.select_tag('expense_accno_id_0', accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_0) %]</td> </tr> <tr> <th align=right>[% 'Revenues EU with UStId' | $T8 %]</th> - <td>[% L.select_tag('income_accno_id_1', L.options_for_select(accounts.IC_income, title_sub=\account_label, default=income_accno_id_1)) %]</td> + <td>[% L.select_tag('income_accno_id_1', accounts.IC_income, title_sub=\account_label, default=income_accno_id_1) %]</td> </tr> <tr> <th align=right>[% 'Expenses EU with UStId' | $T8 %]</th> - <td>[% L.select_tag('expense_accno_id_1', L.options_for_select(accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_1)) %]</td> + <td>[% L.select_tag('expense_accno_id_1', accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_1) %]</td> </tr> <tr> <th align=right>[% 'Revenues EU without UStId' | $T8 %]</th> - <td>[% L.select_tag('income_accno_id_2', L.options_for_select(accounts.IC_income, title_sub=\account_label, default=income_accno_id_2)) %]</td> + <td>[% L.select_tag('income_accno_id_2', accounts.IC_income, title_sub=\account_label, default=income_accno_id_2) %]</td> </tr> <tr> <th align=right>[% 'Expenses EU without UStId' | $T8 %]</th> - <td>[% L.select_tag('expense_accno_id_2', L.options_for_select(accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_2)) %]</td> + <td>[% L.select_tag('expense_accno_id_2', accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_2) %]</td> </tr> <tr> <th align=right>[% 'Foreign Revenues' | $T8 %]</th> - <td>[% L.select_tag('income_accno_id_3', L.options_for_select(accounts.IC_income, title_sub=\account_label, default=income_accno_id_3)) %]</td> + <td>[% L.select_tag('income_accno_id_3', accounts.IC_income, title_sub=\account_label, default=income_accno_id_3) %]</td> </tr> <tr> <th align=right>[% 'Foreign Expenses' | $T8 %]</th> - <td>[% L.select_tag('expense_accno_id_3', L.options_for_select(accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_3)) %]</td> + <td>[% L.select_tag('expense_accno_id_3', accounts.IC_expense, title_sub=\account_label, default=expense_accno_id_3) %]</td> </tr> <td colspan=2><hr size=3 noshade></td> </tr> diff --git a/templates/webpages/am/config.html b/templates/webpages/am/config.html index 3c26298ba..7e2293d94 100644 --- a/templates/webpages/am/config.html +++ b/templates/webpages/am/config.html @@ -80,21 +80,13 @@ <tr> <th align="right">[% 'Date Format' | $T8 %]</th> <td> - <select name="dateformat"> - [%- FOREACH row = DATEFORMATS %] - <option value="[% HTML.escape(row.value) %]"[% IF row.selected %] selected[% END %]>[% HTML.escape(row.name) %]</option> - [%- END %] - </select> + [% L.select_tag('dateformat', DATEFORMATS, value_key = 'value', title_key = 'name') %] </td> </tr> <tr> <th align="right">[% 'Output Number Format' | $T8 %]</th> <td> - <select name="numberformat"> - [%- FOREACH row = NUMBERFORMATS %] - <option value="[% HTML.escape(row.value) %]"[% IF row.selected %] selected[% END %]>[% HTML.escape(row.name) %]</option> - [%- END %] - </select> + [% L.select_tag('numberformat', NUMBERFORMATS, value_key = 'value', title_key = 'name') %] </td> </tr> @@ -106,22 +98,14 @@ <tr> <th align="right">[% 'Language' | $T8 %]</th> <td> - <select name="countrycode"> - [%- FOREACH row = COUNTRYCODES %] - <option value="[% HTML.escape(row.value) %]"[% IF row.selected %] selected[% END %]>[% HTML.escape(row.name) %]</option> - [%- END %] - </select> + [% L.select_tag('countrycode', COUNTRYCODES, value_key = 'value', title_key = 'name') %] </td> </tr> <tr> <th align="right">[% 'Stylesheet' | $T8 %]</th> <td> - <select name="usestylesheet"> - [%- FOREACH row = STYLESHEETS %] - <option value="[% HTML.escape(row.value) %]"[% IF row.selected %] selected[% END %]>[% HTML.escape(row.name) %]</option> - [%- END %] - </select> + [% L.select_tag('usestylesheet', STYLESHEETS, value_key = 'value', title_key = 'name') %] </td> </tr> @@ -169,29 +153,21 @@ <tr> <th align="right">[% 'Default template format' | $T8 %]</th> <td> - <select name="template_format"> - [%- FOREACH row = TEMPLATE_FORMATS %] - <option value="[% HTML.escape(row.value) %]"[% IF row.selected %] selected[% END %]>[% HTML.escape(row.name) %]</option> - [%- END %] - </select> + [% L.select_tag('template_format', TEMPLATE_FORMATS, value_key = 'value', title_key = 'name') %] </td> </tr> <tr> <th align="right">[% 'Default output medium' | $T8 %]</th> <td> - <select name="default_media"> - [%- FOREACH row = MEDIA %] - <option value="[% HTML.escape(row.value) %]"[% IF row.selected %] selected[% END %]>[% HTML.escape(row.name) %]</option> - [%- END %] - </select> + [% L.select_tag('default_media', MEDIA, value_key = 'value', title_key = 'name') %] </td> </tr> <tr> <th align="right">[% 'Default printer' | $T8 %]</th> <td> - [% L.select_tag('default_printer_id', L.options_for_select(PRINTERS, default => myconfig_default_printer_id, title => 'printer_description', with_empty => 1)) %] + [% L.select_tag('default_printer_id', PRINTERS, default = myconfig_default_printer_id, title_key = 'printer_description', with_empty = 1) %] </td> </tr> diff --git a/templates/webpages/am/edit_accounts.html b/templates/webpages/am/edit_accounts.html index 167642489..76a08e463 100644 --- a/templates/webpages/am/edit_accounts.html +++ b/templates/webpages/am/edit_accounts.html @@ -63,16 +63,18 @@ window.onload = function() { <td> [% IF AccountIsPosted %] [% L.select_tag('dummy_charttype', - L.options_for_select(all_charttypes, - title => 'name', value => 'value', - default => selected_charttype), + all_charttypes, + title_key => 'name', + value_key => 'value', + default => selected_charttype, disabled => '1') %] [% L.hidden_tag('charttype', selected_charttype) %] [% ELSE %] [% L.select_tag('charttype', - L.options_for_select(all_charttypes, - title => 'name', value => 'value', - default => selected_charttype)) %] + all_charttypes, + title_key => 'name', + value_key => 'value', + default => selected_charttype) %] [% END %] </td> </tr> diff --git a/templates/webpages/am/language_header.html b/templates/webpages/am/language_header.html index c17b14e6e..99ec45f87 100644 --- a/templates/webpages/am/language_header.html +++ b/templates/webpages/am/language_header.html @@ -28,11 +28,11 @@ </tr> <tr> <th align=right>[% 'Number Format' | $T8 %]</th> - <td><select name="output_numberformat">[% L.options_for_select(numberformats, default=output_numberformat, with_empty=1, empty_title=LxERP.t8('use program settings')) %]</select></td> + <td><select name="output_numberformat">[% numberformats, default = output_numberformat, with_empty = 1, empty_title = LxERP.t8('use program settings') %]</select></td> </tr> <tr> <th align=right>[% 'Date Format' | $T8 %]</th> - <td><select name="output_dateformat">[% L.options_for_select(dateformats, default=output_dateformat, with_empty=1, empty_title=LxERP.t8('use program settings')) %]</select></td> + <td><select name="output_dateformat">[% dateformats, default = output_dateformat, with_empty = 1, empty_title=LxERP.t8('use program settings') %]</select></td> </tr> <tr> <th align=right>[% 'Long Dates' | $T8 %]</th> diff --git a/templates/webpages/ar/form_header.html b/templates/webpages/ar/form_header.html index e5ba4ab31..0e65ea9c6 100644 --- a/templates/webpages/ar/form_header.html +++ b/templates/webpages/ar/form_header.html @@ -114,7 +114,7 @@ </tr> <tr> <th align=right nowrap>[% 'Project Number' | $T8 %]</th> - <td>[% L.select_tag('globalproject_id', L.options_for_select(ALL_PROJECTS, title='projectnumber', default=globalproject_id, with_empty=1)) %]</td> + <td>[% L.select_tag('globalproject_id', ALL_PROJECTS, title_key = 'projectnumber', default = globalproject_id, with_empty = 1) %]</td> </tr> </table> </td> @@ -142,7 +142,7 @@ <td>[% L.input_tag('amount_' _ loop.count, LxERP.format_amount(row.amount, 2)) %]</td> <td>[% L.hidden_tag('tax_' _ loop.count, LxERP.format_tax(row.tax, 2)) %][% LxERP.format_amount(row.tax, 2) | html %]</td> <td>[% row.taxchart %]</td> - <td>[% L.select_tag('project_id_' _ loop.count, L.options_for_select(ALL_PROJECTS, title='projectnumber', default=row.project_id, with_empty=1)) %]</td> + <td>[% L.select_tag('project_id_' _ loop.count, ALL_PROJECTS, title_key = 'projectnumber', default = row.project_id, with_empty = 1) %]</td> </tr> [%- END %] @@ -245,7 +245,7 @@ </td> <td> [%- IF row.changeable %] - [% L.select_tag('paid_project_id_' _ loop.count, L.options_for_select(ALL_PROJECTS, title='projectnumber', default=row.paid_project_id, with_empty=1)) %] + [% L.select_tag('paid_project_id_' _ loop.count, ALL_PROJECTS, title_key = 'projectnumber', default = row.paid_project_id, with_empty=1) %] [%- ELSE %] [% project_labels.${row.paid_project_id} | html %] <input type=hidden name="paid_project_id_[% loop.count %]" value='[% row.paid_project_id %]'> diff --git a/templates/webpages/ar/search.html b/templates/webpages/ar/search.html index 5bfada3b4..2da933963 100644 --- a/templates/webpages/ar/search.html +++ b/templates/webpages/ar/search.html @@ -52,11 +52,11 @@ </tr> <tr> <th align="right">[% 'Employee' | $T8 %]</th> - <td>[% L.select_tag('employee_id', L.options_for_select(ALL_EMPLOYEES, title='safe_name', with_empty=1), style='width:250px') %]</td> + <td>[% L.select_tag('employee_id', ALL_EMPLOYEES, title_key = 'safe_name', with_empty = 1, style = 'width:250px') %]</td> </tr> <tr> <th align="right">[% 'Salesman' | $T8 %]</th> - <td>[% L.select_tag('salesman_id', L.options_for_select(ALL_EMPLOYEES, title='safe_name', with_empty=1), style='width:250px') %]</td> + <td>[% L.select_tag('salesman_id', ALL_EMPLOYEES, title_key = 'safe_name', with_empty = 1, style = 'width:250px') %]</td> </tr> <tr> <th align=right nowrap>[% 'Transaction description' | $T8 %]</th> diff --git a/templates/webpages/background_job/form.html b/templates/webpages/background_job/form.html index a4753bb41..b5869f38e 100644 --- a/templates/webpages/background_job/form.html +++ b/templates/webpages/background_job/form.html @@ -14,8 +14,13 @@ <tr> <th align="right">[%- LxERP.t8('Execution type') %]</th> - <td>[% L.select_tag("background_job.type", L.options_for_select([ [ 'once', LxERP.t8('one-time execution') ], [ 'interval', LxERP.t8('repeated execution') ] ], - 'default' => SELF.background_job.type)) %]</td> + <td> + [% L.select_tag('background_job.type', [ + [ 'once', LxERP.t8('one-time execution') ], + [ 'interval', LxERP.t8('repeated execution') ] + ], + 'default' = SELF.background_job.type) %] + </td> </tr> <tr> diff --git a/templates/webpages/bp/list_spool.html b/templates/webpages/bp/list_spool.html index 10855b3aa..eaa86fdd6 100644 --- a/templates/webpages/bp/list_spool.html +++ b/templates/webpages/bp/list_spool.html @@ -77,7 +77,7 @@ [% L.submit_tag('action', LxERP.t8('Remove'), confirm=LxERP.t8('Are you sure you want to remove the marked entries from the queue?')) %] [% L.submit_tag('action', LxERP.t8('Print')) %] -[% L.select_tag('printer', L.options_for_select(ALL_PRINTERS, title='printer_description')) %] +[% L.select_tag('printer', ALL_PRINTERS, title_key = 'printer_description') %] </form> diff --git a/templates/webpages/bp/search.html b/templates/webpages/bp/search.html index bf94eea0d..cc163ef14 100644 --- a/templates/webpages/bp/search.html +++ b/templates/webpages/bp/search.html @@ -30,7 +30,7 @@ [% IF show_accounts %] <tr> <th align=right>[% 'Account' | $T8 %]</th> - <td colspan=3>[% L.select_tag('account', L.options_for_select(accounts, value_title_sub=\account_sub)) %]</td> + <td colspan=3>[% L.select_tag('account', accounts, value_title_sub=\account_sub) %]</td> </tr> [% END %] [%- IF label.$type.invnumber %] diff --git a/templates/webpages/csv_import/_form_customers_vendors.html b/templates/webpages/csv_import/_form_customers_vendors.html index c3bf9a51d..dbb828031 100644 --- a/templates/webpages/csv_import/_form_customers_vendors.html +++ b/templates/webpages/csv_import/_form_customers_vendors.html @@ -5,6 +5,6 @@ <th align="right">[%- LxERP.t8('Target table') %]:</th> <td colspan="10"> [% opts = [ [ 'customer', LxERP.t8('Customers') ], [ 'vendor', LxERP.t8('Vendors') ] ] %] - [% L.select_tag('settings.table', L.options_for_select(opts, default => SELF.profile.get('table')), style => 'width: 300px') %] + [% L.select_tag('settings.table', opts, default = SELF.profile.get('table'), style = 'width: 300px') %] </td> </tr> diff --git a/templates/webpages/csv_import/_form_parts.html b/templates/webpages/csv_import/_form_parts.html index 0eea2d14f..c88b710e9 100644 --- a/templates/webpages/csv_import/_form_parts.html +++ b/templates/webpages/csv_import/_form_parts.html @@ -4,14 +4,14 @@ <th align="right">[%- LxERP.t8('Parts with existing part numbers') %]:</th> <td colspan="10"> [% opts = [ [ 'update_prices', LxERP.t8('Update prices of existing entries') ], [ 'insert_new', LxERP.t8('Insert with new part number') ], [ 'skip', LxERP.t8('Skip entry') ] ] %] - [% L.select_tag('settings.article_number_policy', L.options_for_select(opts, default => SELF.profile.get('article_number_policy')), style => 'width: 300px') %] + [% L.select_tag('settings.article_number_policy', opts, default = SELF.profile.get('article_number_policy'), style = 'width: 300px') %] </td> </tr> <tr> <th align="right">[%- LxERP.t8('Sellprice significant places') %]:</th> <td colspan="10"> - [% L.select_tag('settings.sellprice_places', L.options_for_select([ 0, 1, 2, 3, 4, 5 ], default => SELF.profile.get('sellprice_places')), style => 'width: 300px') %] + [% L.select_tag('settings.sellprice_places', [ 0, 1, 2, 3, 4, 5 ], default = SELF.profile.get('sellprice_places')), style = 'width: 300px') %] </td> </tr> @@ -20,7 +20,7 @@ <td colspan="10"> [% L.input_tag('settings.sellprice_adjustment', LxERP.format_amount(SELF.profile.get('sellprice_adjustment')), size => "5") %] [% opts = [ [ 'percent', LxERP.t8('percental') ], [ 'absolute', LxERP.t8('absolute') ] ] %] - [% L.select_tag('settings.sellprice_adjustment_type', L.options_for_select(opts, default => SELF.profile.get('sellprice_adjustment_type'))) %] + [% L.select_tag('settings.sellprice_adjustment_type', opts, default = SELF.profile.get('sellprice_adjustment_type')) %] </td> </tr> @@ -28,7 +28,7 @@ <th align="right">[%- LxERP.t8('Mark as shop article if column missing') %]:</th> <td colspan="10"> [% opts = [ [ '1', LxERP.t8('yes') ], [ '0', LxERP.t8('no') ] ] %] - [% L.select_tag('settings.shoparticle_if_missing', L.options_for_select(opts, default => SELF.profile.get('shoparticle_if_missing')), style => 'width: 300px') %] + [% L.select_tag('settings.shoparticle_if_missing', opts, default = SELF.profile.get('shoparticle_if_missing'), style = 'width: 300px') %] </td> </tr> @@ -36,25 +36,25 @@ <th align="right">[%- LxERP.t8('Type') %]:</th> <td colspan="10"> [% opts = [ [ 'part', LxERP.t8('Parts') ], [ 'service', LxERP.t8('Services') ], [ 'mixed', LxERP.t8('Mixed (requires column "type")') ] ] %] - [% L.select_tag('settings.parts_type', L.options_for_select(opts, default => SELF.profile.get('parts_type')), style => 'width: 300px') %] + [% L.select_tag('settings.parts_type', opts, default = SELF.profile.get('parts_type'), style = 'width: 300px') %] </td> </tr> <tr> <th align="right" valign="top">[%- LxERP.t8('Default buchungsgruppe') %]:</th> <td colspan="10" valign="top"> - [% opts = L.options_for_select(SELF.all_buchungsgruppen, title => 'description', default => SELF.profile.get('default_buchungsgruppe')) %] + [% opts = SELF.all_buchungsgruppen, title_key = 'description', default = SELF.profile.get('default_buchungsgruppe') %] [% L.select_tag('settings.default_buchungsgruppe', opts, style => 'width: 300px') %] <br> [% opts = [ [ 'never', LxERP.t8('Do not set default buchungsgruppe') ], [ 'all', LxERP.t8('Apply to all parts') ], [ 'missing', LxERP.t8('Apply to parts without buchungsgruppe') ] ] %] - [% L.select_tag('settings.apply_buchungsgruppe', L.options_for_select(opts, default => SELF.profile.get('apply_buchungsgruppe')), style => 'width: 300px') %] + [% L.select_tag('settings.apply_buchungsgruppe', opts, default = SELF.profile.get('apply_buchungsgruppe'), style = 'width: 300px') %] </td> </tr> <tr> <th align="right" valign="top">[%- LxERP.t8('Default unit') %]:</th> <td colspan="10" valign="top"> - [% opts = L.options_for_select(SELF.all_units, title => 'name', value => 'name', default => SELF.profile.get('default_unit')) %] + [% opts = SELF.all_units, title_key = 'name', value_key = 'name', default = SELF.profile.get('default_unit')) %] [% L.select_tag('settings.default_unit', opts, style => 'width: 300px') %] </td> </tr> diff --git a/templates/webpages/csv_import/form.html b/templates/webpages/csv_import/form.html index eba42f6a9..4d6618bd6 100644 --- a/templates/webpages/csv_import/form.html +++ b/templates/webpages/csv_import/form.html @@ -27,7 +27,7 @@ <tr> <th align="right">[%- LxERP.t8('Existing profiles') %]:</th> <td> - [% L.select_tag('profile.id', L.options_for_select(SELF.all_profiles, title => 'name', default => SELF.profile.id), style => 'width: 300px') %] + [% L.select_tag('profile.id', SELF.all_profiles, title_key = 'name', default = SELF.profile.id, style = 'width: 300px') %] </td> <td> [% L.submit_tag('action_new', LxERP.t8('Load profile')) %] @@ -103,14 +103,13 @@ <tr> <th align="right">[%- LxERP.t8('Number Format') %]:</th> <td colspan="10"> - [% SET options = L.options_for_select([ '1.000,00', '1000,00', '1,000.00', '1000.00' ], default => SELF.profile.get('numberformat')) %] - [% L.select_tag('settings.numberformat', options, style => 'width: 300px') %] + [% L.select_tag('settings.numberformat', ['1.000,00', '1000,00', '1,000.00', '1000.00'], default = SELF.profile.get('numberformat'), style = 'width: 300px') %] </td> </tr> <tr> <th align="right">[%- LxERP.t8('Charset') %]:</th> - <td colspan="10">[% L.select_tag('settings.charset', L.options_for_select(SELF.all_charsets, default => SELF.profile.get('charset')), style => 'width: 300px') %]</td> + <td colspan="10">[% L.select_tag('settings.charset', SELF.all_charsets, default = SELF.profile.get('charset'), style = 'width: 300px') %]</td> </tr> <tr> @@ -181,7 +180,7 @@ [% opts = [ [ 'no_check', LxERP.t8('Do not check for duplicates') ], [ 'check_csv', LxERP.t8('Discard duplicate entries in CSV file') ], [ 'check_db', LxERP.t8('Discard entries with duplicates in database or CSV file') ] ] %] - [% L.select_tag('settings.duplicates', L.options_for_select(opts, default => SELF.profile.get('duplicates')), style => 'width: 300px') %] + [% L.select_tag('settings.duplicates', opts, default = SELF.profile.get('duplicates'), style = 'width: 300px') %] </td> </tr> [% END %] @@ -244,4 +243,4 @@ --> </script> </body> -</html> \ No newline at end of file +</html> diff --git a/templates/webpages/ct/_contact.html b/templates/webpages/ct/_contact.html index 528ad8ddc..bfa4f3772 100644 --- a/templates/webpages/ct/_contact.html +++ b/templates/webpages/ct/_contact.html @@ -4,8 +4,8 @@ <tr> <th align="left">[% 'Contacts' | $T8 %]</th> <td> - [%- L.select_tag('cp_id', L.options_for_select(CONTACTS, default => cp_id, with_empty => 1, empty_title => LxERP.t8('New contact'), value => 'cp_id', title_sub => \contacts_label), - onchange => "\$('#contacts').load('ct.pl?action=get_contact&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&cp_id=' + \$('#cp_id').attr('value'))") %] + [%- L.select_tag('cp_id', CONTACTS, default = cp_id, with_empty = 1, empty_title = LxERP.t8('New contact'), value_key = 'cp_id', title_sub = \contacts_label, + onchange = "\$('#contacts').load('ct.pl?action=get_contact&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&cp_id=' + \$('#cp_id').attr('value'))") %] </td> </tr> @@ -23,7 +23,7 @@ <th align="left" nowrap>[% 'Title' | $T8 %]</th> <td> <input id="cp_title" name="cp_title" size="40" maxlength="75" value="[% HTML.escape(cp_title) %]">  - [% L.select_tag('selected_cp_title', L.options_for_select(TITLES, with_empty => 1)) %] + [% L.select_tag('selected_cp_title', TITLES, with_empty = 1) %] </td> </tr> @@ -31,7 +31,7 @@ <th align="left" nowrap>[% 'Department' | $T8 %]</th> <td> <input id="cp_abteilung" name="cp_abteilung" size="40" value="[% HTML.escape(cp_abteilung) %]">  - [% L.select_tag('selected_cp_abteilung', L.options_for_select(DEPARTMENT, with_empty => 1)) %] + [% L.select_tag('selected_cp_abteilung', DEPARTMENT, with_empty = 1) %] </td> </tr> diff --git a/templates/webpages/ct/_shipto.html b/templates/webpages/ct/_shipto.html index cb0d59cf4..6367cceaf 100644 --- a/templates/webpages/ct/_shipto.html +++ b/templates/webpages/ct/_shipto.html @@ -3,8 +3,8 @@ <tr> <th align="right">[% 'Shipping Address' | $T8 %]</th> <td> - [% L.select_tag('shipto_id', L.options_for_select(SHIPTO, default => shipto_id, value => 'shipto_id', title_sub => \shipto_label, with_empty => 1, empty_title => LxERP.t8('New shipto')), - onchange => "\$('#shipto').load('ct.pl?action=get_shipto&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&shipto_id=' + this.value)") %] + [% L.select_tag('shipto_id', SHIPTO, default = shipto_id, value_key = 'shipto_id', title_sub = \shipto_label, with_empty = 1, empty_title = LxERP.t8('New shipto'), + onchange = "\$('#shipto').load('ct.pl?action=get_shipto&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&shipto_id=' + this.value)") %] </td> </tr> diff --git a/templates/webpages/ct/form_header.html b/templates/webpages/ct/form_header.html index 5e5480ae2..9c3df1221 100644 --- a/templates/webpages/ct/form_header.html +++ b/templates/webpages/ct/form_header.html @@ -215,7 +215,7 @@ <td><input name="bic" size="10" maxlength="100" value="[% HTML.escape(bic) %]"></td> [%- IF ALL_CURRENCIES.size %] <th align="right">[% 'Currency' | $T8 %]</th> - <td>[% L.select_tag('currency', L.options_for_select(ALL_CURRENCIES, default=currency, with_empty=1)) %]</td> + <td>[% L.select_tag('currency', ALL_CURRENCIES, default = currency, with_empty = 1) %]</td> [%- END %] </tr> @@ -279,7 +279,7 @@ </td> [%- IF is_customer && !conf_vertreter %] <th align="right">[% 'Salesman' | $T8 %]</th> - <td>[% L.select_tag('salesman_id', L.options_for_select(ALL_SALESMEN, default=salesman_id, with_empty=1, title='safe_name')) %]</td> + <td>[% L.select_tag('salesman_id', ALL_SALESMEN, default = salesman_id, with_empty = 1, title_key = 'safe_name') %]</td> [%- END %] </tr> </table> @@ -310,8 +310,8 @@ <tr> <th align="right">[% 'Shipping Address' | $T8 %]</th> <td colspan="3"> - [% L.select_tag('delivery_id', L.options_for_select(SHIPTO_ALL, title_sub => \shipto_label, with_empty => 1), - onchange => "\$('#delivery').load('ct.pl?action=get_delivery&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&shipto_id=' + this.value)") %] + [% L.select_tag('delivery_id', SHIPTO_ALL, title_sub = \shipto_label, with_empty = 1, + onchange = "\$('#delivery').load('ct.pl?action=get_delivery&id=' + \$('#cvid').attr('value') + '&db=' + \$('#db').attr('value') + '&shipto_id=' + this.value)") %] </td> </tr> @@ -399,7 +399,7 @@ <td> [% L.date_tag('FU_date', FU_date) %] [% 'for' | $T8 %] - [% L.select_tag('FU_created_for_user', L.options_for_select(ALL_EMPLOYEES, default=(FU_created_for_user ? FU_created_for_user : USER.id), title='safe_name')) %] + [% L.select_tag('FU_created_for_user', ALL_EMPLOYEES, default = (FU_created_for_user ? FU_created_for_user : USER.id), title='safe_name') %] </td> </tr> diff --git a/templates/webpages/ct/search.html b/templates/webpages/ct/search.html index 74697749a..eeea49ab2 100644 --- a/templates/webpages/ct/search.html +++ b/templates/webpages/ct/search.html @@ -1,4 +1,5 @@ [%- USE T8 %] +[%- USE L %] [% USE HTML %]<body onload="fokus()"> <form method="post" action="ct.pl" name="Form"> @@ -47,9 +48,7 @@ <tr> <th align="right" nowrap>[% IF IS_CUSTOMER %][% 'Customer type' | $T8 %][% ELSE %][% 'Vendor type' | $T8 %][% END %]</th> <td> - <select name="business_id"><option value=""></option> - [% FOREACH bt = ALL_BUSINESS_TYPES %]<option value="[% HTML.escape(bt.id) %]">[% HTML.escape(bt.description) %]</option>[% END %] - </select> + [% L.select_tag('business_id', ALL_BUSINESS_TYPES, title_key = 'description', with_empty = 1) %] </td> </tr> [% END %] diff --git a/templates/webpages/do/form_header.html b/templates/webpages/do/form_header.html index 2f29a953a..198a44ff3 100644 --- a/templates/webpages/do/form_header.html +++ b/templates/webpages/do/form_header.html @@ -132,7 +132,7 @@ [%- HTML.escape(row.cp_name) %][%- IF row.cp_abteilung %] ([% HTML.escape(row.cp_abteilung) %])[% END -%] [%- END %] [%- ELSE %] - [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title='full_name_dep', with_empty=1), style='width: 250px') %] + [% L.select_tag('cp_id', ALL_CONTACTS, default = cp_id, value = 'cp_id', title = 'full_name_dep', with_empty = 1, style='width: 250px') %] [%- END %] </td> </tr> @@ -154,7 +154,7 @@ [%- END %] [%- ELSE %] - [% L.select_tag('shipto_id', L.options_for_select(ALL_SHIPTO, default=shipto_id, value='shipto_id', title='displayable_id', with_empty=1), class='fixed_width') %] + [% L.select_tag('shipto_id', ALL_SHIPTO, default = shipto_id, value = 'shipto_id', title = 'displayable_id', with_empty = 1, class = 'fixed_width') %] [%- END %] </td> </tr> @@ -185,7 +185,7 @@ [% IF ( delivered ) %] [% L.hidden_tag('department_id', department_id) %] [% END %] - [% L.select_tag('department_id', L.options_for_select(ALL_DEPARTMENTS, default=department_id, title="description", with_empty=1), style='width: 250px', disabled => delivered )%] + [% L.select_tag('department_id', ALL_DEPARTMENTS, default = department_id, title = 'description', with_empty = 1, style = 'width: 250px', disabled = delivered )%] </td> </tr> [%- END %] @@ -246,7 +246,7 @@ [% IF row.id == employee_id %][%- IF row.name %][%- HTML.escape(row.name) %][%- ELSE %][% HTML.escape(row.login) %][%- END %][% END %] [%- END %] [%- ELSE %] - [% L.select_tag('employee_id', L.options_for_select(ALL_EMPLOYEES, default=employee_id, title='safe_name')) %] + [% L.select_tag('employee_id', ALL_EMPLOYEES, default = employee_id, title = 'safe_name') %] [%- END %] </td> </tr> @@ -266,7 +266,7 @@ [% IF row.id == the_salesman_id %][%- IF row.name %][%- HTML.escape(row.name) %][%- ELSE %][% HTML.escape(row.login) %][%- END %][% END %] [%- END %] [%- ELSE %] - [% L.select_tag('salesman_id', L.options_for_select(ALL_SALESMEN, default=(salesman_id ? salesman_id : employee_id), title='safe_name')) %] + [% L.select_tag('salesman_id', ALL_SALESMEN, default = (salesman_id ? salesman_id : employee_id), title = 'safe_name') %] [%- END %] </td> </tr> diff --git a/templates/webpages/do/search.html b/templates/webpages/do/search.html index 7d750d06b..213f962ea 100644 --- a/templates/webpages/do/search.html +++ b/templates/webpages/do/search.html @@ -71,13 +71,13 @@ <tr> <th align="right">[% 'Employee' | $T8 %]</th> - <td>[% L.select_tag('employee_id', L.options_for_select(ALL_EMPLOYEES, title='safe_name', with_empty=1), class='fixed_width') %]</td> + <td>[% L.select_tag('employee_id', ALL_EMPLOYEES, title_key = 'safe_name', with_empty = 1, class = 'fixed_width') %]</td> </tr> [%- IF is_customer %] <tr> <th align="right">[% 'Salesman' | $T8 %]</th> - <td>[% L.select_tag('salesman_id', L.options_for_select(ALL_EMPLOYEES, title='safe_name', with_empty=1), class='fixed_width') %]</td> + <td>[% L.select_tag('salesman_id', ALL_EMPLOYEES, title_key = 'safe_name', with_empty = 1, class = 'fixed_width') %]</td> </tr> [%- END %] diff --git a/templates/webpages/dunning/search.html b/templates/webpages/dunning/search.html index 2e6105af4..5d3bfdf8b 100644 --- a/templates/webpages/dunning/search.html +++ b/templates/webpages/dunning/search.html @@ -93,7 +93,7 @@ </tr> <tr> <th align="right">[% 'Salesman' | $T8 %]</th> - <td>[% L.select_tag('salesman_id', L.options_for_select(ALL_EMPLOYEES, title='safe_name', with_empty=1), style='width:250px') %]</td> + <td>[% L.select_tag('salesman_id', ALL_EMPLOYEES, title_key = 'safe_name', with_empty = 1, style = 'width:250px') %]</td> </tr> </table> </td> diff --git a/templates/webpages/gl/search.html b/templates/webpages/gl/search.html index ed7948df5..9f7c45e64 100644 --- a/templates/webpages/gl/search.html +++ b/templates/webpages/gl/search.html @@ -25,7 +25,7 @@ [%- IF all_departments %] <tr> <th align=right nowrap>[% 'Department' | $T8 %]</th> - <td colspan=3>[% L.select_tag('department', L.options_for_select(all_departments, value_title_sub=\department_label, with_empty=1)) %]</td> + <td colspan=3>[% L.select_tag('department', all_departments, value_title_sub = \department_label, with_empty = 1) %]</td> </tr> [%- END %] <tr> @@ -40,11 +40,11 @@ </tr> <tr> <th align=right>[% 'Project Number' | $T8 %]</th> - <td colspan=3>[% L.select_tag('project_id', L.options_for_select(ALL_PROJECTS, title='projectnumber', with_empty=1)) %]</td> + <td colspan=3>[% L.select_tag('project_id', ALL_PROJECTS, title_key = 'projectnumber', with_empty = 1) %]</td> </tr> <tr> <th align=right>[% 'Employee' | $T8 %]</th> - <td colspan=3>[% L.select_tag('employee', L.options_for_select(ALL_EMPLOYEES, title='safe_name', with_empty=1)) %]</td> + <td colspan=3>[% L.select_tag('employee', ALL_EMPLOYEES, title_key = 'safe_name', with_empty = 1) %]</td> </tr> <tr> <th align=right>[% 'Filter date by' | $T8 %]</th> diff --git a/templates/webpages/io/ship_to.html b/templates/webpages/io/ship_to.html index 516460bf5..318a5ebcd 100644 --- a/templates/webpages/io/ship_to.html +++ b/templates/webpages/io/ship_to.html @@ -57,7 +57,7 @@ <th align="right" nowrap>[% LxERP.t8('Gender') %]</th> <td></td> <td> - [% L.select_tag("shiptocp_gender", L.options_for_select([ [ "m", LxERP.t8("male") ], [ "f", LxERP.t8("female") ] ], "default", shiptocp_gender)) %] + [% L.select_tag('shiptocp_gender', [ [ 'm', LxERP.t8('male') ], [ 'f', LxERP.t8('female') ] ], 'default' = shiptocp_gender) %] </td> </tr> <tr> diff --git a/templates/webpages/ir/form_header.html b/templates/webpages/ir/form_header.html index d8a44e163..ee186c0b1 100644 --- a/templates/webpages/ir/form_header.html +++ b/templates/webpages/ir/form_header.html @@ -54,7 +54,7 @@ <tr> <th align="right">[% 'Contact Person' | $T8 %]</th> <td> - [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title='full_name_dep', with_empty=1), style='width: 250px') %] + [% L.select_tag('cp_id', ALL_CONTACTS, default = cp_id, value_key = 'cp_id', title_key = 'full_name_dep', with_empty = 1, style = 'width: 250px') %] </td> </tr> [%- END %] @@ -125,7 +125,7 @@ <table> <tr> <th align="right">[% 'Employee' | $T8 %]</th> - <td>[% L.select_tag('employee_id', L.options_for_select(ALL_EMPLOYEES, default=employee_id, title='safe_name')) %]</td> + <td>[% L.select_tag('employee_id', ALL_EMPLOYEES, default = employee_id, title_key = 'safe_name') %]</td> </tr> [%- IF is_type_credit_note %] diff --git a/templates/webpages/is/form_header.html b/templates/webpages/is/form_header.html index 80dd758e1..24b253f04 100644 --- a/templates/webpages/is/form_header.html +++ b/templates/webpages/is/form_header.html @@ -55,7 +55,7 @@ <tr> <th align="right">[% 'Contact Person' | $T8 %]</th> <td> - [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title='full_name_dep', with_empty=1), style='width: 250px') %] + [% L.select_tag('cp_id', ALL_CONTACTS, default = cp_id, value_key = 'cp_id', title_key = 'full_name_dep', with_empty = 1, style = 'width: 250px') %] </td> </tr> [%- END %] @@ -63,7 +63,7 @@ <tr> <th align="right">[% 'Shipping Address' | $T8 %]</th> <td> - [% L.select_tag('shipto_id', L.options_for_select(ALL_SHIPTO, default=shipto_id, value='shipto_id', title='displayable_id', with_empty=1), style='width: 250px', onChange="document.getElementById('update_button').click();") %] + [% L.select_tag('shipto_id', ALL_SHIPTO, default = shipto_id, value_key = 'shipto_id', title_key = 'displayable_id', with_empty = 1, style='width: 250px', onChange = "document.getElementById('update_button').click();") %] </td> </tr> [%- END %] @@ -98,7 +98,7 @@ <tr> <th align="right">[% 'Steuersatz' | $T8 %]</th> <td> - [% L.select_tag('taxzone_id', L.options_for_select(ALL_TAXZONES, default=taxzone_id, title='description'), disabled=(id ? 1 : 0), style='width: 250px', onchange="document.getElementById('update_button').click();") %] + [% L.select_tag('taxzone_id', ALL_TAXZONES, default = taxzone_id, title_key = 'description', disabled = (id ? 1 : 0), style='width: 250px', onchange = "document.getElementById('update_button').click();") %] [%- IF id %] <input type='hidden' name='taxzone_id' value='[% taxzone_id %]'> [%- END %] @@ -108,7 +108,7 @@ <tr> <th align="right" nowrap>[% 'Department' | $T8 %]</th> <td colspan="3"> - [% L.select_tag('department_id', L.options_for_select(all_departments, default=department_id, title_sub=\department_labels, with_empty=1), style='width:250px') %] + [% L.select_tag('department_id', all_departments, default = department_id, title_sub = \department_labels, with_empty = 1, style = 'width:250px') %] </td> </tr> [%- END %] @@ -155,14 +155,14 @@ <tr> <th align="right">[% 'Employee' | $T8 %]</th> <td> - [% L.select_tag('employee_id', L.options_for_select(ALL_EMPLOYEES, default=employee_id, title='safe_name')) %] + [% L.select_tag('employee_id', ALL_EMPLOYEES, default = employee_id, title_key = 'safe_name') %] </td> </tr> [%- IF ALL_SALESMEN.size %] <tr> <th align="right">[% 'Salesman' | $T8 %]</th> <td> - [% L.select_tag('salesman_id', L.options_for_select(ALL_SALESMEN, default=(salesman_id ? salesman_id : employee_id), title='safe_name')) %] + [% L.select_tag('salesman_id', ALL_SALESMEN, default = (salesman_id ? salesman_id : employee_id), title_key = 'safe_name') %] </td> </tr> [%- END %] @@ -226,7 +226,7 @@ <tr> <th align="right" nowrap>[% 'Project Number' | $T8 %]</th> <td> - [%- L.select_tag('globalproject_id', L.options_for_select(ALL_PROJECTS, title='projectnumber', default=globalproject_id, with_empty='1'), onChange="document.getElementById('update_button').click();") %] + [%- L.select_tag('globalproject_id', ALL_PROJECTS, title='projectnumber', default = globalproject_id, with_empty = '1', onChange = "document.getElementById('update_button').click();") %] </td> </tr> </table> diff --git a/templates/webpages/oe/edit_periodic_invoices_config.html b/templates/webpages/oe/edit_periodic_invoices_config.html index c469a02ce..2df969ebb 100644 --- a/templates/webpages/oe/edit_periodic_invoices_config.html +++ b/templates/webpages/oe/edit_periodic_invoices_config.html @@ -56,7 +56,7 @@ <tr> <th align="right">[%- LxERP.t8('Record in') %]</th> <td valign="top"> - [% L.select_tag("ar_chart_id", L.options_for_select(AR, title => 'description', default => ar_chart_id)) %] + [% L.select_tag("ar_chart_id", AR, title_key => 'description', default => ar_chart_id)) %] </td> </tr> @@ -70,7 +70,7 @@ <tr> <th align="right">[%- LxERP.t8('Printer') %]</th> <td valign="top"> - [% L.select_tag("printer_id", L.options_for_select(ALL_PRINTERS, title => 'printer_description', default => printer_id), disabled => !print) %] + [% L.select_tag("printer_id", ALL_PRINTERS, title_key = 'printer_description', default = printer_id, disabled = !print) %] </td> </tr> diff --git a/templates/webpages/oe/form_header.html b/templates/webpages/oe/form_header.html index 9b275af24..dff98c638 100644 --- a/templates/webpages/oe/form_header.html +++ b/templates/webpages/oe/form_header.html @@ -57,7 +57,7 @@ <tr> <th align="right">[% 'Contact Person' | $T8 %]</th> <td> - [% L.select_tag('cp_id', L.options_for_select(ALL_CONTACTS, default=cp_id, value='cp_id', title='full_name_dep', with_empty=1), style='width: 250px') %] + [% L.select_tag('cp_id', ALL_CONTACTS, default=cp_id, value_key='cp_id', title_key='full_name_dep', with_empty=1, style='width: 250px') %] </td> </tr> [%- END %] @@ -65,7 +65,7 @@ <tr> <th align="right">[% 'Shipping Address' | $T8 %]</th> <td> - [% L.select_tag('shipto_id', L.options_for_select(ALL_SHIPTO, default=shipto_id, value='shipto_id', title='displayable_id', with_empty=1), style='width: 250px', onChange="document.getElementById('update_button').click();") %] + [% L.select_tag('shipto_id', ALL_SHIPTO, default=shipto_id, value_key='shipto_id', title_key='displayable_id', with_empty=1, style='width: 250px', onChange="document.getElementById('update_button').click();") %] </td> </tr> [%- END %] @@ -93,14 +93,14 @@ <tr> <th align="right">[% 'Steuersatz' | $T8 %]</th> <td> - [% L.select_tag('taxzone_id', L.options_for_select(ALL_TAXZONES, default=taxzone_id, title='description'), style='width: 250px') %] + [% L.select_tag('taxzone_id', ALL_TAXZONES, default=taxzone_id, title_key='description', style='width: 250px') %] </td> </tr> [%- IF ALL_DEPARTMENTS %] <tr> <th align="right" nowrap>[% 'Department' | $T8 %]</th> <td colspan="3"> - [% L.select_tag('department_id', L.options_for_select(ALL_DEPARTMENTS, default=department_id, title_sub=\department_labels, with_empty=1), style='width:250px') %] + [% L.select_tag('department_id', ALL_DEPARTMENTS, default=department_id, title_sub=\department_labels, with_empty=1, style='width:250px') %] </td> </tr> [%- END %] @@ -164,14 +164,14 @@ <tr> <th align="right">[% 'Employee' | $T8 %]</th> <td> - [% L.select_tag('employee_id', L.options_for_select(ALL_EMPLOYEES, default=employee_id, title='safe_name')) %] + [% L.select_tag('employee_id', ALL_EMPLOYEES, default=employee_id, title_key='safe_name') %] </td> </tr> [%- IF is_sales and ALL_SALESMEN.size %] <tr> <th align="right">[% 'Salesman' | $T8 %]</th> <td> - [% L.select_tag('salesman_id', L.options_for_select(ALL_SALESMEN, default=(salesman_id ? salesman_id : employee_id), title='safe_name')) %] + [% L.select_tag('salesman_id', ALL_SALESMEN, default=(salesman_id ? salesman_id : employee_id), title_key='safe_name') %] </td> </tr> [%- END %] @@ -220,7 +220,7 @@ <tr> <th width="70%" align="right" nowrap>[% 'Project Number' | $T8 %]</th> <td> - [%- L.select_tag('globalproject_id', L.options_for_select(ALL_PROJECTS, title='projectnumber', default=globalproject_id, with_empty='1'), onChange="document.getElementById('update_button').click();") %] + [%- L.select_tag('globalproject_id', ALL_PROJECTS, title_key='projectnumber', default=globalproject_id, with_empty='1', onChange="document.getElementById('update_button').click();") %] </td> </tr> </table> diff --git a/templates/webpages/oe/search.html b/templates/webpages/oe/search.html index 3e3e5df5d..fb28ea18a 100644 --- a/templates/webpages/oe/search.html +++ b/templates/webpages/oe/search.html @@ -54,11 +54,11 @@ </tr> <tr> <th align="right">[% 'Employee' | $T8 %]</th> - <td>[% L.select_tag('employee_id', L.options_for_select(ALL_EMPLOYEES, title='safe_name', with_empty=1), style='width:250px') %]</td> + <td>[% L.select_tag('employee_id', ALL_EMPLOYEES, title_key='safe_name', with_empty=1, style='width:250px') %]</td> </tr> <tr> <th align="right">[% 'Salesman' | $T8 %]</th> - <td>[% L.select_tag('salesman_id', L.options_for_select(ALL_EMPLOYEES, title='safe_name', with_empty=1), style='width:250px') %]</td> + <td>[% L.select_tag('salesman_id', ALL_EMPLOYEES, title_key='safe_name', with_empty=1, style='width:250px') %]</td> </tr> <tr> <th align="right">[% 'Transaction description' | $T8 %]</th> diff --git a/templates/webpages/rc/step1.html b/templates/webpages/rc/step1.html index 718fe30cd..376ff6f52 100644 --- a/templates/webpages/rc/step1.html +++ b/templates/webpages/rc/step1.html @@ -11,7 +11,7 @@ <table> <tr> <th align=right nowrap>[% 'Account' | $T8 %]</th> - <td colspan=3>[% L.select_tag('accno', L.options_for_select(PR, value_title_sub=\selection_sub)) %]</td> + <td colspan=3>[% L.select_tag('accno', PR, value_title_sub=\selection_sub) %]</td> </tr> <tr> <th align=right>[% 'From' | $T8 %]</th> diff --git a/templates/webpages/rp/report.html b/templates/webpages/rp/report.html index 6f9583ecd..d99d45897 100644 --- a/templates/webpages/rp/report.html +++ b/templates/webpages/rp/report.html @@ -70,7 +70,7 @@ [%- BLOCK projectnumber %] <tr> <th align=right nowrap>[% 'Project' | $T8 %]</th> - <td colspan=3>[% L.select_tag('project_id', L.options_for_select(ALL_PROJECTS, title='projectnumber', with_empty=1)) %]</td> + <td colspan=3>[% L.select_tag('project_id', ALL_PROJECTS, title_key = 'projectnumber', with_empty = 1) %]</td> </tr> [%- END %]