From 7c3117b50d46f04f589aae322525f0797c4146e9 Mon Sep 17 00:00:00 2001 From: Thomas Kasulke Date: Wed, 4 Apr 2007 10:36:32 +0000 Subject: [PATCH] Abfangen von doppelten Lieferantenadressen (beim Eintragen) --- SL/Form.pm | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index aebac40dc..5e0b9fd53 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1344,16 +1344,36 @@ sub add_shipto { WHERE shipto_id = $self->{shipto_id}|; $dbh->do($query) || $self->dberror($query); } else { - my $query = - qq|INSERT INTO shipto (trans_id, shiptoname, shiptodepartment_1, shiptodepartment_2, shiptostreet, + my $query = qq|SELECT * FROM shipto + WHERE shiptoname = '$self->{shiptoname}' AND + shiptodepartment_1 = '$self->{shiptodepartment_1}' AND + shiptodepartment_2 = '$self->{shiptodepartment_2}' AND + shiptostreet = '$self->{shiptostreet}' AND + shiptozipcode = '$self->{shiptozipcode}' AND + shiptocity = '$self->{shiptocity}' AND + shiptocountry = '$self->{shiptocountry}' AND + shiptocontact = '$self->{shiptocontact}' AND + shiptophone = '$self->{shiptophone}' AND + shiptofax = '$self->{shiptofax}' AND + shiptoemail = '$self->{shiptoemail}' + | ; + my $sth = $dbh->prepare($query); + $sth->execute() || $self->dberror($query); + my $insert_check = $sth->fetch(); + $sth->finish(); + if(!$insert_check){ + $query = + qq|INSERT INTO shipto (trans_id, shiptoname, shiptodepartment_1, + shiptodepartment_2, shiptostreet, shiptozipcode, shiptocity, shiptocountry, shiptocontact, shiptophone, shiptofax, shiptoemail, module) VALUES ($id, '$self->{shiptoname}', '$self->{shiptodepartment_1}', '$self->{shiptodepartment_2}', '$self->{shiptostreet}', '$self->{shiptozipcode}', '$self->{shiptocity}', '$self->{shiptocountry}', '$self->{shiptocontact}', '$self->{shiptophone}', '$self->{shiptofax}', - '$self->{shiptoemail}', '$module')|; - $dbh->do($query) || $self->dberror($query); + '$self->{shiptoemail}', '$module')|; + $dbh->do($query) || $self->dberror($query); + } } } ##/LINET -- 2.20.1