Revision 508801bb
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
571 | 571 |
$main::lxdebug->leave_sub(); |
572 | 572 |
} |
573 | 573 |
|
574 |
sub business { |
|
575 |
$main::lxdebug->enter_sub(); |
|
576 |
|
|
577 |
my ($self, $myconfig, $form) = @_; |
|
578 |
|
|
579 |
# connect to database |
|
580 |
my $dbh = $form->dbconnect($myconfig); |
|
581 |
|
|
582 |
my $query = qq|SELECT id, description, discount, customernumberinit, salesman |
|
583 |
FROM business |
|
584 |
ORDER BY 2|; |
|
585 |
|
|
586 |
my $sth = $dbh->prepare($query); |
|
587 |
$sth->execute || $form->dberror($query); |
|
588 |
|
|
589 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
590 |
push @{ $form->{ALL} }, $ref; |
|
591 |
} |
|
592 |
|
|
593 |
$sth->finish; |
|
594 |
$dbh->disconnect; |
|
595 |
|
|
596 |
$main::lxdebug->leave_sub(); |
|
597 |
} |
|
598 |
|
|
599 |
sub get_business { |
|
600 |
$main::lxdebug->enter_sub(); |
|
601 |
|
|
602 |
my ($self, $myconfig, $form) = @_; |
|
603 |
|
|
604 |
# connect to database |
|
605 |
my $dbh = $form->dbconnect($myconfig); |
|
606 |
|
|
607 |
my $query = |
|
608 |
qq|SELECT b.description, b.discount, b.customernumberinit, b.salesman |
|
609 |
FROM business b |
|
610 |
WHERE b.id = ?|; |
|
611 |
my $sth = $dbh->prepare($query); |
|
612 |
$sth->execute($form->{id}) || $form->dberror($query . " ($form->{id})"); |
|
613 |
|
|
614 |
my $ref = $sth->fetchrow_hashref("NAME_lc"); |
|
615 |
|
|
616 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
|
617 |
|
|
618 |
$sth->finish; |
|
619 |
|
|
620 |
$dbh->disconnect; |
|
621 |
|
|
622 |
$main::lxdebug->leave_sub(); |
|
623 |
} |
|
624 |
|
|
625 |
sub save_business { |
|
626 |
$main::lxdebug->enter_sub(); |
|
627 |
|
|
628 |
my ($self, $myconfig, $form) = @_; |
|
629 |
my ($query); |
|
630 |
|
|
631 |
# connect to database |
|
632 |
my $dbh = $form->dbconnect($myconfig); |
|
633 |
|
|
634 |
my @values = ($form->{description}, $form->{discount}, $form->{customernumberinit}, $form->{salesman} ? 't' : 'f'); |
|
635 |
# id is the old record |
|
636 |
if ($form->{id}) { |
|
637 |
$query = qq|UPDATE business SET |
|
638 |
description = ?, |
|
639 |
discount = ?, |
|
640 |
customernumberinit = ?, |
|
641 |
salesman = ? |
|
642 |
WHERE id = ?|; |
|
643 |
push(@values, $form->{id}); |
|
644 |
} else { |
|
645 |
$query = qq|INSERT INTO business |
|
646 |
(description, discount, customernumberinit, salesman) |
|
647 |
VALUES (?, ?, ?, ?)|; |
|
648 |
} |
|
649 |
do_query($form, $dbh, $query, @values); |
|
650 |
|
|
651 |
$dbh->disconnect; |
|
652 |
|
|
653 |
$main::lxdebug->leave_sub(); |
|
654 |
} |
|
655 |
|
|
656 |
sub delete_business { |
|
657 |
$main::lxdebug->enter_sub(); |
|
658 |
|
|
659 |
my ($self, $myconfig, $form) = @_; |
|
660 |
|
|
661 |
# connect to database |
|
662 |
my $dbh = $form->dbconnect($myconfig); |
|
663 |
|
|
664 |
my $query = qq|DELETE FROM business |
|
665 |
WHERE id = ?|; |
|
666 |
do_query($form, $dbh, $query, $form->{id}); |
|
667 |
|
|
668 |
$dbh->disconnect; |
|
669 |
|
|
670 |
$main::lxdebug->leave_sub(); |
|
671 |
} |
|
672 |
|
|
673 |
|
|
674 | 574 |
sub language { |
675 | 575 |
$main::lxdebug->enter_sub(); |
676 | 576 |
|
Auch abrufbar als: Unified diff
Verwaltung von Kunden-/Lieferantentypen auf Controller umgestellt