]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/extras/org_tree_js.pl
viewable mime time
[working/Evergreen.git] / Open-ILS / src / extras / org_tree_js.pl
1
2 # turns the orgTree and orgTypes into js files
3
4 use OpenSRF::AppSession;
5 use OpenSRF::System;
6 use JSON;
7 OpenSRF::System->bootstrap_client(config_file => "/pines/conf/bootstrap.conf");
8
9
10 my $ses = OpenSRF::AppSession->create("open-ils.search");
11 my $req = $ses->request("open-ils.search.actor.org_tree.slim.retrieve");
12 my $tree = $req->gather(1);
13
14 my $ses2 = OpenSRF::AppSession->create("open-ils.storage");
15 my $req2 = $ses2->request("open-ils.storage.direct.actor.org_unit_type.retrieve.all.atomic");
16 my $types = $req2->gather(1);
17
18
19 my $tree_string = JSON->perl2JSON($tree);
20 my $types_string = JSON->perl2JSON($types);
21
22 $tree_string =~ s/\"/\\\"/g;
23 $types_string =~ s/\"/\\\"/g;
24
25 $tree_string = "var globalOrgTree = JSON2js(\"$tree_string\");";
26 $types_string = "var globalOrgTypes = JSON2js(\"$types_string\");";
27
28 print "$tree_string\n\n$types_string\n";
29
30
31 $ses->disconnect();
32 $ses2->disconnect();