Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6770b19a

Von Bernd Bleßmann vor mehr als 6 Jahren hinzugefügt

  • ID 6770b19ab3f0dc0d8b00f70d8aab74149354a181
  • Vorgänger 00402ae6
  • Nachfolger 34d35b6a

calculate_qty (Formel): auf Dialog umgestellt

Unterschiede anzeigen:

bin/mozilla/common.pl
181 181
  }, @header_sort;
182 182

  
183 183
  $form->{formel} = $formel;
184
  $form->{title}  = $locale->text("Please enter values");
185
  $form->header(no_layout => 1);
186
  print $form->parse_html_template("generic/calculate_qty", { "HEADER"    => \@header,
187
                                                              "VARIABLES" => \@variable, });
184
  my $html = $form->parse_html_template("generic/calculate_qty", { "HEADER"    => \@header,
185
                                                                   "VARIABLES" => \@variable, });
186
  print $::form->ajax_response_header, $html;
188 187

  
189 188
  $main::lxdebug->leave_sub();
190 189
}
bin/mozilla/io.pl
319 319
    my $qty_dec = ($form->{"qty_$i"} =~ /\.(\d+)/) ? length $1 : 2;
320 320

  
321 321
    $column_data{qty}  = $cgi->textfield(-name => "qty_$i", -size => 5, -class => "numeric", -value => $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec));
322
    $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_window('qty_$i', '', 'formel_$i', '')", -value => $locale->text('*/'))
322
    $column_data{qty} .= $cgi->button(-onclick => "calculate_qty_selection_dialog('qty_$i', '', 'formel_$i', '')", -value => $locale->text('*/'))
323 323
                       . $cgi->hidden(-name => "formel_$i", -value => $form->{"formel_$i"})
324 324
      if $form->{"formel_$i"};
325 325

  
js/calculate_qty.js
1
function calculate_qty_selection_window(input_name, input_id, formel_name, formel_id) {
2
  var parm = centerParms(600,500) + ",width=600,height=500,status=yes,scrollbars=yes";
3
  var action = "calculate_qty";
1
function calculate_qty_selection_dialog(input_name, input_id, formel_name, formel_id) {
2
  // The target input element is determined by it's dom id or by it's name.
3
  // The formula input element (the one containing the formula) is determined by it's dom id or by it's name.
4
  // If the id is not provided the name is used.
4 5
  if (formel_id) {
5 6
    var formel = $('#' + formel_id).val();
6 7
  } else {
7 8
    var formel = $('[name="' + formel_name + '"]').val();
8 9
  }
9
  url = "common.pl?" +
10
    "INPUT_ENCODING=UTF-8&" +
11
    "action=" + action + "&" +
12
    "input_name=" + encodeURIComponent(input_name) + "&" +
13
    "input_id="   + encodeURIComponent(input_id)   + "&" +
14
    "formel=" + encodeURIComponent(formel);
15
  //alert(url);
16
  window.open(url, "_new_generic", parm);
10
  var url  = "common.pl";
11
  var data = {
12
    action:     "calculate_qty",
13
    input_name: input_name,
14
    input_id:   input_id,
15
    formel:     formel
16
  };
17
  kivi.popup_dialog({
18
    id:     'calc_qty_dialog',
19
    url:    url,
20
    data:   data,
21
    dialog: {
22
      width:  500,
23
      height: 400,
24
      title:  kivi.t8('Please enter values'),
25
    }
26
  });
17 27
}
js/kivi.Order.js
626 626
  ns.show_calculate_qty_dialog = function(clicked) {
627 627
    var row = $(clicked).parents("tbody").first();
628 628
    var input_id = $(row).find('[name="order.orderitems[].qty_as_number"]').attr('id');
629
    var formula_id = $(row).find('[name="formula"]').attr('id');
629
    var formula_id = $(row).find('[name="formula[+]"]').attr('id');
630 630

  
631
    calculate_qty_selection_window("", input_id, "", formula_id);
631
    calculate_qty_selection_dialog("", input_id, "", formula_id);
632 632
    return true;
633 633
  }
634 634

  
js/locale/de.js
80 80
"Paste":"Einfügen",
81 81
"Paste template":"Vorlage einfügen",
82 82
"Please enter the new name:":"Bitte geben Sie den neuen Namen ein:",
83
"Please enter values":"Bitte Werte eingeben",
83 84
"Please select a customer.":"Bitte wählen Sie einen Kunden aus.",
84 85
"Please select a vendor.":"Bitte wählen Sie einen Lieferanten aus.",
85 86
"Price Types":"Preistypen",
js/locale/en.js
78 78
"Paste":"",
79 79
"Paste template":"",
80 80
"Please enter the new name:":"",
81
"Please enter values":"",
81 82
"Please select a customer.":"",
82 83
"Please select a vendor.":"",
83 84
"Price Types":"",
templates/webpages/generic/calculate_qty.html
1 1
[%- USE T8 %]
2 2
[%- USE HTML %]
3
<h1>[% title %]</h1>
4

  
5
 <form name="Form">
3
 <form name="CalcQtyForm" id="calc_qty_form_id">
6 4

  
7 5
  <input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]">
8 6
  <input type="hidden" name="input_id"   value="[% HTML.escape(input_id) %]">
......
37 35
 <script type="text/javascript">
38 36
   function calculate_qty() {
39 37
[%- FOREACH row = VARIABLES %]
40
     var [% row.name %] = parse_amount('[% MYCONFIG.numberformat %]', document.getElementsByName("[% row.name %]")[0].value);
38
     var [% row.name %] = parse_amount('[% MYCONFIG.numberformat %]', $('#calc_qty_form_id #[% row.name %]').val());
41 39
[%- END %]
42 40
     var result = [% formel %];
43 41
     result = number_format(result, 2, '[% MYCONFIG.numberformat %]');
44
     if (document.Form.input_id.value) {
45
       window.opener.document.getElementById(document.Form.input_id.value).value = result;
42
     if (document.CalcQtyForm.input_id.value) {
43
       document.getElementById(document.CalcQtyForm.input_id.value).value = result;
46 44
     } else {
47
       window.opener.document.getElementsByName(document.Form.input_name.value)[0].value = result;
45
       document.getElementsByName(document.CalcQtyForm.input_name.value)[0].value = result;
48 46
     }
49
     self.close();
47
     $('#calc_qty_dialog').dialog('close');
50 48
   }
51 49

  
52 50
   function parse_amount(numberformat, amount) {
templates/webpages/order/tabs/_row.html
55 55
                      class="recalc reformat_number numeric") %]
56 56
      [%- IF ITEM.part.formel -%]
57 57
        [%- L.button_tag("kivi.Order.show_calculate_qty_dialog(this)", LxERP.t8("*/")) %]
58
        [%- L.hidden_tag("formula", ITEM.part.formel) -%]
58
        [%- L.hidden_tag("formula[+]", ITEM.part.formel) -%]
59 59
      [%- END -%]
60 60
    </td>
61 61
    <td>

Auch abrufbar als: Unified diff