Revision dcef6ec7
Von Moritz Bunkus vor fast 18 Jahren hinzugefügt
SL/AM.pm | ||
---|---|---|
974 | 974 |
# connect to database |
975 | 975 |
my $dbh = $form->dbconnect_noauto($myconfig); |
976 | 976 |
|
977 |
my $query = "DELETE FROM units_language WHERE language_id = ?"; |
|
978 |
$dbh->do($query, undef, $form->{"id"}) || |
|
979 |
$form->dberror($query . " ($form->{id})"); |
|
977 |
foreach my $table (qw(translation_payment_terms units_language)) { |
|
978 |
my $query = qq|DELETE FROM $table WHERE language_id = ?|; |
|
979 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
980 |
} |
|
980 | 981 |
|
981 | 982 |
$query = "DELETE FROM language WHERE id = ?"; |
982 |
$dbh->do($query, undef, $form->{"id"}) || |
|
983 |
$form->dberror($query . " ($form->{id})"); |
|
983 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
984 | 984 |
|
985 | 985 |
$dbh->commit(); |
986 | 986 |
$dbh->disconnect; |
... | ... | |
1360 | 1360 |
|
1361 | 1361 |
my $ref = $sth->fetchrow_hashref(NAME_lc); |
1362 | 1362 |
map { $form->{$_} = $ref->{$_} } keys %$ref; |
1363 |
$sth->finish(); |
|
1364 |
|
|
1365 |
$query = |
|
1366 |
qq|SELECT t.language_id, t.description_long, l.description AS language | . |
|
1367 |
qq|FROM translation_payment_terms t | . |
|
1368 |
qq|LEFT JOIN language l ON t.language_id = l.id | . |
|
1369 |
qq|WHERE t.payment_terms_id = ? | . |
|
1370 |
qq|UNION | . |
|
1371 |
qq|SELECT l.id AS language_id, NULL AS description_long, | . |
|
1372 |
qq|l.description AS language | . |
|
1373 |
qq|FROM language l|; |
|
1374 |
$sth = $dbh->prepare($query); |
|
1375 |
$sth->execute($form->{"id"}) || $form->dberror($query . " ($form->{id})"); |
|
1363 | 1376 |
|
1377 |
my %mapping; |
|
1378 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
|
1379 |
$mapping{ $ref->{"language_id"} } = $ref |
|
1380 |
unless (defined($mapping{ $ref->{"language_id"} })); |
|
1381 |
} |
|
1364 | 1382 |
$sth->finish; |
1365 | 1383 |
|
1384 |
$form->{"TRANSLATION"} = [sort({ $a->{"language"} cmp $b->{"language"} } |
|
1385 |
values(%mapping))]; |
|
1386 |
|
|
1366 | 1387 |
$dbh->disconnect; |
1367 | 1388 |
|
1368 | 1389 |
$main::lxdebug->leave_sub(); |
... | ... | |
1374 | 1395 |
my ($self, $myconfig, $form) = @_; |
1375 | 1396 |
|
1376 | 1397 |
# connect to database |
1377 |
my $dbh = $form->dbconnect($myconfig); |
|
1398 |
my $dbh = $form->dbconnect_noauto($myconfig);
|
|
1378 | 1399 |
|
1400 |
my $query; |
|
1401 |
|
|
1402 |
if (!$form->{id}) { |
|
1403 |
$query = qq|SELECT nextval('id'), MAX(sortkey) + 1 FROM payment_terms|; |
|
1404 |
my $sortkey; |
|
1405 |
($form->{id}, $sortkey) = selectrow_query($form, $dbh, $query); |
|
1406 |
|
|
1407 |
$query = qq|INSERT INTO payment_terms (id, sortkey) VALUES (?, ?)|; |
|
1408 |
do_query($form, $dbh, $query, $form->{id}, $sortkey); |
|
1409 |
|
|
1410 |
} else { |
|
1411 |
$query = |
|
1412 |
qq|DELETE FROM translation_payment_terms | . |
|
1413 |
qq|WHERE payment_terms_id = ?|; |
|
1414 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
1415 |
} |
|
1416 |
|
|
1417 |
$query = qq|UPDATE payment_terms SET |
|
1418 |
description = ?, description_long = ?, |
|
1419 |
ranking = ?, |
|
1420 |
terms_netto = ?, terms_skonto = ?, |
|
1421 |
percent_skonto = ? |
|
1422 |
WHERE id = ?|; |
|
1379 | 1423 |
my @values = ($form->{description}, $form->{description_long}, |
1380 | 1424 |
$form->{ranking} * 1, |
1381 | 1425 |
$form->{terms_netto} * 1, $form->{terms_skonto} * 1, |
1382 |
$form->{percent_skonto} * 1); |
|
1426 |
$form->{percent_skonto} * 1, |
|
1427 |
$form->{id}); |
|
1428 |
do_query($form, $dbh, $query, @values); |
|
1383 | 1429 |
|
1384 |
my $query; |
|
1385 |
# id is the old record |
|
1386 |
if ($form->{id}) { |
|
1387 |
$query = qq|UPDATE payment_terms SET |
|
1388 |
description = ?, description_long = ?, |
|
1389 |
ranking = ?, |
|
1390 |
terms_netto = ?, terms_skonto = ?, |
|
1391 |
percent_skonto = ? |
|
1392 |
WHERE id = ?|; |
|
1393 |
push(@values, $form->{"id"}); |
|
1394 |
} else { |
|
1395 |
$query = qq|SELECT MAX(sortkey) + 1 FROM payment_terms|; |
|
1396 |
my ($sortkey) = selectrow_query($form, $dbh, $query); |
|
1397 |
$query = qq|INSERT INTO payment_terms |
|
1398 |
(description, description_long, ranking, |
|
1399 |
terms_netto, terms_skonto, percent_skonto, sortkey) |
|
1400 |
VALUES (?, ?, ?, ?, ?, ?, ?)|; |
|
1401 |
push(@values, $sortkey); |
|
1430 |
$query = qq|SELECT id FROM language|; |
|
1431 |
my @language_ids; |
|
1432 |
my $sth = $dbh->prepare($query); |
|
1433 |
$sth->execute() || $form->dberror($query); |
|
1434 |
|
|
1435 |
while (my ($id) = $sth->fetchrow_array()) { |
|
1436 |
push(@language_ids, $id); |
|
1402 | 1437 |
} |
1403 |
do_query($form, $dbh, $query, @values);
|
|
1438 |
$sth->finish();
|
|
1404 | 1439 |
|
1440 |
$query = |
|
1441 |
qq|INSERT INTO translation_payment_terms | . |
|
1442 |
qq|(language_id, payment_terms_id, description_long) | . |
|
1443 |
qq|VALUES (?, ?, ?)|; |
|
1444 |
$sth = $dbh->prepare($query); |
|
1445 |
|
|
1446 |
foreach my $language_id (@language_ids) { |
|
1447 |
do_statement($form, $sth, $query, $language_id, $form->{"id"}, |
|
1448 |
$form->{"description_long_${language_id}"}); |
|
1449 |
} |
|
1450 |
$sth->finish(); |
|
1451 |
|
|
1452 |
$dbh->commit(); |
|
1405 | 1453 |
$dbh->disconnect; |
1406 | 1454 |
|
1407 | 1455 |
$main::lxdebug->leave_sub(); |
... | ... | |
1413 | 1461 |
my ($self, $myconfig, $form) = @_; |
1414 | 1462 |
|
1415 | 1463 |
# connect to database |
1416 |
my $dbh = $form->dbconnect($myconfig); |
|
1464 |
my $dbh = $form->dbconnect_noauto($myconfig);
|
|
1417 | 1465 |
|
1418 | 1466 |
my $query = qq|DELETE FROM payment_terms WHERE id = ?|; |
1419 | 1467 |
do_query($form, $dbh, $query, $form->{"id"}); |
1420 | 1468 |
|
1469 |
$query = |
|
1470 |
qq|DELETE FROM translation_payment_terms WHERE payment_terms_id = ?|; |
|
1471 |
do_query($form, $dbh, $query, $form->{"id"}); |
|
1472 |
|
|
1473 |
$dbh->commit(); |
|
1421 | 1474 |
$dbh->disconnect; |
1422 | 1475 |
|
1423 | 1476 |
$main::lxdebug->leave_sub(); |
Auch abrufbar als: Unified diff
Für alle Zahlungskonditionen kann jetzt für jede Sprache eine Übersetzung speichern.