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');
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');
18 // timeout so xulG gets a chance to get pushed in
20 function () { xulG.from_item_details_new = false; load_item(); },
25 try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
29 function set(name,value) {
30 var nodes = document.getElementsByAttribute('name',name);
31 for (var i = 0; i < nodes.length; i++) {
32 nodes[i].setAttribute('value',value); nodes[i].value = value;
36 function set_tooltip(name,value) {
37 var nodes = document.getElementsByAttribute('name',name);
38 for (var i = 0; i < nodes.length; i++) {
39 nodes[i].setAttribute('tooltiptext',value);
43 function renewal_composite_kludge(circ) {
44 // Only a corrupt database could give us a situation where more
45 // than one of these were true at a time, right?
46 if (circ.desk_renewal() == "t")
47 return document.getElementById('circStrings').getString(
48 'staff.circ.copy_details.desk_renewal'
50 else if (circ.opac_renewal() == "t")
51 return document.getElementById('circStrings').getString(
52 'staff.circ.copy_details.opac_renewal'
54 else if (circ.phone_renewal() == "t")
55 return document.getElementById('circStrings').getString(
56 'staff.circ.copy_details.phone_renewal'
61 function load_item() {
63 if (! xulG.barcode) return;
65 if (xulG.fetched_copy_details && xulG.fetched_copy_details[xulG.barcode]) {
66 var details = xulG.fetched_copy_details[xulG.barcode];
67 // We don't want to use these details more than once (i.e., we
68 // don't want cached data after things have potentially changed).
69 delete xulG.fetched_copy_details[xulG.barcode];
71 var details = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE.authoritative', [ ses(), xulG.barcode ]);
72 // Should get back .mvr, .copy, .volume, .transit, .circ, .hold
75 if (typeof bib_brief_overlay == 'function') bib_brief_overlay( { 'mvr' : details.mvr, 'acp' : details.copy } );
86 set('types_of_resource', '');
87 set('call_numbers', '');
89 set('online_loc', '');
91 set('physical_description', '');
93 set('copy_count', '');
98 set('title',details.mvr.title());
99 set('author',details.mvr.author());
100 set('doc_id', details.mvr.doc_id());
101 set('doc_type', details.mvr.doc_type());
102 set('pubdate', details.mvr.pubdate());
103 set('isbn',details.mvr.isbn());
104 set('publisher', details.mvr.publisher());
105 set('tcn', details.mvr.tcn());
106 set('subject', details.mvr.subject());
107 set('types_of_resource', details.mvr.types_of_resource());
108 set('call_numbers', details.mvr.call_numbers());
109 set('edition', details.mvr.edition());
110 set('online_loc', details.mvr.online_loc());
111 set('synopsis', details.mvr.synopsis());
112 set('physical_description', details.mvr.physical_description());
113 set('toc', details.mvr.toc());
114 set('copy_count', details.mvr.copy_count());
115 set('series', details.mvr.series());
116 set('serials', details.mvr.serials());
118 set('title',details.copy.dummy_title());
119 set('author',details.copy.dummy_author());
120 set('isbn',details.copy.dummy_isbn());
123 set("stat_cat_entries", '');
124 set("age_protect", '');
125 set("alert_message", '');
127 set("call_number", '');
128 set("circ_as_type", '');
129 set("copy_circ_lib" , '');
130 set_tooltip("copy_circ_lib" , '');
131 set("circ_modifier", '');
132 set("circulate", '');
133 set("copy_number", '');
134 set("copy_create_date", '');
135 set("status_changed_time", '');
136 set("copy_creator", '');
139 set("deposit_amount", '');
140 set("dummy_author", '');
141 set("dummy_title", '');
142 set("copy_edit_date", '');
143 set("copy_editor", '');
144 set("fine_level", '');
147 set("loan_duration", '');
149 set("renewal_type", '');
150 set("opac_visible", '');
155 set("stat_cat_entry_copy_maps", '');
156 set("circulations", '');
157 set("total_circ_count", '');
158 set_tooltip("total_circ_count", '');
159 set("total_circ_count_prev_year", '');
160 set("total_circ_count_curr_year", '');
164 set("stat_cat_entries", details.copy.stat_cat_entries());
165 set("age_protect", details.copy.age_protect());
166 set("alert_message", details.copy.alert_message());
167 set("barcode", details.copy.barcode());
168 set("call_number", details.copy.call_number());
169 set("circ_as_type", details.copy.circ_as_type());
170 set("copy_circ_lib" , typeof details.copy.circ_lib() == 'object' ? details.copy.circ_lib().shortname() : data.hash.aou[ details.copy.circ_lib() ].shortname());
171 set_tooltip("copy_circ_lib" , typeof details.copy.circ_lib() == 'object' ? details.copy.circ_lib().name() : data.hash.aou[ details.copy.circ_lib() ].name());
172 set("circ_modifier", details.copy.circ_modifier());
173 set("circulate", 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", details.copy.fine_level());
186 set("holdable", details.copy.holdable());
187 set("copy_id", details.copy.id());
188 set("loan_duration", details.copy.loan_duration());
189 set("location", details.copy.location());
190 set("opac_visible", details.copy.opac_visible());
191 set("price", details.copy.price());
192 set("ref", details.copy.ref());
193 set("status", details.copy.status());
194 set("notes", details.copy.notes());
195 set("stat_cat_entry_copy_maps", details.copy.stat_cat_entry_copy_maps());
196 set("circulations", details.copy.circulations());
197 set("holds", details.copy.holds());
199 network.simple_request('FM_CIRC_IMPROVED_COUNT_VIA_COPY', [ses(), { 'copy' : details.copy.id() } ], function(req) {
200 var r = req.getResultObject();
201 var total = 0; var tooltip = ''; var year = {};
202 for (var i = 0; i < r.length; i++) {
203 total += Number( r[i].count() );
204 if (typeof year[ r[i].year() ] == 'undefined') year[ r[i].year() ] = 0;
205 year[ r[i].year() ] += Number( r[i].count() ); // Add original circs and renewals together
207 set( 'total_circ_count', total );
208 var curr_year = (new Date()).getFullYear();
209 var prev_year = curr_year - 1;
210 set( 'total_circ_count_curr_year', year[ curr_year ] || 0 );
211 set( 'total_circ_count_prev_year', year[ prev_year ] || 0 );
212 var keys = []; for (var i in year) { keys.push( i ); }; keys.sort();
213 for (var i = 0; i < keys.length; i++) {
214 tooltip += document.getElementById('circStrings').getFormattedString(
215 'staff.circ.copy_details.circ_count_by_year', [
216 keys[i] == -1 ? document.getElementById('circStrings').getString('staff.circ.copy_details.circ_count_by_year.legacy_label') : keys[i],
221 set_tooltip( 'total_circ_count', tooltip );
226 set("volume_create_date", '');
227 set("volume_creator", '');
229 set("volume_edit_date", '');
230 set("volume_editor", '');
231 set("volume_id", '');
233 set("owning_lib" , '');
234 set_tooltip("owning_lib" , '');
240 if (details.volume) {
241 set("copies", details.volume.copies());
242 set("volume_create_date", util.date.formatted_date( details.volume.create_date(), '%{localized}' ));
243 set("volume_creator", details.volume.creator());
244 set("deleted", details.volume.deleted());
245 set("volume_edit_date", util.date.formatted_date( details.volume.edit_date(), '%{localized}' ));
246 set("volume_editor", details.volume.editor());
247 set("volume_id", details.volume.id());
248 set("label", details.volume.label());
249 set("owning_lib" , typeof details.volume.owning_lib() == 'object' ? details.volume.owning_lib().shortname() : data.hash.aou[ details.volume.owning_lib() ].shortname());
250 set_tooltip("owning_lib" , typeof details.volume.owning_lib() == 'object' ? details.volume.owning_lib().name() : data.hash.aou[ details.volume.owning_lib() ].name());
251 set("record", details.volume.record());
252 set("notes", details.volume.notes());
253 set("uri_maps", details.volume.uri_maps());
254 set("uris", details.volume.uris());
257 set("copy_status", '');
259 set("dest_recv_time", '');
260 set("transit_id", '');
261 set("persistant_transfer", '');
264 set("source_send_time", '');
265 set("target_copy", '');
266 set("hold_transit_copy", '');
268 if (details.transit) {
269 set("copy_status", details.transit.copy_status());
270 set("dest", details.transit.dest());
271 set("dest_recv_time", util.date.formatted_date( details.transit.dest_recv_time(), '%{localized}' ));
272 set("transit_id", details.transit.id());
273 set("persistant_transfer", details.transit.persistant_transfer());
274 set("prev_hop", details.transit.prev_hop());
275 set("source", details.transit.source());
276 set("source_send_time", util.date.formatted_date( details.transit.source_send_time(), '%{localized}' ));
277 set("target_copy", details.transit.target_copy());
278 set("hold_transit_copy", details.transit.hold_transit_copy());
281 set("checkin_lib", '');
282 set_tooltip("checkin_lib", '');
283 set("checkin_workstation","");
284 set("checkin_staff", '');
285 set("checkin_time", '');
286 set("checkin_scan_time", '');
287 set("circ_circ_lib" , '');
288 set_tooltip("circ_circ_lib" , '');
289 set("circ_staff", '');
290 set("desk_renewal", '');
293 set("duration_rule", '');
294 set("fine_interval", '');
297 set("max_fine_rule", '');
298 set("opac_renewal", '');
299 set("phone_renewal", '');
300 set("recurring_fine", '');
301 set("recurring_fine_rule", '');
302 set("renewal_remaining", '');
303 set("stop_fines", '');
304 set("stop_fines_time", '');
305 set("target_copy", '');
307 set("xact_finish", '');
308 set("xact_start", '');
309 set("create_time", '');
310 set("workstation", '');
311 set("renewal_workstation", '');
312 set("checkout_workstation", '');
315 set("billable_transaction", '');
316 set("circ_type", '');
317 set("billing_total", '');
318 set("payment_total", '');
321 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) {};
322 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) {};
323 if (details.circ.checkin_workstation()) {
324 set("checkin_workstation", details.circ.checkin_workstation().name());
326 set("checkin_staff", details.circ.checkin_staff());
327 set("checkin_time", util.date.formatted_date( details.circ.checkin_time(), '%{localized}' ));
328 set("checkin_scan_time", util.date.formatted_date( details.circ.checkin_scan_time(), '%{localized}' ));
329 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) {};
330 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) {};
331 set("circ_staff", details.circ.circ_staff());
332 set("desk_renewal", details.circ.desk_renewal());
333 set("due_date", util.date.formatted_date( details.circ.due_date(), '%{localized}' ));
334 set("duration", details.circ.duration());
335 set("fine_interval", details.circ.fine_interval());
336 set("circ_id", details.circ.id());
337 set("max_fine", details.circ.max_fine());
338 set("opac_renewal", details.circ.opac_renewal());
339 set("phone_renewal", details.circ.phone_renewal());
340 set("renewal_type", renewal_composite_kludge(details.circ));
341 set("recurring_fine", details.circ.recurring_fine());
342 set("renewal_remaining", details.circ.renewal_remaining());
343 set("stop_fines", details.circ.stop_fines());
344 set("stop_fines_time", util.date.formatted_date( details.circ.stop_fines_time(), '%{localized}' ));
345 set("target_copy", details.circ.target_copy());
346 set("usr", details.circ.usr());
347 set("xact_finish", util.date.formatted_date( details.circ.xact_finish(), '%{localized}' ));
348 set("xact_start", util.date.formatted_date( details.circ.xact_start(), '%{localized}' ));
349 set("create_time", util.date.formatted_date( details.circ.create_time(), '%{localized}' ));
350 set("workstation", details.circ.workstation());
351 if (get_bool(details.circ.opac_renewal())||get_bool(details.circ.phone_renewal())||get_bool(details.circ.desk_renewal())) {
352 set("renewal_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
353 network.simple_request('FM_CIRC_CHAIN', [ses(), details.circ.id() ], function(req) { // Tiny race condition between details.circ and circs[circs.length-1] here, but meh :)
355 var circs = req.getResultObject();
356 set("checkout_workstation", (typeof circs[0].workstation() == 'object' && circs[0].workstation() != null) ? circs[0].workstation().name() : circs[0].workstation() );
358 alert('Error in alternate_copy_summary.js, FM_CIRC_CHAIN: ' + E);
362 set("checkout_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
364 set("billings", details.circ.billings());
365 set("payments", details.circ.payments());
366 set("billable_transaction", details.circ.billable_transaction());
367 set("circ_type", details.circ.circ_type());
368 set("billing_total", details.circ.billing_total());
369 set("payment_total", details.circ.payment_total());
370 if (! details.circ.checkin_time() ) {
371 set("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
372 'staff.circ.copy_details.recurring_fine_rule_format',
374 details.circ.recurring_fine_rule().name(),
375 details.circ.recurring_fine_rule().id(),
376 details.circ.recurring_fine_rule().low(),
377 details.circ.recurring_fine_rule().normal(),
378 details.circ.recurring_fine_rule().high(),
379 details.circ.recurring_fine_rule().recurrence_interval()
382 set_tooltip("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
383 'staff.circ.copy_details.recurring_fine_rule_tooltip_format',
385 details.circ.recurring_fine_rule().name(),
386 details.circ.recurring_fine_rule().id(),
387 details.circ.recurring_fine_rule().low(),
388 details.circ.recurring_fine_rule().normal(),
389 details.circ.recurring_fine_rule().high(),
390 details.circ.recurring_fine_rule().recurrence_interval()
393 set("duration_rule", document.getElementById('circStrings').getFormattedString(
394 'staff.circ.copy_details.duration_rule_format',
396 details.circ.duration_rule().name(),
397 details.circ.duration_rule().id(),
398 details.circ.duration_rule().shrt(),
399 details.circ.duration_rule().normal(),
400 details.circ.duration_rule().extended(),
401 details.circ.duration_rule().max_renewals()
404 set_tooltip("duration_rule", document.getElementById('circStrings').getFormattedString(
405 'staff.circ.copy_details.duration_rule_tooltip_format',
407 details.circ.duration_rule().name(),
408 details.circ.duration_rule().id(),
409 details.circ.duration_rule().shrt(),
410 details.circ.duration_rule().normal(),
411 details.circ.duration_rule().extended(),
412 details.circ.duration_rule().max_renewals()
415 set("max_fine_rule", document.getElementById('circStrings').getFormattedString(
416 'staff.circ.copy_details.max_fine_rule_format',
418 details.circ.max_fine_rule().name(),
419 details.circ.max_fine_rule().id(),
420 details.circ.max_fine_rule().amount(),
421 details.circ.max_fine_rule().is_percent()
424 set_tooltip("max_fine_rule", document.getElementById('circStrings').getFormattedString(
425 'staff.circ.copy_details.max_fine_rule_tooltip_format',
427 details.circ.max_fine_rule().name(),
428 details.circ.max_fine_rule().id(),
429 details.circ.max_fine_rule().amount(),
430 details.circ.max_fine_rule().is_percent()
438 set("capture_time", '');
439 set("current_copy", '');
440 set("email_notify", '');
441 set("expire_time", '');
442 set("fulfillment_lib", '');
443 set_tooltip("fulfillment_lib", '');
444 set("fulfillment_staff", '');
445 set("fulfillment_time", '');
446 set("hold_type", '');
447 set("holdable_formats", '');
449 set("phone_notify", '');
450 set("pickup_lib", '');
451 set_tooltip("pickup_lib", '');
452 set("prev_check_time", '');
453 set("request_lib", '');
454 set_tooltip("request_lib", '');
455 set("request_time", '');
456 set("requestor", '');
457 set("selection_depth", '');
458 set("selection_ou", '');
459 set_tooltip("selection_ou", '');
462 set("cancel_time", '');
463 set("notify_time", '');
464 set("notify_count", '');
465 set("notifications", '');
467 set("eligible_copies", '');
469 set("thaw_date", '');
470 set("shelf_time", '');
471 set("cancel_cause", '');
472 set("cancel_note", '');
476 set("status", details.hold.status());
477 set("transit", details.hold.transit());
478 set("capture_time", util.date.formatted_date( details.hold.capture_time(), '%{localized}' ));
479 set("current_copy", details.hold.current_copy());
480 set("email_notify", details.hold.email_notify());
481 set("expire_time", util.date.formatted_date( details.hold.expire_time(), '%{localized}' ));
482 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) {}
483 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) {}
484 set("fulfillment_staff", details.hold.fulfillment_staff());
485 set("fulfillment_time", util.date.formatted_date( details.hold.fulfillment_time(), '%{localized}' ));
486 set("hold_type", details.hold.hold_type());
487 set("holdable_formats", details.hold.holdable_formats());
488 set("hold_id", details.hold.id());
489 set("phone_notify", details.hold.phone_notify());
490 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) {}
491 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) {}
492 set("prev_check_time", util.date.formatted_date( details.hold.prev_check_time(), '%{localized}' ));
493 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) {}
494 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) {}
495 set("request_time", util.date.formatted_date( details.hold.request_time(), '%{localized}' ));
496 set("requestor", details.hold.requestor());
497 set("selection_depth", details.hold.selection_depth());
498 set("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().shortname() : data.hash.aou[ details.hold.selection_ou() ].shortname() );
499 set_tooltip("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().name() : data.hash.aou[ details.hold.selection_ou() ].name() );
500 set("target", details.hold.target());
501 set("usr", details.hold.usr());
502 set("cancel_time", util.date.formatted_date( details.hold.cancel_time(), '%{localized}' ));
503 set("notify_time", util.date.formatted_date( details.hold.notify_time(), '%{localized}' ));
504 set("notify_count", details.hold.notify_count());
505 set("notifications", details.hold.notifications());
506 set("bib_rec", details.hold.bib_rec());
507 set("eligible_copies", details.hold.eligible_copies());
508 set("frozen", details.hold.frozen());
509 set("thaw_date", util.date.formatted_date( details.hold.thaw_date(), '%{localized}' ));
510 set("shelf_time", util.date.formatted_date( details.hold.shelf_time(), '%{localized}' ));
511 set("cancel_cause", details.hold.cancel_cause());
512 set("cancel_note", details.hold.cancel_note());
513 set("notes", details.hold.notes());
516 var x = document.getElementById('cat_deck');
518 JSAN.use('util.deck');
519 var d = new util.deck('cat_deck');
520 d.reset_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : details.mvr ? details.mvr.doc_id() : -1 } );