]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js
for the Circulate as Type column in xul lists, display the actual citm value instead...
[Evergreen.git] / Open-ILS / xul / staff_client / server / circ / alternate_copy_summary.js
1 var error; 
2 var network;
3 var data;
4 var transit_list;
5 var hold_list;
6
7 function my_init() {
8     try {
9         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
10         if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
11         JSAN.errorLevel = "die"; // none, warn, or die
12         JSAN.addRepository('/xul/server/');
13         JSAN.use('util.error'); error = new util.error();
14         error.sdump('D_TRACE','my_init() for alternate_copy_summary.xul');
15
16         JSAN.use('util.network'); network = new util.network();
17         JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
18         JSAN.use('util.date');
19         JSAN.use('cat.util');
20
21         var x = document.getElementById('patron_name');
22         if (x) {
23             x.addEventListener(
24                 'command',
25                 function(ev) {
26                     var usr = ev.target.getAttribute('data');
27                     if (usr) { window.xulG.new_patron_tab( {}, { 'id' : usr } ); }
28                 },
29                 false
30             );
31         }
32         var y = document.getElementById('prev_patron_name');
33         if (y) {
34             y.addEventListener(
35                 'command',
36                 function(ev) {
37                     var usr = ev.target.getAttribute('data');
38                     if (usr) { window.xulG.new_patron_tab( {}, { 'id' : usr } ); }
39                 },
40                 false
41             );
42         }
43
44         JSAN.use('circ.util'); 
45         JSAN.use('util.list'); 
46
47         var columns = circ.util.transit_columns({});
48         transit_list = new util.list('transit');
49         transit_list.init( { 'columns' : columns, 'map_row_to_columns' : circ.util.std_map_row_to_columns(), });
50
51         hold_list = new util.list('hold');
52         hold_list.init( { 'columns' : columns, 'map_row_to_columns' : circ.util.std_map_row_to_columns(), });
53
54         // timeout so xulG gets a chance to get pushed in
55         setTimeout(
56             function () { xulG.from_item_details_new = false; load_item(); },
57             1000
58         );
59
60     } catch(E) {
61         try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
62     }
63 }
64
65 function set(name,value,data) { 
66     if (typeof value == 'undefined' || typeof value == 'null') { return; }
67     var nodes = document.getElementsByAttribute('name',name); 
68     for (var i = 0; i < nodes.length; i++) {
69         if (nodes[i].nodeName == 'button') {
70             nodes[i].setAttribute('label',value);
71             if (data) {
72                 nodes[i].setAttribute('data',data); 
73             } else {
74                 nodes[i].setAttribute('data',''); 
75             }
76         } else {
77             nodes[i].setAttribute('value',value);
78         }
79         nodes[i].value = value; 
80     }
81 }
82
83 function set_tooltip(name,value) { 
84     if (typeof value == 'undefined' || typeof value == 'null') { return; }
85     var nodes = document.getElementsByAttribute('name',name); 
86     for (var i = 0; i < nodes.length; i++) {
87         nodes[i].setAttribute('tooltiptext',value);
88     }
89 }
90
91 function renewal_composite_kludge(circ) {
92     // Only a corrupt database could give us a situation where more
93     // than one of these were true at a time, right?
94     if (circ.desk_renewal() == "t")
95         return document.getElementById('circStrings').getString(
96             'staff.circ.copy_details.desk_renewal'
97         );
98     else if (circ.opac_renewal() == "t")
99         return document.getElementById('circStrings').getString(
100             'staff.circ.copy_details.opac_renewal'
101         );
102     else if (circ.phone_renewal() == "t")
103         return document.getElementById('circStrings').getString(
104             'staff.circ.copy_details.phone_renewal'
105         );
106     else return "";
107 }
108
109 function load_item() {
110     try {
111         if (! xulG.barcode) return;
112
113         if (xulG.fetched_copy_details && xulG.fetched_copy_details[xulG.barcode]) {
114             var details = xulG.fetched_copy_details[xulG.barcode];
115             // We don't want to use these details more than once (i.e., we
116             // don't want cached data after things have potentially changed).
117             delete xulG.fetched_copy_details[xulG.barcode];
118         } else {
119             var details = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE.authoritative', [ ses(), xulG.barcode ]);
120             // Should get back .mvr, .copy, .volume, .transit, .circ, .hold
121         }
122
123         if (typeof bib_brief_overlay == 'function') bib_brief_overlay( { 'mvr' : details.mvr, 'acp' : details.copy } );
124
125         set("stat_cat_entries", '');
126         set("age_protect", '');
127         set("alert_message", '');
128         set("barcode", '');
129         set("call_number", '');
130         set("circ_as_type", '');
131         set("copy_circ_lib" , '');
132         set_tooltip("copy_circ_lib" , '');
133         set("circ_modifier", '');
134         set("circulate", '');
135         set("floating", '');
136         set("copy_number", '');
137         set("copy_create_date", '');
138         set("status_changed_time", '');
139         set("copy_creator", '');
140         set("deleted", '');
141         set("deposit", '');
142         set("deposit_amount", '');
143         set("dummy_author", '');
144         set("dummy_title", '');
145         set("copy_edit_date", '');
146         set("copy_editor", '');
147         set("fine_level", '');
148         set("holdable", '');
149         set("copy_id", '');
150         set("loan_duration", '');
151         set("location", '');
152         set_tooltip("location", '');
153         set("renewal_type", '');
154         set("opac_visible", '');
155         set("price", '');
156         set("ref", '');
157         set("copy_status", '');
158         set_tooltip("copy_status", '');
159         set("notes", '');
160         set("stat_cat_entry_copy_maps", '');
161         set("circulations", '');
162         set("total_circ_count", '');
163         set_tooltip("total_circ_count", '');
164         set("total_circ_count_prev_year", '');
165         set("total_circ_count_curr_year", '');
166         set("holds", '');
167
168         if (details.copy) {
169             set("stat_cat_entries", details.copy.stat_cat_entries()); 
170             set("age_protect", details.copy.age_protect()); 
171             set("alert_message", details.copy.alert_message()); 
172             set("barcode", details.copy.barcode()); 
173             if (typeof details.copy.call_number() == 'object') {
174                 set("call_number", details.copy.call_number().label()); 
175             } else {
176                 network.simple_request('FM_ACN_RETRIEVE.authoritative',[details.copy.call_number()], function(req) {
177                     var acn_obj = req.getResultObject();
178                     set("call_number", acn_obj.label());
179                 });
180             }
181             set("circ_as_type", details.copy.circ_as_type() != null && details.copy.circ_as_type() == 'object'
182                 ? details.copy.circ_as_type()
183                 : ( typeof data.hash.citm[ details.copy.circ_as_type() ] != 'undefined'
184                     ? data.hash.citm[ details.copy.circ_as_type() ].value
185                     : ''
186                 )
187             ); 
188             set("copy_circ_lib" , typeof details.copy.circ_lib() == 'object' ? details.copy.circ_lib().shortname() : data.hash.aou[ details.copy.circ_lib() ].shortname()); 
189             set_tooltip("copy_circ_lib" , typeof details.copy.circ_lib() == 'object' ? details.copy.circ_lib().name() : data.hash.aou[ details.copy.circ_lib() ].name()); 
190             var cm = details.copy.circ_modifier();
191             if (typeof data.hash.ccm[cm] != 'undefined') {
192                 set("circ_modifier", document.getElementById('commonStrings').getFormattedString('staff.circ_modifier.display',[cm,data.hash.ccm[cm].name(),data.hash.ccm[cm].description()])); 
193             } else {
194                 set("circ_modifier","");
195             }
196             set("circulate", get_localized_bool( details.copy.circulate() )); 
197             set("floating", get_localized_bool( details.copy.floating() )); 
198             set("copy_number", details.copy.copy_number()); 
199             set("copy_create_date", util.date.formatted_date( details.copy.create_date(), '%{localized}' )); 
200             set("status_changed_time", util.date.formatted_date( details.copy.status_changed_time(), '%{localized}' )); 
201             set("copy_creator", details.copy.creator()); 
202             set("deleted", details.copy.deleted()); 
203             set("deposit", details.copy.deposit()); 
204             set("deposit_amount", details.copy.deposit_amount()); 
205             set("dummy_author", details.copy.dummy_author()); 
206             set("dummy_title", details.copy.dummy_title()); 
207             set("copy_edit_date", util.date.formatted_date( details.copy.edit_date(), '%{localized}' )); 
208             set("copy_editor", details.copy.editor()); 
209             set("fine_level", cat.util.render_fine_level( details.copy.fine_level() )); 
210             set("holdable", get_localized_bool( details.copy.holdable() )); 
211             set("copy_id", details.copy.id()); 
212             set("loan_duration", cat.util.render_loan_duration( details.copy.loan_duration() )); 
213             var copy_location = typeof details.copy.location() == 'object' ? details.copy.location() : data.lookup('acpl',details.copy.location());
214                 set("location", copy_location.name());
215                 set_tooltip("location", document.getElementById('circStrings').getFormattedString( 
216                     'staff.circ.copy_details.location_tooltip',
217                     [
218                         get_localized_bool( copy_location.circulate() ), 
219                         get_localized_bool( copy_location.holdable() ), 
220                         get_localized_bool( copy_location.hold_verify() ), 
221                         get_localized_bool( copy_location.opac_visible() )
222                     ]
223                 ));
224             set("opac_visible", get_localized_bool( details.copy.opac_visible() )); 
225             set("price", details.copy.price()); 
226             set("ref", get_localized_bool( details.copy.ref() )); 
227             var copy_status = typeof details.copy.status() == 'object' ? details.copy.status() : data.hash.ccs[ details.copy.status() ];
228                 set("copy_status", copy_status.name() );
229                 set_tooltip("copy_status", document.getElementById('circStrings').getFormattedString(
230                     'staff.circ.copy_details.copy_status_tooltip',
231                     [
232                         get_localized_bool( copy_status.opac_visible() ), 
233                         get_localized_bool( copy_status.holdable() ) 
234                     ]
235                 ));
236             set("notes", details.copy.notes()); 
237             set("stat_cat_entry_copy_maps", details.copy.stat_cat_entry_copy_maps()); 
238             set("circulations", details.copy.circulations()); 
239             set("holds", details.copy.holds()); 
240
241             network.simple_request('FM_CIRC_IMPROVED_COUNT_VIA_COPY', [ses(), { 'copy' : details.copy.id() } ], function(req) {
242                 var r = req.getResultObject();
243                 var total = 0; var tooltip = ''; var year = {};
244                 for (var i = 0; i < r.length; i++) {
245                     total += Number( r[i].count() );
246                     if (typeof year[ r[i].year() ] == 'undefined') year[ r[i].year() ] = 0;
247                     year[ r[i].year() ] += Number( r[i].count() ); // Add original circs and renewals together
248                 }
249                 set( 'total_circ_count', total );
250                 var curr_year = (new Date()).getFullYear();
251                 var prev_year = curr_year - 1;
252                 set( 'total_circ_count_curr_year', year[ curr_year ] || 0 );
253                 set( 'total_circ_count_prev_year', year[ prev_year ] || 0 );
254                 var keys = []; for (var i in year) { keys.push( i ); }; keys.sort();
255                 for (var i = 0; i < keys.length; i++) {
256                     tooltip += document.getElementById('circStrings').getFormattedString( 
257                         'staff.circ.copy_details.circ_count_by_year', [ 
258                             keys[i] == -1 ? document.getElementById('circStrings').getString('staff.circ.copy_details.circ_count_by_year.legacy_label') : keys[i], 
259                             year[keys[i]]
260                         ] 
261                     ) + '\n';
262                 }
263                 set_tooltip( 'total_circ_count', tooltip );
264             } );
265         }
266
267         set("copies", '');
268         set("volume_create_date", '');
269         set("volume_creator", '');
270         set("deleted", '');
271         set("volume_edit_date", '');
272         set("volume_editor", '');
273         set("volume_id", '');
274         set("label", '');
275         set("owning_lib" , '');
276         set_tooltip("owning_lib" , '');
277         set("record", '');
278         set("notes", '');
279         set("uri_maps", '');
280         set("uris", '');
281
282         if (details.volume) {
283             set("copies", details.volume.copies()); 
284             set("volume_create_date", util.date.formatted_date( details.volume.create_date(), '%{localized}' )); 
285             set("volume_creator", details.volume.creator()); 
286             set("deleted", details.volume.deleted()); 
287             set("volume_edit_date", util.date.formatted_date( details.volume.edit_date(), '%{localized}' )); 
288             set("volume_editor", details.volume.editor()); 
289             set("volume_id", details.volume.id()); 
290             set("label", details.volume.label()); 
291             set("owning_lib" , typeof details.volume.owning_lib() == 'object' ? details.volume.owning_lib().shortname() : data.hash.aou[ details.volume.owning_lib() ].shortname()); 
292             set_tooltip("owning_lib" , typeof details.volume.owning_lib() == 'object' ? details.volume.owning_lib().name() : data.hash.aou[ details.volume.owning_lib() ].name()); 
293             set("record", details.volume.record()); 
294             set("notes", details.volume.notes()); 
295             set("uri_maps", details.volume.uri_maps()); 
296             set("uris", details.volume.uris()); 
297         }
298
299         set("transit_copy_status", '');
300         set_tooltip("transit_copy_status", '');
301         set("dest", '');
302         set("dest_recv_time", '');
303         set("transit_id", '');
304         set("persistant_transfer", '');
305         set("prev_hop", '');
306         set("source", '');
307         set("source_send_time", '');
308         set("target_copy", '');
309         set("hold_transit_copy", '');
310
311         if (details.transit) {
312
313             transit_list.clear();
314             transit_list.append( { 'row' : { 'my' : { 'atc' : details.transit, } } });
315
316             var transit_copy_status = typeof details.transit.copy_status() == 'object' ? details.transit.copy_status() : data.hash.ccs[ details.transit.copy_status() ];
317                 set("transit_copy_status", transit_copy_status.name() );
318                 set_tooltip("transit_copy_status", document.getElementById('circStrings').getFormattedString(
319                     'staff.circ.copy_details.copy_status_tooltip',
320                     [
321                         get_localized_bool( transit_copy_status.opac_visible() ), 
322                         get_localized_bool( transit_copy_status.holdable() ) 
323                     ]
324                 ));
325             set("dest", details.transit.dest()); 
326             set("dest_recv_time", util.date.formatted_date( details.transit.dest_recv_time(), '%{localized}' )); 
327             set("transit_id", details.transit.id()); 
328             set("persistant_transfer", details.transit.persistant_transfer()); 
329             set("prev_hop", details.transit.prev_hop()); 
330             set("source", details.transit.source()); 
331             set("source_send_time", util.date.formatted_date( details.transit.source_send_time(), '%{localized}' )); 
332             set("target_copy", details.transit.target_copy()); 
333             set("hold_transit_copy", details.transit.hold_transit_copy()); 
334         } else {
335             $('transit_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.not_transit'));
336         }
337
338         set("checkin_lib", '');
339         set_tooltip("checkin_lib", '');
340         set("checkin_workstation",""); 
341         set("checkin_staff", '');
342         set("checkin_time", '');
343         set("checkin_scan_time", '');
344         set("circ_circ_lib" , '');
345         set_tooltip("circ_circ_lib" , '');
346         set("circ_staff", '');
347         set("desk_renewal", '');
348         set("due_date", '');
349         set("duration", '');
350         set("duration_rule", '');
351         set("fine_interval", '');
352         set("circ_id", '');
353         set("max_fine", '');
354         set("max_fine_rule", '');
355         set("opac_renewal", '');
356         set("phone_renewal", '');
357         set("recurring_fine", '');
358         set("recurring_fine_rule", '');
359         set("renewal_remaining", '');
360         set("stop_fines", '');
361         set("stop_fines_time", '');
362         set("target_copy", '');
363         set("circ_usr", '');
364         set("xact_finish", '');
365         set("xact_start", '');
366         set("create_time", '');
367         set("workstation", '');
368         set("renewal_workstation", '');
369         set("checkout_workstation", '');
370         set("billings", '');
371         set("payments", '');
372         set("billable_transaction", '');
373         set("circ_type", '');
374         set("billing_total", '');
375         set("payment_total", '');
376         set("patron_name", '');
377         set("prev_patron_name", '');
378         set("prev_num_circs", '');
379         set("prev_num_renewals", '');
380         set("prev_xact_start", '');
381         set("prev_checkout_workstation", '');
382         set("prev_renewal_time", '');
383         set("prev_stop_fines", '');
384         set("prev_stop_fines_time", '');
385         set("prev_renewal_workstation", '');
386         set("prev_checkin_workstation", '');
387         set("prev_last_checkin_time", '');
388         set("prev_last_checkin_scan_time", '');
389
390         if (details.circ) {
391             try { set("checkin_lib", typeof details.circ.checkin_lib() == 'object' ? details.circ.checkin_lib().shortname() : data.hash.aou[ details.circ.checkin_lib() ].shortname() );  } catch(E) {};
392             try { set_tooltip("checkin_lib", typeof details.circ.checkin_lib() == 'object' ? details.circ.checkin_lib().name() : data.hash.aou[ details.circ.checkin_lib() ].name() );  } catch(E) {};
393             if (details.circ.checkin_workstation()) {
394                 set("checkin_workstation", details.circ.checkin_workstation().name()); 
395             }
396             set("checkin_staff", details.circ.checkin_staff()); 
397             set("checkin_time", util.date.formatted_date( details.circ.checkin_time(), '%{localized}' )); 
398             set("last_checkin_time", util.date.formatted_date( details.circ.checkin_time(), '%{localized}' )); 
399             set("checkin_scan_time", util.date.formatted_date( details.circ.checkin_scan_time(), '%{localized}' )); 
400             set("last_checkin_scan_time", util.date.formatted_date( details.circ.checkin_scan_time(), '%{localized}' )); 
401             try { set("circ_circ_lib" , typeof details.circ.circ_lib() == 'object' ? details.circ.circ_lib().shortname() : data.hash.aou[ details.circ.circ_lib() ].shortname() );  } catch(E) {};
402             try { set_tooltip("circ_circ_lib" , typeof details.circ.circ_lib() == 'object' ? details.circ.circ_lib().name() : data.hash.aou[ details.circ.circ_lib() ].name() );  } catch(E) {};
403             set("circ_staff", details.circ.circ_staff()); 
404             set("desk_renewal", details.circ.desk_renewal()); 
405             set("due_date", util.date.formatted_date( details.circ.due_date(), '%{localized}' )); 
406             set("duration", details.circ.duration()); 
407             set("fine_interval", details.circ.fine_interval()); 
408             set("circ_id", details.circ.id()); 
409             set("max_fine", details.circ.max_fine()); 
410             set("opac_renewal", details.circ.opac_renewal()); 
411             set("phone_renewal", details.circ.phone_renewal()); 
412             set("renewal_type", renewal_composite_kludge(details.circ));
413             set("recurring_fine", details.circ.recurring_fine()); 
414             set("renewal_remaining", details.circ.renewal_remaining()); 
415             set("stop_fines", details.circ.stop_fines()); 
416             set("stop_fines_time", util.date.formatted_date( details.circ.stop_fines_time(), '%{localized}' )); 
417             set("target_copy", details.circ.target_copy()); 
418             set("circ_usr", details.circ.usr()); 
419             network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), details.circ.usr() ], function(preq) {
420                 var r_au = preq.getResultObject();
421                 JSAN.use('patron.util');
422                 set(
423                     'patron_name', 
424                     patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(),
425                     details.circ.usr()
426                 );
427                 set_tooltip('patron_name','circ id ' + details.circ.id());
428             });
429             set("xact_finish", util.date.formatted_date( details.circ.xact_finish(), '%{localized}' )); 
430             set("xact_start", util.date.formatted_date( details.circ.xact_start(), '%{localized}' )); 
431             set("create_time", util.date.formatted_date( details.circ.create_time(), '%{localized}' )); 
432             set("workstation", details.circ.workstation()); 
433             if (get_bool(details.circ.opac_renewal())||get_bool(details.circ.phone_renewal())||get_bool(details.circ.desk_renewal())) {
434                 set("renewal_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() ); 
435                 network.simple_request('FM_CIRC_CHAIN_SUMMARY', [ses(), details.circ.id() ], function(req) {
436                     try {
437                         var summary = req.getResultObject();
438                         set("num_circs", summary.num_circs());
439                         set("num_renewals", Number(summary.num_circs()) - 1);
440                         set("xact_start", util.date.formatted_date( summary.start_time(), '%{localized}' )); 
441                         set("checkout_workstation", summary.checkout_workstation());
442                         set("renewal_time", util.date.formatted_date( summary.last_renewal_time(), '%{localized}' )); 
443                         set("stop_fines", summary.last_stop_fines());
444                         set("stop_fines_time", util.date.formatted_date( summary.last_stop_fines_time(), '%{localized}' )); 
445                         set("renewal_workstation", summary.last_renewal_workstation());
446                         set("checkin_workstation", summary.last_checkin_workstation());
447                         set("last_checkin_time", util.date.formatted_date( summary.last_checkin_time(), '%{localized}' )); 
448                         set("last_checkin_scan_time", util.date.formatted_date( summary.last_checkin_scan_time(), '%{localized}' )); 
449                     } catch(E) {
450                         alert('Error in alternate_copy_summary.js, FM_CIRC_CHAIN: ' + E);
451                     }
452                 } );
453             } else {
454                 set("checkout_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
455             }
456             network.simple_request('FM_CIRC_PREV_CHAIN_SUMMARY', [ses(), details.circ.id() ], function(req) {
457                 try {
458                     var robj = req.getResultObject();
459                     if (!robj || typeof robj == 'null') { return; }
460                     var summary = robj['summary'];
461                     network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), robj['usr'] ], function(preq) {
462                         var r_au = preq.getResultObject();
463                         JSAN.use('patron.util');
464                         set(
465                             'prev_patron_name', 
466                             patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(),
467                             robj['usr']
468                         );
469                         set_tooltip('prev_patron_name','circ chain prior to circ id ' + details.circ.id());
470                     });
471                     set("prev_num_circs", summary.num_circs());
472                     set("prev_num_renewals", Number(summary.num_circs()) - 1);
473                     set("prev_xact_start", util.date.formatted_date( summary.start_time(), '%{localized}' )); 
474                     set("prev_checkout_workstation", summary.checkout_workstation());
475                     set("prev_renewal_time", util.date.formatted_date( summary.last_renewal_time(), '%{localized}' )); 
476                     set("prev_stop_fines", summary.last_stop_fines());
477                     set("prev_stop_fines_time", util.date.formatted_date( summary.last_stop_fines_time(), '%{localized}' )); 
478                     set("prev_renewal_workstation", summary.last_renewal_workstation());
479                     set("prev_checkin_workstation", summary.last_checkin_workstation());
480                     set("prev_last_checkin_time", util.date.formatted_date( summary.last_checkin_time(), '%{localized}' )); 
481                     set("prev_last_checkin_scan_time", util.date.formatted_date( summary.last_checkin_scan_time(), '%{localized}' )); 
482                 } catch(E) {
483                     alert('Error in alternate_copy_summary.js, FM_CIRC_PREV_CHAIN: ' + E);
484                 }
485             });
486             set("billings", details.circ.billings()); 
487             set("payments", details.circ.payments()); 
488             set("billable_transaction", details.circ.billable_transaction()); 
489             set("circ_type", details.circ.circ_type()); 
490             set("billing_total", details.circ.billing_total()); 
491             set("payment_total", details.circ.payment_total()); 
492             if (! details.circ.checkin_time() ) {
493                 set("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
494                     'staff.circ.copy_details.recurring_fine_rule_format',
495                     [
496                         details.circ.recurring_fine_rule().name(),
497                         details.circ.recurring_fine_rule().id(),
498                         details.circ.recurring_fine_rule().low(),
499                         details.circ.recurring_fine_rule().normal(),
500                         details.circ.recurring_fine_rule().high(),
501                         details.circ.recurring_fine_rule().recurrence_interval()
502                     ]
503                 )); 
504                 set_tooltip("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
505                     'staff.circ.copy_details.recurring_fine_rule_tooltip_format',
506                     [
507                         details.circ.recurring_fine_rule().name(),
508                         details.circ.recurring_fine_rule().id(),
509                         details.circ.recurring_fine_rule().low(),
510                         details.circ.recurring_fine_rule().normal(),
511                         details.circ.recurring_fine_rule().high(),
512                         details.circ.recurring_fine_rule().recurrence_interval()
513                     ]
514                 )); 
515                 set("duration_rule", document.getElementById('circStrings').getFormattedString(
516                     'staff.circ.copy_details.duration_rule_format',
517                     [
518                         details.circ.duration_rule().name(),
519                         details.circ.duration_rule().id(),
520                         details.circ.duration_rule().shrt(),
521                         details.circ.duration_rule().normal(),
522                         details.circ.duration_rule().extended(),
523                         details.circ.duration_rule().max_renewals()
524                     ]
525                 )); 
526                 set_tooltip("duration_rule", document.getElementById('circStrings').getFormattedString(
527                     'staff.circ.copy_details.duration_rule_tooltip_format',
528                     [
529                         details.circ.duration_rule().name(),
530                         details.circ.duration_rule().id(),
531                         details.circ.duration_rule().shrt(),
532                         details.circ.duration_rule().normal(),
533                         details.circ.duration_rule().extended(),
534                         details.circ.duration_rule().max_renewals()
535                     ]
536                 )); 
537                 set("max_fine_rule", document.getElementById('circStrings').getFormattedString(
538                     'staff.circ.copy_details.max_fine_rule_format',
539                     [
540                         details.circ.max_fine_rule().name(),
541                         details.circ.max_fine_rule().id(),
542                         details.circ.max_fine_rule().amount(),
543                         details.circ.max_fine_rule().is_percent()
544                     ]
545                 ));
546                 set_tooltip("max_fine_rule", document.getElementById('circStrings').getFormattedString(
547                     'staff.circ.copy_details.max_fine_rule_tooltip_format',
548                     [
549                         details.circ.max_fine_rule().name(),
550                         details.circ.max_fine_rule().id(),
551                         details.circ.max_fine_rule().amount(),
552                         details.circ.max_fine_rule().is_percent()
553                     ]
554                 ));
555             }
556         }
557
558         set("hold_status", '');
559         set("transit", '');
560         set("capture_time", '');
561         set("current_copy", '');
562         set("email_notify", '');
563         set("expire_time", '');
564         set("fulfillment_lib", '');
565         set_tooltip("fulfillment_lib", '');
566         set("fulfillment_staff", '');
567         set("fulfillment_time", '');
568         set("hold_type", '');
569         set("holdable_formats", '');
570         set("hold_id", '');
571         set("phone_notify", '');
572         set("pickup_lib", '');
573         set_tooltip("pickup_lib", '');
574         set("prev_check_time", '');
575         set("request_lib", '');
576         set_tooltip("request_lib", '');
577         set("request_time", '');
578         set("requestor", '');
579         set("selection_depth", '');
580         set("selection_ou", '');
581         set_tooltip("selection_ou", '');
582         set("target", '');
583         set("hold_usr", '');
584         set("hold_patron_name", '');
585         set("cancel_time", '');
586         set("notify_time", '');
587         set("notify_count", '');
588         set("notifications", '');
589         set("bib_rec", '');
590         set("eligible_copies", '');
591         set("frozen", '');
592         set("thaw_date", '');
593         set("shelf_time", '');
594         set("cancel_cause", '');
595         set("cancel_note", '');
596         set("notes", '');
597
598         if (details.hold) {
599             var better_fleshed_hold_blob = network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative',[ ses(), details.hold.id() ]);
600             var status_robj = better_fleshed_hold_blob.status;
601             JSAN.use('circ.util');
602             var columns = circ.util.hold_columns( 
603                 { 
604                     'request_time' : { 'hidden' : false },
605                     'pickup_lib_shortname' : { 'hidden' : false },
606                     'hold_type' : { 'hidden' : true },
607                     'current_copy' : { 'hidden' : true },
608                     'capture_time' : { 'hidden' : true },
609                     'email_notify' : { 'hidden' : false },
610                     'phone_notify' : { 'hidden' : false },
611                 } 
612             );
613
614             hold_list.clear();
615             hold_list.append( { 'row' : { 'my' : { 'ahr' : better_fleshed_hold_blob.hold, 'acp' : details.copy, 'status' : status_robj, } } });
616
617             JSAN.use('patron.util'); 
618             var au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), details.hold.usr() );
619             $('hold_patron_name').setAttribute('value', $('circStrings').getFormattedString('staff.circ.copy_details.user_details', [au_obj.family_name(), au_obj.first_given_name(), au_obj.card().barcode()]) );
620
621             set("hold_status", details.hold.status()); 
622             set("transit", details.hold.transit()); 
623             set("capture_time", util.date.formatted_date( details.hold.capture_time(), '%{localized}' )); 
624             set("current_copy", details.hold.current_copy()); 
625             set("email_notify", details.hold.email_notify()); 
626             set("expire_time", util.date.formatted_date( details.hold.expire_time(), '%{localized}' )); 
627             try { set("fulfillment_lib" , typeof details.hold.fulfillment_lib() == 'object' ? details.hold.fulfillment_lib().shortname() : data.hash.aou[ details.hold.fulfillment_lib() ].shortname() );  } catch(E) {}
628             try { set_tooltip("fulfillment_lib" , typeof details.hold.fulfillment_lib() == 'object' ? details.hold.fulfillment_lib().name() : data.hash.aou[ details.hold.fulfillment_lib() ].name() );  } catch(E) {}
629             set("fulfillment_staff", details.hold.fulfillment_staff()); 
630             set("fulfillment_time", util.date.formatted_date( details.hold.fulfillment_time(), '%{localized}' )); 
631             set("hold_type", details.hold.hold_type()); 
632             set("holdable_formats", details.hold.holdable_formats()); 
633             set("hold_id", details.hold.id()); 
634             set("phone_notify", details.hold.phone_notify()); 
635             try { set("pickup_lib" , typeof details.hold.pickup_lib() == 'object' ? details.hold.pickup_lib().shortname() : data.hash.aou[ details.hold.pickup_lib() ].shortname() );  } catch(E) {}
636             try { set_tooltip("pickup_lib" , typeof details.hold.pickup_lib() == 'object' ? details.hold.pickup_lib().name() : data.hash.aou[ details.hold.pickup_lib() ].name() );  } catch(E) {}
637             set("prev_check_time", util.date.formatted_date( details.hold.prev_check_time(), '%{localized}' )); 
638             try { set("request_lib" , typeof details.hold.request_lib() == 'object' ? details.hold.request_lib().shortname() : data.hash.aou[ details.hold.request_lib() ].shortname() ); } catch(E) {}
639             try { set_tooltip("request_lib" , typeof details.hold.request_lib() == 'object' ? details.hold.request_lib().name() : data.hash.aou[ details.hold.request_lib() ].name() ); } catch(E) {}
640             set("request_time", util.date.formatted_date( details.hold.request_time(), '%{localized}' )); 
641             set("requestor", details.hold.requestor()); 
642             set("selection_depth", details.hold.selection_depth()); 
643             set("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().shortname() : data.hash.aou[ details.hold.selection_ou() ].shortname() ); 
644             set_tooltip("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().name() : data.hash.aou[ details.hold.selection_ou() ].name() ); 
645             set("target", details.hold.target()); 
646             set("hold_usr", details.hold.usr()); 
647             set("cancel_time", util.date.formatted_date( details.hold.cancel_time(), '%{localized}' )); 
648             set("notify_time", util.date.formatted_date( details.hold.notify_time(), '%{localized}' )); 
649             set("notify_count", details.hold.notify_count()); 
650             set("notifications", details.hold.notifications()); 
651             set("bib_rec", details.hold.bib_rec()); 
652             set("eligible_copies", details.hold.eligible_copies()); 
653             set("frozen", details.hold.frozen()); 
654             set("thaw_date", util.date.formatted_date( details.hold.thaw_date(), '%{localized}' )); 
655             set("shelf_time", util.date.formatted_date( details.hold.shelf_time(), '%{localized}' )); 
656             set("cancel_cause", details.hold.cancel_cause()); 
657             set("cancel_note", details.hold.cancel_note()); 
658             set("notes", details.hold.notes()); 
659         } else {
660             if (details.copy.status() == 8 /* ON HOLDS SHELF */) {
661                 $('hold_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.bad_hold_status'));
662             } else {
663                 $('hold_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.no_hold'));
664             }
665         }
666
667         var x = document.getElementById('cat_deck');
668         if (x) {
669             JSAN.use('util.deck');
670             var d = new util.deck('cat_deck');
671             d.reset_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : details.mvr ? details.mvr.doc_id() : -1 } );
672         }
673
674     } catch(E) {
675         alert(E);
676     }
677 }