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();
17 // timeout so xulG gets a chance to get pushed in
19 function () { xulG.from_item_details_new = false; load_item(); },
24 try { error.standard_unexpected_error_alert('main/test.xul',E); } catch(F) { alert(E); }
28 function set(name,value) {
29 var nodes = document.getElementsByAttribute('name',name);
30 for (var i = 0; i < nodes.length; i++) {
31 nodes[i].setAttribute('value',value); nodes[i].value = value;
35 function set_tooltip(name,value) {
36 var nodes = document.getElementsByAttribute('name',name);
37 for (var i = 0; i < nodes.length; i++) {
38 nodes[i].setAttribute('tooltiptext',value);
42 function renewal_composite_kludge(circ) {
43 // Only a corrupt database could give us a situation where more
44 // than one of these were true at a time, right?
45 if (circ.desk_renewal() == "t")
46 return document.getElementById('circStrings').getString(
47 'staff.circ.copy_details.desk_renewal'
49 else if (circ.opac_renewal() == "t")
50 return document.getElementById('circStrings').getString(
51 'staff.circ.copy_details.opac_renewal'
53 else if (circ.phone_renewal() == "t")
54 return document.getElementById('circStrings').getString(
55 'staff.circ.copy_details.phone_renewal'
60 function load_item() {
62 if (! xulG.barcode) return;
64 if (xulG.fetched_copy_details && xulG.fetched_copy_details[xulG.barcode]) {
65 var details = xulG.fetched_copy_details[xulG.barcode];
66 // We don't want to use these details more than once (i.e., we
67 // don't want cached data after things have potentially changed).
68 delete xulG.fetched_copy_details[xulG.barcode];
70 var details = network.simple_request('FM_ACP_DETAILS_VIA_BARCODE.authoritative', [ ses(), xulG.barcode ]);
71 // Should get back .mvr, .copy, .volume, .transit, .circ, .hold
74 if (typeof bib_brief_overlay == 'function') bib_brief_overlay( { 'mvr' : details.mvr, 'acp' : details.copy } );
85 set('types_of_resource', '');
86 set('call_numbers', '');
88 set('online_loc', '');
90 set('physical_description', '');
92 set('copy_count', '');
97 set('title',details.mvr.title());
98 set('author',details.mvr.author());
99 set('doc_id', details.mvr.doc_id());
100 set('doc_type', details.mvr.doc_type());
101 set('pubdate', details.mvr.pubdate());
102 set('isbn',details.mvr.isbn());
103 set('publisher', details.mvr.publisher());
104 set('tcn', details.mvr.tcn());
105 set('subject', details.mvr.subject());
106 set('types_of_resource', details.mvr.types_of_resource());
107 set('call_numbers', details.mvr.call_numbers());
108 set('edition', details.mvr.edition());
109 set('online_loc', details.mvr.online_loc());
110 set('synopsis', details.mvr.synopsis());
111 set('physical_description', details.mvr.physical_description());
112 set('toc', details.mvr.toc());
113 set('copy_count', details.mvr.copy_count());
114 set('series', details.mvr.series());
115 set('serials', details.mvr.serials());
117 set('title',details.copy.dummy_title());
118 set('author',details.copy.dummy_author());
119 set('isbn',details.copy.dummy_isbn());
122 set("stat_cat_entries", '');
123 set("age_protect", '');
124 set("alert_message", '');
126 set("call_number", '');
127 set("circ_as_type", '');
128 set("copy_circ_lib" , '');
129 set("circ_modifier", '');
130 set("circulate", '');
131 set("copy_number", '');
132 set("copy_create_date", '');
133 set("status_changed_time", '');
134 set("copy_creator", '');
137 set("deposit_amount", '');
138 set("dummy_author", '');
139 set("dummy_title", '');
140 set("copy_edit_date", '');
141 set("copy_editor", '');
142 set("fine_level", '');
145 set("loan_duration", '');
147 set("renewal_type", '');
148 set("opac_visible", '');
153 set("stat_cat_entry_copy_maps", '');
154 set("circulations", '');
155 set("total_circ_count", '');
156 set_tooltip("total_circ_count", '');
157 set("total_circ_count_prev_year", '');
158 set("total_circ_count_curr_year", '');
162 set("stat_cat_entries", details.copy.stat_cat_entries());
163 set("age_protect", details.copy.age_protect());
164 set("alert_message", details.copy.alert_message());
165 set("barcode", details.copy.barcode());
166 set("call_number", details.copy.call_number());
167 set("circ_as_type", details.copy.circ_as_type());
168 set("copy_circ_lib" , details.copy.circ_lib());
169 set("circ_modifier", details.copy.circ_modifier());
170 set("circulate", details.copy.circulate());
171 set("copy_number", details.copy.copy_number());
172 set("copy_create_date", details.copy.create_date());
173 set("status_changed_time", details.copy.status_changed_time());
174 set("copy_creator", details.copy.creator());
175 set("deleted", details.copy.deleted());
176 set("deposit", details.copy.deposit());
177 set("deposit_amount", details.copy.deposit_amount());
178 set("dummy_author", details.copy.dummy_author());
179 set("dummy_title", details.copy.dummy_title());
180 set("copy_edit_date", details.copy.edit_date());
181 set("copy_editor", details.copy.editor());
182 set("fine_level", details.copy.fine_level());
183 set("holdable", details.copy.holdable());
184 set("copy_id", details.copy.id());
185 set("loan_duration", details.copy.loan_duration());
186 set("location", details.copy.location());
187 set("opac_visible", details.copy.opac_visible());
188 set("price", details.copy.price());
189 set("ref", details.copy.ref());
190 set("status", details.copy.status());
191 set("notes", details.copy.notes());
192 set("stat_cat_entry_copy_maps", details.copy.stat_cat_entry_copy_maps());
193 set("circulations", details.copy.circulations());
194 set("holds", details.copy.holds());
196 network.simple_request('FM_CIRC_IMPROVED_COUNT_VIA_COPY', [ses(), { 'copy' : details.copy.id() } ], function(req) {
197 var r = req.getResultObject();
198 var total = 0; var tooltip = ''; var year = {};
199 for (var i = 0; i < r.length; i++) {
200 total += Number( r[i].count() );
201 if (typeof year[ r[i].year() ] == 'undefined') year[ r[i].year() ] = 0;
202 year[ r[i].year() ] += Number( r[i].count() ); // Add original circs and renewals together
204 set( 'total_circ_count', total );
205 var curr_year = (new Date()).getFullYear();
206 var prev_year = curr_year - 1;
207 set( 'total_circ_count_curr_year', year[ curr_year ] || 0 );
208 set( 'total_circ_count_prev_year', year[ prev_year ] || 0 );
209 var keys = []; for (var i in year) { keys.push( i ); }; keys.sort();
210 for (var i = 0; i < keys.length; i++) {
211 tooltip += document.getElementById('circStrings').getFormattedString(
212 'staff.circ.copy_details.circ_count_by_year', [
213 keys[i] == -1 ? document.getElementById('circStrings').getString('staff.circ.copy_details.circ_count_by_year.legacy_label') : keys[i],
218 set_tooltip( 'total_circ_count', tooltip );
223 set("volume_create_date", '');
224 set("volume_creator", '');
226 set("volume_edit_date", '');
227 set("volume_editor", '');
228 set("volume_id", '');
230 set("owning_lib" , '');
236 if (details.volume) {
237 set("copies", details.volume.copies());
238 set("volume_create_date", details.volume.create_date());
239 set("volume_creator", details.volume.creator());
240 set("deleted", details.volume.deleted());
241 set("volume_edit_date", details.volume.edit_date());
242 set("volume_editor", details.volume.editor());
243 set("volume_id", details.volume.id());
244 set("label", details.volume.label());
245 set("owning_lib" , details.volume.owning_lib());
246 set("record", details.volume.record());
247 set("notes", details.volume.notes());
248 set("uri_maps", details.volume.uri_maps());
249 set("uris", details.volume.uris());
252 set("copy_status", '');
254 set("dest_recv_time", '');
255 set("transit_id", '');
256 set("persistant_transfer", '');
259 set("source_send_time", '');
260 set("target_copy", '');
261 set("hold_transit_copy", '');
263 if (details.transit) {
264 set("copy_status", details.transit.copy_status());
265 set("dest", details.transit.dest());
266 set("dest_recv_time", details.transit.dest_recv_time());
267 set("transit_id", details.transit.id());
268 set("persistant_transfer", details.transit.persistant_transfer());
269 set("prev_hop", details.transit.prev_hop());
270 set("source", details.transit.source());
271 set("source_send_time", details.transit.source_send_time());
272 set("target_copy", details.transit.target_copy());
273 set("hold_transit_copy", details.transit.hold_transit_copy());
276 set("checkin_lib", '');
277 set("checkin_workstation","");
278 set("checkin_staff", '');
279 set("checkin_time", '');
280 set("checkin_scan_time", '');
281 set("circ_circ_lib" , '');
282 set("circ_staff", '');
283 set("desk_renewal", '');
286 set("duration_rule", '');
287 set("fine_interval", '');
290 set("max_fine_rule", '');
291 set("opac_renewal", '');
292 set("phone_renewal", '');
293 set("recurring_fine", '');
294 set("recurring_fine_rule", '');
295 set("renewal_remaining", '');
296 set("stop_fines", '');
297 set("stop_fines_time", '');
298 set("target_copy", '');
300 set("xact_finish", '');
301 set("xact_start", '');
302 set("create_time", '');
303 set("workstation", '');
304 set("renewal_workstation", '');
305 set("checkout_workstation", '');
308 set("billable_transaction", '');
309 set("circ_type", '');
310 set("billing_total", '');
311 set("payment_total", '');
314 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) {};
315 if (details.circ.checkin_workstation()) {
316 set("checkin_workstation", details.circ.checkin_workstation().name());
318 set("checkin_staff", details.circ.checkin_staff());
319 set("checkin_time", details.circ.checkin_time());
320 set("checkin_scan_time", details.circ.checkin_scan_time());
321 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) {};
322 set("circ_staff", details.circ.circ_staff());
323 set("desk_renewal", details.circ.desk_renewal());
324 set("due_date", details.circ.due_date());
325 set("duration", details.circ.duration());
326 set("duration_rule", details.circ.duration_rule());
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("max_fine_rule", details.circ.max_fine_rule());
331 set("opac_renewal", details.circ.opac_renewal());
332 set("phone_renewal", details.circ.phone_renewal());
333 set("renewal_type", renewal_composite_kludge(details.circ));
334 set("recurring_fine", details.circ.recurring_fine());
335 set("recurring_fine_rule", details.circ.recurring_fine_rule());
336 set("renewal_remaining", details.circ.renewal_remaining());
337 set("stop_fines", details.circ.stop_fines());
338 set("stop_fines_time", details.circ.stop_fines_time());
339 set("target_copy", details.circ.target_copy());
340 set("usr", details.circ.usr());
341 set("xact_finish", details.circ.xact_finish());
342 set("xact_start", details.circ.xact_start());
343 set("create_time", details.circ.create_time());
344 set("workstation", details.circ.workstation());
345 if (get_bool(details.circ.opac_renewal())||get_bool(details.circ.phone_renewal())||get_bool(details.circ.desk_renewal())) {
346 set("renewal_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
347 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 :)
349 var circs = req.getResultObject();
350 set("checkout_workstation", (typeof circs[0].workstation() == 'object' && circs[0].workstation() != null) ? circs[0].workstation().name() : circs[0].workstation() );
352 alert('Error in alternate_copy_summary.js, FM_CIRC_CHAIN: ' + E);
356 set("checkout_workstation", (typeof details.circ.workstation() == 'object' && details.circ.workstation() != null) ? details.circ.workstation().name() : details.circ.workstation() );
358 set("billings", details.circ.billings());
359 set("payments", details.circ.payments());
360 set("billable_transaction", details.circ.billable_transaction());
361 set("circ_type", details.circ.circ_type());
362 set("billing_total", details.circ.billing_total());
363 set("payment_total", details.circ.payment_total());
368 set("capture_time", '');
369 set("current_copy", '');
370 set("email_notify", '');
371 set("expire_time", '');
372 set("fulfillment_lib", '');
373 set("fulfillment_staff", '');
374 set("fulfillment_time", '');
375 set("hold_type", '');
376 set("holdable_formats", '');
378 set("phone_notify", '');
379 set("pickup_lib", '');
380 set("prev_check_time", '');
381 set("request_lib", '');
382 set("request_time", '');
383 set("requestor", '');
384 set("selection_depth", '');
385 set("selection_ou", '');
388 set("cancel_time", '');
389 set("notify_time", '');
390 set("notify_count", '');
391 set("notifications", '');
393 set("eligible_copies", '');
395 set("thaw_date", '');
396 set("shelf_time", '');
397 set("cancel_cause", '');
398 set("cancel_note", '');
402 set("status", details.hold.status());
403 set("transit", details.hold.transit());
404 set("capture_time", details.hold.capture_time());
405 set("current_copy", details.hold.current_copy());
406 set("email_notify", details.hold.email_notify());
407 set("expire_time", details.hold.expire_time());
408 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) {}
409 set("fulfillment_staff", details.hold.fulfillment_staff());
410 set("fulfillment_time", details.hold.fulfillment_time());
411 set("hold_type", details.hold.hold_type());
412 set("holdable_formats", details.hold.holdable_formats());
413 set("hold_id", details.hold.id());
414 set("phone_notify", details.hold.phone_notify());
415 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) {}
416 set("prev_check_time", details.hold.prev_check_time());
417 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) {}
418 set("request_time", details.hold.request_time());
419 set("requestor", details.hold.requestor());
420 set("selection_depth", details.hold.selection_depth());
421 set("selection_ou" , typeof details.hold.selection_ou() == 'object' ? details.hold.selection_ou().shortname() : data.hash.aou[ details.hold.selection_ou() ].shortname() );
422 set("target", details.hold.target());
423 set("usr", details.hold.usr());
424 set("cancel_time", details.hold.cancel_time());
425 set("notify_time", details.hold.notify_time());
426 set("notify_count", details.hold.notify_count());
427 set("notifications", details.hold.notifications());
428 set("bib_rec", details.hold.bib_rec());
429 set("eligible_copies", details.hold.eligible_copies());
430 set("frozen", details.hold.frozen());
431 set("thaw_date", details.hold.thaw_date());
432 set("shelf_time", details.hold.shelf_time());
433 set("cancel_cause", details.hold.cancel_cause());
434 set("cancel_note", details.hold.cancel_note());
435 set("notes", details.hold.notes());
438 var x = document.getElementById('cat_deck');
440 JSAN.use('util.deck');
441 var d = new util.deck('cat_deck');
442 d.reset_iframe( urls.XUL_MARC_VIEW, {}, { 'docid' : details.mvr ? details.mvr.doc_id() : -1 } );