From 6ea1dd9bb2e7965da7d0ef66a0b464267ce41a9b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Thu, 23 Apr 2015 15:20:36 +0200 Subject: [PATCH] item_selected: Multiselect bzw. Mengeneingabe beim Artikelselektor Dieses Feature kann in den Benutzereinstellungen aktiviert werden. --- SL/DB/AuthUser.pm | 2 +- bin/mozilla/do.pl | 2 +- bin/mozilla/ic.pl | 2 +- bin/mozilla/io.pl | 67 ++++++++++++++++++-------- bin/mozilla/ir.pl | 2 +- bin/mozilla/is.pl | 2 +- bin/mozilla/oe.pl | 2 +- doc/changelog | 5 ++ locale/de/all | 1 + locale/en/all | 1 + templates/webpages/am/config.html | 7 +++ templates/webpages/io/select_item.html | 31 +++++++++++- 12 files changed, 97 insertions(+), 27 deletions(-) diff --git a/SL/DB/AuthUser.pm b/SL/DB/AuthUser.pm index 1eac6f937..a8d8ab513 100644 --- a/SL/DB/AuthUser.pm +++ b/SL/DB/AuthUser.pm @@ -11,7 +11,7 @@ use SL::DB::Helper::Util; use constant CONFIG_VARS => qw(copies countrycode dateformat timeformat default_media default_printer_id email favorites fax hide_cvar_search_options mandatory_departments menustyle name numberformat show_form_details signature stylesheet taxincluded_checked tel - template_format vclimit focus_position form_cvars_nr_cols); + template_format vclimit focus_position form_cvars_nr_cols item_multiselect); __PACKAGE__->meta->add_relationship( groups => { diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index 3f624181f..6b37b6cb8 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -419,7 +419,7 @@ sub update_delivery_order { if ($rows > 1) { - select_item(mode => $mode); + select_item(mode => $mode, pre_entered_qty => $form->{"qty_$i"}); ::end_of_request(); } else { diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 12037639d..98b4037b0 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -1845,7 +1845,7 @@ sub update { if ($rows > 1) { $form->{makemodel_rows}--; - select_item(mode => 'IC'); + select_item(mode => 'IC', pre_entered_qty => $form->parse_amount(\%myconfig, $form->{"qty_$i"})); ::end_of_request(); } else { map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 4930d25e4..4a3805dd2 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -497,8 +497,8 @@ sub select_item { $main::lxdebug->enter_sub(); my %params = @_; - my $mode = $params{mode} || croak "Missing parameter 'mode'"; - + my $mode = $params{mode} || croak "Missing parameter 'mode'"; + my $pre_entered_qty = $params{pre_entered_qty} || 1; _check_io_auth(); my $previous_form = $::auth->save_form_in_session(form => $::form); @@ -513,11 +513,12 @@ sub select_item { # delete action variable delete @{$::form}{qw(action item_list)}; - print $::form->parse_html_template('io/select_item', { PREVIOUS_FORM => $previous_form, - MODE => $mode, - ITEM_LIST => \@item_list, - IS_ASSEMBLY => $mode eq 'IC', - IS_PURCHASE => $mode eq 'IS' }); + print $::form->parse_html_template('io/select_item', { PREVIOUS_FORM => $previous_form, + MODE => $mode, + ITEM_LIST => \@item_list, + IS_ASSEMBLY => $mode eq 'IC', + IS_PURCHASE => $mode eq 'IS', + PRE_ENTERED_QTY => $pre_entered_qty, }); $main::lxdebug->leave_sub(); } @@ -536,18 +537,47 @@ sub item_selected { $::auth->restore_form_from_session($form->{select_item_previous_form} || croak('Missing previous form ID'), form => $form); - my $mode = delete($form->{select_item_mode}) || croak 'Missing item selection mode'; - my $id = delete($form->{select_item_id}) || croak 'Missing item selection ID'; - my $i = $form->{ $mode eq 'IC' ? 'assembly_rows' : 'rowcount' }; + my $mode = delete($form->{select_item_mode}) || croak 'Missing item selection mode'; + my $row_key = $mode eq 'IC' ? 'assembly_rows' : 'rowcount'; + my $curr_row = $form->{ $row_key }; + + my $row = $curr_row; + + if ($myconfig{item_multiselect}) { + foreach (grep(/^select_qty_/, keys(%{ $form }))) { + next unless $form->{$_}; + $_ =~ /^select_qty_(\d+)/; + $form->{"id_${row}"} = $1; + $form->{"qty_${row}"} = $form->{$_}; + $row++; + } + } else { + $form->{"id_${row}"} = delete($form->{select_item_id}) || croak 'Missing item selection ID'; + $row++; + } + + map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } + qw(sellprice listprice weight); if ( $mode eq 'IC' ) { # assembly mode: - # the qty variables of the existing assembly items are all still formatted, so we parse them here (1 .. $i-1) - # including the qty of the just added part ($i) - $form->{"qty_$_"} = $form->parse_amount(\%myconfig, $form->{"qty_$_"}) for (1 .. $i); + # the qty variables of the existing assembly items are all still formatted, so we parse them here + # including the qty of the just added part + $form->{"qty_$_"} = $form->parse_amount(\%myconfig, $form->{"qty_$_"}) for (1 .. $row - 1); + } else { + if ($myconfig{item_multiselect}) { + # other modes and multiselection: + # parse all newly entered qtys + $form->{"qty_$_"} = $form->parse_amount(\%myconfig, $form->{"qty_$_"}) for ($curr_row .. $row - 1); + } } - $form->{"id_${i}"} = $id; + for my $i ($curr_row .. $row - 1) { + $form->{ $row_key } = $i; + + my $id = $form->{"id_${i}"}; + + delete $form->{item_list}; if ($mode eq 'IS') { IS->retrieve_item(\%myconfig, \%$form); @@ -617,9 +647,6 @@ sub item_selected { } } - map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } - qw(sellprice listprice weight); - # at this stage qty of newly added part needs to be have been parsed $form->{weight} += ($form->{"weight_$i"} * $form->{"qty_$i"}); @@ -640,14 +667,16 @@ sub item_selected { $form->{"runningnumber_$i"} = $i; - delete $form->{nextsub}; - # format amounts map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice lastcost qty) if $form->{item} ne 'assembly'; + delete $form->{nextsub}; + + } + &display_form; $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 7176653cb..731f74737 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -492,7 +492,7 @@ sub update { if ($rows > 1) { - select_item(mode => 'IR'); + select_item(mode => 'IR', pre_entered_qty => $form->{"qty_$i"}); ::end_of_request(); } else { diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index cac93daad..1f9dd0843 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -568,7 +568,7 @@ sub update { if ($rows > 1) { - select_item(mode => 'IS'); + select_item(mode => 'IS', pre_entered_qty => $form->{"qty_$i"}); ::end_of_request(); } else { diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index 147e9d9de..7b6796bd4 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -648,7 +648,7 @@ sub update { if ($rows > 1) { - select_item(mode => $mode); + select_item(mode => $mode, pre_entered_qty => $form->{"qty_$i"}); ::end_of_request(); } else { diff --git a/doc/changelog b/doc/changelog index 19290121a..c2bd15555 100644 --- a/doc/changelog +++ b/doc/changelog @@ -10,6 +10,11 @@ Kleinere neue Features und Detailverbesserungen: - Briefe werden auch im WebDAV archiviert. Ferner bessere Fehlerbehandlung und E-Mail-Funktion aktiviert. +- Mehrfachauswahl und Mengeneingabe für Artikel: + Wenn in den Belegmasken die Artikeleingabe nicht eindeutig ist, erscheint + eine Maske zur Artikelauswahl. Hierzu kann jetzt in den Benutzereinstellungen + eingestellt werden, dass in dieser Maske mehrere Artikel mit Mengen ausgewählt + werden können. 2015-04-10 - Release 3.2.1 diff --git a/locale/de/all b/locale/de/all index f30e33dbd..f618bd82d 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1402,6 +1402,7 @@ $self->{texts} = { 'It will simply set the taxkey to 0 (meaning "no taxes") which is the correct value for such inventory transactions.' => 'Es wird einfach die Steuerschlüssel auf 0 setzen, was "keine Steuer" bedeutet und für solche Warenbestandsbuchungen der richtige Wert ist.', 'Item deleted!' => 'Artikel gelöscht!', 'Item mode' => 'Artikelmodus', + 'Item multi selection with qty' => 'Artikel-Mehrfachauswahl mit Menge', 'Item not on file!' => 'Dieser Artikel ist nicht in der Datenbank!', 'Item values' => 'Artikelwerte', 'Item variables' => 'Artikelvariablen', diff --git a/locale/en/all b/locale/en/all index 92b686361..76f300989 100644 --- a/locale/en/all +++ b/locale/en/all @@ -1192,6 +1192,7 @@ $self->{texts} = { 'It will simply set the taxkey to 0 (meaning "no taxes") which is the correct value for such inventory transactions.' => '', 'Item deleted!' => '', 'Item mode' => '', + 'Item multi selection with qty' => '', 'Item not on file!' => '', 'Item values' => '', 'Item variables' => '', diff --git a/templates/webpages/am/config.html b/templates/webpages/am/config.html index 13b060a16..ac7875b11 100644 --- a/templates/webpages/am/config.html +++ b/templates/webpages/am/config.html @@ -78,6 +78,13 @@ + + [% 'Item multi selection with qty' | $T8 %] + + [% L.yes_no_tag('item_multiselect', myconfig_item_multiselect) %] + + + diff --git a/templates/webpages/io/select_item.html b/templates/webpages/io/select_item.html index 9252b45fc..11dfbf609 100644 --- a/templates/webpages/io/select_item.html +++ b/templates/webpages/io/select_item.html @@ -5,7 +5,11 @@ - + [%- IF myconfig_item_multiselect %] + + [%- ELSE %] + + [%- END %] @@ -19,7 +23,11 @@ [%- FOREACH item = ITEM_LIST %] - + [%- IF myconfig_item_multiselect %] + + [%- ELSE %] + + [%- END %] @@ -41,3 +49,22 @@ [% L.submit_tag('action', LxERP.t8('Continue')) %] + +[%- IF myconfig_item_multiselect %] + +[%- END %] -- 2.20.1
 [% LxERP.t8('Qty') %] [% LxERP.t8('Number') %] [% LxERP.t8('Part Description') %] [% LxERP.t8('Other Matches') %]
[% L.input_tag('select_qty_' _ HTML.escape(item.id), '', size => 5) %][% HTML.escape(item.partnumber) %] [% HTML.escape(item.description) %] [% HTML.escape(item.matches).join('
') %]