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