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