]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/summary.xul
Merge branch 'master' of git.evergreen-ils.org:Evergreen-DocBook into doc_consolidati...
[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 { font_helper(); my_init(); 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 { persist_helper(); 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 export_address(ev) {
80             var action = ev.originalTarget.id;
81             var a;
82             var p = g.summary.patron;
83             switch(document.popupNode.id) {
84                 case 'addr_export_mailing':
85                     a = g.summary.patron.mailing_address();
86                 break;
87                 case 'addr_export_physical':
88                     a = g.summary.patron.billing_address();
89                 break;
90             };
91
92             var parts = [
93                 p.first_given_name(), p.second_given_name(), p.family_name(),
94                 a.street1(), a.street2(), a.city(), a.county(),
95                 a.state(), a.post_code(), a.country()
96             ];
97             for (var i = 0; i < parts.length; i++)
98                 if (parts[i] == null) parts[i] = "";
99
100             var s = $("patronStrings").getFormattedString(
101                 'staff.patron.mailable_address_format', parts
102             );
103
104             switch(action) {
105                 case 'addr_export_copy':
106                     // Replace literal instances of '\n' and excessive whitespace.
107                     s = s.replace(/(\\n)+/g, "\r\n").replace(/ {2,}/g, " ");
108                     copy_to_clipboard(s);
109                 break;
110                 case 'addr_export_print':
111                     // Replace literal instances of '\n' and excessive whitespace.
112                     s = s.replace(/(\\n)+/g, "<br/>").replace(/ {2,}/g, " ");
113                     JSAN.use('util.print'); var print = new util.print('mail'); print.simple(s);
114                 break;
115             };
116         }
117     
118         function post_overlay() {
119             try {
120                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
121
122                 var patron_id = xul_param('id'); 
123                 var patron_bc = xul_param('barcode'); 
124
125                 JSAN.use('patron.summary'); g.summary = new patron.summary();
126                 g.summary.init( { 
127                     'barcode' : patron_bc,
128                     'id' : patron_id,
129                     'show_name' : xul_param('show_name'),
130                 } );
131
132                 window.refresh = function () { g.summary.retrieve(); }
133                 font_helper();
134             } catch(E) {
135                 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/summary.xul:post_overlay()', E]);
136                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
137                 alert(err_msg);
138             }
139         }
140     ]]>
141     </script>
142     
143     <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties"/>
144     <messagecatalog id="offlineStrings" src="/xul/server/locale/<!--#echo var='locale'-->/offline.properties"/>
145
146     <commandset id="patron_summary_cmds" />
147     <popupset id="patron_summary_popups" />
148
149     <box id="patron_summary_main" />
150
151 </window>
152