]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js
hold/transit data in Item Status->Alternate View->Holds/Transit
[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             set("circ_modifier", details.copy.circ_modifier()); 
172             set("circulate", get_localized_bool( details.copy.circulate() )); 
173             set("copy_number", details.copy.copy_number()); 
174             set("copy_create_date", util.date.formatted_date( details.copy.create_date(), '%{localized}' )); 
175             set("status_changed_time", util.date.formatted_date( details.copy.status_changed_time(), '%{localized}' )); 
176             set("copy_creator", details.copy.creator()); 
177             set("deleted", details.copy.deleted()); 
178             set("deposit", details.copy.deposit()); 
179             set("deposit_amount", details.copy.deposit_amount()); 
180             set("dummy_author", details.copy.dummy_author()); 
181             set("dummy_title", details.copy.dummy_title()); 
182             set("copy_edit_date", util.date.formatted_date( details.copy.edit_date(), '%{localized}' )); 
183             set("copy_editor", details.copy.editor()); 
184             set("fine_level", cat.util.render_fine_level( details.copy.fine_level() )); 
185             set("holdable", get_localized_bool( details.copy.holdable() )); 
186             set("copy_id", details.copy.id()); 
187             set("loan_duration", cat.util.render_loan_duration( details.copy.loan_duration() )); 
188             var copy_location = typeof details.copy.location() == 'object' ? details.copy.location() : data.lookup('acpl',details.copy.location());
189                 set("location", copy_location.name());
190                 set_tooltip("location", document.getElementById('circStrings').getFormattedString( 
191                     'staff.circ.copy_details.location_tooltip',
192                     [
193                         get_localized_bool( copy_location.circulate() ), 
194                         get_localized_bool( copy_location.holdable() ), 
195                         get_localized_bool( copy_location.hold_verify() ), 
196                         get_localized_bool( copy_location.opac_visible() )
197                     ]
198                 ));
199             set("opac_visible", get_localized_bool( details.copy.opac_visible() )); 
200             set("price", details.copy.price()); 
201             set("ref", get_localized_bool( details.copy.ref() )); 
202             var copy_status = typeof details.copy.status() == 'object' ? details.copy.status() : data.hash.ccs[ details.copy.status() ];
203                 set("copy_status", copy_status.name() );
204                 set_tooltip("copy_status", document.getElementById('circStrings').getFormattedString(
205                     'staff.circ.copy_details.copy_status_tooltip',
206                     [
207                         get_localized_bool( copy_status.opac_visible() ), 
208                         get_localized_bool( copy_status.holdable() ) 
209                     ]
210                 ));
211             set("notes", details.copy.notes()); 
212             set("stat_cat_entry_copy_maps", details.copy.stat_cat_entry_copy_maps()); 
213             set("circulations", details.copy.circulations()); 
214             set("holds", details.copy.holds()); 
215
216             network.simple_request('FM_CIRC_IMPROVED_COUNT_VIA_COPY', [ses(), { 'copy' : details.copy.id() } ], function(req) {
217                 var r = req.getResultObject();
218                 var total = 0; var tooltip = ''; var year = {};
219                 for (var i = 0; i < r.length; i++) {
220                     total += Number( r[i].count() );
221                     if (typeof year[ r[i].year() ] == 'undefined') year[ r[i].year() ] = 0;
222                     year[ r[i].year() ] += Number( r[i].count() ); // Add original circs and renewals together
223                 }
224                 set( 'total_circ_count', total );
225                 var curr_year = (new Date()).getFullYear();
226                 var prev_year = curr_year - 1;
227                 set( 'total_circ_count_curr_year', year[ curr_year ] || 0 );
228                 set( 'total_circ_count_prev_year', year[ prev_year ] || 0 );
229                 var keys = []; for (var i in year) { keys.push( i ); }; keys.sort();
230                 for (var i = 0; i < keys.length; i++) {
231                     tooltip += document.getElementById('circStrings').getFormattedString( 
232                         'staff.circ.copy_details.circ_count_by_year', [ 
233                             keys[i] == -1 ? document.getElementById('circStrings').getString('staff.circ.copy_details.circ_count_by_year.legacy_label') : keys[i], 
234                             year[keys[i]]
235                         ] 
236                     ) + '\n';
237                 }
238                 set_tooltip( 'total_circ_count', tooltip );
239             } );
240         }
241
242         set("copies", '');
243         set("volume_create_date", '');
244         set("volume_creator", '');
245         set("deleted", '');
246         set("volume_edit_date", '');
247         set("volume_editor", '');
248         set("volume_id", '');
249         set("label", '');
250         set("owning_lib" , '');
251         set_tooltip("owning_lib" , '');
252         set("record", '');
253         set("notes", '');
254         set("uri_maps", '');
255         set("uris", '');
256
257         if (details.volume) {
258             set("copies", details.volume.copies()); 
259             set("volume_create_date", util.date.formatted_date( details.volume.create_date(), '%{localized}' )); 
260             set("volume_creator", details.volume.creator()); 
261             set("deleted", details.volume.deleted()); 
262             set("volume_edit_date", util.date.formatted_date( details.volume.edit_date(), '%{localized}' )); 
263             set("volume_editor", details.volume.editor()); 
264             set("volume_id", details.volume.id()); 
265             set("label", details.volume.label()); 
266             set("owning_lib" , typeof details.volume.owning_lib() == 'object' ? details.volume.owning_lib().shortname() : data.hash.aou[ details.volume.owning_lib() ].shortname()); 
267             set_tooltip("owning_lib" , typeof details.volume.owning_lib() == 'object' ? details.volume.owning_lib().name() : data.hash.aou[ details.volume.owning_lib() ].name()); 
268             set("record", details.volume.record()); 
269             set("notes", details.volume.notes()); 
270             set("uri_maps", details.volume.uri_maps()); 
271             set("uris", details.volume.uris()); 
272         }
273
274         set("transit_copy_status", '');
275         set_tooltip("transit_copy_status", '');
276         set("dest", '');
277         set("dest_recv_time", '');
278         set("transit_id", '');
279         set("persistant_transfer", '');
280         set("prev_hop", '');
281         set("source", '');
282         set("source_send_time", '');
283         set("target_copy", '');
284         set("hold_transit_copy", '');
285
286         if (details.transit) {
287             JSAN.use('circ.util'); var columns = circ.util.transit_columns({});
288
289             JSAN.use('util.list'); var list = new util.list('transit');
290             list.init( { 'columns' : columns, 'map_row_to_columns' : circ.util.std_map_row_to_columns(), });
291             list.append( { 'row' : { 'my' : { 'atc' : details.transit, } } });
292
293             var transit_copy_status = typeof details.transit.copy_status() == 'object' ? details.transit.copy_status() : data.hash.ccs[ details.transit.copy_status() ];
294                 set("transit_copy_status", transit_copy_status.name() );
295                 set_tooltip("transit_copy_status", document.getElementById('circStrings').getFormattedString(
296                     'staff.circ.copy_details.copy_status_tooltip',
297                     [
298                         get_localized_bool( transit_copy_status.opac_visible() ), 
299                         get_localized_bool( transit_copy_status.holdable() ) 
300                     ]
301                 ));
302             set("dest", details.transit.dest()); 
303             set("dest_recv_time", util.date.formatted_date( details.transit.dest_recv_time(), '%{localized}' )); 
304             set("transit_id", details.transit.id()); 
305             set("persistant_transfer", details.transit.persistant_transfer()); 
306             set("prev_hop", details.transit.prev_hop()); 
307             set("source", details.transit.source()); 
308             set("source_send_time", util.date.formatted_date( details.transit.source_send_time(), '%{localized}' )); 
309             set("target_copy", details.transit.target_copy()); 
310             set("hold_transit_copy", details.transit.hold_transit_copy()); 
311         } else {
312             $('transit_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.not_transit'));
313         }
314
315         set("checkin_lib", '');
316         set_tooltip("checkin_lib", '');
317         set("checkin_workstation",""); 
318         set("checkin_staff", '');
319         set("checkin_time", '');
320         set("checkin_scan_time", '');
321         set("circ_circ_lib" , '');
322         set_tooltip("circ_circ_lib" , '');
323         set("circ_staff", '');
324         set("desk_renewal", '');
325         set("due_date", '');
326         set("duration", '');
327         set("duration_rule", '');
328         set("fine_interval", '');
329         set("circ_id", '');
330         set("max_fine", '');
331         set("max_fine_rule", '');
332         set("opac_renewal", '');
333         set("phone_renewal", '');
334         set("recurring_fine", '');
335         set("recurring_fine_rule", '');
336         set("renewal_remaining", '');
337         set("stop_fines", '');
338         set("stop_fines_time", '');
339         set("target_copy", '');
340         set("circ_usr", '');
341         set("xact_finish", '');
342         set("xact_start", '');
343         set("create_time", '');
344         set("workstation", '');
345         set("renewal_workstation", '');
346         set("checkout_workstation", '');
347         set("billings", '');
348         set("payments", '');
349         set("billable_transaction", '');
350         set("circ_type", '');
351         set("billing_total", '');
352         set("payment_total", '');
353         set("patron_name", '');
354         set("prev_patron_name", '');
355         set("prev_num_circs", '');
356         set("prev_num_renewals", '');
357         set("prev_xact_start", '');
358         set("prev_checkout_workstation", '');
359         set("prev_renewal_time", '');
360         set("prev_stop_fines", '');
361         set("prev_stop_fines_time", '');
362         set("prev_renewal_workstation", '');
363         set("prev_checkin_workstation", '');
364         set("prev_last_checkin_time", '');
365         set("prev_last_checkin_scan_time", '');
366
367         if (details.circ) {
368             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) {};
369             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) {};
370             if (details.circ.checkin_workstation()) {
371                 set("checkin_workstation", details.circ.checkin_workstation().name()); 
372             }
373             set("checkin_staff", details.circ.checkin_staff()); 
374             set("checkin_time", util.date.formatted_date( details.circ.checkin_time(), '%{localized}' )); 
375             set("last_checkin_time", util.date.formatted_date( details.circ.checkin_time(), '%{localized}' )); 
376             set("checkin_scan_time", util.date.formatted_date( details.circ.checkin_scan_time(), '%{localized}' )); 
377             set("last_checkin_scan_time", util.date.formatted_date( details.circ.checkin_scan_time(), '%{localized}' )); 
378             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) {};
379             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) {};
380             set("circ_staff", details.circ.circ_staff()); 
381             set("desk_renewal", details.circ.desk_renewal()); 
382             set("due_date", util.date.formatted_date( details.circ.due_date(), '%{localized}' )); 
383             set("duration", details.circ.duration()); 
384             set("fine_interval", details.circ.fine_interval()); 
385             set("circ_id", details.circ.id()); 
386             set("max_fine", details.circ.max_fine()); 
387             set("opac_renewal", details.circ.opac_renewal()); 
388             set("phone_renewal", details.circ.phone_renewal()); 
389             set("renewal_type", renewal_composite_kludge(details.circ));
390             set("recurring_fine", details.circ.recurring_fine()); 
391             set("renewal_remaining", details.circ.renewal_remaining()); 
392             set("stop_fines", details.circ.stop_fines()); 
393             set("stop_fines_time", util.date.formatted_date( details.circ.stop_fines_time(), '%{localized}' )); 
394             set("target_copy", details.circ.target_copy()); 
395             set("circ_usr", details.circ.usr()); 
396             network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), details.circ.usr() ], function(preq) {
397                 var r_au = preq.getResultObject();
398                 JSAN.use('patron.util');
399                 set(
400                     'patron_name', 
401                     patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(),
402                     details.circ.usr()
403                 );
404             });
405             set("xact_finish", util.date.formatted_date( details.circ.xact_finish(), '%{localized}' )); 
406             set("xact_start", util.date.formatted_date( details.circ.xact_start(), '%{localized}' )); 
407             set("create_time", util.date.formatted_date( details.circ.create_time(), '%{localized}' )); 
408             set("workstation", details.circ.workstation()); 
409             if (get_bool(details.circ.opac_renewal())||get_bool(details.circ.phone_renewal())||get_bool(details.circ.desk_renewal())) {
410                 set("renewal_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() ); 
411                 network.simple_request('FM_CIRC_CHAIN_SUMMARY', [ses(), details.circ.id() ], function(req) {
412                     try {
413                         var summary = req.getResultObject();
414                         set("num_circs", summary.num_circs());
415                         set("num_renewals", Number(summary.num_circs()) - 1);
416                         set("xact_start", util.date.formatted_date( summary.start_time(), '%{localized}' )); 
417                         set("checkout_workstation", summary.checkout_workstation());
418                         set("renewal_time", util.date.formatted_date( summary.last_renewal_time(), '%{localized}' )); 
419                         set("stop_fines", summary.last_stop_fines());
420                         set("stop_fines_time", util.date.formatted_date( summary.last_stop_fines_time(), '%{localized}' )); 
421                         set("renewal_workstation", summary.last_renewal_workstation());
422                         set("checkin_workstation", summary.last_checkin_workstation());
423                         set("last_checkin_time", util.date.formatted_date( summary.last_checkin_time(), '%{localized}' )); 
424                         set("last_checkin_scan_time", util.date.formatted_date( summary.last_checkin_scan_time(), '%{localized}' )); 
425                     } catch(E) {
426                         alert('Error in alternate_copy_summary.js, FM_CIRC_CHAIN: ' + E);
427                     }
428                 } );
429             } else {
430                 set("checkout_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
431             }
432             network.simple_request('FM_CIRC_PREV_CHAIN_SUMMARY', [ses(), details.circ.id() ], function(req) {
433                 try {
434                     var robj = req.getResultObject();
435                     if (!robj || typeof robj == 'null') { return; }
436                     var summary = robj['summary'];
437                     network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), robj['usr'] ], function(preq) {
438                         var r_au = preq.getResultObject();
439                         JSAN.use('patron.util');
440                         set(
441                             'prev_patron_name', 
442                             patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(),
443                             robj['usr']
444                         );
445                     });
446                     set("prev_num_circs", summary.num_circs());
447                     set("prev_num_renewals", Number(summary.num_circs()) - 1);
448                     set("prev_xact_start", util.date.formatted_date( summary.start_time(), '%{localized}' )); 
449                     set("prev_checkout_workstation", summary.checkout_workstation());
450                     set("prev_renewal_time", util.date.formatted_date( summary.last_renewal_time(), '%{localized}' )); 
451                     set("prev_stop_fines", summary.last_stop_fines());
452                     set("prev_stop_fines_time", util.date.formatted_date( summary.last_stop_fines_time(), '%{localized}' )); 
453                     set("prev_renewal_workstation", summary.last_renewal_workstation());
454                     set("prev_checkin_workstation", summary.last_checkin_workstation());
455                     set("prev_last_checkin_time", util.date.formatted_date( summary.last_checkin_time(), '%{localized}' )); 
456                     set("prev_last_checkin_scan_time", util.date.formatted_date( summary.last_checkin_scan_time(), '%{localized}' )); 
457                 } catch(E) {
458                     alert('Error in alternate_copy_summary.js, FM_CIRC_PREV_CHAIN: ' + E);
459                 }
460             });
461             set("billings", details.circ.billings()); 
462             set("payments", details.circ.payments()); 
463             set("billable_transaction", details.circ.billable_transaction()); 
464             set("circ_type", details.circ.circ_type()); 
465             set("billing_total", details.circ.billing_total()); 
466             set("payment_total", details.circ.payment_total()); 
467             if (! details.circ.checkin_time() ) {
468                 set("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
469                     'staff.circ.copy_details.recurring_fine_rule_format',
470                     [
471                         details.circ.recurring_fine_rule().name(),
472                         details.circ.recurring_fine_rule().id(),
473                         details.circ.recurring_fine_rule().low(),
474                         details.circ.recurring_fine_rule().normal(),
475                         details.circ.recurring_fine_rule().high(),
476                         details.circ.recurring_fine_rule().recurrence_interval()
477                     ]
478                 )); 
479                 set_tooltip("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
480                     'staff.circ.copy_details.recurring_fine_rule_tooltip_format',
481                     [
482                         details.circ.recurring_fine_rule().name(),
483                         details.circ.recurring_fine_rule().id(),
484                         details.circ.recurring_fine_rule().low(),
485                         details.circ.recurring_fine_rule().normal(),
486                         details.circ.recurring_fine_rule().high(),
487                         details.circ.recurring_fine_rule().recurrence_interval()
488                     ]
489                 )); 
490                 set("duration_rule", document.getElementById('circStrings').getFormattedString(
491                     'staff.circ.copy_details.duration_rule_format',
492                     [
493                         details.circ.duration_rule().name(),
494                         details.circ.duration_rule().id(),
495                         details.circ.duration_rule().shrt(),
496                         details.circ.duration_rule().normal(),
497                         details.circ.duration_rule().extended(),
498                         details.circ.duration_rule().max_renewals()
499                     ]
500                 )); 
501                 set_tooltip("duration_rule", document.getElementById('circStrings').getFormattedString(
502                     'staff.circ.copy_details.duration_rule_tooltip_format',
503                     [
504                         details.circ.duration_rule().name(),
505                         details.circ.duration_rule().id(),
506                         details.circ.duration_rule().shrt(),
507                         details.circ.duration_rule().normal(),
508                         details.circ.duration_rule().extended(),
509                         details.circ.duration_rule().max_renewals()
510                     ]
511                 )); 
512                 set("max_fine_rule", document.getElementById('circStrings').getFormattedString(
513                     'staff.circ.copy_details.max_fine_rule_format',
514                     [
515                         details.circ.max_fine_rule().name(),
516                         details.circ.max_fine_rule().id(),
517                         details.circ.max_fine_rule().amount(),
518                         details.circ.max_fine_rule().is_percent()
519                     ]
520                 ));
521                 set_tooltip("max_fine_rule", document.getElementById('circStrings').getFormattedString(
522                     'staff.circ.copy_details.max_fine_rule_tooltip_format',
523                     [
524                         details.circ.max_fine_rule().name(),
525                         details.circ.max_fine_rule().id(),
526                         details.circ.max_fine_rule().amount(),
527                         details.circ.max_fine_rule().is_percent()
528                     ]
529                 ));
530             }
531         }
532
533         set("hold_status", '');
534         set("transit", '');
535         set("capture_time", '');
536         set("current_copy", '');
537         set("email_notify", '');
538         set("expire_time", '');
539         set("fulfillment_lib", '');
540         set_tooltip("fulfillment_lib", '');
541         set("fulfillment_staff", '');
542         set("fulfillment_time", '');
543         set("hold_type", '');
544         set("holdable_formats", '');
545         set("hold_id", '');
546         set("phone_notify", '');
547         set("pickup_lib", '');
548         set_tooltip("pickup_lib", '');
549         set("prev_check_time", '');
550         set("request_lib", '');
551         set_tooltip("request_lib", '');
552         set("request_time", '');
553         set("requestor", '');
554         set("selection_depth", '');
555         set("selection_ou", '');
556         set_tooltip("selection_ou", '');
557         set("target", '');
558         set("hold_usr", '');
559         set("cancel_time", '');
560         set("notify_time", '');
561         set("notify_count", '');
562         set("notifications", '');
563         set("bib_rec", '');
564         set("eligible_copies", '');
565         set("frozen", '');
566         set("thaw_date", '');
567         set("shelf_time", '');
568         set("cancel_cause", '');
569         set("cancel_note", '');
570         set("notes", '');
571
572         if (details.hold) {
573             var better_fleshed_hold_blob = network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative',[ ses(), details.hold.id() ]);
574             var status_robj = better_fleshed_hold_blob.status;
575             JSAN.use('circ.util');
576             var columns = circ.util.hold_columns( 
577                 { 
578                     'request_time' : { 'hidden' : false },
579                     'pickup_lib_shortname' : { 'hidden' : false },
580                     'hold_type' : { 'hidden' : true },
581                     'current_copy' : { 'hidden' : true },
582                     'capture_time' : { 'hidden' : true },
583                     'email_notify' : { 'hidden' : false },
584                     'phone_notify' : { 'hidden' : false },
585                 } 
586             );
587
588             JSAN.use('util.list'); var list = new util.list('hold');
589             list.init( { 'columns' : columns, 'map_row_to_columns' : circ.util.std_map_row_to_columns(), });
590             list.append( { 'row' : { 'my' : { 'ahr' : better_fleshed_hold_blob.hold, 'acp' : details.copy, 'status' : status_robj, } } });
591
592             JSAN.use('patron.util'); 
593             var au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), details.hold.usr() );
594             $('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()]) );
595
596             set("hold_status", details.hold.status()); 
597             set("transit", details.hold.transit()); 
598             set("capture_time", util.date.formatted_date( details.hold.capture_time(), '%{localized}' )); 
599             set("current_copy", details.hold.current_copy()); 
600             set("email_notify", details.hold.email_notify()); 
601             set("expire_time", util.date.formatted_date( details.hold.expire_time(), '%{localized}' )); 
602             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) {}
603             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) {}
604             set("fulfillment_staff", details.hold.fulfillment_staff()); 
605             set("fulfillment_time", util.date.formatted_date( details.hold.fulfillment_time(), '%{localized}' )); 
606             set("hold_type", details.hold.hold_type()); 
607             set("holdable_formats", details.hold.holdable_formats()); 
608             set("hold_id", details.hold.id()); 
609             set("phone_notify", details.hold.phone_notify()); 
610             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) {}
611             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) {}
612             set("prev_check_time", util.date.formatted_date( details.hold.prev_check_time(), '%{localized}' )); 
613             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) {}
614             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) {}
615             set("request_time", util.date.formatted_date( details.hold.request_time(), '%{localized}' )); 
616             set("requestor", details.hold.requestor()); 
617             set("selection_depth", details.hold.selection_depth()); 
618             set("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().shortname() : data.hash.aou[ details.hold.selection_ou() ].shortname() ); 
619             set_tooltip("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().name() : data.hash.aou[ details.hold.selection_ou() ].name() ); 
620             set("target", details.hold.target()); 
621             set("hold_usr", details.hold.usr()); 
622             set("cancel_time", util.date.formatted_date( details.hold.cancel_time(), '%{localized}' )); 
623             set("notify_time", util.date.formatted_date( details.hold.notify_time(), '%{localized}' )); 
624             set("notify_count", details.hold.notify_count()); 
625             set("notifications", details.hold.notifications()); 
626             set("bib_rec", details.hold.bib_rec()); 
627             set("eligible_copies", details.hold.eligible_copies()); 
628             set("frozen", details.hold.frozen()); 
629             set("thaw_date", util.date.formatted_date( details.hold.thaw_date(), '%{localized}' )); 
630             set("shelf_time", util.date.formatted_date( details.hold.shelf_time(), '%{localized}' )); 
631             set("cancel_cause", details.hold.cancel_cause()); 
632             set("cancel_note", details.hold.cancel_note()); 
633             set("notes", details.hold.notes()); 
634         } else {
635             if (details.copy.status() == 8 /* ON HOLDS SHELF */) {
636                 $('hold_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.bad_hold_status'));
637             } else {
638                 $('hold_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.no_hold'));
639             }
640         }
641
642         var x = document.getElementById('cat_deck');
643         if (x) {
644             JSAN.use('util.deck');
645             var d = new util.deck('cat_deck');
646             d.reset_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : details.mvr ? details.mvr.doc_id() : -1 } );
647         }
648
649     } catch(E) {
650         alert(E);
651     }
652 }