]> wagnertech.de Git - mfinanz.git/blobdiff - SL/OE.pm
oe.pl: Schnellsuche analog zu all:substr:multi::ilike
[mfinanz.git] / SL / OE.pm
index 1e6a47c6207b4f422663360b5d014db89195eecf..1c812e24f57548c934478f9bd7f80893fa84caf3 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -50,6 +50,7 @@ use SL::DBUtils;
 use SL::HTML::Restrict;
 use SL::IC;
 use SL::TransNumber;
+use Text::ParseWords;
 
 use strict;
 
@@ -285,6 +286,18 @@ SQL
     push @values, conv_date($form->{expected_billing_date_to});
   }
 
+  if ($form->{all}) {
+    my @tokens = parse_line('\s+', 0, $form->{all});
+    # ordnumber quonumber customer.name vendor.name transaction_description
+    $query .= qq| AND (
+      o.ordnumber ILIKE ? OR
+      o.quonumber ILIKE ? OR
+      ct.name     ILIKE ? OR
+      o.transaction_description ILIKE ?
+    )| for @tokens;
+    push @values, ("%$_%")x4 for @tokens;
+  }
+
   my ($cvar_where, @cvar_values) = CVar->build_filter_query('module'         => 'CT',
                                                             'trans_id_field' => 'ct.id',
                                                             'filter'         => $form,
@@ -653,7 +666,10 @@ SQL
     $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, ($form->{vc} eq 'customer') ? 'buy' : 'sell');
   }
 
-  $form->{exchangerate} = $exchangerate || $form->parse_amount($myconfig, $form->{exchangerate});
+  # from inputfield (exchangerate) or hidden (forex)
+  my $exchangerate_from_form = $form->{forex} || $form->parse_amount($myconfig, $form->{exchangerate});
+
+  $form->{exchangerate} = $exchangerate || $exchangerate_from_form;
 
   my $quotation = $form->{type} =~ /_order$/ ? 'f' : 't';
 
@@ -693,6 +709,8 @@ SQL
              conv_i($form->{id}));
   do_query($form, $dbh, $query, @values);
 
+  $form->new_lastmtime('oe');
+
   $form->{ordtotal} = $amount;
 
   $form->{name} = $form->{ $form->{vc} };