]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/reporter/templates/widgets/lib-choose.multiselect
allow clone+edit of existing stage3 reports
[working/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                 sel = 0;
38                 FOR v = current_value;
39                         sel = 1 IF v == f.id;
40                         LAST;
41                 END;
42                 INCLUDE option value=f.id content=f.name selected=sel;
43                 INCLUDE next_level parent_ou = f.id;
44         END;
45 END;
46
47 BLOCK next_level;
48         depth = depth + 1;
49         x = depth;
50         s = DBI.prepare(q);
51         FOR f = s.execute(parent_ou);
52                 ou_t = f.ou_type;
53
54                 logme(["can_have_vols for ou_t", ,org_unit_type.$ou_t.can_have_vols]);
55
56                 IF org_unit_type.$ou_t.can_have_vols == 1;
57                         %]
58                         <script language="javascript">
59                                 multihier_[% table_alias %].push("mh_[% f.id %]");
60                         </script>
61                         [%
62                 END;
63
64                 x = depth;
65                 val = '';
66                 WHILE x > 0;
67                         val = val _ '&nbsp;&nbsp;';
68                         x = x - 1;
69                 END;
70
71                 selected = '';
72                 FOR v = current_value;
73                         IF v == f.id;
74                                 selected = 'selected';
75                                 LAST;
76                         END;
77                 END;
78                 INCLUDE option value=f.id content=val _ f.name id='mh_' _ f.id;
79                 INCLUDE next_level parent_ou = f.id;
80         END;
81 END;
82
83 %]