PartPicker nach Kunden- und Lieferanten-Artikel-Nr. suchen und filtern können
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 19 Jul 2019 12:20:38 +0000 (14:20 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 7 Aug 2019 13:37:09 +0000 (15:37 +0200)
SL/Controller/Part.pm
SL/Presenter/Part.pm
js/kivi.Part.js
templates/webpages/part/_multi_items_dialog.html
templates/webpages/part/part_picker_search.html
templates/webpages/part/test_page.html

index 2b5ac56..6092f29 100644 (file)
@@ -399,8 +399,15 @@ sub action_add_assembly_item {
 }
 
 sub action_show_multi_items_dialog {
+  my ($self) = @_;
+
+  my $search_term = $self->models->filtered->laundered->{all_substr_multi__ilike};
+  $search_term  ||= $self->models->filtered->laundered->{all_with_makemodel_substr_multi__ilike};
+  $search_term  ||= $self->models->filtered->laundered->{all_with_customer_partnumber_substr_multi__ilike};
+
   $_[0]->render('part/_multi_items_dialog', { layout => 0 },
-    all_partsgroups => SL::DB::Manager::PartsGroup->get_all
+                all_partsgroups => SL::DB::Manager::PartsGroup->get_all,
+                search_term     => $search_term
   );
 }
 
@@ -562,7 +569,9 @@ sub action_ajax_autocomplete {
   # since we need a second get models instance with different filters for that,
   # we only modify the original filter temporarily in place
   if ($::form->{prefer_exact}) {
-    local $::form->{filter}{'all::ilike'} = delete local $::form->{filter}{'all:substr:multi::ilike'};
+    local $::form->{filter}{'all::ilike'}                          = delete local $::form->{filter}{'all:substr:multi::ilike'};
+    local $::form->{filter}{'all_with_makemodel::ilike'}           = delete local $::form->{filter}{'all_with_makemodel:substr:multi::ilike'};
+    local $::form->{filter}{'all_with_customer_partnumber::ilike'} = delete local $::form->{filter}{'all_with_customer_partnumber:substr:multi::ilike'};
 
     my $exact_models = SL::Controller::Helper::GetModels->new(
       controller   => $self,
@@ -598,7 +607,13 @@ sub action_test_page {
 }
 
 sub action_part_picker_search {
-  $_[0]->render('part/part_picker_search', { layout => 0 });
+  my ($self) = @_;
+
+  my $search_term = $self->models->filtered->laundered->{all_substr_multi__ilike};
+  $search_term  ||= $self->models->filtered->laundered->{all_with_makemodel_substr_multi__ilike};
+  $search_term  ||= $self->models->filtered->laundered->{all_with_customer_partnumber_substr_multi__ilike};
+
+  $_[0]->render('part/part_picker_search', { layout => 0 }, search_term => $search_term);
 }
 
 sub action_part_picker_result {
index 145d912..bc5ee8a 100644 (file)
@@ -241,6 +241,10 @@ C<h,min>.
 If C<%params> contains C<convertible_unit> only parts with a unit
 that's convertible to unit will be used for autocompletion.
 
+If C<%params> contains C<with_makemodel> or C<with_customer_partnumber> even
+parts will be used for autocompletion which partnumber is a vendor partnumber
+(makemodel) or a customer partnumber.
+
 Obsolete parts will by default not be displayed for selection. However they are
 accepted as default values and can persist during updates. As with other
 selectors though, they are not selectable once overridden.
index e8a721d..4f813bb 100644 (file)
@@ -334,7 +334,6 @@ namespace('kivi.Part', function(ns) {
     },
     ajax_data: function(term) {
       var data = {
-        'filter.all:substr:multi::ilike': term,
         current:  this.$real.val(),
       };
 
@@ -356,6 +355,15 @@ namespace('kivi.Part', function(ns) {
       if (this.o.convertible_unit)
         data['filter.unit_obj.convertible_to'] = this.o.convertible_unit;
 
+      var filter_name = 'all';
+      if (this.o.with_makemodel) {
+        filter_name = 'all_with_makemodel';
+      }
+      if (this.o.with_customer_partnumber) {
+        filter_name = 'all_with_customer_partnumber';
+      }
+      data['filter.' + filter_name + ':substr:multi::ilike'] = term;
+
       return data;
     },
     set_item: function(item) {
index dfaeb94..49916e0 100644 (file)
@@ -5,7 +5,7 @@
 <table id='multi_items_filter_table'>
   <tr>
     <th>[%- LxERP.t8("Description") %]/[%- LxERP.t8("Partnumber") %]:</th>
-    <td>[%- L.input_tag('multi_items_filter', SELF.multi_items_models.filtered.laundered.all_substr_multi__ilike) %]</td>
+    <td>[%- L.input_tag('multi_items_filter', search_term) %]</td>
     <th>[%- LxERP.t8("Partsgroup") %]</th>
     <td>[%- L.select_tag('multi_items.filter.partsgroup_id', all_partsgroups, title_key='partsgroup', value_key='id', with_empty=1) %]</td>
   <tr>
index aa50c7d..49b08c4 100644 (file)
@@ -5,7 +5,7 @@
 
 <div style='overflow:hidden'>
 
-[% LxERP.t8("Filter") %]: [% L.input_tag('part_picker_filter', SELF.models.filtered.laundered.all_substr_multi__ilike, class='part_picker_filter') %]
+[% LxERP.t8("Filter") %]: [% L.input_tag('part_picker_filter', search_term, class='part_picker_filter') %]
 
 <div class='float-right'>
   [% L.checkbox_tag('no_paginate', checked=FORM.no_paginate, id='no_paginate', for_submit=1, label=LxERP.t8('All as list')) %]
index 02d54d9..3918ee6 100644 (file)
@@ -32,14 +32,23 @@ Artikel-Status: Ungültig<br>
 [% P.part.picker('part_id17', undef, status="obsolete") %]<br>
 Artikel-Status: Alle<br>
 [% P.part.picker('part_id18', undef, status="all") %]<br>
-
+<br>
 Pre-filled:<br>
 [% P.part.picker('part_id6', pre_filled_part) %]<br>
 Convertible unit 'Std': (only select parts with unit Tag/Std/Min)<br>
 [% P.part.picker('part_id7', undef, convertible_unit='Std') %]<br>
-
+<br>
 With multi select popup<br>
 [% P.part.picker('part_id8', undef, multiple=1) %]<br>
+With multi select popup (only obsolete)<br>
+[% P.part.picker('part_id8', undef, multiple=1, status='obsolete') %]<br>
+<br>
+All parts including make models of all vendors: <br>
+[% P.part.picker('part_id', undef, with_makemodel=1) %]<br>
+All parts including make models of all vendors with multi select popup: <br>
+[% P.part.picker('part_id', undef, with_makemodel=1, multiple=1) %]<br>
+All parts including customer partnumbers of all customers: <br>
+[% P.part.picker('part_id', undef, with_customer_partnumber=1) %]<br>
 
 <h2>Styling</h2>