Backport r12134 from trunk: fixes depth problems with static org_unit selector
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 10 Feb 2009 19:19:39 +0000 (19:19 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 10 Feb 2009 19:19:39 +0000 (19:19 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4_0@12136 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/org_tree_html_options.pl

index 475ead0..36c78c6 100644 (file)
@@ -6,6 +6,7 @@ use OpenSRF::System;
 use OpenILS::Utils::Fieldmapper;
 use OpenSRF::Utils::SettingsClient;
 use Unicode::Normalize;
+use Data::Dumper;
 
 die "usage: perl org_tree_html_options.pl <bootstrap_config> <output_file>" unless $ARGV[1];
 OpenSRF::System->bootstrap_client(config_file => $ARGV[0]);
@@ -17,6 +18,12 @@ Fieldmapper->import(IDL => OpenSRF::Utils::SettingsClient->new->config_value("ID
 my $ses = OpenSRF::AppSession->create("open-ils.actor");
 my $tree = $ses->request("open-ils.actor.org_tree.retrieve")->gather(1);
 
+my @types;
+my $aout = $ses->request("open-ils.actor.org_types.retrieve")->gather(1);
+foreach my $type (@$aout) {
+       $types[int($type->id)] = $type;
+}
+
 print_option($tree);
 
 $ses->disconnect();
@@ -28,7 +35,7 @@ sub print_option {
        my $node = shift;
        return unless ($node->opac_visible =~ /^[y1t]+/i);
 
-       my $depth = $node->ou_type - 1;
+       my $depth = $types[$node->ou_type]->depth;
        my $sname = entityize($node->shortname);
        my $name = entityize($node->name);
        my $kids = $node->children;