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