]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/circ_summary.xul
contentWindow wrapper to get around security
[Evergreen.git] / Open-ILS / xul / staff_client / server / circ / circ_summary.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Brief Bib Display -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
10 <?xml-stylesheet href="/xul/server/skin/patron_display.css" type="text/css"?>
11
12 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
13 <!-- LOCALIZATION -->
14 <!DOCTYPE window PUBLIC "" ""[
15         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
16 ]>
17
18 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
19 <!-- OVERLAYS -->
20 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
21
22 <window id="circ_circ_brief_win" 
23         onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
24         width="750" height="550"
25         xmlns:html="http://www.w3.org/1999/xhtml"
26         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
27
28         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
29         <!-- BEHAVIOR -->
30         <script type="text/javascript">
31                 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
32         </script>
33         <scripts id="openils_util_scripts"/>
34
35         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
36         <script>
37         <![CDATA[
38                 function $(id) { return document.getElementById(id); }
39
40                 var xulG = {};
41
42                 function my_init() {
43                         try {
44                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
45                                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
46                                 JSAN.errorLevel = "die"; // none, warn, or die
47                                 JSAN.addRepository('/xul/server/');
48                                 JSAN.use('util.error'); g.error = new util.error();
49                                 g.error.sdump('D_TRACE','my_init() for circ_circ_brief.xul');
50
51                                 g.copy_id = xul_param('copy_id',{'modal_xulG':true});
52                                 g.count = xul_param('count',{'modal_xulG':true});
53
54                                 JSAN.use('util.network'); g.network = new util.network();
55                                 JSAN.use('util.date');
56                                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
57
58                                 g.copy = g.network.simple_request('FM_ACP_RETRIEVE',[ g.copy_id ]);
59                                 if (typeof g.copy.ilsevent != 'undefined') throw(g.copy);
60                                 g.callnumber = g.network.simple_request('FM_ACN_RETRIEVE',[ g.copy.call_number() ]);
61                                 if (typeof g.callnumber.ilsevent != 'undefined') throw(g.callnumber);
62
63                                 $('top').setAttribute('src',urls.XUL_BIB_BRIEF);// + '?docid=' + g.callnumber.record());
64                                 get_contentWindow($('top')).xulG = { 'docid' : g.callnumber.record() };
65                                 $('mid').setAttribute('src',urls.XUL_COPY_SUMMARY); // + '?copy_id=' + g.copy.id());
66                                 get_contentWindow($('mid')).xulG = { 'copy_id' : g.copy.id() };
67
68                                 show_circs();
69
70                         } catch(E) {
71                                 g.error.standard_unexpected_error_alert('Error in circ_brief.xul, my_init()',E);
72                         }
73                 }
74
75                 function show_circs() {
76                         try {
77                                 $('r_last').disabled = true; $('r_all').disabled = true;        
78                                 g.circs = g.network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',
79                                         [ ses(), g.copy_id, g.count ]);
80                                 if (g.circs == null || typeof g.circs.ilsevent != 'undefined') throw(circs);
81                                 if (g.circs.length == 0) return;
82                                 //g.circs = g.circs.reverse(); /* put the most recent at the top */
83                                 $('r_last').disabled = false; $('r_all').disabled = false;      
84
85                                 var gb = $('circs');
86                                 for (var j = 0; j < g.circs.length; j++) {
87                                         var iframe = document.createElement('iframe');
88                                         iframe.setAttribute('style','overflow: none; min-height: 100px;');
89                                         iframe.setAttribute('flex','1');
90                                         gb.appendChild(iframe);
91                                         iframe.setAttribute('src', urls.XUL_CIRC_BRIEF); // + '?circ_id=' + g.circs[j].id() );
92                                         get_contentWindow(iframe).xulG = { 'circ_id' : g.circs[j].id() };
93                                 }
94                         } catch(E) {
95                                 g.error.standard_unexpected_error_alert('error showing circs',E);
96                         }
97                 }
98
99                 function retrieve_last() {
100                         try {
101                                 //g.data.fancy_prompt_data = js2JSON( [ g.circs[0].usr() ] );
102                                 //g.data.stash('fancy_prompt_data');
103                                 xulG.retrieve_these_patrons = [ g.circs[0].usr() ];
104                                 update_modal_xulG(xulG);
105                                 window.close();
106                         } catch(E) {
107                                 g.error.standard_unexpected_error_alert('retrieve_last',E);
108                         }
109                 }
110
111                 function retrieve_all() {
112                         try {
113                                 var patrons = []; var p_hash = {};
114                                 for (var i = 0; i < g.circs.length; i++) {
115                                         var usr = g.circs[i].usr();
116                                         if (typeof p_hash[usr] != 'undefined') { continue; }
117                                         p_hash[usr] = true;
118                                         patrons.push( function(a){return a;}(usr) );
119                                 }
120                                 //g.data.fancy_prompt_data = js2JSON(patrons);
121                                 //g.data.stash('fancy_prompt_data');
122                                 xulG.retrieve_these_patrons = patrons;
123                                 update_modal_xulG(xulG);
124                                 window.close();
125                         } catch(E) {
126                                 g.error.standard_unexpected_error_alert('retrieve_all',E);
127                         }
128                 }
129
130         ]]>
131         </script>
132
133         <vbox flex="1" style="overflow: auto;">
134                 <iframe id="top" style="overflow: auto;"/>
135                 <splitter><grippy/></splitter>
136                 <iframe id="mid" style="overflow: auto;"/>
137                 <splitter><grippy/></splitter>
138                 <groupbox flex="1" id="circs" style="overflow: auto;">
139                         <caption label="Last Few Circulations"/>
140                 </groupbox>
141                 <hbox>
142                         <button id="r_last" label="Retrieve Last Patron" accesskey="L" oncommand="retrieve_last();"/>
143                         <button id="r_all" label="Retrieve All These Patrons" accesskey="A" oncommand="retrieve_all();"/>
144                         <spacer flex="1"/>
145                         <button label="Done" accesskey="D" oncommand="window.close();"/>
146                 </hbox>
147         </vbox>
148
149 </window>
150