}, @header_sort;
$form->{formel} = $formel;
- $form->{title} = $locale->text("Please enter values");
- $form->header(no_layout => 1);
- print $form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header,
- "VARIABLES" => \@variable, });
+ my $html = $form->parse_html_template("generic/calculate_qty", { "HEADER" => \@header,
+ "VARIABLES" => \@variable, });
+ print $::form->ajax_response_header, $html;
$main::lxdebug->leave_sub();
}
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_dialog('qty_$i', '', 'formel_$i', '')", -value => $locale->text('*/'))
. $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"})
if $form->{"formel_$i"};
-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";
+function calculate_qty_selection_dialog(input_name, input_id, formel_name, formel_id) {
+ // The target input element is determined by it's dom id or by it's name.
+ // The formula input element (the one containing the formula) is determined by it's dom id or by it's name.
+ // If the id is not provided the name is used.
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) + "&" +
- "input_id=" + encodeURIComponent(input_id) + "&" +
- "formel=" + encodeURIComponent(formel);
- //alert(url);
- window.open(url, "_new_generic", parm);
+ var url = "common.pl";
+ var data = {
+ action: "calculate_qty",
+ input_name: input_name,
+ input_id: input_id,
+ formel: formel
+ };
+ kivi.popup_dialog({
+ id: 'calc_qty_dialog',
+ url: url,
+ data: data,
+ dialog: {
+ width: 500,
+ height: 400,
+ title: kivi.t8('Please enter values'),
+ }
+ });
}
ns.show_calculate_qty_dialog = function(clicked) {
var row = $(clicked).parents("tbody").first();
var input_id = $(row).find('[name="order.orderitems[].qty_as_number"]').attr('id');
- var formula_id = $(row).find('[name="formula"]').attr('id');
+ var formula_id = $(row).find('[name="formula[+]"]').attr('id');
- calculate_qty_selection_window("", input_id, "", formula_id);
+ calculate_qty_selection_dialog("", input_id, "", formula_id);
return true;
}
"Paste":"Einfügen",
"Paste template":"Vorlage einfügen",
"Please enter the new name:":"Bitte geben Sie den neuen Namen ein:",
+"Please enter values":"Bitte Werte eingeben",
"Please select a customer.":"Bitte wählen Sie einen Kunden aus.",
"Please select a vendor.":"Bitte wählen Sie einen Lieferanten aus.",
"Price Types":"Preistypen",
"Paste":"",
"Paste template":"",
"Please enter the new name:":"",
+"Please enter values":"",
"Please select a customer.":"",
"Please select a vendor.":"",
"Price Types":"",
[%- USE T8 %]
[%- USE HTML %]
-<h1>[% title %]</h1>
-
- <form name="Form">
+ <form name="CalcQtyForm" id="calc_qty_form_id">
<input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]">
<input type="hidden" name="input_id" value="[% HTML.escape(input_id) %]">
<script type="text/javascript">
function calculate_qty() {
[%- FOREACH row = VARIABLES %]
- var [% row.name %] = parse_amount('[% MYCONFIG.numberformat %]', document.getElementsByName("[% row.name %]")[0].value);
+ var [% row.name %] = parse_amount('[% MYCONFIG.numberformat %]', $('#calc_qty_form_id #[% row.name %]').val());
[%- END %]
var result = [% formel %];
result = number_format(result, 2, '[% MYCONFIG.numberformat %]');
- if (document.Form.input_id.value) {
- window.opener.document.getElementById(document.Form.input_id.value).value = result;
+ if (document.CalcQtyForm.input_id.value) {
+ document.getElementById(document.CalcQtyForm.input_id.value).value = result;
} else {
- window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result;
+ document.getElementsByName(document.CalcQtyForm.input_name.value)[0].value = result;
}
- self.close();
+ $('#calc_qty_dialog').dialog('close');
}
function parse_amount(numberformat, amount) {
class="recalc reformat_number numeric") %]
[%- IF ITEM.part.formel -%]
[%- L.button_tag("kivi.Order.show_calculate_qty_dialog(this)", LxERP.t8("*/")) %]
- [%- L.hidden_tag("formula", ITEM.part.formel) -%]
+ [%- L.hidden_tag("formula[+]", ITEM.part.formel) -%]
[%- END -%]
</td>
<td>