Revision e549422f
Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
1474 | 1474 |
return $error; |
1475 | 1475 |
} |
1476 | 1476 |
|
1477 |
sub save_preferences {
|
|
1477 |
sub save_defaults {
|
|
1478 | 1478 |
$main::lxdebug->enter_sub(); |
1479 | 1479 |
|
1480 |
my ($self, $myconfig, $form, $memberfile, $userspath, $webdav) = @_; |
|
1480 |
my $self = shift; |
|
1481 |
my %params = @_; |
|
1481 | 1482 |
|
1482 |
map { ($form->{$_}) = split(/--/, $form->{$_}) }
|
|
1483 |
qw(inventory_accno income_accno expense_accno fxgain_accno fxloss_accno);
|
|
1483 |
my $myconfig = \%main::myconfig;
|
|
1484 |
my $form = $main::form;
|
|
1484 | 1485 |
|
1485 |
my @a; |
|
1486 |
$form->{curr} =~ s/ //g; |
|
1487 |
map { push(@a, uc pack "A3", $_) if $_ } split(/:/, $form->{curr}); |
|
1488 |
$form->{curr} = join ':', @a; |
|
1486 |
my $dbh = $params{dbh} || $form->get_standard_dbh($myconfig); |
|
1489 | 1487 |
|
1490 |
# connect to database |
|
1491 |
my $dbh = $form->dbconnect_noauto($myconfig); |
|
1488 |
my %accnos; |
|
1489 |
map { ($accnos{$_}) = split(m/--/, $form->{$_}) } qw(inventory_accno income_accno expense_accno fxgain_accno fxloss_accno); |
|
1490 |
|
|
1491 |
$form->{curr} =~ s/ //g; |
|
1492 |
my @currencies = grep { $_ ne '' } split m/:/, $form->{curr}; |
|
1493 |
my $currency = join ':', @currencies; |
|
1492 | 1494 |
|
1493 | 1495 |
# these defaults are database wide |
1494 |
# user specific variables are in myconfig |
|
1495 |
# save defaults |
|
1496 |
|
|
1496 | 1497 |
my $query = |
1497 |
qq|UPDATE defaults SET | . |
|
1498 |
qq|inventory_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), | . |
|
1499 |
qq|income_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), | . |
|
1500 |
qq|expense_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), | . |
|
1501 |
qq|fxgain_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), | . |
|
1502 |
qq|fxloss_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), | . |
|
1503 |
qq|invnumber = ?, | . |
|
1504 |
qq|cnnumber = ?, | . |
|
1505 |
qq|sonumber = ?, | . |
|
1506 |
qq|ponumber = ?, | . |
|
1507 |
qq|sqnumber = ?, | . |
|
1508 |
qq|rfqnumber = ?, | . |
|
1509 |
qq|customernumber = ?, | . |
|
1510 |
qq|vendornumber = ?, | . |
|
1511 |
qq|articlenumber = ?, | . |
|
1512 |
qq|servicenumber = ?, | . |
|
1513 |
qq|yearend = ?, | . |
|
1514 |
qq|curr = ?, | . |
|
1515 |
qq|businessnumber = ?|; |
|
1516 |
my @values = ($form->{inventory_accno}, $form->{income_accno}, |
|
1517 |
$form->{expense_accno}, |
|
1518 |
$form->{fxgain_accno}, $form->{fxloss_accno}, |
|
1519 |
$form->{invnumber}, $form->{cnnumber}, |
|
1520 |
$form->{sonumber}, $form->{ponumber}, |
|
1521 |
$form->{sqnumber}, $form->{rfqnumber}, |
|
1522 |
$form->{customernumber}, $form->{vendornumber}, |
|
1523 |
$form->{articlenumber}, $form->{servicenumber}, |
|
1524 |
$form->{yearend}, $form->{curr}, |
|
1498 |
qq|UPDATE defaults SET |
|
1499 |
inventory_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1500 |
income_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1501 |
expense_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1502 |
fxgain_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1503 |
fxloss_accno_id = (SELECT c.id FROM chart c WHERE c.accno = ?), |
|
1504 |
invnumber = ?, |
|
1505 |
cnnumber = ?, |
|
1506 |
sonumber = ?, |
|
1507 |
ponumber = ?, |
|
1508 |
sqnumber = ?, |
|
1509 |
rfqnumber = ?, |
|
1510 |
customernumber = ?, |
|
1511 |
vendornumber = ?, |
|
1512 |
articlenumber = ?, |
|
1513 |
servicenumber = ?, |
|
1514 |
yearend = ?, |
|
1515 |
curr = ?, |
|
1516 |
businessnumber = ?|; |
|
1517 |
my @values = ($accnos{inventory_accno}, $accnos{income_accno}, $accnos{expense_accno}, |
|
1518 |
$accnos{fxgain_accno}, $accnos{fxloss_accno}, |
|
1519 |
$form->{invnumber}, $form->{cnnumber}, |
|
1520 |
$form->{sonumber}, $form->{ponumber}, |
|
1521 |
$form->{sqnumber}, $form->{rfqnumber}, |
|
1522 |
$form->{customernumber}, $form->{vendornumber}, |
|
1523 |
$form->{articlenumber}, $form->{servicenumber}, |
|
1524 |
$form->{yearend}, $currency, |
|
1525 | 1525 |
$form->{businessnumber}); |
1526 | 1526 |
do_query($form, $dbh, $query, @values); |
1527 | 1527 |
|
1528 |
$dbh->commit(); |
|
1529 |
|
|
1530 |
$main::lxdebug->leave_sub(); |
|
1531 |
} |
|
1532 |
|
|
1533 |
|
|
1534 |
sub save_preferences { |
|
1535 |
$main::lxdebug->enter_sub(); |
|
1536 |
|
|
1537 |
my ($self, $myconfig, $form, $memberfile, $userspath, $webdav) = @_; |
|
1538 |
|
|
1539 |
my $dbh = $form->get_standard_dbh($myconfig); |
|
1540 |
|
|
1541 |
my ($currency, $businessnumber) = selectrow_query($form, $dbh, qq|SELECT curr, businessnumber FROM defaults|); |
|
1542 |
|
|
1528 | 1543 |
# update name |
1529 |
$query = qq|UPDATE employee |
|
1530 |
SET name = ? |
|
1531 |
WHERE login = ?|; |
|
1544 |
my $query = qq|UPDATE employee SET name = ? WHERE login = ?|; |
|
1532 | 1545 |
do_query($form, $dbh, $query, $form->{name}, $form->{login}); |
1533 | 1546 |
|
1534 |
my $rc = $dbh->commit; |
|
1535 |
$dbh->disconnect; |
|
1547 |
my $rc = $dbh->commit(); |
|
1536 | 1548 |
|
1537 | 1549 |
# save first currency in myconfig |
1538 |
$form->{currency} = substr($form->{curr}, 0, 3); |
|
1550 |
$currency =~ s/:.*//; |
|
1551 |
$form->{currency} = $currency; |
|
1552 |
|
|
1553 |
$form->{businessnumber} = $businessnumber; |
|
1539 | 1554 |
|
1540 | 1555 |
$myconfig = new User "$memberfile", "$form->{login}"; |
1541 | 1556 |
|
Auch abrufbar als: Unified diff
Das Bearbeiten der Einstellungen, die in der Tabelle "defaults" gespeichert werden, wurde in eine eigene Maske ausgelagert, die unter "System -> Nummernkreise und Standardkonten" aufrufbar ist. Bei "Programm -> Benutzereinstellungen" hingegen befinden sich nur noch Einstellungen, die pro Benutzer einstellbar sind (also die Sachen aus %myconfig).