Lieferschein ein- und auslagern: sofort Mengenanzeige in entsprechender Zeile aktuali...
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 27 Dec 2010 16:11:12 +0000 (17:11 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 27 Dec 2010 16:14:52 +0000 (17:14 +0100)
Fix für Bug 1400.

bin/mozilla/do.pl
templates/webpages/do/set_stock_in_out.html

index cde1c60..2b1bdd9 100644 (file)
@@ -939,7 +939,7 @@ sub calculate_stock_in_out {
                                             'amount_unit' => $all_units->{$form->{"partunit_$i"}}->{base_unit},
                                             'conv_units'  => 'convertible_not_smaller',
                                             'max_places'  => 2);
-  $content    .= qq| <input type="button" onclick="open_stock_in_out_window('${in_out}', $i);" value="?">|;
+  $content     = qq|<span id="stock_in_out_qty_display_${i}">${content}</span> <input type="button" onclick="open_stock_in_out_window('${in_out}', $i);" value="?">|;
 
   $main::lxdebug->leave_sub();
 
@@ -1061,6 +1061,18 @@ sub display_stock_in_form {
   $main::lxdebug->leave_sub();
 }
 
+sub _stock_in_out_set_qty_display {
+  my $stock_info       = shift;
+  my $form             = $::form;
+  my $all_units        = AM->retrieve_all_units();
+  my $sum              = AM->sum_with_unit(map { $_->{qty}, $_->{unit} } @{ $stock_info });
+  $form->{qty_display} = $form->format_amount_units(amount      => $sum * 1,
+                                                    part_unit   => $form->{partunit},
+                                                    amount_unit => $all_units->{ $form->{partunit} }->{base_unit},
+                                                    conv_units  => 'convertible_not_smaller',
+                                                    max_places  => 2);
+}
+
 sub set_stock_in {
   $main::lxdebug->enter_sub();
 
@@ -1079,6 +1091,8 @@ sub set_stock_in {
 
   $form->{stock} = YAML::Dump($stock_info);
 
+  _stock_in_out_set_qty_display($stock_info);
+
   $form->header();
   print $form->parse_html_template('do/set_stock_in_out');
 
@@ -1172,6 +1186,8 @@ sub set_stock_out {
     stock_in_out_form();
 
   } else {
+    _stock_in_out_set_qty_display($stock_info);
+
     $form->header();
     print $form->parse_html_template('do/set_stock_in_out');
   }
index 36bbf7f..07e084d 100644 (file)
@@ -1,13 +1,14 @@
-[% USE HTML %]<body onload="on_load();">
+[% USE HTML %]
+[% USE L %]
+[% L.javascript_tag('jquery') %]
+<body onload="on_load();">
 
  <script type="text/javascript">
   <!--
       function on_load() {
-        var row    = document.getElementsByName("row")[0].value;
-        var stock  = document.getElementsByName("stock")[0].value;
-        var in_out = document.getElementsByName("in_out")[0].value;
-
-        window.opener.document.getElementsByName("stock_" + in_out + "_" + row)[0].value = stock;
+        var row = $('#row').attr('value');
+        window.opener.document.getElementsByName("stock_" + $('#in_out').attr('value') + "_" + row)[0].value = $('#stock').attr('value');
+        $(window.opener.document.getElementById("stock_in_out_qty_display_" + row)).html($('#qty_display').attr('value'));
 
         window.close();
       }
  </script>
 
  <form name="data">
-  <input type="hidden" name="row" value="[% HTML.escape(row) %]">
-  <input type="hidden" name="stock" value="[% HTML.escape(stock) %]">
-  <input type="hidden" name="in_out" value="[% HTML.escape(in_out) %]">
+  <input type="hidden" name="row" id="row" value="[% HTML.escape(row) %]">
+  <input type="hidden" name="stock" id="stock" value="[% HTML.escape(stock) %]">
+  <input type="hidden" name="in_out" id="in_out" value="[% HTML.escape(in_out) %]">
+  <input type="hidden" name="qty_display" id="qty_display" value="[% HTML.escape(qty_display) %]">
  </form>
 
 </body>