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(); |
SL/DBUtils.pm | ||
---|---|---|
3 | 3 |
require Exporter; |
4 | 4 |
@ISA = qw(Exporter); |
5 | 5 |
|
6 |
@EXPORT = qw(conv_i conv_date do_query selectrow_query dump_query); |
|
6 |
@EXPORT = qw(conv_i conv_date do_query selectrow_query do_statement dump_query);
|
|
7 | 7 |
|
8 | 8 |
sub conv_i { |
9 | 9 |
my ($value, $default) = @_; |
... | ... | |
40 | 40 |
} |
41 | 41 |
} |
42 | 42 |
|
43 |
sub do_statement { |
|
44 |
my ($form, $sth, $query) = splice(@_, 0, 3); |
|
45 |
|
|
46 |
if (0 == scalar(@_)) { |
|
47 |
$sth->execute() || $form->dberror($query); |
|
48 |
} else { |
|
49 |
$sth->execute(@_) || |
|
50 |
$form->dberror($query . " (" . join(", ", @_) . ")"); |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
43 | 54 |
sub dump_query { |
44 | 55 |
my ($level, $msg, $query) = splice(@_, 0, 3); |
45 | 56 |
while ($query =~ /\?/) { |
bin/mozilla/am.pl | ||
---|---|---|
2326 | 2326 |
$form->{terms_netto} = 0; |
2327 | 2327 |
$form->{terms_skonto} = 0; |
2328 | 2328 |
$form->{percent_skonto} = 0; |
2329 |
my @languages = AM->language(\%myconfig, $form, 1); |
|
2330 |
map({ $_->{"language"} = $_->{"description"}; |
|
2331 |
$_->{"language_id"} = $_->{"id"}; } @languages); |
|
2332 |
$form->{"TRANSLATION"} = \@languages; |
|
2329 | 2333 |
&payment_header; |
2330 | 2334 |
&form_footer; |
2331 | 2335 |
|
... | ... | |
2337 | 2341 |
|
2338 | 2342 |
$form->{title} = "Edit"; |
2339 | 2343 |
|
2340 |
AM->get_payment(\%myconfig, \%$form);
|
|
2344 |
AM->get_payment(\%myconfig, $form); |
|
2341 | 2345 |
$form->{percent_skonto} = |
2342 | 2346 |
$form->format_amount(\%myconfig, $form->{percent_skonto} * 100); |
2343 | 2347 |
|
... | ... | |
2537 | 2541 |
<th align=right>| . $locale->text('Long Description') . qq|</th> |
2538 | 2542 |
<td><input name=description_long size=50 value="$form->{description_long}"></td> |
2539 | 2543 |
</tr> |
2544 |
|; |
|
2545 |
|
|
2546 |
foreach my $language (@{ $form->{"TRANSLATION"} }) { |
|
2547 |
print qq| |
|
2548 |
<tr> |
|
2549 |
<th align="right">| . |
|
2550 |
sprintf($locale->text('Translation (%s)'), |
|
2551 |
$language->{"language"}) |
|
2552 |
. qq|</th> |
|
2553 |
<td><input name="description_long_$language->{language_id}" size="50" |
|
2554 |
value="| . Q($language->{"description_long"}) . qq|"></td> |
|
2555 |
</tr> |
|
2556 |
|; |
|
2557 |
} |
|
2558 |
|
|
2559 |
print qq| |
|
2540 | 2560 |
<tr> |
2541 | 2561 |
<th align=right>| . $locale->text('Netto Terms') . qq|</th> |
2542 | 2562 |
<td><input name=terms_netto size=10 value="$form->{terms_netto}"></td> |
locale/de/all | ||
---|---|---|
1049 | 1049 |
'Transfer' => 'Umlagerung', |
1050 | 1050 |
'Transfer Inventory' => 'Ware umlagern', |
1051 | 1051 |
'Transfer to' => 'umlagern nach', |
1052 |
'Translation (%s)' => 'Übersetzung (%s)', |
|
1052 | 1053 |
'Trial Balance' => 'Saldenbilanz', |
1053 | 1054 |
'Type' => 'Typ', |
1054 | 1055 |
'Type of Business' => 'Kundentyp', |
locale/de/am | ||
---|---|---|
255 | 255 |
'Top (Javascript)' => 'Oben (mit Javascript)', |
256 | 256 |
'Transaction reversal enforced for all dates' => 'Fehleintragungen m?ssen f?r jeden Zeitraum mit einer Kontraeintragung ausgebessert werden', |
257 | 257 |
'Transaction reversal enforced up to' => 'Fehleintragungen k?nnen bis zu dem angegebenen Zeitraum nur mit einer Kontraeintragung ausgebessert werden!', |
258 |
'Translation (%s)' => 'Übersetzung (%s)', |
|
258 | 259 |
'Type of Business' => 'Kundentyp', |
259 | 260 |
'UStVA-Nr. 35' => 'Kz. 35', |
260 | 261 |
'UStVA-Nr. 36' => 'Kz. 36', |
sql/Pg-upgrade2/payment_terms_translation.sql | ||
---|---|---|
1 |
-- @tag: payment_terms_translation |
|
2 |
-- @description: Übersetzungen von Zahlungskonditionen |
|
3 |
-- @depends: release_2_4_1 |
|
4 |
CREATE TABLE translation_payment_terms ( |
|
5 |
payment_terms_id integer NOT NULL, |
|
6 |
language_id integer NOT NULL, |
|
7 |
description_long text, |
|
8 |
|
|
9 |
FOREIGN KEY (payment_terms_id) REFERENCES payment_terms (id), |
|
10 |
FOREIGN KEY (language_id) REFERENCES language (id) |
|
11 |
); |
Auch abrufbar als: Unified diff
Für alle Zahlungskonditionen kann jetzt für jede Sprache eine Übersetzung speichern.