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