|
1 |
package SL::Presenter::Filter::Part;
|
|
2 |
|
|
3 |
use parent SL::Presenter::Filter;
|
|
4 |
|
|
5 |
use strict;
|
|
6 |
|
|
7 |
use SL::Locale::String qw(t8);
|
|
8 |
|
|
9 |
use Params::Validate qw(:all);
|
|
10 |
|
|
11 |
sub get_default_filter_elements {
|
|
12 |
my ($filter) = @_;
|
|
13 |
|
|
14 |
my %default_filter_elements = ( # {{{
|
|
15 |
part_data => {
|
|
16 |
'position' => 1,
|
|
17 |
'text' => t8('Article data'),
|
|
18 |
'input_type' => 'input_group',
|
|
19 |
'input_values' => {
|
|
20 |
'partnumber' => {
|
|
21 |
'position' => 1,
|
|
22 |
'text' => t8("Partnumber"),
|
|
23 |
'input_type' => 'input_tag',
|
|
24 |
'input_name' => 'filter.partnumber:substr::ilike',
|
|
25 |
'input_default' => $filter->{'partnumber:substr::ilike'},
|
|
26 |
'report_id' => 'partnumber',
|
|
27 |
'active' => 1,
|
|
28 |
},
|
|
29 |
'ean' => {
|
|
30 |
'position' => 2,
|
|
31 |
'text' => t8("EAN"),
|
|
32 |
'input_type' => 'input_tag',
|
|
33 |
'input_name' => 'filter.ean:substr::ilike',
|
|
34 |
'input_default' => $filter->{'ean:substr::ilike'},
|
|
35 |
'report_id' => 'ean',
|
|
36 |
'active' => 1,
|
|
37 |
},
|
|
38 |
'description' => {
|
|
39 |
'position' => 3,
|
|
40 |
'text' => t8("Part Description"),
|
|
41 |
'input_type' => 'input_tag',
|
|
42 |
'input_name' => 'filter.description:substr::ilike',
|
|
43 |
'input_default' => $filter->{'description:substr::ilike'},
|
|
44 |
'report_id' => 'description',
|
|
45 |
'active' => 1,
|
|
46 |
},
|
|
47 |
'notes' => {
|
|
48 |
'position' => 4,
|
|
49 |
'text' => t8("Notes"),
|
|
50 |
'input_type' => 'input_tag',
|
|
51 |
'input_name' => 'filter.notes:substr::ilike',
|
|
52 |
'input_default' => $filter->{'notes:substr::ilike'},
|
|
53 |
'report_id' => 'notes',
|
|
54 |
'active' => 1,
|
|
55 |
},
|
|
56 |
'partsgroup' => {
|
|
57 |
'position' => 5,
|
|
58 |
'text' => t8("Partsgroup"),
|
|
59 |
'input_type' => 'input_tag',
|
|
60 |
'input_name' => 'filter.partsgroup.partsgroup:substr::ilike',
|
|
61 |
'input_default' => $filter->{partsgroup}->{'partsgroup:substr::ilike'},
|
|
62 |
'report_id' => 'partsgroup',
|
|
63 |
'active' => 1,
|
|
64 |
},
|
|
65 |
},
|
|
66 |
'input_name' => 'part_data',
|
|
67 |
'active' => 1,
|
|
68 |
},
|
|
69 |
); # }}}
|
|
70 |
return \%default_filter_elements;
|
|
71 |
}
|
|
72 |
|
|
73 |
sub get_price_change_printed_filter {
|
|
74 |
my ($filter) = @_;
|
|
75 |
my %part_label_print_filter = (
|
|
76 |
price_change_printed => {
|
|
77 |
'position' => 0.5,
|
|
78 |
'text' => t8('Price Change Printed'),
|
|
79 |
'input_type' => 'input_group',
|
|
80 |
'input_values' => {
|
|
81 |
'template' => {
|
|
82 |
'position' => 1,
|
|
83 |
'text' => t8("Template"),
|
|
84 |
'input_type' => 'select_tag',
|
|
85 |
'input_values' => [
|
|
86 |
['' => ''],
|
|
87 |
['part_label' => t8('Part label')],
|
|
88 |
['part_info' => t8('Part info')],
|
|
89 |
],
|
|
90 |
'input_name' => 'filter.price_change_printed.template',
|
|
91 |
'input_default' => $filter->{price_change_printed}->{template},
|
|
92 |
'active' => 1,
|
|
93 |
},
|
|
94 |
'print_type' => {
|
|
95 |
'position' => 2,
|
|
96 |
'text' => t8("Print Type"),
|
|
97 |
'input_type' => 'select_tag',
|
|
98 |
'input_values' => [
|
|
99 |
['' => ''],
|
|
100 |
['stock' => t8('Stock')],
|
|
101 |
['single' => t8('Single')],
|
|
102 |
],
|
|
103 |
'input_name' => 'filter.price_change_printed.print_type',
|
|
104 |
'input_default' => $filter->{price_change_printed}->{print_type},
|
|
105 |
'active' => 1,
|
|
106 |
},
|
|
107 |
'printed' => {
|
|
108 |
'position' => 3,
|
|
109 |
'text' => t8("Printed"),
|
|
110 |
'input_type' => 'select_tag',
|
|
111 |
'input_values' => [['0' => t8('No')], ['1' => t8('Yes')]],
|
|
112 |
'input_name' => 'filter.price_change_printed.printed',
|
|
113 |
'input_default' => $filter->{price_change_printed}->{printed},
|
|
114 |
'active' => 1,
|
|
115 |
},
|
|
116 |
},
|
|
117 |
'input_name' => 'price_change_printed_group',
|
|
118 |
'active' => 1,
|
|
119 |
},
|
|
120 |
);
|
|
121 |
return \%part_label_print_filter
|
|
122 |
}
|
|
123 |
|
|
124 |
sub filter {
|
|
125 |
my $filter = shift @_;
|
|
126 |
die "filter has to be a hash ref" if ref $filter ne 'HASH';
|
|
127 |
my %params = validate_with(
|
|
128 |
params => \@_,
|
|
129 |
spec => {
|
|
130 |
},
|
|
131 |
allow_extra => 1,
|
|
132 |
);
|
|
133 |
|
|
134 |
my $filter_elements = get_default_filter_elements($filter);
|
|
135 |
if(delete $params{show_price_change_printed_filter}) {
|
|
136 |
$filter_elements = {
|
|
137 |
%{$filter_elements},
|
|
138 |
%{get_price_change_printed_filter($filter)}
|
|
139 |
}
|
|
140 |
}
|
|
141 |
|
|
142 |
return SL::Presenter::Filter::create_filter($filter_elements, %params);
|
|
143 |
}
|
|
144 |
|
|
145 |
1;
|
|
146 |
|
|
147 |
__END__
|
|
148 |
|
|
149 |
=pod
|
|
150 |
|
|
151 |
=encoding utf8
|
|
152 |
|
|
153 |
=head1 NAME
|
|
154 |
|
|
155 |
SL::Presenter::Filter::Reclamation - Presenter module for a generic Filter on
|
|
156 |
Reclamation.
|
|
157 |
|
|
158 |
=head1 SYNOPSIS
|
|
159 |
|
|
160 |
# in Reclamation Controller
|
|
161 |
my $filter_html = SL::Presenter::Filter::Reclamation::filter(
|
|
162 |
$::form->{filter}, $self->type, active_in_report => $::form->{active_in_report}
|
|
163 |
);
|
|
164 |
|
|
165 |
|
|
166 |
=head1 FUNCTIONS
|
|
167 |
|
|
168 |
=over 4
|
|
169 |
|
|
170 |
=item C<filter $filter, $reclamation_type, %params>
|
|
171 |
|
|
172 |
Returns a rendered version (actually an instance of
|
|
173 |
L<SL::Presenter::EscapedText>) of a filter form for reclamations of type
|
|
174 |
C<$reclamation_type>.
|
|
175 |
|
|
176 |
C<$filter> should be the C<filter> value of the last C<$::form>. This is used to
|
|
177 |
get the previous values of the input fields.
|
|
178 |
|
|
179 |
C<%params> fields get forwarded to C<SL::Presenter::Filter::create_filter>.
|
|
180 |
|
|
181 |
=back
|
|
182 |
|
|
183 |
=head1 BUGS
|
|
184 |
|
|
185 |
Nothing here yet.
|
|
186 |
|
|
187 |
=head1 AUTHOR
|
|
188 |
|
|
189 |
Tamino Steinert E<lt>tamino.steinert@tamino.stE<gt>
|
|
190 |
|
|
191 |
=cut
|
FIX: S:P:Filter: Spalten und Zeilen für Filtereingabe richtig berechnen