]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/circ/alternate_copy_summary.js
17abb99d827d0fee1e90eaa6e5f82257e3475205
[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
452             if (details.circ.usr()) {
453                 set("circ_usr", details.circ.usr()); 
454                 network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',
455                     [ ses(), details.circ.usr() ], function(preq) {
456                     var r_au = preq.getResultObject();
457                     JSAN.use('patron.util');
458                     set(
459                         'patron_name', 
460                         patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(),
461                         details.circ.usr()
462                     );
463                     set_tooltip('patron_name','circ id ' + details.circ.id());
464                 });
465             } else {
466                 set("circ_usr", "");
467                 set('patron_name', document.getElementById(
468                     'circStrings').getString('staff.circ.aged_circ'));
469                 set_tooltip('patron_name','circ id ' + details.circ.id());
470             }
471             set("xact_finish", util.date.formatted_date( details.circ.xact_finish(), '%{localized}' )); 
472             set("xact_start", util.date.formatted_date( details.circ.xact_start(), '%{localized}' )); 
473             set("create_time", util.date.formatted_date( details.circ.create_time(), '%{localized}' )); 
474             set("workstation", details.circ.workstation()); 
475             if (get_bool(details.circ.opac_renewal())||get_bool(details.circ.phone_renewal())||get_bool(details.circ.desk_renewal())) {
476                 set("renewal_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() ); 
477                 network.simple_request('FM_CIRC_CHAIN_SUMMARY', [ses(), details.circ.id() ], function(req) {
478                     try {
479                         var summary = req.getResultObject();
480                         set("num_circs", summary.num_circs());
481                         set("num_renewals", Number(summary.num_circs()) - 1);
482                         set("xact_start", util.date.formatted_date( summary.start_time(), '%{localized}' )); 
483                         set("checkout_workstation", summary.checkout_workstation());
484                         set("renewal_time", util.date.formatted_date( summary.last_renewal_time(), '%{localized}' )); 
485                         set("stop_fines", summary.last_stop_fines());
486                         set("stop_fines_time", util.date.formatted_date( summary.last_stop_fines_time(), '%{localized}' )); 
487                         set("renewal_workstation", summary.last_renewal_workstation());
488                         set("checkin_workstation", summary.last_checkin_workstation());
489                         set("last_checkin_time", util.date.formatted_date( summary.last_checkin_time(), '%{localized}' )); 
490                         set("last_checkin_scan_time", util.date.formatted_date( summary.last_checkin_scan_time(), '%{localized}' )); 
491                     } catch(E) {
492                         alert('Error in alternate_copy_summary.js, FM_CIRC_CHAIN: ' + E);
493                     }
494                 } );
495             } else {
496                 set("checkout_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
497             }
498             network.simple_request('FM_CIRC_PREV_CHAIN_SUMMARY', [ses(), details.circ.id() ], function(req) {
499                 try {
500                     var robj = req.getResultObject();
501                     if (!robj || typeof robj == 'null') { return; }
502                     var summary = robj['summary'];
503                     if (robj['usr']) {
504                         network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ ses(), robj['usr'] ], function(preq) {
505                             var r_au = preq.getResultObject();
506                             JSAN.use('patron.util');
507                             set(
508                                 'prev_patron_name', 
509                                 patron.util.format_name( r_au ) + ' : ' + r_au.card().barcode(),
510                                 robj['usr']
511                             );
512                             set_tooltip('prev_patron_name','circ chain prior to circ id ' + details.circ.id());
513                         });
514                     } else {
515                         set('prev_patron_name', document.getElementById(
516                             'circStrings').getString('staff.circ.aged_circ'));
517                         set_tooltip('prev_patron_name','circ chain prior to circ id ' + details.circ.id());
518                     }
519                     set("prev_num_circs", summary.num_circs());
520                     set("prev_num_renewals", Number(summary.num_circs()) - 1);
521                     set("prev_xact_start", util.date.formatted_date( summary.start_time(), '%{localized}' )); 
522                     set("prev_checkout_workstation", summary.checkout_workstation());
523                     set("prev_renewal_time", util.date.formatted_date( summary.last_renewal_time(), '%{localized}' )); 
524                     set("prev_stop_fines", summary.last_stop_fines());
525                     set("prev_stop_fines_time", util.date.formatted_date( summary.last_stop_fines_time(), '%{localized}' )); 
526                     set("prev_renewal_workstation", summary.last_renewal_workstation());
527                     set("prev_checkin_workstation", summary.last_checkin_workstation());
528                     set("prev_last_checkin_time", util.date.formatted_date( summary.last_checkin_time(), '%{localized}' )); 
529                     set("prev_last_checkin_scan_time", util.date.formatted_date( summary.last_checkin_scan_time(), '%{localized}' )); 
530                 } catch(E) {
531                     alert('Error in alternate_copy_summary.js, FM_CIRC_PREV_CHAIN: ' + E);
532                 }
533             });
534             set("billings", details.circ.billings()); 
535             set("payments", details.circ.payments()); 
536             set("billable_transaction", details.circ.billable_transaction()); 
537             set("circ_type", details.circ.circ_type()); 
538             set("billing_total", details.circ.billing_total()); 
539             set("payment_total", details.circ.payment_total()); 
540             if (! details.circ.checkin_time() ) {
541                 set("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
542                     'staff.circ.copy_details.recurring_fine_rule_format',
543                     [
544                         details.circ.recurring_fine_rule().name(),
545                         details.circ.recurring_fine_rule().id(),
546                         details.circ.recurring_fine_rule().low(),
547                         details.circ.recurring_fine_rule().normal(),
548                         details.circ.recurring_fine_rule().high(),
549                         details.circ.recurring_fine_rule().recurrence_interval()
550                     ]
551                 )); 
552                 set_tooltip("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
553                     'staff.circ.copy_details.recurring_fine_rule_tooltip_format',
554                     [
555                         details.circ.recurring_fine_rule().name(),
556                         details.circ.recurring_fine_rule().id(),
557                         details.circ.recurring_fine_rule().low(),
558                         details.circ.recurring_fine_rule().normal(),
559                         details.circ.recurring_fine_rule().high(),
560                         details.circ.recurring_fine_rule().recurrence_interval()
561                     ]
562                 )); 
563                 set("duration_rule", document.getElementById('circStrings').getFormattedString(
564                     'staff.circ.copy_details.duration_rule_format',
565                     [
566                         details.circ.duration_rule().name(),
567                         details.circ.duration_rule().id(),
568                         details.circ.duration_rule().shrt(),
569                         details.circ.duration_rule().normal(),
570                         details.circ.duration_rule().extended(),
571                         details.circ.duration_rule().max_renewals()
572                     ]
573                 )); 
574                 set_tooltip("duration_rule", document.getElementById('circStrings').getFormattedString(
575                     'staff.circ.copy_details.duration_rule_tooltip_format',
576                     [
577                         details.circ.duration_rule().name(),
578                         details.circ.duration_rule().id(),
579                         details.circ.duration_rule().shrt(),
580                         details.circ.duration_rule().normal(),
581                         details.circ.duration_rule().extended(),
582                         details.circ.duration_rule().max_renewals()
583                     ]
584                 )); 
585                 set("max_fine_rule", document.getElementById('circStrings').getFormattedString(
586                     'staff.circ.copy_details.max_fine_rule_format',
587                     [
588                         details.circ.max_fine_rule().name(),
589                         details.circ.max_fine_rule().id(),
590                         details.circ.max_fine_rule().amount(),
591                         details.circ.max_fine_rule().is_percent()
592                     ]
593                 ));
594                 set_tooltip("max_fine_rule", document.getElementById('circStrings').getFormattedString(
595                     'staff.circ.copy_details.max_fine_rule_tooltip_format',
596                     [
597                         details.circ.max_fine_rule().name(),
598                         details.circ.max_fine_rule().id(),
599                         details.circ.max_fine_rule().amount(),
600                         details.circ.max_fine_rule().is_percent()
601                     ]
602                 ));
603             }
604         }
605
606         set("hold_status", '');
607         set("transit", '');
608         set("capture_time", '');
609         set("current_copy", '');
610         set("email_notify", '');
611         set("expire_time", '');
612         set("fulfillment_lib", '');
613         set_tooltip("fulfillment_lib", '');
614         set("fulfillment_staff", '');
615         set("fulfillment_time", '');
616         set("hold_type", '');
617         set("holdable_formats", '');
618         set("hold_id", '');
619         set("phone_notify", '');
620         set("pickup_lib", '');
621         set_tooltip("pickup_lib", '');
622         set("prev_check_time", '');
623         set("request_lib", '');
624         set_tooltip("request_lib", '');
625         set("request_time", '');
626         set("requestor", '');
627         set("selection_depth", '');
628         set("selection_ou", '');
629         set_tooltip("selection_ou", '');
630         set("target", '');
631         set("hold_usr", '');
632         set("hold_patron_name", '');
633         set("cancel_time", '');
634         set("notify_time", '');
635         set("notify_count", '');
636         set("notifications", '');
637         set("bib_rec", '');
638         set("eligible_copies", '');
639         set("frozen", '');
640         set("thaw_date", '');
641         set("shelf_time", '');
642         set("cancel_cause", '');
643         set("cancel_note", '');
644         set("notes", '');
645
646         if (details.hold) {
647             var better_fleshed_hold_blob = network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative',[ ses(), details.hold.id() ]);
648             var status_robj = better_fleshed_hold_blob.status;
649             JSAN.use('circ.util');
650
651             hold_list.clear();
652             hold_list.append( { 'row' : { 'my' : { 'ahr' : better_fleshed_hold_blob.hold, 'acp' : details.copy, 'status' : status_robj, } } });
653
654             JSAN.use('patron.util'); 
655             var au_obj = patron.util.retrieve_fleshed_au_via_id( ses(), details.hold.usr() );
656             $('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()]) );
657             $('hold_patron_name').onclick = function(e) {
658                 if (e.ctrlKey) {
659                    window.xulG.new_patron_tab( {}, { 'id' : au_obj.id() } );
660                    return;
661                 }
662                 copy_to_clipboard(au_obj.card().barcode());
663             };
664
665             set("hold_status", details.hold.status()); 
666             set("transit", details.hold.transit()); 
667             set("capture_time", util.date.formatted_date( details.hold.capture_time(), '%{localized}' )); 
668             set("current_copy", details.hold.current_copy()); 
669             set("email_notify", details.hold.email_notify()); 
670             set("expire_time", util.date.formatted_date( details.hold.expire_time(), '%{localized}' )); 
671             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) {}
672             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) {}
673             set("fulfillment_staff", details.hold.fulfillment_staff()); 
674             set("fulfillment_time", util.date.formatted_date( details.hold.fulfillment_time(), '%{localized}' )); 
675             set("hold_type", details.hold.hold_type()); 
676             set("holdable_formats", details.hold.holdable_formats()); 
677             set("hold_id", details.hold.id()); 
678             set("phone_notify", details.hold.phone_notify()); 
679             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) {}
680             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) {}
681             set("prev_check_time", util.date.formatted_date( details.hold.prev_check_time(), '%{localized}' )); 
682             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) {}
683             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) {}
684             set("request_time", util.date.formatted_date( details.hold.request_time(), '%{localized}' )); 
685             set("requestor", details.hold.requestor()); 
686             set("selection_depth", details.hold.selection_depth()); 
687             set("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().shortname() : data.hash.aou[ details.hold.selection_ou() ].shortname() ); 
688             set_tooltip("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().name() : data.hash.aou[ details.hold.selection_ou() ].name() ); 
689             set("target", details.hold.target()); 
690             set("hold_usr", details.hold.usr()); 
691             set("cancel_time", util.date.formatted_date( details.hold.cancel_time(), '%{localized}' )); 
692             set("notify_time", util.date.formatted_date( details.hold.notify_time(), '%{localized}' )); 
693             set("notify_count", details.hold.notify_count()); 
694             set("notifications", details.hold.notifications()); 
695             set("bib_rec", details.hold.bib_rec()); 
696             set("eligible_copies", details.hold.eligible_copies()); 
697             set("frozen", details.hold.frozen()); 
698             set("thaw_date", util.date.formatted_date( details.hold.thaw_date(), '%{localized}' )); 
699             set("shelf_time", util.date.formatted_date( details.hold.shelf_time(), '%{localized}' )); 
700             set("cancel_cause", details.hold.cancel_cause()); 
701             set("cancel_note", details.hold.cancel_note()); 
702             set("notes", details.hold.notes()); 
703         } else {
704             if (details.copy.status() == 8 /* ON HOLDS SHELF */) {
705                 $('hold_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.bad_hold_status'));
706             } else {
707                 $('hold_caption').setAttribute('label', $('circStrings').getString('staff.circ.copy_details.no_hold'));
708             }
709         }
710
711         var x = document.getElementById('cat_deck');
712         if (x) {
713             JSAN.use('util.deck');
714             var d = new util.deck('cat_deck');
715             d.reset_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : details.mvr ? details.mvr.doc_id() : -1 } );
716         }
717
718     } catch(E) {
719         alert(E);
720     }
721 }