From: Sven Schöling Date: Thu, 11 Sep 2014 16:14:41 +0000 (+0200) Subject: PriceRule: Filter nach Ware implementiert X-Git-Tag: release-3.2.0beta~145 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=78df36d13721e785efbfcc6c17e400bb87cdc6e7;p=kivitendo-erp.git PriceRule: Filter nach Ware implementiert --- diff --git a/SL/Controller/PriceRule.pm b/SL/Controller/PriceRule.pm index 3f5983264..a90f68e22 100644 --- a/SL/Controller/PriceRule.pm +++ b/SL/Controller/PriceRule.pm @@ -202,7 +202,7 @@ sub all_price_rule_item_types { } sub add_javascripts { - $::request->{layout}->add_javascripts(qw(kivi.PriceRule.js autocomplete_customer.js autocomplete_vendor.js)); + $::request->{layout}->add_javascripts(qw(kivi.PriceRule.js autocomplete_customer.js autocomplete_vendor.js autocomplete_part.js)); } sub init_price_rule { diff --git a/SL/DB/Manager/PriceRuleItem.pm b/SL/DB/Manager/PriceRuleItem.pm index 6842d5ba1..60e5d8248 100644 --- a/SL/DB/Manager/PriceRuleItem.pm +++ b/SL/DB/Manager/PriceRuleItem.pm @@ -15,7 +15,7 @@ __PACKAGE__->make_manager_methods; use SL::Locale::String qw(t8); my @types = qw( - customer vendor business partsgroup qty reqdate pricegroup + part customer vendor business partsgroup qty reqdate pricegroup ); my %ops = ( @@ -28,6 +28,7 @@ my %types = ( 'vendor' => { description => t8('Vendor'), customer => 0, vendor => 1, data_type => 'int', data => sub { $_[0]->vendor->id }, }, 'business' => { description => t8('Type of Business'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[0]->customervendor->business_id }, exclude_nulls => 1 }, 'reqdate' => { description => t8('Reqdate'), customer => 1, vendor => 1, data_type => 'date', data => sub { $_[0]->reqdate }, ops => 'date' }, + 'part' => { description => t8('Part'), customer => 1, vendor => 0, data_type => 'int', data => sub { $_[1]->part->id }, }, 'pricegroup' => { description => t8('Pricegroup'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[1]->pricegroup_id }, exclude_nulls => 1 }, 'partsgroup' => { description => t8('Group'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[1]->part->partsgroup_id }, exclude_nulls => 1 }, 'qty' => { description => t8('Qty'), customer => 1, vendor => 1, data_type => 'num', data => sub { $_[1]->qty }, ops => 'num' }, diff --git a/SL/DB/PriceRuleItem.pm b/SL/DB/PriceRuleItem.pm index 91870c17e..c53d9b7d0 100644 --- a/SL/DB/PriceRuleItem.pm +++ b/SL/DB/PriceRuleItem.pm @@ -37,6 +37,9 @@ sub match_business { sub match_partsgroup { $_[0]->value_int == $_[1]{record_item}->parts->partsgroup_id; } +sub match_part { + $_[0]->value_int == $_[1]{record_item}->parts_id; +} sub match_qty { if ($_[0]->op eq 'eq') { return $_[0]->value_num == $_[1]{record_item}->qty @@ -59,6 +62,10 @@ sub match_pricegroup { $_[0]->value_int == $_[1]{record_item}->customervendor->pricegroup_id; } +sub part { + require SL::DB::Part; + SL::DB::Part->load_cached($_[0]->value_int); +} sub customer { require SL::DB::Customer; SL::DB::Customer->load_cached($_[0]->value_int); @@ -95,6 +102,7 @@ sub full_description { : $type eq 'business' ? t8('Type of Business') . ' ' . $self->business->displayable_name : $type eq 'partsgroup' ? t8('Group') . ' ' . $self->partsgroup->displayable_name : $type eq 'pricegroup' ? t8('Pricegroup') . ' ' . $self->pricegroup->displayable_name + : $type eq 'part' ? t8('Part') . ' ' . $self->part->long_description : $type eq 'qty' ? ( $op eq 'eq' ? t8('Qty equals #1', $self->value_num_as_number) : $op eq 'lt' ? t8('Qty less than #1', $self->value_num_as_number) diff --git a/templates/webpages/price_rule/item.html b/templates/webpages/price_rule/item.html index e3734e948..1bff4b9b9 100644 --- a/templates/webpages/price_rule/item.html +++ b/templates/webpages/price_rule/item.html @@ -17,6 +17,8 @@ [% L.hidden_tag('price_rule.items[+].id', item.id) %] [% L.hidden_tag('price_rule.items[].type', item.type) %] [%- SWITCH item.type %] + [% CASE 'part' %] + [% 'Part' | $T8 %] [% 'is' | $T8 %] [% L.part_picker('price_rule.items[].value_int', item.part) %] [% CASE 'customer' %] [% 'Customer' | $T8 %] [% 'is' | $T8 %] [% L.customer_vendor_picker('price_rule.items[].value_int', item.customer, type='customer') %] [% CASE 'vendor' %]