]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/copy_summary.xul
explicit number casting for JSON results
[Evergreen.git] / Open-ILS / xul / staff_client / server / cat / copy_summary.xul
1 <?xml version="1.0"?>
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="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
10
11 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
12 <!-- LOCALIZATION -->
13 <!DOCTYPE window PUBLIC "" ""[
14         <!--#include virtual="/opac/locale/en-US/lang.dtd"-->
15 ]>
16
17 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
18 <!-- OVERLAYS -->
19 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
20
21 <window id="cat_copy_summary_win" 
22         onload="try { my_init(); font_helper(); } catch(E) { alert(E); }"
23         xmlns:html="http://www.w3.org/1999/xhtml"
24         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
25
26         <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
27         <!-- BEHAVIOR -->
28         <script type="text/javascript">
29                 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
30         </script>
31         <scripts id="openils_util_scripts"/>
32
33         <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
34         <script>
35         <![CDATA[
36                 function $(id) { return document.getElementById(id); }
37                 function $w(id,text) { if ($(id)) util.widgets.set_text($(id),text); }
38
39                 function my_init() {
40                         try {
41                                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
42                                 if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
43                                 JSAN.errorLevel = "die"; // none, warn, or die
44                                 JSAN.addRepository('/xul/server/');
45                                 JSAN.use('util.error'); g.error = new util.error();
46                                 g.error.sdump('D_TRACE','my_init() for cat_copy_summary.xul');
47
48                                 var copy_id = xul_param('copy_id');
49
50                                 JSAN.use('util.network'); g.network = new util.network();
51                                 JSAN.use('util.date'); JSAN.use('util.widgets');
52                                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
53                                 var copy = xul_param('copy',{'stash_name':'temp_copy','clear_xpcom':true});
54                                 var callnumber = xul_param('callnumber',{'stash_name':'temp_callnumber','clear_xpcom':true});
55
56                                 $('caption').setAttribute('tooltiptext','Copy ID = ' + (copy_id || copy.id() ) );
57
58                                 JSAN.use('circ.util');
59                                 var columns = circ.util.columns( 
60                                         { 
61                                                 'barcode' : { 'hidden' : false },
62                                                 'location' : { 'hidden' : false },
63                                                 'owning_lib' : { 'hidden' : false },
64                                                 'circ_lib' : { 'hidden' : false },
65                                                 'call_number' : { 'hidden' : false },
66                                                 'status' : { 'hidden' : false },
67                                                 'alert_message' : { 'hidden' : false },
68                                         } 
69                                 ).concat(
70                                         {
71                                                 'id' : 'total_circs', 'label' : 'Total Circs', 'flex' : 1,
72                                                 'primary' : false, 'hidden' : false, 'persist' : 'hidden width ordinal',
73                                                 'render' : 'v = obj.network.simple_request("FM_CIRC_COUNT_RETRIEVE_VIA_COPY",[ my.acp.id() ]).total.count; v;' 
74                                         }
75                                 );
76
77                                 JSAN.use('util.list'); g.list = new util.list('item_summary_list');
78                                 g.list.init(
79                                         {
80                                                 'columns' : columns,
81                                                 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
82                                         }
83                                 );
84         
85                                 function acp_callback(req) {
86                                         try {
87                                                 var copy = req.getResultObject();
88                                                 if (typeof copy.ilsevent != 'undefined') throw(copy);
89
90                                                 function acn_callback(rreq) {
91                                                         try {
92                                                                 $w('barcode',copy.barcode());   
93                                                                 $w('ref',get_bool(copy.ref()) ? 'Yes' : 'No');  
94                                                                 $w('opac_visible',get_bool(copy.opac_visible()) ? 'Yes' : 'No');        
95                                                                 $w('circulate',get_bool(copy.circulate()) ? 'Yes' : 'No');      
96                                                                 $w('holdable',get_bool(copy.holdable()) ? 'Yes' : 'No');        
97                                                                 $w('age_protect',copy.age_protect() == null ? '<Unset>' : ( typeof copy.age_protect() == 'object' ? copy.age_protect().name() : g.data.hash.crahp[ copy.age_protect() ].name() ) );     
98                                                                 $w('location',typeof copy.location() == 'object' ? copy.location().name() : g.data.lookup('acpl',copy.location()).name() );     
99                                                                 $w('create_date',util.date.formatted_date(copy.create_date(),'%F'));
100                                                                 $w('edit_date',util.date.formatted_date(copy.edit_date(),'%F'));
101                                                                 $w('status',typeof copy.status() == 'object' ? copy.status().name() : g.data.hash.ccs[ copy.status() ].name() );        
102                                                         } catch(E) {
103                                                                 g.error.standard_unexpected_error_alert('rendering copy',E);
104                                                         }
105                                                         try {
106                                                                 var cn = rreq.getResultObject();
107                                                                 if (typeof cn.ilsevent != 'undefined') {
108                                                                         switch(Number(cn.ilsevent)) {
109                                                                                 case 1508 /* ASSET_CALL_NUMBER_NOT_FOUND */ :
110                                                                                         $w('callnumber','Not Cataloged');       
111                                                                                 break;
112                                                                                 default:
113                                                                                         throw(cn);
114                                                                                 break;
115                                                                         }
116                                                                 } else {
117                                                                         $w('callnumber',cn.label());    
118                                                                 }
119                                                                 g.list.append({'row':{'my':{'acp':copy,'acn':cn}}});
120                                                         } catch(E) {
121                                                                 g.error.standard_unexpected_error_alert('retrieving volume',E);
122                                                         }
123                                                 }
124
125                                                 if (callnumber) {
126                                                         acn_callback( { 'getResultObject' : function() { return callnumber; } } );
127                                                 } else {
128                                                         g.network.simple_request(
129                                                                 'FM_ACN_RETRIEVE',
130                                                                 [ copy.call_number() ], acn_callback
131                                                         );
132                                                 }
133                                         } catch(E) {
134                                                 g.error.standard_unexpected_error_alert('retrieving copy',E);
135                                         }
136                                 }
137
138                                 if (copy_id) {
139                                         g.network.simple_request( 'FM_ACP_RETRIEVE', [ copy_id ], acp_callback);
140                                 } else {
141                                         acp_callback( { 'getResultObject' : function() { return copy; } } );
142                                         copy_id = copy.id();
143                                 }
144
145                                 g.network.simple_request('FM_CIRC_COUNT_RETRIEVE_VIA_COPY',[ copy_id ],function(req) {
146                                         try {
147                                                 var robj = req.getResultObject();
148                                                 if (typeof robj.ilsevent != 'undefined') throw(robj);
149                                                 $w('total_circs',robj.total.count);
150                                         } catch(E) {
151                                                 g.error.standard_unexpected_error_alert('retrieving circ total',E);
152                                         }
153                                 });
154
155                                 toggle_deck(); toggle_deck(); /* quick hack */
156
157                         } catch(E) {
158                                 try { g.error.standard_unexpected_error_alert('copy_summary.xul',E); } catch(F) { alert(E + '\n' + F); }
159                         }
160                 }
161
162                 function toggle_deck() {
163                         try {
164                                 if ($('item_deck').selectedIndex == 0) {
165                                         $('item_deck').selectedIndex = 1; /* change to grid */
166                                         $('save_columns').hidden = true;
167                                         $('sel_clip').hidden = true;
168                                 } else {
169                                         $('item_deck').selectedIndex = 0; /* change to tree */
170                                         $('save_columns').hidden = false;
171                                         $('sel_clip').hidden = false;
172                                 }
173                         } catch(E) {
174                         }
175                 }
176         ]]>
177         </script>
178
179     <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale' -->/circ.properties"/>
180
181         <groupbox id="groupbox" flex="1" style="overflow: none; min-height: 80;">
182                 <caption label="Item Summary" id="caption"/>
183                 <deck id="item_deck" persist="selectedIndex">
184                         <tree id="item_summary_list" enableColumnDrag="true" flex="1"/>
185                         <grid>
186                                 <columns>
187                                         <column/>
188                                         <column/>
189                                         <column/>
190                                         <column/>
191                                         <column/>
192                                         <column/>
193                                         <column/>
194                                         <column/>
195                                 </columns>
196                                 <rows>
197                                         <row>
198                                                 <label style="font-weight: bold" value="Barcode:"/>
199                                                 <label id="barcode" style="color: blue; text-decoration: underline; -moz-user-focus: normal;" onclick="copy_to_clipboard(event);"/>
200                                                 <label style="font-weight: bold" value="Location:"/>
201                                                 <label id="location"/>
202                                                 <label style="font-weight: bold" value="Call Number:"/>
203                                                 <label id="callnumber"/>
204                                                 <label style="font-weight: bold" value="Status:"/>
205                                                 <label id="status"/>
206                                         </row>
207                                         <row>
208                                                 <label style="font-weight: bold" value="Circulate:"/>
209                                                 <label id="circulate"/>
210                                                 <label style="font-weight: bold" value="Reference:"/>
211                                                 <label id="ref"/>
212                                                 <label style="font-weight: bold" value="Holdable:"/>
213                                                 <label id="holdable"/>
214                                                 <label style="font-weight: bold" value="Opac Visible:"/>
215                                                 <label id="opac_visible"/>
216                                         </row>
217                                         <row>
218                                                 <label style="font-weight: bold" value="Created:"/>
219                                                 <label id="create_date"/>
220                                                 <label style="font-weight: bold" value="Edited:"/>
221                                                 <label id="edit_date"/>
222                                                 <label style="font-weight: bold" value="Age Protect:"/>
223                                                 <label id="age_protect"/>
224                                                 <label style="font-weight: bold" value="Total Circs:"/>
225                                                 <label id="total_circs"/>
226                                         </row>
227                                 </rows>
228                         </grid>
229                 </deck>
230                 <hbox>
231                         <button label="Alternate View" oncommand="toggle_deck()"/>
232                         <button id="save_columns" label="Save Columns" oncommand="try { g.list.save_columns(); } catch(E) { alert(E); }"/>
233                         <button id="sel_clip" label="Copy to Clipboard" oncommand="try { g.list.node.view.selection.selectAll(); g.list.clipboard(); } catch(E) { alert(E); }"/>
234                         <button id="print_export" label="Print Export" oncommand="try { g.list.on_all_fleshed = function() { JSAN.use('util.print'); var p = new util.print(); p.simple( g.list.dump_csv(), { 'content_type' : 'text/plain' } ); setTimeout( function() { g.list.on_all_fleshed = null; }, 0); }; g.list.full_retrieve(); } catch(E) { alert(E); }"/>
235                 </hbox>
236         </groupbox>
237
238 </window>
239