]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/summary.xul
cee959b03a73ae39e87fa53989ca9123e14c06fd
[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                 var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
41                 observerService.addObserver(this, "xul-overlay-merged", false);
42             },
43             unregister: function() {
44                 var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
45                 observerService.removeObserver(this, "xul-overlay-merged");
46             },
47             observe: function(subject,topic,data) {
48                 dump('observe: <'+subject+','+topic+','+data+'>\n');
49                 // setTimeout is needed here for xulrunner 1.8
50                 setTimeout( function() { try { persist_helper(); post_overlay(); } catch(E) { alert(E); } }, 0 );
51             }
52         }
53                 
54         function my_init() {
55             try {
56                 if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
57                 JSAN.errorLevel = "die"; // none, warn, or die
58                 JSAN.addRepository('/xul/server/');
59                 JSAN.use('util.error'); g.error = new util.error();
60                 g.error.sdump('D_TRACE','my_init() for patron_summary.xul');
61                 
62                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
63                 
64                 var horizontal_interface = String( g.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
65                 var url = horizontal_interface ? '/xul/server/patron/summary_overlay_horiz.xul' : '/xul/server/patron/summary_overlay.xul';
66                 
67                 observer = new myObserver();
68                 document.loadOverlay(location.protocol + '//' + location.hostname + url,observer)
69             } catch(E) {
70                 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/summary.xul:my_init()', E]);
71                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
72                 alert(err_msg);
73             }
74         }
75
76         function export_address(ev) {
77             var action = ev.originalTarget.id;
78             var a;
79             var p = g.summary.patron;
80             switch(document.popupNode.id) {
81                 case 'addr_export_mailing':
82                     a = g.summary.patron.mailing_address();
83                 break;
84                 case 'addr_export_physical':
85                     a = g.summary.patron.billing_address();
86                 break;
87             };
88
89             var parts = [
90                 p.first_given_name(), p.second_given_name(), p.family_name(),
91                 a.street1(), a.street2(), a.city(), a.county(),
92                 a.state(), a.post_code(), a.country()
93             ];
94             for (var i = 0; i < parts.length; i++)
95                 if (parts[i] == null) parts[i] = "";
96
97             var s = $("patronStrings").getFormattedString(
98                 'staff.patron.mailable_address_format', parts
99             );
100
101             switch(action) {
102                 case 'addr_export_copy':
103                     // Replace literal instances of '\n' and excessive whitespace.
104                     s = s.replace(/(\\n)+/g, "\r\n").replace(/ {2,}/g, " ");
105                     copy_to_clipboard(s);
106                 break;
107                 case 'addr_export_print':
108                     // Replace literal instances of '\n' and excessive whitespace.
109                     s = s.replace(/(\\n)+/g, "<br/>").replace(/ {2,}/g, " ");
110                     JSAN.use('util.print'); var print = new util.print('mail'); print.simple(s);
111                 break;
112             };
113         }
114     
115         function post_overlay() {
116             try {
117                 var patron_id = xul_param('id'); 
118                 var patron_bc = xul_param('barcode'); 
119
120                 JSAN.use('patron.summary'); g.summary = new patron.summary();
121                 g.summary.init( { 
122                     'barcode' : patron_bc,
123                     'id' : patron_id,
124                     'show_name' : xul_param('show_name'),
125                 } );
126
127                 window.refresh = function () { g.summary.retrieve(); }
128                 font_helper();
129             } catch(E) {
130                 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/summary.xul:post_overlay()', E]);
131                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
132                 alert(err_msg);
133             }
134         }
135     ]]>
136     </script>
137     
138     <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties"/>
139     <messagecatalog id="offlineStrings" src="/xul/server/locale/<!--#echo var='locale'-->/offline.properties"/>
140
141     <commandset id="patron_summary_cmds" />
142     <popupset id="patron_summary_popups" />
143
144     <box id="patron_summary_main" />
145
146 </window>
147