X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FOE.pm;h=149a6cf1a21ac4ffc00e138a9d50df41c5d38f41;hb=c7241bf7c547d63999898dee7b5dd486e4d122d3;hp=1c812e24f57548c934478f9bd7f80893fa84caf3;hpb=aa4fda0ec21c0715f1d8af27efdd900af3dd4915;p=kivitendo-erp.git diff --git a/SL/OE.pm b/SL/OE.pm index 1c812e24f..149a6cf1a 100644 --- 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 SL::Util qw(trim); use Text::ParseWords; use strict; @@ -172,12 +173,12 @@ SQL } elsif ($form->{$vc}) { $query .= " AND ct.name ILIKE ?"; - push(@values, '%' . $form->{$vc} . '%'); + push(@values, '%' . trim($form->{$vc}) . '%'); } if ($form->{"cp_name"}) { $query .= " AND (cp.cp_name ILIKE ? OR cp.cp_givenname ILIKE ?)"; - push(@values, ('%' . $form->{"cp_name"} . '%')x2); + push(@values, ('%' . trim($form->{"cp_name"}) . '%')x2); } if (!$main::auth->assert('sales_all_edit', 1)) { @@ -208,12 +209,12 @@ SQL if ($form->{$ordnumber}) { $query .= qq| AND o.$ordnumber ILIKE ?|; - push(@values, '%' . $form->{$ordnumber} . '%'); + push(@values, '%' . trim($form->{$ordnumber}) . '%'); } if ($form->{cusordnumber}) { $query .= qq| AND o.cusordnumber ILIKE ?|; - push(@values, '%' . $form->{cusordnumber} . '%'); + push(@values, '%' . trim($form->{cusordnumber}) . '%'); } if($form->{transdatefrom}) { @@ -248,7 +249,7 @@ SQL if ($form->{shippingpoint}) { $query .= qq| AND o.shippingpoint ILIKE ?|; - push(@values, '%' . $form->{shippingpoint} . '%'); + push(@values, '%' . trim($form->{shippingpoint}) . '%'); } if ($form->{taxzone_id} ne '') { # taxzone_id could be 0 @@ -258,7 +259,7 @@ SQL if ($form->{transaction_description}) { $query .= qq| AND o.transaction_description ILIKE ?|; - push(@values, '%' . $form->{transaction_description} . '%'); + push(@values, '%' . trim($form->{transaction_description}) . '%'); } if ($form->{periodic_invoices_active} ne $form->{periodic_invoices_inactive}) { @@ -273,7 +274,7 @@ SQL if (($form->{order_probability_value} || '') ne '') { my $op = $form->{order_probability_value} eq 'le' ? '<=' : '>='; $query .= qq| AND (o.order_probability ${op} ?)|; - push @values, $form->{order_probability_value}; + push @values, trim($form->{order_probability_value}); } if ($form->{expected_billing_date_from}) { @@ -420,6 +421,11 @@ sub save { $form->{$number_field} ||= $trans_number->create_unique; # set $form->{ordnumber} or $form->{quonumber} if ($form->{id}) { + $query = qq|DELETE FROM custom_variables + WHERE (config_id IN (SELECT id FROM custom_variable_configs WHERE (module = 'ShipTo'))) + AND (trans_id IN (SELECT shipto_id FROM shipto WHERE (module = 'OE') AND (trans_id = ?)))|; + do_query($form, $dbh, $query, $form->{id}); + $query = qq|DELETE FROM shipto | . qq|WHERE trans_id = ? AND module = 'OE'|; do_query($form, $dbh, $query, $form->{id}); @@ -1010,6 +1016,15 @@ sub retrieve { map { $form->{$_} = $ref->{$_} } keys %$ref; $sth->finish; + if ($form->{shipto_id}) { + my $cvars = CVar->get_custom_variables( + dbh => $dbh, + module => 'ShipTo', + trans_id => $form->{shipto_id}, + ); + $form->{"shiptocvar_$_->{name}"} = $_->{value} for @{ $cvars }; + } + # get printed, emailed and queued $query = qq|SELECT s.printed, s.emailed, s.spoolfile, s.formname FROM status s WHERE s.trans_id = ?|; $sth = prepare_execute_query($form, $dbh, $query, $form->{id});