Revision 83381f25
Von Moritz Bunkus vor fast 11 Jahren hinzugefügt
SL/IC.pm | ||
---|---|---|
146 | 146 |
} |
147 | 147 |
|
148 | 148 |
# get translations |
149 |
$form->{language_values} = ""; |
|
150 | 149 |
$query = qq|SELECT language_id, translation, longdescription |
151 | 150 |
FROM translation |
152 | 151 |
WHERE parts_id = ?|; |
153 |
my $trq = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); |
|
154 |
while (my $tr = $trq->fetchrow_hashref("NAME_lc")) { |
|
155 |
$form->{language_values} .= "---+++---" . join('--++--', @{$tr}{qw(language_id translation longdescription)}); |
|
156 |
} |
|
157 |
$trq->finish; |
|
152 |
$form->{translations} = selectall_hashref_query($form, $dbh, $query, conv_i($form->{id})); |
|
158 | 153 |
|
159 | 154 |
# is it an orphan |
160 | 155 |
my @referencing_tables = qw(invoice orderitems inventory); |
... | ... | |
401 | 396 |
# delete translation records |
402 | 397 |
do_query($form, $dbh, qq|DELETE FROM translation WHERE parts_id = ?|, conv_i($form->{id})); |
403 | 398 |
|
404 |
if ($form->{language_values} ne "") { |
|
405 |
foreach my $item (split(/---\+\+\+---/, $form->{language_values})) { |
|
406 |
my ($language_id, $translation, $longdescription) = split(/--\+\+--/, $item); |
|
407 |
if ($translation ne "") { |
|
408 |
$query = qq|INSERT into translation (parts_id, language_id, translation, longdescription) |
|
409 |
VALUES ( ?, ?, ?, ? )|; |
|
410 |
@values = (conv_i($form->{id}), conv_i($language_id), $translation, $longdescription); |
|
411 |
do_query($form, $dbh, $query, @values); |
|
412 |
} |
|
399 |
my @translations = grep { $_->{language_id} && $_->{translation} } @{ $form->{translations} || [] }; |
|
400 |
if (@translations) { |
|
401 |
$query = qq|INSERT into translation (parts_id, language_id, translation, longdescription) |
|
402 |
VALUES ( ?, ?, ?, ? )|; |
|
403 |
$sth = $dbh->prepare($query); |
|
404 |
|
|
405 |
foreach my $translation (@translations) { |
|
406 |
do_statement($form, $sth, $query, conv_i($form->{id}), conv_i($translation->{language_id}), $translation->{translation}, $translation->{longdescription}); |
|
413 | 407 |
} |
408 |
|
|
409 |
$sth->finish(); |
|
414 | 410 |
} |
415 | 411 |
|
416 | 412 |
# delete price records |
bin/mozilla/ic.pl | ||
---|---|---|
1608 | 1608 |
$form->{bin_id} ||= $default_bin_id || $form->{WAREHOUSES}->[$max -1]->{BINS}->[0]->{id}; |
1609 | 1609 |
} |
1610 | 1610 |
|
1611 |
$form->{LANGUAGES} = SL::DB::Manager::Language->get_all_sorted; |
|
1612 |
$form->{translations_map} = { map { ($_->{language_id} => $_) } @{ $form->{translations} || [] } }; |
|
1611 | 1613 |
|
1612 | 1614 |
IC->retrieve_buchungsgruppen(\%myconfig, $form); |
1613 | 1615 |
@{ $form->{BUCHUNGSGRUPPEN} } = grep { $_->{id} eq $form->{buchungsgruppen_id} || ($form->{id} && $form->{orphaned}) || !$form->{id} } @{ $form->{BUCHUNGSGRUPPEN} }; |
... | ... | |
2063 | 2065 |
$lxdebug->leave_sub(); |
2064 | 2066 |
} |
2065 | 2067 |
|
2066 |
sub parts_language_selection { |
|
2067 |
$lxdebug->enter_sub(); |
|
2068 |
|
|
2069 |
$auth->assert('part_service_assembly_edit'); |
|
2070 |
|
|
2071 |
my $languages = IC->retrieve_languages(\%myconfig, $form); |
|
2072 |
|
|
2073 |
if ($form->{language_values} ne "") { |
|
2074 |
foreach my $item (split(/---\+\+\+---/, $form->{language_values})) { |
|
2075 |
my ($language_id, $translation, $longdescription) = split(/--\+\+--/, $item); |
|
2076 |
|
|
2077 |
foreach my $language (@{ $languages }) { |
|
2078 |
next unless ($language->{id} == $language_id); |
|
2079 |
|
|
2080 |
$language->{translation} = $translation; |
|
2081 |
$language->{longdescription} = $longdescription; |
|
2082 |
|
|
2083 |
$language->{translation_area} = ($language->{translation_rows} = $form->numtextrows($language->{translation}, 40)) > 1; |
|
2084 |
$language->{longdescription_rows} = max 4, $form->numtextrows($language->{longdescription}, 40); |
|
2085 |
|
|
2086 |
last; |
|
2087 |
} |
|
2088 |
} |
|
2089 |
} |
|
2090 |
|
|
2091 |
my @header_sort = qw(name longdescription); |
|
2092 |
my %header_title = ( "name" => $locale->text("Name"), |
|
2093 |
"longdescription" => $locale->text("Long Description"), |
|
2094 |
); |
|
2095 |
|
|
2096 |
my @header = |
|
2097 |
map(+{ "column_title" => $header_title{$_}, |
|
2098 |
"column" => $_, |
|
2099 |
}, |
|
2100 |
@header_sort); |
|
2101 |
|
|
2102 |
$form->{"title"} = $locale->text("Language Values"); |
|
2103 |
$form->header(); |
|
2104 |
print $form->parse_html_template("ic/parts_language_selection", { "HEADER" => \@header, |
|
2105 |
"LANGUAGES" => $languages, }); |
|
2106 |
|
|
2107 |
$lxdebug->leave_sub(); |
|
2108 |
} |
|
2109 |
|
|
2110 | 2068 |
sub ajax_autocomplete { |
2111 | 2069 |
$main::lxdebug->enter_sub(); |
2112 | 2070 |
|
js/parts_language_selection.js | ||
---|---|---|
1 |
function parts_language_selection_window(input_name) { |
|
2 |
var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; |
|
3 |
var name = document.getElementsByName(input_name)[0].value; |
|
4 |
url = "ic.pl?" + |
|
5 |
"INPUT_ENCODING=UTF-8&" + |
|
6 |
"action=parts_language_selection&" + |
|
7 |
"id=" + encodeURIComponent(document.ic.id.value) + "&" + |
|
8 |
"language_values=" + encodeURIComponent(document.ic.language_values.value) + "&" + |
|
9 |
"name=" + encodeURIComponent(name) + "&" + |
|
10 |
"input_name=" + encodeURIComponent(input_name) + "&" |
|
11 |
window.open(url, "_new_generic", parm); |
|
12 |
} |
locale/de/all | ||
---|---|---|
1210 | 1210 |
'Language' => 'Sprache', |
1211 | 1211 |
'Language (database ID)' => 'Sprache (Datenbank-ID)', |
1212 | 1212 |
'Language (name)' => 'Sprache (Name)', |
1213 |
'Language Values' => 'Sprachübersetzungen', |
|
1214 | 1213 |
'Language deleted!' => 'Sprache gelöscht!', |
1215 | 1214 |
'Language missing!' => 'Sprache fehlt!', |
1216 | 1215 |
'Language saved!' => 'Sprache gespeichert!', |
... | ... | |
1589 | 1588 |
'Please enter the taxnumber in the client configuration.' => 'Bitte geben Sie in der Mandantenkonfiguration die Steuernummer an.', |
1590 | 1589 |
'Please enter values' => 'Bitte Werte eingeben', |
1591 | 1590 |
'Please insert object dimensions below.' => 'Bitte geben Sie die Abmessungen unten ein', |
1592 |
'Please insert your language values below' => 'Bitte die Übersetzungen unten eintragen', |
|
1593 | 1591 |
'Please insert your longdescription below' => 'Bitte den Langtext eingeben', |
1594 | 1592 |
'Please install the below listed modules or ask your system administrator to.' => 'Bitte installieren Sie die unten aufgeführten Module, oder bitten Sie Ihren Administrator darum.', |
1595 | 1593 |
'Please log in to the administration panel.' => 'Bitte melden Sie sich im Administrationsbereich an.', |
... | ... | |
1887 | 1885 |
'Service Number missing!' => 'Dienstleistungsnummer fehlt!', |
1888 | 1886 |
'Service, assembly or part' => 'Dienstleistung, Erzeugnis oder Ware', |
1889 | 1887 |
'Services' => 'Dienstleistungen', |
1890 |
'Set Language Values' => 'Spracheinstellungen', |
|
1891 | 1888 |
'Set eMail text' => 'E-Mail Text eingeben', |
1892 | 1889 |
'Settings' => 'Einstellungen', |
1893 | 1890 |
'Setup Menu' => 'Menü-Variante', |
... | ... | |
2386 | 2383 |
'Transfer qty' => 'Umlagermenge', |
2387 | 2384 |
'Transfer successful' => 'Lagervorgang erfolgreich', |
2388 | 2385 |
'Translation' => 'Übersetzung', |
2386 |
'Translations' => 'Übersetzungen', |
|
2389 | 2387 |
'Trial Balance' => 'Summen- und Saldenliste', |
2390 | 2388 |
'Trial balance between %s and %s' => 'Summen- und Saldenlisten vom %s bis zum %s', |
2391 | 2389 |
'Trying to call a sub without a name' => 'Es wurde versucht, eine Unterfunktion ohne Namen aufzurufen.', |
templates/webpages/client_config/form.html | ||
---|---|---|
1 | 1 |
[%- USE L %][% USE LxERP %][% USE HTML %][%- USE JavaScript -%] |
2 | 2 |
<script type="text/javascript" src="js/common.js"></script> |
3 |
<script type="text/javascript" src="js/parts_language_selection.js"></script> |
|
4 | 3 |
<script type="text/javascript"> |
5 | 4 |
<!-- |
6 | 5 |
var warehouses = [ |
templates/webpages/common/select_warehouse_bin.html | ||
---|---|---|
3 | 3 |
[%- USE LxERP %] |
4 | 4 |
[%- USE JavaScript -%] |
5 | 5 |
<script type="text/javascript" src="js/common.js"></script> |
6 |
<script type="text/javascript" src="js/parts_language_selection.js"></script> |
|
7 | 6 |
<script type="text/javascript"> |
8 | 7 |
<!-- |
9 | 8 |
warehouses = new Array(); |
templates/webpages/dbupgrade/default_bin_parts.html | ||
---|---|---|
3 | 3 |
[%- USE LxERP %] |
4 | 4 |
[%- USE JavaScript %] |
5 | 5 |
<script type="text/javascript" src="js/common.js"></script> |
6 |
<script type="text/javascript" src="js/parts_language_selection.js"></script> |
|
7 | 6 |
<script type="text/javascript"> |
8 | 7 |
<!-- |
9 | 8 |
warehouses = new Array(); |
templates/webpages/ic/form_footer.html | ||
---|---|---|
26 | 26 |
</table> |
27 | 27 |
</div> |
28 | 28 |
|
29 |
[%- IF LANGUAGES.size %] |
|
30 |
[% PROCESS 'ic/tabs/_edit_translations.html' %] |
|
31 |
[%- END %] |
|
32 |
|
|
29 | 33 |
[%- IF id %] |
30 | 34 |
<div id="sales_price_information"> |
31 | 35 |
[% PROCESS ic/sales_price_information.html id=id %] |
templates/webpages/ic/form_header.html | ||
---|---|---|
1 | 1 |
[%- USE T8 %] |
2 | 2 |
[%- USE HTML %] |
3 |
[%- USE LxERP %] |
|
3 |
[%- USE LxERP %][%- USE L -%]
|
|
4 | 4 |
[% PROCESS 'common/select_warehouse_bin.html' %] |
5 | 5 |
<p><div class="listtop">[% title %] [% HTML.escape(partnumber) %] [% HTML.escape(description) %]</div></p> |
6 | 6 |
|
... | ... | |
18 | 18 |
<input name="taxaccounts" type="hidden" value="[% HTML.escape(taxaccounts) %]"> |
19 | 19 |
<input name="rowcount" type="hidden" value="[% HTML.escape(rowcount) %]"> |
20 | 20 |
<input name="eur" type="hidden" value="[% HTML.escape(eur) %]"> |
21 |
<input name="language_values" type="hidden" value="[% HTML.escape(language_values) %]"> |
|
22 | 21 |
<input name="original_partnumber" type="hidden" value="[% HTML.escape(original_partnumber) %]"> |
23 | 22 |
<input name="currow" type="hidden" value="[% HTML.escape(currow) %]"> |
24 | 23 |
|
25 | 24 |
<div class="tabwidget"> |
26 | 25 |
<ul> |
27 | 26 |
<li><a href="#master_data">[% 'Basic Data' | $T8 %]</a></li> |
27 |
[% IF LANGUAGES.size %] |
|
28 |
<li><a href="#translations_tab">[% 'Translations' | $T8 %]</a></li> |
|
29 |
[% END %] |
|
28 | 30 |
[%- IF id %] |
29 | 31 |
<li><a href="#sales_price_information">[% 'Price information' | $T8 %]</a></li> |
30 | 32 |
[%- END %] |
... | ... | |
122 | 124 |
</td> |
123 | 125 |
</tr> |
124 | 126 |
|
125 |
<tr> |
|
126 |
<td> |
|
127 |
<button type="button" onclick="parts_language_selection_window('language_values')">[% 'Set Language Values' | $T8 %]</button> |
|
128 |
</td> |
|
129 |
</tr> |
|
130 |
|
|
131 | 127 |
<tr height="5"></tr> |
132 | 128 |
|
133 | 129 |
<tr> |
templates/webpages/ic/parts_language_selection.html | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
[%- USE HTML %] |
|
3 |
<form name="Form"> |
|
4 |
|
|
5 |
<input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]"> |
|
6 |
|
|
7 |
<div class="listtop">[% title %]</div> |
|
8 |
|
|
9 |
<p>[% 'Please insert your language values below' | $T8 %]</p> |
|
10 |
|
|
11 |
<p> |
|
12 |
<table> |
|
13 |
<tr class="listheading"> |
|
14 |
<th class="listheading"> </th> |
|
15 |
[%- FOREACH col = HEADER %] |
|
16 |
<th nowrap class="listheading">[% col.column_title %]</th> |
|
17 |
[%- END %] |
|
18 |
</tr> |
|
19 |
|
|
20 |
[%- FOREACH row = LANGUAGES %] |
|
21 |
<tr class="listrow[% loop.count % 2 %]"> |
|
22 |
<td><input type="hidden" id="id_[% loop.count %]" name="id_[% loop.count %]" value="[% HTML.escape(row.id) %]">[% HTML.escape(row.description) %]</td> |
|
23 |
<td> |
|
24 |
[%- IF row.translation_area %] |
|
25 |
<textarea id="translation_[% loop.count %]" name="translation_[% loop.count %]" rows="[% HTML.escape(row.translation_rows) %]" cols=40 wrap="soft">[% HTML.escape(row.translation) %]</textarea> |
|
26 |
[%- ELSE %] |
|
27 |
<input id="translation_[% loop.count %]" name="translation_[% loop.count %]" value="[% HTML.escape(row.translation) %]"> |
|
28 |
[%- END %] |
|
29 |
</td> |
|
30 |
<td><textarea id="longdescription_[% loop.count %]" name="longdescription_[% loop.count %]" rows="[% HTML.escape(row.longdescription_rows) %]" cols=40 wrap="soft">[% HTML.escape(row.longdescription) %]</textarea></td> |
|
31 |
</tr> |
|
32 |
|
|
33 |
[%- IF loop.last %] |
|
34 |
<input type="hidden" id="rowcount" name="rowcount" value="[% loop.count %]"> |
|
35 |
[%- END %] |
|
36 |
[%- END %] |
|
37 |
</table> |
|
38 |
</p> |
|
39 |
|
|
40 |
<p> |
|
41 |
<button type="button" onclick="languages_updated()">[% 'Close' | $T8 %]</button> |
|
42 |
</p> |
|
43 |
|
|
44 |
</form> |
|
45 |
|
|
46 |
<script type="text/javascript"> |
|
47 |
<!-- |
|
48 |
function languages_updated() { |
|
49 |
var languages = ""; |
|
50 |
for (var i = 1; i <= (document.getElementsByName("rowcount")[0].value); i++) { |
|
51 |
var id = "id_" + i ; |
|
52 |
var translation = "translation_" + i ; |
|
53 |
var longdescription = "longdescription_" + i; |
|
54 |
|
|
55 |
languages = languages + |
|
56 |
"---+++---" + document.getElementsByName( id )[0].value + |
|
57 |
"--++--" + document.getElementsByName( translation )[0].value + |
|
58 |
"--++--" + document.getElementsByName( longdescription )[0].value; |
|
59 |
} |
|
60 |
|
|
61 |
window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = languages; |
|
62 |
|
|
63 |
self.close(); |
|
64 |
} |
|
65 |
//--> |
|
66 |
</script> |
|
67 |
|
templates/webpages/ic/tabs/_edit_translations.html | ||
---|---|---|
1 |
[%- USE HTML %][%- USE L -%][%- USE P -%][%- USE LxERP -%] |
|
2 |
|
|
3 |
<div id="translations_tab"> |
|
4 |
<table> |
|
5 |
<tr class="listheading"> |
|
6 |
<th>[% LxERP.t8("Language") %]</th> |
|
7 |
<th>[% LxERP.t8("Description") %]</th> |
|
8 |
<th>[% LxERP.t8("Long Description") %]</th> |
|
9 |
</tr> |
|
10 |
|
|
11 |
[%- FOREACH language = LANGUAGES %] |
|
12 |
[% SET language_id = language.id |
|
13 |
translation = translations_map.$language_id %] |
|
14 |
[% L.hidden_tag('translations[+].language_id', language.id) %] |
|
15 |
<tr class="listrow" valign="top"> |
|
16 |
<td>[% HTML.escape(language.description) %]</td> |
|
17 |
<td>[% L.input_tag("translations[].translation", translation.translation) %]</td> |
|
18 |
<td>[% L.textarea_tag("translations[].longdescription", translation.longdescription, id="translations_longdescription_" _ language_id, style="width: 500px; height: 100px") %]</td> |
|
19 |
</tr> |
|
20 |
[%- END %] |
|
21 |
</table> |
|
22 |
</div> |
Auch abrufbar als: Unified diff
Artikelstammdaten: Spracheinstellungen rein in eigenem Tab bearbeiten
Der alte Mechanismus öffnete ein normales Popup-Fenster, in dem eine
URL geladen wurde, die dann die Maske angezeigt hat. Das
Zurückschreiben geschah schon via JavaScript.
Mit der Methode gibt's zwei Probleme:
1. Es ist langsam, weil ein überflüssiger Roundtrip zum Server gemacht
wird. Die Informationen sind bereits alle beim initialen Anzeigen
der Maske vorhanden.
2. Es handelt sich um einen GET-Request, an den sämtliche
Übersetzungen als GET-Parameter angehängt werden. Damit kann man
problemlos in die Größenbeschränkung bei GET-Requests laufen.