X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCT.pm;h=ded457738be4aa529257ef44a9a56ebcd852fd31;hb=9af3ce1ca10555dff25e4762d2eb1e7fa0c1e877;hp=cdf274b712dce558b15523c9e37ff2eeb8d9a0e8;hpb=3624b119556731da41e4ad395491ebb067f26565;p=kivitendo-erp.git diff --git a/SL/CT.pm b/SL/CT.pm index cdf274b71..ded457738 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -75,6 +75,7 @@ sub search { "zipcode" => "ct.zipcode", "city" => "ct.city", "country" => "ct.country", + "gln" => "ct.gln", "discount" => "ct.discount", "insertdate" => "ct.itime", "salesman" => "e.name", @@ -117,6 +118,28 @@ sub search { push @values, '%' . $form->{cp_name} . '%'; } + if ($form->{addr_street}) { + $where .= qq| AND ((ct.street ILIKE ?) | . + qq| OR | . + qq| (ct.id IN ( | . + qq| SELECT sc.trans_id FROM shipto sc | . + qq| WHERE (sc.module = 'CT') | . + qq| AND (sc.shiptostreet ILIKE ?) | . + qq| ))) |; + push @values, ('%' . $form->{addr_street} . '%') x 2; + } + + if ($form->{addr_zipcode}) { + $where .= qq| AND ((ct.zipcode ILIKE ?) | . + qq| OR | . + qq| (ct.id IN ( | . + qq| SELECT sc.trans_id FROM shipto sc | . + qq| WHERE (sc.module = 'CT') | . + qq| AND (sc.shiptozipcode ILIKE ?) | . + qq| ))) |; + push @values, ('%' . $form->{addr_zipcode} . '%') x 2; + } + if ($form->{addr_city}) { $where .= " AND ((lower(ct.city) LIKE lower(?)) OR @@ -143,6 +166,19 @@ sub search { push @values, ('%' . $form->{addr_country} . '%') x 2; } + if ($form->{addr_gln}) { + $where .= " AND ((lower(ct.gln) LIKE lower(?)) + OR + (ct.id IN ( + SELECT so.trans_id + FROM shipto so + WHERE (so.module = 'CT') + AND (lower(so.shiptogln) LIKE lower(?)) + )) + )"; + push @values, ('%' . $form->{addr_gln} . '%') x 2; + } + if ( $form->{status} eq 'orphaned' ) { $where .= qq| AND ct.id NOT IN | . @@ -204,16 +240,6 @@ sub search { push @values, @cvar_values; } - if ($form->{addr_street}) { - $where .= qq| AND (ct.street ILIKE ?)|; - push @values, '%' . $form->{addr_street} . '%'; - } - - if ($form->{addr_zipcode}) { - $where .= qq| AND (ct.zipcode ILIKE ?)|; - push @values, $form->{addr_zipcode} . '%'; - } - my $pg_select = $form->{l_pricegroup} ? qq|, pg.pricegroup as pricegroup | : ''; my $pg_join = $form->{l_pricegroup} ? qq|LEFT JOIN pricegroup pg ON (ct.klass = pg.id) | : ''; my $query =