[% PROCESS inputs; BLOCK editor; root = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' WHERE parent_ou IS NULL ORDER BY name;'; q = 'SELECT * FROM ' _ table.findvalue('tablename') _ ' WHERE parent_ou = ? ORDER BY name;'; org_unit_type = DBI.tie('actor.org_unit_type', 'id') %] [% WRAPPER select name=input_prefix multi="multi" onchange='change_multihier_' _ table_alias _ '(this);'; depth = 0; FOR f = DBI.query(root); sel = 0; FOR v = current_value; sel = 1 IF v == f.id; LAST; END; INCLUDE option value=f.id content=f.name selected=sel; INCLUDE next_level parent_ou = f.id; END; END; END; BLOCK next_level; depth = depth + 1; x = depth; s = DBI.prepare(q); FOR f = s.execute(parent_ou); ou_t = f.ou_type; logme(["can_have_vols for ou_t", ,org_unit_type.$ou_t.can_have_vols]); IF org_unit_type.$ou_t.can_have_vols == 1; %] [% END; x = depth; val = ''; WHILE x > 0; val = val _ '  '; x = x - 1; END; selected = ''; FOR v = current_value; IF v == f.id; selected = 'selected'; LAST; END; END; INCLUDE option value=f.id content=val _ f.name id='mh_' _ f.id; INCLUDE next_level parent_ou = f.id; END; END; BLOCK display; org_units = DBI.tie('actor.org_unit', 'id'); list = []; FOR o = current_value; list.push(org_units.$o.name); END; list.join('
'); END; %]