Revision 0aa294a4
Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt
SL/CT.pm | ||
---|---|---|
368 | 368 |
); |
369 | 369 |
do_query( $form, $dbh, $query, @values ); |
370 | 370 |
|
371 |
$query = undef; |
|
372 |
my @columns = qw(cp_title cp_givenname cp_name cp_email cp_phone1 cp_phone2 cp_abteilung cp_fax |
|
373 |
cp_mobile1 cp_mobile2 cp_satphone cp_satfax cp_project cp_privatphone cp_privatemail cp_birthday cp_gender |
|
374 |
cp_street cp_zipcode cp_city); |
|
375 |
@values = map { $_ eq 'cp_gender' ? ($form->{$_} eq 'f' ? 'f' : 'm') : $form->{$_} } @columns; |
|
376 |
|
|
377 |
if ( $form->{cp_id} ) { |
|
378 |
$query = qq|UPDATE contacts SET | . join(', ', map { "${_} = ?" } @columns) . qq| WHERE cp_id = ?|; |
|
379 |
push @values, $form->{cp_id}; |
|
380 |
|
|
381 |
} elsif ( $form->{cp_name} || $form->{cp_givenname} ) { |
|
382 |
$query = qq|INSERT INTO contacts (| . join(', ', 'cp_cv_id', @columns) . qq|) VALUES (?, | . join(', ', ('?') x scalar(@columns)) . qq|)|; |
|
383 |
unshift @values, $form->{id}; |
|
384 |
} |
|
385 |
do_query( $form, $dbh, $query, @values ) if ($query); |
|
371 |
$form->{cp_id} = $self->_save_contact($form, $dbh); |
|
386 | 372 |
|
387 | 373 |
# add shipto |
388 | 374 |
$form->add_shipto( $dbh, $form->{id}, "CT" ); |
... | ... | |
530 | 516 |
); |
531 | 517 |
do_query($form, $dbh, $query, @values); |
532 | 518 |
|
533 |
$query = undef; |
|
534 |
if ( $form->{cp_id} ) { |
|
535 |
$query = qq|UPDATE contacts SET | . |
|
536 |
qq|cp_title = ?, | . |
|
537 |
qq|cp_givenname = ?, | . |
|
538 |
qq|cp_name = ?, | . |
|
539 |
qq|cp_email = ?, | . |
|
540 |
qq|cp_phone1 = ?, | . |
|
541 |
qq|cp_phone2 = ?, | . |
|
542 |
qq|cp_abteilung = ?, | . |
|
543 |
qq|cp_fax = ?, | . |
|
544 |
qq|cp_mobile1 = ?, | . |
|
545 |
qq|cp_mobile2 = ?, | . |
|
546 |
qq|cp_satphone = ?, | . |
|
547 |
qq|cp_satfax = ?, | . |
|
548 |
qq|cp_project = ?, | . |
|
549 |
qq|cp_privatphone = ?, | . |
|
550 |
qq|cp_privatemail = ?, | . |
|
551 |
qq|cp_birthday = ?, | . |
|
552 |
qq|cp_gender = ? | . |
|
553 |
qq|WHERE cp_id = ?|; |
|
554 |
@values = ( |
|
555 |
$form->{cp_title}, |
|
556 |
$form->{cp_givenname}, |
|
557 |
$form->{cp_name}, |
|
558 |
$form->{cp_email}, |
|
559 |
$form->{cp_phone1}, |
|
560 |
$form->{cp_phone2}, |
|
561 |
$form->{cp_abteilung}, |
|
562 |
$form->{cp_fax}, |
|
563 |
$form->{cp_mobile1}, |
|
564 |
$form->{cp_mobile2}, |
|
565 |
$form->{cp_satphone}, |
|
566 |
$form->{cp_satfax}, |
|
567 |
$form->{cp_project}, |
|
568 |
$form->{cp_privatphone}, |
|
569 |
$form->{cp_privatemail}, |
|
570 |
$form->{cp_birthday}, |
|
571 |
$form->{cp_gender} eq 'f' ? 'f' : 'm', |
|
572 |
$form->{cp_id} |
|
573 |
); |
|
574 |
} elsif ( $form->{cp_name} || $form->{cp_givenname} ) { |
|
575 |
$query = |
|
576 |
qq|INSERT INTO contacts ( cp_cv_id, cp_title, cp_givenname, | . |
|
577 |
qq| cp_name, cp_email, cp_phone1, cp_phone2, cp_abteilung, cp_fax, cp_mobile1, | . |
|
578 |
qq| cp_mobile2, cp_satphone, cp_satfax, cp_project, cp_privatphone, cp_privatemail, | . |
|
579 |
qq| cp_birthday, cp_gender) | . |
|
580 |
qq|VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)|; |
|
581 |
@values = ( |
|
582 |
$form->{id}, |
|
583 |
$form->{cp_title}, |
|
584 |
$form->{cp_givenname}, |
|
585 |
$form->{cp_name}, |
|
586 |
$form->{cp_email}, |
|
587 |
$form->{cp_phone1}, |
|
588 |
$form->{cp_phone2}, |
|
589 |
$form->{cp_abteilung}, |
|
590 |
$form->{cp_fax}, |
|
591 |
$form->{cp_mobile1}, |
|
592 |
$form->{cp_mobile2}, |
|
593 |
$form->{cp_satphone}, |
|
594 |
$form->{cp_satfax}, |
|
595 |
$form->{cp_project}, |
|
596 |
$form->{cp_privatphone}, |
|
597 |
$form->{cp_privatemail}, |
|
598 |
$form->{cp_birthday}, |
|
599 |
$form->{cp_gender} |
|
600 |
); |
|
601 |
} |
|
602 |
do_query($form, $dbh, $query, @values) if ($query); |
|
519 |
$form->{cp_id} = $self->_save_contact($form, $dbh); |
|
603 | 520 |
|
604 | 521 |
# add shipto |
605 | 522 |
$form->add_shipto( $dbh, $form->{id}, "CT" ); |
... | ... | |
627 | 544 |
return $rc; |
628 | 545 |
} |
629 | 546 |
|
547 |
sub _save_contact { |
|
548 |
my ($self, $form, $dbh) = @_; |
|
549 |
|
|
550 |
return undef unless $form->{cp_id} || $form->{cp_name} || $form->{cp_givenname}; |
|
551 |
|
|
552 |
my @columns = qw(cp_title cp_givenname cp_name cp_email cp_phone1 cp_phone2 cp_abteilung cp_fax |
|
553 |
cp_mobile1 cp_mobile2 cp_satphone cp_satfax cp_project cp_privatphone cp_privatemail cp_birthday cp_gender |
|
554 |
cp_street cp_zipcode cp_city); |
|
555 |
my @values = map { $_ eq 'cp_gender' ? ($form->{$_} eq 'f' ? 'f' : 'm') : $form->{$_} } @columns; |
|
556 |
|
|
557 |
my ($query, $cp_id); |
|
558 |
if ($form->{cp_id}) { |
|
559 |
$query = qq|UPDATE contacts SET | . join(', ', map { "${_} = ?" } @columns) . qq| WHERE cp_id = ?|; |
|
560 |
push @values, $form->{cp_id}; |
|
561 |
$cp_id = $form->{cp_id}; |
|
562 |
|
|
563 |
} else { |
|
564 |
($cp_id) = selectrow_query($form, $dbh, qq|SELECT nextval('id')|); |
|
565 |
|
|
566 |
$query = qq|INSERT INTO contacts (| . join(', ', @columns, 'cp_cv_id', 'cp_id') . qq|) VALUES (| . join(', ', ('?') x (2 + scalar @columns)) . qq|)|; |
|
567 |
push @values, $form->{id}, $cp_id; |
|
568 |
} |
|
569 |
|
|
570 |
do_query($form, $dbh, $query, @values); |
|
571 |
|
|
572 |
return $cp_id; |
|
573 |
} |
|
574 |
|
|
630 | 575 |
sub delete { |
631 | 576 |
$main::lxdebug->enter_sub(); |
632 | 577 |
|
Auch abrufbar als: Unified diff
Beim Anlegen von Kunden/Lieferanten CVars für Ansprechpersonen speichern
Fixt #2016.