From: Thomas Kasulke Date: Wed, 4 Apr 2007 10:36:32 +0000 (+0000) Subject: Abfangen von doppelten Lieferantenadressen (beim Eintragen) X-Git-Tag: release-2.4.3^2~525 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/commitdiff_plain/7c3117b50d46f04f589aae322525f0797c4146e9?ds=inline Abfangen von doppelten Lieferantenadressen (beim Eintragen) --- 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