]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/summary.xul
quick links for copying address info to the clipboard in tab-delimited format
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / patron / summary.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Patron 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 <?xml-stylesheet href="/xul/server/skin/patron_summary.css" type="text/css"?>
12
13 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
14 <!-- LOCALIZATION -->
15 <!DOCTYPE window PUBLIC "" ""[
16         <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
17 ]>
18
19 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
20 <!-- OVERLAYS -->
21 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
22
23 <window id="patron_summary_win" 
24         onload="try { my_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }" onunload="try { observer.unregister(); } catch(E) { alert(E); }"
25         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
26
27         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
28         <!-- BEHAVIOR -->
29         <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
30         <scripts id="openils_util_scripts"/>
31
32         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
33         <script>
34         <![CDATA[
35                 function $(id) { return document.getElementById(id); }
36                 
37                 var observer;
38                 function myObserver() { this.register(); }
39                 myObserver.prototype = {
40                         register: function() {
41                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
42                                 var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
43                                 observerService.addObserver(this, "xul-overlay-merged", false);
44                         },
45                         unregister: function() {
46                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
47                                 var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
48                                 observerService.removeObserver(this, "xul-overlay-merged");
49                         },
50                         observe: function(subject,topic,data) {
51                                 dump('observe: <'+subject+','+topic+','+data+'>\n');
52                                 // setTimeout is needed here for xulrunner 1.8
53                                 setTimeout( function() { try { post_overlay(); } catch(E) { alert(E); } }, 0 );
54                         }
55                 }
56                                 
57                 function my_init() {
58                         try {
59                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
60                                 if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
61                                 JSAN.errorLevel = "die"; // none, warn, or die
62                                 JSAN.addRepository('/xul/server/');
63                                 JSAN.use('util.error'); g.error = new util.error();
64                                 g.error.sdump('D_TRACE','my_init() for patron_summary.xul');
65                                 
66                                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
67                                 
68                                 var horizontal_interface = String( g.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
69                                 var url = horizontal_interface ? '/xul/server/patron/summary_overlay_horiz.xul' : '/xul/server/patron/summary_overlay.xul';
70                                 
71                                 observer = new myObserver();
72                                 document.loadOverlay(location.protocol + '//' + location.hostname + url,observer)
73                         } catch(E) {
74                                 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/summary.xul:my_init()', E]);
75                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
76                                 alert(err_msg);
77                         }
78                 }
79
80         function copy_mailing_address() {
81             var a = g.summary.patron.mailing_address();
82             if (!a) return;
83             copy_to_clipboard(
84                 (a.street1() ? a.street1() : "") + "\t" + 
85                 (a.street2() ? a.street2() : "") + "\t" +  
86                 (a.county() ? a.county() : "") + "\t" + 
87                 (a.city() ? a.city() : "") + "\t" +  
88                 (a.post_code() ? a.post_code() : "") + "\t" + 
89                 (a.country() ? a.country() : "")
90             );
91         }
92         
93         function copy_billing_address() {
94             var a = g.summary.patron.billing_address();
95             if (!a) return;
96             copy_to_clipboard(
97                 (a.street1() ? a.street1() : "") + "\t" + 
98                 (a.street2() ? a.street2() : "") + "\t" +  
99                 (a.county() ? a.county() : "") + "\t" + 
100                 (a.city() ? a.city() : "") + "\t" +  
101                 (a.post_code() ? a.post_code() : "") + "\t" + 
102                 (a.country() ? a.country() : "")
103             );
104         }
105         
106                 function post_overlay() {
107                         try {
108                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
109
110                                 var patron_id = xul_param('id'); 
111                                 var patron_bc = xul_param('barcode'); 
112
113                                 JSAN.use('patron.summary'); g.summary = new patron.summary();
114                                 g.summary.init( { 
115                                         'barcode' : patron_bc,
116                                         'id' : patron_id,
117                                         'show_name' : xul_param('show_name'),
118                                 } );
119
120                                 window.refresh = function () { g.summary.retrieve(); }
121                                 font_helper();
122                         } catch(E) {
123                                 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/summary.xul:post_overlay()', E]);
124                                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
125                                 alert(err_msg);
126                         }
127                 }
128         ]]>
129         </script>
130         
131         <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties"/>
132
133         <commandset id="patron_summary_cmds">
134         </commandset>
135
136         <box id="patron_summary_main" />
137
138 </window>
139