Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 15682dc4

Von Moritz Bunkus vor fast 18 Jahren hinzugefügt

  • ID 15682dc47316fcc2deab66730045cd38afec001f
  • Vorgänger f27a8a8f
  • Nachfolger 8e206587

Drop-Down-Auswahlboxen für Ansprechpartner und Lieferadresse bei jedem Maskenaufbau aus der Datenbank aufbauen. Für den HTML-Code wird jetzt das CGI-Modul verwendet.

Unterschiede anzeigen:

SL/Form.pm
1395 1395
  $main::lxdebug->leave_sub();
1396 1396
}
1397 1397

  
1398
# get other contact for transaction and form - html/tex
1399
sub get_contact {
1398
# get contacts for id, if no contact return {"","","","",""}
1399
sub get_contacts {
1400 1400
  $main::lxdebug->enter_sub();
1401 1401

  
1402
  my ($self, $dbh, $id) = @_;
1402
  my ($self, $dbh, $id, $key) = @_;
1403 1403

  
1404
  my $query = qq|SELECT c.*
1405
              FROM contacts c
1406
              WHERE cp_id=$id|;
1407
  $sth = $dbh->prepare($query);
1408
  $sth->execute || $self->dberror($query);
1404
  $key = "all_contacts" unless ($key);
1405
  $self->{$key} = [];
1409 1406

  
1410
  $ref = $sth->fetchrow_hashref(NAME_lc);
1407
  my $query =
1408
    qq|SELECT c.cp_id, c.cp_cv_id, c.cp_name, c.cp_givenname, c.cp_abteilung | .
1409
    qq|FROM contacts c | .
1410
    qq|WHERE cp_cv_id = ? | .
1411
    qq|ORDER BY lower(c.cp_name)|;
1412
  my $sth = $dbh->prepare($query);
1413
  $sth->execute($id) || $self->dberror($query . " ($id)");
1411 1414

  
1412
  push @{ $self->{$_} }, $ref;
1415
  my $i = 0;
1416
  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
1417
    push @{ $self->{$key} }, $ref;
1418
    $i++;
1419
  }
1413 1420

  
1421
  if ($i == 0) {
1422
    push @{ $self->{$key} }, { { "", "", "", "", "", "" } };
1423
  }
1414 1424
  $sth->finish;
1415 1425
  $main::lxdebug->leave_sub();
1416 1426
}
1417 1427

  
1418
# get contacts for id, if no contact return {"","","","",""}
1419
sub get_contacts {
1428
sub get_lists {
1420 1429
  $main::lxdebug->enter_sub();
1421 1430

  
1422
  my ($self, $dbh, $id) = @_;
1431
  my $self = shift;
1432
  my %params = @_;
1433

  
1434
  my $dbh = $self->dbconnect(\%main::myconfig);
1435
  my ($sth, $query, $ref);
1423 1436

  
1424
  my $query = qq|SELECT c.cp_id, c.cp_cv_id, c.cp_name, c.cp_givenname, c.cp_abteilung
1425
              FROM contacts c
1426
              WHERE cp_cv_id=$id|;
1427
  my $sth = $dbh->prepare($query);
1428
  $sth->execute || $self->dberror($query);
1437
  my $vc = $self->{"vc"} eq "customer" ? "customer" : "vendor";
1438
  my $vc_id = $self->{"${vc}_id"};
1429 1439

  
1430
  my $i = 0;
1431
  while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
1432
    push @{ $self->{all_contacts} }, $ref;
1433
    $i++;
1440
  if ($params{"contacts"}) {
1441
    $self->get_contacts($dbh, $vc_id, $params{"contacts"});
1434 1442
  }
1435 1443

  
1436
  if ($i == 0) {
1437
    push @{ $self->{all_contacts} }, { { "", "", "", "", "", "" } };
1444
  if ($params{"shipto"}) {
1445
    # get shipping addresses
1446
    $query =
1447
      qq|SELECT s.shipto_id,s.shiptoname,s.shiptodepartment_1 | .
1448
      qq|FROM shipto s | .
1449
      qq|WHERE s.trans_id = ?|;
1450
    $sth = $dbh->prepare($query);
1451
    $sth->execute($vc_id) || $self->dberror($query . " ($vc_id)");
1452

  
1453
    $self->{$params{"shipto"}} = [];
1454
    while ($ref = $sth->fetchrow_hashref(NAME_lc)) {
1455
      push(@{ $self->{$params{"shipto"}} }, $ref);
1456
    }
1457
    $sth->finish;
1438 1458
  }
1439
  $sth->finish;
1459

  
1460
  $dbh->disconnect();
1461

  
1440 1462
  $main::lxdebug->leave_sub();
1441 1463
}
1442 1464

  

Auch abrufbar als: Unified diff