From becda06d038cfbcc3b69fbdfa4b89447626e7cab Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 17 Jan 2011 12:37:10 +0100 Subject: [PATCH] =?utf8?q?Beim=20Anlegen=20von=20Kunden-/Lieferantennummer?= =?utf8?q?n=20L=C3=BCcken=20im=20Nummernkreis=20richtig=20behandeln?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fix für Bug 1553. --- SL/CT.pm | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/SL/CT.pm b/SL/CT.pm index 3c17ca535..58a460039 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -44,6 +44,7 @@ use SL::CVar; use SL::DBUtils; use SL::FU; use SL::Notes; +use SL::TransNumber; use strict; @@ -261,21 +262,12 @@ sub save_customer { } } else { - if (!$form->{customernumber} && $form->{business}) { - $form->{customernumber} = - $form->update_business($myconfig, $form->{business}, $dbh); - } - if (!$form->{customernumber}) { - $form->{customernumber} = - $form->update_defaults($myconfig, "customernumber", $dbh); - } - - $query = qq|SELECT c.id FROM customer c WHERE c.customernumber = ?|; - ($f_id) = selectrow_query($form, $dbh, $query, $form->{customernumber}); - if ($f_id ne "") { - $main::lxdebug->leave_sub(); - return 3; - } + my $customernumber = SL::TransNumber->new(type => 'customer', + dbh => $dbh, + number => $form->{customernumber}, + business_id => $form->{business}, + save => 1); + $form->{customernumber} = $customernumber->create_unique unless $customernumber->is_unique; $query = qq|SELECT nextval('id')|; ($form->{id}) = selectrow_query($form, $dbh, $query); @@ -488,9 +480,11 @@ sub save_vendor { $query = qq|INSERT INTO vendor (id, name) VALUES (?, '')|; do_query($form, $dbh, $query, $form->{id}); - if ( !$form->{vendornumber} ) { - $form->{vendornumber} = $form->update_defaults( $myconfig, "vendornumber", $dbh ); - } + my $vendornumber = SL::TransNumber->new(type => 'vendor', + dbh => $dbh, + number => $form->{vendornumber}, + save => 1); + $form->{vendornumber} = $vendornumber->create_unique unless $vendornumber->is_unique; } $query = -- 2.20.1