Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6d14c91b

Von Kivitendo Admin vor 9 Tagen hinzugefügt

  • ID 6d14c91b432b9a3690168cdd26b353363c6ac2d2
  • Vorgänger d7077fec
  • Nachfolger e8ce945f

Warengruppen hierarchisch - DB

Unterschiede anzeigen:

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