Revision 4f152ed2
Von Kivitendo Admin vor mehr als 9 Jahren hinzugefügt
SL/DB/Manager/Chart.pm | ||
---|---|---|
6 | 6 |
use base qw(SL::DB::Helper::Manager); |
7 | 7 |
|
8 | 8 |
use SL::DB::Helper::Sorted; |
9 |
use SL::DB::Helper::Paginated; |
|
10 |
use SL::DB::Helper::Filtered; |
|
11 |
use SL::MoreCommon qw(listify); |
|
9 | 12 |
use DateTime; |
10 | 13 |
use SL::DBUtils; |
14 |
use Data::Dumper; |
|
11 | 15 |
|
12 | 16 |
sub object_class { 'SL::DB::Chart' } |
13 | 17 |
|
14 | 18 |
__PACKAGE__->make_manager_methods; |
15 | 19 |
|
20 |
__PACKAGE__->add_filter_specs( |
|
21 |
type => sub { |
|
22 |
my ($key, $value) = @_; |
|
23 |
return __PACKAGE__->type_filter($value); |
|
24 |
}, |
|
25 |
category => sub { |
|
26 |
my ($key, $value) = @_; |
|
27 |
return __PACKAGE__->category_filter($value); |
|
28 |
}, |
|
29 |
selected_category => sub { |
|
30 |
my ($key, $value) = @_; |
|
31 |
return __PACKAGE__->selected_category_filter($value); |
|
32 |
}, |
|
33 |
all => sub { |
|
34 |
my ($key, $value) = @_; |
|
35 |
return or => [ map { $_ => $value } qw(accno description) ] |
|
36 |
}, |
|
37 |
booked => sub { |
|
38 |
my ($key, $value) = @_; |
|
39 |
return __PACKAGE__->booked_filter($value); |
|
40 |
}, |
|
41 |
); |
|
42 |
|
|
43 |
sub booked_filter { |
|
44 |
my ($class, $booked) = @_; |
|
45 |
|
|
46 |
$booked //= 0; |
|
47 |
my @filter; |
|
48 |
|
|
49 |
if ( $booked ) { |
|
50 |
push @filter, ( id => [ \"SELECT distinct chart_id FROM acc_trans" ] ); |
|
51 |
}; |
|
52 |
|
|
53 |
return @filter; |
|
54 |
} |
|
55 |
|
|
56 |
sub selected_category_filter { |
|
57 |
my ($class, $selected_categories) = @_; |
|
58 |
|
|
59 |
my @selected_categories = @$selected_categories; |
|
60 |
|
|
61 |
# if no category is selected, there is no filter and thus all charts of all |
|
62 |
# categories are displayed, which is what we want. |
|
63 |
|
|
64 |
return (category => \@$selected_categories); |
|
65 |
} |
|
66 |
|
|
67 |
sub type_filter { |
|
68 |
my ($class, $type) = @_; |
|
69 |
|
|
70 |
# filter by link or several defined custom types |
|
71 |
# special types: |
|
72 |
# bank, guv, balance |
|
73 |
|
|
74 |
return () unless $type; |
|
75 |
|
|
76 |
if ('HASH' eq ref $type) { |
|
77 |
# this is to make selection like type => { AR_paid => 1, AP_paid => 1 } work |
|
78 |
$type = [ grep { $type->{$_} } keys %$type ]; |
|
79 |
} |
|
80 |
|
|
81 |
my @types = grep { $_ } listify($type); |
|
82 |
my @filter; |
|
83 |
|
|
84 |
for my $type (@types) { |
|
85 |
if ( $type eq 'bank' ) { |
|
86 |
push @filter, ( id => [ \"SELECT chart_id FROM bank_accounts" ] ); |
|
87 |
} elsif ( $type eq 'guv' ) { |
|
88 |
push @filter, ( category => [ 'I', 'E' ] ); |
|
89 |
} elsif ( $type eq 'balance' ) { |
|
90 |
push @filter, ( category => [ 'A', 'Q', 'L' ] ); |
|
91 |
} else { |
|
92 |
push @filter, $class->link_filter($type); |
|
93 |
}; |
|
94 |
}; |
|
95 |
|
|
96 |
return @filter > 2 ? (or => \@filter) : @filter; |
|
97 |
} |
|
98 |
|
|
99 |
sub category_filter { |
|
100 |
my ($class, $category) = @_; |
|
101 |
|
|
102 |
return () unless $category; |
|
103 |
|
|
104 |
# filter for chart_picker if a category filter was passed via params |
|
105 |
|
|
106 |
if ( ref $category eq 'HASH' ) { |
|
107 |
# this is to make a selection like category => { I => 1, E => 1 } work |
|
108 |
$category = [ grep { $category->{$_} } keys %$category ]; |
|
109 |
} |
|
110 |
|
|
111 |
my @categories = grep { $_ } listify($category); |
|
112 |
|
|
113 |
return (category => \@categories); |
|
114 |
} |
|
115 |
|
|
16 | 116 |
sub link_filter { |
17 | 117 |
my ($class, $link) = @_; |
18 | 118 |
|
... | ... | |
43 | 143 |
} |
44 | 144 |
} |
45 | 145 |
|
146 |
sub _sort_spec { |
|
147 |
( |
|
148 |
default => [ 'accno', 1 ], |
|
149 |
# columns => { |
|
150 |
# SIMPLE => 'ALL', |
|
151 |
# }, |
|
152 |
nulls => {}, |
|
153 |
); |
|
154 |
} |
|
155 |
|
|
46 | 156 |
1; |
47 | 157 |
|
48 | 158 |
__END__ |
... | ... | |
77 | 187 |
|
78 | 188 |
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt> |
79 | 189 |
|
190 |
G. Richardson E<lt>information@kivitendo-premium.deE<gt> |
|
191 |
|
|
80 | 192 |
=cut |
Auch abrufbar als: Unified diff
Neues Feature: Chartpicker
Praktisch komplett analog zum Partpicker, danke Sven für die
Pionierleistung!
Es gibt natürlich ein paar Unterschiede bei den Filteroptionen, z.B.
kann man im Popup nur bebuchte Konten anzeigen lassen, oder die
Ergebnisliste nach der Kontenart einschränken. Es wird auch immer nur
eine Konto pro Spalte angezeigt, auch im Block Modus.
Hat der Benutzer FiBu-Rechte wird auch der aktuelle Kontensaldo
angezeigt. Hierfür wurden ein paar neue Methoden für Chart hinzugefügt.