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