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');
19 // timeout so xulG gets a chance to get pushed in
21 function () { xulG.from_item_details_new = false; load_item(); },
26 try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
30 function set(name,value) {
31 var nodes = document.getElementsByAttribute('name',name);
32 for (var i = 0; i < nodes.length; i++) {
33 nodes[i].setAttribute('value',value); nodes[i].value = value;
37 function set_tooltip(name,value) {
38 var nodes = document.getElementsByAttribute('name',name);
39 for (var i = 0; i < nodes.length; i++) {
40 nodes[i].setAttribute('tooltiptext',value);
44 function renewal_composite_kludge(circ) {
45 // Only a corrupt database could give us a situation where more
46 // than one of these were true at a time, right?
47 if (circ.desk_renewal() == "t")
48 return document.getElementById('circStrings').getString(
49 'staff.circ.copy_details.desk_renewal'
51 else if (circ.opac_renewal() == "t")
52 return document.getElementById('circStrings').getString(
53 'staff.circ.copy_details.opac_renewal'
55 else if (circ.phone_renewal() == "t")
56 return document.getElementById('circStrings').getString(
57 'staff.circ.copy_details.phone_renewal'
62 function load_item() {
64 if (! xulG.barcode) return;
66 if (xulG.fetched_copy_details && xulG.fetched_copy_details[xulG.barcode]) {
67 var details = xulG.fetched_copy_details[xulG.barcode];
68 // We don't want to use these details more than once (i.e., we
69 // don't want cached data after things have potentially changed).
70 delete xulG.fetched_copy_details[xulG.barcode];
72 var details = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE.authoritative', [ ses(), xulG.barcode ]);
73 // Should get back .mvr, .copy, .volume, .transit, .circ, .hold
76 if (typeof bib_brief_overlay == 'function') bib_brief_overlay( { 'mvr' : details.mvr, 'acp' : details.copy } );
78 set("stat_cat_entries", '');
79 set("age_protect", '');
80 set("alert_message", '');
82 set("call_number", '');
83 set("circ_as_type", '');
84 set("copy_circ_lib" , '');
85 set_tooltip("copy_circ_lib" , '');
86 set("circ_modifier", '');
88 set("copy_number", '');
89 set("copy_create_date", '');
90 set("status_changed_time", '');
91 set("copy_creator", '');
94 set("deposit_amount", '');
95 set("dummy_author", '');
96 set("dummy_title", '');
97 set("copy_edit_date", '');
98 set("copy_editor", '');
99 set("fine_level", '');
102 set("loan_duration", '');
104 set_tooltip("location", '');
105 set("renewal_type", '');
106 set("opac_visible", '');
109 set("copy_status", '');
110 set_tooltip("copy_status", '');
112 set("stat_cat_entry_copy_maps", '');
113 set("circulations", '');
114 set("total_circ_count", '');
115 set_tooltip("total_circ_count", '');
116 set("total_circ_count_prev_year", '');
117 set("total_circ_count_curr_year", '');
121 set("stat_cat_entries", details.copy.stat_cat_entries());
122 set("age_protect", details.copy.age_protect());
123 set("alert_message", details.copy.alert_message());
124 set("barcode", details.copy.barcode());
125 if (typeof details.copy.call_number() == 'object') {
126 set("call_number", details.copy.call_number().label());
128 network.simple_request('FM_ACN_RETRIEVE.authoritative',[details.copy.call_number()], function(req) {
129 var acn_obj = req.getResultObject();
130 set("call_number", acn_obj.label());
133 set("circ_as_type", details.copy.circ_as_type());
134 set("copy_circ_lib" , typeof details.copy.circ_lib() == 'object' ? details.copy.circ_lib().shortname() : data.hash.aou[ details.copy.circ_lib() ].shortname());
135 set_tooltip("copy_circ_lib" , typeof details.copy.circ_lib() == 'object' ? details.copy.circ_lib().name() : data.hash.aou[ details.copy.circ_lib() ].name());
136 set("circ_modifier", details.copy.circ_modifier());
137 set("circulate", get_localized_bool( details.copy.circulate() ));
138 set("copy_number", details.copy.copy_number());
139 set("copy_create_date", util.date.formatted_date( details.copy.create_date(), '%{localized}' ));
140 set("status_changed_time", util.date.formatted_date( details.copy.status_changed_time(), '%{localized}' ));
141 set("copy_creator", details.copy.creator());
142 set("deleted", details.copy.deleted());
143 set("deposit", details.copy.deposit());
144 set("deposit_amount", details.copy.deposit_amount());
145 set("dummy_author", details.copy.dummy_author());
146 set("dummy_title", details.copy.dummy_title());
147 set("copy_edit_date", util.date.formatted_date( details.copy.edit_date(), '%{localized}' ));
148 set("copy_editor", details.copy.editor());
149 set("fine_level", cat.util.render_fine_level( details.copy.fine_level() ));
150 set("holdable", get_localized_bool( details.copy.holdable() ));
151 set("copy_id", details.copy.id());
152 set("loan_duration", cat.util.render_loan_duration( details.copy.loan_duration() ));
153 var copy_location = typeof details.copy.location() == 'object' ? details.copy.location() : data.lookup('acpl',details.copy.location());
154 set("location", copy_location.name());
155 set_tooltip("location", document.getElementById('circStrings').getFormattedString(
156 'staff.circ.copy_details.location_tooltip',
158 get_localized_bool( copy_location.circulate() ),
159 get_localized_bool( copy_location.holdable() ),
160 get_localized_bool( copy_location.hold_verify() ),
161 get_localized_bool( copy_location.opac_visible() )
164 set("opac_visible", get_localized_bool( details.copy.opac_visible() ));
165 set("price", details.copy.price());
166 set("ref", get_localized_bool( details.copy.ref() ));
167 var copy_status = typeof details.copy.status() == 'object' ? details.copy.status() : data.hash.ccs[ details.copy.status() ];
168 set("copy_status", copy_status.name() );
169 set_tooltip("copy_status", document.getElementById('circStrings').getFormattedString(
170 'staff.circ.copy_details.copy_status_tooltip',
172 get_localized_bool( copy_status.opac_visible() ),
173 get_localized_bool( copy_status.holdable() )
176 set("notes", details.copy.notes());
177 set("stat_cat_entry_copy_maps", details.copy.stat_cat_entry_copy_maps());
178 set("circulations", details.copy.circulations());
179 set("holds", details.copy.holds());
181 network.simple_request('FM_CIRC_IMPROVED_COUNT_VIA_COPY', [ses(), { 'copy' : details.copy.id() } ], function(req) {
182 var r = req.getResultObject();
183 var total = 0; var tooltip = ''; var year = {};
184 for (var i = 0; i < r.length; i++) {
185 total += Number( r[i].count() );
186 if (typeof year[ r[i].year() ] == 'undefined') year[ r[i].year() ] = 0;
187 year[ r[i].year() ] += Number( r[i].count() ); // Add original circs and renewals together
189 set( 'total_circ_count', total );
190 var curr_year = (new Date()).getFullYear();
191 var prev_year = curr_year - 1;
192 set( 'total_circ_count_curr_year', year[ curr_year ] || 0 );
193 set( 'total_circ_count_prev_year', year[ prev_year ] || 0 );
194 var keys = []; for (var i in year) { keys.push( i ); }; keys.sort();
195 for (var i = 0; i < keys.length; i++) {
196 tooltip += document.getElementById('circStrings').getFormattedString(
197 'staff.circ.copy_details.circ_count_by_year', [
198 keys[i] == -1 ? document.getElementById('circStrings').getString('staff.circ.copy_details.circ_count_by_year.legacy_label') : keys[i],
203 set_tooltip( 'total_circ_count', tooltip );
208 set("volume_create_date", '');
209 set("volume_creator", '');
211 set("volume_edit_date", '');
212 set("volume_editor", '');
213 set("volume_id", '');
215 set("owning_lib" , '');
216 set_tooltip("owning_lib" , '');
222 if (details.volume) {
223 set("copies", details.volume.copies());
224 set("volume_create_date", util.date.formatted_date( details.volume.create_date(), '%{localized}' ));
225 set("volume_creator", details.volume.creator());
226 set("deleted", details.volume.deleted());
227 set("volume_edit_date", util.date.formatted_date( details.volume.edit_date(), '%{localized}' ));
228 set("volume_editor", details.volume.editor());
229 set("volume_id", details.volume.id());
230 set("label", details.volume.label());
231 set("owning_lib" , typeof details.volume.owning_lib() == 'object' ? details.volume.owning_lib().shortname() : data.hash.aou[ details.volume.owning_lib() ].shortname());
232 set_tooltip("owning_lib" , typeof details.volume.owning_lib() == 'object' ? details.volume.owning_lib().name() : data.hash.aou[ details.volume.owning_lib() ].name());
233 set("record", details.volume.record());
234 set("notes", details.volume.notes());
235 set("uri_maps", details.volume.uri_maps());
236 set("uris", details.volume.uris());
239 set("transit_copy_status", '');
240 set_tooltip("transit_copy_status", '');
242 set("dest_recv_time", '');
243 set("transit_id", '');
244 set("persistant_transfer", '');
247 set("source_send_time", '');
248 set("target_copy", '');
249 set("hold_transit_copy", '');
251 if (details.transit) {
252 var transit_copy_status = typeof details.transit.copy_status() == 'object' ? details.transit.copy_status() : data.hash.ccs[ details.transit.copy_status() ];
253 set("transit_copy_status", transit_copy_status.name() );
254 set_tooltip("transit_copy_status", document.getElementById('circStrings').getFormattedString(
255 'staff.circ.copy_details.copy_status_tooltip',
257 get_localized_bool( transit_copy_status.opac_visible() ),
258 get_localized_bool( transit_copy_status.holdable() )
261 set("dest", details.transit.dest());
262 set("dest_recv_time", util.date.formatted_date( details.transit.dest_recv_time(), '%{localized}' ));
263 set("transit_id", details.transit.id());
264 set("persistant_transfer", details.transit.persistant_transfer());
265 set("prev_hop", details.transit.prev_hop());
266 set("source", details.transit.source());
267 set("source_send_time", util.date.formatted_date( details.transit.source_send_time(), '%{localized}' ));
268 set("target_copy", details.transit.target_copy());
269 set("hold_transit_copy", details.transit.hold_transit_copy());
272 set("checkin_lib", '');
273 set_tooltip("checkin_lib", '');
274 set("checkin_workstation","");
275 set("checkin_staff", '');
276 set("checkin_time", '');
277 set("checkin_scan_time", '');
278 set("circ_circ_lib" , '');
279 set_tooltip("circ_circ_lib" , '');
280 set("circ_staff", '');
281 set("desk_renewal", '');
284 set("duration_rule", '');
285 set("fine_interval", '');
288 set("max_fine_rule", '');
289 set("opac_renewal", '');
290 set("phone_renewal", '');
291 set("recurring_fine", '');
292 set("recurring_fine_rule", '');
293 set("renewal_remaining", '');
294 set("stop_fines", '');
295 set("stop_fines_time", '');
296 set("target_copy", '');
298 set("xact_finish", '');
299 set("xact_start", '');
300 set("create_time", '');
301 set("workstation", '');
302 set("renewal_workstation", '');
303 set("checkout_workstation", '');
306 set("billable_transaction", '');
307 set("circ_type", '');
308 set("billing_total", '');
309 set("payment_total", '');
312 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) {};
313 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) {};
314 if (details.circ.checkin_workstation()) {
315 set("checkin_workstation", details.circ.checkin_workstation().name());
317 set("checkin_staff", details.circ.checkin_staff());
318 set("checkin_time", util.date.formatted_date( details.circ.checkin_time(), '%{localized}' ));
319 set("checkin_scan_time", util.date.formatted_date( details.circ.checkin_scan_time(), '%{localized}' ));
320 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) {};
321 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) {};
322 set("circ_staff", details.circ.circ_staff());
323 set("desk_renewal", details.circ.desk_renewal());
324 set("due_date", util.date.formatted_date( details.circ.due_date(), '%{localized}' ));
325 set("duration", details.circ.duration());
326 set("fine_interval", details.circ.fine_interval());
327 set("circ_id", details.circ.id());
328 set("max_fine", details.circ.max_fine());
329 set("opac_renewal", details.circ.opac_renewal());
330 set("phone_renewal", details.circ.phone_renewal());
331 set("renewal_type", renewal_composite_kludge(details.circ));
332 set("recurring_fine", details.circ.recurring_fine());
333 set("renewal_remaining", details.circ.renewal_remaining());
334 set("stop_fines", details.circ.stop_fines());
335 set("stop_fines_time", util.date.formatted_date( details.circ.stop_fines_time(), '%{localized}' ));
336 set("target_copy", details.circ.target_copy());
337 set("usr", details.circ.usr());
338 set("xact_finish", util.date.formatted_date( details.circ.xact_finish(), '%{localized}' ));
339 set("xact_start", util.date.formatted_date( details.circ.xact_start(), '%{localized}' ));
340 set("create_time", util.date.formatted_date( details.circ.create_time(), '%{localized}' ));
341 set("workstation", details.circ.workstation());
342 if (get_bool(details.circ.opac_renewal())||get_bool(details.circ.phone_renewal())||get_bool(details.circ.desk_renewal())) {
343 set("renewal_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
344 network.simple_request('FM_CIRC_CHAIN_SUMMARY', [ses(), details.circ.id() ], function(req) {
346 var summary = req.getResultObject();
347 set("checkout_workstation", summary.checkout_workstation());
348 set("renewal_workstation", summary.last_renewal_workstation());
349 set("checkin_workstation", summary.last_checkin_workstation());
350 set("stop_fines", summary.last_stop_fines());
351 set("stop_fines_time", util.date.formatted_date( summary.last_stop_fines_time(), '%{localized}' ));
352 set("renewal_time", util.date.formatted_date( summary.last_renewal_time(), '%{localized}' ));
354 alert('Error in alternate_copy_summary.js, FM_CIRC_CHAIN: ' + E);
358 set("checkout_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
360 set("billings", details.circ.billings());
361 set("payments", details.circ.payments());
362 set("billable_transaction", details.circ.billable_transaction());
363 set("circ_type", details.circ.circ_type());
364 set("billing_total", details.circ.billing_total());
365 set("payment_total", details.circ.payment_total());
366 if (! details.circ.checkin_time() ) {
367 set("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
368 'staff.circ.copy_details.recurring_fine_rule_format',
370 details.circ.recurring_fine_rule().name(),
371 details.circ.recurring_fine_rule().id(),
372 details.circ.recurring_fine_rule().low(),
373 details.circ.recurring_fine_rule().normal(),
374 details.circ.recurring_fine_rule().high(),
375 details.circ.recurring_fine_rule().recurrence_interval()
378 set_tooltip("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
379 'staff.circ.copy_details.recurring_fine_rule_tooltip_format',
381 details.circ.recurring_fine_rule().name(),
382 details.circ.recurring_fine_rule().id(),
383 details.circ.recurring_fine_rule().low(),
384 details.circ.recurring_fine_rule().normal(),
385 details.circ.recurring_fine_rule().high(),
386 details.circ.recurring_fine_rule().recurrence_interval()
389 set("duration_rule", document.getElementById('circStrings').getFormattedString(
390 'staff.circ.copy_details.duration_rule_format',
392 details.circ.duration_rule().name(),
393 details.circ.duration_rule().id(),
394 details.circ.duration_rule().shrt(),
395 details.circ.duration_rule().normal(),
396 details.circ.duration_rule().extended(),
397 details.circ.duration_rule().max_renewals()
400 set_tooltip("duration_rule", document.getElementById('circStrings').getFormattedString(
401 'staff.circ.copy_details.duration_rule_tooltip_format',
403 details.circ.duration_rule().name(),
404 details.circ.duration_rule().id(),
405 details.circ.duration_rule().shrt(),
406 details.circ.duration_rule().normal(),
407 details.circ.duration_rule().extended(),
408 details.circ.duration_rule().max_renewals()
411 set("max_fine_rule", document.getElementById('circStrings').getFormattedString(
412 'staff.circ.copy_details.max_fine_rule_format',
414 details.circ.max_fine_rule().name(),
415 details.circ.max_fine_rule().id(),
416 details.circ.max_fine_rule().amount(),
417 details.circ.max_fine_rule().is_percent()
420 set_tooltip("max_fine_rule", document.getElementById('circStrings').getFormattedString(
421 'staff.circ.copy_details.max_fine_rule_tooltip_format',
423 details.circ.max_fine_rule().name(),
424 details.circ.max_fine_rule().id(),
425 details.circ.max_fine_rule().amount(),
426 details.circ.max_fine_rule().is_percent()
432 set("hold_status", '');
434 set("capture_time", '');
435 set("current_copy", '');
436 set("email_notify", '');
437 set("expire_time", '');
438 set("fulfillment_lib", '');
439 set_tooltip("fulfillment_lib", '');
440 set("fulfillment_staff", '');
441 set("fulfillment_time", '');
442 set("hold_type", '');
443 set("holdable_formats", '');
445 set("phone_notify", '');
446 set("pickup_lib", '');
447 set_tooltip("pickup_lib", '');
448 set("prev_check_time", '');
449 set("request_lib", '');
450 set_tooltip("request_lib", '');
451 set("request_time", '');
452 set("requestor", '');
453 set("selection_depth", '');
454 set("selection_ou", '');
455 set_tooltip("selection_ou", '');
458 set("cancel_time", '');
459 set("notify_time", '');
460 set("notify_count", '');
461 set("notifications", '');
463 set("eligible_copies", '');
465 set("thaw_date", '');
466 set("shelf_time", '');
467 set("cancel_cause", '');
468 set("cancel_note", '');
472 set("hold_status", details.hold.status());
473 set("transit", details.hold.transit());
474 set("capture_time", util.date.formatted_date( details.hold.capture_time(), '%{localized}' ));
475 set("current_copy", details.hold.current_copy());
476 set("email_notify", details.hold.email_notify());
477 set("expire_time", util.date.formatted_date( details.hold.expire_time(), '%{localized}' ));
478 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) {}
479 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) {}
480 set("fulfillment_staff", details.hold.fulfillment_staff());
481 set("fulfillment_time", util.date.formatted_date( details.hold.fulfillment_time(), '%{localized}' ));
482 set("hold_type", details.hold.hold_type());
483 set("holdable_formats", details.hold.holdable_formats());
484 set("hold_id", details.hold.id());
485 set("phone_notify", details.hold.phone_notify());
486 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) {}
487 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) {}
488 set("prev_check_time", util.date.formatted_date( details.hold.prev_check_time(), '%{localized}' ));
489 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) {}
490 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) {}
491 set("request_time", util.date.formatted_date( details.hold.request_time(), '%{localized}' ));
492 set("requestor", details.hold.requestor());
493 set("selection_depth", details.hold.selection_depth());
494 set("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().shortname() : data.hash.aou[ details.hold.selection_ou() ].shortname() );
495 set_tooltip("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().name() : data.hash.aou[ details.hold.selection_ou() ].name() );
496 set("target", details.hold.target());
497 set("usr", details.hold.usr());
498 set("cancel_time", util.date.formatted_date( details.hold.cancel_time(), '%{localized}' ));
499 set("notify_time", util.date.formatted_date( details.hold.notify_time(), '%{localized}' ));
500 set("notify_count", details.hold.notify_count());
501 set("notifications", details.hold.notifications());
502 set("bib_rec", details.hold.bib_rec());
503 set("eligible_copies", details.hold.eligible_copies());
504 set("frozen", details.hold.frozen());
505 set("thaw_date", util.date.formatted_date( details.hold.thaw_date(), '%{localized}' ));
506 set("shelf_time", util.date.formatted_date( details.hold.shelf_time(), '%{localized}' ));
507 set("cancel_cause", details.hold.cancel_cause());
508 set("cancel_note", details.hold.cancel_note());
509 set("notes", details.hold.notes());
512 var x = document.getElementById('cat_deck');
514 JSAN.use('util.deck');
515 var d = new util.deck('cat_deck');
516 d.reset_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : details.mvr ? details.mvr.doc_id() : -1 } );