From: Martin Helmling martin.helmling@octosoft.eu Date: Wed, 28 Dec 2016 15:38:42 +0000 (+0100) Subject: partpicker mit classification_id als filter erweitert X-Git-Tag: release-3.5.4~1744 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3a1b684b14006df369bac9f91a942fd3fd3e40dd;p=kivitendo-erp.git partpicker mit classification_id als filter erweitert --- diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 23b4eff1e..8eb0f834c 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -491,6 +491,7 @@ sub action_ajax_autocomplete { query => [ obsolete => 0, SL::DB::Manager::Part->type_filter($::form->{filter}{part_type}), + SL::DB::Manager::PartClassification->classification_filter($::form->{filter}{classification_id}), or => [ description => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, partnumber => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, @@ -792,7 +793,7 @@ sub init_models { partnumber => t8('Partnumber'), description => t8('Description'), }, - with_objects => [ qw(unit_obj) ], + with_objects => [ qw(unit_obj classification) ], ); } @@ -915,7 +916,7 @@ sub init_multi_items_models { SL::Controller::Helper::GetModels->new( controller => $_[0], model => 'Part', - with_objects => [ qw(unit_obj partsgroup) ], + with_objects => [ qw(unit_obj partsgroup classification) ], disable_plugin => 'paginated', source => $::form->{multi_items}, sorted => { diff --git a/SL/DB/Manager/PartClassification.pm b/SL/DB/Manager/PartClassification.pm index c00bea76a..9730f4482 100644 --- a/SL/DB/Manager/PartClassification.pm +++ b/SL/DB/Manager/PartClassification.pm @@ -9,6 +9,17 @@ sub object_class { 'SL::DB::PartClassification' } __PACKAGE__->make_manager_methods; +sub classification_filter { + my ($class, $classification, $prefix) = @_; + + return () unless $classification; + + $prefix //= ''; + + my @classifications = grep { $_ } listify($classification); + return ( $prefix . 'classification_id' => \@classifications ); +} + 1; diff --git a/SL/Presenter/Part.pm b/SL/Presenter/Part.pm index 3de612376..4bd45ca41 100644 --- a/SL/Presenter/Part.pm +++ b/SL/Presenter/Part.pm @@ -39,7 +39,7 @@ sub part_picker { my $ret = $self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) . - join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(part_type unit convertible_unit)) . + join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(part_type classification_id unit convertible_unit)) . $self->input_tag("", ref $value ? $value->displayable_name : '', id => "${id}_name", %params); $::request->layout->add_javascripts('autocomplete_part.js'); diff --git a/js/autocomplete_part.js b/js/autocomplete_part.js index 57f90c7a7..cbce72cea 100644 --- a/js/autocomplete_part.js +++ b/js/autocomplete_part.js @@ -28,10 +28,11 @@ namespace('kivi', function(k){ UNDEFINED: CLASSES.UNDEFINED } var real_id = $real.attr('id'); - var $dummy = $('#' + real_id + '_name'); - var $part_type = $('#' + real_id + '_part_type'); - var $unit = $('#' + real_id + '_unit'); - var $convertible_unit = $('#' + real_id + '_convertible_unit'); + var $dummy = $('#' + real_id + '_name'); + var $part_type = $('#' + real_id + '_part_type'); + var $classification_id = $('#' + real_id + '_classification_id'); + var $unit = $('#' + real_id + '_unit'); + var $convertible_unit = $('#' + real_id + '_convertible_unit'); var state = STATES.PICKED; var last_real = $real.val(); var last_dummy = $dummy.val(); @@ -66,6 +67,9 @@ namespace('kivi', function(k){ if ($part_type && $part_type.val()) data['filter.part_type'] = $part_type.val().split(','); + if ($classification_id && $classification_id.val()) + data['filter.classification_id'] = $classification_id.val().split(','); + if ($unit && $unit.val()) data['filter.unit'] = $unit.val().split(','); @@ -242,11 +246,12 @@ namespace('kivi', function(k){ popup_button.click(open_dialog); var pp = { - real: function() { return $real }, - dummy: function() { return $dummy }, - part_type: function() { return $part_type }, - unit: function() { return $unit }, - convertible_unit: function() { return $convertible_unit }, + real: function() { return $real }, + dummy: function() { return $dummy }, + part_type: function() { return $part_type }, + classification_id: function() { return $classification_id }, + unit: function() { return $unit }, + convertible_unit: function() { return $convertible_unit }, update_results: update_results, result_timer: result_timer, set_item: set_item, @@ -258,6 +263,7 @@ namespace('kivi', function(k){ set_item({ id: $(this).children('input.part_picker_id').val(), name: $(this).children('input.part_picker_description').val(), + classification_id: $(this).children('input.part_picker_classification_id').val(), unit: $(this).children('input.part_picker_unit').val(), partnumber: $(this).children('input.part_picker_partnumber').val(), description: $(this).children('input.part_picker_description').val(), diff --git a/templates/webpages/part/_part_picker_result.html b/templates/webpages/part/_part_picker_result.html index d283e6cac..c150a0822 100644 --- a/templates/webpages/part/_part_picker_result.html +++ b/templates/webpages/part/_part_picker_result.html @@ -1,6 +1,7 @@ [%- USE T8 %] [%- USE HTML %] [%- USE L %] +[%- USE P %] [%- USE LxERP %] [%# L.dump(SELF.parts) %] @@ -15,6 +16,7 @@ [% part.description | html %]
[% 'Sellprice' | $T8 %]: [% part.sellprice_as_number | html %] + [% P.typeclass_abbreviation(part) %] [%- END %] diff --git a/templates/webpages/part/test_page.html b/templates/webpages/part/test_page.html index b8fa6f53a..64d956c2f 100644 --- a/templates/webpages/part/test_page.html +++ b/templates/webpages/part/test_page.html @@ -13,6 +13,16 @@ Nur Erzeugnisse:
[% L.part_picker('part_id4', undef, part_type='assembly') %]
Waren und Dienstleistungen:
[% L.part_picker('part_id5', undef, part_type='part,service') %]
+Artikel-Klassifizierung: Einkauf
+[% L.part_picker('part_id10', undef, classification_id='1') %]
+Artikel-Klassifizierung: Verkauf
+[% L.part_picker('part_id11', undef, classification_id='2') %]
+Artikel-Klassifizierung: Handelsware
+[% L.part_picker('part_id12', undef, classification_id='3') %]
+Artikel-Klassifizierung: Produktion
+[% L.part_picker('part_id13', undef, classification_id='4') %]
+Artikel-Klassifizierung: Eink.,Verk.,Prod.
+[% L.part_picker('part_id14', undef, classification_id='1,2,4') %]
Pre-filled:
[% L.part_picker('part_id6', pre_filled_part) %]
Convertible unit 'Std': (only select parts with unit Tag/Std/Min)