1 var docid; var marc_html; var top_pane; var bottom_pane; var opac_frame; var opac_url;
3 var marc_view_reset = true;
4 var marc_edit_reset = true;
5 var copy_browser_reset = true;
6 var hold_browser_reset = true;
7 var serctrl_view_reset = true;
9 function $(id) { return document.getElementById(id); }
13 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
14 if (typeof JSAN == 'undefined') { throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); }
15 JSAN.errorLevel = "die"; // none, warn, or die
16 JSAN.addRepository('..');
17 JSAN.use('util.error'); g.error = new util.error();
18 g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
20 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
21 XML_HTTP_SERVER = g.data.server_unadorned;
23 // Pull in local customizations
24 var r = new XMLHttpRequest();
25 r.open("GET", xulG.url_prefix('/xul/server/skin/custom.js'), false);
27 if (r.status == 200) {
28 dump('Evaluating /xul/server/skin/custom.js\n');
29 eval( r.responseText );
32 window.help_context_set_locally = true;
34 JSAN.use('util.network'); g.network = new util.network();
37 try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
38 try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
39 try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
40 try { g.view_override = g.cgi.param('default_view') || xulG.default_view; } catch(E) { g.error.sdump('D_ERROR',E); }
42 JSAN.use('util.deck');
43 top_pane = new util.deck('top_pane');
44 bottom_pane = new util.deck('bottom_pane');
49 var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
50 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
55 function default_focus() {
56 opac_wrapper_set_help_context();
59 function opac_wrapper_set_help_context() {
61 dump('Entering opac.js, opac_wrapper_set_help_context\n');
62 var cw = bottom_pane.get_contentWindow();
63 if (cw && typeof cw['location'] != 'undefined') {
64 if (typeof cw.help_context_set_locally == 'undefined') {
66 'protocol' : cw.location.protocol,
67 'hostname' : cw.location.hostname,
68 'port' : cw.location.port,
69 'pathname' : cw.location.pathname,
72 xulG.set_help_context(help_params);
74 dump('\tcw.help_context_set_locally = ' + cw.help_context_set_locally + '\n');
75 if (typeof cw.default_focus == 'function') {
80 dump('opac.js: problem in opac_wrapper_set_help_context(): bottom_pane = ' + bottom_pane + ' cw = ' + cw + '\n');
81 dump('\tcw.location = ' + cw.location + '\n');
84 // We can expect some errors here if this called before the DOM is ready. Easiest to just trap and ignore
85 dump('Error in opac.js, opac_wrapper_set_help_context(): ' + E + '\n');
89 function set_brief_view() {
90 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
91 dump('spawning ' + url + '\n');
96 'set_tab_name' : function(n) {
97 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
98 try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
100 dump('no set_tab_name\n');
107 function set_marc_view() {
108 g.view = 'marc_view';
109 if (marc_view_reset) {
110 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
111 marc_view_reset = false;
113 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
115 opac_wrapper_set_help_context();
116 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
119 function set_marc_edit() {
120 g.view = 'marc_edit';
121 var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
124 'marc_control_number_identifier' : g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
125 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid, "id": docid, "rtype": "bre" },
126 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
128 var cat = { util: {} }; /* FIXME: kludge since we can't load remote JSAN libraries into chrome */
129 cat.util.spawn_copy_editor = function(params) {
131 if (!params.copy_ids && !params.copies) return;
132 if (params.copy_ids && params.copy_ids.length == 0) return;
133 if (params.copies && params.copies.length == 0) return;
134 if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
135 if (!params.caller_handles_update) params.handle_update = 1; // legacy
138 JSAN.use('util.network'); obj.network = new util.network();
139 JSAN.use('util.error'); obj.error = new util.error();
142 if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
143 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_edit');
144 else if(params.copies && params.copies.length > 1 && params.edit == 1)
145 title = $("offlineStrings").getString('staff.cat.util.copy_editor.batch_view');
146 else if(params.copy_ids && params.copy_ids.length == 1)
147 title = $("offlineStrings").getString('staff.cat.util.copy_editor.edit');
149 title = $("offlineStrings").getString('staff.cat.util.copy_editor.view');
151 JSAN.use('util.window'); var win = new util.window();
152 var my_xulG = win.open(
153 (urls.XUL_COPY_EDITOR),
155 'chrome,modal,resizable',
158 if (!my_xulG.copies && params.edit) {
160 return my_xulG.copies;
164 JSAN.use('util.error'); var error = new util.error();
165 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.spawn_copy_editor',E);
168 cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
172 JSAN.use('util.error'); error = new util.error();
173 JSAN.use('util.network'); var network = new util.network();
175 var acn_id = network.simple_request(
176 'FM_ACN_FIND_OR_CREATE',
177 [ ses(), cn_label, doc_id, ses('ws_ou') ]
180 if (typeof acn_id.ilsevent != 'undefined') {
181 error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add', acn_id);
185 var copy_obj = new acp();
188 copy_obj.barcode( cp_barcode );
189 copy_obj.call_number( acn_id );
190 copy_obj.circ_lib( ses('ws_ou') );
191 /* FIXME -- use constants */
194 copy_obj.deposit_amount(0);
195 copy_obj.fine_level(2);
196 copy_obj.loan_duration(2);
197 copy_obj.location(1);
199 copy_obj.circulate(get_db_true());
200 copy_obj.holdable(get_db_true());
201 copy_obj.opac_visible(get_db_true());
202 copy_obj.ref(get_db_false());
204 JSAN.use('util.window'); var win = new util.window();
205 return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
208 if (error) error.standard_unexpected_error_alert('Error in chrome/content/cat/opac.js, cat.util.fast_item_add #2',E); else alert('FIXME: ' + E);
211 return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
213 alert('Error in chrome/content/cat/opac.js, set_marc_edit, fast_item_add: ' + E);
217 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
218 'func' : function (new_marcxml) {
220 var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
221 marc_view_reset = true;
222 copy_browser_reset = true;
223 hold_browser_reset = true;
224 if (typeof r.ilsevent != 'undefined') {
229 'oncomplete' : function() {}
233 g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
237 'lock_tab' : xulG.lock_tab,
238 'unlock_tab' : xulG.unlock_tab
240 if (marc_edit_reset) {
241 bottom_pane.reset_iframe( a,b,c );
242 marc_edit_reset = false;
244 bottom_pane.set_iframe( a,b,c );
246 opac_wrapper_set_help_context();
247 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
250 function set_copy_browser() {
251 g.view = 'copy_browser';
252 if (copy_browser_reset) {
253 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
254 copy_browser_reset =false;
256 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
258 opac_wrapper_set_help_context();
259 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
262 function set_hold_browser() {
263 g.view = 'hold_browser';
264 if (hold_browser_reset) {
265 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
266 hold_browser_reset = false;
268 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
270 opac_wrapper_set_help_context();
271 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
275 function open_acq_orders() {
277 var content_params = {
279 "authtime": ses("authtime"),
281 "show_nav_buttons": true,
282 "show_print_button": false
285 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
286 "set_patron_tab", "volume_item_creator", "get_new_session",
287 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
288 "url_prefix", "network_meter", "page_meter", "set_statusbar",
290 ].forEach(function(k) { content_params[k] = xulG[k]; });
292 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
293 xulG.url_prefix("/eg/acq/lineitem/related/") +
294 docid + "?target=bib"
298 "tab_name": $("offlineStrings").getString(
299 "staff.cat.opac.related_items"
305 g.error.sdump("D_ERROR", E);
309 function open_alt_serial_mgmt() {
311 var content_params = {
313 "authtime": ses("authtime"),
314 "show_nav_buttons": true,
316 "show_print_button": false
319 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
320 "set_patron_tab", "volume_item_creator", "get_new_session",
321 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
322 "url_prefix", "network_meter", "page_meter", "set_statusbar",
324 ].forEach(function(k) { content_params[k] = xulG[k]; });
326 var loc = urls.XUL_BROWSER + "?url=" + window.escape(
327 xulG.url_prefix("/eg/serial/list_subscription?record_entry=") +
332 "tab_name": $("offlineStrings").getString(
333 "staff.cat.opac.serial_alt_mgmt"
339 g.error.sdump("D_ERROR", E);
343 function set_opac() {
346 var content_params = {
347 'show_nav_buttons' : true,
348 'show_print_button' : true,
349 'passthru_content_params' : {
351 'authtime' : ses('authtime'),
352 'window_open' : function(a,b,c) {
354 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
355 return window.open(a,b,c);
357 g.error.standard_unexpected_error_alert('window_open',E);
361 'on_url_load' : function(f) {
362 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
365 if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
366 win = f.contentWindow.wrappedJSObject;
368 win = f.contentWindow;
371 win = f.contentWindow;
373 win.attachEvt("rdetail", "recordRetrieved",
376 if (docid == id) return;
380 g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
385 g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
386 $('record_start').disabled = true; $('record_next').disabled = true;
387 $('record_prev').disabled = true; $('record_end').disabled = true;
388 $('record_pos').setAttribute('value','');
390 win.attachEvt("rdetail", "nextPrevDrawn",
391 function(rIndex,rCount){
392 $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
393 if (win.rdetailNext) {
394 g.f_record_next = function() {
395 g.view_override = g.view;
398 $('record_next').disabled = false;
400 if (win.rdetailPrev) {
401 g.f_record_prev = function() {
402 g.view_override = g.view;
405 $('record_prev').disabled = false;
407 if (win.rdetailStart) {
408 g.f_record_start = function() {
409 g.view_override = g.view;
412 $('record_start').disabled = false;
414 if (win.rdetailEnd) {
415 g.f_record_end = function() {
416 g.view_override = g.view;
419 $('record_end').disabled = false;
424 $('mfhd_add').setAttribute('oncommand','create_mfhd()');
425 var mfhd_edit_menu = $('mfhd_edit');
426 var mfhd_delete_menu = $('mfhd_delete');
428 // clear menus on subsequent loads
429 if (mfhd_edit_menu.firstChild) {
430 mfhd_edit_menu.removeChild(mfhd_edit_menu.firstChild);
431 mfhd_delete_menu.removeChild(mfhd_delete_menu.firstChild);
434 mfhd_edit_menu.disabled = true;
435 mfhd_delete_menu.disabled = true;
437 win.attachEvt("rdetail", "MFHDDrawn",
439 if (win.mfhdDetails && win.mfhdDetails.length > 0) {
441 g.mfhd.details = win.mfhdDetails;
442 mfhd_edit_menu.disabled = false;
443 mfhd_delete_menu.disabled = false;
444 for (var i = 0; i < win.mfhdDetails.length; i++) {
445 var mfhd_details = win.mfhdDetails[i];
446 var num = mfhd_details.entryNum;
448 var label = mfhd_details.label + ' (' + num + ')';
449 var item = mfhd_edit_menu.appendItem(label);
450 item.setAttribute('oncommand','open_mfhd_editor('+mfhd_details.id+')');
451 item = mfhd_delete_menu.appendItem(label);
452 item.setAttribute('oncommand','delete_mfhd('+mfhd_details.id+')');
458 'url_prefix' : xulG.url_prefix,
460 content_params.new_tab = xulG.new_tab;
461 content_params.set_tab = xulG.set_tab;
462 content_params.close_tab = xulG.close_tab;
463 content_params.lock_tab = xulG.lock_tab;
464 content_params.unlock_tab = xulG.unlock_tab;
465 content_params.inspect_tab = xulG.inspect_tab;
466 content_params.new_patron_tab = xulG.new_patron_tab;
467 content_params.set_patron_tab = xulG.set_patron_tab;
468 content_params.volume_item_creator = xulG.volume_item_creator;
469 content_params.get_new_session = xulG.get_new_session;
470 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
471 content_params.set_tab_name = xulG.set_tab_name;
472 content_params.open_chrome_window = xulG.open_chrome_window;
473 content_params.url_prefix = xulG.url_prefix;
474 content_params.network_meter = xulG.network_meter;
475 content_params.page_meter = xulG.page_meter;
476 content_params.set_statusbar = xulG.set_statusbar;
477 content_params.set_help_context = xulG.set_help_context;
479 if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
480 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
481 /* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
482 browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
485 g.error.sdump('D_ERROR','set_opac: ' + E);
487 opac_wrapper_set_help_context();
488 bottom_pane.get_contentWindow().addEventListener('load',opac_wrapper_set_help_context,false);
491 function set_serctrl_view() {
492 g.view = 'serctrl_view';
493 if (serctrl_view_reset) {
494 bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
495 serctrl_view_reset =false;
497 bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_SERIAL_SERCTRL_MAIN ) + '?docid=' + window.escape(docid), {}, xulG);
501 function create_mfhd() {
503 JSAN.use('util.window'); var win = new util.window();
504 var select_aou_window = win.open(
505 xulG.url_prefix(urls.XUL_SERIAL_SELECT_AOU),
507 'chrome,resizable,modal,centerscreen',
508 {'server_unadorned' : g.data.server_unadorned}
510 if (!select_aou_window.create_mfhd_aou) {
513 var r = g.network.simple_request(
514 'MFHD_XML_RECORD_CREATE',
515 [ ses(), 1, select_aou_window.create_mfhd_aou, docid ]
517 if (typeof r.ilsevent != 'undefined') {
520 alert("MFHD record created."); //TODO: better success message
521 //TODO: refresh opac display
523 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
527 function delete_mfhd(sre_id) {
528 if (g.error.yns_alert(
529 document.getElementById('offlineStrings').getFormattedString('serial.delete_record.confirm', [sre_id]),
530 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
531 document.getElementById('offlineStrings').getString('cat.opac.delete'),
532 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
534 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
535 var robj = g.network.request(
536 'open-ils.permacrud',
537 'open-ils.permacrud.delete.sre',
539 if (typeof robj.ilsevent != 'undefined') {
540 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
542 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
543 //TODO: refresh opac display
548 function open_mfhd_editor(sre_id) {
550 var r = g.network.simple_request(
554 if (typeof r.ilsevent != 'undefined') {
557 open_marc_editor(r, 'MFHD');
559 g.error.standard_unexpected_error_alert("Create MFHD failed", E); //TODO: better error handling
563 function open_marc_editor(rec, label) {
564 win = window.open( xulG.url_prefix('/xul/server/cat/marcedit.xul') );
567 record : {marc : rec.marc()},
569 label: 'Save ' + label,
570 func: function(xmlString) { // TODO: switch to pcrud, or define an sre update method in Serial.pm?
571 var method = 'open-ils.permacrud.update.' + rec.classname;
574 'open-ils.permacrud', method,
582 function bib_in_new_tab() {
584 var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
585 var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
586 content_params.url_prefix = xulG.url_prefix;
587 content_params.new_tab = xulG.new_tab;
588 content_params.set_tab = xulG.set_tab;
589 content_params.close_tab = xulG.close_tab;
590 content_params.lock_tab = xulG.lock_tab;
591 content_params.unlock_tab = xulG.unlock_tab;
592 content_params.inspect_tab = xulG.inspect_tab;
593 content_params.new_patron_tab = xulG.new_patron_tab;
594 content_params.set_patron_tab = xulG.set_patron_tab;
595 content_params.volume_item_creator = xulG.volume_item_creator;
596 content_params.get_new_session = xulG.get_new_session;
597 content_params.holdings_maintenance_tab = xulG.holdings_maintenance_tab;
598 content_params.set_tab_name = xulG.set_tab_name;
599 content_params.open_chrome_window = xulG.open_chrome_window;
600 content_params.url_prefix = xulG.url_prefix;
601 content_params.network_meter = xulG.network_meter;
602 content_params.page_meter = xulG.page_meter;
603 content_params.set_statusbar = xulG.set_statusbar;
604 content_params.set_help_context = xulG.set_help_context;
606 xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
608 g.error.sdump('D_ERROR',E);
612 function batch_receive_in_new_tab() {
614 var content_params = {"session": ses(), "authtime": ses("authtime")};
616 ["url_prefix", "new_tab", "set_tab", "close_tab", "new_patron_tab",
617 "set_patron_tab", "volume_item_creator", "get_new_session",
618 "holdings_maintenance_tab", "set_tab_name", "open_chrome_window",
619 "url_prefix", "network_meter", "page_meter", "set_statusbar",
621 ].forEach(function(k) { content_params[k] = xulG[k]; });
624 xulG.url_prefix(urls.XUL_SERIAL_BATCH_RECEIVE) +
625 "?docid=" + window.escape(docid), {
626 "tab_name": $("offlineStrings").getString(
627 "menu.cmd_serial_batch_receive.tab"
632 g.error.sdump("D_ERROR", E);
636 function remove_me() {
637 var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
638 dump('removing ' + url + '\n');
639 try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
640 $('nav').setAttribute('hidden','true');
643 function add_to_bucket() {
644 JSAN.use('util.window'); var win = new util.window();
646 xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK),
648 'chrome,resizable,modal,centerscreen',
650 record_ids: [ docid ]
655 function mark_for_overlay() {
656 g.data.marked_record = docid;
657 g.data.stash('marked_record');
658 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
659 if (typeof robj.ilsevent == 'undefined') {
660 g.data.marked_record_mvr = robj;
662 g.data.marked_record_mvr = null;
663 g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
665 g.data.stash('marked_record_mvr');
666 if (g.data.marked_record_mvr) {
667 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.tcn.alert',[ g.data.marked_record_mvr.tcn() ]));
668 xulG.set_statusbar(1, $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.tcn.label',[g.data.marked_record_mvr.tcn()]) );
670 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_marked_for_overlay.record_id.alert',[ g.data.marked_record ]));
671 xulG.set_statusbar(1, $("offlineStrings").getFormattedString('staff.cat.z3950.marked_record_for_overlay_indicator.record_id.label',[g.data.marked_record]) );
675 function mark_for_hold_transfer() {
676 g.data.marked_record_for_hold_transfer = docid;
677 g.data.stash('marked_record_for_hold_transfer');
678 var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
679 if (typeof robj.ilsevent == 'undefined') {
680 g.data.marked_record_for_hold_transfer_mvr = robj;
682 g.data.marked_record_for_hold_transfer_mvr = null;
683 g.error.standard_unexpected_error_alert('in mark_for_hold_transfer',robj);
685 g.data.stash('marked_record_for_hold_transfer_mvr');
686 if (g.data.marked_record_mvr) {
687 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.tcn.label',[g.data.marked_record_for_hold_transfer_mvr.tcn()]);
688 alert(m); xulG.set_statusbar(1, m );
690 var m = $("offlineStrings").getFormattedString('staff.cat.opac.marked_record_for_hold_transfer_indicator.record_id.label',[g.data.marked_record_for_hold_transfer]);
691 alert(m); xulG.set_statusbar(1, m );
695 function transfer_title_holds() {
696 g.data.stash_retrieve();
697 var target = g.data.marked_record_for_hold_transfer;
699 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.destination_needed.label');
703 var robj = g.network.simple_request('TRANSFER_TITLE_HOLDS',[ ses(), target, [ docid ] ]);
705 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.success.label');
708 var m = $("offlineStrings").getString('staff.cat.opac.title_for_hold_transfer.failure.label');
711 hold_browser_reset = true;
712 if (g.view == 'hold_browser') { set_hold_browser(); };
715 function delete_record() {
716 if (g.error.yns_alert(
717 document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
718 document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
719 document.getElementById('offlineStrings').getString('cat.opac.delete'),
720 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
722 document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
723 var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
724 if (typeof robj.ilsevent != 'undefined') {
725 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
727 alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
728 refresh_display(docid);
733 function undelete_record() {
734 if (g.error.yns_alert(
735 document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
736 document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
737 document.getElementById('offlineStrings').getString('cat.opac.undelete'),
738 document.getElementById('offlineStrings').getString('cat.opac.cancel'),
740 document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
742 var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
743 if (typeof robj.ilsevent != 'undefined') {
744 alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
746 alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
747 refresh_display(docid);
752 function refresh_display(id) {
754 marc_view_reset = true;
755 marc_edit_reset = true;
756 copy_browser_reset = true;
757 hold_browser_reset = true;
758 while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
759 var children = bottom_pane.node.childNodes;
760 for (var i = 0; i < children.length; i++) {
761 if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
765 $('nav').setAttribute('hidden','false');
766 var settings = g.network.simple_request(
768 [ ses(), g.data.list.au[0].id() ]
770 var view = settings['staff_client.catalog.record_view.default'];
771 if (g.view_override) {
772 view = g.view_override;
773 g.view_override = null;
776 case 'marc_view' : set_marc_view(); break;
777 case 'marc_edit' : set_marc_edit(); break;
778 case 'copy_browser' : set_copy_browser(); break;
779 case 'hold_browser' : set_hold_browser(); break;
780 case 'serctrl_view' : set_serctrl_view(); break;
782 default: set_opac(); break;
784 opac_wrapper_set_help_context();
786 g.error.standard_unexpected_error_alert('in refresh_display',E);
790 function set_default() {
791 var robj = g.network.simple_request(
793 [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
795 if (typeof robj.ilsevent != 'undefined') {
796 if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
800 function add_volumes() {
804 edit = g.network.request(
805 api.PERM_MULTI_ORG_CHECK.app,
806 api.PERM_MULTI_ORG_CHECK.method,
811 [ 'CREATE_VOLUME', 'CREATE_COPY' ]
813 ).length == 0 ? 1 : 0;
815 g.error.sdump('D_ERROR','batch permission check: ' + E);
819 alert(document.getElementById('offlineStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
820 return; // no read-only view for this interface
823 var title = document.getElementById('offlineStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [docid]);
825 var w = xulG.new_tab(
826 window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
827 { 'tab_name' : title },
828 { 'doc_id' : docid, 'ou_ids' : [ ses('ws_ou') ] }
831 alert('Error in chrome/content/cat/opac.js, add_volumes(): ' + E);