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