]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/reporter/templates/widgets/lib-choose.multiselect
05c57b6f583659db85c32ecb547f2e0322a088ab
[Evergreen.git] / Open-ILS / src / reporter / templates / widgets / lib-choose.multiselect
1 [%
2
3 PROCESS inputs;
4
5 root = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' WHERE parent_ou IS NULL ORDER BY name;';
6 q = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' WHERE parent_ou = ? ORDER BY name;';
7
8 org_unit_type = DBI.tie('actor.org_unit_type', 'id')
9
10 %]
11
12 <script language="javascript">
13         filters["[% input_prefix %]"] = "[% table_label _ ' -- ' _ field.findvalue('label') %]";
14
15         var multihier_[% table_alias %] = [];
16
17         function change_multihier_[% table_alias %] ( sel ) {
18                 for (var i = 0; i < sel.options.length; i++) {
19                         if (sel.options[i].selected) {
20                                 sel.options[i].selected = false;
21                                 for (var j in multihier_[% table_alias %]) {
22                                         if (multihier_[% table_alias %][j] == sel.options[i].id) {
23                                                 sel.options[i].selected = true
24                                                 continue;
25                                         }
26                                 }
27                         }
28                 }
29         }
30 </script>
31
32 [%
33
34 WRAPPER select name=input_prefix multi="multi" onchange='change_multihier_' _ table_alias _ '(this);';
35         depth = 0;
36         FOR f = DBI.query(root);
37                 INCLUDE option value=f.id content=f.name;
38                 INCLUDE next_level parent_ou = f.id depth;
39         END;
40 END;
41
42 BLOCK next_level;
43         depth = depth + 1;
44         x = depth;
45         s = DBI.prepare(q);
46         FOR f = s.execute(parent_ou);
47                 ou_t = f.ou_type;
48
49                 logme(["can_have_vols for ou_t", ,org_unit_type.$ou_t.can_have_vols]);
50
51                 IF org_unit_type.$ou_t.can_have_vols == 1;
52                         %]
53                         <script language="javascript">
54                                 multihier_[% table_alias %].push("mh_[% f.id %]");
55                         </script>
56                         [%
57                 END;
58
59                 x = depth;
60                 val = '';
61                 WHILE x > 0;
62                         val = val _ '&nbsp;&nbsp;';
63                         x = x - 1;
64                 END;
65
66                 INCLUDE option value=f.id content=f.name content=val _ f.name id='mh_' _ f.id;
67                 INCLUDE next_level parent_ou = f.id;
68         END;
69 END;
70
71 %]