3 [%- USE HTML %][%- USE JavaScript %][%- USE LxERP %][%- USE P -%]
 
   6  <script type="text/javascript">
 
   8       warehouses = new Array();
 
   9       [%- USE WAREHOUSES_it = Iterator(WAREHOUSES) %][%- FOREACH warehouse = WAREHOUSES_it %]
 
  10       warehouses[[% WAREHOUSES_it.count - 1 %]] = new Array();
 
  11       warehouses[[% WAREHOUSES_it.count - 1 %]]['id'] = [% warehouse.id %];
 
  12       warehouses[[% WAREHOUSES_it.count - 1 %]]['bins'] = new Array();
 
  13       [% USE BINS_it = Iterator(warehouse.BINS) %][% FOREACH bin = BINS_it %]
 
  14       warehouses[[% WAREHOUSES_it.count - 1%]]['bins'][[% BINS_it.count - 1 %]] = new Array();
 
  15       warehouses[[% WAREHOUSES_it.count - 1%]]['bins'][[% BINS_it.count - 1 %]]['description'] = "[% JavaScript.escape(bin.description) %]";
 
  16       warehouses[[% WAREHOUSES_it.count - 1%]]['bins'][[% BINS_it.count - 1 %]]['id'] = [% bin.id %];
 
  20       function warehouse_selected(warehouse_id, bin_id) {
 
  21         var control = document.getElementById("bin_id");
 
  23         for (var i = control.options.length - 1; i >= 0; i--) {
 
  24           control.options[i] = null;
 
  27         var warehouse_index = 0;
 
  29         for (i = 0; i < warehouses.length; i++)
 
  30           if (warehouses[i]['id'] == warehouse_id) {
 
  35         var warehouse = warehouses[warehouse_index];
 
  38         for (i = 0; i < warehouse['bins'].length; i++)
 
  39           if (warehouse['bins'][i]['id'] == bin_id) {
 
  44         for (i = 0; i < warehouse['bins'].length; i++) {
 
  45           control.options[i] = new Option(warehouse['bins'][i]['description'], warehouse['bins'][i]['id']);
 
  49         control.options[bin_index].selected = true;
 
  53         warehouse_selected([% warehouse_id %], [% bin_id %]);
 
  58  <form name="Form" method="post" action="wh.pl" id="form">
 
  60   [% IF saved_message %]
 
  61   <p>[% saved_message %]</p>
 
  67      <th align="right" nowrap>[% 'Assembly' | $T8 %]</th>
 
  69       [% P.part.picker("parts_id", parts_id, part_type="assembly", class="initial_focus", fat_set_item="1") %]
 
  74      <th align="right" nowrap>[% 'Destination warehouse' | $T8 %]</th>
 
  76       <select name="warehouse_id" id="warehouse_id" onchange="warehouse_selected(warehouses[this.selectedIndex]['id'], 0)">
 
  77        [%- FOREACH warehouse = WAREHOUSES %]
 
  78        <option value="[% HTML.escape(warehouse.id) %]"[% IF warehouse_id == warehouse.id %] selected[% END %]>[% warehouse.description %]</option>
 
  85      <th align="right" nowrap>[% 'Destination bin' | $T8 %]:</th>
 
  86      <td><select id="bin_id" name="bin_id"></select></td>
 
  90      <th align="right" nowrap>[% 'Charge number' | $T8 %]</th>
 
  91      <td><input name="chargenumber" size="30" value="[% HTML.escape(chargenumber) %]"></td>
 
  94     [% IF INSTANCE_CONF.get_show_bestbefore %]
 
  96      <th align="right" nowrap>[% 'Best Before' | $T8 %]</th>
 
  98       [% L.date_tag('bestbefore', bestbefore) %]
 
 104      <th align="right" nowrap>[% 'Quantity' | $T8 %]</th>
 
 106       <input name="qty" size="10" value="[% HTML.escape(LxERP.format_amount(qty)) %]">
 
 108        [%- FOREACH unit = UNITS %]<option[% IF unit.selected %] selected[% END %]>[% HTML.escape(unit.name) %]</option>[% END %]
 
 114      <th align="right" nowrap>[% 'Optional comment' | $T8 %]</th>
 
 115      <td><input name="comment" size="30" value="[% HTML.escape(comment) %]"></td>
 
 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);