]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/reporter/templates/widgets/lib-choose.dropdown
4d27612d600e4366eb317163c91ffce09da378a7
[Evergreen.git] / Open-ILS / src / reporter / templates / widgets / lib-choose.dropdown
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 hier_[% table_alias %] = [];
16
17         function change_hier_[% table_alias %] ( sel ) {
18                 for (var i in hier_[% table_alias %]) {
19                         if (hier_[% table_alias %][i] == sel.options[sel.selectedIndex].id) {
20                                 return true;
21                         }
22                 }
23                 sel.selectedIndex = null;
24                 return false;
25         }
26 </script>
27
28 [%
29
30 WRAPPER select id=input_prefix name=input_prefix onchange='change_hier_' _ table_alias _ '(this);';
31         depth = 0;
32         INCLUDE option value='' content='Select One';
33         INCLUDE option value='' content='----------';
34         FOR f = DBI.query(root);
35                 INCLUDE option value=f.$fieldname;
36                 INCLUDE next_level parent_ou = f.id depth;
37         END;
38 END;
39
40
41 BLOCK next_level;
42         depth = depth + 1;
43         x = depth;
44         s = DBI.prepare(q);
45         FOR f = s.execute(parent_ou);
46                 ou_t = f.ou_type;
47
48                 logme(["can_have_vols for ou_t", ,org_unit_type.$ou_t.can_have_vols]);
49
50                 IF org_unit_type.$ou_t.can_have_vols == 1;
51                         %]
52                         <script language="javascript">
53                                 hier_[% table_alias %].push("dr_[% f.id %]");
54                         </script>
55                         [%
56                 END;
57
58                 x = depth;
59                 val = '';
60                 WHILE x > 0;
61                         val = val _ '&nbsp;&nbsp;';
62                         x = x - 1;
63                 END;
64
65                 INCLUDE option value=f.name content=val _ f.name id='dr_' _ f.id;
66                 INCLUDE next_level parent_ou = f.id;
67         END;
68 END;
69
70 %]