Revision 2ff2f6c9
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
250 | 250 |
|
251 | 251 |
# if charttype is heading make sure certain values are empty |
252 | 252 |
# specifically, if charttype is changed from an existing account, empty the |
253 |
# fields unnecessary for headings, so that e.g. heading doesn't appear in
|
|
253 |
# fields unnecessary for headings, so that e.g. heading doesn't appear in |
|
254 | 254 |
# drop-down menues due to still having a valid "link" entry |
255 | 255 |
|
256 | 256 |
if ( $form->{charttype} eq 'H' ) { |
... | ... | |
474 | 474 |
return $rc; |
475 | 475 |
} |
476 | 476 |
|
477 |
sub departments { |
|
478 |
$main::lxdebug->enter_sub(); |
|
479 |
|
|
480 |
my ($self, $myconfig, $form) = @_; |
|
481 |
|
|
482 |
# connect to database |
|
483 |
my $dbh = $form->dbconnect($myconfig); |
|
484 |
|
|
485 |
my $query = qq|SELECT d.id, d.description, d.role |
|
486 |
FROM department d |
|
487 |
ORDER BY 2|; |
|
488 |
|
|
489 |
my $sth = $dbh->prepare($query); |
|
490 |
$sth->execute || $form->dberror($query); |
|
491 |
|
|
492 |
$form->{ALL} = []; |
|
493 |
while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { |
|
494 |
push @{ $form->{ALL} }, $ref; |
|
495 |
} |
|
496 |
|
|
497 |
$sth->finish; |
|
498 |
$dbh->disconnect; |
|
499 |
|
|
500 |
$main::lxdebug->leave_sub(); |
|
501 |
} |
|
502 |
|
|
503 |
sub get_department { |
|
504 |
$main::lxdebug->enter_sub(); |
|
505 |
|
|
506 |
my ($self, $myconfig, $form) = @_; |
|
507 |
|
|
508 |
# connect to database |
|
509 |
my $dbh = $form->dbconnect($myconfig); |
|
510 |
|
|
511 |
my $query = qq|SELECT d.description, d.role |
|
512 |
FROM department d |
|
513 |
WHERE d.id = ?|; |
|
514 |
my $sth = $dbh->prepare($query); |
|
515 |
$sth->execute($form->{id}) || $form->dberror($query . " ($form->{id})"); |
|
516 |
|
|
517 |
my $ref = $sth->fetchrow_hashref("NAME_lc"); |
|
518 |
|
|
519 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
|
520 |
|
|
521 |
$sth->finish; |
|
522 |
|
|
523 |
# see if it is in use |
|
524 |
$query = qq|SELECT count(*) FROM dpt_trans d |
|
525 |
WHERE d.department_id = ?|; |
|
526 |
($form->{orphaned}) = selectrow_query($form, $dbh, $query, $form->{id}); |
|
527 |
|
|
528 |
$form->{orphaned} = !$form->{orphaned}; |
|
529 |
$sth->finish; |
|
530 |
|
|
531 |
$dbh->disconnect; |
|
532 |
|
|
533 |
$main::lxdebug->leave_sub(); |
|
534 |
} |
|
535 |
|
|
536 |
sub save_department { |
|
537 |
$main::lxdebug->enter_sub(); |
|
538 |
|
|
539 |
my ($self, $myconfig, $form) = @_; |
|
540 |
my ($query); |
|
541 |
|
|
542 |
# connect to database |
|
543 |
my $dbh = $form->dbconnect($myconfig); |
|
544 |
|
|
545 |
my @values = ($form->{description}, $form->{role}); |
|
546 |
if ($form->{id}) { |
|
547 |
$query = qq|UPDATE department SET |
|
548 |
description = ?, role = ? |
|
549 |
WHERE id = ?|; |
|
550 |
push(@values, $form->{id}); |
|
551 |
} else { |
|
552 |
$query = qq|INSERT INTO department |
|
553 |
(description, role) |
|
554 |
VALUES (?, ?)|; |
|
555 |
} |
|
556 |
do_query($form, $dbh, $query, @values); |
|
557 |
|
|
558 |
$dbh->disconnect; |
|
559 |
|
|
560 |
$main::lxdebug->leave_sub(); |
|
561 |
} |
|
562 |
|
|
563 |
sub delete_department { |
|
564 |
$main::lxdebug->enter_sub(); |
|
565 |
|
|
566 |
my ($self, $myconfig, $form) = @_; |
|
567 |
my ($query); |
|
568 |
|
|
569 |
# connect to database |
|
570 |
my $dbh = $form->dbconnect($myconfig); |
|
571 |
|
|
572 |
$query = qq|DELETE FROM department |
|
573 |
WHERE id = ?|; |
|
574 |
do_query($form, $dbh, $query, $form->{id}); |
|
575 |
|
|
576 |
$dbh->disconnect; |
|
577 |
|
|
578 |
$main::lxdebug->leave_sub(); |
|
579 |
} |
|
580 |
|
|
581 | 477 |
sub lead { |
582 | 478 |
$main::lxdebug->enter_sub(); |
583 | 479 |
|
Auch abrufbar als: Unified diff
Verwaltung von Abteilungen auf Controller umgestellt