From a5419c17b2553d59cd1369ca322115015ac05252 Mon Sep 17 00:00:00 2001 From: Werner Hahn Date: Wed, 30 Oct 2024 14:19:05 +0100 Subject: [PATCH] PartGroup: auch in deiversen Dropdown Partsgroup hierarchisch darstellen --- SL/Controller/Part.pm | 4 ++-- SL/DB/Manager/PartsGroup.pm | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 8965377e7e..ba2353522e 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -502,7 +502,7 @@ sub action_show_multi_items_dialog { $search_term ||= $self->models->filtered->laundered->{all_with_customer_partnumber_substr_multi__ilike}; $_[0]->render('part/_multi_items_dialog', { layout => 0 }, - all_partsgroups => SL::DB::Manager::PartsGroup->get_all, + all_partsgroups => SL::DB::Manager::PartsGroup->data_partsgroup_dropdown, search_term => $search_term ); } @@ -1420,7 +1420,7 @@ sub init_all_languages { sub init_all_partsgroups { my ($self) = @_; - SL::DB::Manager::PartsGroup->get_all_sorted(query => [ or => [ id => $self->part->partsgroup_id, obsolete => 0 ] ]); + SL::DB::Manager::PartsGroup->data_partsgroup_dropdown; } sub init_all_buchungsgruppen { diff --git a/SL/DB/Manager/PartsGroup.pm b/SL/DB/Manager/PartsGroup.pm index 027e2f3611..af04145c34 100644 --- a/SL/DB/Manager/PartsGroup.pm +++ b/SL/DB/Manager/PartsGroup.pm @@ -45,4 +45,15 @@ sub get_hierarchy { return \@list; } +sub data_partsgroup_dropdown { + my ($name, %params); + my $partsgroup = get_hierarchy; + my $partsgroup_hierarchie; + foreach my $pg (@{$partsgroup}) { + next if $pg->{obsolete}; + $pg->{partsgroup} = "| " x $pg->{level} . $pg->{partsgroup}; + push @{$partsgroup_hierarchie}, $pg; + } + return $partsgroup_hierarchie; +} 1;