From: Bernd Bleßmann Date: Wed, 9 May 2018 12:21:45 +0000 (+0200) Subject: calculate_qty (Formel): Input- und Formel-Feld auch als Dom-Id übergeben können X-Git-Tag: release-3.5.4~413 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=1ccc89c81f95c77ec583c973dec38b56177c81ab;p=kivitendo-erp.git calculate_qty (Formel): Input- und Formel-Feld auch als Dom-Id übergeben können --- diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 7cdc751bd..fa6300482 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -319,7 +319,7 @@ sub display_row { my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2; $column_data{qty} = $cgi->textfield(-name => "qty_$i", -size => 5, -class => "numeric", -value => $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec)); - $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', 'formel_$i')", -value => $locale->text('*/')) + $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', '', 'formel_$i')", -value => $locale->text('*/')) . $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"}) if $form->{"formel_$i"}; diff --git a/js/calculate_qty.js b/js/calculate_qty.js index e0aecc431..01fa5bfe5 100644 --- a/js/calculate_qty.js +++ b/js/calculate_qty.js @@ -1,11 +1,17 @@ -function calculate_qty_selection_window(input_name, formel) { +function calculate_qty_selection_window(input_name, input_id, formel_name, formel_id) { var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes"; var action = "calculate_qty"; + if (formel_id) { + var formel = $('#' + formel_id).val(); + } else { + var formel = $('[name="' + formel_name + '"]').val(); + } url = "common.pl?" + "INPUT_ENCODING=UTF-8&" + "action=" + action + "&" + "input_name=" + encodeURIComponent(input_name) + "&" + - "formel=" + encodeURIComponent(document.getElementsByName(formel)[0].value) + "input_id=" + encodeURIComponent(input_id) + "&" + + "formel=" + encodeURIComponent(formel); //alert(url); window.open(url, "_new_generic", parm); } diff --git a/templates/webpages/generic/calculate_qty.html b/templates/webpages/generic/calculate_qty.html index 49c105483..3d2910cbe 100644 --- a/templates/webpages/generic/calculate_qty.html +++ b/templates/webpages/generic/calculate_qty.html @@ -5,6 +5,7 @@
+ @@ -40,7 +41,11 @@ [%- END %] var result = [% formel %]; result = number_format(result, 2, '[% MYCONFIG.numberformat %]'); - window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result; + if (document.Form.input_id.value) { + window.opener.document.getElementById(document.Form.input_id.value).value = result; + } else { + window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result; + } self.close(); }
[% 'Please insert object dimensions below.' | $T8 %]