--- /dev/null
+dump('entering circ.copy_status.js\n');
+
+if (typeof circ == 'undefined') circ = {};
+circ.copy_status = function (params) {
+
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('util.date');
+ JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
+}
+
+circ.copy_status.prototype = {
+ 'selection_list' : [],
+
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ obj.session = params['session'];
+
+ JSAN.use('circ.util');
+ var columns = circ.util.columns(
+ {
+ 'barcode' : { 'hidden' : false },
+ 'title' : { 'hidden' : false },
+ 'location' : { 'hidden' : false },
+ 'call_number' : { 'hidden' : false },
+ 'status' : { 'hidden' : false },
+ }
+ );
+
+ JSAN.use('util.list'); obj.list = new util.list('copy_status_list');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_column' : circ.util.std_map_row_to_column(),
+ 'on_select' : function(ev) {
+ try {
+ JSAN.use('util.functional');
+ var sel = obj.list.retrieve_selection();
+ obj.selection_list = util.functional.map_list(
+ sel,
+ function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
+ );
+ obj.error.sdump('D_TRACE','circ/copy_status: selection list = ' + js2JSON(obj.selection_list) );
+ if (obj.selection_list.length == 0) {
+ obj.controller.view.sel_checkin.disabled = true;
+ obj.controller.view.sel_edit.disabled = true;
+ obj.controller.view.sel_opac.disabled = true;
+ obj.controller.view.sel_patron.disabled = true;
+ obj.controller.view.sel_bucket.disabled = true;
+ } else {
+ obj.controller.view.sel_checkin.disabled = false;
+ obj.controller.view.sel_edit.disabled = false;
+ obj.controller.view.sel_opac.disabled = false;
+ obj.controller.view.sel_patron.disabled = false;
+ obj.controller.view.sel_bucket.disabled = false;
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ },
+ }
+ );
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'sel_checkin' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ var barcode = obj.selection_list[i][1];
+ var checkin = circ.util.checkin_via_barcode(
+ obj.session, barcode
+ );
+ }
+ }
+ ],
+ 'sel_edit' : [
+ ['command'],
+ function() {
+ try {
+ obj.spawn_copy_editor();
+ } catch(E) {
+ alert(E);
+ }
+ }
+ ],
+ 'sel_opac' : [
+ ['command'],
+ function() {
+ alert('Not Yet Implemented');
+ }
+ ],
+ 'sel_patron' : [
+ ['command'],
+ function() {
+ alert('Not Yet Implemented');
+ }
+ ],
+ 'sel_bucket' : [
+ ['command'],
+ function() {
+ alert('Not Yet Implemented');
+ }
+ ],
+ 'copy_status_barcode_entry_textbox' : [
+ ['keypress'],
+ function(ev) {
+ if (ev.keyCode && ev.keyCode == 13) {
+ obj.copy_status();
+ }
+ }
+ ],
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert('Not Yet Implemented'); }
+ ],
+ 'cmd_copy_status_submit_barcode' : [
+ ['command'],
+ function() {
+ obj.copy_status();
+ }
+ ],
+ 'cmd_copy_status_print' : [
+ ['command'],
+ function() {
+ dump( js2JSON( obj.list.dump() ) );
+ alert( js2JSON( obj.list.dump() ) );
+ }
+ ],
+ 'cmd_copy_status_reprint' : [
+ ['command'],
+ function() {
+ }
+ ],
+ 'cmd_copy_status_done' : [
+ ['command'],
+ function() {
+ }
+ ],
+ }
+ }
+ );
+ this.controller.render();
+ this.controller.view.copy_status_barcode_entry_textbox.focus();
+
+ },
+
+ 'copy_status' : function() {
+ var obj = this;
+ try {
+ var barcode = obj.controller.view.copy_status_barcode_entry_textbox.value;
+ JSAN.use('circ.util');
+ var copy = obj.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE', [ barcode ]);
+ if (copy == null) {
+ throw('COPY NOT FOUND');
+ } else {
+ obj.list.append(
+ {
+ 'retrieve_id' : js2JSON( [ copy.id(), barcode ] ),
+ 'row' : {
+ 'my' : {
+ 'mvr' : obj.network.simple_request('MODS_SLIM_RECORD_RETRIEVE_VIA_COPY', [ copy.id() ]),
+ 'acp' : copy,
+ }
+ }
+ }
+ );
+ }
+ obj.controller.view.copy_status_barcode_entry_textbox.value = '';
+ obj.controller.view.copy_status_barcode_entry_textbox.focus();
+ } catch(E) {
+ alert('FIXME: need special alert and error handling\n'
+ + js2JSON(E));
+ obj.controller.view.copy_status_barcode_entry_textbox.select();
+ obj.controller.view.copy_status_barcode_entry_textbox.focus();
+ }
+
+ },
+
+ 'spawn_copy_editor' : function() {
+
+ /* FIXME - a lot of redundant calls here */
+
+ var obj = this;
+
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+
+ var list = obj.selection_list;
+
+ list = util.functional.map_list(
+ list,
+ function (obj) {
+ return obj[0];
+ }
+ );
+
+ var copies = util.functional.map_list(
+ list,
+ function (acp_id) {
+ return obj.network.simple_request('FM_ACP_RETRIEVE',[acp_id]);
+ }
+ );
+
+ var edit = 0;
+ try {
+ edit = obj.network.request(
+ api.PERM_MULTI_ORG_CHECK.app,
+ api.PERM_MULTI_ORG_CHECK.method,
+ [
+ obj.session,
+ obj.data.list.au[0].id(),
+ util.functional.map_list(
+ copies,
+ function (obj) {
+ return obj.network.simple_request('FM_ACN_RETRIEVE',[obj.call_number()]).owning_lib();
+ }
+ ),
+ [ 'UPDATE_COPY', 'UPDATE_BATCH_COPY' ]
+ ]
+ ).length == 0 ? 1 : 0;
+ } catch(E) {
+ obj.error.sdump('batch permission check: ' + E);
+ }
+
+ var title = list.length == 1 ? 'Copy' : 'Copies';
+
+ JSAN.use('util.window'); var win = new util.window();
+ obj.data.temp = '';
+ obj.data.stash('temp');
+ var w = win.open(
+ window.xulG.url_prefix(urls.XUL_COPY_EDITOR)
+ +'?session='+window.escape(obj.session)
+ +'©_ids='+window.escape(js2JSON(list))
+ +'&edit='+edit,
+ title,
+ 'chrome,modal,resizable'
+ );
+ /* FIXME -- need to unique the temp space, and not rely on modalness of window */
+ obj.data.stash_retrieve();
+ copies = JSON2js( obj.data.temp );
+ obj.error.sdump('D_CAT','in circ/copy_status, copy editor, copies =\n<<' + copies + '>>');
+ if (edit=='1' && copies!='' && typeof copies != 'undefined') {
+ try {
+ var r = obj.network.request(
+ api.FM_ACP_FLESHED_BATCH_UPDATE.app,
+ api.FM_ACP_FLESHED_BATCH_UPDATE.method,
+ [ obj.session, copies ]
+ );
+ /* FIXME -- revisit the return value here */
+ } catch(E) {
+ alert('copy update error: ' + js2JSON(E));
+ }
+ }
+ },
+
+}
+
+dump('exiting circ.copy_status.js\n');
--- /dev/null
+<?xml version="1.0"?>
+<!-- Application: Evergreen Staff Client -->
+<!-- Screen: Patron Display -->
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- STYLESHEETS -->
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+<?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="/xul/server/skin/circ.css" type="text/css"?>
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- LOCALIZATION -->
+<!DOCTYPE window SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
+
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+<?xul-overlay href="/xul/server/circ/copy_status_overlay.xul"?>
+
+<window id="copy_status_win"
+ onload="my_init()"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+ <!-- BEHAVIOR -->
+ <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
+ <scripts id="openils_util_scripts"/>
+
+ <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
+ <script>
+ <![CDATA[
+ function my_init() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('/xul/server/');
+ JSAN.use('util.error'); g.error = new util.error();
+ g.error.sdump('D_TRACE','my_init() for copy_status.xul');
+
+ g.cgi = new CGI();
+
+ JSAN.use('circ.copy_status'); g.copy_status = new circ.copy_status();
+ g.copy_status.init(
+ {
+ 'session' : g.cgi.param('session')
+ }
+ );
+
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name('Copy Status'); } catch(E) { alert(E); }
+ }
+
+ } catch(E) {
+ var err_msg = "!! This software has encountered an error. Please tell your friendly " +
+ "system administrator or software developer the following:\n"
+ + 'circ.copy_status.xul\n' + E + '\n';
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+ alert(err_msg);
+ }
+ }
+
+ ]]>
+ </script>
+
+ <commandset id="copy_status_cmds">
+ <command id="cmd_copy_status_submit_barcode" />
+ <command id="cmd_copy_status_print" />
+ <command id="cmd_copy_status_reprint" />
+ <command id="cmd_copy_status_done" />
+ </commandset>
+
+ <box id="copy_status_main" />
+
+</window>
+
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE overlay SYSTEM "chrome://open_ils_staff_client/locale/lang.dtd">
+<overlay id="copy_status_overlay"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script>dump('loading copy_status_overlay.xul\n');</script>
+
+<commandset id="copy_status_cmds" />
+
+<box id="copy_status_main" flex="1" orient="vertical" class="my_overflow">
+ <vbox id="cmvb1" flex="1"/>
+</box>
+
+<vbox id="cmvb1" flex="1">
+ <groupbox id="cmgb1" flex="2">
+ <caption label="Scan Item" />
+ <hbox id="copy_status_top_ui" />
+ <tree id="copy_status_list" flex="1" enableColumnDrag="true"/>
+ <hbox id="copy_status_bottom_ui" />
+ </groupbox>
+</vbox>
+
+<hbox id="copy_status_top_ui">
+ <label id="copy_status_scan_barcode_label"
+ value="Barcode:"
+ accesskey="B"
+ control="copy_status_barcode_entry_textbox"/>
+ <textbox id="copy_status_barcode_entry_textbox"/>
+ <button id="copy_status_submit_barcode_button"
+ label="Submit"
+ command="cmd_copy_status_submit_barcode"
+ accesskey="S"/>
+ <spacer flex="1"/>
+ <label value="Selected Items:"/>
+ <button id="sel_checkin" label="Check In" disabled="true"/>
+ <button id="sel_edit" label="Edit" disabled="true"/>
+ <button id="sel_opac" label="OPAC" disabled="true"/>
+ <button id="sel_patron" label="Patron" disabled="true"/>
+ <button id="sel_bucket" label="Bucket" disabled="true"/>
+</hbox>
+
+<hbox id="copy_status_bottom_ui">
+ <button id="copy_status_print"
+ label="Print"
+ command="cmd_copy_status_print"
+ accesskey="P"/>
+ <button id="copy_status_reprint"
+ label="Print Last"
+ command="cmd_copy_status_reprint"
+ accesskey_disabled="L"/>
+ <spacer id="pcii3s" flex="1"/>
+ <checkbox id="copy_status_auto"
+ label="Auto-Print"
+ accesskey_disabled="A"/>
+<!--
+ <button id="copy_status_done"
+ label="&staff.copy_status.done_label;"
+ command="cmd_copy_status_done"
+ accesskey="&staff.copy_status.done_label.accesskey;"/>
+-->
+</hbox>
+
+</overlay>