Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a45417f3

Von Kivitendo Admin vor etwa 1 Jahr hinzugefügt

  • ID a45417f381c0aa7112adc6489049e23d23432df1
  • Vorgänger 7a29d8f7
  • Nachfolger 20af1c62

Warengruppen hierarchisch - DB

Unterschiede anzeigen:

SL/DB/Manager/PartsGroup.pm
columns => { SIMPLE => 'ALL' });
}
sub get_hierarchy {
my (%params) = @_;
# print params is only used for debugging in console
my @list;
foreach my $root_pg ( @{ SL::DB::Manager::PartsGroup->get_all( where => [ parent_id => undef ],
sort_by => ('sortkey'),
) } ) {
$root_pg->{partscount} = $root_pg->parts_count;
$root_pg->{level} = 0;
push(@list, $root_pg);
$root_pg->printable if $params{print}; # only for debugging
next unless scalar @{ $root_pg->children };
my $iterator = $root_pg->partsgroup_iterator_dfs;
while ( my $pg = $iterator->() ) {
push(@list, $pg);
$pg->{level} = $pg->get_level;
$pg->{partscount} = $pg->parts_count // 0; # probably better to call this separately. Also it doesn't need to be calculated each time for dropdown
# $pg->{padded_partsgroup} = ' ' x $pg->{level} . $pg->partsgroup; # this is probably redundant now, using css
$pg->printable if $params{print};
# $pg->print_report_charts if $params{charts};
# code $pg->printable if $params{tail};
};
# $root_pg->printable if $params{tail};
};
return \@list;
}
1;

Auch abrufbar als: Unified diff