10 <script type="text/javascript"><!--
11 warehouses = new Array();
12 [% USE WAREHOUSES_it = Iterator(WAREHOUSES) %]
13 [% FOREACH warehouse = WAREHOUSES_it %]
14 warehouses[[% WAREHOUSES_it.count - 1 %]] = new Array();
15 warehouses[[% WAREHOUSES_it.count - 1 %]]['id'] = [% warehouse.id %];
16 warehouses[[% WAREHOUSES_it.count - 1 %]]['bins'] = new Array();
17 [% USE BINS_it = Iterator(warehouse.BINS) %]
18 [% FOREACH bin = BINS_it %]
19 warehouses[[% WAREHOUSES_it.count - 1%]]['bins'][[% BINS_it.count - 1 %]] = new Array();
20 warehouses[[% WAREHOUSES_it.count - 1%]]['bins'][[% BINS_it.count - 1 %]]['description'] = "[% JavaScript.escape(bin.description) %]";
21 warehouses[[% WAREHOUSES_it.count - 1%]]['bins'][[% BINS_it.count - 1 %]]['id'] = [% bin.id %];
25 function warehouse_selected(warehouse_id, bin_id) {
26 var control = document.getElementById("bin_id");
28 for (var i = control.options.length - 1; i >= 0; i--) {
29 control.options[i] = null;
32 var warehouse_index = 0;
34 for (i = 0; i < warehouses.length; i++)
35 if (warehouses[i]['id'] == warehouse_id) {
40 var warehouse = warehouses[warehouse_index];
43 for (i = 0; i < warehouse['bins'].length; i++)
44 if (warehouse['bins'][i]['id'] == bin_id) {
49 for (i = 0; i < warehouse['bins'].length; i++) {
50 control.options[i] = new Option(warehouse['bins'][i]['description'], warehouse['bins'][i]['id']);
54 control.options[bin_index].selected = true;
58 warehouse_selected([% warehouse_id %], [% bin_id %]);
62 <form name="Form" method="post" action="wh.pl" id="form">
65 [% IF saved_message %]
66 <p>[% saved_message %]</p>
70 <table class="tbl-horizontal">
73 <th>[% 'Assembly' | $T8 %]</th>
74 <td>[% P.part.picker("parts_id", parts_id, part_type="assembly", class="initial_focus wi-lightwide", fat_set_item="1") %] </td>
77 <th>[% 'Destination warehouse' | $T8 %]</th>
79 <select name="warehouse_id" id="warehouse_id" onchange="warehouse_selected(warehouses[this.selectedIndex]['id'], 0)" class="wi-lightwide">
80 [% FOREACH warehouse = WAREHOUSES %]
81 <option value="[% HTML.escape(warehouse.id) %]"[% IF warehouse_id == warehouse.id %] selected[% END %]>[% warehouse.description %]</option>
87 <th>[% 'Destination bin' | $T8 %]</th>
88 <td><select id="bin_id" name="bin_id" class="wi-lightwide"></select></td>
91 <th>[% 'Charge number' | $T8 %]</th>
92 <td><input type="text" name="chargenumber" class="wi-lightwide" value="[% HTML.escape(chargenumber) %]"></td>
94 [% IF INSTANCE_CONF.get_show_bestbefore %]
96 <th>[% 'Best Before' | $T8 %]</th>
97 <td><span class="wi-date">[% L.date_tag('bestbefore', bestbefore) %]</span> </td>
101 <th>[% 'Quantity' | $T8 %]</th>
103 <input type="text" name="qty" class="wi-verysmall" value="[% HTML.escape(LxERP.format_amount(qty)) %]">
104 <select name="unit" class="wi-small">
105 [% FOREACH unit = UNITS %]
106 <option[% IF unit.selected %] selected[% END %]>[% HTML.escape(unit.name) %]</option>
112 <th>[% 'Optional comment' | $T8 %]</th>
113 <td><input type="text" name="comment" class="wi-lightwide" value="[% HTML.escape(comment) %]">
122 <script type='text/javascript'>
124 $('#parts_id').on('set_item:PartPicker', function(event, item) {
125 if (!item.warehouse_id)
128 $('#warehouse_id').val(item.warehouse_id);
129 warehouse_selected(item.warehouse_id, item.bin_id);