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("circ_modifier", '');
131 set("circulate", '');
132 set("copy_number", '');
133 set("copy_create_date", '');
134 set("status_changed_time", '');
135 set("copy_creator", '');
138 set("deposit_amount", '');
139 set("dummy_author", '');
140 set("dummy_title", '');
141 set("copy_edit_date", '');
142 set("copy_editor", '');
143 set("fine_level", '');
146 set("loan_duration", '');
148 set("renewal_type", '');
149 set("opac_visible", '');
154 set("stat_cat_entry_copy_maps", '');
155 set("circulations", '');
156 set("total_circ_count", '');
157 set_tooltip("total_circ_count", '');
158 set("total_circ_count_prev_year", '');
159 set("total_circ_count_curr_year", '');
163 set("stat_cat_entries", details.copy.stat_cat_entries());
164 set("age_protect", details.copy.age_protect());
165 set("alert_message", details.copy.alert_message());
166 set("barcode", details.copy.barcode());
167 set("call_number", details.copy.call_number());
168 set("circ_as_type", details.copy.circ_as_type());
169 set("copy_circ_lib" , details.copy.circ_lib());
170 set("circ_modifier", details.copy.circ_modifier());
171 set("circulate", details.copy.circulate());
172 set("copy_number", details.copy.copy_number());
173 set("copy_create_date", util.date.formatted_date( details.copy.create_date(), '%{localized}' ));
174 set("status_changed_time", util.date.formatted_date( details.copy.status_changed_time(), '%{localized}' ));
175 set("copy_creator", details.copy.creator());
176 set("deleted", details.copy.deleted());
177 set("deposit", details.copy.deposit());
178 set("deposit_amount", details.copy.deposit_amount());
179 set("dummy_author", details.copy.dummy_author());
180 set("dummy_title", details.copy.dummy_title());
181 set("copy_edit_date", util.date.formatted_date( details.copy.edit_date(), '%{localized}' ));
182 set("copy_editor", details.copy.editor());
183 set("fine_level", details.copy.fine_level());
184 set("holdable", details.copy.holdable());
185 set("copy_id", details.copy.id());
186 set("loan_duration", details.copy.loan_duration());
187 set("location", details.copy.location());
188 set("opac_visible", details.copy.opac_visible());
189 set("price", details.copy.price());
190 set("ref", details.copy.ref());
191 set("status", details.copy.status());
192 set("notes", details.copy.notes());
193 set("stat_cat_entry_copy_maps", details.copy.stat_cat_entry_copy_maps());
194 set("circulations", details.copy.circulations());
195 set("holds", details.copy.holds());
197 network.simple_request('FM_CIRC_IMPROVED_COUNT_VIA_COPY', [ses(), { 'copy' : details.copy.id() } ], function(req) {
198 var r = req.getResultObject();
199 var total = 0; var tooltip = ''; var year = {};
200 for (var i = 0; i < r.length; i++) {
201 total += Number( r[i].count() );
202 if (typeof year[ r[i].year() ] == 'undefined') year[ r[i].year() ] = 0;
203 year[ r[i].year() ] += Number( r[i].count() ); // Add original circs and renewals together
205 set( 'total_circ_count', total );
206 var curr_year = (new Date()).getFullYear();
207 var prev_year = curr_year - 1;
208 set( 'total_circ_count_curr_year', year[ curr_year ] || 0 );
209 set( 'total_circ_count_prev_year', year[ prev_year ] || 0 );
210 var keys = []; for (var i in year) { keys.push( i ); }; keys.sort();
211 for (var i = 0; i < keys.length; i++) {
212 tooltip += document.getElementById('circStrings').getFormattedString(
213 'staff.circ.copy_details.circ_count_by_year', [
214 keys[i] == -1 ? document.getElementById('circStrings').getString('staff.circ.copy_details.circ_count_by_year.legacy_label') : keys[i],
219 set_tooltip( 'total_circ_count', tooltip );
224 set("volume_create_date", '');
225 set("volume_creator", '');
227 set("volume_edit_date", '');
228 set("volume_editor", '');
229 set("volume_id", '');
231 set("owning_lib" , '');
237 if (details.volume) {
238 set("copies", details.volume.copies());
239 set("volume_create_date", util.date.formatted_date( details.volume.create_date(), '%{localized}' ));
240 set("volume_creator", details.volume.creator());
241 set("deleted", details.volume.deleted());
242 set("volume_edit_date", util.date.formatted_date( details.volume.edit_date(), '%{localized}' ));
243 set("volume_editor", details.volume.editor());
244 set("volume_id", details.volume.id());
245 set("label", details.volume.label());
246 set("owning_lib" , details.volume.owning_lib());
247 set("record", details.volume.record());
248 set("notes", details.volume.notes());
249 set("uri_maps", details.volume.uri_maps());
250 set("uris", details.volume.uris());
253 set("copy_status", '');
255 set("dest_recv_time", '');
256 set("transit_id", '');
257 set("persistant_transfer", '');
260 set("source_send_time", '');
261 set("target_copy", '');
262 set("hold_transit_copy", '');
264 if (details.transit) {
265 set("copy_status", details.transit.copy_status());
266 set("dest", details.transit.dest());
267 set("dest_recv_time", util.date.formatted_date( details.transit.dest_recv_time(), '%{localized}' ));
268 set("transit_id", details.transit.id());
269 set("persistant_transfer", details.transit.persistant_transfer());
270 set("prev_hop", details.transit.prev_hop());
271 set("source", details.transit.source());
272 set("source_send_time", util.date.formatted_date( details.transit.source_send_time(), '%{localized}' ));
273 set("target_copy", details.transit.target_copy());
274 set("hold_transit_copy", details.transit.hold_transit_copy());
277 set("checkin_lib", '');
278 set("checkin_workstation","");
279 set("checkin_staff", '');
280 set("checkin_time", '');
281 set("checkin_scan_time", '');
282 set("circ_circ_lib" , '');
283 set("circ_staff", '');
284 set("desk_renewal", '');
287 set("duration_rule", '');
288 set("fine_interval", '');
291 set("max_fine_rule", '');
292 set("opac_renewal", '');
293 set("phone_renewal", '');
294 set("recurring_fine", '');
295 set("recurring_fine_rule", '');
296 set("renewal_remaining", '');
297 set("stop_fines", '');
298 set("stop_fines_time", '');
299 set("target_copy", '');
301 set("xact_finish", '');
302 set("xact_start", '');
303 set("create_time", '');
304 set("workstation", '');
305 set("renewal_workstation", '');
306 set("checkout_workstation", '');
309 set("billable_transaction", '');
310 set("circ_type", '');
311 set("billing_total", '');
312 set("payment_total", '');
315 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) {};
316 if (details.circ.checkin_workstation()) {
317 set("checkin_workstation", details.circ.checkin_workstation().name());
319 set("checkin_staff", details.circ.checkin_staff());
320 set("checkin_time", util.date.formatted_date( details.circ.checkin_time(), '%{localized}' ));
321 set("checkin_scan_time", util.date.formatted_date( details.circ.checkin_scan_time(), '%{localized}' ));
322 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) {};
323 set("circ_staff", details.circ.circ_staff());
324 set("desk_renewal", details.circ.desk_renewal());
325 set("due_date", util.date.formatted_date( details.circ.due_date(), '%{localized}' ));
326 set("duration", details.circ.duration());
327 set("fine_interval", details.circ.fine_interval());
328 set("circ_id", details.circ.id());
329 set("max_fine", details.circ.max_fine());
330 set("opac_renewal", details.circ.opac_renewal());
331 set("phone_renewal", details.circ.phone_renewal());
332 set("renewal_type", renewal_composite_kludge(details.circ));
333 set("recurring_fine", details.circ.recurring_fine());
334 set("renewal_remaining", details.circ.renewal_remaining());
335 set("stop_fines", details.circ.stop_fines());
336 set("stop_fines_time", util.date.formatted_date( details.circ.stop_fines_time(), '%{localized}' ));
337 set("target_copy", details.circ.target_copy());
338 set("usr", details.circ.usr());
339 set("xact_finish", util.date.formatted_date( details.circ.xact_finish(), '%{localized}' ));
340 set("xact_start", util.date.formatted_date( details.circ.xact_start(), '%{localized}' ));
341 set("create_time", util.date.formatted_date( details.circ.create_time(), '%{localized}' ));
342 set("workstation", details.circ.workstation());
343 if (get_bool(details.circ.opac_renewal())||get_bool(details.circ.phone_renewal())||get_bool(details.circ.desk_renewal())) {
344 set("renewal_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
345 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 :)
347 var circs = req.getResultObject();
348 set("checkout_workstation", (typeof circs[0].workstation() == 'object' && circs[0].workstation() != null) ? circs[0].workstation().name() : circs[0].workstation() );
350 alert('Error in alternate_copy_summary.js, FM_CIRC_CHAIN: ' + E);
354 set("checkout_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
356 set("billings", details.circ.billings());
357 set("payments", details.circ.payments());
358 set("billable_transaction", details.circ.billable_transaction());
359 set("circ_type", details.circ.circ_type());
360 set("billing_total", details.circ.billing_total());
361 set("payment_total", details.circ.payment_total());
362 if (! details.circ.checkin_time() ) {
363 set("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
364 'staff.circ.copy_details.recurring_fine_rule_format',
366 details.circ.recurring_fine_rule().name(),
367 details.circ.recurring_fine_rule().id(),
368 details.circ.recurring_fine_rule().low(),
369 details.circ.recurring_fine_rule().normal(),
370 details.circ.recurring_fine_rule().high(),
371 details.circ.recurring_fine_rule().recurrence_interval()
374 set_tooltip("recurring_fine_rule", document.getElementById('circStrings').getFormattedString(
375 'staff.circ.copy_details.recurring_fine_rule_tooltip_format',
377 details.circ.recurring_fine_rule().name(),
378 details.circ.recurring_fine_rule().id(),
379 details.circ.recurring_fine_rule().low(),
380 details.circ.recurring_fine_rule().normal(),
381 details.circ.recurring_fine_rule().high(),
382 details.circ.recurring_fine_rule().recurrence_interval()
385 set("duration_rule", document.getElementById('circStrings').getFormattedString(
386 'staff.circ.copy_details.duration_rule_format',
388 details.circ.duration_rule().name(),
389 details.circ.duration_rule().id(),
390 details.circ.duration_rule().shrt(),
391 details.circ.duration_rule().normal(),
392 details.circ.duration_rule().extended(),
393 details.circ.duration_rule().max_renewals()
396 set_tooltip("duration_rule", document.getElementById('circStrings').getFormattedString(
397 'staff.circ.copy_details.duration_rule_tooltip_format',
399 details.circ.duration_rule().name(),
400 details.circ.duration_rule().id(),
401 details.circ.duration_rule().shrt(),
402 details.circ.duration_rule().normal(),
403 details.circ.duration_rule().extended(),
404 details.circ.duration_rule().max_renewals()
407 set("max_fine_rule", document.getElementById('circStrings').getFormattedString(
408 'staff.circ.copy_details.max_fine_rule_format',
410 details.circ.max_fine_rule().name(),
411 details.circ.max_fine_rule().id(),
412 details.circ.max_fine_rule().amount(),
413 details.circ.max_fine_rule().is_percent()
416 set_tooltip("max_fine_rule", document.getElementById('circStrings').getFormattedString(
417 'staff.circ.copy_details.max_fine_rule_tooltip_format',
419 details.circ.max_fine_rule().name(),
420 details.circ.max_fine_rule().id(),
421 details.circ.max_fine_rule().amount(),
422 details.circ.max_fine_rule().is_percent()
430 set("capture_time", '');
431 set("current_copy", '');
432 set("email_notify", '');
433 set("expire_time", '');
434 set("fulfillment_lib", '');
435 set("fulfillment_staff", '');
436 set("fulfillment_time", '');
437 set("hold_type", '');
438 set("holdable_formats", '');
440 set("phone_notify", '');
441 set("pickup_lib", '');
442 set("prev_check_time", '');
443 set("request_lib", '');
444 set("request_time", '');
445 set("requestor", '');
446 set("selection_depth", '');
447 set("selection_ou", '');
450 set("cancel_time", '');
451 set("notify_time", '');
452 set("notify_count", '');
453 set("notifications", '');
455 set("eligible_copies", '');
457 set("thaw_date", '');
458 set("shelf_time", '');
459 set("cancel_cause", '');
460 set("cancel_note", '');
464 set("status", details.hold.status());
465 set("transit", details.hold.transit());
466 set("capture_time", util.date.formatted_date( details.hold.capture_time(), '%{localized}' ));
467 set("current_copy", details.hold.current_copy());
468 set("email_notify", details.hold.email_notify());
469 set("expire_time", util.date.formatted_date( details.hold.expire_time(), '%{localized}' ));
470 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) {}
471 set("fulfillment_staff", details.hold.fulfillment_staff());
472 set("fulfillment_time", util.date.formatted_date( details.hold.fulfillment_time(), '%{localized}' ));
473 set("hold_type", details.hold.hold_type());
474 set("holdable_formats", details.hold.holdable_formats());
475 set("hold_id", details.hold.id());
476 set("phone_notify", details.hold.phone_notify());
477 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) {}
478 set("prev_check_time", util.date.formatted_date( details.hold.prev_check_time(), '%{localized}' ));
479 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) {}
480 set("request_time", util.date.formatted_date( details.hold.request_time(), '%{localized}' ));
481 set("requestor", details.hold.requestor());
482 set("selection_depth", details.hold.selection_depth());
483 set("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().shortname() : data.hash.aou[ details.hold.selection_ou() ].shortname() );
484 set("target", details.hold.target());
485 set("usr", details.hold.usr());
486 set("cancel_time", util.date.formatted_date( details.hold.cancel_time(), '%{localized}' ));
487 set("notify_time", util.date.formatted_date( details.hold.notify_time(), '%{localized}' ));
488 set("notify_count", details.hold.notify_count());
489 set("notifications", details.hold.notifications());
490 set("bib_rec", details.hold.bib_rec());
491 set("eligible_copies", details.hold.eligible_copies());
492 set("frozen", details.hold.frozen());
493 set("thaw_date", util.date.formatted_date( details.hold.thaw_date(), '%{localized}' ));
494 set("shelf_time", util.date.formatted_date( details.hold.shelf_time(), '%{localized}' ));
495 set("cancel_cause", details.hold.cancel_cause());
496 set("cancel_note", details.hold.cancel_note());
497 set("notes", details.hold.notes());
500 var x = document.getElementById('cat_deck');
502 JSAN.use('util.deck');
503 var d = new util.deck('cat_deck');
504 d.reset_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : details.mvr ? details.mvr.doc_id() : -1 } );