Rip modal_xulG_stack out, replace with openDialog
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / circ / copy_details.xul
1 <?xml version="1.0" encoding="UTF-8"?>
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="/xul/server/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/patron_display.css" type="text/css"?>
10
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!-- LOCALIZATION -->
13 <!DOCTYPE window PUBLIC "" ""[
14     <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
15 ]>
16
17 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
18 <!-- OVERLAYS -->
19 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
20
21 <window id="circ_copy_details_win" 
22     onload="try { my_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }"
23     width="800" height="600" oils_persist="width height"
24     xmlns:html="http://www.w3.org/1999/xhtml"
25     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
26
27     <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
28     <!-- BEHAVIOR -->
29         <script type="text/javascript">
30         var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
31     </script>
32         <scripts id="openils_util_scripts"/>
33
34     <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
35     <script>
36     <![CDATA[
37         function $(id) { return document.getElementById(id); }
38
39         var xulG = {};
40
41         function my_init() {
42             try {
43                 if (typeof JSAN == 'undefined') { 
44                     throw( document.getElementById("commonStrings").getString('common.jsan.missing') );
45                 }
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_copy_details.xul');
50
51                 g.copy_id = xul_param('copy_id');
52
53                 JSAN.use('util.network'); g.network = new util.network();
54                 JSAN.use('util.date');
55                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
56
57                 // uber method
58                 var robj = g.network.simple_request('FM_ACP_DETAILS', [ ses(), g.copy_id ] );
59                 if (typeof robj.ilsevent != 'undefined') {
60                     throw(robj);
61                 }
62                 if (robj.copy) {
63                     g.copy = robj.copy;
64                 } else {
65                     throw(robj);
66                 }
67                 g.hold = robj.hold; g.transit = robj.transit; g.circ = robj.circ; g.callnumber = robj.volume;
68                 var tt_msg = '';
69                 if (g.hold) {
70                     tt_msg = $('circStrings').getFormattedString('staff.circ.copy_details.hold', [g.hold.id()]);
71                     $('hold_caption').setAttribute('tooltiptext', tt_msg);
72                 }
73                 if (g.transit) {
74                     tt_msg = $('circStrings').getFormattedString('staff.circ.copy_details.transit', [g.transit.id()]);
75                     $('transit_caption').setAttribute('tooltiptext', tt_msg);
76                 }
77                 if (g.circ) {
78                     tt_msg = $('circStrings').getFormattedString('staff.circ.copy_details.circ', [g.circ.id()]);
79                     $('circ_caption').setAttribute('tooltiptext', tt_msg);
80                 }
81
82                 //g.callnumber = g.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ g.copy.call_number() ]);
83                 //if (typeof g.callnumber.ilsevent != 'undefined') throw(g.callnumber);
84
85                 var tb = $('top_box'); while (tb.firstChild) tb.removeChild(tb.lastChild);
86                 var top = document.createElement('iframe'); tb.appendChild(top);
87                 top.setAttribute('src',urls.XUL_BIB_BRIEF);
88                 top.setAttribute('flex','1');
89                 get_contentWindow(top).xulG = { 'docid' : g.callnumber.record() };
90                 //g.data.temp_copy = g.copy; g.data.stash('temp_copy'); 
91                 //g.data.temp_callnumber = g.callnumber; g.data.stash('temp_callnumber'); 
92                 var ib = $('item_summary_box'); while(ib.firstChild) ib.removeChild(ib.lastChild);
93                 var item_summary = document.createElement('iframe'); ib.appendChild(item_summary);
94                 item_summary.setAttribute('src',urls.XUL_COPY_SUMMARY);
95                 item_summary.setAttribute('flex','1');
96                 get_contentWindow(item_summary).xulG = { 'copy' : g.copy, 'callnumber' : g.callnumber, 'new_tab' : xulG.new_tab, 'url_prefix' : xulG.url_prefix };
97
98                 $('r_last').disabled = true;
99                 if (g.circ) {
100                     $('r_last').disabled = false;
101                     g.data.temp_circ = g.circ; g.data.stash('temp_circ');
102                     var cb = $('circ_box'); while(cb.firstChild) cb.removeChild(cb.lastChild);
103                     var circ_frame = document.createElement('iframe'); cb.appendChild(circ_frame);
104                     circ_frame.setAttribute('src',urls.XUL_CIRC_BRIEF);
105                     circ_frame.setAttribute('flex','1');
106                     get_contentWindow(circ_frame).xulG = { 'no_border' : 1 };
107                     if (g.circ.checkin_time()) {
108                         $('circ_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.last_circ'));
109                     } else {
110                         $('circ_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.current_circ'));
111                     }
112                 } else {
113                     $('circ_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.no_circ'));
114                 }
115
116                 if (g.transit) {
117                     JSAN.use('circ.util'); var columns = circ.util.transit_columns({});
118
119                     JSAN.use('util.list'); g.list = new util.list('transit');
120                     g.list.init( { 'columns' : columns });
121                     g.list.append( { 'row' : { 'my' : { 'atc' : g.transit, } } });
122     
123                 } else {
124                     $('transit_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.not_transit'));
125                     $('transit').hidden = true;
126                 }
127
128
129                 $('r_hold').disabled = true;
130                 if (g.hold) {
131                     $('r_hold').disabled = false;
132                     var better_fleshed_hold_blob = g.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative',[ ses(), g.hold.id() ]);
133                     var status_robj = better_fleshed_hold_blob.status;
134                     JSAN.use('circ.util');
135                     var columns = circ.util.hold_columns( 
136                         { 
137                             'request_time' : { 'hidden' : false },
138                             'pickup_lib_shortname' : { 'hidden' : false },
139                             'hold_type' : { 'hidden' : true },
140                             'current_copy' : { 'hidden' : true },
141                             'capture_time' : { 'hidden' : true },
142                             'email_notify' : { 'hidden' : false },
143                             'phone_notify' : { 'hidden' : false },
144                         } 
145                     );
146
147                     JSAN.use('util.list'); g.list = new util.list('hold');
148                     g.list.init( { 'columns' : columns });
149                     g.list.append( { 'row' : { 'my' : { 'ahr' : better_fleshed_hold_blob.hold, 'acp' : g.copy, 'status' : status_robj, } } });
150     
151                     JSAN.use('patron.util'); 
152                     var au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), g.hold.usr() );
153                     $('patron_name').setAttribute('value', $('circStrings').getFormattedString('staff.circ.copy_details.user_details', [au_obj.family_name(), au_obj.first_given_name(), au_obj.card().barcode()]) );
154
155                 } else {
156                     if (g.copy.status() == 8 /* ON HOLDS SHELF */) {
157                         $('hold_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.bad_hold_status'));
158                     } else {
159                         $('hold_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.no_hold'));
160                     }
161                     $('hold').hidden = true;
162                 }
163
164             } catch(E) {
165                 g.error.standard_unexpected_error_alert('Error in copy_details.xul, my_init()',E);
166             }
167         }
168
169         function retrieve_last_patron() {
170             try {
171                 //g.data.fancy_prompt_data = js2JSON( [ g.circ.usr() ] );
172                 //g.data.stash('fancy_prompt_data');
173                 xulG.retrieve_these_patrons = [ g.circ.usr() ];
174                 window.close();
175             } catch(E) {
176                 alert(E);
177             }
178         }
179
180         function retrieve_hold_patron() {
181             try {
182                 //g.data.fancy_prompt_data = js2JSON( [ g.hold.usr() ] );
183                 //g.data.stash('fancy_prompt_data');
184                 xulG.retrieve_these_patrons = [ g.hold.usr() ];
185                 window.close();
186             } catch(E) {
187                 alert(E);
188             }
189         }
190
191     ]]>
192     </script>
193
194     <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
195
196     <vbox flex="1" style="overflow: auto;">
197         <vbox id="top_box" flex="1" style="border: none; overflow: none; min-height: 80;" oils_persist="height"/>
198         <splitter id="splitter1" oils_persist="state hidden" oils_persist_peers="top_box item_summary_box"><grippy/></splitter>
199         <vbox id="item_summary_box" flex="1" style="border: none; overflow: none; min-height: 80;" oils_persist="height"/>
200         <splitter id="splitter2" oils_persist="state hidden" oils_persist_peers="item_summary_box holds"><grippy/></splitter>
201         <groupbox flex="1" id="holds" style="overflow: none; min-height: 80;" oils_persist="height">
202             <caption id="hold_caption" label="&staff.circ.copy_details.hold_caption;"/>
203             <label id="patron_name" class="patronNameLarge"/>
204             <tree id="hold" flex="1" enableColumnDrag="true"/>
205             <spacer FIXME="label and tree get swapped without this"/>
206         </groupbox>
207         <splitter id="splitter3" oils_persist="state hidden" oils_persist_peers="holds transits"><grippy/></splitter>
208         <groupbox flex="1" id="transits" style="overflow: none; min-height: 80;" oils_persist="height">
209             <caption id="transit_caption" label="&staff.circ.copy_details.transit_caption;"/>
210             <tree id="transit" flex="1" enableColumnDrag="true"/>
211         </groupbox>
212         <splitter id="splitter4" oils_persist="state hidden" oils_persist_peers="transits circs"><grippy/></splitter>
213         <groupbox flex="1" id="circs" style="overflow: none; min-height: 80;" oils_persist="height">
214             <caption id="circ_caption" label="&staff.circ.copy_details.circ_caption;" style="font-weight: bold"/>
215             <vbox id="circ_box" flex="1" style="min-height: 80"/>
216         </groupbox>
217     </vbox>
218     <hbox>
219         <button id="r_last" label="&staff.circ.copy_details.r_last.label;" accesskey="&staff.circ.copy_details.r_last.accesskey;" oncommand="retrieve_last_patron();"/>
220         <button id="r_hold" label="&staff.circ.copy_details.r_hold.label;" accesskey="&staff.circ.copy_details.r_hold.accesskey;" oncommand="retrieve_hold_patron();"/>
221         <spacer flex="1"/>
222         <button id="done" label="&staff.circ.copy_details.done.label;" accesskey="&staff.circ.copy_details.done.accesskey;" oncommand="window.close();"/>
223     </hbox>
224
225 </window>
226