'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();
$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();
$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');
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');
}
-[% 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>