Belege verknüpfen: auch nach Belegnummer filtern können
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 8 Oct 2021 11:42:23 +0000 (13:42 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 8 Oct 2021 11:42:23 +0000 (13:42 +0200)
SL/Controller/RecordLinks.pm
templates/webpages/record_links/add_filter.html

index eec3ce2..3e8f028 100644 (file)
@@ -132,6 +132,7 @@ sub action_ajax_add_list {
   my $project_id  = "${project}_id";
   my $description = $self->link_type_desc->{description};
   my $filter      = $self->link_type_desc->{filter};
+  my $number      = $self->link_type_desc->{number};
 
   my @where = $filter && $manager->can($filter) ? $manager->$filter($self->link_type) : ();
   push @where, ("${vc}.${vc}number"     => { ilike => like($::form->{vc_number}) })               if $::form->{vc_number};
@@ -139,6 +140,16 @@ sub action_ajax_add_list {
   push @where, ($description            => { ilike => like($::form->{transaction_description}) }) if $::form->{transaction_description};
   push @where, ($project_id             => $::form->{globalproject_id})                           if $::form->{globalproject_id} && $manager->can($project_id);
 
+  if ($::form->{number}) {
+    my $class    = 'SL::DB::' . $self->link_type_desc->{model};
+    my $col_type = ref $class->meta->column($number);
+    if ($col_type =~ /^Rose::DB::Object::Metadata::Column::(?:Integer|Serial)$/) {
+      push @where, ($number => $::form->{number});
+    } elsif ($col_type =~ /^Rose::DB::Object::Metadata::Column::Text$/) {
+      push @where, ($number => { ilike => like($::form->{number}) });
+    }
+  }
+
   my @with_objects = ($vc);
   push @with_objects, $project if $manager->can($project_id);
 
index 04346b5..d9b0209 100644 (file)
                        style=style) %]</td>
   </tr>
 
+  <tr>
+   <td>[%- LxERP.t8("Record number") %]:</td>
+   <td>[% L.input_tag('number', '', style=style) %]</td>
+  </tr>
+
   <tr>
    <td>[%- LxERP.t8("Customer/Vendor Number") %]:</td>
    <td>[% L.input_tag('vc_number', is_sales ? SELF.object.customer.customernumber : SELF.object.vendor.vendornumber, style=style) %]</td>