Erzeugnis fertigen: Standardlager des Erzeugnisses auswählen
[kivitendo-erp.git] / templates / webpages / wh / warehouse_selection_assembly.html
1 [%- USE T8 %]
2 [%- USE L %]
3 [%- USE HTML %][%- USE JavaScript %][%- USE LxERP %][%- USE P -%]
4 <h1>[% title %]</h1>
5
6  <script type="text/javascript">
7   <!--
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 %];
17       [% END %]
18       [% END %]
19
20       function warehouse_selected(warehouse_id, bin_id) {
21         var control = document.getElementById("bin_id");
22
23         for (var i = control.options.length - 1; i >= 0; i--) {
24           control.options[i] = null;
25         }
26
27         var warehouse_index = 0;
28
29         for (i = 0; i < warehouses.length; i++)
30           if (warehouses[i]['id'] == warehouse_id) {
31             warehouse_index = i;
32             break;
33           }
34
35         var warehouse = warehouses[warehouse_index];
36         var bin_index = 0;
37
38         for (i = 0; i < warehouse['bins'].length; i++)
39           if (warehouse['bins'][i]['id'] == bin_id) {
40             bin_index = i;
41             break;
42           }
43
44         for (i = 0; i < warehouse['bins'].length; i++) {
45           control.options[i] = new Option(warehouse['bins'][i]['description'], warehouse['bins'][i]['id']);
46         }
47
48
49         control.options[bin_index].selected = true;
50       }
51
52       $(function() {
53         warehouse_selected([% warehouse_id %], [% bin_id %]);
54       })
55     -->
56  </script>
57
58  <form name="Form" method="post" action="wh.pl">
59
60   <input type="hidden" name="nextsub" value="transfer_assembly">
61   <input type="hidden" name="update_nextsub" value="transfer_assembly_update_part">
62
63   [% IF saved_message %]
64   <p>[% saved_message %]</p>
65   [% END %]
66
67   <p>
68    <table>
69     <tr>
70      <th align="right" nowrap>[% 'Assembly' | $T8 %]</th>
71      <td>
72       [% P.part_picker("parts_id", parts_id, part_type="assembly", class="partpicker_fat_set_item initial_focus") %]
73      </td>
74     </tr>
75
76     <tr>
77      <th align="right" nowrap>[% 'Destination warehouse' | $T8 %]</th>
78      <td>
79       <select name="warehouse_id" id="warehouse_id" onchange="warehouse_selected(warehouses[this.selectedIndex]['id'], 0)">
80        [%- FOREACH warehouse = WAREHOUSES %]
81        <option value="[% HTML.escape(warehouse.id) %]"[% IF warehouse_id == warehouse.id %] selected[% END %]>[% warehouse.description %]</option>
82        [%- END %]
83       </select>
84      </td>
85     </tr>
86
87     <tr>
88      <th align="right" nowrap>[% 'Destination bin' | $T8 %]:</th>
89      <td><select id="bin_id" name="bin_id"></select></td>
90     </tr>
91
92     <tr>
93      <th align="right" nowrap>[% 'Charge number' | $T8 %]</th>
94      <td><input name="chargenumber" size="30" value="[% HTML.escape(chargenumber) %]"></td>
95     </tr>
96
97     [% IF INSTANCE_CONF.get_show_bestbefore %]
98     <tr>
99      <th align="right" nowrap>[% 'Best Before' | $T8 %]</th>
100      <td>
101       [% L.date_tag('bestbefore', bestbefore) %]
102      </td>
103     </tr>
104     [% END %]
105
106     <tr>
107      <th align="right" nowrap>[% 'Quantity' | $T8 %]</th>
108      <td>
109       <input name="qty" size="10" value="[% HTML.escape(LxERP.format_amount(qty)) %]">
110       <select name="unit">
111        [%- FOREACH unit = UNITS %]<option[% IF unit.selected %] selected[% END %]>[% HTML.escape(unit.name) %]</option>[% END %]
112       </select>
113      </td>
114     </tr>
115
116     <tr>
117      <th align="right" nowrap>[% 'Optional comment' | $T8 %]</th>
118      <td><input name="comment" size="30" value="[% HTML.escape(comment) %]"></td>
119     </tr>
120
121    </table>
122   </p>
123
124   <p>
125    <input type="submit" class="submit" name="action" id="update_button" value="[% 'Update' | $T8 %]">
126    [%- IF parts_id %]
127    <input type="submit" class="submit" name="action" value="[% 'Create Assembly' | $T8 %]">
128    [%- END %]
129   </p>
130  </form>
131
132 <script type='text/javascript'>
133 $(function(){
134   $('#parts_id').on('set_item:PartPicker', function(event, item) {
135     if (!item.warehouse_id)
136       return;
137
138     $('#warehouse_id').val(item.warehouse_id);
139     warehouse_selected(item.warehouse_id, item.bin_id);
140   });
141 })
142 </script>