E-Mail-Journal: Journal anzeigen, Eintrag anzeigen, Anhänge herunterladen
[kivitendo-erp.git] / templates / webpages / common / select_warehouse_bin.html
1 [%- USE T8 %]
2 [%- USE HTML %]
3 [%- USE LxERP %]
4 [%- USE JavaScript -%]
5  <script type="text/javascript" src="js/common.js"></script>
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>