Revision 986282c1
Von Sven Schöling vor etwa 10 Jahren hinzugefügt
SL/Controller/PriceRule.pm | ||
---|---|---|
197 | 197 |
push @filter_strings, "$_->[1]: $_->[0]" if $_->[0]; |
198 | 198 |
} |
199 | 199 |
|
200 |
if ($filter->{has_item_type}) { |
|
201 |
push @filter_strings, sprintf "%s: %s", t8('Has item type'), join ', ', map { |
|
202 |
SL::DB::Manager::PriceRuleItem->get_type($_)->{description} |
|
203 |
} @{ $filter->{has_item_type} || [] }; |
|
204 |
} |
|
205 |
|
|
200 | 206 |
$self->{filter_summary} = join ', ', @filter_strings; |
201 | 207 |
} |
202 | 208 |
|
203 | 209 |
sub all_price_rule_item_types { |
204 |
SL::DB::Manager::PriceRuleItem->get_all_types($_[0]->price_rule->type); |
|
210 |
SL::DB::Manager::PriceRuleItem->get_all_types($_[0]->vc || $_[0]->price_rule->type);
|
|
205 | 211 |
} |
206 | 212 |
|
207 | 213 |
sub add_javascripts { |
SL/DB/Manager/PriceRule.pm | ||
---|---|---|
17 | 17 |
sub object_class { 'SL::DB::PriceRule' } |
18 | 18 |
|
19 | 19 |
__PACKAGE__->make_manager_methods; |
20 |
__PACKAGE__->add_filter_specs( |
|
21 |
has_item_type => sub { |
|
22 |
my ($key, $values, $prefix) = @_; |
|
23 |
return unless @$values; |
|
24 |
|
|
25 |
my $each_type = "SELECT DISTINCT price_rules_id FROM price_rule_items WHERE type = %s"; |
|
26 |
my $sub_query = join ' INTERSECT ', map { sprintf $each_type, $::form->get_standard_dbh->quote($_) } @$values; |
|
27 |
return or => [ ${prefix} . 'id' => [ \$sub_query ] ]; |
|
28 |
}, |
|
29 |
item_type_matches => sub { |
|
30 |
my ($key, $values, $prefix) = @_; |
|
31 |
return unless @$values; |
|
32 |
return unless 'HASH' eq ref $values->[0]; |
|
33 |
return unless grep $_, values %{ $values->[0] }; |
|
34 |
|
|
35 |
my $each_type = "SELECT DISTINCT price_rules_id FROM price_rule_items WHERE type = %s AND (%s)"; |
|
36 |
my $sub_query = join ' INTERSECT ', map { |
|
37 |
sprintf $each_type, $::form->get_standard_dbh->quote($_), SL::DB::Manager::PriceRuleItem->filter_match($_, $values->[0]{$_}) |
|
38 |
} grep { $values->[0]{$_} } keys %{ $values->[0] }; |
|
39 |
return or => [ ${prefix} . 'id' => [ \$sub_query ] ]; |
|
40 |
}, |
|
41 |
); |
|
20 | 42 |
|
21 | 43 |
sub get_matching_filter { |
22 | 44 |
my ($class, %params) = @_; |
SL/DB/Manager/PriceRuleItem.pm | ||
---|---|---|
78 | 78 |
[ map { [ $_, $types{$_}{description} ] } grep { $types{$_}{$vc} } map { $_ } @types ]; |
79 | 79 |
} |
80 | 80 |
|
81 |
sub get_type { |
|
82 |
$types{$_[1]} |
|
83 |
} |
|
84 |
|
|
85 |
sub filter_match { |
|
86 |
my ($self, $type, $value) = @_; |
|
87 |
|
|
88 |
my $type_def = $types{$type}; |
|
89 |
|
|
90 |
if (!$type_def->{ops}) { |
|
91 |
my $evalue = $::form->get_standard_dbh->quote($value); |
|
92 |
return "value_$type_def->{data_type} = $evalue"; |
|
93 |
} elsif ($type_def->{ops} eq 'date') { |
|
94 |
my $date_value = $::form->get_standard_dbh->quote(DateTime->from_kivitendo($value)); |
|
95 |
return " |
|
96 |
(value_$type_def->{data_type} > $date_value AND op = 'lt') OR |
|
97 |
(value_$type_def->{data_type} < $date_value AND op = 'gt') OR |
|
98 |
(value_$type_def->{data_type} = $date_value AND op = 'eq') |
|
99 |
"; |
|
100 |
} elsif ($type_def->{ops} eq 'num') { |
|
101 |
my $num_value = $::form->get_standard_dbh->quote($::form->parse_amount(\%::myconfig, $value)); |
|
102 |
return " |
|
103 |
(value_$type_def->{data_type} >= $num_value AND op = 'le') OR |
|
104 |
(value_$type_def->{data_type} <= $num_value AND op = 'ge') OR |
|
105 |
(value_$type_def->{data_type} = $num_value AND op = 'eq') |
|
106 |
"; |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
|
|
81 | 111 |
1; |
locale/de/all | ||
---|---|---|
1210 | 1210 |
'HTML Templates' => 'HTML-Vorlagen', |
1211 | 1211 |
'Handling of WebDAV' => 'Behandlung von WebDAV', |
1212 | 1212 |
'Hardcopy' => 'Seite drucken', |
1213 |
'Has item type' => 'Hat Regeltypen', |
|
1213 | 1214 |
'Has serial number' => 'Hat eine Serienummer', |
1214 | 1215 |
'Heading' => 'Überschrift', |
1215 | 1216 |
'Help Template Variables' => 'Hilfe zu Dokumenten-Variablen', |
templates/webpages/price_rule/_filter.html | ||
---|---|---|
10 | 10 |
<div class='filter_toggle' style='display:none'> |
11 | 11 |
<a href='#' onClick='javascript:$(".filter_toggle").toggle()'>[% 'Hide Filter' | $T8 %]</a> |
12 | 12 |
<table id='filter_table'> |
13 |
<tr> |
|
14 | 13 |
<tr> |
15 | 14 |
<th align="right">[% 'Description' | $T8 %]</th> |
16 |
<td>[% L.input_tag('filter.name:substr::ilike', filter.name_substr__ilike, size = 20) %]</td> |
|
15 |
<td>[% L.input_tag('filter.name:substr::ilike', filter.name_substr__ilike, size = 20, style='width: 300px') %]</td> |
|
16 |
</tr> |
|
17 |
<tr> |
|
18 |
<th align="right">[% 'Part' | $T8 %]</th> |
|
19 |
<td>[% L.part_picker('filter.item_type_matches[].part', FORM.filter.item_type_matches.0.part, style='width: 300px') %]</td> |
|
20 |
</tr> |
|
21 |
[%- IF SELF.vc == 'customer' %] |
|
22 |
<tr> |
|
23 |
<th align="right">[% 'Customer' | $T8 %]</th> |
|
24 |
<td>[% L.customer_vendor_picker('filter.item_type_matches[].customer', FORM.filter.item_type_matches.0.customer, type='customer', style='width: 300px') %]</td> |
|
25 |
</tr> |
|
26 |
[%- END %] |
|
27 |
[%- IF SELF.vc == 'vendor' %] |
|
28 |
<tr> |
|
29 |
<th align="right">[% 'Vendor' | $T8 %]</th> |
|
30 |
<td>[% L.customer_vendor_picker('filter.item_type_matches[].vendor', FORM.filter.item_type_matches.0.vendor, type='vendor', style='width: 300px') %]</td> |
|
31 |
</tr> |
|
32 |
[%- END %] |
|
33 |
<tr> |
|
34 |
<th align="right">[% 'Business' | $T8 %]</th> |
|
35 |
<td>[% L.select_tag('filter.item_type_matches[].business', SELF.businesses, title_key='description', default=FORM.filter.item_type_matches.0.business, with_empty=1, style='width: 300px') %]</td> |
|
36 |
</tr> |
|
37 |
<tr> |
|
38 |
<th align="right">[% 'Group' | $T8 %]</th> |
|
39 |
<td>[% L.select_tag('filter.item_type_matches[].partsgroup', SELF.partsgroups, title_key='partsgroup', default=FORM.filter.item_type_matches.0.partsgroup, with_empty=1, style='width: 300px') %]</td> |
|
40 |
</tr> |
|
41 |
<tr> |
|
42 |
<th align="right">[% 'Qty' | $T8 %]</th> |
|
43 |
<td>[% L.input_tag('filter.item_type_matches[].qty', FORM.filter.item_type_matches.0.qty, style='width: 300px') %]</td> |
|
44 |
</tr> |
|
45 |
<tr> |
|
46 |
<th align="right">[% 'Reqdate' | $T8 %]</th> |
|
47 |
<td>[% L.date_tag('filter.item_type_matches[].reqdate', FORM.filter.item_type_matches.0.reqdate, style='width: 300px') %]</td> |
|
48 |
</tr> |
|
49 |
<tr> |
|
50 |
<th align="right">[% 'Transdate' | $T8 %]</th> |
|
51 |
<td>[% L.date_tag('filter.item_type_matches[].transdate', FORM.filter.item_type_matches.0.transdate, style='width: 300px') %]</td> |
|
52 |
</tr> |
|
53 |
<tr> |
|
54 |
<th align="right">[% 'Pricegroup' | $T8 %]</th> |
|
55 |
<td>[% L.select_tag('filter.item_type_matches[].pricegroup', SELF.pricegroups, default=FORM.filter.item_type_matches.0.pricegroup, title_key='pricegroup', with_empty=1, style='width: 300px') %]<br> |
|
56 |
</td> |
|
17 | 57 |
</tr> |
18 | 58 |
<tr> |
19 | 59 |
<th align="right">[% 'Price' | $T8 %]</th> |
20 |
<td>[% L.input_tag('filter.price:number', filter.price_number, size=20) %]</td> |
|
60 |
<td>[% L.input_tag('filter.price:number', filter.price_number, size=20, style='width: 300px') %]</td>
|
|
21 | 61 |
</tr> |
22 | 62 |
<tr> |
23 | 63 |
<th align="right">[% 'Discount' | $T8 %]</th> |
24 |
<td>[% L.input_tag('filter.discount:number', filter.discount_number, size=20) %]</td> |
|
64 |
<td>[% L.input_tag('filter.discount:number', filter.discount_number, size=20, style='width: 300px') %]</td>
|
|
25 | 65 |
</tr> |
26 | 66 |
<tr> |
27 | 67 |
<th align="right">[% 'Priority' | $T8 %]</th> |
... | ... | |
31 | 71 |
<th align="right">[% 'Obsolete' | $T8 %]</th> |
32 | 72 |
<td>[% L.select_tag('filter.obsolete', [ [ '', LxERP.t8('Both') ], [ 0, LxERP.t8('Valid') ], [ 1 , LxERP.t8('Obsolete')]], default=filter.obsolete, style='width: 300px') %]</td> |
33 | 73 |
</tr> |
74 |
<tr> |
|
75 |
<th align="right">[% 'Has item type' | $T8 %]</th> |
|
76 |
<td> |
|
77 |
[%- FOREACH type = SELF.all_price_rule_item_types %] |
|
78 |
[%- L.checkbox_tag('filter.has_item_type[]', value=type.0, label=type.1, checked=filter.has_item_type_.${type.0}) %] |
|
79 |
[%- END %] |
|
80 |
</td> |
|
81 |
</tr> |
|
82 |
|
|
34 | 83 |
</table> |
35 | 84 |
|
36 | 85 |
[% L.hidden_tag('action', 'PriceRule/dispatch') %] |
Auch abrufbar als: Unified diff
PriceRule: Mehr Filteroptionen