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