Kunden/Lieferanten: UStId/Steuernr. eindeutig: Mandantenkonfiguration
[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       warehouses[[% WAREHOUSES_it.count - 1 %]]['bins'][0] = new Array();
14       warehouses[[% WAREHOUSES_it.count - 1 %]]['bins'][0]['description'] = "---";
15       warehouses[[% WAREHOUSES_it.count - 1 %]]['bins'][0]['id'] = "";
16       [% USE BINS_it = Iterator(warehouse.BINS) %][% FOREACH bin = BINS_it %]
17       warehouses[[% WAREHOUSES_it.count - 1 %]]['bins'][[% BINS_it.count %]] = new Array();
18       warehouses[[% WAREHOUSES_it.count - 1 %]]['bins'][[% BINS_it.count %]]['description'] = "[% JavaScript.escape(bin.description) %]";
19       warehouses[[% WAREHOUSES_it.count - 1 %]]['bins'][[% BINS_it.count %]]['id'] = [% bin.id %];
20       [% END %]
21       [% END %]
22
23       function warehouse_selected(warehouse_id, bin_id) {
24         var control = document.getElementById("bin_id");
25
26         for (var i = control.options.length - 1; i >= 0; i--) {
27           control.options[i] = null;
28         }
29
30         var warehouse_index = 0;
31
32         for (i = 0; i < warehouses.length; i++)
33           if (warehouses[i]['id'] == warehouse_id) {
34             warehouse_index = i;
35             break;
36           }
37
38         var warehouse = warehouses[warehouse_index];
39         var bin_index = 0;
40
41         for (i = 0; i < warehouse['bins'].length; i++)
42           if (warehouse['bins'][i]['id'] == bin_id) {
43             bin_index = i;
44             break;
45           }
46
47         for (i = 0; i < warehouse['bins'].length; i++) {
48           control.options[i] = new Option(warehouse['bins'][i]['description'], warehouse['bins'][i]['id']);
49         }
50
51
52         control.options[bin_index].selected = true;
53       }
54
55       $(function() {
56         warehouse_selected([% warehouse_id %], [% bin_id %]);
57       })
58     -->
59  </script>