Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 992a539d

Von Moritz Bunkus vor fast 18 Jahren hinzugefügt

  • ID 992a539da1a37c94c13a2f015fb470636d219331
  • Vorgänger 024df846
  • Nachfolger f300c481

Recommit von r1168 von skoehler: Kundennummer laesst sich nur einmal vergegen, nicht ueber Datenbankschema unique bwz. primary key

Unterschiede anzeigen:

SL/CT.pm
378 378
  $form->{taxzone_id} *= 1;
379 379
  $form->{creditlimit} = $form->parse_amount($myconfig, $form->{creditlimit});
380 380

  
381
  my ($query, $sth);
381
  my ($query, $sth, $f_id);
382 382

  
383 383
  if ($form->{id}) {
384

  
385
    $query = qq|SELECT id FROM customer
386
                WHERE customernumber = '$form->{customernumber}'|;
387
    $sth = $dbh->prepare($query);
388
    $sth->execute || $form->dberror($query);
389
    (${f_id}) = $sth->fetchrow_array;
390
    $sth->finish;
391
    if ((${f_id} ne $form->{id}) and (${f_id} ne "")) {
392

  
393
      $main::lxdebug->leave_sub();
394
      return 3;
395
    }
384 396
    $query = qq|DELETE FROM customertax
385 397
                WHERE customer_id = $form->{id}|;
386 398
    $dbh->do($query) || $form->dberror($query);
......
389 401
#                 WHERE trans_id = $form->{id} AND module = 'CT'|;
390 402
#     $dbh->do($query) || $form->dberror($query);
391 403
  } else {
404

  
392 405
    my $uid = rand() . time;
393 406

  
394 407
    $uid .= $form->{login};
395 408

  
396 409
    $uid = substr($uid, 2, 75);
410
    if (!$form->{customernumber} && $form->{business}) {
411
      $form->{customernumber} =
412
        $form->update_business($myconfig, $form->{business});
413
    }
414
    if (!$form->{customernumber}) {
415
      $form->{customernumber} =
416
        $form->update_defaults($myconfig, "customernumber");
417
    }
418

  
419
    $query = qq|SELECT c.id FROM customer c
420
                WHERE c.customernumber = '$form->{customernumber}'|;
421
    $sth = $dbh->prepare($query);
422
    $sth->execute || $form->dberror($query);
423
    (${f_id}) = $sth->fetchrow_array;
424
    $sth->finish;
425
    if (${f_id} ne "") {
426
      $main::lxdebug->leave_sub();
427
      return 3;
428
    }
397 429

  
398 430
    $query = qq|INSERT INTO customer (name)
399 431
                VALUES ('$uid')|;
......
406 438

  
407 439
    ($form->{id}) = $sth->fetchrow_array;
408 440
    $sth->finish;
409
    if (!$form->{customernumber} && $form->{business}) {
410
      $form->{customernumber} =
411
        $form->update_business($myconfig, $form->{business});
412
    }
413
    if (!$form->{customernumber}) {
414
      $form->{customernumber} =
415
        $form->update_defaults($myconfig, "customernumber");
416
    }
417

  
418 441
  }
419

  
420 442
  $query = qq|UPDATE customer SET
421 443
              customernumber = '$form->{customernumber}',
422 444
	      name = '$form->{name}',

Auch abrufbar als: Unified diff