Revision aa08ecd9
Von Kivitendo Admin vor 10 Monaten hinzugefügt
SL/DB/Manager/PartsGroup.pm | ||
---|---|---|
16 | 16 |
columns => { SIMPLE => 'ALL' }); |
17 | 17 |
} |
18 | 18 |
|
19 |
sub get_hierarchy { |
|
20 |
my (%params) = @_; |
|
21 |
# print params is only used for debugging in console |
|
22 |
|
|
23 |
my @list; |
|
24 |
|
|
25 |
foreach my $root_pg ( @{ SL::DB::Manager::PartsGroup->get_all( where => [ parent_id => undef ], |
|
26 |
sort_by => ('sortkey'), |
|
27 |
) } ) { |
|
28 |
$root_pg->{partscount} = $root_pg->parts_count; |
|
29 |
$root_pg->{level} = 0; |
|
30 |
push(@list, $root_pg); |
|
31 |
$root_pg->printable if $params{print}; # only for debugging |
|
32 |
next unless scalar @{ $root_pg->children }; |
|
33 |
my $iterator = $root_pg->partsgroup_iterator_dfs; |
|
34 |
while ( my $pg = $iterator->() ) { |
|
35 |
push(@list, $pg); |
|
36 |
$pg->{level} = $pg->get_level; |
|
37 |
$pg->{partscount} = $pg->parts_count // 0; # probably better to call this separately. Also it doesn't need to be calculated each time for dropdown |
|
38 |
# $pg->{padded_partsgroup} = ' ' x $pg->{level} . $pg->partsgroup; # this is probably redundant now, using css |
|
39 |
$pg->printable if $params{print}; |
|
40 |
# $pg->print_report_charts if $params{charts}; |
|
41 |
# code $pg->printable if $params{tail}; |
|
42 |
}; |
|
43 |
# $root_pg->printable if $params{tail}; |
|
44 |
}; |
|
45 |
return \@list; |
|
46 |
} |
|
47 |
|
|
19 | 48 |
1; |
Auch abrufbar als: Unified diff
Warengruppen hierarchisch - DB