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