throw(E);
}
- return this;
+ return this;
}
OpenILS.data.prototype = {
- 'list' : {},
- 'hash' : {},
- 'tree' : {},
-
- 'temp' : '',
-
- 'data_progress' : function(msg) {
- try {
- var x = document.getElementById('data_progress');
- if (x) {
- x.appendChild( document.createTextNode( msg ) );
- }
- } catch(E) {
- this.error.sdump('D_ERROR',msg + '\n' + E);
- }
- },
-
- 'init' : function (params) {
-
- try {
- if (params && params.via == 'stash') {
- this.stash_retrieve();
- } else {
- this.network_retrieve();
- }
-
- } catch(E) {
- this.error.sdump('D_ERROR','Error in OpenILS.data.init('
- +js2JSON(params)+'): ' + js2JSON(E) );
- }
-
-
- },
-
- // This should be invoked only once per application, in a persistant window
- 'init_observer_functions' : function() {
- try {
- var obj = this; // OpenILS.data
- obj.observers = {}; //
- obj.observers.id = 1; // Unique id for each observer function added
- obj.observers.id2path = {}; // Lookup for full_path via observer id
- obj.observers.cache = {}; // Observer funcs go in here
-
- // For a given path, this executes all the registered observer funcs
- obj.observers.dispatch = function(full_path, old_value, new_value) {
- obj.error.sdump('D_OBSERVERS', 'entering observers.dispatch\nfull_path = ' + full_path + '\nold_value = ' + js2JSON(old_value) + '\nnew_value = ' + js2JSON(new_value) + '\n');
- try {
- var path = full_path.split(/\./).pop();
- for (var i in obj.observers.cache[full_path]) {
- try {
- var o = obj.observers.cache[full_path][i];
- if (typeof o.func == 'function') o.func(path, old_value, new_value);
- } catch(E) {
- obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) );
- }
- }
- } catch(E) {
- obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) );
- }
- }
-
- // This registers an observer function for a given path
- obj.observers.add = function(full_path, func) {
- try {
- obj.error.sdump('D_OBSERVERS', 'entering observers.add\nfull_path = ' + full_path + '\nfunc = ' + func + '\n');
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
- var data_cache=new OpenILS( );
- var stash = data_cache.wrappedJSObject.OpenILS.prototype.data;
-
- var id = obj.observers.id++;
- if (typeof obj.observers.cache[ full_path ] == 'undefined') obj.observers.cache[ full_path ] = {};
- obj.observers.cache[ full_path ][ id ] = { 'func' : func, 'time_added' : new Date() };
- obj.observers.id2path[ id ] = [ full_path ];
-
- var path_list = full_path.split(/\./);
- var observed_prop = path_list.pop();
-
- // Convert soft path to object reference. Error if any but the last node is undefined
- for (var i in path_list) stash = stash[ path_list[i] ];
-
- /*
-
- // experiment with storing only json in cache to avoid the [ ] -> { '0' : .., '1' : .. } bug
-
- if (stash[observed_prop] && getKeys( obj.observers.cache[ full_path ] ).length == 0) {
- stash['_' + observed_prop] = js2JSON(stash[observed_prop]);
- }
-
- stash.__defineSetter__(observed_prop, function(x) { this['_'+observed_prop] = js2JSON(x); });
- stash.__defineGetter__(observed_prop, function() { return JSON2js(this['_'+observed_prop]); });
- */
-
- stash.watch(
- observed_prop,
- function(p,old_value,new_value) {
- obj.observers.dispatch(full_path,old_value,new_value);
- return new_value;
- }
- );
-
- return id;
- } catch(E) {
- obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.add(): ' + js2JSON(E) );
- }
- }
-
- // This unregisters an observer function for a given observer id
- obj.observers.remove = function(id) {
- try {
- obj.error.sdump('D_OBSERVERS', 'entering observers.remove\nid = ' + id + '\n');
- var path = obj.observers.id2path[ id ];
- delete obj.observers.cache[ path ][ id ];
- delete obj.observers.id2path[ id ];
- } catch(E) {
- obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.remove(): ' + js2JSON(E) );
- }
- }
-
- // This purges observer functions for a given path
- obj.observers.purge = function(full_path) {
- obj.error.sdump('D_OBSERVERS', 'entering observers.purge\nfull_path = ' + full_path + '\n');
- try {
- var remove_these = [];
- for (var id in obj.observers.cache[ full_path ]) remove_these.push( id );
- for (var id in remove_these) delete obj.observers.id2path[ id ];
- delete obj.observers.cache[ full_path ];
- } catch(E) {
- obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.purge(): ' + js2JSON(E) );
- }
- }
-
- obj.stash('observers'); // make this accessible globally
-
- } catch(E) {
- this.error.sdump('D_ERROR','Error in OpenILS.data.init_observer_functions(): ' + js2JSON(E) );
- }
- },
-
- 'stash' : function () {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
- var data_cache=new OpenILS( );
- for (var i = 0; i < arguments.length; i++) {
- try {
- if (arguments[i] != 'hash' && arguments[i] != 'list') this.error.sdump('D_DATA_STASH','stashing ' + arguments[i] + ' : ' + this[arguments[i]] + (typeof this[arguments[i]] == 'object' ? ' = ' + (this[arguments[i]]) : '') + '\n');
- } catch(F) { alert(F); }
- data_cache.wrappedJSObject.OpenILS.prototype.data[arguments[i]] = this[arguments[i]];
- }
- } catch(E) {
- this.error.sdump('D_ERROR','Error in OpenILS.data.stash(): ' + js2JSON(E) );
- }
- },
-
- 'lookup' : function(key,value) {
- try {
- var obj = this; var found;
- if (obj.hash[key] && obj.hash[key][value]) return obj.hash[key][value];
- switch(key) {
- case 'acpl':
- found = obj.network.simple_request('FM_ACPL_RETRIEVE_VIA_ID.authoritative',[ value ]);
- break;
- default: return undefined; break;
- }
- if (typeof found.ilsevent != 'undefined') throw(found);
- if (!obj.hash[key]) obj.hash[key] = {};
- obj.hash[key][value] = found; obj.list[key].push( found ); obj.stash('hash','list');
- return found;
- } catch(E) {
- this.error.sdump('D_ERROR','Error in OpenILS.data.lookup('+key+','+value+'): ' + js2JSON(E) );
- return undefined;
- }
- },
-
- '_debug_stash' : function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
- var data_cache=new OpenILS( );
- for (var i in data_cache.wrappedJSObject.OpenILS.prototype.data) {
- dump('_debug_stash ' + i + '\n');
- }
- } catch(E) {
- this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
- }
- },
-
- '_fm_objects' : {
-
- 'pgt' : [ api.FM_PGT_RETRIEVE.app, api.FM_PGT_RETRIEVE.method, [], true ],
- 'cit' : [ api.FM_CIT_RETRIEVE.app, api.FM_CIT_RETRIEVE.method, [], true ],
- 'citm' : [ api.FM_CITM_RETRIEVE.app, api.FM_CITM_RETRIEVE.method, [], true ],
- /*
- 'cst' : [ api.FM_CST_RETRIEVE.app, api.FM_CST_RETRIEVE.method, [], true ],
- */
- /*
- 'acpl' : [ api.FM_ACPL_RETRIEVE.app, api.FM_ACPL_RETRIEVE.method, [], true ],
- */
- 'ccs' : [ api.FM_CCS_RETRIEVE.app, api.FM_CCS_RETRIEVE.method, [], true ],
- 'aou' : [ api.FM_AOU_RETRIEVE.app, api.FM_AOU_RETRIEVE.method, [], true ],
- 'aout' : [ api.FM_AOUT_RETRIEVE.app, api.FM_AOUT_RETRIEVE.method, [], true ],
- 'crahp' : [ api.FM_CRAHP_RETRIEVE.app, api.FM_CRAHP_RETRIEVE.method, [], true ]
- },
-
- 'stash_retrieve' : function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
- var data_cache=new OpenILS( );
- var dc = data_cache.wrappedJSObject.OpenILS.prototype.data;
- for (var i in dc) {
- this.error.sdump('D_DATA_RETRIEVE','Retrieving ' + i + ' : ' + dc[i] + '\n');
- this[i] = dc[i];
- }
- if (typeof this.on_complete == 'function') {
-
- this.on_complete();
- }
- } catch(E) {
- this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
- }
- },
-
- 'print_list_defaults' : function() {
- var obj = this;
- //if (typeof obj.print_list_templates == 'undefined') {
- {
- obj.print_list_types = [
- 'offline_checkout',
- 'offline_checkin',
- 'offline_renew',
- 'offline_inhouse_use',
- 'items',
- 'bills',
- 'payment',
- 'holds',
- /* 'patrons' */
- ];
- obj.print_list_templates = {
- 'item_status' : {
- 'type' : 'items',
- 'header' : 'The following items have been examined:<hr/><ol>',
- 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode%\r\n',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'transit_list' : {
- 'type' : 'transits',
- 'header' : 'Transits:<hr/><ol>',
- 'line_item' : '<li>From: %transit_source% To: %transit_dest_lib%<br/>\r\nWhen: %transit_source_send_time%<br />\r\nBarcode: %transit_item_barcode% Title: %transit_item_title%<br/>\r\n',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'items_out' : {
- 'type' : 'items',
- 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following items:<hr/><ol>',
- 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
- },
- 'renew' : {
- 'type' : 'items',
- 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have renewed the following items:<hr/><ol>',
- 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
- },
- 'checkout' : {
- 'type' : 'items',
- 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou checked out the following items:<hr/><ol>',
- 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
- },
- 'offline_checkout' : {
- 'type' : 'offline_checkout',
- 'header' : 'Patron %patron_barcode%<br/>\r\nYou checked out the following items:<hr/><ol>',
- 'line_item' : '<li>Barcode: %barcode%<br/>\r\nDue: %due_date%\r\n',
- 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'checkin' : {
- 'type' : 'items',
- 'header' : 'You checked in the following items:<hr/><ol>',
- 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Call Number: %call_number%\r\n',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'bill_payment' : {
- 'type' : 'payment',
- 'header' : 'Welcome to %LIBRARY%!<br/>A receipt of your transaction:<hr/> <table width="100%"> <tr> <td>Original Balance:</td> <td align="right">$%original_balance%</td> </tr> <tr> <td>Payment Method:</td> <td align="right">%payment_type%</td> </tr> <tr> <td>Payment Received:</td> <td align="right">$%payment_received%</td> </tr> <tr> <td>Payment Applied:</td> <td align="right">$%payment_applied%</td> </tr> <tr> <td>Billings Voided:</td> <td align="right">%voided_balance%</td> </tr> <tr> <td>Change Given:</td> <td align="right">$%change_given%</td> </tr> <tr> <td>New Balance:</td> <td align="right">$%new_balance%</td> </tr> </table> <p> Note: %note% </p> <p> Specific bills: <blockquote>',
- 'line_item' : 'Bill #%bill_id% %last_billing_type% Received: $%payment%<br />%barcode% %title%<br /><br />',
- 'footer' : '</blockquote> </p> <hr />%SHORTNAME% %TODAY_TRIM%<br/> <br/> '
- },
- 'bills_historical' : {
- 'type' : 'bills',
- 'header' : 'Welcome to %LIBRARY%!<br/>You had the following bills:<hr/><ol>',
- 'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'bills_current' : {
- 'type' : 'bills',
- 'header' : 'Welcome to %LIBRARY%!<br/>You have the following bills:<hr/><ol>',
- 'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'bills_main_view' : {
- 'type' : 'bills',
- 'header' : 'Welcome to %LIBRARY%!<br/>You have the following bills:<hr/><ol>',
- 'line_item' : '<dt><b>Bill #%id%</b> %title%</dt> <dd> <table width="100%"> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'offline_checkin' : {
- 'type' : 'offline_checkin',
- 'header' : 'You checked in the following items:<hr/><ol>',
- 'line_item' : '<li>Barcode: %barcode%\r\n',
- 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'offline_renew' : {
- 'type' : 'offline_renew',
- 'header' : 'You renewed the following items:<hr/><ol>',
- 'line_item' : '<li>Barcode: %barcode%\r\n',
- 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'offline_inhouse_use' : {
- 'type' : 'offline_inhouse_use',
- 'header' : 'You marked the following in-house items used:<hr/><ol>',
- 'line_item' : '<li>Barcode: %barcode%\r\nUses: %count%',
- 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'in_house_use' : {
- 'type' : 'items',
- 'header' : 'You marked the following in-house items used:<hr/><ol>',
- 'line_item' : '<li>Barcode: %barcode%\r\nUses: %uses%\r\n<br />%alert_message%',
- 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
- },
- 'holds' : {
- 'type' : 'holds',
- 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following titles on hold:<hr/><ol>',
- 'line_item' : '<li>%title%\r\n',
- 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
- },
+ 'list' : {},
+ 'hash' : {},
+ 'tree' : {},
+
+ 'temp' : '',
+
+ 'data_progress' : function(msg) {
+ try {
+ var x = document.getElementById('data_progress');
+ if (x) {
+ x.appendChild( document.createTextNode( msg ) );
+ }
+ } catch(E) {
+ this.error.sdump('D_ERROR',msg + '\n' + E);
+ }
+ },
+
+ 'init' : function (params) {
+
+ try {
+ if (params && params.via == 'stash') {
+ this.stash_retrieve();
+ } else {
+ this.network_retrieve();
+ }
+
+ } catch(E) {
+ this.error.sdump('D_ERROR','Error in OpenILS.data.init('
+ +js2JSON(params)+'): ' + js2JSON(E) );
+ }
+
+
+ },
+
+ // This should be invoked only once per application, in a persistant window
+ 'init_observer_functions' : function() {
+ try {
+ var obj = this; // OpenILS.data
+ obj.observers = {}; //
+ obj.observers.id = 1; // Unique id for each observer function added
+ obj.observers.id2path = {}; // Lookup for full_path via observer id
+ obj.observers.cache = {}; // Observer funcs go in here
+
+ // For a given path, this executes all the registered observer funcs
+ obj.observers.dispatch = function(full_path, old_value, new_value) {
+ obj.error.sdump('D_OBSERVERS', 'entering observers.dispatch\nfull_path = ' + full_path + '\nold_value = ' + js2JSON(old_value) + '\nnew_value = ' + js2JSON(new_value) + '\n');
+ try {
+ var path = full_path.split(/\./).pop();
+ for (var i in obj.observers.cache[full_path]) {
+ try {
+ var o = obj.observers.cache[full_path][i];
+ if (typeof o.func == 'function') o.func(path, old_value, new_value);
+ } catch(E) {
+ obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) );
+ }
+ }
+ } catch(E) {
+ obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.dispatch(): ' + js2JSON(E) );
+ }
+ }
+
+ // This registers an observer function for a given path
+ obj.observers.add = function(full_path, func) {
+ try {
+ obj.error.sdump('D_OBSERVERS', 'entering observers.add\nfull_path = ' + full_path + '\nfunc = ' + func + '\n');
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
+ var data_cache=new OpenILS( );
+ var stash = data_cache.wrappedJSObject.OpenILS.prototype.data;
+
+ var id = obj.observers.id++;
+ if (typeof obj.observers.cache[ full_path ] == 'undefined') obj.observers.cache[ full_path ] = {};
+ obj.observers.cache[ full_path ][ id ] = { 'func' : func, 'time_added' : new Date() };
+ obj.observers.id2path[ id ] = [ full_path ];
+
+ var path_list = full_path.split(/\./);
+ var observed_prop = path_list.pop();
+
+ // Convert soft path to object reference. Error if any but the last node is undefined
+ for (var i in path_list) stash = stash[ path_list[i] ];
+
+ /*
+
+ // experiment with storing only json in cache to avoid the [ ] -> { '0' : .., '1' : .. } bug
+
+ if (stash[observed_prop] && getKeys( obj.observers.cache[ full_path ] ).length == 0) {
+ stash['_' + observed_prop] = js2JSON(stash[observed_prop]);
+ }
+
+ stash.__defineSetter__(observed_prop, function(x) { this['_'+observed_prop] = js2JSON(x); });
+ stash.__defineGetter__(observed_prop, function() { return JSON2js(this['_'+observed_prop]); });
+ */
+
+ stash.watch(
+ observed_prop,
+ function(p,old_value,new_value) {
+ obj.observers.dispatch(full_path,old_value,new_value);
+ return new_value;
+ }
+ );
+
+ return id;
+ } catch(E) {
+ obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.add(): ' + js2JSON(E) );
+ }
+ }
+
+ // This unregisters an observer function for a given observer id
+ obj.observers.remove = function(id) {
+ try {
+ obj.error.sdump('D_OBSERVERS', 'entering observers.remove\nid = ' + id + '\n');
+ var path = obj.observers.id2path[ id ];
+ delete obj.observers.cache[ path ][ id ];
+ delete obj.observers.id2path[ id ];
+ } catch(E) {
+ obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.remove(): ' + js2JSON(E) );
+ }
+ }
+
+ // This purges observer functions for a given path
+ obj.observers.purge = function(full_path) {
+ obj.error.sdump('D_OBSERVERS', 'entering observers.purge\nfull_path = ' + full_path + '\n');
+ try {
+ var remove_these = [];
+ for (var id in obj.observers.cache[ full_path ]) remove_these.push( id );
+ for (var id in remove_these) delete obj.observers.id2path[ id ];
+ delete obj.observers.cache[ full_path ];
+ } catch(E) {
+ obj.error.sdump('D_ERROR','Error in OpenILS.data.observers.purge(): ' + js2JSON(E) );
+ }
+ }
+
+ obj.stash('observers'); // make this accessible globally
+
+ } catch(E) {
+ this.error.sdump('D_ERROR','Error in OpenILS.data.init_observer_functions(): ' + js2JSON(E) );
+ }
+ },
+
+ 'stash' : function () {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
+ var data_cache=new OpenILS( );
+ for (var i = 0; i < arguments.length; i++) {
+ try {
+ if (arguments[i] != 'hash' && arguments[i] != 'list') this.error.sdump('D_DATA_STASH','stashing ' + arguments[i] + ' : ' + this[arguments[i]] + (typeof this[arguments[i]] == 'object' ? ' = ' + (this[arguments[i]]) : '') + '\n');
+ } catch(F) { alert(F); }
+ data_cache.wrappedJSObject.OpenILS.prototype.data[arguments[i]] = this[arguments[i]];
+ }
+ } catch(E) {
+ this.error.sdump('D_ERROR','Error in OpenILS.data.stash(): ' + js2JSON(E) );
+ }
+ },
+
+ 'lookup' : function(key,value) {
+ try {
+ var obj = this; var found;
+ if (obj.hash[key] && obj.hash[key][value]) return obj.hash[key][value];
+ switch(key) {
+ case 'acpl':
+ found = obj.network.simple_request('FM_ACPL_RETRIEVE_VIA_ID.authoritative',[ value ]);
+ break;
+ default: return undefined; break;
+ }
+ if (typeof found.ilsevent != 'undefined') throw(found);
+ if (!obj.hash[key]) obj.hash[key] = {};
+ obj.hash[key][value] = found; obj.list[key].push( found ); obj.stash('hash','list');
+ return found;
+ } catch(E) {
+ this.error.sdump('D_ERROR','Error in OpenILS.data.lookup('+key+','+value+'): ' + js2JSON(E) );
+ return undefined;
+ }
+ },
+
+ '_debug_stash' : function() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
+ var data_cache=new OpenILS( );
+ for (var i in data_cache.wrappedJSObject.OpenILS.prototype.data) {
+ dump('_debug_stash ' + i + '\n');
+ }
+ } catch(E) {
+ this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
+ }
+ },
+
+ '_fm_objects' : {
+
+ 'pgt' : [ api.FM_PGT_RETRIEVE.app, api.FM_PGT_RETRIEVE.method, [], true ],
+ 'cit' : [ api.FM_CIT_RETRIEVE.app, api.FM_CIT_RETRIEVE.method, [], true ],
+ 'citm' : [ api.FM_CITM_RETRIEVE.app, api.FM_CITM_RETRIEVE.method, [], true ],
+ /*
+ 'cst' : [ api.FM_CST_RETRIEVE.app, api.FM_CST_RETRIEVE.method, [], true ],
+ */
+ /*
+ 'acpl' : [ api.FM_ACPL_RETRIEVE.app, api.FM_ACPL_RETRIEVE.method, [], true ],
+ */
+ 'ccs' : [ api.FM_CCS_RETRIEVE.app, api.FM_CCS_RETRIEVE.method, [], true ],
+ 'aou' : [ api.FM_AOU_RETRIEVE.app, api.FM_AOU_RETRIEVE.method, [], true ],
+ 'aout' : [ api.FM_AOUT_RETRIEVE.app, api.FM_AOUT_RETRIEVE.method, [], true ],
+ 'crahp' : [ api.FM_CRAHP_RETRIEVE.app, api.FM_CRAHP_RETRIEVE.method, [], true ]
+ },
+
+ 'stash_retrieve' : function() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ const OpenILS=new Components.Constructor("@mozilla.org/openils_data_cache;1", "nsIOpenILS");
+ var data_cache=new OpenILS( );
+ var dc = data_cache.wrappedJSObject.OpenILS.prototype.data;
+ for (var i in dc) {
+ this.error.sdump('D_DATA_RETRIEVE','Retrieving ' + i + ' : ' + dc[i] + '\n');
+ this[i] = dc[i];
+ }
+ if (typeof this.on_complete == 'function') {
+
+ this.on_complete();
+ }
+ } catch(E) {
+ this.error.sdump('D_ERROR','Error in OpenILS.data._debug_stash(): ' + js2JSON(E) );
+ }
+ },
+
+ 'print_list_defaults' : function() {
+ var obj = this;
+ //if (typeof obj.print_list_templates == 'undefined') {
+ {
+ obj.print_list_types = [
+ 'offline_checkout',
+ 'offline_checkin',
+ 'offline_renew',
+ 'offline_inhouse_use',
+ 'items',
+ 'bills',
+ 'payment',
+ 'holds',
+ /* 'patrons' */
+ ];
+ obj.print_list_templates = {
+ 'item_status' : {
+ 'type' : 'items',
+ 'header' : 'The following items have been examined:<hr/><ol>',
+ 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode%\r\n',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'transit_list' : {
+ 'type' : 'transits',
+ 'header' : 'Transits:<hr/><ol>',
+ 'line_item' : '<li>From: %transit_source% To: %transit_dest_lib%<br/>\r\nWhen: %transit_source_send_time%<br />\r\nBarcode: %transit_item_barcode% Title: %transit_item_title%<br/>\r\n',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'items_out' : {
+ 'type' : 'items',
+ 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following items:<hr/><ol>',
+ 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
+ },
+ 'renew' : {
+ 'type' : 'items',
+ 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have renewed the following items:<hr/><ol>',
+ 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
+ },
+ 'checkout' : {
+ 'type' : 'items',
+ 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou checked out the following items:<hr/><ol>',
+ 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Due: %due_date%\r\n',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
+ },
+ 'offline_checkout' : {
+ 'type' : 'offline_checkout',
+ 'header' : 'Patron %patron_barcode%<br/>\r\nYou checked out the following items:<hr/><ol>',
+ 'line_item' : '<li>Barcode: %barcode%<br/>\r\nDue: %due_date%\r\n',
+ 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'checkin' : {
+ 'type' : 'items',
+ 'header' : 'You checked in the following items:<hr/><ol>',
+ 'line_item' : '<li>%title%<br/>\r\nBarcode: %barcode% Call Number: %call_number%\r\n',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'bill_payment' : {
+ 'type' : 'payment',
+ 'header' : 'Welcome to %LIBRARY%!<br/>A receipt of your transaction:<hr/> <table width="100%"> <tr> <td>Original Balance:</td> <td align="right">$%original_balance%</td> </tr> <tr> <td>Payment Method:</td> <td align="right">%payment_type%</td> </tr> <tr> <td>Payment Received:</td> <td align="right">$%payment_received%</td> </tr> <tr> <td>Payment Applied:</td> <td align="right">$%payment_applied%</td> </tr> <tr> <td>Billings Voided:</td> <td align="right">%voided_balance%</td> </tr> <tr> <td>Change Given:</td> <td align="right">$%change_given%</td> </tr> <tr> <td>New Balance:</td> <td align="right">$%new_balance%</td> </tr> </table> <p> Note: %note% </p> <p> Specific bills: <blockquote>',
+ 'line_item' : 'Bill #%bill_id% %last_billing_type% Received: $%payment%<br />%barcode% %title%<br /><br />',
+ 'footer' : '</blockquote> </p> <hr />%SHORTNAME% %TODAY_TRIM%<br/> <br/> '
+ },
+ 'bills_historical' : {
+ 'type' : 'bills',
+ 'header' : 'Welcome to %LIBRARY%!<br/>You had the following bills:<hr/><ol>',
+ 'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'bills_current' : {
+ 'type' : 'bills',
+ 'header' : 'Welcome to %LIBRARY%!<br/>You have the following bills:<hr/><ol>',
+ 'line_item' : '<dt><b>Bill #%id%</b></dt> <dd> <table> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'bills_main_view' : {
+ 'type' : 'bills',
+ 'header' : 'Welcome to %LIBRARY%!<br/>You have the following bills:<hr/><ol>',
+ 'line_item' : '<dt><b>Bill #%id%</b> %title%</dt> <dd> <table width="100%"> <tr valign="top"><td>Date:</td><td>%xact_start%</td></tr> <tr valign="top"><td>Type:</td><td>%xact_type%</td></tr> <tr valign="top"><td>Last Billing:</td><td>%last_billing_type%<br/>%last_billing_note%</td></tr> <tr valign="top"><td>Total Billed:</td><td>$%total_owed%</td></tr> <tr valign="top"><td>Last Payment:</td><td>%last_payment_type%<br/>%last_payment_note%</td></tr> <tr valign="top"><td>Total Paid:</td><td>$%total_paid%</td></tr> <tr valign="top"><td><b>Balance:</b></td><td><b>$%balance_owed%</b></td></tr> </table><br/>',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'offline_checkin' : {
+ 'type' : 'offline_checkin',
+ 'header' : 'You checked in the following items:<hr/><ol>',
+ 'line_item' : '<li>Barcode: %barcode%\r\n',
+ 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'offline_renew' : {
+ 'type' : 'offline_renew',
+ 'header' : 'You renewed the following items:<hr/><ol>',
+ 'line_item' : '<li>Barcode: %barcode%\r\n',
+ 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'offline_inhouse_use' : {
+ 'type' : 'offline_inhouse_use',
+ 'header' : 'You marked the following in-house items used:<hr/><ol>',
+ 'line_item' : '<li>Barcode: %barcode%\r\nUses: %count%',
+ 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'in_house_use' : {
+ 'type' : 'items',
+ 'header' : 'You marked the following in-house items used:<hr/><ol>',
+ 'line_item' : '<li>Barcode: %barcode%\r\nUses: %uses%\r\n<br />%alert_message%',
+ 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n'
+ },
+ 'holds' : {
+ 'type' : 'holds',
+ 'header' : 'Welcome to %LIBRARY%!<br/>\r\nYou have the following titles on hold:<hr/><ol>',
+ 'line_item' : '<li>%title%\r\n',
+ 'footer' : '</ol><hr />%SHORTNAME% %TODAY_TRIM%<br/>\r\nYou were helped by %STAFF_FIRSTNAME%<br/>\r\n<br/>\r\n'
+ },
'hold_slip' : {
- 'type' : 'holds',
- 'header' : 'This item needs to be routed to <b>%route_to%</b>:<br/>\r\nBarcode: %item_barcode%<br/>\r\nTitle: %item_title%<br/>\r\n<br/>\r\n%hold_for_msg%<br/>\r\nBarcode: %PATRON_BARCODE%<br/>\r\nNotify by phone: %notify_by_phone%<br/>\r\nNotify by email: %notify_by_email%<br/>\r\n',
+ 'type' : 'holds',
+ 'header' : 'This item needs to be routed to <b>%route_to%</b>:<br/>\r\nBarcode: %item_barcode%<br/>\r\nTitle: %item_title%<br/>\r\n<br/>\r\n%hold_for_msg%<br/>\r\nBarcode: %PATRON_BARCODE%<br/>\r\nNotify by phone: %notify_by_phone%<br/>\r\nNotify by email: %notify_by_email%<br/>\r\n',
'line_item' : '%formatted_note%<br/>\r\n',
'footer' : '<br/>\r\nRequest date: %request_date%<br/>\r\nSlip Date: %TODAY_TRIM%<br/>\r\nPrinted by %STAFF_FIRSTNAME% at %SHORTNAME%<br/>\r\n<br/>\r\n'
},
'transit_slip' : {
- 'type' : 'transits',
- 'header' : 'This item needs to be routed to <b>%route_to%</b>:<br/>\r\n%route_to_org_fullname%<br/>\r\n%street1%<br/>\r\n%street2%<br/>\r\n%city_state_zip%<br/>\r\n<br/>\r\n',
+ 'type' : 'transits',
+ 'header' : 'This item needs to be routed to <b>%route_to%</b>:<br/>\r\n%route_to_org_fullname%<br/>\r\n%street1%<br/>\r\n%street2%<br/>\r\n%city_state_zip%<br/>\r\n<br/>\r\n',
'line_item' : 'Barcode: %item_barcode%<br/>\r\nTitle: %item_title%<br/>\r\nAuthor: %item_author%<br>\r\n<br/>\r\n',
'footer' : 'Slip Date: %TODAY_TRIM%<br/>\r\nPrinted by %STAFF_FIRSTNAME% at %SHORTNAME%<br/>\r\n<br/>\r\n'
},
'hold_transit_slip' : {
- 'type' : 'transits',
- 'header' : 'This item needs to be routed to <b>%route_to%</b>:<br/>\r\n%route_to_org_fullname%<br/>\r\n%street1%<br/>\r\n%street2%<br/>\r\n%city_state_zip%<br/>\r\n<br/>\r\nBarcode: %item_barcode%<br/>\r\nTitle: %item_title%<br/>\r\nAuthor: %item_author%<br>\r\n<br/>\r\n%hold_for_msg%<br/>\r\nBarcode: %PATRON_BARCODE%<br/>\r\nNotify by phone: %notify_by_phone%<br/>\r\nNotify by email: %notify_by_email%<br/>\r\n',
+ 'type' : 'transits',
+ 'header' : 'This item needs to be routed to <b>%route_to%</b>:<br/>\r\n%route_to_org_fullname%<br/>\r\n%street1%<br/>\r\n%street2%<br/>\r\n%city_state_zip%<br/>\r\n<br/>\r\nBarcode: %item_barcode%<br/>\r\nTitle: %item_title%<br/>\r\nAuthor: %item_author%<br>\r\n<br/>\r\n%hold_for_msg%<br/>\r\nBarcode: %PATRON_BARCODE%<br/>\r\nNotify by phone: %notify_by_phone%<br/>\r\nNotify by email: %notify_by_email%<br/>\r\n',
'line_item' : '%formatted_note%<br/>\r\n',
'footer' : '<br/>\r\nRequest date: %request_date%<br/>\r\nSlip Date: %TODAY_TRIM%<br/>\r\nPrinted by %STAFF_FIRSTNAME% at %SHORTNAME%<br/>\r\n<br/>\r\n'
}
- };
-
- obj.stash( 'print_list_templates', 'print_list_types' );
- }
- },
-
- 'network_retrieve' : function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
-
-
- JSAN.use('util.file'); var file = new util.file('print_list_templates');
- obj.print_list_defaults();
- obj.data_progress('Default print templates set. ');
- if (file._file.exists()) {
- try {
- var x = file.get_object();
- if (x) {
- for (var i in x) {
- obj.print_list_templates[i] = x[i];
- }
- obj.stash('print_list_templates');
- obj.data_progress('Saved print templates retrieved from file. ');
- }
- } catch(E) {
- alert(E);
- }
- }
- file.close();
-
- JSAN.use('util.file'); var file = new util.file('global_font_adjust');
- if (file._file.exists()) {
- try {
- var x = file.get_object();
- if (x) {
- obj.global_font_adjust = x;
- obj.stash('global_font_adjust');
- obj.data_progress('Saved font settings retrieved from file. ');
- }
- } catch(E) {
- alert(E);
- }
- }
- file.close();
-
- JSAN.use('util.file'); var file = new util.file('no_sound');
- if (file._file.exists()) {
- try {
- var x = file.get_content();
- if (x) {
- obj.no_sound = x;
- obj.stash('no_sound');
- obj.data_progress('Saved sound settings retrieved from file. ');
- }
- } catch(E) {
- alert(E);
- }
- }
- file.close();
-
- JSAN.use('util.file'); var file = new util.file('print_strategy');
- if (file._file.exists()) {
- try {
- var x = file.get_content();
- if (x) {
- obj.print_strategy = x;
- obj.stash('print_strategy');
- obj.data_progress('Print strategy retrieved from file. ');
- }
- } catch(E) {
- alert(E);
- }
- }
- file.close();
-
- JSAN.use('util.functional');
- JSAN.use('util.fm_utils');
-
- function gen_fm_retrieval_func(classname,data) {
- var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3];
- return function () {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
- function convert() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- try {
- if (obj.list[classname].constructor.name == 'Array') {
- obj.hash[classname] =
- util.functional.convert_object_list_to_hash(
- obj.list[classname]
- );
- }
- } catch(E) {
-
- obj.error.sdump('D_ERROR',E + '\n');
- }
-
- }
-
- try {
- var level = obj.error.sdump_levels.D_SES_RESULT;
- if (classname == 'aou' || classname == 'my_aou')
- obj.error.sdump_levels.D_SES_RESULT = false;
- var robj = obj.network.request( app, method, params);
- if (robj != null && typeof robj.ilsevent != 'undefined') {
- obj.error.standard_unexpected_error_alert('The staff client failed to retrieve expected data from this call, "' + method + '"',robj);
- throw(robj);
- }
- obj.list[classname] = robj == null ? [] : robj;
- obj.error.sdump_levels.D_SES_RESULT = level;
- convert();
- obj.data_progress('Retrieved list for ' + classname + ' objects. ');
-
- } catch(E) {
- // if cacheable, try offline
- if (cacheable) {
- /* FIXME -- we're going to revisit caching and do it differently
- try {
- var file = new util.file( classname );
- obj.list[classname] = file.get_object(); file.close();
- convert();
- } catch(E) {
- throw(E);
- }
- */
- throw(E); // for now
- } else {
- throw(E); // for now
- }
- }
- }
- }
-
- this.chain = [];
-
- this.chain.push(
- function() {
- try {
- var robj = obj.network.simple_request('CIRC_MODIFIER_LIST',[]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- obj.list.circ_modifier = robj;
- obj.data_progress('Retrieved circ modifier list. ');
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
- this.chain.push(
- function() {
- var f = gen_fm_retrieval_func(
- 'cnal',
- [
- api.FM_CNAL_RETRIEVE.app,
- api.FM_CNAL_RETRIEVE.method,
- [ obj.session.key ],
- false
- ]
- );
- try {
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
- this.chain.push(
- function() {
- var f = gen_fm_retrieval_func(
- 'csp',
- [
- api.FM_CSP_PCRUD_SEARCH.app,
- api.FM_CSP_PCRUD_SEARCH.method,
- [ obj.session.key, {"id":{"!=":null}}, {"order_by":{"csp":"id"}} ],
- false
- ]
- );
- try {
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
- this.chain.push(
- function() {
- var f = gen_fm_retrieval_func(
- 'ahrcc',
- [
- api.FM_AHRCC_PCRUD_SEARCH.app,
- api.FM_AHRCC_PCRUD_SEARCH.method,
- [ obj.session.key, {"id":{"!=":null}}, {"order_by":{"ahrcc":"label"}} ],
- false
- ]
- );
- try {
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
-
- this.chain.push(
- function() {
- var f = gen_fm_retrieval_func(
- 'au',
- [
- api.FM_AU_RETRIEVE_VIA_SESSION.app,
- api.FM_AU_RETRIEVE_VIA_SESSION.method,
- [ obj.session.key ],
- false
- ]
- );
- try {
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- obj.list.au = [ obj.list.au ];
- }
- );
-
- this.chain.push(
- function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var f = gen_fm_retrieval_func(
- 'my_asv',
- [
- api.FM_ASV_RETRIEVE_REQUIRED.app,
- api.FM_ASV_RETRIEVE_REQUIRED.method,
- [ obj.session.key ],
- true
- ]
- );
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
- this.chain.push(
- function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var f = gen_fm_retrieval_func(
- 'asv',
- [
- api.FM_ASV_RETRIEVE.app,
- api.FM_ASV_RETRIEVE.method,
- [ obj.session.key ],
- true
- ]
- );
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
- obj.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
-
- for (var i in this._fm_objects) {
- this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
- }
-
- // The previous org_tree call returned a tree, not a list or hash.
- this.chain.push(
- function () {
- obj.tree.aou = obj.list.aou;
- obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
- for (var i = 0; i < obj.list.aou.length; i++) {
- var c = obj.list.aou[i].children();
- if (!c) c = [];
- c = c.sort(
- function( a, b ) {
- if (a.shortname() < b.shortname()) return -1;
- if (a.shortname() > b.shortname()) return 1;
- return 0;
- }
- );
- obj.list.aou[i].children( c );
- }
- obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
- obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
- }
- );
-
- // The previous pgt call returned a tree, not a list or hash.
- this.chain.push(
- function () {
- obj.tree.pgt = obj.list.pgt;
- obj.list.pgt = util.fm_utils.flatten_ou_branch( obj.tree.pgt );
- obj.hash.pgt = util.functional.convert_object_list_to_hash( obj.list.pgt );
- }
- );
-
- // Do these after we get the user object
-
- this.chain.push(
- function() {
- try {
- var robj = obj.network.simple_request('FM_AOUS_RETRIEVE',[ obj.session.key, obj.list.au[0].ws_ou() ]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- obj.hash.aous = robj;
- obj.data_progress('Retrieved org unit settings. ');
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
- this.chain.push(
-
- function() {
-
- gen_fm_retrieval_func('my_aou',
- [
- api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.app,
- api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.method,
- [ obj.session.key, obj.list.au[0].ws_ou() ], /* use ws_ou and not home_ou */
- true
- ]
- )();
- }
- );
-
- this.chain.push(
-
- function () {
-
- gen_fm_retrieval_func( 'my_actsc',
- [
- api.FM_ACTSC_RETRIEVE_VIA_AOU.app,
- api.FM_ACTSC_RETRIEVE_VIA_AOU.method,
- [ obj.session.key, obj.list.au[0].ws_ou() ],
- true
- ]
- )();
- }
- );
-
- this.chain.push(
-
- function () {
-
- gen_fm_retrieval_func( 'my_asc',
- [
- api.FM_ASC_RETRIEVE_VIA_AOU.app,
- api.FM_ASC_RETRIEVE_VIA_AOU.method,
- [ obj.session.key, obj.list.au[0].ws_ou() ],
- true
- ]
- )();
- }
- );
-
-
- this.chain.push(
- function() {
- var f = gen_fm_retrieval_func(
- 'cnct',
- [
- api.FM_CNCT_RETRIEVE.app,
- api.FM_CNCT_RETRIEVE.method,
- [ obj.list.au[0].ws_ou() ],
- false
- ]
- );
- try {
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
- this.chain.push(
- function() {
- var f = gen_fm_retrieval_func(
- 'my_cnct',
- [
- api.FM_CNCT_RETRIEVE.app,
- api.FM_CNCT_RETRIEVE.method,
- [ obj.list.au[0].ws_ou() ],
- false
- ]
- );
- try {
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
-
- this.chain.push(
- function() {
- var f = gen_fm_retrieval_func(
- 'acpl',
- [
- api.FM_ACPL_RETRIEVE.app,
- api.FM_ACPL_RETRIEVE.method,
- [ obj.list.au[0].ws_ou() ],
- false
- ]
- );
- try {
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
- this.chain.push(
- function() {
- var f = gen_fm_retrieval_func(
- 'cbt',
- [
- api.FM_CBT_RETRIEVE.app,
- api.FM_CBT_RETRIEVE.method,
- [ obj.session.key, obj.list.au[0].ws_ou() ],
- false
- ]
- );
- try {
- f();
- } catch(E) {
- var error = 'Error: ' + js2JSON(E);
- obj.error.sdump('D_ERROR',error);
- throw(E);
- }
- }
- );
-
- if (typeof this.on_complete == 'function') {
-
- this.chain.push( this.on_complete );
- }
- JSAN.use('util.exec'); this.exec = new util.exec();
- this.exec.on_error = function(E) {
-
- if (typeof obj.on_error == 'function') {
- return obj.on_error(E); /* false breaks chain */
- } else {
- alert('oops: ' + E );
- return false; /* break chain */
- }
-
- }
-
- this.exec.chain( this.chain );
-
- }
+ };
+
+ obj.stash( 'print_list_templates', 'print_list_types' );
+ }
+ },
+
+ 'network_retrieve' : function() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var obj = this;
+
+
+ JSAN.use('util.file'); var file = new util.file('print_list_templates');
+ obj.print_list_defaults();
+ obj.data_progress('Default print templates set. ');
+ if (file._file.exists()) {
+ try {
+ var x = file.get_object();
+ if (x) {
+ for (var i in x) {
+ obj.print_list_templates[i] = x[i];
+ }
+ obj.stash('print_list_templates');
+ obj.data_progress('Saved print templates retrieved from file. ');
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }
+ file.close();
+
+ JSAN.use('util.file'); var file = new util.file('global_font_adjust');
+ if (file._file.exists()) {
+ try {
+ var x = file.get_object();
+ if (x) {
+ obj.global_font_adjust = x;
+ obj.stash('global_font_adjust');
+ obj.data_progress('Saved font settings retrieved from file. ');
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }
+ file.close();
+
+ JSAN.use('util.file'); var file = new util.file('no_sound');
+ if (file._file.exists()) {
+ try {
+ var x = file.get_content();
+ if (x) {
+ obj.no_sound = x;
+ obj.stash('no_sound');
+ obj.data_progress('Saved sound settings retrieved from file. ');
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }
+ file.close();
+
+ JSAN.use('util.file'); var file = new util.file('print_strategy');
+ if (file._file.exists()) {
+ try {
+ var x = file.get_content();
+ if (x) {
+ obj.print_strategy = x;
+ obj.stash('print_strategy');
+ obj.data_progress('Print strategy retrieved from file. ');
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }
+ file.close();
+
+ JSAN.use('util.functional');
+ JSAN.use('util.fm_utils');
+
+ function gen_fm_retrieval_func(classname,data) {
+ var app = data[0]; var method = data[1]; var params = data[2]; var cacheable = data[3];
+ return function () {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ function convert() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ try {
+ if (obj.list[classname].constructor.name == 'Array') {
+ obj.hash[classname] =
+ util.functional.convert_object_list_to_hash(
+ obj.list[classname]
+ );
+ }
+ } catch(E) {
+
+ obj.error.sdump('D_ERROR',E + '\n');
+ }
+
+ }
+
+ try {
+ var level = obj.error.sdump_levels.D_SES_RESULT;
+ if (classname == 'aou' || classname == 'my_aou')
+ obj.error.sdump_levels.D_SES_RESULT = false;
+ var robj = obj.network.request( app, method, params);
+ if (robj != null && typeof robj.ilsevent != 'undefined') {
+ obj.error.standard_unexpected_error_alert('The staff client failed to retrieve expected data from this call, "' + method + '"',robj);
+ throw(robj);
+ }
+ obj.list[classname] = robj == null ? [] : robj;
+ obj.error.sdump_levels.D_SES_RESULT = level;
+ convert();
+ obj.data_progress('Retrieved list for ' + classname + ' objects. ');
+
+ } catch(E) {
+ // if cacheable, try offline
+ if (cacheable) {
+ /* FIXME -- we're going to revisit caching and do it differently
+ try {
+ var file = new util.file( classname );
+ obj.list[classname] = file.get_object(); file.close();
+ convert();
+ } catch(E) {
+ throw(E);
+ }
+ */
+ throw(E); // for now
+ } else {
+ throw(E); // for now
+ }
+ }
+ }
+ }
+
+ this.chain = [];
+
+ this.chain.push(
+ function() {
+ try {
+ var robj = obj.network.simple_request('CIRC_MODIFIER_LIST',[]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ obj.list.circ_modifier = robj;
+ obj.data_progress('Retrieved circ modifier list. ');
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+ this.chain.push(
+ function() {
+ var f = gen_fm_retrieval_func(
+ 'cnal',
+ [
+ api.FM_CNAL_RETRIEVE.app,
+ api.FM_CNAL_RETRIEVE.method,
+ [ obj.session.key ],
+ false
+ ]
+ );
+ try {
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+ this.chain.push(
+ function() {
+ var f = gen_fm_retrieval_func(
+ 'csp',
+ [
+ api.FM_CSP_PCRUD_SEARCH.app,
+ api.FM_CSP_PCRUD_SEARCH.method,
+ [ obj.session.key, {"id":{"!=":null}}, {"order_by":{"csp":"id"}} ],
+ false
+ ]
+ );
+ try {
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+ this.chain.push(
+ function() {
+ var f = gen_fm_retrieval_func(
+ 'ahrcc',
+ [
+ api.FM_AHRCC_PCRUD_SEARCH.app,
+ api.FM_AHRCC_PCRUD_SEARCH.method,
+ [ obj.session.key, {"id":{"!=":null}}, {"order_by":{"ahrcc":"label"}} ],
+ false
+ ]
+ );
+ try {
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+
+ this.chain.push(
+ function() {
+ var f = gen_fm_retrieval_func(
+ 'au',
+ [
+ api.FM_AU_RETRIEVE_VIA_SESSION.app,
+ api.FM_AU_RETRIEVE_VIA_SESSION.method,
+ [ obj.session.key ],
+ false
+ ]
+ );
+ try {
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ obj.list.au = [ obj.list.au ];
+ }
+ );
+
+ this.chain.push(
+ function() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var f = gen_fm_retrieval_func(
+ 'my_asv',
+ [
+ api.FM_ASV_RETRIEVE_REQUIRED.app,
+ api.FM_ASV_RETRIEVE_REQUIRED.method,
+ [ obj.session.key ],
+ true
+ ]
+ );
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+ this.chain.push(
+ function() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var f = gen_fm_retrieval_func(
+ 'asv',
+ [
+ api.FM_ASV_RETRIEVE.app,
+ api.FM_ASV_RETRIEVE.method,
+ [ obj.session.key ],
+ true
+ ]
+ );
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+ obj.error.sdump('D_DEBUG','_fm_objects = ' + js2JSON(this._fm_objects) + '\n');
+
+ for (var i in this._fm_objects) {
+ this.chain.push( gen_fm_retrieval_func(i,this._fm_objects[i]) );
+ }
+
+ // The previous org_tree call returned a tree, not a list or hash.
+ this.chain.push(
+ function () {
+ obj.tree.aou = obj.list.aou;
+ obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
+ for (var i = 0; i < obj.list.aou.length; i++) {
+ var c = obj.list.aou[i].children();
+ if (!c) c = [];
+ c = c.sort(
+ function( a, b ) {
+ if (a.shortname() < b.shortname()) return -1;
+ if (a.shortname() > b.shortname()) return 1;
+ return 0;
+ }
+ );
+ obj.list.aou[i].children( c );
+ }
+ obj.list.aou = util.fm_utils.flatten_ou_branch( obj.tree.aou );
+ obj.hash.aou = util.functional.convert_object_list_to_hash( obj.list.aou );
+ }
+ );
+
+ // The previous pgt call returned a tree, not a list or hash.
+ this.chain.push(
+ function () {
+ obj.tree.pgt = obj.list.pgt;
+ obj.list.pgt = util.fm_utils.flatten_ou_branch( obj.tree.pgt );
+ obj.hash.pgt = util.functional.convert_object_list_to_hash( obj.list.pgt );
+ }
+ );
+
+ // Do these after we get the user object
+
+ this.chain.push(
+ function() {
+ try {
+ var robj = obj.network.simple_request('FM_AOUS_RETRIEVE',[ obj.session.key, obj.list.au[0].ws_ou() ]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ obj.hash.aous = robj;
+ obj.data_progress('Retrieved org unit settings. ');
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+ this.chain.push(
+
+ function() {
+
+ gen_fm_retrieval_func('my_aou',
+ [
+ api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.app,
+ api.FM_AOU_RETRIEVE_RELATED_VIA_SESSION.method,
+ [ obj.session.key, obj.list.au[0].ws_ou() ], /* use ws_ou and not home_ou */
+ true
+ ]
+ )();
+ }
+ );
+
+ this.chain.push(
+
+ function () {
+
+ gen_fm_retrieval_func( 'my_actsc',
+ [
+ api.FM_ACTSC_RETRIEVE_VIA_AOU.app,
+ api.FM_ACTSC_RETRIEVE_VIA_AOU.method,
+ [ obj.session.key, obj.list.au[0].ws_ou() ],
+ true
+ ]
+ )();
+ }
+ );
+
+ this.chain.push(
+
+ function () {
+
+ gen_fm_retrieval_func( 'my_asc',
+ [
+ api.FM_ASC_RETRIEVE_VIA_AOU.app,
+ api.FM_ASC_RETRIEVE_VIA_AOU.method,
+ [ obj.session.key, obj.list.au[0].ws_ou() ],
+ true
+ ]
+ )();
+ }
+ );
+
+
+ this.chain.push(
+ function() {
+ var f = gen_fm_retrieval_func(
+ 'cnct',
+ [
+ api.FM_CNCT_RETRIEVE.app,
+ api.FM_CNCT_RETRIEVE.method,
+ [ obj.list.au[0].ws_ou() ],
+ false
+ ]
+ );
+ try {
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+ this.chain.push(
+ function() {
+ var f = gen_fm_retrieval_func(
+ 'my_cnct',
+ [
+ api.FM_CNCT_RETRIEVE.app,
+ api.FM_CNCT_RETRIEVE.method,
+ [ obj.list.au[0].ws_ou() ],
+ false
+ ]
+ );
+ try {
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+
+ this.chain.push(
+ function() {
+ var f = gen_fm_retrieval_func(
+ 'acpl',
+ [
+ api.FM_ACPL_RETRIEVE.app,
+ api.FM_ACPL_RETRIEVE.method,
+ [ obj.list.au[0].ws_ou() ],
+ false
+ ]
+ );
+ try {
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+ this.chain.push(
+ function() {
+ var f = gen_fm_retrieval_func(
+ 'cbt',
+ [
+ api.FM_CBT_RETRIEVE.app,
+ api.FM_CBT_RETRIEVE.method,
+ [ obj.session.key, obj.list.au[0].ws_ou() ],
+ false
+ ]
+ );
+ try {
+ f();
+ } catch(E) {
+ var error = 'Error: ' + js2JSON(E);
+ obj.error.sdump('D_ERROR',error);
+ throw(E);
+ }
+ }
+ );
+
+ if (typeof this.on_complete == 'function') {
+
+ this.chain.push( this.on_complete );
+ }
+ JSAN.use('util.exec'); this.exec = new util.exec();
+ this.exec.on_error = function(E) {
+
+ if (typeof obj.on_error == 'function') {
+ return obj.on_error(E); /* false breaks chain */
+ } else {
+ alert('oops: ' + E );
+ return false; /* break chain */
+ }
+
+ }
+
+ this.exec.chain( this.chain );
+
+ }
}
dump('exiting OpenILS/data.js\n');
- function $(id) { return document.getElementById(id); }
+ function $(id) { return document.getElementById(id); }
- function ses(a,params) {
+ function ses(a,params) {
try {
if (!params) params = {};
var data;
alert(location.href + '\nError in global_utils.js, ses(): ' + E);
throw(E);
}
- }
+ }
- function font_helper() {
- try {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- removeCSSClass(document.documentElement,'ALL_FONTS_LARGER');
- removeCSSClass(document.documentElement,'ALL_FONTS_SMALLER');
- removeCSSClass(document.documentElement,'ALL_FONTS_XX_SMALL');
- removeCSSClass(document.documentElement,'ALL_FONTS_X_SMALL');
- removeCSSClass(document.documentElement,'ALL_FONTS_SMALL');
- removeCSSClass(document.documentElement,'ALL_FONTS_MEDIUM');
- removeCSSClass(document.documentElement,'ALL_FONTS_LARGE');
- removeCSSClass(document.documentElement,'ALL_FONTS_X_LARGE');
- removeCSSClass(document.documentElement,'ALL_FONTS_XX_LARGE');
- addCSSClass(document.documentElement,data.global_font_adjust);
- } catch(E) {
+ function font_helper() {
+ try {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ removeCSSClass(document.documentElement,'ALL_FONTS_LARGER');
+ removeCSSClass(document.documentElement,'ALL_FONTS_SMALLER');
+ removeCSSClass(document.documentElement,'ALL_FONTS_XX_SMALL');
+ removeCSSClass(document.documentElement,'ALL_FONTS_X_SMALL');
+ removeCSSClass(document.documentElement,'ALL_FONTS_SMALL');
+ removeCSSClass(document.documentElement,'ALL_FONTS_MEDIUM');
+ removeCSSClass(document.documentElement,'ALL_FONTS_LARGE');
+ removeCSSClass(document.documentElement,'ALL_FONTS_X_LARGE');
+ removeCSSClass(document.documentElement,'ALL_FONTS_XX_LARGE');
+ addCSSClass(document.documentElement,data.global_font_adjust);
+ } catch(E) {
var Strings = $('offlineStrings') || $('commonStrings');
- alert(Strings.getFormattedString('openils.global_util.font_size.error', [E]));
- }
- }
+ alert(Strings.getFormattedString('openils.global_util.font_size.error', [E]));
+ }
+ }
function persist_helper() {
try {
}
}
- function getKeys(o) {
- var keys = [];
- for (var k in o) keys.push(k);
- return keys;
- }
+ function getKeys(o) {
+ var keys = [];
+ for (var k in o) keys.push(k);
+ return keys;
+ }
- function get_contentWindow(frame) {
+ function get_contentWindow(frame) {
try {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (frame && frame.contentWindow) {
try {
if (typeof frame.contentWindow.wrappedJSObject != 'undefined') {
- return frame.contentWindow.wrappedJSObject;
- }
+ return frame.contentWindow.wrappedJSObject;
+ }
} catch(E) {
var Strings = $('offlineStrings') || $('commonStrings');
alert(Strings.getFormattedString('openils.global_util.content_window_jsobject.error', [frame, E]));
var Strings = $('offlineStrings') || $('commonStrings');
alert(Strings.getFormattedString('openils.global_util.content_window.error', [frame, E]));
}
- }
+ }
- function update_modal_xulG(v) {
- try {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- var key = location.pathname + location.search + location.hash;
- if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
- data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v;
- data.stash('modal_xulG_stack');
- }
- } catch(E) {
- alert('FIXME: update_modal_xulG => ' + E);
- }
- }
+ function update_modal_xulG(v) {
+ try {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ var key = location.pathname + location.search + location.hash;
+ if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
+ data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ] = v;
+ data.stash('modal_xulG_stack');
+ }
+ } catch(E) {
+ alert('FIXME: update_modal_xulG => ' + E);
+ }
+ }
- function xul_param(param_name,_params) {
- /* By default, this function looks for a CGI-style query param identified by param_name. If one isn't found, it then looks in xulG. If one still isn't found, and _params.stash_name is true, it looks in the global xpcom stash for the field identified by stash_name. If _params.concat is true, then it looks in all these places and concatenates the results. There are also options for converting JSON to javascript objects, and clearing the xpcom stash_name field after retrieval. Also added, ability to search a specific spot in the xpcom stash that implements a stack to hold xulG's for modal windows */
- try {
- //dump('xul_param('+param_name+','+js2JSON(_params)+')\n');
- var value = undefined; if (!_params) _params = {};
- if (typeof _params.no_cgi == 'undefined') {
- var cgi = new CGI();
- if (cgi.param(param_name)) {
- var x = cgi.param(param_name);
- //dump('\tfound via location.href = ' + x + '\n');
- if (typeof _params.JSON2js_if_cgi != 'undefined') {
- x = JSON2js( x );
- //dump('\tJSON2js = ' + x + '\n');
- }
- if (typeof _params.concat == 'undefined') {
- //alert(param_name + ' x = ' + x);
- return x; // value
- } else {
- if (value) {
- if (value.constructor != Array) value = [ value ];
- value = value.concat(x);
- } else {
- value = x;
- }
- }
- }
- }
- if (typeof _params.no_xulG == 'undefined') {
- if (typeof _params.modal_xulG != 'undefined') {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- var key = location.pathname + location.search + location.hash;
- //dump('xul_param, considering modal key = ' + key + '\n');
- if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
- xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
- }
- }
- if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
- var x = xulG[ param_name ];
- //dump('\tfound via xulG = ' + x + '\n');
- if (typeof _params.JSON2js_if_xulG != 'undefined') {
- x = JSON2js( x );
- //dump('\tJSON2js = ' + x + '\n');
- }
- if (typeof _params.concat == 'undefined') {
- //alert(param_name + ' x = ' + x);
- return x; // value
- } else {
- if (value) {
- if (value.constructor != Array) value = [ value ];
- value = value.concat(x);
- } else {
- value = x;
- }
- }
- }
- }
- if (typeof _params.no_xpcom == 'undefined') {
- /* the field names used for temp variables in the global stash tend to be more unique than xuLG or CGI param names, to avoid collisions */
- if (typeof _params.stash_name != 'undefined') {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- if (typeof data[ _params.stash_name ] != 'undefined') {
- var x = data[ _params.stash_name ];
- //dump('\tfound via xpcom = ' + x + '\n');
- if (typeof _params.JSON2js_if_xpcom != 'undefined') {
- x = JSON2js( x );
- //dump('\tJSON2js = ' + x + '\n');
- }
- if (_params.clear_xpcom) {
- data[ _params.stash_name ] = undefined; data.stash( _params.stash_name );
- }
- if (typeof _params.concat == 'undefined') {
- //alert(param_name + ' x = ' + x);
- return x; // value
- } else {
- if (value) {
- if (value.constructor != Array) value = [ value ];
- value = value.concat(x);
- } else {
- value = x;
- }
- }
- }
- }
- }
- //alert(param_name + ' value = ' + value);
- return value;
- } catch(E) {
- dump('xul_param error: ' + E + '\n');
- }
- }
+ function xul_param(param_name,_params) {
+ /* By default, this function looks for a CGI-style query param identified by param_name. If one isn't found, it then looks in xulG. If one still isn't found, and _params.stash_name is true, it looks in the global xpcom stash for the field identified by stash_name. If _params.concat is true, then it looks in all these places and concatenates the results. There are also options for converting JSON to javascript objects, and clearing the xpcom stash_name field after retrieval. Also added, ability to search a specific spot in the xpcom stash that implements a stack to hold xulG's for modal windows */
+ try {
+ //dump('xul_param('+param_name+','+js2JSON(_params)+')\n');
+ var value = undefined; if (!_params) _params = {};
+ if (typeof _params.no_cgi == 'undefined') {
+ var cgi = new CGI();
+ if (cgi.param(param_name)) {
+ var x = cgi.param(param_name);
+ //dump('\tfound via location.href = ' + x + '\n');
+ if (typeof _params.JSON2js_if_cgi != 'undefined') {
+ x = JSON2js( x );
+ //dump('\tJSON2js = ' + x + '\n');
+ }
+ if (typeof _params.concat == 'undefined') {
+ //alert(param_name + ' x = ' + x);
+ return x; // value
+ } else {
+ if (value) {
+ if (value.constructor != Array) value = [ value ];
+ value = value.concat(x);
+ } else {
+ value = x;
+ }
+ }
+ }
+ }
+ if (typeof _params.no_xulG == 'undefined') {
+ if (typeof _params.modal_xulG != 'undefined') {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ var key = location.pathname + location.search + location.hash;
+ //dump('xul_param, considering modal key = ' + key + '\n');
+ if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
+ xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
+ }
+ }
+ if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
+ var x = xulG[ param_name ];
+ //dump('\tfound via xulG = ' + x + '\n');
+ if (typeof _params.JSON2js_if_xulG != 'undefined') {
+ x = JSON2js( x );
+ //dump('\tJSON2js = ' + x + '\n');
+ }
+ if (typeof _params.concat == 'undefined') {
+ //alert(param_name + ' x = ' + x);
+ return x; // value
+ } else {
+ if (value) {
+ if (value.constructor != Array) value = [ value ];
+ value = value.concat(x);
+ } else {
+ value = x;
+ }
+ }
+ }
+ }
+ if (typeof _params.no_xpcom == 'undefined') {
+ /* the field names used for temp variables in the global stash tend to be more unique than xuLG or CGI param names, to avoid collisions */
+ if (typeof _params.stash_name != 'undefined') {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ if (typeof data[ _params.stash_name ] != 'undefined') {
+ var x = data[ _params.stash_name ];
+ //dump('\tfound via xpcom = ' + x + '\n');
+ if (typeof _params.JSON2js_if_xpcom != 'undefined') {
+ x = JSON2js( x );
+ //dump('\tJSON2js = ' + x + '\n');
+ }
+ if (_params.clear_xpcom) {
+ data[ _params.stash_name ] = undefined; data.stash( _params.stash_name );
+ }
+ if (typeof _params.concat == 'undefined') {
+ //alert(param_name + ' x = ' + x);
+ return x; // value
+ } else {
+ if (value) {
+ if (value.constructor != Array) value = [ value ];
+ value = value.concat(x);
+ } else {
+ value = x;
+ }
+ }
+ }
+ }
+ }
+ //alert(param_name + ' value = ' + value);
+ return value;
+ } catch(E) {
+ dump('xul_param error: ' + E + '\n');
+ }
+ }
- function get_bool(a) {
- // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false, and '0' == false (newer JSON is returning '0' instead of 0 in cases)
- // So false includes 'f', '', '0', 0, null, and undefined
- if (a == 'f') return false;
- if (a == 'F') return false;
- if (a == '0') return false;
- if (a) return true; else return false;
- }
+ function get_bool(a) {
+ // Normal javascript interpretation except 'f' == false, per postgres, and 'F' == false, and '0' == false (newer JSON is returning '0' instead of 0 in cases)
+ // So false includes 'f', '', '0', 0, null, and undefined
+ if (a == 'f') return false;
+ if (a == 'F') return false;
+ if (a == '0') return false;
+ if (a) return true; else return false;
+ }
- function get_db_true() {
- return 't';
- }
+ function get_db_true() {
+ return 't';
+ }
- function get_db_false() {
- return 'f';
- }
+ function get_db_false() {
+ return 'f';
+ }
- function copy_to_clipboard(ev) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- var text;
- if (typeof ev == 'object') {
- if (typeof ev.target != 'undefined') {
- if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
- if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
- }
- } else if (typeof ev == 'string') {
- text = ev;
- }
- const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
- .getService(Components.interfaces.nsIClipboardHelper);
- gClipboardHelper.copyString(text);
+ function copy_to_clipboard(ev) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ var text;
+ if (typeof ev == 'object') {
+ if (typeof ev.target != 'undefined') {
+ if (typeof ev.target.textContent != 'undefined') if (ev.target.textContent) text = ev.target.textContent;
+ if (typeof ev.target.value != 'undefined') if (ev.target.value) text = ev.target.value;
+ }
+ } else if (typeof ev == 'string') {
+ text = ev;
+ }
+ const gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
+ .getService(Components.interfaces.nsIClipboardHelper);
+ gClipboardHelper.copyString(text);
var Strings = $('offlineStrings') || $('commonStrings');
- alert(Strings.getFormattedString('openils.global_util.clipboard', [text]));
- } catch(E) {
+ alert(Strings.getFormattedString('openils.global_util.clipboard', [text]));
+ } catch(E) {
var Strings = $('offlineStrings') || $('commonStrings');
- alert(Strings.getFormattedString('openils.global_util.clipboard.error', [E]));
- }
- }
+ alert(Strings.getFormattedString('openils.global_util.clipboard.error', [E]));
+ }
+ }
- function clear_the_cache() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
- var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
- cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
- cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
- } catch(E) {
+ function clear_the_cache() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
+ var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
+ cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
+ cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
+ } catch(E) {
var Strings = $('offlineStrings') || $('commonStrings');
- alert(Strings.getFormattedString('openils.global_util.clear_cache.error', [E]));
- }
- }
+ alert(Strings.getFormattedString('openils.global_util.clear_cache.error', [E]));
+ }
+ }
- function toOpenWindowByType(inType, uri) {
- var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
- window.open(uri, "_blank", winopts);
- }
+ function toOpenWindowByType(inType, uri) {
+ var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
+ window.open(uri, "_blank", winopts);
+ }
- function url_prefix(url) {
- if (url.match(/^\//)) url = urls.remote + url;
- if (! url.match(/^(http|chrome):\/\//) && ! url.match(/^data:/) ) url = 'http://' + url;
- dump('url_prefix = ' + url + '\n');
- return url;
- }
+ function url_prefix(url) {
+ if (url.match(/^\//)) url = urls.remote + url;
+ if (! url.match(/^(http|chrome):\/\//) && ! url.match(/^data:/) ) url = 'http://' + url;
+ dump('url_prefix = ' + url + '\n');
+ return url;
+ }
try {
- if (typeof JSAN == 'undefined') {
- throw(document.getElementById('offlineStrings').getString('common.jsan.missing'));
- }
- JSAN.errorLevel = "die"; // none, warn, or die
- JSAN.addRepository('..');
- JSAN.use('OpenILS.data');
- var data = new OpenILS.data(); data.init({'via':'stash'});
- var url = data.server + urls.fieldmapper;
- dump('url = ' + url + '\n');
- var js = JSAN._loadJSFromUrl( url );
- eval( js );
+ if (typeof JSAN == 'undefined') {
+ throw(document.getElementById('offlineStrings').getString('common.jsan.missing'));
+ }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+ JSAN.use('OpenILS.data');
+ var data = new OpenILS.data(); data.init({'via':'stash'});
+ var url = data.server + urls.fieldmapper;
+ dump('url = ' + url + '\n');
+ var js = JSAN._loadJSFromUrl( url );
+ eval( js );
} catch(E) {
- alert('fmall.js: ' + E);
+ alert('fmall.js: ' + E);
}
function survey_init() {
- dump('survey_init()\n');
- render_lib_menu();
- SURVEY['asv'] = new asv(); SURVEY['asv'].isnew('1');
- SURVEY['num_of_questions'] = 0;
- document.getElementById('survey_name').focus();
+ dump('survey_init()\n');
+ render_lib_menu();
+ SURVEY['asv'] = new asv(); SURVEY['asv'].isnew('1');
+ SURVEY['num_of_questions'] = 0;
+ document.getElementById('survey_name').focus();
}
function save_survey() {
- SURVEY.asv.description(
- document.getElementById('survey_description').value
- );
- SURVEY.asv.name(
- document.getElementById('survey_name').value
- );
- SURVEY.asv.owner(
- document.getElementById('lib_menulist').value
- );
- var survey_start = document.getElementById('survey_start').value;
- if (survey_start) {
- SURVEY.asv.start_date(
- survey_start
- );
- } else {
- SURVEY.asv.start_date(
- null
- );
- }
- var survey_end = document.getElementById('survey_end').value;
- if (survey_end) {
- SURVEY.asv.end_date(
- survey_end
- );
- } else {
- SURVEY.asv.end_date(
- null
- );
- }
- if ( document.getElementById('required_checkbox').checked ) {
- SURVEY.asv.required('1');
- } else {
- SURVEY.asv.required('0');
- }
- if ( document.getElementById('opac_checkbox').checked ) {
- SURVEY.asv.opac('1');
- } else {
- SURVEY.asv.opac('0');
- }
- if ( document.getElementById('poll_checkbox').checked ) {
- SURVEY.asv.poll('1');
- } else {
- SURVEY.asv.poll('0');
- }
-
- if ( document.getElementById('patron_summary_checkbox').checked ) {
- SURVEY.asv.usr_summary('1');
- } else {
- SURVEY.asv.usr_summary('0');
- }
- g.error.sdump('D_SURVEY', 'before survey = ' + js2JSON( SURVEY.asv ) + '\n');
- try {
- var result = g.network.request(
- api.FM_ASV_CREATE.app,
- api.FM_ASV_CREATE.method,
- [ ses(), SURVEY.asv ]
- );
- if (! (result instanceof asv) ) {
- throw('save_survey: result not an asv');
- } else {
- var surveys_list = g.OpenILS.data.list.asv;
- var surveys_hash = g.OpenILS.data.hash.asv;
- surveys_list.push( result );
- surveys_hash[ result.id() ] = result;
- g.OpenILS.data.stash('list','hash');
- }
- } catch(E) {
- var err = ('Survey failed: ' + js2JSON(E) + '\n');
- g.error.sdump('D_ERROR',err);
- alert(err);
- throw(err);
- }
- g.error.sdump('D_SURVEY', 'after survey = ' + js2JSON( SURVEY.asv ) + '\n');
+ SURVEY.asv.description(
+ document.getElementById('survey_description').value
+ );
+ SURVEY.asv.name(
+ document.getElementById('survey_name').value
+ );
+ SURVEY.asv.owner(
+ document.getElementById('lib_menulist').value
+ );
+ var survey_start = document.getElementById('survey_start').value;
+ if (survey_start) {
+ SURVEY.asv.start_date(
+ survey_start
+ );
+ } else {
+ SURVEY.asv.start_date(
+ null
+ );
+ }
+ var survey_end = document.getElementById('survey_end').value;
+ if (survey_end) {
+ SURVEY.asv.end_date(
+ survey_end
+ );
+ } else {
+ SURVEY.asv.end_date(
+ null
+ );
+ }
+ if ( document.getElementById('required_checkbox').checked ) {
+ SURVEY.asv.required('1');
+ } else {
+ SURVEY.asv.required('0');
+ }
+ if ( document.getElementById('opac_checkbox').checked ) {
+ SURVEY.asv.opac('1');
+ } else {
+ SURVEY.asv.opac('0');
+ }
+ if ( document.getElementById('poll_checkbox').checked ) {
+ SURVEY.asv.poll('1');
+ } else {
+ SURVEY.asv.poll('0');
+ }
+
+ if ( document.getElementById('patron_summary_checkbox').checked ) {
+ SURVEY.asv.usr_summary('1');
+ } else {
+ SURVEY.asv.usr_summary('0');
+ }
+ g.error.sdump('D_SURVEY', 'before survey = ' + js2JSON( SURVEY.asv ) + '\n');
+ try {
+ var result = g.network.request(
+ api.FM_ASV_CREATE.app,
+ api.FM_ASV_CREATE.method,
+ [ ses(), SURVEY.asv ]
+ );
+ if (! (result instanceof asv) ) {
+ throw('save_survey: result not an asv');
+ } else {
+ var surveys_list = g.OpenILS.data.list.asv;
+ var surveys_hash = g.OpenILS.data.hash.asv;
+ surveys_list.push( result );
+ surveys_hash[ result.id() ] = result;
+ g.OpenILS.data.stash('list','hash');
+ }
+ } catch(E) {
+ var err = ('Survey failed: ' + js2JSON(E) + '\n');
+ g.error.sdump('D_ERROR',err);
+ alert(err);
+ throw(err);
+ }
+ g.error.sdump('D_SURVEY', 'after survey = ' + js2JSON( SURVEY.asv ) + '\n');
}
var original_description;
function setDescription(e,t) {
- var page = document.getElementById(e);
- var desc = page.getAttribute('description');
- if (!original_description) original_description = desc;
- var value = document.getElementById(t).value;
- page.setAttribute('description',original_description + ' ' + value);
+ var page = document.getElementById(e);
+ var desc = page.getAttribute('description');
+ if (!original_description) original_description = desc;
+ var value = document.getElementById(t).value;
+ page.setAttribute('description',original_description + ' ' + value);
}
var new_id = -1;
function add_answer(e, my_asvq_id) {
- var row = e.target.parentNode;
- var rows = row.parentNode;
- var answer = e.target.previousSibling; answer.select();
-
- if (! answer.value ) { return; }
-
- /* XUL */
- var n_row = document.createElement('row');
- rows.insertBefore( n_row, row );
- var label_1 = document.createElement('label');
- n_row.appendChild( label_1 );
- var label_2 = document.createElement('label');
- label_2.setAttribute('value', answer.value );
- n_row.appendChild( label_2 );
-
- /* OBJECT */
-
- var my_asva = new asva(); my_asva.isnew('1'); my_asva.id( new_id-- );
- my_asva.answer( answer.value );
-
- JSAN.use('util.functional');
- var my_asvq = util.functional.find_id_object_in_list( SURVEY.asv.questions(), my_asvq_id );
- if (my_asvq.answers() == null) {
- my_asvq.answers( [] );
- }
-
- my_asvq.answers().push( my_asva );
-
- var num_of_answers = my_asvq.answers().length;
- var last_number = 96 + num_of_answers;
- var next_number = 97 + num_of_answers;
- var last_letter = String.fromCharCode( last_number );
- var next_letter = String.fromCharCode( next_number );
- label_1.setAttribute('value', last_letter + ')' );
- row.firstChild.setAttribute('value', next_letter + ')' );
-
- if (num_of_answers == 26) {
- rows.removeChild(row);
- }
+ var row = e.target.parentNode;
+ var rows = row.parentNode;
+ var answer = e.target.previousSibling; answer.select();
+
+ if (! answer.value ) { return; }
+
+ /* XUL */
+ var n_row = document.createElement('row');
+ rows.insertBefore( n_row, row );
+ var label_1 = document.createElement('label');
+ n_row.appendChild( label_1 );
+ var label_2 = document.createElement('label');
+ label_2.setAttribute('value', answer.value );
+ n_row.appendChild( label_2 );
+
+ /* OBJECT */
+
+ var my_asva = new asva(); my_asva.isnew('1'); my_asva.id( new_id-- );
+ my_asva.answer( answer.value );
+
+ JSAN.use('util.functional');
+ var my_asvq = util.functional.find_id_object_in_list( SURVEY.asv.questions(), my_asvq_id );
+ if (my_asvq.answers() == null) {
+ my_asvq.answers( [] );
+ }
+
+ my_asvq.answers().push( my_asva );
+
+ var num_of_answers = my_asvq.answers().length;
+ var last_number = 96 + num_of_answers;
+ var next_number = 97 + num_of_answers;
+ var last_letter = String.fromCharCode( last_number );
+ var next_letter = String.fromCharCode( next_number );
+ label_1.setAttribute('value', last_letter + ')' );
+ row.firstChild.setAttribute('value', next_letter + ')' );
+
+ if (num_of_answers == 26) {
+ rows.removeChild(row);
+ }
}
function add_question() {
- SURVEY.num_of_questions++;
- var question = document.getElementById('new_question');
+ SURVEY.num_of_questions++;
+ var question = document.getElementById('new_question');
- if (! question.value ) { return; }
+ if (! question.value ) { return; }
- document.getElementById('survey_add').canAdvance = true;
+ document.getElementById('survey_add').canAdvance = true;
- var my_asvq = new asvq(); my_asvq.isnew('1'); my_asvq.id( new_id-- );
- my_asvq.question( question.value );
+ var my_asvq = new asvq(); my_asvq.isnew('1'); my_asvq.id( new_id-- );
+ my_asvq.question( question.value );
- if ( SURVEY.asv.questions() == null ) {
- SURVEY.asv.questions( [] );
- }
+ if ( SURVEY.asv.questions() == null ) {
+ SURVEY.asv.questions( [] );
+ }
- SURVEY.asv.questions().push( my_asvq );
+ SURVEY.asv.questions().push( my_asvq );
- add_question_row(my_asvq);
+ add_question_row(my_asvq);
- document.getElementById('new_question_label').setAttribute('value', '#' + (SURVEY.num_of_questions + 1) );
- //question.select();
- if (last_answer) last_answer.focus();
+ document.getElementById('new_question_label').setAttribute('value', '#' + (SURVEY.num_of_questions + 1) );
+ //question.select();
+ if (last_answer) last_answer.focus();
}
function add_question_row(my_asvq) {
- var rows = document.getElementById('page2_grid1_rows');
- var row = document.createElement('row');
- rows.insertBefore(row, document.getElementById('page2_grid1_row1'));
-
- var label_number = document.createElement('label');
- label_number.setAttribute('value','#' + SURVEY['num_of_questions']);
- row.appendChild(label_number);
-
- var grid = document.createElement('grid');
- row.appendChild(grid);
- var g_cols = document.createElement('columns');
- grid.appendChild(g_cols);
- var g_col_1 = document.createElement('column');
- g_cols.appendChild(g_col_1);
- var g_col_2 = document.createElement('column');
- g_col_2.setAttribute('flex','1');
- g_cols.appendChild(g_col_2);
- var g_col_3 = document.createElement('column');
- g_cols.appendChild(g_col_3);
- var g_rows = document.createElement('rows');
- grid.appendChild(g_rows);
- var g_row_1 = document.createElement('row');
- g_rows.appendChild(g_row_1);
- var g_label_1 = document.createElement('label');
- g_row_1.appendChild(g_label_1);
- var g_label_2 = document.createElement('label');
- g_label_2.setAttribute('value', my_asvq.question() );
- g_row_1.appendChild(g_label_2);
- var g_row_2 = document.createElement('row');
- g_rows.appendChild(g_row_2);
- var g_label2_1 = document.createElement('label');
- g_label2_1.setAttribute('value', 'a)' );
- g_row_2.appendChild(g_label2_1);
- var g_tb = document.createElement('textbox');
- g_tb.setAttribute('flex','1');
- g_row_2.appendChild(g_tb);
- if (last_button) last_button.setAttribute('accesskey','');
- var g_b = document.createElement('button');
- var strbundle = document.getElementById("offlineStrings");
- g_b.setAttribute('label', strbundle.getString('staff.admin.survey.save_response.label'));
- g_b.setAttribute('accesskey', strbundle.getString('staff.admin.survey.save_response.label'));
- g_b.setAttribute('oncommand','add_answer(event,' + my_asvq.id() + ');');
- g_row_2.appendChild(g_b);
-
- var blank = document.createElement('row');
- rows.insertBefore( blank , document.getElementById('page2_grid1_row1') );
- var blank2 = document.createElement('label');
- blank2.setAttribute('value', ' ');
- blank.appendChild( blank2 );
-
- last_answer = g_tb;
- last_button = g_b;
+ var rows = document.getElementById('page2_grid1_rows');
+ var row = document.createElement('row');
+ rows.insertBefore(row, document.getElementById('page2_grid1_row1'));
+
+ var label_number = document.createElement('label');
+ label_number.setAttribute('value','#' + SURVEY['num_of_questions']);
+ row.appendChild(label_number);
+
+ var grid = document.createElement('grid');
+ row.appendChild(grid);
+ var g_cols = document.createElement('columns');
+ grid.appendChild(g_cols);
+ var g_col_1 = document.createElement('column');
+ g_cols.appendChild(g_col_1);
+ var g_col_2 = document.createElement('column');
+ g_col_2.setAttribute('flex','1');
+ g_cols.appendChild(g_col_2);
+ var g_col_3 = document.createElement('column');
+ g_cols.appendChild(g_col_3);
+ var g_rows = document.createElement('rows');
+ grid.appendChild(g_rows);
+ var g_row_1 = document.createElement('row');
+ g_rows.appendChild(g_row_1);
+ var g_label_1 = document.createElement('label');
+ g_row_1.appendChild(g_label_1);
+ var g_label_2 = document.createElement('label');
+ g_label_2.setAttribute('value', my_asvq.question() );
+ g_row_1.appendChild(g_label_2);
+ var g_row_2 = document.createElement('row');
+ g_rows.appendChild(g_row_2);
+ var g_label2_1 = document.createElement('label');
+ g_label2_1.setAttribute('value', 'a)' );
+ g_row_2.appendChild(g_label2_1);
+ var g_tb = document.createElement('textbox');
+ g_tb.setAttribute('flex','1');
+ g_row_2.appendChild(g_tb);
+ if (last_button) last_button.setAttribute('accesskey','');
+ var g_b = document.createElement('button');
+ var strbundle = document.getElementById("offlineStrings");
+ g_b.setAttribute('label', strbundle.getString('staff.admin.survey.save_response.label'));
+ g_b.setAttribute('accesskey', strbundle.getString('staff.admin.survey.save_response.label'));
+ g_b.setAttribute('oncommand','add_answer(event,' + my_asvq.id() + ');');
+ g_row_2.appendChild(g_b);
+
+ var blank = document.createElement('row');
+ rows.insertBefore( blank , document.getElementById('page2_grid1_row1') );
+ var blank2 = document.createElement('label');
+ blank2.setAttribute('value', ' ');
+ blank.appendChild( blank2 );
+
+ last_answer = g_tb;
+ last_button = g_b;
}
function page1_check_advance() {
- if ( document.getElementById('survey_name').value ) {
- document.getElementById('survey_add').canAdvance = true;
- } else {
- document.getElementById('survey_add').canAdvance = false;
- }
+ if ( document.getElementById('survey_name').value ) {
+ document.getElementById('survey_add').canAdvance = true;
+ } else {
+ document.getElementById('survey_add').canAdvance = false;
+ }
}
if (typeof auth == 'undefined') auth = {};
auth.controller = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- this.w = params.window;
+ JSAN.use('util.error'); this.error = new util.error();
+ this.w = params.window;
- return this;
+ return this;
};
auth.controller.prototype = {
- 'init' : function () {
-
- var obj = this; // so the 'this' in event handlers don't confuse us
- var w = obj.w;
-
- JSAN.use('OpenILS.data');
- obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
-
- // MVC
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'cmd_login' : [
- ['command'],
- function() {
- obj.login();
- }
- ],
- 'cmd_standalone' : [
- ['command'],
- function() {
- obj.standalone();
- }
- ],
- 'cmd_standalone_import' : [
- ['command'],
- function() {
- obj.standalone_import();
- }
- ],
- 'cmd_standalone_export' : [
- ['command'],
- function() {
- obj.standalone_export();
- }
- ],
- 'cmd_clear_cache' : [
- ['command'],
- function() {
- obj.debug('clear_cache');
- }
- ],
- 'cmd_js_console' : [
- ['command'],
- function() {
- obj.debug('js_console');
- }
- ],
+ 'init' : function () {
+
+ var obj = this; // so the 'this' in event handlers don't confuse us
+ var w = obj.w;
+
+ JSAN.use('OpenILS.data');
+ obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+
+ // MVC
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'cmd_login' : [
+ ['command'],
+ function() {
+ obj.login();
+ }
+ ],
+ 'cmd_standalone' : [
+ ['command'],
+ function() {
+ obj.standalone();
+ }
+ ],
+ 'cmd_standalone_import' : [
+ ['command'],
+ function() {
+ obj.standalone_import();
+ }
+ ],
+ 'cmd_standalone_export' : [
+ ['command'],
+ function() {
+ obj.standalone_export();
+ }
+ ],
+ 'cmd_clear_cache' : [
+ ['command'],
+ function() {
+ obj.debug('clear_cache');
+ }
+ ],
+ 'cmd_js_console' : [
+ ['command'],
+ function() {
+ obj.debug('js_console');
+ }
+ ],
'cmd_debugger' : [
['command'],
function() {
start_js_shell();
}
],
- 'cmd_override' : [
- ['command'],
- function() {
- obj.override();
- }
- ],
- 'cmd_logoff' : [
- ['command'],
- function() {
- obj.logoff()
- }
- ],
- 'cmd_close_window' : [
- ['command'],
- function() {
- obj.close()
- }
- ],
- 'cmd_test_server' : [
- ['command'],
- function() {
- obj.test_server( obj.controller.view.server_prompt.value );
- }
- ],
+ 'cmd_override' : [
+ ['command'],
+ function() {
+ obj.override();
+ }
+ ],
+ 'cmd_logoff' : [
+ ['command'],
+ function() {
+ obj.logoff()
+ }
+ ],
+ 'cmd_close_window' : [
+ ['command'],
+ function() {
+ obj.close()
+ }
+ ],
+ 'cmd_test_server' : [
+ ['command'],
+ function() {
+ obj.test_server( obj.controller.view.server_prompt.value );
+ }
+ ],
'ssl_exception' : [
['render'],
function(e) {
'prefetchCert' : true
}
);
- obj.test_server( obj.controller.view.server_prompt.value );
+ obj.test_server( obj.controller.view.server_prompt.value );
}
],
- 'server_prompt' : [
- ['keypress'],
- handle_keypress
- ],
+ 'server_prompt' : [
+ ['keypress'],
+ handle_keypress
+ ],
'server_menu' : [
['render'],
function(e) {
};
}
],
- 'name_prompt' : [
- ['keypress'],
- handle_keypress
- ],
- 'password_prompt' : [
- ['keypress'],
- handle_keypress
- ],
- 'submit_button' : [
- ['render'],
- function(e) { return function() {} }
- ],
- 'apply_locale_btn' : [
- ['render'],
- function(e) { return function() {} }
- ],
- 'progress_bar' : [
- ['render'],
- function(e) { return function() {} }
- ],
- 'status' : [
- ['render'],
- function(e) { return function() {
- } }
- ],
- 'ws_deck' : [
- ['render'],
- function(e) { return function() {
- try {
- JSAN.use('util.widgets'); util.widgets.remove_children(e);
- var x = document.createElement('description');
- e.appendChild(x);
- if (obj.data.ws_info
- && obj.data.ws_info[ obj.controller.view.server_prompt.value ]) {
- var ws = obj.data.ws_info[ obj.controller.view.server_prompt.value ];
- x.appendChild(
- document.createTextNode(
- ws.name /*+ ' @ ' + ws.lib_shortname*/
- )
- );
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('last_ws_server');
- file.set_object(obj.controller.view.server_prompt.value);
- file.close();
- } else {
- x.appendChild(
- document.createTextNode(
- document.getElementById('authStrings').getString('staff.auth.controller.not_configured')
- )
- );
- }
- } catch(E) {
- alert(E);
- }
- } }
- ],
- 'menu_spot' : [
- ['render'],
- function(e) { return function() {
- } }
- ],
-
- }
- }
- );
- obj.controller.view.name_prompt.focus();
-
- function handle_keypress(ev) {
- try {
- if (ev.keyCode && ev.keyCode == 13) {
- switch(this) {
- case obj.controller.view.server_prompt:
- ev.preventDefault();
- obj.controller.view.name_prompt.focus(); obj.controller.view.name_prompt.select();
- break;
- case obj.controller.view.name_prompt:
- ev.preventDefault();
- obj.controller.view.password_prompt.focus(); obj.controller.view.password_prompt.select();
- break;
- case obj.controller.view.password_prompt:
- ev.preventDefault();
- obj.controller.view.submit_button.focus();
- obj.login();
- break;
- default: break;
- }
- }
- } catch(E) {
- alert(E);
- }
- }
-
- obj.controller.view.server_prompt.addEventListener(
- 'change',
- function (ev) {
- obj.test_server(ev.target.value);
- obj.controller.render('ws_deck');
- },
- false
- );
+ 'name_prompt' : [
+ ['keypress'],
+ handle_keypress
+ ],
+ 'password_prompt' : [
+ ['keypress'],
+ handle_keypress
+ ],
+ 'submit_button' : [
+ ['render'],
+ function(e) { return function() {} }
+ ],
+ 'apply_locale_btn' : [
+ ['render'],
+ function(e) { return function() {} }
+ ],
+ 'progress_bar' : [
+ ['render'],
+ function(e) { return function() {} }
+ ],
+ 'status' : [
+ ['render'],
+ function(e) { return function() {
+ } }
+ ],
+ 'ws_deck' : [
+ ['render'],
+ function(e) { return function() {
+ try {
+ JSAN.use('util.widgets'); util.widgets.remove_children(e);
+ var x = document.createElement('description');
+ e.appendChild(x);
+ if (obj.data.ws_info
+ && obj.data.ws_info[ obj.controller.view.server_prompt.value ]) {
+ var ws = obj.data.ws_info[ obj.controller.view.server_prompt.value ];
+ x.appendChild(
+ document.createTextNode(
+ ws.name /*+ ' @ ' + ws.lib_shortname*/
+ )
+ );
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('last_ws_server');
+ file.set_object(obj.controller.view.server_prompt.value);
+ file.close();
+ } else {
+ x.appendChild(
+ document.createTextNode(
+ document.getElementById('authStrings').getString('staff.auth.controller.not_configured')
+ )
+ );
+ }
+ } catch(E) {
+ alert(E);
+ }
+ } }
+ ],
+ 'menu_spot' : [
+ ['render'],
+ function(e) { return function() {
+ } }
+ ],
+
+ }
+ }
+ );
+ obj.controller.view.name_prompt.focus();
+
+ function handle_keypress(ev) {
+ try {
+ if (ev.keyCode && ev.keyCode == 13) {
+ switch(this) {
+ case obj.controller.view.server_prompt:
+ ev.preventDefault();
+ obj.controller.view.name_prompt.focus(); obj.controller.view.name_prompt.select();
+ break;
+ case obj.controller.view.name_prompt:
+ ev.preventDefault();
+ obj.controller.view.password_prompt.focus(); obj.controller.view.password_prompt.select();
+ break;
+ case obj.controller.view.password_prompt:
+ ev.preventDefault();
+ obj.controller.view.submit_button.focus();
+ obj.login();
+ break;
+ default: break;
+ }
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }
+
+ obj.controller.view.server_prompt.addEventListener(
+ 'change',
+ function (ev) {
+ obj.test_server(ev.target.value);
+ obj.controller.render('ws_deck');
+ },
+ false
+ );
obj.controller.view.server_prompt.addEventListener(
'command',
function (ev) {
obj.controller.view.name_prompt.focus();
obj.controller.view.name_prompt.select();
- obj.test_server(ev.target.value);
- obj.controller.render('ws_deck');
+ obj.test_server(ev.target.value);
+ obj.controller.render('ws_deck');
},
false
);
- // This talks to our ILS
- JSAN.use('auth.session');
- obj.session = new auth.session(obj.controller.view);
-
- obj.controller.render();
- obj.test_server( obj.controller.view.server_prompt.value );
- obj.controller.render('ws_deck');
-
- if (typeof this.on_init == 'function') {
- this.error.sdump('D_AUTH','auth.controller.on_init()\n');
- this.on_init();
- }
- },
-
- 'test_server' : function(url) {
- var obj = this;
- if (!url) {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('last_ws_server');
- if (file._file.exists()) {
- url = file.get_object(); file.close();
- obj.controller.view.server_prompt.value = url;
- }
- }
- obj.controller.view.submit_button.disabled = true;
- obj.controller.view.server_prompt.disabled = true;
- var s = document.getElementById('status');
- s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.testing_hostname'));
- s.setAttribute('style','color: orange;');
- document.getElementById('version').value = '';
- if (!url) {
- s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.prompt_hostname'));
- s.setAttribute('style','color: red;');
- obj.controller.view.server_prompt.disabled = false;
- obj.controller.view.server_prompt.focus();
- return;
- }
- try {
- if ( ! url.match(/^https:\/\//) ) url = 'https://' + url;
- var x = new XMLHttpRequest();
- dump('server url = ' + url + '\n');
- x.open("GET",url,true);
- x.onreadystatechange = function() {
- try {
- if (x.readyState != 4) return;
- s.setAttribute('value', document.getElementById('authStrings').getFormattedString('staff.auth.controller.status', [x.status, x.statusText]));
- if (x.status == 200) {
- s.setAttribute('style','color: green;');
- } else {
- s.setAttribute('style','color: red;');
- }
- obj.test_version(url);
- } catch(E) {
- obj.controller.view.server_prompt.disabled = false;
- obj.controller.view.server_prompt.focus();
- s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.error_hostname'));
- s.setAttribute('style','color: red;');
- obj.error.sdump('D_ERROR',E);
- }
- }
- x.send(null);
- } catch(E) {
- s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.error_hostname'));
- s.setAttribute('style','color: brown;');
- obj.error.sdump('D_ERROR',E);
- obj.controller.view.server_prompt.disabled = false;
- obj.controller.view.server_prompt.focus();
- }
- },
-
- 'test_version' : function(url) {
- var obj = this;
- var s = document.getElementById('version');
- s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.testing_version'));
- s.setAttribute('style','color: orange;');
- try {
- var x = new XMLHttpRequest();
- var url2 = url + '/xul/server/';
- dump('version url = ' + url2 + '\n');
- x.open("GET",url2,true);
- x.onreadystatechange = function() {
- try {
- if (x.readyState != 4) return;
- s.setAttribute('value', document.getElementById('authStrings').getFormattedString('staff.auth.controller.status', [x.status, x.statusText]));
- if (x.status == 200) {
- s.setAttribute('style','color: green;');
- obj.controller.view.submit_button.disabled = false;
- } else {
- s.setAttribute('style','color: red;');
- obj.test_upgrade_instructions(url);
- }
- obj.controller.view.server_prompt.disabled = false;
- } catch(E) {
- s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.error_version'));
- s.setAttribute('style','color: red;');
- obj.error.sdump('D_ERROR',E);
- obj.controller.view.server_prompt.disabled = false;
- }
- }
- x.send(null);
- } catch(E) {
- s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.error_version'));
- s.setAttribute('style','color: brown;');
- obj.error.sdump('D_ERROR',E);
- obj.controller.view.server_prompt.disabled = false;
- }
- },
-
- 'test_upgrade_instructions' : function(url) {
- var obj = this;
- try {
- var x = new XMLHttpRequest();
- var url2 = url + '/xul/versions.html';
- dump('upgrade url = ' + url2 + '\n');
- x.open("GET",url2,true);
- x.onreadystatechange = function() {
- try {
- if (x.readyState != 4) return;
- if (x.status == 200) {
- window.open('data:text/html,'+window.escape(x.responseText),'upgrade','chrome,resizable,modal,centered');
- } else {
- alert(document.getElementById('authStrings').getString('staff.auth.controller.version_mismatch'));
- }
- obj.controller.view.server_prompt.disabled = false;
- } catch(E) {
- obj.error.sdump('D_ERROR',E);
- obj.controller.view.server_prompt.disabled = false;
- }
- }
- x.send(null);
- } catch(E) {
- obj.error.sdump('D_ERROR',E);
- obj.controller.view.server_prompt.disabled = false;
- }
- },
-
- 'login' : function() {
-
- var obj = this;
-
- this.error.sdump('D_AUTH',
- document.getElementById('authStrings').getFormattedString(
- 'staff.auth.controller.error_login', [
- this.controller.view.name_prompt.value,
- this.controller.view.password_prompt.value,
- this.controller.view.server_prompt.value
- ]
- )
- );
- this.controller.view.server_prompt.disabled = true;
- this.controller.view.name_prompt.disabled = true;
- this.controller.view.password_prompt.disabled = true;
- this.controller.view.submit_button.disabled = true;
- this.controller.view.apply_locale_btn.disabled = true;
- XML_HTTP_SERVER = this.controller.view.server_prompt.value;
-
- try {
-
- if (typeof this.on_login == 'function') {
- this.error.sdump('D_AUTH','auth.controller.session.on_init = ' +
- 'auth.controller.on_login\n');
- this.session.on_init = this.on_login;
- this.session.on_error = function() { obj.logoff(); };
- }
-
- this.session.init();
-
- } catch(E) {
- var error = '!! ' + E + '\n';
- this.error.sdump('D_ERROR',error);
- alert(error);
- this.logoff();
- if (E == 'open-ils.auth.authenticate.init returned false\n') {
- this.controller.view.server_prompt.focus();
- this.controller.view.server_prompt.select();
- }
-
- if (typeof this.on_login_error == 'function') {
- this.error.sdump('D_AUTH','auth.controller.on_login_error()\n');
- this.on_login_error(E);
- }
- }
-
- },
-
- 'standalone' : function() {
- var obj = this;
- try {
- if (typeof this.on_standalone == 'function') {
- obj.on_standalone();
- }
- } catch(E) {
- var error = '!! ' + E + '\n';
- obj.error.sdump('D_ERROR',error);
- alert(error);
- }
- },
-
- 'standalone_import' : function() {
- var obj = this;
- try {
- if (typeof this.on_standalone_import == 'function') {
- obj.on_standalone_import();
- }
- } catch(E) {
- var error = '!! ' + E + '\n';
- obj.error.sdump('D_ERROR',error);
- alert(error);
- }
- },
-
- 'standalone_export' : function() {
- var obj = this;
- try {
- if (typeof this.on_standalone_export == 'function') {
- obj.on_standalone_export();
- }
- } catch(E) {
- var error = '!! ' + E + '\n';
- obj.error.sdump('D_ERROR',error);
- alert(error);
- }
- },
-
- 'debug' : function(action) {
- var obj = this;
- try {
- if (typeof this.on_debug == 'function') {
- obj.on_debug(action);
- }
- } catch(E) {
- var error = '!! ' + E + '\n';
- obj.error.sdump('D_ERROR',error);
- alert(error);
- }
- },
-
- 'logoff' : function() {
-
- this.error.sdump('D_AUTH','logoff' + this.w + '\n');
- this.controller.view.progress_bar.value = 0;
- this.controller.view.progress_bar.setAttribute('real','0.0');
- this.controller.view.submit_button.disabled = false;
- this.controller.view.apply_locale_btn.disabled = false;
- this.controller.view.password_prompt.disabled = false;
- this.controller.view.password_prompt.value = '';
- this.controller.view.name_prompt.disabled = false;
- this.controller.view.name_prompt.focus();
- this.controller.view.name_prompt.select();
- this.controller.view.server_prompt.disabled = false;
-
- var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
- var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
- var enumerator = windowManagerInterface.getEnumerator(null);
-
- var w; // close all other windows
- while ( w = enumerator.getNext() ) {
- if (w != window) w.close();
- }
-
- this.controller.render('ws_deck');
-
- this.session.close();
-
- /* FIXME - need some locking or object destruction for the async tests */
- /* this.test_server( this.controller.view.server_prompt.value ); */
-
- if (typeof this.on_logoff == 'function') {
- this.error.sdump('D_AUTH','auth.controller.on_logoff()\n');
- this.on_logoff();
- }
-
- },
- 'close' : function() {
-
- this.error.sdump('D_AUTH','close' + this.w + '\n');
-
- if (window.confirm(document.getElementById('authStrings').getString('staff.auth.controller.confirm_close'))) {
- this.logoff();
- this.w.close(); /* Probably won't go any further */
-
- if (typeof this.on_close == 'function') {
- this.error.sdump('D_AUTH','auth.controller.on_close()\n');
- this.on_close();
- }
- }
-
- }
+ // This talks to our ILS
+ JSAN.use('auth.session');
+ obj.session = new auth.session(obj.controller.view);
+
+ obj.controller.render();
+ obj.test_server( obj.controller.view.server_prompt.value );
+ obj.controller.render('ws_deck');
+
+ if (typeof this.on_init == 'function') {
+ this.error.sdump('D_AUTH','auth.controller.on_init()\n');
+ this.on_init();
+ }
+ },
+
+ 'test_server' : function(url) {
+ var obj = this;
+ if (!url) {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('last_ws_server');
+ if (file._file.exists()) {
+ url = file.get_object(); file.close();
+ obj.controller.view.server_prompt.value = url;
+ }
+ }
+ obj.controller.view.submit_button.disabled = true;
+ obj.controller.view.server_prompt.disabled = true;
+ var s = document.getElementById('status');
+ s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.testing_hostname'));
+ s.setAttribute('style','color: orange;');
+ document.getElementById('version').value = '';
+ if (!url) {
+ s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.prompt_hostname'));
+ s.setAttribute('style','color: red;');
+ obj.controller.view.server_prompt.disabled = false;
+ obj.controller.view.server_prompt.focus();
+ return;
+ }
+ try {
+ if ( ! url.match(/^https:\/\//) ) url = 'https://' + url;
+ var x = new XMLHttpRequest();
+ dump('server url = ' + url + '\n');
+ x.open("GET",url,true);
+ x.onreadystatechange = function() {
+ try {
+ if (x.readyState != 4) return;
+ s.setAttribute('value', document.getElementById('authStrings').getFormattedString('staff.auth.controller.status', [x.status, x.statusText]));
+ if (x.status == 200) {
+ s.setAttribute('style','color: green;');
+ } else {
+ s.setAttribute('style','color: red;');
+ }
+ obj.test_version(url);
+ } catch(E) {
+ obj.controller.view.server_prompt.disabled = false;
+ obj.controller.view.server_prompt.focus();
+ s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.error_hostname'));
+ s.setAttribute('style','color: red;');
+ obj.error.sdump('D_ERROR',E);
+ }
+ }
+ x.send(null);
+ } catch(E) {
+ s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.error_hostname'));
+ s.setAttribute('style','color: brown;');
+ obj.error.sdump('D_ERROR',E);
+ obj.controller.view.server_prompt.disabled = false;
+ obj.controller.view.server_prompt.focus();
+ }
+ },
+
+ 'test_version' : function(url) {
+ var obj = this;
+ var s = document.getElementById('version');
+ s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.testing_version'));
+ s.setAttribute('style','color: orange;');
+ try {
+ var x = new XMLHttpRequest();
+ var url2 = url + '/xul/server/';
+ dump('version url = ' + url2 + '\n');
+ x.open("GET",url2,true);
+ x.onreadystatechange = function() {
+ try {
+ if (x.readyState != 4) return;
+ s.setAttribute('value', document.getElementById('authStrings').getFormattedString('staff.auth.controller.status', [x.status, x.statusText]));
+ if (x.status == 200) {
+ s.setAttribute('style','color: green;');
+ obj.controller.view.submit_button.disabled = false;
+ } else {
+ s.setAttribute('style','color: red;');
+ obj.test_upgrade_instructions(url);
+ }
+ obj.controller.view.server_prompt.disabled = false;
+ } catch(E) {
+ s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.error_version'));
+ s.setAttribute('style','color: red;');
+ obj.error.sdump('D_ERROR',E);
+ obj.controller.view.server_prompt.disabled = false;
+ }
+ }
+ x.send(null);
+ } catch(E) {
+ s.setAttribute('value', document.getElementById('authStrings').getString('staff.auth.controller.error_version'));
+ s.setAttribute('style','color: brown;');
+ obj.error.sdump('D_ERROR',E);
+ obj.controller.view.server_prompt.disabled = false;
+ }
+ },
+
+ 'test_upgrade_instructions' : function(url) {
+ var obj = this;
+ try {
+ var x = new XMLHttpRequest();
+ var url2 = url + '/xul/versions.html';
+ dump('upgrade url = ' + url2 + '\n');
+ x.open("GET",url2,true);
+ x.onreadystatechange = function() {
+ try {
+ if (x.readyState != 4) return;
+ if (x.status == 200) {
+ window.open('data:text/html,'+window.escape(x.responseText),'upgrade','chrome,resizable,modal,centered');
+ } else {
+ alert(document.getElementById('authStrings').getString('staff.auth.controller.version_mismatch'));
+ }
+ obj.controller.view.server_prompt.disabled = false;
+ } catch(E) {
+ obj.error.sdump('D_ERROR',E);
+ obj.controller.view.server_prompt.disabled = false;
+ }
+ }
+ x.send(null);
+ } catch(E) {
+ obj.error.sdump('D_ERROR',E);
+ obj.controller.view.server_prompt.disabled = false;
+ }
+ },
+
+ 'login' : function() {
+
+ var obj = this;
+
+ this.error.sdump('D_AUTH',
+ document.getElementById('authStrings').getFormattedString(
+ 'staff.auth.controller.error_login', [
+ this.controller.view.name_prompt.value,
+ this.controller.view.password_prompt.value,
+ this.controller.view.server_prompt.value
+ ]
+ )
+ );
+ this.controller.view.server_prompt.disabled = true;
+ this.controller.view.name_prompt.disabled = true;
+ this.controller.view.password_prompt.disabled = true;
+ this.controller.view.submit_button.disabled = true;
+ this.controller.view.apply_locale_btn.disabled = true;
+ XML_HTTP_SERVER = this.controller.view.server_prompt.value;
+
+ try {
+
+ if (typeof this.on_login == 'function') {
+ this.error.sdump('D_AUTH','auth.controller.session.on_init = ' +
+ 'auth.controller.on_login\n');
+ this.session.on_init = this.on_login;
+ this.session.on_error = function() { obj.logoff(); };
+ }
+
+ this.session.init();
+
+ } catch(E) {
+ var error = '!! ' + E + '\n';
+ this.error.sdump('D_ERROR',error);
+ alert(error);
+ this.logoff();
+ if (E == 'open-ils.auth.authenticate.init returned false\n') {
+ this.controller.view.server_prompt.focus();
+ this.controller.view.server_prompt.select();
+ }
+
+ if (typeof this.on_login_error == 'function') {
+ this.error.sdump('D_AUTH','auth.controller.on_login_error()\n');
+ this.on_login_error(E);
+ }
+ }
+
+ },
+
+ 'standalone' : function() {
+ var obj = this;
+ try {
+ if (typeof this.on_standalone == 'function') {
+ obj.on_standalone();
+ }
+ } catch(E) {
+ var error = '!! ' + E + '\n';
+ obj.error.sdump('D_ERROR',error);
+ alert(error);
+ }
+ },
+
+ 'standalone_import' : function() {
+ var obj = this;
+ try {
+ if (typeof this.on_standalone_import == 'function') {
+ obj.on_standalone_import();
+ }
+ } catch(E) {
+ var error = '!! ' + E + '\n';
+ obj.error.sdump('D_ERROR',error);
+ alert(error);
+ }
+ },
+
+ 'standalone_export' : function() {
+ var obj = this;
+ try {
+ if (typeof this.on_standalone_export == 'function') {
+ obj.on_standalone_export();
+ }
+ } catch(E) {
+ var error = '!! ' + E + '\n';
+ obj.error.sdump('D_ERROR',error);
+ alert(error);
+ }
+ },
+
+ 'debug' : function(action) {
+ var obj = this;
+ try {
+ if (typeof this.on_debug == 'function') {
+ obj.on_debug(action);
+ }
+ } catch(E) {
+ var error = '!! ' + E + '\n';
+ obj.error.sdump('D_ERROR',error);
+ alert(error);
+ }
+ },
+
+ 'logoff' : function() {
+
+ this.error.sdump('D_AUTH','logoff' + this.w + '\n');
+ this.controller.view.progress_bar.value = 0;
+ this.controller.view.progress_bar.setAttribute('real','0.0');
+ this.controller.view.submit_button.disabled = false;
+ this.controller.view.apply_locale_btn.disabled = false;
+ this.controller.view.password_prompt.disabled = false;
+ this.controller.view.password_prompt.value = '';
+ this.controller.view.name_prompt.disabled = false;
+ this.controller.view.name_prompt.focus();
+ this.controller.view.name_prompt.select();
+ this.controller.view.server_prompt.disabled = false;
+
+ var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
+ var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
+ var enumerator = windowManagerInterface.getEnumerator(null);
+
+ var w; // close all other windows
+ while ( w = enumerator.getNext() ) {
+ if (w != window) w.close();
+ }
+
+ this.controller.render('ws_deck');
+
+ this.session.close();
+
+ /* FIXME - need some locking or object destruction for the async tests */
+ /* this.test_server( this.controller.view.server_prompt.value ); */
+
+ if (typeof this.on_logoff == 'function') {
+ this.error.sdump('D_AUTH','auth.controller.on_logoff()\n');
+ this.on_logoff();
+ }
+
+ },
+ 'close' : function() {
+
+ this.error.sdump('D_AUTH','close' + this.w + '\n');
+
+ if (window.confirm(document.getElementById('authStrings').getString('staff.auth.controller.confirm_close'))) {
+ this.logoff();
+ this.w.close(); /* Probably won't go any further */
+
+ if (typeof this.on_close == 'function') {
+ this.error.sdump('D_AUTH','auth.controller.on_close()\n');
+ this.on_close();
+ }
+ }
+
+ }
}
dump('exiting auth/controller.js\n');
if (typeof auth == 'undefined') auth = {};
auth.session = function (view,login_type) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- this.view = view;
- this.login_type = login_type || 'staff';
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ this.view = view;
+ this.login_type = login_type || 'staff';
- return this;
+ return this;
};
auth.session.prototype = {
- 'init' : function () {
-
- var obj = this;
-
- try {
- var init = this.network.request(
- api.AUTH_INIT.app,
- api.AUTH_INIT.method,
- [ this.view.name_prompt.value ]
- );
-
- if (init) {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
-
- var params = {
- 'username' : this.view.name_prompt.value,
- 'password' : hex_md5(
- init +
- hex_md5(
- this.view.password_prompt.value
- )
- ),
- 'type' : 'temp',
- };
-
- if (data.ws_info[ this.view.server_prompt.value ]) {
- params.type = this.login_type;
- params.workstation = data.ws_info[ this.view.server_prompt.value ].name;
- data.ws_name = params.workstation; data.stash('ws_name');
- }
-
- var robj = this.network.simple_request( 'AUTH_COMPLETE', [ params ]);
-
- switch (Number(robj.ilsevent)) {
- case 0:
- this.key = robj.payload.authtoken;
- this.authtime = robj.payload.authtime;
- break;
- case 1520 /* WORKSTATION_NOT_FOUND */:
- alert(document.getElementById('authStrings').getFormattedString('staff.auth.session.unregistered', [params.workstation]));
- delete(params.workstation);
- delete(data.ws_info[ this.view.server_prompt.value ]);
- data.stash('ws_info');
- data.ws_name = null; data.stash('ws_name');
- params.type = 'temp';
- robj = this.network.simple_request('AUTH_COMPLETE',[ params ]);
- if (robj.ilsevent == 0) {
- this.key = robj.payload.authtoken;
- this.authtime = robj.payload.authtime;
- } else {
- //this.error.standard_unexpected_error_alert('auth.session.init',robj);
- throw(robj);
- }
- break;
- default:
- //obj.error.standard_unexpected_error_alert('auth.session.init',robj);
- throw(robj);
- break;
- }
-
- this.error.sdump('D_AUTH','auth.session.key = ' + this.key + '\n');
-
- if (typeof this.on_init == 'function') {
- this.error.sdump('D_AUTH','auth.session.on_init()\n');
- this.on_init();
- }
-
- } else {
-
- var error = document.getElementById('authStrings').getString('staff.auth.session.init_false') + '\n';
- this.error.sdump('D_ERROR',error);
- throw(error);
- }
-
- } catch(E) {
- alert(document.getElementById('authStrings').getString('staff.auth.session.login_failed'));
- //obj.error.standard_unexpected_error_alert('Error on auth.session.init()',E);
-
- if (typeof this.on_init_error == 'function') {
- this.error.sdump('D_AUTH','auth.session.on_init_error()\n');
- this.on_init_error(E);
- }
- if (typeof this.on_error == 'function') {
- this.error.sdump('D_AUTH','auth.session.on_error()\n');
- this.on_error();
- }
-
- //throw(E);
- /* This was for testing
- if (typeof this.on_init == 'function') {
- this.error.sdump('D_AUTH','auth.session.on_init() despite error\n');
- this.on_init();
- }
- */
- }
- },
-
- 'close' : function () {
- var obj = this;
- obj.error.sdump('D_AUTH','auth.session.close()\n');
- if (obj.key) obj.network.request(
- api.AUTH_DELETE.app,
- api.AUTH_DELETE.method,
- [ obj.key ],
- function(req) {}
- );
- obj.key = null;
- if (typeof obj.on_close == 'function') {
- obj.error.sdump('D_AUTH','auth.session.on_close()\n');
- obj.on_close();
- }
- }
+ 'init' : function () {
+
+ var obj = this;
+
+ try {
+ var init = this.network.request(
+ api.AUTH_INIT.app,
+ api.AUTH_INIT.method,
+ [ this.view.name_prompt.value ]
+ );
+
+ if (init) {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+
+ var params = {
+ 'username' : this.view.name_prompt.value,
+ 'password' : hex_md5(
+ init +
+ hex_md5(
+ this.view.password_prompt.value
+ )
+ ),
+ 'type' : 'temp',
+ };
+
+ if (data.ws_info[ this.view.server_prompt.value ]) {
+ params.type = this.login_type;
+ params.workstation = data.ws_info[ this.view.server_prompt.value ].name;
+ data.ws_name = params.workstation; data.stash('ws_name');
+ }
+
+ var robj = this.network.simple_request( 'AUTH_COMPLETE', [ params ]);
+
+ switch (Number(robj.ilsevent)) {
+ case 0:
+ this.key = robj.payload.authtoken;
+ this.authtime = robj.payload.authtime;
+ break;
+ case 1520 /* WORKSTATION_NOT_FOUND */:
+ alert(document.getElementById('authStrings').getFormattedString('staff.auth.session.unregistered', [params.workstation]));
+ delete(params.workstation);
+ delete(data.ws_info[ this.view.server_prompt.value ]);
+ data.stash('ws_info');
+ data.ws_name = null; data.stash('ws_name');
+ params.type = 'temp';
+ robj = this.network.simple_request('AUTH_COMPLETE',[ params ]);
+ if (robj.ilsevent == 0) {
+ this.key = robj.payload.authtoken;
+ this.authtime = robj.payload.authtime;
+ } else {
+ //this.error.standard_unexpected_error_alert('auth.session.init',robj);
+ throw(robj);
+ }
+ break;
+ default:
+ //obj.error.standard_unexpected_error_alert('auth.session.init',robj);
+ throw(robj);
+ break;
+ }
+
+ this.error.sdump('D_AUTH','auth.session.key = ' + this.key + '\n');
+
+ if (typeof this.on_init == 'function') {
+ this.error.sdump('D_AUTH','auth.session.on_init()\n');
+ this.on_init();
+ }
+
+ } else {
+
+ var error = document.getElementById('authStrings').getString('staff.auth.session.init_false') + '\n';
+ this.error.sdump('D_ERROR',error);
+ throw(error);
+ }
+
+ } catch(E) {
+ alert(document.getElementById('authStrings').getString('staff.auth.session.login_failed'));
+ //obj.error.standard_unexpected_error_alert('Error on auth.session.init()',E);
+
+ if (typeof this.on_init_error == 'function') {
+ this.error.sdump('D_AUTH','auth.session.on_init_error()\n');
+ this.on_init_error(E);
+ }
+ if (typeof this.on_error == 'function') {
+ this.error.sdump('D_AUTH','auth.session.on_error()\n');
+ this.on_error();
+ }
+
+ //throw(E);
+ /* This was for testing
+ if (typeof this.on_init == 'function') {
+ this.error.sdump('D_AUTH','auth.session.on_init() despite error\n');
+ this.on_init();
+ }
+ */
+ }
+ },
+
+ 'close' : function () {
+ var obj = this;
+ obj.error.sdump('D_AUTH','auth.session.close()\n');
+ if (obj.key) obj.network.request(
+ api.AUTH_DELETE.app,
+ api.AUTH_DELETE.method,
+ [ obj.key ],
+ function(req) {}
+ );
+ obj.key = null;
+ if (typeof obj.on_close == 'function') {
+ obj.error.sdump('D_AUTH','auth.session.on_close()\n');
+ obj.on_close();
+ }
+ }
}
function $(id) { return document.getElementById(id); }
function my_init() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (typeof JSAN == 'undefined') { throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); }
- JSAN.errorLevel = "die"; // none, warn, or die
- JSAN.addRepository('..');
- JSAN.use('util.error'); g.error = new util.error();
- g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw(document.getElementById('offlineStrings').getString('common.jsan.missing')); }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+ JSAN.use('util.error'); g.error = new util.error();
+ g.error.sdump('D_TRACE','my_init() for cat/opac.xul');
- JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
- XML_HTTP_SERVER = g.data.server_unadorned;
+ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+ XML_HTTP_SERVER = g.data.server_unadorned;
//JSAN.addRepository('http://' + g.data.server_unadorned + '/xul/server/');
//JSAN._loadJSFromUrl('http://' + g.data.server_unadorned + '/xul/server/cat/util.js');
- JSAN.use('util.network'); g.network = new util.network();
+ JSAN.use('util.network'); g.network = new util.network();
- g.cgi = new CGI();
- try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
- try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
- try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
+ g.cgi = new CGI();
+ try { authtime = g.cgi.param('authtime') || xulG.authtime; } catch(E) { g.error.sdump('D_ERROR',E); }
+ try { docid = g.cgi.param('docid') || xulG.docid; } catch(E) { g.error.sdump('D_ERROR',E); }
+ try { opac_url = g.cgi.param('opac_url') || xulG.opac_url; } catch(E) { g.error.sdump('D_ERROR',E); }
- JSAN.use('util.deck');
- top_pane = new util.deck('top_pane');
- bottom_pane = new util.deck('bottom_pane');
+ JSAN.use('util.deck');
+ top_pane = new util.deck('top_pane');
+ bottom_pane = new util.deck('bottom_pane');
- set_opac();
+ set_opac();
- } catch(E) {
- var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
- try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
- alert(err_msg);
- }
+ } catch(E) {
+ var err_msg = document.getElementById("offlineStrings").getFormattedString("common.exception", ["cat/opac.xul", E]);
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+ alert(err_msg);
+ }
}
function set_brief_view() {
- var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
- dump('spawning ' + url + '\n');
- top_pane.set_iframe(
- url,
- {},
- {
- 'set_tab_name' : function(n) {
- if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
- try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
- } else {
- dump('no set_tab_name\n');
- }
- }
- }
- );
+ var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
+ dump('spawning ' + url + '\n');
+ top_pane.set_iframe(
+ url,
+ {},
+ {
+ 'set_tab_name' : function(n) {
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name(document.getElementById('offlineStrings').getFormattedString("cat.bib_record", [n])); } catch(E) { alert(E); }
+ } else {
+ dump('no set_tab_name\n');
+ }
+ }
+ }
+ );
}
function set_marc_view() {
- g.view = 'marc_view';
- if (marc_view_reset) {
- bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
+ g.view = 'marc_view';
+ if (marc_view_reset) {
+ bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
marc_view_reset = false;
- } else {
- bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
- }
+ } else {
+ bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_MARC_VIEW ) + '?docid=' + window.escape(docid),{},xulG);
+ }
}
function set_marc_edit() {
- g.view = 'marc_edit';
- var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
- var b = {};
- var c = {
- 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid },
+ g.view = 'marc_edit';
+ var a = xulG.url_prefix( urls.XUL_MARC_EDIT );
+ var b = {};
+ var c = {
+ 'record' : { 'url' : '/opac/extras/supercat/retrieve/marcxml/record/' + docid },
/* // FIXME - disable this until we find a good way of pulling remote JSAN libraries into chrome
'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
try {
}
},
*/
- 'save' : {
- 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
- 'func' : function (new_marcxml) {
- try {
- var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
+ 'save' : {
+ 'label' : document.getElementById('offlineStrings').getString('cat.save_record'),
+ 'func' : function (new_marcxml) {
+ try {
+ var r = g.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), docid, new_marcxml ]);
marc_view_reset = true;
copy_browser_reset = true;
hold_browser_reset = true;
- if (typeof r.ilsevent != 'undefined') {
- throw(r);
- } else {
- alert(document.getElementById('offlineStrings').getString("cat.save.success"));
+ if (typeof r.ilsevent != 'undefined') {
+ throw(r);
+ } else {
+ alert(document.getElementById('offlineStrings').getString("cat.save.success"));
return {
'id' : r.id(),
'oncomplete' : function() {}
};
- }
- } catch(E) {
- g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
- }
- }
- }
- };
- if (marc_edit_reset) {
- bottom_pane.reset_iframe( a,b,c );
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString("cat.save.failure"), E);
+ }
+ }
+ }
+ };
+ if (marc_edit_reset) {
+ bottom_pane.reset_iframe( a,b,c );
marc_edit_reset = false;
- } else {
- bottom_pane.set_iframe( a,b,c );
- }
+ } else {
+ bottom_pane.set_iframe( a,b,c );
+ }
}
function set_copy_browser() {
- g.view = 'copy_browser';
- if (copy_browser_reset) {
- bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
+ g.view = 'copy_browser';
+ if (copy_browser_reset) {
+ bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
copy_browser_reset =false;
- } else {
- bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
- }
+ } else {
+ bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_COPY_VOLUME_BROWSE ) + '?docid=' + window.escape(docid),{},xulG);
+ }
}
function set_hold_browser() {
- g.view = 'hold_browser';
- if (hold_browser_reset) {
- bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
+ g.view = 'hold_browser';
+ if (hold_browser_reset) {
+ bottom_pane.reset_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
hold_browser_reset = false;
- } else {
- bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
- }
+ } else {
+ bottom_pane.set_iframe( xulG.url_prefix( urls.XUL_HOLDS_BROWSER ) + '?docid=' + window.escape(docid),{},xulG);
+ }
}
function set_opac() {
- g.view = 'opac';
- try {
- var content_params = {
- 'show_nav_buttons' : true,
- 'show_print_button' : true,
- 'passthru_content_params' : {
- 'authtoken' : ses(),
- 'authtime' : ses('authtime'),
- 'window_open' : function(a,b,c) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- return window.open(a,b,c);
- } catch(E) {
- g.error.standard_unexpected_error_alert('window_open',E);
- }
- }
- },
- 'on_url_load' : function(f) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var win;
- try {
- if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
- win = f.contentWindow.wrappedJSObject;
- } else {
- win = f.contentWindow;
- }
- } catch(E) {
- win = f.contentWindow;
- }
- win.attachEvt("rdetail", "recordRetrieved",
- function(id){
- try {
- if (docid == id) return;
- docid = id;
- refresh_display(id);
- } catch(E) {
- g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
- }
- }
- );
-
- g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
- $('record_start').disabled = true; $('record_next').disabled = true;
- $('record_prev').disabled = true; $('record_end').disabled = true;
- $('record_pos').setAttribute('value','');
+ g.view = 'opac';
+ try {
+ var content_params = {
+ 'show_nav_buttons' : true,
+ 'show_print_button' : true,
+ 'passthru_content_params' : {
+ 'authtoken' : ses(),
+ 'authtime' : ses('authtime'),
+ 'window_open' : function(a,b,c) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ return window.open(a,b,c);
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('window_open',E);
+ }
+ }
+ },
+ 'on_url_load' : function(f) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var win;
+ try {
+ if (typeof f.contentWindow.wrappedJSObject.attachEvt != 'undefined') {
+ win = f.contentWindow.wrappedJSObject;
+ } else {
+ win = f.contentWindow;
+ }
+ } catch(E) {
+ win = f.contentWindow;
+ }
+ win.attachEvt("rdetail", "recordRetrieved",
+ function(id){
+ try {
+ if (docid == id) return;
+ docid = id;
+ refresh_display(id);
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('rdetail -> recordRetrieved',E);
+ }
+ }
+ );
+
+ g.f_record_start = null; g.f_record_prev = null; g.f_record_next = null; g.f_record_end = null;
+ $('record_start').disabled = true; $('record_next').disabled = true;
+ $('record_prev').disabled = true; $('record_end').disabled = true;
+ $('record_pos').setAttribute('value','');
- win.attachEvt("rdetail", "nextPrevDrawn",
- function(rIndex,rCount){
- $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
- if (win.rdetailNext) {
- g.f_record_next = function() {
- g.view_override = g.view;
- win.rdetailNext();
- }
- $('record_next').disabled = false;
- }
- if (win.rdetailPrev) {
- g.f_record_prev = function() {
- g.view_override = g.view;
- win.rdetailPrev();
- }
- $('record_prev').disabled = false;
- }
- if (win.rdetailStart) {
- g.f_record_start = function() {
- g.view_override = g.view;
- win.rdetailStart();
- }
- $('record_start').disabled = false;
- }
- if (win.rdetailEnd) {
- g.f_record_end = function() {
- g.view_override = g.view;
- win.rdetailEnd();
- }
- $('record_end').disabled = false;
- }
- }
- );
- },
- 'url_prefix' : xulG.url_prefix,
- };
- if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
- browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
+ win.attachEvt("rdetail", "nextPrevDrawn",
+ function(rIndex,rCount){
+ $('record_pos').setAttribute('value', document.getElementById('offlineStrings').getFormattedString('cat.record.counter', [(1+rIndex), rCount ? rCount : 1]));
+ if (win.rdetailNext) {
+ g.f_record_next = function() {
+ g.view_override = g.view;
+ win.rdetailNext();
+ }
+ $('record_next').disabled = false;
+ }
+ if (win.rdetailPrev) {
+ g.f_record_prev = function() {
+ g.view_override = g.view;
+ win.rdetailPrev();
+ }
+ $('record_prev').disabled = false;
+ }
+ if (win.rdetailStart) {
+ g.f_record_start = function() {
+ g.view_override = g.view;
+ win.rdetailStart();
+ }
+ $('record_start').disabled = false;
+ }
+ if (win.rdetailEnd) {
+ g.f_record_end = function() {
+ g.view_override = g.view;
+ win.rdetailEnd();
+ }
+ $('record_end').disabled = false;
+ }
+ }
+ );
+ },
+ 'url_prefix' : xulG.url_prefix,
+ };
+ if (opac_url) { content_params.url = opac_url; } else { content_params.url = xulG.url_prefix( urls.browser ); }
+ browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_BROWSER) + '?name=Catalog', {}, content_params);
/* // Remember to use the REMOTE_BROWSER if we ever try to move this to remote xul again
- browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
+ browser_frame = bottom_pane.set_iframe( xulG.url_prefix(urls.XUL_REMOTE_BROWSER) + '?name=Catalog', {}, content_params);
*/
- } catch(E) {
- g.error.sdump('D_ERROR','set_opac: ' + E);
- }
+ } catch(E) {
+ g.error.sdump('D_ERROR','set_opac: ' + E);
+ }
}
function bib_in_new_tab() {
- try {
- var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
- var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
- xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
- } catch(E) {
- g.error.sdump('D_ERROR',E);
- }
+ try {
+ var url = browser_frame.contentWindow.g.browser.controller.view.browser_browser.contentWindow.wrappedJSObject.location.href;
+ var content_params = { 'session' : ses(), 'authtime' : ses('authtime'), 'opac_url' : url };
+ xulG.new_tab(xulG.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
+ } catch(E) {
+ g.error.sdump('D_ERROR',E);
+ }
}
function remove_me() {
- var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
- dump('removing ' + url + '\n');
- try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
- $('nav').setAttribute('hidden','true');
+ var url = xulG.url_prefix( urls.XUL_BIB_BRIEF ) + '?docid=' + window.escape(docid);
+ dump('removing ' + url + '\n');
+ try { top_pane.remove_iframe( url ); } catch(E) { dump(E + '\n'); }
+ $('nav').setAttribute('hidden','true');
}
function add_to_bucket() {
- JSAN.use('util.window'); var win = new util.window();
- win.open(
- xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK)
- + '?record_ids=' + js2JSON( [ docid ] ),
- 'sel_bucket_win' + win.window_name_increment(),
- 'chrome,resizable,modal,center'
- );
+ JSAN.use('util.window'); var win = new util.window();
+ win.open(
+ xulG.url_prefix(urls.XUL_RECORD_BUCKETS_QUICK)
+ + '?record_ids=' + js2JSON( [ docid ] ),
+ 'sel_bucket_win' + win.window_name_increment(),
+ 'chrome,resizable,modal,center'
+ );
}
function mark_for_overlay() {
- g.data.marked_record = docid;
- g.data.stash('marked_record');
- var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
+ g.data.marked_record = docid;
+ g.data.stash('marked_record');
+ var robj = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative',[docid]);
if (typeof robj.ilsevent == 'undefined') {
g.data.marked_record_mvr = robj;
} else {
g.data.marked_record_mvr = null;
- g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
+ g.error.standard_unexpected_error_alert('in mark_for_overlay',robj);
}
g.data.stash('marked_record_mvr');
if (g.data.marked_record_mvr) {
}
function delete_record() {
- if (g.error.yns_alert(
- document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
- document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
- document.getElementById('offlineStrings').getString('cat.opac.delete'),
- document.getElementById('offlineStrings').getString('cat.opac.cancel'),
- null,
- document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
- var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
- if (typeof robj.ilsevent != 'undefined') {
- alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
- } else {
- alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
- refresh_display(docid);
- }
- }
+ if (g.error.yns_alert(
+ document.getElementById('offlineStrings').getFormattedString('cat.opac.delete_record.confirm', [docid]),
+ document.getElementById('offlineStrings').getString('cat.opac.delete_record'),
+ document.getElementById('offlineStrings').getString('cat.opac.delete'),
+ document.getElementById('offlineStrings').getString('cat.opac.cancel'),
+ null,
+ document.getElementById('offlineStrings').getString('cat.opac.record_deleted.confirm')) == 0) {
+ var robj = g.network.simple_request('FM_BRE_DELETE',[ses(),docid]);
+ if (typeof robj.ilsevent != 'undefined') {
+ alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_deleted.error', [docid, robj.textcode, robj.desc]) + '\n');
+ } else {
+ alert(document.getElementById('offlineStrings').getString('cat.opac.record_deleted'));
+ refresh_display(docid);
+ }
+ }
}
function undelete_record() {
if (g.error.yns_alert(
- document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
- document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
- document.getElementById('offlineStrings').getString('cat.opac.undelete'),
- document.getElementById('offlineStrings').getString('cat.opac.cancel'),
- null,
- document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
+ document.getElementById('offlineStrings').getFormattedString('cat.opac.undelete_record.confirm', [docid]),
+ document.getElementById('offlineStrings').getString('cat.opac.undelete_record'),
+ document.getElementById('offlineStrings').getString('cat.opac.undelete'),
+ document.getElementById('offlineStrings').getString('cat.opac.cancel'),
+ null,
+ document.getElementById('offlineStrings').getString('cat.opac.record_undeleted.confirm')) == 0) {
var robj = g.network.simple_request('FM_BRE_UNDELETE',[ses(),docid]);
if (typeof robj.ilsevent != 'undefined') {
- alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
+ alert(document.getElementById('offlineStrings').getFormattedString('cat.opac.record_undeleted.error', [docid, robj.textcode, robj.desc]) + '\n');
} else {
- alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
- refresh_display(docid);
+ alert(document.getElementById('offlineStrings').getString('cat.opac.record_undeleted'));
+ refresh_display(docid);
}
}
}
function refresh_display(id) {
- try {
+ try {
marc_view_reset = true;
marc_edit_reset = true;
copy_browser_reset = true;
hold_browser_reset = true;
- while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
- var children = bottom_pane.node.childNodes;
- for (var i = 0; i < children.length; i++) {
- if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
- }
+ while(top_pane.node.lastChild) top_pane.node.removeChild( top_pane.node.lastChild );
+ var children = bottom_pane.node.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ if (children[i] != browser_frame) bottom_pane.node.removeChild(children[i]);
+ }
- set_brief_view();
- $('nav').setAttribute('hidden','false');
- var settings = g.network.simple_request(
- 'FM_AUS_RETRIEVE',
- [ ses(), g.data.list.au[0].id() ]
- );
- var view = settings['staff_client.catalog.record_view.default'];
- if (g.view_override) {
- view = g.view_override;
- g.view_override = null;
- }
- switch(view) {
- case 'marc_view' : set_marc_view(); break;
- case 'marc_edit' : set_marc_edit(); break;
- case 'copy_browser' : set_copy_browser(); break;
- case 'hold_browser' : set_hold_browser(); break;
- case 'opac' :
- default: set_opac(); break;
- }
- } catch(E) {
- g.error.standard_unexpected_error_alert('in refresh_display',E);
- }
+ set_brief_view();
+ $('nav').setAttribute('hidden','false');
+ var settings = g.network.simple_request(
+ 'FM_AUS_RETRIEVE',
+ [ ses(), g.data.list.au[0].id() ]
+ );
+ var view = settings['staff_client.catalog.record_view.default'];
+ if (g.view_override) {
+ view = g.view_override;
+ g.view_override = null;
+ }
+ switch(view) {
+ case 'marc_view' : set_marc_view(); break;
+ case 'marc_edit' : set_marc_edit(); break;
+ case 'copy_browser' : set_copy_browser(); break;
+ case 'hold_browser' : set_hold_browser(); break;
+ case 'opac' :
+ default: set_opac(); break;
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('in refresh_display',E);
+ }
}
function set_default() {
- var robj = g.network.simple_request(
- 'FM_AUS_UPDATE',
- [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
- )
- if (typeof robj.ilsevent != 'undefined') {
- if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
- }
+ var robj = g.network.simple_request(
+ 'FM_AUS_UPDATE',
+ [ ses(), g.data.list.au[0].id(), { 'staff_client.catalog.record_view.default' : g.view } ]
+ )
+ if (typeof robj.ilsevent != 'undefined') {
+ if (robj.ilsevent != 0) g.error.standard_unexpected_error_alert(document.getElementById('offlineStrings').getString('cat.preference.error'), robj);
+ }
}
if (typeof circ == 'undefined') circ = {};
circ.offline = function (params) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.error'); this.error = new util.error();
- } catch(E) {
- dump('circ.offline: ' + E + '\n');
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.error'); this.error = new util.error();
+ } catch(E) {
+ dump('circ.offline: ' + E + '\n');
+ }
}
circ.offline.prototype = {
- 'init' : function( params ) {
+ 'init' : function( params ) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
+ var obj = this;
- JSAN.use('util.deck'); obj.deck = new util.deck('main');
+ JSAN.use('util.deck'); obj.deck = new util.deck('main');
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'cmd_broken' : [
- ['command'],
- function() { alert('Not Yet Implemented'); }
- ],
- 'cmd_checkout' : [
- ['command'],
- function() { obj.deck.set_iframe('offline_checkout.xul',{},{}); }
- ],
- 'cmd_renew' : [
- ['command'],
- function() { obj.deck.set_iframe('offline_renew.xul',{},{}); }
- ],
- 'cmd_in_house_use' : [
- ['command'],
- function() { obj.deck.set_iframe('offline_in_house_use.xul',{},{}); }
- ],
- 'cmd_checkin' : [
- ['command'],
- function() { obj.deck.set_iframe('offline_checkin.xul',{},{}); }
- ],
- 'cmd_register_patron' : [
- ['command'],
- function() { obj.deck.set_iframe('offline_register.xul',{},{}); }
- ],
- 'cmd_print_last_receipt' : [
- ['command'],
- function() {
- JSAN.use('util.print'); var print = new util.print();
- print.reprint_last();
- }
- ],
- 'cmd_exit' : [
- ['command'],
- function() { try { xulG.close_tab(); } catch(E) { window.close(); } }
- ],
- }
- }
- );
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert('Not Yet Implemented'); }
+ ],
+ 'cmd_checkout' : [
+ ['command'],
+ function() { obj.deck.set_iframe('offline_checkout.xul',{},{}); }
+ ],
+ 'cmd_renew' : [
+ ['command'],
+ function() { obj.deck.set_iframe('offline_renew.xul',{},{}); }
+ ],
+ 'cmd_in_house_use' : [
+ ['command'],
+ function() { obj.deck.set_iframe('offline_in_house_use.xul',{},{}); }
+ ],
+ 'cmd_checkin' : [
+ ['command'],
+ function() { obj.deck.set_iframe('offline_checkin.xul',{},{}); }
+ ],
+ 'cmd_register_patron' : [
+ ['command'],
+ function() { obj.deck.set_iframe('offline_register.xul',{},{}); }
+ ],
+ 'cmd_print_last_receipt' : [
+ ['command'],
+ function() {
+ JSAN.use('util.print'); var print = new util.print();
+ print.reprint_last();
+ }
+ ],
+ 'cmd_exit' : [
+ ['command'],
+ function() { try { xulG.close_tab(); } catch(E) { window.close(); } }
+ ],
+ }
+ }
+ );
- obj.receipt_init();
+ obj.receipt_init();
- obj.patron_init();
+ obj.patron_init();
- } catch(E) {
- this.error.sdump('D_ERROR','circ.offline.init: ' + E + '\n');
- }
- },
+ } catch(E) {
+ this.error.sdump('D_ERROR','circ.offline.init: ' + E + '\n');
+ }
+ },
- 'receipt_init' : function() {
- function backup_receipt_templates() {
- data.print_list_templates = {
- 'offline_checkout' : {
- 'type' : 'offline_checkout',
- 'header' : 'Patron %patron_barcode%<br/>\r\nYou checked out the following items:<hr/><ol>',
- 'line_item' : '<li>Barcode: %barcode%<br/>\r\nDue: %due_date%\r\n',
- 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
- },
- 'offline_checkin' : {
- 'type' : 'offline_checkin',
- 'header' : 'You checked in the following items:<hr/><ol>',
- 'line_item' : '<li>Barcode: %barcode%\r\n',
- 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
- },
- 'offline_renew' : {
- 'type' : 'offline_renew',
- 'header' : 'You renewed the following items:<hr/><ol>',
- 'line_item' : '<li>Barcode: %barcode%\r\n',
- 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
- },
- 'offline_inhouse_use' : {
- 'type' : 'offline_inhouse_use',
- 'header' : 'You marked the following in-house items used:<hr/><ol>',
- 'line_item' : '<li>Barcode: %barcode%\r\nUses: %count%',
- 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
- },
- };
- data.stash('print_list_templates');
- }
+ 'receipt_init' : function() {
+ function backup_receipt_templates() {
+ data.print_list_templates = {
+ 'offline_checkout' : {
+ 'type' : 'offline_checkout',
+ 'header' : 'Patron %patron_barcode%<br/>\r\nYou checked out the following items:<hr/><ol>',
+ 'line_item' : '<li>Barcode: %barcode%<br/>\r\nDue: %due_date%\r\n',
+ 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
+ },
+ 'offline_checkin' : {
+ 'type' : 'offline_checkin',
+ 'header' : 'You checked in the following items:<hr/><ol>',
+ 'line_item' : '<li>Barcode: %barcode%\r\n',
+ 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
+ },
+ 'offline_renew' : {
+ 'type' : 'offline_renew',
+ 'header' : 'You renewed the following items:<hr/><ol>',
+ 'line_item' : '<li>Barcode: %barcode%\r\n',
+ 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
+ },
+ 'offline_inhouse_use' : {
+ 'type' : 'offline_inhouse_use',
+ 'header' : 'You marked the following in-house items used:<hr/><ol>',
+ 'line_item' : '<li>Barcode: %barcode%\r\nUses: %count%',
+ 'footer' : '</ol><hr />%TODAY_TRIM%<br/>\r\n<br/>\r\n',
+ },
+ };
+ data.stash('print_list_templates');
+ }
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- JSAN.use('util.file'); var file = new util.file('print_list_templates');
- if (file._file.exists()) {
- try {
- var x = file.get_object();
- if (x) {
- data.print_list_templates = x;
- data.stash('print_list_templates');
- } else {
- backup_receipt_templates();
- }
- } catch(E) {
- alert(E);
- backup_receipt_templates();
- }
- } else {
- backup_receipt_templates();
- }
- file.close();
- },
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ JSAN.use('util.file'); var file = new util.file('print_list_templates');
+ if (file._file.exists()) {
+ try {
+ var x = file.get_object();
+ if (x) {
+ data.print_list_templates = x;
+ data.stash('print_list_templates');
+ } else {
+ backup_receipt_templates();
+ }
+ } catch(E) {
+ alert(E);
+ backup_receipt_templates();
+ }
+ } else {
+ backup_receipt_templates();
+ }
+ file.close();
+ },
- 'patron_init' : function() {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- JSAN.use('util.file'); var file = new util.file('offline_patron_list');
- if (file._file.exists()) {
- var lines = file.get_content().split(/\n/);
- var hash = {};
- for (var i = 0; i < lines.length; i++) {
- hash[ lines[i].split(/\s+/)[0] ] = lines[i].split(/\s+/)[1];
- }
- delete(lines);
- data.bad_patrons = hash;
- data.stash('bad_patrons');
- var file2 = new util.file('offline_patron_list.date');
- if (file2._file.exists()) {
- data.bad_patrons_date = file2.get_content();
- data.stash('bad_patrons_date');
- }
- file2.close();
- } else {
- data.bad_patrons = {};
- data.stash('bad_patrons');
- }
- file.close();
- },
+ 'patron_init' : function() {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ JSAN.use('util.file'); var file = new util.file('offline_patron_list');
+ if (file._file.exists()) {
+ var lines = file.get_content().split(/\n/);
+ var hash = {};
+ for (var i = 0; i < lines.length; i++) {
+ hash[ lines[i].split(/\s+/)[0] ] = lines[i].split(/\s+/)[1];
+ }
+ delete(lines);
+ data.bad_patrons = hash;
+ data.stash('bad_patrons');
+ var file2 = new util.file('offline_patron_list.date');
+ if (file2._file.exists()) {
+ data.bad_patrons_date = file2.get_content();
+ data.stash('bad_patrons_date');
+ }
+ file2.close();
+ } else {
+ data.bad_patrons = {};
+ data.stash('bad_patrons');
+ }
+ file.close();
+ },
}
var offlineStrings;
function my_init() {
- try {
- offlineStrings = $('offlineStrings');
-
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (typeof JSAN == 'undefined') { throw(offlineStrings.getString('common.jsan.missing')); }
- JSAN.errorLevel = "die"; // none, warn, or die
- JSAN.addRepository('..');
- JSAN.use('util.error'); g.error = new util.error();
- g.error.sdump('D_TRACE','my_init() for offline_checkin.xul');
-
- if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
- try { window.xulG.set_tab_name(offlineStrings.getString('circ.standalone')); } catch(E) { alert(E); }
- }
+ try {
+ offlineStrings = $('offlineStrings');
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw(offlineStrings.getString('common.jsan.missing')); }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+ JSAN.use('util.error'); g.error = new util.error();
+ g.error.sdump('D_TRACE','my_init() for offline_checkin.xul');
+
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name(offlineStrings.getString('circ.standalone')); } catch(E) { alert(E); }
+ }
- JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
- JSAN.use('util.list'); g.list = new util.list('checkin_list');
- JSAN.use('circ.util');
- g.list.init( {
- 'columns' : circ.util.offline_checkin_columns(),
- 'map_row_to_column' : circ.util.std_map_row_to_column(),
- } );
+ JSAN.use('util.list'); g.list = new util.list('checkin_list');
+ JSAN.use('circ.util');
+ g.list.init( {
+ 'columns' : circ.util.offline_checkin_columns(),
+ 'map_row_to_column' : circ.util.std_map_row_to_column(),
+ } );
- JSAN.use('util.date');
+ JSAN.use('util.date');
- $('i_barcode').addEventListener('keypress',handle_keypress,false);
- $('i_barcode').focus();
+ $('i_barcode').addEventListener('keypress',handle_keypress,false);
+ $('i_barcode').focus();
- $('enter').addEventListener('command',handle_enter,false);
+ $('enter').addEventListener('command',handle_enter,false);
- $('submit').addEventListener('command',next_patron,false);
+ $('submit').addEventListener('command',next_patron,false);
- JSAN.use('util.file');
- var file = new util.file('offline_delta');
- if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
+ JSAN.use('util.file');
+ var file = new util.file('offline_delta');
+ if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
- } catch(E) {
- var err_msg = offlineStrings.getFormattedString('common.exception', ["circ/offline_checkin.xul", E]);
- try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
- alert(err_msg);
- }
+ } catch(E) {
+ var err_msg = offlineStrings.getFormattedString('common.exception', ["circ/offline_checkin.xul", E]);
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+ alert(err_msg);
+ }
}
function $(id) { return document.getElementById(id); }
function handle_keypress(ev) {
- if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
- switch(ev.target) {
- case $('i_barcode') : handle_enter(); break;
- default: break;
- }
+ if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
+ switch(ev.target) {
+ case $('i_barcode') : handle_enter(); break;
+ default: break;
+ }
}
function handle_enter(ev) {
- JSAN.use('util.barcode');
- if ( ($('strict_i_barcode').checked) && (! util.barcode.check($('i_barcode').value)) ) {
- var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
- if (r == 1) {
- setTimeout(
- function() {
- $('i_barcode').value = '';
- $('i_barcode').focus();
- },0
- );
- } else {
- append_to_list();
- }
- } else {
- append_to_list();
- }
+ JSAN.use('util.barcode');
+ if ( ($('strict_i_barcode').checked) && (! util.barcode.check($('i_barcode').value)) ) {
+ var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
+ if (r == 1) {
+ setTimeout(
+ function() {
+ $('i_barcode').value = '';
+ $('i_barcode').focus();
+ },0
+ );
+ } else {
+ append_to_list();
+ }
+ } else {
+ append_to_list();
+ }
}
function append_to_list() {
- try {
+ try {
- var my = {};
+ var my = {};
- my.type = 'checkin';
- my.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
- /* I18N to-do: enable localized date formats */
- my.backdate = util.date.formatted_date(new Date(),"%F %H:%M:%s");
+ my.type = 'checkin';
+ my.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
+ /* I18N to-do: enable localized date formats */
+ my.backdate = util.date.formatted_date(new Date(),"%F %H:%M:%s");
- var i_barcode = $('i_barcode').value;
- if (! i_barcode) return;
- my.barcode = i_barcode;
-
- g.list.append( { 'row' : { 'my' : my }, 'to_top' : true } );
+ var i_barcode = $('i_barcode').value;
+ if (! i_barcode) return;
+ my.barcode = i_barcode;
+
+ g.list.append( { 'row' : { 'my' : my }, 'to_top' : true } );
- var x = $('i_barcode'); x.value = ''; x.focus();
+ var x = $('i_barcode'); x.value = ''; x.focus();
- } catch(E) {
+ } catch(E) {
- dump(E+'\n'); alert(E);
+ dump(E+'\n'); alert(E);
- }
+ }
}
function next_patron() {
- try {
- JSAN.use('util.file'); var file = new util.file('pending_xacts');
- var rows = g.list.dump_with_keys();
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i]; row.delta = g.delta;
- file.append_object(row);
- }
- file.close();
-
- if ($('print_receipt').checked) {
- try {
+ try {
+ JSAN.use('util.file'); var file = new util.file('pending_xacts');
+ var rows = g.list.dump_with_keys();
+ for (var i = 0; i < rows.length; i++) {
+ var row = rows[i]; row.delta = g.delta;
+ file.append_object(row);
+ }
+ file.close();
+
+ if ($('print_receipt').checked) {
+ try {
var params = {
'template' : 'offline_checkin',
'callback' : function() {
}
};
g.list.print( params );
- } catch(E) {
- g.error.sdump('D_ERROR','print: ' + E);
- alert('print: ' + E);
- }
- } else {
+ } catch(E) {
+ g.error.sdump('D_ERROR','print: ' + E);
+ alert('print: ' + E);
+ }
+ } else {
g.list.clear();
var x = $('i_barcode'); x.value = ''; x.focus();
}
- } catch(E) {
- dump(E+'\n'); alert(E);
- }
+ } catch(E) {
+ dump(E+'\n'); alert(E);
+ }
}
var offlineStrings;
function my_init() {
- try {
- offlineStrings = $('offlineStrings');
-
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (typeof JSAN == 'undefined') { throw(offlineStrings.getString('common.jsan.missing')); }
- JSAN.errorLevel = "die"; // none, warn, or die
- JSAN.addRepository('..');
- JSAN.use('util.error'); g.error = new util.error();
- g.error.sdump('D_TRACE','my_init() for offline_checkout.xul');
-
- JSAN.use('util.widgets'); JSAN.use('util.file');
-
- if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
- try { window.xulG.set_tab_name(offlineStrings.getString('circ.standalone')); } catch(E) { alert(E); }
- }
-
- JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
-
- JSAN.use('util.list'); g.list = new util.list('checkout_list');
- JSAN.use('circ.util');
- g.list.init( {
- 'columns' : circ.util.offline_checkout_columns(),
- 'map_row_to_column' : circ.util.std_map_row_to_column(),
- } );
-
- JSAN.use('util.date');
- var today = new Date();
- var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
- todayPlus = util.date.formatted_date(todayPlus,"%F");
-
- $('duedate').setAttribute('value',todayPlus);
- $('duedate').addEventListener('change',check_date,false);
-
- $('p_barcode').addEventListener('change',test_patron,false);
-
- $('p_barcode').addEventListener('keypress',handle_keypress,false);
- $('p_barcode').focus();
-
- $('i_barcode').addEventListener('keypress',handle_keypress,false);
- $('enter').addEventListener('command',handle_enter,false);
-
- $('duedate_menu').addEventListener('command',handle_duedate_menu,false);
-
- $('submit').addEventListener('command',function(ev){
- save_xacts(); next_patron();
- },false);
- $('cancel').addEventListener('command',function(ev){
- next_patron('cancel');
- },false);
-
- var file; var list_data; var ml;
-
- file = new util.file('offline_cnct_list');
- if (file._file.exists()) {
- list_data = file.get_object(); file.close();
- ml = util.widgets.make_menulist(
- [ [offlineStrings.getString('circ.offline_checkout.nonbarcoded'), ''] ].concat(list_data[0]),
- list_data[1]
- );
- ml.setAttribute('id','noncat_type_menu'); $('x_noncat_type').appendChild(ml);
- ml.addEventListener(
- 'command',
- function(ev) {
- var count = window.prompt(offlineStrings.getString('circ.offline_checkout.items'),1,ml.getAttribute('label'));
- append_to_list('noncat',count);
- ml.value = '';
- },
- false
- );
- } else {
- alert(offlineStrings.getString('circ.offline_checkout.download.warning'));
- }
-
- var file = new util.file('offline_delta');
- if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
-
- } catch(E) {
- var err_msg = offlineStrings.getFormattedString('common.exception', ["circ/offline_checkout.xul", E]);
- try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
- alert(err_msg);
- }
+ try {
+ offlineStrings = $('offlineStrings');
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw(offlineStrings.getString('common.jsan.missing')); }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+ JSAN.use('util.error'); g.error = new util.error();
+ g.error.sdump('D_TRACE','my_init() for offline_checkout.xul');
+
+ JSAN.use('util.widgets'); JSAN.use('util.file');
+
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name(offlineStrings.getString('circ.standalone')); } catch(E) { alert(E); }
+ }
+
+ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+
+ JSAN.use('util.list'); g.list = new util.list('checkout_list');
+ JSAN.use('circ.util');
+ g.list.init( {
+ 'columns' : circ.util.offline_checkout_columns(),
+ 'map_row_to_column' : circ.util.std_map_row_to_column(),
+ } );
+
+ JSAN.use('util.date');
+ var today = new Date();
+ var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
+ todayPlus = util.date.formatted_date(todayPlus,"%F");
+
+ $('duedate').setAttribute('value',todayPlus);
+ $('duedate').addEventListener('change',check_date,false);
+
+ $('p_barcode').addEventListener('change',test_patron,false);
+
+ $('p_barcode').addEventListener('keypress',handle_keypress,false);
+ $('p_barcode').focus();
+
+ $('i_barcode').addEventListener('keypress',handle_keypress,false);
+ $('enter').addEventListener('command',handle_enter,false);
+
+ $('duedate_menu').addEventListener('command',handle_duedate_menu,false);
+
+ $('submit').addEventListener('command',function(ev){
+ save_xacts(); next_patron();
+ },false);
+ $('cancel').addEventListener('command',function(ev){
+ next_patron('cancel');
+ },false);
+
+ var file; var list_data; var ml;
+
+ file = new util.file('offline_cnct_list');
+ if (file._file.exists()) {
+ list_data = file.get_object(); file.close();
+ ml = util.widgets.make_menulist(
+ [ [offlineStrings.getString('circ.offline_checkout.nonbarcoded'), ''] ].concat(list_data[0]),
+ list_data[1]
+ );
+ ml.setAttribute('id','noncat_type_menu'); $('x_noncat_type').appendChild(ml);
+ ml.addEventListener(
+ 'command',
+ function(ev) {
+ var count = window.prompt(offlineStrings.getString('circ.offline_checkout.items'),1,ml.getAttribute('label'));
+ append_to_list('noncat',count);
+ ml.value = '';
+ },
+ false
+ );
+ } else {
+ alert(offlineStrings.getString('circ.offline_checkout.download.warning'));
+ }
+
+ var file = new util.file('offline_delta');
+ if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
+
+ } catch(E) {
+ var err_msg = offlineStrings.getFormattedString('common.exception', ["circ/offline_checkout.xul", E]);
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+ alert(err_msg);
+ }
}
function $(id) { return document.getElementById(id); }
function test_patron(ev) {
- try {
- var barcode = ev.target.value;
- JSAN.use('util.barcode');
- if ( ($('strict_p_barcode').checked) && (! util.barcode.check(barcode)) ) {
- var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
- if (r == 1) {
- setTimeout(
- function() {
- ev.target.value = '';
- ev.target.focus();
- },0
- );
- }
-
- }
-
- if (g.data.bad_patrons[barcode]) {
- var code;
- switch(g.data.bad_patrons[barcode]) {
- case 'L' : code = offlineStrings.getString('common.barcode.status.warning.lost'); break;
- case 'E' : code = offlineStrings.getString('common.barcode.status.warning.expired'); break;
- case 'B' : code = offlineStrings.getString('common.barcode.status.warning.barred'); break;
- case 'D' : code = offlineStrings.getString('common.barcode.status.warning.blocked'); break;
- default : code = offlineStrings.getFormattedString('common.barcode.status.warning.blocked', [g.data.bad_patrons[barcode]]); break;
- }
-
- var msg = offlineStrings.getFormattedString('common.barcode.status.warning', [g.data.bad_patrons_date.substr(0,15), barcode, code]);
- var r = g.error.yns_alert(msg,offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
- if (r == 1) {
- setTimeout(
- function() {
- ev.target.value = '';
- ev.target.focus();
- },0
- );
- }
- }
- } catch(E) {
- alert(E);
- }
+ try {
+ var barcode = ev.target.value;
+ JSAN.use('util.barcode');
+ if ( ($('strict_p_barcode').checked) && (! util.barcode.check(barcode)) ) {
+ var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
+ if (r == 1) {
+ setTimeout(
+ function() {
+ ev.target.value = '';
+ ev.target.focus();
+ },0
+ );
+ }
+
+ }
+
+ if (g.data.bad_patrons[barcode]) {
+ var code;
+ switch(g.data.bad_patrons[barcode]) {
+ case 'L' : code = offlineStrings.getString('common.barcode.status.warning.lost'); break;
+ case 'E' : code = offlineStrings.getString('common.barcode.status.warning.expired'); break;
+ case 'B' : code = offlineStrings.getString('common.barcode.status.warning.barred'); break;
+ case 'D' : code = offlineStrings.getString('common.barcode.status.warning.blocked'); break;
+ default : code = offlineStrings.getFormattedString('common.barcode.status.warning.blocked', [g.data.bad_patrons[barcode]]); break;
+ }
+
+ var msg = offlineStrings.getFormattedString('common.barcode.status.warning', [g.data.bad_patrons_date.substr(0,15), barcode, code]);
+ var r = g.error.yns_alert(msg,offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
+ if (r == 1) {
+ setTimeout(
+ function() {
+ ev.target.value = '';
+ ev.target.focus();
+ },0
+ );
+ }
+ }
+ } catch(E) {
+ alert(E);
+ }
}
function check_date(ev) {
- JSAN.use('util.date');
- try {
- if (! util.date.check('YYYY-MM-DD',ev.target.value) ) { throw(offlineStrings.getString('common.date.invalid')); }
- if (util.date.check_past('YYYY-MM-DD',ev.target.value) ) { throw(offlineStrings.getString('circ.offline_checkout.date.early')); }
- if (util.date.formatted_date(new Date(),'%F') == ev.target.value) { throw(offlineStrings.getString('circ.offline_checkout.date.early')); }
- } catch(E) {
- alert(E);
- var today = new Date();
- var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
- todayPlus = util.date.formatted_date(todayPlus,"%F");
- ev.target.value = todayPlus;
- }
+ JSAN.use('util.date');
+ try {
+ if (! util.date.check('YYYY-MM-DD',ev.target.value) ) { throw(offlineStrings.getString('common.date.invalid')); }
+ if (util.date.check_past('YYYY-MM-DD',ev.target.value) ) { throw(offlineStrings.getString('circ.offline_checkout.date.early')); }
+ if (util.date.formatted_date(new Date(),'%F') == ev.target.value) { throw(offlineStrings.getString('circ.offline_checkout.date.early')); }
+ } catch(E) {
+ alert(E);
+ var today = new Date();
+ var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
+ todayPlus = util.date.formatted_date(todayPlus,"%F");
+ ev.target.value = todayPlus;
+ }
}
function handle_keypress(ev) {
- if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
- switch(ev.target) {
- case $('p_barcode') : /*$('p_barcode').disabled = true;*/ setTimeout( function() { $('i_barcode').focus(); },0 ); break;
- case $('i_barcode') : handle_enter(); break;
- default: break;
- }
+ if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
+ switch(ev.target) {
+ case $('p_barcode') : /*$('p_barcode').disabled = true;*/ setTimeout( function() { $('i_barcode').focus(); },0 ); break;
+ case $('i_barcode') : handle_enter(); break;
+ default: break;
+ }
}
function handle_enter(ev) {
- JSAN.use('util.barcode');
- if ( ($('strict_i_barcode').checked) && (! util.barcode.check($('i_barcode').value)) ) {
- var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
- if (r == 1) {
- setTimeout(
- function() {
- $('i_barcode').value = '';
- $('i_barcode').focus();
- },0
- );
- } else {
- append_to_list('barcode');
- }
- } else {
- append_to_list('barcode');
- }
+ JSAN.use('util.barcode');
+ if ( ($('strict_i_barcode').checked) && (! util.barcode.check($('i_barcode').value)) ) {
+ var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
+ if (r == 1) {
+ setTimeout(
+ function() {
+ $('i_barcode').value = '';
+ $('i_barcode').focus();
+ },0
+ );
+ } else {
+ append_to_list('barcode');
+ }
+ } else {
+ append_to_list('barcode');
+ }
}
function handle_duedate_menu(ev) {
- if (ev.target.value=='0') return;
- JSAN.use('util.date');
- var today = new Date();
- var todayPlus = new Date();
- todayPlus.setTime( today.getTime() + 24*60*60*1000*ev.target.value );
- todayPlus = util.date.formatted_date(todayPlus,'%F');
- $('duedate').setAttribute('value',todayPlus);
- $('duedate').value = todayPlus;
+ if (ev.target.value=='0') return;
+ JSAN.use('util.date');
+ var today = new Date();
+ var todayPlus = new Date();
+ todayPlus.setTime( today.getTime() + 24*60*60*1000*ev.target.value );
+ todayPlus = util.date.formatted_date(todayPlus,'%F');
+ $('duedate').setAttribute('value',todayPlus);
+ $('duedate').value = todayPlus;
}
function append_to_list(checkout_type,count) {
- try {
-
- var my = {};
-
- my.type = 'checkout';
- my.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
- my.checkout_time = util.date.formatted_date(new Date(),"%F %H:%M:%s");
-
- var p_barcode = $('p_barcode').value;
- if (! p_barcode) {
- g.error.yns_alert(offlineStrings.getString('circ.barcode.enter'),offlineStrings.getString('circ.offline_checkout.required_field'),offlineStrings.getString('common.ok'),null,null,offlineStrings.getString('common.confirm'));
- return;
- } else {
-
- // Need to validate patron barcode against bad patron list
- my.patron_barcode = p_barcode;
- }
-
- var due_date = $('duedate').value; // Need to validate this
- my.due_date = due_date;
-
- var i_barcode = $('i_barcode').value;
- switch(checkout_type) {
- case 'barcode' :
- if (! i_barcode) return;
-
- var rows = g.list.dump_with_keys();
- for (var i = 0; i < rows.length; i++) {
- if (rows[i].barcode == i_barcode) {
- g.error.yns_alert(offlineStrings.getString('circ.duplicate_scan.msg'),offlineStrings.getString('circ.duplicate_scan.field'),offlineStrings.getString('common.ok'),null,null,offlineStrings.getString('common.confirm'));
- return;
- }
- }
-
- my.barcode = i_barcode;
- break;
- case 'noncat' :
- count = parseInt(count); if (! (count>0) ) {
- g.error.yns_alert(offlineStrings.getString('circ.offline_checkout.valid_count'),offlineStrings.getString('circ.offline_checkout.required_value'),offlineStrings.getString('common.ok'),null,null,offlineStrings.getString('common.confirm'));
- return;
- }
- my.barcode = $('noncat_type_menu').getAttribute('label');
- my.noncat = 1;
- my.noncat_type = JSON2js($('noncat_type_menu').value)[0];
- my.noncat_count = count;
- break;
- default: alert(offlineStrings.getString('common.error.default')); break;
- }
-
- g.list.append( { 'row' : { 'my' : my }, 'to_top' : true } );
-
- var x = $('i_barcode'); x.value = ''; x.focus();
-
- } catch(E) {
-
- dump(E+'\n'); alert(E);
-
- }
+ try {
+
+ var my = {};
+
+ my.type = 'checkout';
+ my.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
+ my.checkout_time = util.date.formatted_date(new Date(),"%F %H:%M:%s");
+
+ var p_barcode = $('p_barcode').value;
+ if (! p_barcode) {
+ g.error.yns_alert(offlineStrings.getString('circ.barcode.enter'),offlineStrings.getString('circ.offline_checkout.required_field'),offlineStrings.getString('common.ok'),null,null,offlineStrings.getString('common.confirm'));
+ return;
+ } else {
+
+ // Need to validate patron barcode against bad patron list
+ my.patron_barcode = p_barcode;
+ }
+
+ var due_date = $('duedate').value; // Need to validate this
+ my.due_date = due_date;
+
+ var i_barcode = $('i_barcode').value;
+ switch(checkout_type) {
+ case 'barcode' :
+ if (! i_barcode) return;
+
+ var rows = g.list.dump_with_keys();
+ for (var i = 0; i < rows.length; i++) {
+ if (rows[i].barcode == i_barcode) {
+ g.error.yns_alert(offlineStrings.getString('circ.duplicate_scan.msg'),offlineStrings.getString('circ.duplicate_scan.field'),offlineStrings.getString('common.ok'),null,null,offlineStrings.getString('common.confirm'));
+ return;
+ }
+ }
+
+ my.barcode = i_barcode;
+ break;
+ case 'noncat' :
+ count = parseInt(count); if (! (count>0) ) {
+ g.error.yns_alert(offlineStrings.getString('circ.offline_checkout.valid_count'),offlineStrings.getString('circ.offline_checkout.required_value'),offlineStrings.getString('common.ok'),null,null,offlineStrings.getString('common.confirm'));
+ return;
+ }
+ my.barcode = $('noncat_type_menu').getAttribute('label');
+ my.noncat = 1;
+ my.noncat_type = JSON2js($('noncat_type_menu').value)[0];
+ my.noncat_count = count;
+ break;
+ default: alert(offlineStrings.getString('common.error.default')); break;
+ }
+
+ g.list.append( { 'row' : { 'my' : my }, 'to_top' : true } );
+
+ var x = $('i_barcode'); x.value = ''; x.focus();
+
+ } catch(E) {
+
+ dump(E+'\n'); alert(E);
+
+ }
}
function save_xacts() {
- JSAN.use('util.file'); var file = new util.file('pending_xacts');
- var rows = g.list.dump_with_keys();
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i]; row.delta = g.delta;
- if (row.noncat == 1) {
- delete(row.barcode);
- } else {
- delete(row.noncat);
- delete(row.noncat_type);
- delete(row.noncat_count);
- }
- file.append_object(row);
- }
- file.close();
+ JSAN.use('util.file'); var file = new util.file('pending_xacts');
+ var rows = g.list.dump_with_keys();
+ for (var i = 0; i < rows.length; i++) {
+ var row = rows[i]; row.delta = g.delta;
+ if (row.noncat == 1) {
+ delete(row.barcode);
+ } else {
+ delete(row.noncat);
+ delete(row.noncat_type);
+ delete(row.noncat_count);
+ }
+ file.append_object(row);
+ }
+ file.close();
}
function next_patron(cancel) {
- try {
-
- if ($('print_receipt').checked && (cancel!='cancel')) {
- try {
- var params = {
- 'patron_barcode' : $('p_barcode').value,
- 'template' : 'offline_checkout',
+ try {
+
+ if ($('print_receipt').checked && (cancel!='cancel')) {
+ try {
+ var params = {
+ 'patron_barcode' : $('p_barcode').value,
+ 'template' : 'offline_checkout',
'callback' : function() {
g.list.clear();
var x = $('i_barcode'); x.value = '';
x.setAttribute('disabled','false'); x.disabled = false;
x.focus();
}
- };
- g.list.print( params );
- } catch(E) {
- g.error.sdump('D_ERROR','print: ' + E);
- alert('print: ' + E);
- }
- } else {
+ };
+ g.list.print( params );
+ } catch(E) {
+ g.error.sdump('D_ERROR','print: ' + E);
+ alert('print: ' + E);
+ }
+ } else {
g.list.clear();
var x = $('i_barcode'); x.value = '';
x = $('p_barcode'); x.value = '';
x.setAttribute('disabled','false'); x.disabled = false;
x.focus();
- }
- } catch(E) {
- dump(E+'\n'); alert(E);
- }
+ }
+ } catch(E) {
+ dump(E+'\n'); alert(E);
+ }
}
var offlineStrings;
function my_init() {
- try {
- offlineStrings = document.getElementById('offlineStrings');
-
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (typeof JSAN == 'undefined') { throw(offlineStrings.getString('common.jsan.missing')); }
- JSAN.errorLevel = "die"; // none, warn, or die
- JSAN.addRepository('..');
- JSAN.use('util.error'); g.error = new util.error();
- g.error.sdump('D_TRACE','my_init() for offline_checkout.xul');
-
- if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
- try { window.xulG.set_tab_name(offlineStrings.getString('circ.standalone')); } catch(E) { alert(E); }
- }
-
- JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
-
- JSAN.use('util.list'); g.list = new util.list('checkout_list');
- JSAN.use('circ.util');
- g.list.init( {
- 'columns' : circ.util.offline_inhouse_use_columns(),
- 'map_row_to_column' : circ.util.std_map_row_to_column(),
- } );
-
- $('i_barcode').addEventListener('keypress',handle_keypress,false);
- $('enter').addEventListener('command',handle_enter,false);
- $('submit').addEventListener('command',next_patron,false);
-
- $('i_barcode').focus();
-
- JSAN.use('util.file');
- var file = new util.file('offline_delta');
- if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
-
- } catch(E) {
- var err_msg = offlineStrings.getFormattedString('common.exception', ["circ/offline_in_house_use.xul", E]);
- try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
- alert(err_msg);
- }
+ try {
+ offlineStrings = document.getElementById('offlineStrings');
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw(offlineStrings.getString('common.jsan.missing')); }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+ JSAN.use('util.error'); g.error = new util.error();
+ g.error.sdump('D_TRACE','my_init() for offline_checkout.xul');
+
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name(offlineStrings.getString('circ.standalone')); } catch(E) { alert(E); }
+ }
+
+ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+
+ JSAN.use('util.list'); g.list = new util.list('checkout_list');
+ JSAN.use('circ.util');
+ g.list.init( {
+ 'columns' : circ.util.offline_inhouse_use_columns(),
+ 'map_row_to_column' : circ.util.std_map_row_to_column(),
+ } );
+
+ $('i_barcode').addEventListener('keypress',handle_keypress,false);
+ $('enter').addEventListener('command',handle_enter,false);
+ $('submit').addEventListener('command',next_patron,false);
+
+ $('i_barcode').focus();
+
+ JSAN.use('util.file');
+ var file = new util.file('offline_delta');
+ if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
+
+ } catch(E) {
+ var err_msg = offlineStrings.getFormattedString('common.exception', ["circ/offline_in_house_use.xul", E]);
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+ alert(err_msg);
+ }
}
function $(id) { return document.getElementById(id); }
function handle_keypress(ev) {
- if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
- switch(ev.target) {
- case $('i_barcode') : handle_enter(); break;
- default: break;
- }
+ if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
+ switch(ev.target) {
+ case $('i_barcode') : handle_enter(); break;
+ default: break;
+ }
}
function handle_enter(ev) {
- JSAN.use('util.barcode');
- if ( ($('strict_i_barcode').checked) && (! util.barcode.check($('i_barcode').value)) ) {
- var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
- if (r == 1) {
- setTimeout(
- function() {
- $('i_barcode').value = '';
- $('i_barcode').focus();
- },0
- );
- } else {
- append_to_list();
- }
- } else {
- append_to_list();
- }
+ JSAN.use('util.barcode');
+ if ( ($('strict_i_barcode').checked) && (! util.barcode.check($('i_barcode').value)) ) {
+ var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
+ if (r == 1) {
+ setTimeout(
+ function() {
+ $('i_barcode').value = '';
+ $('i_barcode').focus();
+ },0
+ );
+ } else {
+ append_to_list();
+ }
+ } else {
+ append_to_list();
+ }
}
function append_to_list() {
- try {
+ try {
- JSAN.use('util.date');
+ JSAN.use('util.date');
- var my = {};
+ var my = {};
- my.type = 'in_house_use';
- my.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
- /* I18N to-do: enable localized date formats */
- my.use_time = util.date.formatted_date(new Date(),"%F %H:%M:%s");
+ my.type = 'in_house_use';
+ my.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
+ /* I18N to-do: enable localized date formats */
+ my.use_time = util.date.formatted_date(new Date(),"%F %H:%M:%s");
- var i_barcode = $('i_barcode').value;
- if (! i_barcode) return;
- my.barcode = i_barcode;
+ var i_barcode = $('i_barcode').value;
+ if (! i_barcode) return;
+ my.barcode = i_barcode;
- var count = $('count').value;
- if (!Number(count) || count < 1) count = 1;
- my.count = count;
+ var count = $('count').value;
+ if (!Number(count) || count < 1) count = 1;
+ my.count = count;
- g.list.append( { 'row' : { 'my' : my }, 'to_top' : true } );
+ g.list.append( { 'row' : { 'my' : my }, 'to_top' : true } );
- var x = $('i_barcode'); x.value = ''; x.focus();
+ var x = $('i_barcode'); x.value = ''; x.focus();
- } catch(E) {
+ } catch(E) {
- dump(E+'\n'); alert(E);
+ dump(E+'\n'); alert(E);
- }
+ }
}
function next_patron() {
- try {
- JSAN.use('util.file'); var file = new util.file('pending_xacts');
- var rows = g.list.dump_with_keys();
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i]; row.delta = g.delta;
- file.append_object(row);
- }
- file.close();
-
- if ($('print_receipt').checked) {
- try {
- var params = {
- 'template' : 'offline_inhouse_use',
+ try {
+ JSAN.use('util.file'); var file = new util.file('pending_xacts');
+ var rows = g.list.dump_with_keys();
+ for (var i = 0; i < rows.length; i++) {
+ var row = rows[i]; row.delta = g.delta;
+ file.append_object(row);
+ }
+ file.close();
+
+ if ($('print_receipt').checked) {
+ try {
+ var params = {
+ 'template' : 'offline_inhouse_use',
'callback' : function() {
g.list.clear();
var x = $('i_barcode'); x.value = ''; x.focus();
}
- };
- g.list.print( params );
- } catch(E) {
- g.error.sdump('D_ERROR','print: ' + E);
- alert('print: ' + E);
- }
- } else {
+ };
+ g.list.print( params );
+ } catch(E) {
+ g.error.sdump('D_ERROR','print: ' + E);
+ alert('print: ' + E);
+ }
+ } else {
g.list.clear();
var x = $('i_barcode'); x.value = ''; x.focus();
}
- } catch(E) {
- dump(E+'\n'); alert(E);
- }
+ } catch(E) {
+ dump(E+'\n'); alert(E);
+ }
}
var offlineStrings;
function my_init() {
- try {
- offlineStrings = $('offlineStrings');
-
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (typeof JSAN == 'undefined') { throw(offlineStrings.getString('common.jsan.missing')); }
- JSAN.errorLevel = "die"; // none, warn, or die
- JSAN.addRepository('..');
- JSAN.use('util.error'); g.error = new util.error();
- g.error.sdump('D_TRACE','my_init() for offline_register.xul');
-
- JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
-
- if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
- try { window.xulG.set_tab_name(offlineStrings.getString('circ.standalone')); } catch(E) { alert(E); }
- }
-
- $('barcode').addEventListener('change',test_patron,false);
- $('barcode').addEventListener('keypress',handle_keypress,false);
- $('submit').addEventListener('command',next_patron,false);
-
- JSAN.use('util.file');
- JSAN.use('util.widgets');
-
- var file; var list_data; var ml; var errors = '';
-
- file = new util.file('offline_ou_list');
- if (file._file.exists()) {
- list_data = file.get_object(); file.close();
- ml = util.widgets.make_menulist( list_data[0], list_data[1] );
- ml.setAttribute('id','home_ou'); $('x_home_ou').appendChild(ml);
- } else {
- errors += offlineStrings.getString('circ.offline_register.missing.library.list') + "\n";
- }
-
- file = new util.file('offline_pgt_list');
- if (file._file.exists()) {
- list_data = file.get_object(); file.close();
- ml = util.widgets.make_menulist( list_data[0], list_data[1] );
- ml.setAttribute('id','profile'); $('x_profile').appendChild(ml);
- } else {
- errors += offlineStrings.getString('circ.offline_register.missing.profile.list') + "\n";
- }
-
- file = new util.file('offline_cit_list');
- if (file._file.exists()) {
- list_data = file.get_object(); file.close();
- ml = util.widgets.make_menulist( list_data[0], list_data[1] );
- ml.setAttribute('id','ident_type'); $('x_ident_type').appendChild(ml);
- } else {
- errors += offlineStrings.getString('circ.offline_register.missing.id.type.list') + "\n";
- }
-
- file = new util.file('offline_asv_list');
- if (file._file.exists()) {
- list_data = file.get_object(); file.close();
- render_surveys('x_surveys', list_data);
- } else {
- errors += offlineStrings.getString('circ.offline_register.missing.required.surveys');
- }
-
- if (errors != '') {
- alert(offlineStrings.getString('circ.offline_register.missing.files.error') + errors);
- location.href = 'about:blank';
- }
-
- $('passwd').value = parseInt(Math.random()*8999+1000);
-
- $('dob').addEventListener('change',handle_check_date,false);
- $('barcode').focus();
-
- var file = new util.file('offline_delta');
- if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
-
- } catch(E) {
- var err_msg = offlineStrings.getFormattedString('common.exception', ["circ/offline_register.xul", E]);
- try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
- alert(err_msg);
- }
+ try {
+ offlineStrings = $('offlineStrings');
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw(offlineStrings.getString('common.jsan.missing')); }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+ JSAN.use('util.error'); g.error = new util.error();
+ g.error.sdump('D_TRACE','my_init() for offline_register.xul');
+
+ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name(offlineStrings.getString('circ.standalone')); } catch(E) { alert(E); }
+ }
+
+ $('barcode').addEventListener('change',test_patron,false);
+ $('barcode').addEventListener('keypress',handle_keypress,false);
+ $('submit').addEventListener('command',next_patron,false);
+
+ JSAN.use('util.file');
+ JSAN.use('util.widgets');
+
+ var file; var list_data; var ml; var errors = '';
+
+ file = new util.file('offline_ou_list');
+ if (file._file.exists()) {
+ list_data = file.get_object(); file.close();
+ ml = util.widgets.make_menulist( list_data[0], list_data[1] );
+ ml.setAttribute('id','home_ou'); $('x_home_ou').appendChild(ml);
+ } else {
+ errors += offlineStrings.getString('circ.offline_register.missing.library.list') + "\n";
+ }
+
+ file = new util.file('offline_pgt_list');
+ if (file._file.exists()) {
+ list_data = file.get_object(); file.close();
+ ml = util.widgets.make_menulist( list_data[0], list_data[1] );
+ ml.setAttribute('id','profile'); $('x_profile').appendChild(ml);
+ } else {
+ errors += offlineStrings.getString('circ.offline_register.missing.profile.list') + "\n";
+ }
+
+ file = new util.file('offline_cit_list');
+ if (file._file.exists()) {
+ list_data = file.get_object(); file.close();
+ ml = util.widgets.make_menulist( list_data[0], list_data[1] );
+ ml.setAttribute('id','ident_type'); $('x_ident_type').appendChild(ml);
+ } else {
+ errors += offlineStrings.getString('circ.offline_register.missing.id.type.list') + "\n";
+ }
+
+ file = new util.file('offline_asv_list');
+ if (file._file.exists()) {
+ list_data = file.get_object(); file.close();
+ render_surveys('x_surveys', list_data);
+ } else {
+ errors += offlineStrings.getString('circ.offline_register.missing.required.surveys');
+ }
+
+ if (errors != '') {
+ alert(offlineStrings.getString('circ.offline_register.missing.files.error') + errors);
+ location.href = 'about:blank';
+ }
+
+ $('passwd').value = parseInt(Math.random()*8999+1000);
+
+ $('dob').addEventListener('change',handle_check_date,false);
+ $('barcode').focus();
+
+ var file = new util.file('offline_delta');
+ if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
+
+ } catch(E) {
+ var err_msg = offlineStrings.getFormattedString('common.exception', ["circ/offline_register.xul", E]);
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+ alert(err_msg);
+ }
}
function $(id) { return document.getElementById(id); }
function test_patron(ev) {
- try {
- var barcode = ev.target.value;
- JSAN.use('util.barcode');
- if ( ! util.barcode.check(ev.target.value) ) {
- var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
- if (r == 1) {
- setTimeout(
- function() {
- ev.target.value = '';
- ev.target.focus();
- },0
- );
- }
-
- }
- if (g.data.bad_patrons[barcode]) {
- var code;
- switch(g.data.bad_patrons[barcode]) {
- case 'L' : code = offlineStrings.getString('common.barcode.status.warning.lost'); break;
- case 'E' : code = offlineStrings.getString('common.barcode.status.warning.expired'); break;
- case 'B' : code = offlineStrings.getString('common.barcode.status.warning.barred'); break;
- case 'D' : code = offlineStrings.getString('common.barcode.status.warning.blocked'); break;
- default : code = offlineStrings.getFormattedString('common.barcode.status.warning.blocked', [g.data.bad_patrons[barcode]]); break;
- }
-
- var msg = offlineStrings.getFormattedString('common.barcode.status.warning', [g.data.bad_patrons_date.substr(0,15), barcode, code]);
- var r = g.error.yns_alert(msg,offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
- if (r == 1) {
- setTimeout(
- function() {
- ev.target.value = '';
- ev.target.focus();
- },0
- );
- }
- }
- } catch(E) {
- alert(E);
- }
+ try {
+ var barcode = ev.target.value;
+ JSAN.use('util.barcode');
+ if ( ! util.barcode.check(ev.target.value) ) {
+ var r = g.error.yns_alert(offlineStrings.getString('circ.bad_checkdigit'),offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
+ if (r == 1) {
+ setTimeout(
+ function() {
+ ev.target.value = '';
+ ev.target.focus();
+ },0
+ );
+ }
+
+ }
+ if (g.data.bad_patrons[barcode]) {
+ var code;
+ switch(g.data.bad_patrons[barcode]) {
+ case 'L' : code = offlineStrings.getString('common.barcode.status.warning.lost'); break;
+ case 'E' : code = offlineStrings.getString('common.barcode.status.warning.expired'); break;
+ case 'B' : code = offlineStrings.getString('common.barcode.status.warning.barred'); break;
+ case 'D' : code = offlineStrings.getString('common.barcode.status.warning.blocked'); break;
+ default : code = offlineStrings.getFormattedString('common.barcode.status.warning.blocked', [g.data.bad_patrons[barcode]]); break;
+ }
+
+ var msg = offlineStrings.getFormattedString('common.barcode.status.warning', [g.data.bad_patrons_date.substr(0,15), barcode, code]);
+ var r = g.error.yns_alert(msg,offlineStrings.getString('circ.barcode.warning'),offlineStrings.getString('common.ok'),offlineStrings.getString('common.clear'),null,offlineStrings.getString('common.confirm'));
+ if (r == 1) {
+ setTimeout(
+ function() {
+ ev.target.value = '';
+ ev.target.focus();
+ },0
+ );
+ }
+ }
+ } catch(E) {
+ alert(E);
+ }
}
function handle_check_date(ev) {
- ev.target.value = check_date(ev.target.value);
+ ev.target.value = check_date(ev.target.value);
}
function check_date(value) {
- JSAN.use('util.date');
- try {
- if (! util.date.check('YYYY-MM-DD',value) ) { throw(offlineStrings.getString('common.date.invalid')); }
- if (! util.date.check_past('YYYY-MM-DD',value) ) { throw(offlineStrings.getString('circ.offline_register.future.birth.date')); }
- if ( util.date.formatted_date(new Date(),'%F') == value) { throw(offlineStrings.getString('circ.offline_register.invalid.birth.date')); }
- } catch(E) {
- alert(E);
- value = '';
- }
- return value;
+ JSAN.use('util.date');
+ try {
+ if (! util.date.check('YYYY-MM-DD',value) ) { throw(offlineStrings.getString('common.date.invalid')); }
+ if (! util.date.check_past('YYYY-MM-DD',value) ) { throw(offlineStrings.getString('circ.offline_register.future.birth.date')); }
+ if ( util.date.formatted_date(new Date(),'%F') == value) { throw(offlineStrings.getString('circ.offline_register.invalid.birth.date')); }
+ } catch(E) {
+ alert(E);
+ value = '';
+ }
+ return value;
}
function render_surveys(node,obj) {
- node = util.widgets.get(node);
- util.widgets.remove_children(node);
-
- for (var i in obj) {
- var survey = obj[i];
- var x_gb = document.createElement('groupbox'); node.appendChild(x_gb);
- var x_cp = document.createElement('caption');
- x_cp.setAttribute('label',i); x_gb.appendChild(x_cp);
- var x_d = document.createElement('description');
- x_d.appendChild( document.createTextNode( survey.description ) ); x_gb.appendChild(x_d);
- for (var j = 0; j < survey.questions.length; j++) {
- var question = survey.questions[j];
- var x_d = document.createElement('description');
- x_d.appendChild( document.createTextNode( (j+1) + ') ' + question.question ) );
- x_gb.appendChild( x_d );
- var x_hb = document.createElement('hbox'); x_hb.setAttribute('flex','1');
- x_gb.appendChild(x_hb);
- var x_spacer = document.createElement('spacer'); x_spacer.setAttribute('flex','1');
- x_hb.appendChild(x_spacer);
- var x_ml = util.widgets.make_menulist( [ [offlineStrings.getString('circ.offline_register.survey.prompt'),''] ].concat(question.answers) );
- x_ml.setAttribute('name','survey'); x_hb.appendChild(x_ml);
- }
- }
+ node = util.widgets.get(node);
+ util.widgets.remove_children(node);
+
+ for (var i in obj) {
+ var survey = obj[i];
+ var x_gb = document.createElement('groupbox'); node.appendChild(x_gb);
+ var x_cp = document.createElement('caption');
+ x_cp.setAttribute('label',i); x_gb.appendChild(x_cp);
+ var x_d = document.createElement('description');
+ x_d.appendChild( document.createTextNode( survey.description ) ); x_gb.appendChild(x_d);
+ for (var j = 0; j < survey.questions.length; j++) {
+ var question = survey.questions[j];
+ var x_d = document.createElement('description');
+ x_d.appendChild( document.createTextNode( (j+1) + ') ' + question.question ) );
+ x_gb.appendChild( x_d );
+ var x_hb = document.createElement('hbox'); x_hb.setAttribute('flex','1');
+ x_gb.appendChild(x_hb);
+ var x_spacer = document.createElement('spacer'); x_spacer.setAttribute('flex','1');
+ x_hb.appendChild(x_spacer);
+ var x_ml = util.widgets.make_menulist( [ [offlineStrings.getString('circ.offline_register.survey.prompt'),''] ].concat(question.answers) );
+ x_ml.setAttribute('name','survey'); x_hb.appendChild(x_ml);
+ }
+ }
}
function handle_keypress(ev) {
- if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
- switch(ev.target) {
- case $('barcode') : setTimeout( function() { $('family_name').focus(); },0 ); break;
- default: break;
- }
+ if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
+ switch(ev.target) {
+ case $('barcode') : setTimeout( function() { $('family_name').focus(); },0 ); break;
+ default: break;
+ }
}
function check_patron(obj) {
- var errors = '';
- if (! obj.user.billing_address.post_code ) {
- errors += offlineStrings.getString('circ.offline_register.missing.post_code') + "\n";
- $('post_code').focus();
- $('post_code').parentNode.setAttribute('style','background-color: red');
- } else {
- $('post_code').parentNode.setAttribute('style','');
- }
- if (! obj.user.billing_address.state ) {
- errors += offlineStrings.getString('circ.offline_register.missing.state') + "\n";
- $('state').focus();
- $('state').parentNode.setAttribute('style','background-color: red');
- } else {
- $('state').parentNode.setAttribute('style','');
- }
- if (! obj.user.billing_address.city ) {
- errors += offlineStrings.getString('circ.offline_register.missing.city') + "\n";
- $('city').focus();
- $('city').parentNode.setAttribute('style','background-color: red');
- } else {
- $('city').parentNode.setAttribute('style','');
- }
- if (! obj.user.billing_address.street1 ) {
- errors += offlineStrings.getString('circ.offline_register.missing.street1') + "\n";
- $('street1').focus();
- $('street1').parentNode.setAttribute('style','background-color: red');
- } else {
- $('street1').parentNode.setAttribute('style','');
- }
- if (! obj.user.ident_value ) {
- errors += offlineStrings.getString('circ.offline_register.missing.ident_value') + "\n";
- $('ident_value').focus();
- $('ident_value').parentNode.setAttribute('style','background-color: red');
- } else {
- $('ident_value').parentNode.setAttribute('style','');
- }
- if (! obj.user.ident_type ) {
- errors += offlineStrings.getString('circ.offline_register.missing.ident_type') + "\n";
- $('ident_type').focus();
- $('ident_type').parentNode.setAttribute('style','background-color: red');
- } else {
- $('ident_type').parentNode.setAttribute('style','');
- }
- if (! obj.user.dob ) {
- errors += offlineStrings.getString('circ.offline_register.missing.dob') + "\n";
- $('dob').focus();
- $('dob').parentNode.parentNode.setAttribute('style','background-color: red');
- } else {
- $('dob').parentNode.parentNode.setAttribute('style','');
- }
- if (! obj.user.first_given_name ) {
- errors += offlineStrings.getString('circ.offline_register.missing.first_given_name') + "\n";
- $('first_given_name').focus();
- $('first_given_name').parentNode.setAttribute('style','background-color: red');
- } else {
- $('first_given_name').parentNode.setAttribute('style','');
- }
- if (! obj.user.family_name ) {
- errors += offlineStrings.getString('circ.offline_register.missing.family_name') + "\n";
- $('family_name').focus();
- $('family_name').parentNode.setAttribute('style','background-color: red');
- } else {
- $('family_name').parentNode.setAttribute('style','');
- }
- if (! obj.user.passwd ) {
- errors += offlineStrings.getString('circ.offline_register.missing.passwd') + "\n";
- $('passwd').focus();
- $('passwd').parentNode.setAttribute('style','background-color: red');
- } else {
- $('passwd').parentNode.setAttribute('style','');
- }
- if (! obj.user.card.barcode ) {
- errors += offlineStrings.getString('circ.offline_register.missing.barcode') + "\n";
- $('barcode').focus();
- $('barcode').parentNode.setAttribute('style','background-color: red');
- } else {
- $('barcode').parentNode.setAttribute('style','');
- }
- if (! obj.user.profile ) {
- errors += offlineStrings.getString('circ.offline_register.missing.profile') + "\n";
- $('profile').focus();
- $('profile').parentNode.setAttribute('style','background-color: red');
- } else {
- $('profile').parentNode.setAttribute('style','');
- }
- if (! obj.user.home_ou ) {
- errors += offlineStrings.getString('circ.offline_register.missing.home_ou') + "\n";
- $('home_ou').focus();
- $('home_ou').parentNode.setAttribute('style','background-color: red');
- } else {
- $('home_ou').parentNode.setAttribute('style','');
- }
- if (errors != '') throw(errors);
+ var errors = '';
+ if (! obj.user.billing_address.post_code ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.post_code') + "\n";
+ $('post_code').focus();
+ $('post_code').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('post_code').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.billing_address.state ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.state') + "\n";
+ $('state').focus();
+ $('state').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('state').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.billing_address.city ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.city') + "\n";
+ $('city').focus();
+ $('city').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('city').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.billing_address.street1 ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.street1') + "\n";
+ $('street1').focus();
+ $('street1').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('street1').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.ident_value ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.ident_value') + "\n";
+ $('ident_value').focus();
+ $('ident_value').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('ident_value').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.ident_type ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.ident_type') + "\n";
+ $('ident_type').focus();
+ $('ident_type').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('ident_type').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.dob ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.dob') + "\n";
+ $('dob').focus();
+ $('dob').parentNode.parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('dob').parentNode.parentNode.setAttribute('style','');
+ }
+ if (! obj.user.first_given_name ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.first_given_name') + "\n";
+ $('first_given_name').focus();
+ $('first_given_name').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('first_given_name').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.family_name ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.family_name') + "\n";
+ $('family_name').focus();
+ $('family_name').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('family_name').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.passwd ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.passwd') + "\n";
+ $('passwd').focus();
+ $('passwd').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('passwd').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.card.barcode ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.barcode') + "\n";
+ $('barcode').focus();
+ $('barcode').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('barcode').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.profile ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.profile') + "\n";
+ $('profile').focus();
+ $('profile').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('profile').parentNode.setAttribute('style','');
+ }
+ if (! obj.user.home_ou ) {
+ errors += offlineStrings.getString('circ.offline_register.missing.home_ou') + "\n";
+ $('home_ou').focus();
+ $('home_ou').parentNode.setAttribute('style','background-color: red');
+ } else {
+ $('home_ou').parentNode.setAttribute('style','');
+ }
+ if (errors != '') throw(errors);
}
function next_patron() {
- try {
- var obj = {}
- obj.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
- obj.type = 'register';
- obj.user = {};
- obj.user.card = { 'barcode' : $('barcode').value };
- obj.user.profile = $('profile').value;
- obj.user.passwd = $('passwd').value;
- obj.user.ident_type = $('ident_type').value;
- obj.user.ident_value = $('ident_value').value;
- obj.user.first_given_name = $('first_given_name').value;
- obj.user.family_name = $('family_name').value;
- obj.user.home_ou = $('home_ou').value;
- obj.user.dob = $('dob').value;
- obj.user.billing_address = {};
- obj.user.billing_address.street1 = $('street1').value;
- obj.user.billing_address.street2 = $('street2').value;
- obj.user.billing_address.city = $('city').value;
- obj.user.billing_address.state = $('state').value;
- obj.user.billing_address.country = $('country').value;
- obj.user.billing_address.post_code = $('post_code').value;
- obj.user.survey_responses = [];
-
- var nl = document.getElementsByAttribute('name','survey');
- for (var i = 0; i < nl.length; i++) {
- var value = nl[i].value; if (value == '') continue;
- var values = JSON2js( value );
- var response = { 'survey' : values[2], 'question' : values[1], 'answer' : values[0] };
- obj.user.survey_responses.push( response );
- }
-
- try {
- check_patron(obj);
- } catch(E) {
- alert(offlineStrings.getString('circ.offline_register.missing.alert') + "\n" + E);
- return;
- }
-
- JSAN.use('util.file'); var file = new util.file('pending_xacts');
- obj.delta = g.delta;
- file.append_object(obj);
- file.close();
-
- alert(offlineStrings.getString('circ.offline_register.patron.saved'));
-
- $('passwd').value = parseInt(Math.random()*8999+1000);
- $('barcode').value = ''; $('ident_value').value = ''; $('first_given_name').value = '';
- $('family_name').value = ''; $('dob').value = ''; $('street1').value = '';
- $('street2').value = '';
-
- file = new util.file('offline_asv_list'); var list_data = file.get_object(); file.close();
- render_surveys('x_surveys', list_data);
-
- $('barcode').focus();
-
- } catch(E) {
- dump(E+'\n'); alert(E);
- }
+ try {
+ var obj = {}
+ obj.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
+ obj.type = 'register';
+ obj.user = {};
+ obj.user.card = { 'barcode' : $('barcode').value };
+ obj.user.profile = $('profile').value;
+ obj.user.passwd = $('passwd').value;
+ obj.user.ident_type = $('ident_type').value;
+ obj.user.ident_value = $('ident_value').value;
+ obj.user.first_given_name = $('first_given_name').value;
+ obj.user.family_name = $('family_name').value;
+ obj.user.home_ou = $('home_ou').value;
+ obj.user.dob = $('dob').value;
+ obj.user.billing_address = {};
+ obj.user.billing_address.street1 = $('street1').value;
+ obj.user.billing_address.street2 = $('street2').value;
+ obj.user.billing_address.city = $('city').value;
+ obj.user.billing_address.state = $('state').value;
+ obj.user.billing_address.country = $('country').value;
+ obj.user.billing_address.post_code = $('post_code').value;
+ obj.user.survey_responses = [];
+
+ var nl = document.getElementsByAttribute('name','survey');
+ for (var i = 0; i < nl.length; i++) {
+ var value = nl[i].value; if (value == '') continue;
+ var values = JSON2js( value );
+ var response = { 'survey' : values[2], 'question' : values[1], 'answer' : values[0] };
+ obj.user.survey_responses.push( response );
+ }
+
+ try {
+ check_patron(obj);
+ } catch(E) {
+ alert(offlineStrings.getString('circ.offline_register.missing.alert') + "\n" + E);
+ return;
+ }
+
+ JSAN.use('util.file'); var file = new util.file('pending_xacts');
+ obj.delta = g.delta;
+ file.append_object(obj);
+ file.close();
+
+ alert(offlineStrings.getString('circ.offline_register.patron.saved'));
+
+ $('passwd').value = parseInt(Math.random()*8999+1000);
+ $('barcode').value = ''; $('ident_value').value = ''; $('first_given_name').value = '';
+ $('family_name').value = ''; $('dob').value = ''; $('street1').value = '';
+ $('street2').value = '';
+
+ file = new util.file('offline_asv_list'); var list_data = file.get_object(); file.close();
+ render_surveys('x_surveys', list_data);
+
+ $('barcode').focus();
+
+ } catch(E) {
+ dump(E+'\n'); alert(E);
+ }
}
var offlineStrings;
function my_init() {
- try {
- offlineStrings = $('offlineStrings');
- 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('..');
- JSAN.use('util.error'); g.error = new util.error();
- g.error.sdump('D_TRACE','my_init() for offline_renew.xul');
-
- if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
- try { window.xulG.set_tab_name('Standalone'); } catch(E) { alert(E); }
- }
-
- JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
-
- JSAN.use('util.list'); g.list = new util.list('checkout_list');
- JSAN.use('circ.util');
- g.list.init( {
- 'columns' : circ.util.offline_renew_columns(),
- 'map_row_to_column' : circ.util.std_map_row_to_column(),
- } );
-
- JSAN.use('util.date');
- var today = new Date();
- var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
- todayPlus = util.date.formatted_date(todayPlus,"%F");
-
- $('duedate').setAttribute('value',todayPlus);
- $('duedate').addEventListener('change',check_date,false);
-
- $('p_barcode').addEventListener('change',test_patron,false);
-
- $('p_barcode').addEventListener('keypress',handle_keypress,false);
- $('p_barcode').focus();
-
- $('i_barcode').addEventListener('keypress',handle_keypress,false);
- $('enter').addEventListener('command',handle_enter,false);
-
- $('duedate_menu').addEventListener('command',handle_duedate_menu,false);
-
- $('submit').addEventListener('command',next_patron,false);
- $('cancel').addEventListener('command',function(){next_patron('cancel');},false);
-
- JSAN.use('util.file');
- var file = new util.file('offline_delta');
- if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
-
- } catch(E) {
- var err_msg = "!! This software has encountered an error. Please tell your friendly " +
- "system administrator or software developer the following:\ncirc/offline_renew.xul\n" + E + '\n';
- try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
- alert(err_msg);
- }
+ try {
+ offlineStrings = $('offlineStrings');
+ 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('..');
+ JSAN.use('util.error'); g.error = new util.error();
+ g.error.sdump('D_TRACE','my_init() for offline_renew.xul');
+
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name('Standalone'); } catch(E) { alert(E); }
+ }
+
+ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+
+ JSAN.use('util.list'); g.list = new util.list('checkout_list');
+ JSAN.use('circ.util');
+ g.list.init( {
+ 'columns' : circ.util.offline_renew_columns(),
+ 'map_row_to_column' : circ.util.std_map_row_to_column(),
+ } );
+
+ JSAN.use('util.date');
+ var today = new Date();
+ var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
+ todayPlus = util.date.formatted_date(todayPlus,"%F");
+
+ $('duedate').setAttribute('value',todayPlus);
+ $('duedate').addEventListener('change',check_date,false);
+
+ $('p_barcode').addEventListener('change',test_patron,false);
+
+ $('p_barcode').addEventListener('keypress',handle_keypress,false);
+ $('p_barcode').focus();
+
+ $('i_barcode').addEventListener('keypress',handle_keypress,false);
+ $('enter').addEventListener('command',handle_enter,false);
+
+ $('duedate_menu').addEventListener('command',handle_duedate_menu,false);
+
+ $('submit').addEventListener('command',next_patron,false);
+ $('cancel').addEventListener('command',function(){next_patron('cancel');},false);
+
+ JSAN.use('util.file');
+ var file = new util.file('offline_delta');
+ if (file._file.exists()) { g.delta = file.get_object()[0]; file.close(); } else { g.delta = 0; }
+
+ } catch(E) {
+ var err_msg = "!! This software has encountered an error. Please tell your friendly " +
+ "system administrator or software developer the following:\ncirc/offline_renew.xul\n" + E + '\n';
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+ alert(err_msg);
+ }
}
function $(id) { return document.getElementById(id); }
function test_patron(ev) {
- try {
- var barcode = ev.target.value;
- JSAN.use('util.barcode');
- if ( ($('strict_p_barcode').checked) && (! util.barcode.check(barcode)) ) {
- var r = g.error.yns_alert('This barcode has a bad checkdigit.','Barcode Warning','Ok','Clear',null,'Check here to confirm this message');
- if (r == 1) {
- setTimeout(
- function() {
- ev.target.value = '';
- ev.target.focus();
- },0
- );
- }
-
- }
-
- if (g.data.bad_patrons[barcode]) {
- var msg = 'Warning: As of ' + g.data.bad_patrons_date.substr(0,15) + ', this barcode (' + barcode + ') was flagged ';
- switch(g.data.bad_patrons[barcode]) {
- case 'L' : msg += 'Lost'; break;
- case 'E' : msg += 'Expired'; break;
- case 'B' : msg += 'Barred'; break;
- case 'D' : msg += 'Blocked'; break;
- default : msg += ' with an unknown code: ' + g.data.bad_patrons[barcode]; break;
- }
- var r = g.error.yns_alert(msg,'Barcode Warning','Ok','Clear',null,'Check here to confirm this message');
- if (r == 1) {
- setTimeout(
- function() {
- ev.target.value = '';
- ev.target.focus();
- },0
- );
- }
- }
- } catch(E) {
- alert(E);
- }
+ try {
+ var barcode = ev.target.value;
+ JSAN.use('util.barcode');
+ if ( ($('strict_p_barcode').checked) && (! util.barcode.check(barcode)) ) {
+ var r = g.error.yns_alert('This barcode has a bad checkdigit.','Barcode Warning','Ok','Clear',null,'Check here to confirm this message');
+ if (r == 1) {
+ setTimeout(
+ function() {
+ ev.target.value = '';
+ ev.target.focus();
+ },0
+ );
+ }
+
+ }
+
+ if (g.data.bad_patrons[barcode]) {
+ var msg = 'Warning: As of ' + g.data.bad_patrons_date.substr(0,15) + ', this barcode (' + barcode + ') was flagged ';
+ switch(g.data.bad_patrons[barcode]) {
+ case 'L' : msg += 'Lost'; break;
+ case 'E' : msg += 'Expired'; break;
+ case 'B' : msg += 'Barred'; break;
+ case 'D' : msg += 'Blocked'; break;
+ default : msg += ' with an unknown code: ' + g.data.bad_patrons[barcode]; break;
+ }
+ var r = g.error.yns_alert(msg,'Barcode Warning','Ok','Clear',null,'Check here to confirm this message');
+ if (r == 1) {
+ setTimeout(
+ function() {
+ ev.target.value = '';
+ ev.target.focus();
+ },0
+ );
+ }
+ }
+ } catch(E) {
+ alert(E);
+ }
}
function handle_keypress(ev) {
- if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
- switch(ev.target) {
- case $('p_barcode') : setTimeout( function() { $('i_barcode').focus(); },0 ); break;
- case $('i_barcode') : handle_enter(); break;
- default: break;
- }
+ if ( (! ev.keyCode) || (ev.keyCode != 13) ) return;
+ switch(ev.target) {
+ case $('p_barcode') : setTimeout( function() { $('i_barcode').focus(); },0 ); break;
+ case $('i_barcode') : handle_enter(); break;
+ default: break;
+ }
}
function handle_enter(ev) {
- JSAN.use('util.barcode');
- if ( ($('strict_i_barcode').checked) && (! util.barcode.check($('i_barcode').value)) ) {
- var r = g.error.yns_alert('This barcode has a bad checkdigit.','Barcode Warning','Ok','Clear',null,'Check here to confirm this message');
- if (r == 1) {
- setTimeout(
- function() {
- ev.target.value = '';
- ev.target.focus();
- },0
- );
- } else {
- append_to_list('barcode');
- }
- } else {
- append_to_list('barcode');
- }
+ JSAN.use('util.barcode');
+ if ( ($('strict_i_barcode').checked) && (! util.barcode.check($('i_barcode').value)) ) {
+ var r = g.error.yns_alert('This barcode has a bad checkdigit.','Barcode Warning','Ok','Clear',null,'Check here to confirm this message');
+ if (r == 1) {
+ setTimeout(
+ function() {
+ ev.target.value = '';
+ ev.target.focus();
+ },0
+ );
+ } else {
+ append_to_list('barcode');
+ }
+ } else {
+ append_to_list('barcode');
+ }
}
function handle_duedate_menu(ev) {
- if (ev.target.value=='0') return;
- JSAN.use('util.date');
- var today = new Date();
- var todayPlus = new Date();
- todayPlus.setTime( today.getTime() + 24*60*60*1000*ev.target.value );
- todayPlus = util.date.formatted_date(todayPlus,'%F');
- $('duedate').setAttribute('value',todayPlus);
- $('duedate').value = todayPlus;
+ if (ev.target.value=='0') return;
+ JSAN.use('util.date');
+ var today = new Date();
+ var todayPlus = new Date();
+ todayPlus.setTime( today.getTime() + 24*60*60*1000*ev.target.value );
+ todayPlus = util.date.formatted_date(todayPlus,'%F');
+ $('duedate').setAttribute('value',todayPlus);
+ $('duedate').value = todayPlus;
}
function check_date(ev) {
- JSAN.use('util.date');
- try {
- if (! util.date.check('YYYY-MM-DD',ev.target.value) ) { throw('Invalid Date'); }
- if (util.date.check_past('YYYY-MM-DD',ev.target.value) ) { throw('Due date needs to be after today.'); }
- if ( util.date.formatted_date(new Date(),'%F') == ev.target.value) { throw('Due date needs to be after today.'); }
- } catch(E) {
- alert(E);
- var today = new Date();
- var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
- todayPlus = util.date.formatted_date(todayPlus,"%F");
- ev.target.value = todayPlus;
- }
+ JSAN.use('util.date');
+ try {
+ if (! util.date.check('YYYY-MM-DD',ev.target.value) ) { throw('Invalid Date'); }
+ if (util.date.check_past('YYYY-MM-DD',ev.target.value) ) { throw('Due date needs to be after today.'); }
+ if ( util.date.formatted_date(new Date(),'%F') == ev.target.value) { throw('Due date needs to be after today.'); }
+ } catch(E) {
+ alert(E);
+ var today = new Date();
+ var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
+ todayPlus = util.date.formatted_date(todayPlus,"%F");
+ ev.target.value = todayPlus;
+ }
}
function append_to_list(checkout_type,count) {
- try {
-
- var my = {};
-
- my.type = 'renew';
- my.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
- my.checkout_time = util.date.formatted_date(new Date(),"%F %H:%M:%s");
-
- var p_barcode = $('p_barcode').value;
- if (! p_barcode) {
- /* Not strictly necessary for a renewal
- alert('Please enter a patron barcode first.');
- return;
- */
- } else {
-
- // Need to validate patron barcode against bad patron list
- my.patron_barcode = p_barcode;
- }
-
- var due_date = $('duedate').value; // Need to validate this
- my.due_date = due_date;
-
- var i_barcode = $('i_barcode').value;
- switch(checkout_type) {
- case 'barcode' :
- if (! i_barcode) return;
-
- var rows = g.list.dump_with_keys();
- for (var i = 0; i < rows.length; i++) {
- if (rows[i].barcode == i_barcode) {
- g.error.yns_alert('This barcode has already been scanned.','Duplicate Scan','Ok',null,null,'Check here to confirm this message');
- return;
- }
- }
+ try {
+
+ var my = {};
+
+ my.type = 'renew';
+ my.timestamp = parseInt( new Date().getTime() / 1000) + g.delta;
+ my.checkout_time = util.date.formatted_date(new Date(),"%F %H:%M:%s");
+
+ var p_barcode = $('p_barcode').value;
+ if (! p_barcode) {
+ /* Not strictly necessary for a renewal
+ alert('Please enter a patron barcode first.');
+ return;
+ */
+ } else {
+
+ // Need to validate patron barcode against bad patron list
+ my.patron_barcode = p_barcode;
+ }
+
+ var due_date = $('duedate').value; // Need to validate this
+ my.due_date = due_date;
+
+ var i_barcode = $('i_barcode').value;
+ switch(checkout_type) {
+ case 'barcode' :
+ if (! i_barcode) return;
+
+ var rows = g.list.dump_with_keys();
+ for (var i = 0; i < rows.length; i++) {
+ if (rows[i].barcode == i_barcode) {
+ g.error.yns_alert('This barcode has already been scanned.','Duplicate Scan','Ok',null,null,'Check here to confirm this message');
+ return;
+ }
+ }
- my.barcode = i_barcode;
- break;
- default: alert("Please report that this happened."); break;
- }
-
- g.list.append( { 'row' : { 'my' : my }, 'to_top' : true } );
+ my.barcode = i_barcode;
+ break;
+ default: alert("Please report that this happened."); break;
+ }
+
+ g.list.append( { 'row' : { 'my' : my }, 'to_top' : true } );
- var x = $('i_barcode'); x.value = ''; x.focus();
+ var x = $('i_barcode'); x.value = ''; x.focus();
- } catch(E) {
+ } catch(E) {
- dump(E+'\n'); alert(E);
+ dump(E+'\n'); alert(E);
- }
+ }
}
function next_patron(cancel) {
- try {
-
- if (cancel!='cancel') {
- JSAN.use('util.file'); var file = new util.file('pending_xacts');
- var rows = g.list.dump_with_keys();
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i]; row.delta = g.delta;
- if (row.patron_barcode == '') {
- delete(row.patron_barcode);
- }
- file.append_object(row);
- }
- file.close();
-
- if ($('print_receipt').checked) {
- try {
- var params = {
- 'patron_barcode' : $('p_barcode').value,
- 'template' : 'offline_renew',
+ try {
+
+ if (cancel!='cancel') {
+ JSAN.use('util.file'); var file = new util.file('pending_xacts');
+ var rows = g.list.dump_with_keys();
+ for (var i = 0; i < rows.length; i++) {
+ var row = rows[i]; row.delta = g.delta;
+ if (row.patron_barcode == '') {
+ delete(row.patron_barcode);
+ }
+ file.append_object(row);
+ }
+ file.close();
+
+ if ($('print_receipt').checked) {
+ try {
+ var params = {
+ 'patron_barcode' : $('p_barcode').value,
+ 'template' : 'offline_renew',
'callback' : function() {
g.list.clear();
var x = $('i_barcode'); x.value = '';
x = $('p_barcode'); x.value = ''; x.focus();
}
- };
- g.list.print( params );
- } catch(E) {
- g.error.sdump('D_ERROR','print: ' + E);
- alert('print: ' + E);
- }
- } else {
+ };
+ g.list.print( params );
+ } catch(E) {
+ g.error.sdump('D_ERROR','print: ' + E);
+ alert('print: ' + E);
+ }
+ } else {
g.list.clear();
var x = $('i_barcode'); x.value = '';
x = $('p_barcode'); x.value = ''; x.focus();
}
- }
- } catch(E) {
- dump(E+'\n'); alert(E);
- }
+ }
+ } catch(E) {
+ dump(E+'\n'); alert(E);
+ }
}
if (typeof circ == 'undefined') var circ = {};
circ.util = {};
-circ.util.EXPORT_OK = [
- 'offline_checkout_columns',
- 'offline_checkin_columns',
- 'offline_renew_columns',
- 'offline_inhouse_use_columns',
- 'hold_columns', 'CHECKIN_VIA_BARCODE', 'std_map_row_to_column', 'hold_capture_via_copy_barcode'
+circ.util.EXPORT_OK = [
+ 'offline_checkout_columns',
+ 'offline_checkin_columns',
+ 'offline_renew_columns',
+ 'offline_inhouse_use_columns',
+ 'hold_columns', 'CHECKIN_VIA_BARCODE', 'std_map_row_to_column', 'hold_capture_via_copy_barcode'
];
-circ.util.EXPORT_TAGS = { ':all' : circ.util.EXPORT_OK };
+circ.util.EXPORT_TAGS = { ':all' : circ.util.EXPORT_OK };
circ.util.offline_checkout_columns = function(modify,params) {
-
- var c = [
- {
- 'id' : 'timestamp',
- 'label' : 'Timestamp',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.timestamp'
- },
- {
- 'id' : 'checkout_time',
- 'label' : 'Check Out Time',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.checkout_time'
- },
- {
- 'id' : 'type',
- 'label' : 'Transaction Type',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.type'
- },
- {
- 'id' : 'noncat',
- 'label' : 'Non-Cataloged?',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.noncat'
- },
- {
- 'id' : 'noncat_type',
- 'label' : 'Non-Cat Type ID',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.noncat_type'
- },
- {
- 'id' : 'noncat_count',
- 'label' : 'Count',
- 'flex' : 1, 'primary' : false, 'hidden' : false,
- 'render' : 'my.noncat_count'
- },
- {
- 'id' : 'patron_barcode',
- 'label' : 'Patron Barcode',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.patron_barcode'
- },
- {
- 'id' : 'barcode',
- 'label' : 'Item Barcode',
- 'flex' : 2, 'primary' : true, 'hidden' : false,
- 'render' : 'my.barcode'
- },
- {
- 'id' : 'due_date',
- 'label' : 'Due Date',
- 'flex' : 1, 'primary' : false, 'hidden' : false,
- 'render' : 'my.due_date'
- },
- ];
- if (modify) for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- return new_c;
- }
- }
- return c;
+
+ var c = [
+ {
+ 'id' : 'timestamp',
+ 'label' : 'Timestamp',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.timestamp'
+ },
+ {
+ 'id' : 'checkout_time',
+ 'label' : 'Check Out Time',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.checkout_time'
+ },
+ {
+ 'id' : 'type',
+ 'label' : 'Transaction Type',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.type'
+ },
+ {
+ 'id' : 'noncat',
+ 'label' : 'Non-Cataloged?',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.noncat'
+ },
+ {
+ 'id' : 'noncat_type',
+ 'label' : 'Non-Cat Type ID',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.noncat_type'
+ },
+ {
+ 'id' : 'noncat_count',
+ 'label' : 'Count',
+ 'flex' : 1, 'primary' : false, 'hidden' : false,
+ 'render' : 'my.noncat_count'
+ },
+ {
+ 'id' : 'patron_barcode',
+ 'label' : 'Patron Barcode',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.patron_barcode'
+ },
+ {
+ 'id' : 'barcode',
+ 'label' : 'Item Barcode',
+ 'flex' : 2, 'primary' : true, 'hidden' : false,
+ 'render' : 'my.barcode'
+ },
+ {
+ 'id' : 'due_date',
+ 'label' : 'Due Date',
+ 'flex' : 1, 'primary' : false, 'hidden' : false,
+ 'render' : 'my.due_date'
+ },
+ ];
+ if (modify) for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ return new_c;
+ }
+ }
+ return c;
}
circ.util.offline_checkin_columns = function(modify,params) {
-
- var c = [
- {
- 'id' : 'timestamp',
- 'label' : 'Timestamp',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.timestamp'
- },
- {
- 'id' : 'backdate',
- 'label' : 'Back Date',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.backdate'
- },
- {
- 'id' : 'type',
- 'label' : 'Transaction Type',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.type'
- },
- {
- 'id' : 'barcode',
- 'label' : 'Item Barcode',
- 'flex' : 2, 'primary' : true, 'hidden' : false,
- 'render' : 'my.barcode'
- },
- ];
- if (modify) for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- return new_c;
- }
- }
- return c;
+
+ var c = [
+ {
+ 'id' : 'timestamp',
+ 'label' : 'Timestamp',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.timestamp'
+ },
+ {
+ 'id' : 'backdate',
+ 'label' : 'Back Date',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.backdate'
+ },
+ {
+ 'id' : 'type',
+ 'label' : 'Transaction Type',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.type'
+ },
+ {
+ 'id' : 'barcode',
+ 'label' : 'Item Barcode',
+ 'flex' : 2, 'primary' : true, 'hidden' : false,
+ 'render' : 'my.barcode'
+ },
+ ];
+ if (modify) for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ return new_c;
+ }
+ }
+ return c;
}
circ.util.offline_renew_columns = function(modify,params) {
-
- var c = [
- {
- 'id' : 'timestamp',
- 'label' : 'Timestamp',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.timestamp'
- },
- {
- 'id' : 'checkout_time',
- 'label' : 'Check Out Time',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.checkout_time'
- },
- {
- 'id' : 'type',
- 'label' : 'Transaction Type',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.type'
- },
- {
- 'id' : 'patron_barcode',
- 'label' : 'Patron Barcode',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.patron_barcode'
- },
- {
- 'id' : 'barcode',
- 'label' : 'Item Barcode',
- 'flex' : 2, 'primary' : true, 'hidden' : false,
- 'render' : 'my.barcode'
- },
- {
- 'id' : 'due_date',
- 'label' : 'Due Date',
- 'flex' : 1, 'primary' : false, 'hidden' : false,
- 'render' : 'my.due_date'
- },
- ];
- if (modify) for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- return new_c;
- }
- }
- return c;
+
+ var c = [
+ {
+ 'id' : 'timestamp',
+ 'label' : 'Timestamp',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.timestamp'
+ },
+ {
+ 'id' : 'checkout_time',
+ 'label' : 'Check Out Time',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.checkout_time'
+ },
+ {
+ 'id' : 'type',
+ 'label' : 'Transaction Type',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.type'
+ },
+ {
+ 'id' : 'patron_barcode',
+ 'label' : 'Patron Barcode',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.patron_barcode'
+ },
+ {
+ 'id' : 'barcode',
+ 'label' : 'Item Barcode',
+ 'flex' : 2, 'primary' : true, 'hidden' : false,
+ 'render' : 'my.barcode'
+ },
+ {
+ 'id' : 'due_date',
+ 'label' : 'Due Date',
+ 'flex' : 1, 'primary' : false, 'hidden' : false,
+ 'render' : 'my.due_date'
+ },
+ ];
+ if (modify) for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ return new_c;
+ }
+ }
+ return c;
}
circ.util.offline_inhouse_use_columns = function(modify,params) {
-
- var c = [
- {
- 'id' : 'timestamp',
- 'label' : 'Timestamp',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.timestamp'
- },
- {
- 'id' : 'use_time',
- 'label' : 'Use Time',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.use_time'
- },
- {
- 'id' : 'type',
- 'label' : 'Transaction Type',
- 'flex' : 1, 'primary' : false, 'hidden' : true,
- 'render' : 'my.type'
- },
- {
- 'id' : 'count',
- 'label' : 'Count',
- 'flex' : 1, 'primary' : false, 'hidden' : false,
- 'render' : 'my.count'
- },
- {
- 'id' : 'barcode',
- 'label' : 'Item Barcode',
- 'flex' : 2, 'primary' : true, 'hidden' : false,
- 'render' : 'my.barcode'
- },
- ];
- if (modify) for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- return new_c;
- }
- }
- return c;
+
+ var c = [
+ {
+ 'id' : 'timestamp',
+ 'label' : 'Timestamp',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.timestamp'
+ },
+ {
+ 'id' : 'use_time',
+ 'label' : 'Use Time',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.use_time'
+ },
+ {
+ 'id' : 'type',
+ 'label' : 'Transaction Type',
+ 'flex' : 1, 'primary' : false, 'hidden' : true,
+ 'render' : 'my.type'
+ },
+ {
+ 'id' : 'count',
+ 'label' : 'Count',
+ 'flex' : 1, 'primary' : false, 'hidden' : false,
+ 'render' : 'my.count'
+ },
+ {
+ 'id' : 'barcode',
+ 'label' : 'Item Barcode',
+ 'flex' : 2, 'primary' : true, 'hidden' : false,
+ 'render' : 'my.barcode'
+ },
+ ];
+ if (modify) for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ return new_c;
+ }
+ }
+ return c;
}
circ.util.std_map_row_to_column = function(error_value) {
- return function(row,col) {
- // row contains { 'my' : { 'barcode' : xxx, 'duedate' : xxx } }
- // col contains one of the objects listed above in columns
+ return function(row,col) {
+ // row contains { 'my' : { 'barcode' : xxx, 'duedate' : xxx } }
+ // col contains one of the objects listed above in columns
- var my = row.my;
- var value;
- try {
- value = eval( col.render );
- if (typeof value == 'undefined') value = '';
+ var my = row.my;
+ var value;
+ try {
+ value = eval( col.render );
+ if (typeof value == 'undefined') value = '';
- } catch(E) {
- JSAN.use('util.error'); var error = new util.error();
- error.sdump('D_WARN','map_row_to_column: ' + E);
- if (error_value) value = error_value; else value = '???';
- }
- return value;
- }
+ } catch(E) {
+ JSAN.use('util.error'); var error = new util.error();
+ error.sdump('D_WARN','map_row_to_column: ' + E);
+ if (error_value) value = error_value; else value = '???';
+ }
+ return value;
+ }
}
/* Get locale from preferences */
var LOCALE = '';
try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
- LOCALE = pref.getCharPref('general.useragent.locale');
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+ LOCALE = pref.getCharPref('general.useragent.locale');
} catch (E) {
- dump("Failed to fetch a locale from preferences: " + E + "\n");
+ dump("Failed to fetch a locale from preferences: " + E + "\n");
}
/* Fall back to en-US if we didn't get a locale from the preferences */
if (!LOCALE) {
- LOCALE = 'en-US';
+ LOCALE = 'en-US';
}
const MODE_RDONLY = 0x01;
const PERMS_DIR = 0755;
const my_constants = {
- 'magical_statuses' : {
- '1' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | Checked out | t */
- '3' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | Lost | f */
- '6' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | In transit | t */
- '8' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : false } /* | On holds shelf | t */
- }
+ 'magical_statuses' : {
+ '1' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | Checked out | t */
+ '3' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | Lost | f */
+ '6' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : true }, /* | In transit | t */
+ '8' : { 'disable_in_copy_editor' : true, 'block_mark_item_damaged' : false, 'block_mark_item_action' : false } /* | On holds shelf | t */
+ }
}
const api = {
'PCRUD_XACT_BEGIN' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.transaction.begin' },
'PCRUD_XACT_COMMIT' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.transaction.commit' },
'PCRUD_XACT_ROLLBACK' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.transaction.rollback' },
- 'TEST_SECURE' : { 'app' : 'open-ils.actor', 'method' : 'opensrf.system.time' },
- 'TEST_UNSECURE' : { 'app' : 'open-ils.actor', 'method' : 'opensrf.system.time', 'secure' : false },
- 'AUTH_INIT' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.init' },
- 'AUTH_COMPLETE' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.complete' },
- 'AUTH_DELETE' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.session.delete' },
- 'AUTH_WORKSTATION' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.workstation.register' },
- 'AUTH_VERIFY_CREDENTIALS' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.verify_user_password' },
- 'BILL_PAY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment' },
- 'BLOB_AU_PARTS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve.parts', 'cacheable' : true, 'ttl' : 120000 },
- 'BLOB_MARC_CALLNUMBERS_RETRIEVE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.marc_cn.retrieve', 'secure' : false },
+ 'TEST_SECURE' : { 'app' : 'open-ils.actor', 'method' : 'opensrf.system.time' },
+ 'TEST_UNSECURE' : { 'app' : 'open-ils.actor', 'method' : 'opensrf.system.time', 'secure' : false },
+ 'AUTH_INIT' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.init' },
+ 'AUTH_COMPLETE' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.authenticate.complete' },
+ 'AUTH_DELETE' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.session.delete' },
+ 'AUTH_WORKSTATION' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.workstation.register' },
+ 'AUTH_VERIFY_CREDENTIALS' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.verify_user_password' },
+ 'BILL_PAY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment' },
+ 'BLOB_AU_PARTS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve.parts', 'cacheable' : true, 'ttl' : 120000 },
+ 'BLOB_MARC_CALLNUMBERS_RETRIEVE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.marc_cn.retrieve', 'secure' : false },
'BLOB_MBTS_DETAILS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transaction.fleshed.retrieve', 'secure' : false },
- 'BLOB_MOBTS_CIRC_MVR_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance.fleshed' },
- 'BLOB_MOBTS_CIRC_MVR_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.fleshed' },
- 'BUCKET_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.create' },
- 'BUCKET_FLESH' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.flesh' },
- 'BUCKET_DELETE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.full_delete' },
- 'BUCKET_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.all.retrieve_by_user' },
- 'BUCKET_ITEM_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.item.create' },
- 'BUCKET_ITEM_DELETE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.item.delete' },
- 'CAPTURE_COPY_FOR_HOLD_VIA_BARCODE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.capture_copy.barcode' },
- 'CHECKIN_VIA_BARCODE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.checkin' },
- 'CHECKOUT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.checkout' },
- 'CHECKOUT_FULL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.checkout.full' },
- 'CHECKOUT_PERMIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.checkout.permit' },
- 'CHECKOUT_RENEW' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.renew' },
- 'CIRC_MODIFIER_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circ_modifier.retrieve.all' },
- 'FM_ACN_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.retrieve', 'secure' : false },
- 'FM_ACN_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.retrieve.authoritative', 'secure' : false },
- 'FM_ACN_TREE_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.volume.fleshed.batch.update' },
- 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy_tree.retrieve', 'secure' : false },
- 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy_tree.retrieve.authoritative', 'secure' : false },
- 'FM_ACN_TRANSFER' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.volume.batch.transfer' },
- 'FM_ACN_FIND_OR_CREATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.call_number.find_or_create', 'secure' : false },
- 'FM_ACP_DETAILS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve' },
- 'FM_ACP_DETAILS_VIA_BARCODE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve.barcode' },
- 'FM_ACP_DETAILS_VIA_BARCODE.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve.barcode.authoritative' },
- //'FM_ACP_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.retrieve' },
- 'FM_ACP_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed2.retrieve', 'secure' : false },
- //'FM_ACP_RETRIEVE_VIA_BARCODE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.find_by_barcode' },
- 'FM_ACP_RETRIEVE_VIA_BARCODE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed2.find_by_barcode', 'secure' : false },
- 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed2.find_by_barcode.authoritative', 'secure' : false },
- 'FM_ACP_FLESHED_BATCH_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.batch.retrieve', 'secure' : false },
- 'FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.batch.retrieve.authoritative', 'secure' : false },
- 'FM_ACP_FLESHED_BATCH_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy.fleshed.batch.update' },
- 'FM_ACP_COUNT' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.copy_count.staff', 'secure' : false },
- 'FM_ACP_COUNT.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.copy_count.staff.authoritative', 'secure' : false },
- 'FM_ACPL_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_location.retrieve.all', 'secure' : false },
- 'FM_ACPL_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_location.retrieve', 'secure' : false },
- 'FM_ACPL_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_location.retrieve.authoritative', 'secure' : false },
- 'FM_ACPN_RETRIEVE_ALL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_note.retrieve.all', 'secure' : false },
- 'FM_ACPN_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_note.create' },
- 'FM_ACPN_DELETE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_note.delete', 'secure' : false },
- 'FM_ACTSC_RETRIEVE_BATCH' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.actor.retrieve.batch', 'secure' : false },
- 'FM_ACTSC_RETRIEVE_VIA_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.actor.retrieve.all', 'secure' : false },
- 'FM_AHRN_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_note.create' },
- 'FM_AHN_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_notification.create' },
- 'FM_AHN_RETRIEVE_VIA_AHR' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_notification.retrieve_by_hold' },
- 'FM_AHN_RETRIEVE_VIA_AHR.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_notification.retrieve_by_hold.authoritative' },
- 'FM_AHR_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve_by_id' },
- 'FM_AHR_BLOB_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.details.retrieve' },
- 'FM_AHR_BLOB_RETRIEVE.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.details.retrieve.authoritative' },
- 'FM_AHR_RETRIEVE_VIA_AU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve' },
- 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.id_list.retrieve' },
- 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.id_list.retrieve.authoritative' },
- 'FM_AHR_RETRIEVE_VIA_BRE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.open_holds.retrieve' },
- 'FM_AHR_RETRIEVE_ALL_VIA_BRE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve_all_from_title' },
- 'FM_AHR_RETRIEVE_VIA_PICKUP_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve_by_pickup_lib' },
- 'FM_AHR_ID_LIST_RETRIEVE_VIA_PICKUP_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.id_list.retrieve_by_pickup_lib' },
- 'FM_AHR_PULL_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_pull_list.retrieve' },
- 'FM_AHR_ID_LIST_PULL_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_pull_list.id_list.retrieve', 'secure' : false },
- 'FM_AHR_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.on_shelf.retrieve' },
- 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.id_list.on_shelf.retrieve', 'secure' : false },
- 'FM_AHR_COUNT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.hold_requests.count', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_AHR_COUNT_RETRIEVE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.hold_requests.count.authoritative', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_AHR_CANCEL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.cancel' },
- 'FM_AHR_UNCANCEL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.uncancel' },
- 'FM_AHR_UPDATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.update' },
- 'FM_AHR_RESET' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.reset' },
- 'FM_AHR_STATUS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.status.retrieve' },
+ 'BLOB_MOBTS_CIRC_MVR_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance.fleshed' },
+ 'BLOB_MOBTS_CIRC_MVR_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.fleshed' },
+ 'BUCKET_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.create' },
+ 'BUCKET_FLESH' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.flesh' },
+ 'BUCKET_DELETE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.full_delete' },
+ 'BUCKET_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.all.retrieve_by_user' },
+ 'BUCKET_ITEM_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.item.create' },
+ 'BUCKET_ITEM_DELETE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.container.item.delete' },
+ 'CAPTURE_COPY_FOR_HOLD_VIA_BARCODE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.capture_copy.barcode' },
+ 'CHECKIN_VIA_BARCODE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.checkin' },
+ 'CHECKOUT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.checkout' },
+ 'CHECKOUT_FULL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.checkout.full' },
+ 'CHECKOUT_PERMIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.checkout.permit' },
+ 'CHECKOUT_RENEW' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.renew' },
+ 'CIRC_MODIFIER_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circ_modifier.retrieve.all' },
+ 'FM_ACN_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.retrieve', 'secure' : false },
+ 'FM_ACN_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.callnumber.retrieve.authoritative', 'secure' : false },
+ 'FM_ACN_TREE_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.volume.fleshed.batch.update' },
+ 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy_tree.retrieve', 'secure' : false },
+ 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy_tree.retrieve.authoritative', 'secure' : false },
+ 'FM_ACN_TRANSFER' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.volume.batch.transfer' },
+ 'FM_ACN_FIND_OR_CREATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.call_number.find_or_create', 'secure' : false },
+ 'FM_ACP_DETAILS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve' },
+ 'FM_ACP_DETAILS_VIA_BARCODE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve.barcode' },
+ 'FM_ACP_DETAILS_VIA_BARCODE.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_details.retrieve.barcode.authoritative' },
+ //'FM_ACP_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.retrieve' },
+ 'FM_ACP_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed2.retrieve', 'secure' : false },
+ //'FM_ACP_RETRIEVE_VIA_BARCODE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.find_by_barcode' },
+ 'FM_ACP_RETRIEVE_VIA_BARCODE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed2.find_by_barcode', 'secure' : false },
+ 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed2.find_by_barcode.authoritative', 'secure' : false },
+ 'FM_ACP_FLESHED_BATCH_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.batch.retrieve', 'secure' : false },
+ 'FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.batch.retrieve.authoritative', 'secure' : false },
+ 'FM_ACP_FLESHED_BATCH_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy.fleshed.batch.update' },
+ 'FM_ACP_COUNT' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.copy_count.staff', 'secure' : false },
+ 'FM_ACP_COUNT.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.copy_count.staff.authoritative', 'secure' : false },
+ 'FM_ACPL_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_location.retrieve.all', 'secure' : false },
+ 'FM_ACPL_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_location.retrieve', 'secure' : false },
+ 'FM_ACPL_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_location.retrieve.authoritative', 'secure' : false },
+ 'FM_ACPN_RETRIEVE_ALL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_note.retrieve.all', 'secure' : false },
+ 'FM_ACPN_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_note.create' },
+ 'FM_ACPN_DELETE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_note.delete', 'secure' : false },
+ 'FM_ACTSC_RETRIEVE_BATCH' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.actor.retrieve.batch', 'secure' : false },
+ 'FM_ACTSC_RETRIEVE_VIA_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.actor.retrieve.all', 'secure' : false },
+ 'FM_AHRN_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_note.create' },
+ 'FM_AHN_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_notification.create' },
+ 'FM_AHN_RETRIEVE_VIA_AHR' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_notification.retrieve_by_hold' },
+ 'FM_AHN_RETRIEVE_VIA_AHR.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_notification.retrieve_by_hold.authoritative' },
+ 'FM_AHR_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve_by_id' },
+ 'FM_AHR_BLOB_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.details.retrieve' },
+ 'FM_AHR_BLOB_RETRIEVE.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.details.retrieve.authoritative' },
+ 'FM_AHR_RETRIEVE_VIA_AU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve' },
+ 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.id_list.retrieve' },
+ 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.id_list.retrieve.authoritative' },
+ 'FM_AHR_RETRIEVE_VIA_BRE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.open_holds.retrieve' },
+ 'FM_AHR_RETRIEVE_ALL_VIA_BRE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve_all_from_title' },
+ 'FM_AHR_RETRIEVE_VIA_PICKUP_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.retrieve_by_pickup_lib' },
+ 'FM_AHR_ID_LIST_RETRIEVE_VIA_PICKUP_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.holds.id_list.retrieve_by_pickup_lib' },
+ 'FM_AHR_PULL_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_pull_list.retrieve' },
+ 'FM_AHR_ID_LIST_PULL_LIST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold_pull_list.id_list.retrieve', 'secure' : false },
+ 'FM_AHR_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.on_shelf.retrieve' },
+ 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.captured_holds.id_list.on_shelf.retrieve', 'secure' : false },
+ 'FM_AHR_COUNT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.hold_requests.count', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_AHR_COUNT_RETRIEVE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.hold_requests.count.authoritative', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_AHR_CANCEL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.cancel' },
+ 'FM_AHR_UNCANCEL' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.uncancel' },
+ 'FM_AHR_UPDATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.update' },
+ 'FM_AHR_RESET' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.reset' },
+ 'FM_AHR_STATUS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.hold.status.retrieve' },
'FM_AHRCC_PCRUD_SEARCH' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.ahrcc.atomic', 'secure' : false },
- 'FM_AIHU_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.in_house_use.create' },
- 'FM_ANCC_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.non_cataloged_circulation.retrieve' },
- 'FM_ANCC_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.open_non_cataloged_circulation.user' },
- 'FM_ANCC_RETRIEVE_VIA_USER.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.open_non_cataloged_circulation.user.authoritative' },
- 'FM_ANCIHU_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.non_cat_in_house_use.create' },
- 'FM_AOA_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_unit.address.retrieve', 'secure' : false },
- 'FM_AOU_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_tree.retrieve', 'secure' : false },
- 'FM_AOU_DESCENDANTS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_tree.descendants.retrieve', 'secure' : false },
- 'FM_AOU_RETRIEVE_RELATED_VIA_SESSION' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_unit.full_path.retrieve' },
- 'FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.actor.org_unit.retrieve_by_title', 'secure' : false },
- 'FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.actor.org_unit.retrieve_by_title.authoritative', 'secure' : false },
+ 'FM_AIHU_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.in_house_use.create' },
+ 'FM_ANCC_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.non_cataloged_circulation.retrieve' },
+ 'FM_ANCC_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.open_non_cataloged_circulation.user' },
+ 'FM_ANCC_RETRIEVE_VIA_USER.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.open_non_cataloged_circulation.user.authoritative' },
+ 'FM_ANCIHU_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.non_cat_in_house_use.create' },
+ 'FM_AOA_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_unit.address.retrieve', 'secure' : false },
+ 'FM_AOU_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_tree.retrieve', 'secure' : false },
+ 'FM_AOU_DESCENDANTS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_tree.descendants.retrieve', 'secure' : false },
+ 'FM_AOU_RETRIEVE_RELATED_VIA_SESSION' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_unit.full_path.retrieve' },
+ 'FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.actor.org_unit.retrieve_by_title', 'secure' : false },
+ 'FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.actor.org_unit.retrieve_by_title.authoritative', 'secure' : false },
'FM_AOUS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_unit_setting.values.ranged.retrieve' },
- 'FM_AOUT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_types.retrieve', 'secure' : false },
- 'FM_ASC_BATCH_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.asset.retrieve.batch', 'secure' : false },
- 'FM_ASC_RETRIEVE_VIA_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.asset.retrieve.all', 'secure' : false },
- 'FM_ASV_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.survey.create' },
- 'FM_ASV_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.survey.retrieve.all', 'secure' : false },
- 'FM_ASV_RETRIEVE_REQUIRED' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.survey.retrieve.required' },
- 'FM_ASVR_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.survey.response.retrieve' },
- 'FM_ATC_VOID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.abort' },
- 'FM_ATC_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.retrieve', 'secure' : false },
- 'FM_ATC_RETRIEVE_VIA_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.retrieve_by_lib', 'secure' : false },
+ 'FM_AOUT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.org_types.retrieve', 'secure' : false },
+ 'FM_ASC_BATCH_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.asset.retrieve.batch', 'secure' : false },
+ 'FM_ASC_RETRIEVE_VIA_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.stat_cat.asset.retrieve.all', 'secure' : false },
+ 'FM_ASV_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.survey.create' },
+ 'FM_ASV_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.survey.retrieve.all', 'secure' : false },
+ 'FM_ASV_RETRIEVE_REQUIRED' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.survey.retrieve.required' },
+ 'FM_ASVR_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.survey.response.retrieve' },
+ 'FM_ATC_VOID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.abort' },
+ 'FM_ATC_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.retrieve', 'secure' : false },
+ 'FM_ATC_RETRIEVE_VIA_AOU' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.transit.retrieve_by_lib', 'secure' : false },
'FM_AU_ID_RETRIEVE_VIA_BARCODE_OR_USERNAME' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve_id_by_barcode_or_username' },
- 'FM_AU_IDS_RETRIEVE_VIA_HASH' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.search.advanced' },
- 'FM_AU_LIST_RETRIEVE_VIA_GROUP' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.members.retrieve' },
- 'FM_AU_LIST_RETRIEVE_VIA_GROUP.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.members.retrieve.authoritative' },
- 'FM_AU_RETRIEVE_VIA_SESSION' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.session.retrieve' },
- 'FM_AU_RETRIEVE_VIA_BARCODE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve_by_barcode', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_AU_RETRIEVE_VIA_BARCODE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve_by_barcode.authoritative', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_AU_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_AU_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve.authoritative', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_AU_FLESHED_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_AU_FLESHED_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve.authoritative', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_AU_IDS_RETRIEVE_VIA_HASH' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.search.advanced' },
+ 'FM_AU_LIST_RETRIEVE_VIA_GROUP' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.members.retrieve' },
+ 'FM_AU_LIST_RETRIEVE_VIA_GROUP.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.members.retrieve.authoritative' },
+ 'FM_AU_RETRIEVE_VIA_SESSION' : { 'app' : 'open-ils.auth', 'method' : 'open-ils.auth.session.retrieve' },
+ 'FM_AU_RETRIEVE_VIA_BARCODE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve_by_barcode', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_AU_RETRIEVE_VIA_BARCODE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve_by_barcode.authoritative', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_AU_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_AU_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve.authoritative', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_AU_FLESHED_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_AU_FLESHED_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fleshed.retrieve.authoritative', 'cacheable' : true, 'ttl' : 60000 },
'FM_AU_MERGE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.merge' },
- 'FM_AU_NEW_USERGROUP' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.new' },
- 'FM_AU_UPDATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.update' },
- 'FM_AU_DELETE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.delete' },
- 'FM_AUN_RETRIEVE_ALL' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.note.retrieve.all', 'cacheable' : false, 'ttl' : 60000 },
- 'FM_AUN_RETRIEVE_ALL.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.note.retrieve.all.authoritative', 'cacheable' : false, 'ttl' : 60000 },
- 'FM_AUN_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.note.create' },
- 'FM_AUN_DELETE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.note.delete' },
- 'FM_AUS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.settings.retrieve' },
- 'FM_AUS_UPDATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.settings.update' },
- 'FM_AUSP_APPLY' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.apply' },
- 'FM_AUSP_REMOVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.remove' },
+ 'FM_AU_NEW_USERGROUP' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.new' },
+ 'FM_AU_UPDATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.update' },
+ 'FM_AU_DELETE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.delete' },
+ 'FM_AUN_RETRIEVE_ALL' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.note.retrieve.all', 'cacheable' : false, 'ttl' : 60000 },
+ 'FM_AUN_RETRIEVE_ALL.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.note.retrieve.all.authoritative', 'cacheable' : false, 'ttl' : 60000 },
+ 'FM_AUN_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.note.create' },
+ 'FM_AUN_DELETE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.note.delete' },
+ 'FM_AUS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.settings.retrieve' },
+ 'FM_AUS_UPDATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.patron.settings.update' },
+ 'FM_AUSP_APPLY' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.apply' },
+ 'FM_AUSP_REMOVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.remove' },
'FM_AUSP_PCRUD_UPDATE' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.update.ausp', 'secure' : false },
- 'FM_AUSP_UPDATE_NOTE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.note.update' },
- 'FM_BRE_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve', 'secure' : false },
- 'FM_BRE_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve.authoritative', 'secure' : false },
- 'FM_BRE_ID_SEARCH_VIA_BARCODE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.find_by_barcode', 'secure' : false },
+ 'FM_AUSP_UPDATE_NOTE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalty.note.update' },
+ 'FM_BRE_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve', 'secure' : false },
+ 'FM_BRE_RETRIEVE_VIA_ID.authoritative' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.metadata.retrieve.authoritative', 'secure' : false },
+ 'FM_BRE_ID_SEARCH_VIA_BARCODE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.find_by_barcode', 'secure' : false },
'FM_BRE_ID_SEARCH_VIA_MULTICLASS_QUERY' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.multiclass.query.staff' },
- 'FM_BRE_ID_SEARCH_VIA_TCN' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.tcn', 'secure' : false },
- 'FM_BRE_DELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.delete', 'secure' : false },
- 'FM_BRE_UNDELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.undelete', 'secure' : false },
- 'FM_BRN_FROM_MARCXML' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.marcxml_to_brn', 'secure' : false },
- 'FM_CBT_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.billing_type.ranged.retrieve.all', 'secure' : false },
- 'FM_CCS_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.config.copy_status.retrieve.all', 'secure' : false },
- 'FM_CIRC_DETAILS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.fleshed.retrieve' },
- 'FM_CIRC_DETAILS.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.fleshed.retrieve.authoritative' },
- 'FM_CIRC_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.retrieve' },
- /*'FM_CIRC_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.actor.user.checked_out.slim' },*/
- 'FM_CIRC_IN_WITH_FINES_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_in_with_fines' },
- 'FM_CIRC_IN_WITH_FINES_VIA_USER.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_in_with_fines.authoritative' },
- 'FM_CIRC_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out' },
- 'FM_CIRC_RETRIEVE_VIA_USER.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.authoritative' },
- 'FM_CIRC_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_checkout_history.retrieve' },
- /*'FM_CIRC_COUNT_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.count' },*/
- 'FM_CIRC_COUNT_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.count', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.count.authoritative', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_CIRC_COUNT_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.count' },
+ 'FM_BRE_ID_SEARCH_VIA_TCN' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.tcn', 'secure' : false },
+ 'FM_BRE_DELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.delete', 'secure' : false },
+ 'FM_BRE_UNDELETE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record_entry.undelete', 'secure' : false },
+ 'FM_BRN_FROM_MARCXML' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.marcxml_to_brn', 'secure' : false },
+ 'FM_CBT_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.billing_type.ranged.retrieve.all', 'secure' : false },
+ 'FM_CCS_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.config.copy_status.retrieve.all', 'secure' : false },
+ 'FM_CIRC_DETAILS' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.fleshed.retrieve' },
+ 'FM_CIRC_DETAILS.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.fleshed.retrieve.authoritative' },
+ 'FM_CIRC_RETRIEVE_VIA_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.retrieve' },
+ /*'FM_CIRC_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.actor.user.checked_out.slim' },*/
+ 'FM_CIRC_IN_WITH_FINES_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_in_with_fines' },
+ 'FM_CIRC_IN_WITH_FINES_VIA_USER.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_in_with_fines.authoritative' },
+ 'FM_CIRC_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out' },
+ 'FM_CIRC_RETRIEVE_VIA_USER.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.authoritative' },
+ 'FM_CIRC_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_checkout_history.retrieve' },
+ /*'FM_CIRC_COUNT_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.count' },*/
+ 'FM_CIRC_COUNT_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.count', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.count.authoritative', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_CIRC_COUNT_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.count' },
'FM_CIRC_IMPROVED_COUNT_VIA_COPY' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.circbyyr.atomic' },
- 'FM_CIRC_EDIT_DUE_DATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.due_date.update' },
+ 'FM_CIRC_EDIT_DUE_DATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.due_date.update' },
'FM_CIRC_BACKDATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.post_checkin_backdate' },
'FM_CIRC_BACKDATE_BATCH' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.post_checkin_backdate.batch' },
- 'FM_CIT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.ident_types.retrieve', 'secure' : false },
- 'FM_CITM_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.item_type_map.retrieve.all', 'secure' : false },
- 'FM_CNAL_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.net_access_level.retrieve.all', 'secure' : false },
- 'FM_CNCT_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.non_cat_types.retrieve.all', 'secure' : false },
- 'FM_CRAHP_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.config.rules.age_hold_protect.retrieve.all', 'secure' : false },
+ 'FM_CIT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.ident_types.retrieve', 'secure' : false },
+ 'FM_CITM_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.item_type_map.retrieve.all', 'secure' : false },
+ 'FM_CNAL_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.net_access_level.retrieve.all', 'secure' : false },
+ 'FM_CNCT_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.non_cat_types.retrieve.all', 'secure' : false },
+ 'FM_CRAHP_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.config.rules.age_hold_protect.retrieve.all', 'secure' : false },
'FM_CSP_PCRUD_SEARCH' : { 'app' : 'open-ils.pcrud', 'method' : 'open-ils.pcrud.search.csp.atomic', 'secure' : false },
- 'FM_CST_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.standings.retrieve', 'secure' : false },
- 'FM_MB_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.create' },
- 'FM_MB_RETRIEVE_VIA_MBTS_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.retrieve.all' },
- 'FM_MB_RETRIEVE_VIA_MBTS_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.retrieve.all.authoritative' },
- 'FM_MB_VOID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.void' },
- 'FM_MB_NOTE_EDIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.note.edit' },
- 'FM_MBTS_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billable_xact_summary.retrieve' },
- 'FM_MBTS_RETRIEVE.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billable_xact_summary.retrieve.authoritative' },
- 'FM_MBTS_IDS_RETRIEVE_ALL' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.ids' },
- 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_CHARGE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_charge.ids' },
- 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_balance.ids' },
- 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_BALANCE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_balance.ids.authoritative' },
- 'FM_MBTS_IDS_RETRIEVE_ALL_STILL_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.still_open.ids' },
- 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_BILL' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.ids' },
- 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_BILL.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.ids.authoritative' },
- 'FM_MBTS_IDS_RETRIEVE_FOR_HISTORY' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.ids' },
- 'FM_MBTS_IDS_RETRIEVE_FOR_HISTORY.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.ids.authoritative' },
- 'FM_MP_RETRIEVE_VIA_MBTS_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all' },
- 'FM_MP_RETRIEVE_VIA_MBTS_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all.authoritative' },
- 'FM_MP_NOTE_EDIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.note.edit' },
- 'FM_MG_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.create' },
- 'FM_MG_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.retrieve' },
- 'FM_MOBTS_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance' },
- 'FM_MOBTS_HAVING_BALANCE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance.authoritative' },
- 'FM_MOBTS_TOTAL_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance.total' },
- 'FM_MOBTS_COUNT_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance.count' },
- 'FM_MOBTS_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions' },
- 'FM_MOBTS_TOTAL_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.total' },
- 'FM_MOBTS_COUNT_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.count' },
- 'FM_MOUS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fines.summary', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_MOUS_RETRIEVE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fines.summary.authoritative', 'cacheable' : true, 'ttl' : 60000 },
- 'FM_PGT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.groups.tree.retrieve', 'secure' : false },
- 'MARC_HTML_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.html', 'secure' : false },
- 'FM_BLOB_RETRIEVE_VIA_Z3950_SEARCH' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.search_class' },
- 'FM_BLOB_RETRIEVE_VIA_Z3950_RAW_SEARCH' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.search_service' },
- 'RETRIEVE_Z3950_SERVICES' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.retrieve_services', 'secure' : false },
- 'MARK_ITEM_DAMAGED' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.mark_item_damaged' },
- 'MARK_ITEM_MISSING' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.mark_item_missing' },
- 'MARK_ITEM_LOST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.set_lost' },
- 'MARK_ITEM_CLAIM_RETURNED' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.set_claims_returned' },
- 'MODS_SLIM_METARECORD_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.metarecord.mods_slim.retrieve', 'secure' : false },
- 'MODS_SLIM_RECORD_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.mods_slim.retrieve', 'secure' : false },
- 'MODS_SLIM_RECORD_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.mods_slim.retrieve.authoritative', 'secure' : false },
- 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.mods_from_copy', 'secure' : false },
- 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.mods_from_copy', 'secure' : false },
- 'PERM_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.perm.check' },
- 'PERM_MULTI_ORG_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.perm.check.multi_org' },
- 'PERM_RETRIEVE_HIGHEST_ORG' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.perm.highest_org' },
- 'PERM_RETRIEVE_WORK_OU' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.has_work_perm_at' },
- 'BATCH_PERM_RETRIEVE_WORK_OU' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.has_work_perm_at.batch' },
- 'MARC_XML_RECORD_CREATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.xml.create' },
- 'MARC_XML_RECORD_IMPORT' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.xml.import' },
- 'MARC_XML_RECORD_REPLACE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.marc.replace' },
- 'MARC_XML_RECORD_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.xml.update' },
- 'MARC_XML_TEMPLATE_RETRIEVE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.marc_template.retrieve', 'secure' : false },
- 'MARC_XML_TEMPLATE_LIST' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.marc_template.types.retrieve', 'secure' : false },
- 'MERGE_RECORDS' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.records.merge' },
- 'PATRON_BARCODE_EXISTS' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.barcode.exists' },
- 'PATRON_BARCODE_EXISTS.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.barcode.exists.authoritative' },
- 'RECALCULATE_STANDING_PENALTIES' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalties.update' },
+ 'FM_CST_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.standings.retrieve', 'secure' : false },
+ 'FM_MB_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.create' },
+ 'FM_MB_RETRIEVE_VIA_MBTS_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.retrieve.all' },
+ 'FM_MB_RETRIEVE_VIA_MBTS_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.retrieve.all.authoritative' },
+ 'FM_MB_VOID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.void' },
+ 'FM_MB_NOTE_EDIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billing.note.edit' },
+ 'FM_MBTS_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billable_xact_summary.retrieve' },
+ 'FM_MBTS_RETRIEVE.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.billable_xact_summary.retrieve.authoritative' },
+ 'FM_MBTS_IDS_RETRIEVE_ALL' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.ids' },
+ 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_CHARGE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_charge.ids' },
+ 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_balance.ids' },
+ 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_BALANCE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_balance.ids.authoritative' },
+ 'FM_MBTS_IDS_RETRIEVE_ALL_STILL_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.still_open.ids' },
+ 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_BILL' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.ids' },
+ 'FM_MBTS_IDS_RETRIEVE_ALL_HAVING_BILL.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.ids.authoritative' },
+ 'FM_MBTS_IDS_RETRIEVE_FOR_HISTORY' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.ids' },
+ 'FM_MBTS_IDS_RETRIEVE_FOR_HISTORY.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.history.have_bill.ids.authoritative' },
+ 'FM_MP_RETRIEVE_VIA_MBTS_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all' },
+ 'FM_MP_RETRIEVE_VIA_MBTS_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all.authoritative' },
+ 'FM_MP_NOTE_EDIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.note.edit' },
+ 'FM_MG_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.create' },
+ 'FM_MG_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.retrieve' },
+ 'FM_MOBTS_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance' },
+ 'FM_MOBTS_HAVING_BALANCE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance.authoritative' },
+ 'FM_MOBTS_TOTAL_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance.total' },
+ 'FM_MOBTS_COUNT_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance.count' },
+ 'FM_MOBTS_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions' },
+ 'FM_MOBTS_TOTAL_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.total' },
+ 'FM_MOBTS_COUNT_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.count' },
+ 'FM_MOUS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fines.summary', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_MOUS_RETRIEVE.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.fines.summary.authoritative', 'cacheable' : true, 'ttl' : 60000 },
+ 'FM_PGT_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.groups.tree.retrieve', 'secure' : false },
+ 'MARC_HTML_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.html', 'secure' : false },
+ 'FM_BLOB_RETRIEVE_VIA_Z3950_SEARCH' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.search_class' },
+ 'FM_BLOB_RETRIEVE_VIA_Z3950_RAW_SEARCH' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.search_service' },
+ 'RETRIEVE_Z3950_SERVICES' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.z3950.retrieve_services', 'secure' : false },
+ 'MARK_ITEM_DAMAGED' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.mark_item_damaged' },
+ 'MARK_ITEM_MISSING' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.mark_item_missing' },
+ 'MARK_ITEM_LOST' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.set_lost' },
+ 'MARK_ITEM_CLAIM_RETURNED' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.set_claims_returned' },
+ 'MODS_SLIM_METARECORD_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.metarecord.mods_slim.retrieve', 'secure' : false },
+ 'MODS_SLIM_RECORD_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.mods_slim.retrieve', 'secure' : false },
+ 'MODS_SLIM_RECORD_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.mods_slim.retrieve.authoritative', 'secure' : false },
+ 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.mods_from_copy', 'secure' : false },
+ 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.mods_from_copy', 'secure' : false },
+ 'PERM_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.perm.check' },
+ 'PERM_MULTI_ORG_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.perm.check.multi_org' },
+ 'PERM_RETRIEVE_HIGHEST_ORG' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.perm.highest_org' },
+ 'PERM_RETRIEVE_WORK_OU' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.has_work_perm_at' },
+ 'BATCH_PERM_RETRIEVE_WORK_OU' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.has_work_perm_at.batch' },
+ 'MARC_XML_RECORD_CREATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.xml.create' },
+ 'MARC_XML_RECORD_IMPORT' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.xml.import' },
+ 'MARC_XML_RECORD_REPLACE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.marc.replace' },
+ 'MARC_XML_RECORD_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.xml.update' },
+ 'MARC_XML_TEMPLATE_RETRIEVE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.marc_template.retrieve', 'secure' : false },
+ 'MARC_XML_TEMPLATE_LIST' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.marc_template.types.retrieve', 'secure' : false },
+ 'MERGE_RECORDS' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.records.merge' },
+ 'PATRON_BARCODE_EXISTS' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.barcode.exists' },
+ 'PATRON_BARCODE_EXISTS.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.barcode.exists.authoritative' },
+ 'RECALCULATE_STANDING_PENALTIES' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.penalties.update' },
'USER_ORG_UNIT_OPT_IN_FEATURE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.enabled' },
'USER_ORG_UNIT_OPT_IN_CHECK' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.check' },
'USER_ORG_UNIT_OPT_IN_CREATE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.org_unit_opt_in.create' }
const urls = {
- 'opac' : '/opac/' + LOCALE + '/skin/default/xml/advanced.xml?nps=1',
- 'opac_rdetail' : '/opac/' + LOCALE + '/skin/default/xml/rdetail.xml',
- 'opac_rresult' : '/opac/' + LOCALE + '/skin/default/xml/rresult.xml',
- 'org_tree' : '/opac/common/js/' + LOCALE + '/OrgTree.js',
- 'browser' : '/opac/' + LOCALE + '/skin/default/xml/advanced.xml?nps=1',
- 'fieldmapper' : '/opac/common/js/fmall.js',
- 'isodate_lib_remote' : '/opac/common/js/DP_DateExtensions.js',
- 'isodate_lib_local' : 'chrome://open_ils_staff_client/content/OpenILS/util/DP_DateExtensions.js',
- 'xsl_marc2html' : '/opac/extras/xsl/oilsMARC21slim2HTML.xsl',
+ 'opac' : '/opac/' + LOCALE + '/skin/default/xml/advanced.xml?nps=1',
+ 'opac_rdetail' : '/opac/' + LOCALE + '/skin/default/xml/rdetail.xml',
+ 'opac_rresult' : '/opac/' + LOCALE + '/skin/default/xml/rresult.xml',
+ 'org_tree' : '/opac/common/js/' + LOCALE + '/OrgTree.js',
+ 'browser' : '/opac/' + LOCALE + '/skin/default/xml/advanced.xml?nps=1',
+ 'fieldmapper' : '/opac/common/js/fmall.js',
+ 'isodate_lib_remote' : '/opac/common/js/DP_DateExtensions.js',
+ 'isodate_lib_local' : 'chrome://open_ils_staff_client/content/OpenILS/util/DP_DateExtensions.js',
+ 'xsl_marc2html' : '/opac/extras/xsl/oilsMARC21slim2HTML.xsl',
- 'AUDIO_GOOD_SOUND' : '/xul/server/skin/media/audio/bonus.wav',
- 'AUDIO_BAD_SOUND' : '/xul/server/skin/media/audio/question.wav',
- 'AUDIO_HORRIBLE_SOUND' : '/xul/server/skin/media/audio/redalert.wav',
- 'AUDIO_CIRC_GOOD_SOUND' : '/xul/server/skin/media/audio/toggled.wav',
- 'AUDIO_CIRC_BAD_SOUND' : '/xul/server/skin/media/audio/question.wav',
+ 'AUDIO_GOOD_SOUND' : '/xul/server/skin/media/audio/bonus.wav',
+ 'AUDIO_BAD_SOUND' : '/xul/server/skin/media/audio/question.wav',
+ 'AUDIO_HORRIBLE_SOUND' : '/xul/server/skin/media/audio/redalert.wav',
+ 'AUDIO_CIRC_GOOD_SOUND' : '/xul/server/skin/media/audio/toggled.wav',
+ 'AUDIO_CIRC_BAD_SOUND' : '/xul/server/skin/media/audio/question.wav',
- 'XUL_AUTH_SIMPLE' : '/xul/server/main/simple_auth.xul',
- 'XUL_BIB_BRIEF' : '/xul/server/cat/bib_brief.xul',
- 'XUL_BROWSER' : 'chrome://open_ils_staff_client/content/util/browser.xul',
- 'XUL_CHECKIN' : '/xul/server/circ/checkin.xul',
- 'XUL_BACKDATE' : '/xul/server/circ/backdate_post_checkin.xul',
- 'XUL_RENEW' : '/xul/server/circ/renew.xul',
- 'XUL_CHECKOUT' : '/xul/server/circ/checkout.xul',
- 'XUL_CIRC_BRIEF' : '/xul/server/circ/circ_brief.xul',
- 'XUL_CIRC_SUMMARY' : '/xul/server/circ/circ_summary.xul',
- 'XUL_COPY_BUCKETS_QUICK' : '/xul/server/cat/copy_buckets_quick.xul',
- 'XUL_COPY_BUCKETS' : '/xul/server/cat/copy_buckets.xul',
- 'XUL_COPY_DETAILS' : '/xul/server/circ/copy_details.xul',
- 'XUL_COPY_EDITOR' : '/xul/server/cat/copy_editor.xul',
- 'XUL_COPY_LOCATION_EDIT' : '/xul/server/admin/copy_locations.xhtml',
- 'XUL_COPY_NOTES' : '/xul/server/cat/copy_notes.xul',
- 'XUL_COPY_STATUS' : '/xul/server/circ/copy_status.xul',
- 'XUL_COPY_SUMMARY' : '/xul/server/cat/copy_summary.xul',
- 'XUL_COPY_VOLUME_BROWSE' : '/xul/server/cat/copy_browser.xul',
- 'XUL_DEBUG_CONSOLE' : 'chrome://global/content/console.xul',
- 'XUL_DEBUG_FIELDMAPPER' : '/xul/server/util/fm_view.xul',
- 'XUL_DEBUG_FILTER_CONSOLE' : '/xul/server/util/filter_console.xul',
- 'XUL_DEBUG_SHELL' : '/xul/server/util/shell.html',
- 'XUL_DEBUG_XULEDITOR' : '/xul/server/util/xuledit.xul',
- 'XUL_FANCY_PROMPT' : '/xul/server/util/fancy_prompt.xul',
- 'XUL_HOLD_CAPTURE' : '/xul/server/circ/hold_capture.xul',
- 'XUL_HOLD_PULL_LIST' : '/xul/server/admin/hold_pull_list.xhtml',
- 'XUL_HOLDS_BROWSER' : '/xul/server/patron/holds.xul',
- 'XUL_HOLD_DETAILS' : '/xul/server/patron/hold_details.xul',
- 'XUL_HOLD_CANCEL' : '/xul/server/patron/hold_cancel.xul',
- 'XUL_IN_HOUSE_USE' : '/xul/server/circ/in_house_use.xul',
- 'XUL_LIST_CLIPBOARD' : '/xul/server/util/list_clipboard.xul',
- 'XUL_LOCAL_ADMIN' : '/xul/server/admin/index.xhtml',
- 'XUL_MARC_NEW' : '/xul/server/cat/marc_new.xul',
- 'XUL_MARC_EDIT' : '/xul/server/cat/marcedit.xul',
- 'XUL_MARC_VIEW' : '/xul/server/cat/marc_view.xul',
- 'XUL_MENU_FRAME' : 'chrome://open_ils_staff_client/content/main/menu_frame.xul',
- 'XUL_NON_CAT_LABEL_EDIT' : '/xul/server/admin/non_cat_types.xhtml',
- 'XUL_OFFLINE_UPLOAD_XACTS' : '/xul/server/admin/upload_xacts.xhtml',
- 'XUL_OFFLINE_MANAGE_XACTS' : '/xul/server/admin/offline_manage_xacts.xul',
- 'XUL_OFFLINE_MANAGE_XACTS_CGI' : '/cgi-bin/offline/offline.pl',
- 'XUL_OFFLINE_GENERATE_WIDGETS' : '/xul/server/main/gen_offline_widgets.xul',
- 'XUL_REMOTE_OPAC_WRAPPER' : '/xul/server/cat/opac.xul',
- 'XUL_OPAC_WRAPPER' : 'chrome://open_ils_staff_client/content/cat/opac.xul',
- 'XUL_PATRON_BARCODE_ENTRY' : '/xul/server/patron/barcode_entry.xul',
- 'XUL_PATRON_BILLS' : '/xul/server/patron/bills.xul',
- 'XUL_PATRON_BILL_CC_INFO' : '/xul/server/patron/bill_cc_info.xul',
- 'XUL_PATRON_BILL_CHECK_INFO' : '/xul/server/patron/bill_check_info.xul',
- 'XUL_PATRON_BILL_DETAILS' : '/xul/server/patron/bill_details.xul',
- 'XUL_PATRON_BILL_HISTORY' : '/xul/server/patron/bill_history.xul',
- 'XUL_PATRON_BILL_WIZARD' : '/xul/server/patron/bill_wizard.xul',
+ 'XUL_AUTH_SIMPLE' : '/xul/server/main/simple_auth.xul',
+ 'XUL_BIB_BRIEF' : '/xul/server/cat/bib_brief.xul',
+ 'XUL_BROWSER' : 'chrome://open_ils_staff_client/content/util/browser.xul',
+ 'XUL_CHECKIN' : '/xul/server/circ/checkin.xul',
+ 'XUL_BACKDATE' : '/xul/server/circ/backdate_post_checkin.xul',
+ 'XUL_RENEW' : '/xul/server/circ/renew.xul',
+ 'XUL_CHECKOUT' : '/xul/server/circ/checkout.xul',
+ 'XUL_CIRC_BRIEF' : '/xul/server/circ/circ_brief.xul',
+ 'XUL_CIRC_SUMMARY' : '/xul/server/circ/circ_summary.xul',
+ 'XUL_COPY_BUCKETS_QUICK' : '/xul/server/cat/copy_buckets_quick.xul',
+ 'XUL_COPY_BUCKETS' : '/xul/server/cat/copy_buckets.xul',
+ 'XUL_COPY_DETAILS' : '/xul/server/circ/copy_details.xul',
+ 'XUL_COPY_EDITOR' : '/xul/server/cat/copy_editor.xul',
+ 'XUL_COPY_LOCATION_EDIT' : '/xul/server/admin/copy_locations.xhtml',
+ 'XUL_COPY_NOTES' : '/xul/server/cat/copy_notes.xul',
+ 'XUL_COPY_STATUS' : '/xul/server/circ/copy_status.xul',
+ 'XUL_COPY_SUMMARY' : '/xul/server/cat/copy_summary.xul',
+ 'XUL_COPY_VOLUME_BROWSE' : '/xul/server/cat/copy_browser.xul',
+ 'XUL_DEBUG_CONSOLE' : 'chrome://global/content/console.xul',
+ 'XUL_DEBUG_FIELDMAPPER' : '/xul/server/util/fm_view.xul',
+ 'XUL_DEBUG_FILTER_CONSOLE' : '/xul/server/util/filter_console.xul',
+ 'XUL_DEBUG_SHELL' : '/xul/server/util/shell.html',
+ 'XUL_DEBUG_XULEDITOR' : '/xul/server/util/xuledit.xul',
+ 'XUL_FANCY_PROMPT' : '/xul/server/util/fancy_prompt.xul',
+ 'XUL_HOLD_CAPTURE' : '/xul/server/circ/hold_capture.xul',
+ 'XUL_HOLD_PULL_LIST' : '/xul/server/admin/hold_pull_list.xhtml',
+ 'XUL_HOLDS_BROWSER' : '/xul/server/patron/holds.xul',
+ 'XUL_HOLD_DETAILS' : '/xul/server/patron/hold_details.xul',
+ 'XUL_HOLD_CANCEL' : '/xul/server/patron/hold_cancel.xul',
+ 'XUL_IN_HOUSE_USE' : '/xul/server/circ/in_house_use.xul',
+ 'XUL_LIST_CLIPBOARD' : '/xul/server/util/list_clipboard.xul',
+ 'XUL_LOCAL_ADMIN' : '/xul/server/admin/index.xhtml',
+ 'XUL_MARC_NEW' : '/xul/server/cat/marc_new.xul',
+ 'XUL_MARC_EDIT' : '/xul/server/cat/marcedit.xul',
+ 'XUL_MARC_VIEW' : '/xul/server/cat/marc_view.xul',
+ 'XUL_MENU_FRAME' : 'chrome://open_ils_staff_client/content/main/menu_frame.xul',
+ 'XUL_NON_CAT_LABEL_EDIT' : '/xul/server/admin/non_cat_types.xhtml',
+ 'XUL_OFFLINE_UPLOAD_XACTS' : '/xul/server/admin/upload_xacts.xhtml',
+ 'XUL_OFFLINE_MANAGE_XACTS' : '/xul/server/admin/offline_manage_xacts.xul',
+ 'XUL_OFFLINE_MANAGE_XACTS_CGI' : '/cgi-bin/offline/offline.pl',
+ 'XUL_OFFLINE_GENERATE_WIDGETS' : '/xul/server/main/gen_offline_widgets.xul',
+ 'XUL_REMOTE_OPAC_WRAPPER' : '/xul/server/cat/opac.xul',
+ 'XUL_OPAC_WRAPPER' : 'chrome://open_ils_staff_client/content/cat/opac.xul',
+ 'XUL_PATRON_BARCODE_ENTRY' : '/xul/server/patron/barcode_entry.xul',
+ 'XUL_PATRON_BILLS' : '/xul/server/patron/bills.xul',
+ 'XUL_PATRON_BILL_CC_INFO' : '/xul/server/patron/bill_cc_info.xul',
+ 'XUL_PATRON_BILL_CHECK_INFO' : '/xul/server/patron/bill_check_info.xul',
+ 'XUL_PATRON_BILL_DETAILS' : '/xul/server/patron/bill_details.xul',
+ 'XUL_PATRON_BILL_HISTORY' : '/xul/server/patron/bill_history.xul',
+ 'XUL_PATRON_BILL_WIZARD' : '/xul/server/patron/bill_wizard.xul',
'XUL_PATRON_BILL_ALTERNATE_VIEW' : '/xul/server/patron/bill2.xul',
- 'XUL_PATRON_DISPLAY' : '/xul/server/patron/display.xul',
- 'XUL_PATRON_HORIZ_DISPLAY' : '/xul/server/patron/display_horiz.xul',
- 'XUL_PATRON_EDIT' : '/eg/actor/user/register',
- 'XUL_USER_PERM_EDITOR' : '/xul/server/patron/user_edit.xhtml',
- 'XUL_PATRON_HOLDS' : '/xul/server/patron/holds.xul',
- 'XUL_PATRON_INFO_NOTES' : '/xul/server/patron/info_notes.xul',
- 'XUL_PATRON_INFO_STAT_CATS' : '/xul/server/patron/info_stat_cats.xul',
- 'XUL_PATRON_INFO_SURVEYS' : '/xul/server/patron/info_surveys.xul',
- 'XUL_PATRON_INFO_GROUP' : '/xul/server/patron/info_group.xul',
- 'XUL_PATRON_ITEMS' : '/xul/server/patron/items.xul',
- 'XUL_PATRON_SEARCH_FORM' : '/xul/server/patron/search_form.xul',
- 'XUL_PATRON_HORIZONTAL_SEARCH_FORM' : '/xul/server/patron/search_form_horiz.xul',
- 'XUL_PATRON_SEARCH_RESULT' : '/xul/server/patron/search_result.xul',
- 'XUL_PATRON_SUMMARY' : '/xul/server/patron/summary.xul',
- 'XUL_PRE_CAT' : '/xul/server/circ/pre_cat_fields.xul',
- 'XUL_PRINT_LIST_TEMPLATE_EDITOR' : '/xul/server/circ/print_list_template_editor.xul',
- 'XUL_RECORD_BUCKETS' : '/xul/server/cat/record_buckets.xul',
- 'XUL_RECORD_BUCKETS_QUICK' : '/xul/server/cat/record_buckets_quick.xul',
- 'XUL_REMOTE_BROWSER' : '/xul/server/util/rbrowser.xul',
- 'XUL_SPINE_LABEL' : '/xul/server/cat/spine_labels.xul',
- 'XUL_STANDALONE' : 'chrome://open_ils_staff_client/content/circ/offline.xul',
- 'XUL_STANDING_PENALTIES' : '/xul/server/patron/standing_penalties.xul',
- 'XUL_NEW_STANDING_PENALTY' : '/xul/server/patron/new_standing_penalty.xul',
- 'XUL_EDIT_STANDING_PENALTY' : '/xul/server/patron/edit_standing_penalty.xul',
- 'XUL_STAT_CAT_EDIT' : '/xul/server/admin/stat_cat_editor.xhtml',
- 'XUL_SURVEY_WIZARD' : 'chrome://open_ils_staff_client/content/admin/survey_wizard.xul',
- 'XUL_USER_BUCKETS' : '/xul/server/patron/user_buckets.xul',
- 'XUL_VERIFY_CREDENTIALS' : '/xul/server/main/verify_credentials.xul',
- 'XUL_VOLUME_BUCKETS' : '/xul/server/cat/volume_buckets.xul',
- 'XUL_VOLUME_COPY_CREATOR' : '/xul/server/cat/volume_copy_creator.xul',
- 'XUL_VOLUME_EDITOR' : '/xul/server/cat/volume_editor.xul',
+ 'XUL_PATRON_DISPLAY' : '/xul/server/patron/display.xul',
+ 'XUL_PATRON_HORIZ_DISPLAY' : '/xul/server/patron/display_horiz.xul',
+ 'XUL_PATRON_EDIT' : '/eg/actor/user/register',
+ 'XUL_USER_PERM_EDITOR' : '/xul/server/patron/user_edit.xhtml',
+ 'XUL_PATRON_HOLDS' : '/xul/server/patron/holds.xul',
+ 'XUL_PATRON_INFO_NOTES' : '/xul/server/patron/info_notes.xul',
+ 'XUL_PATRON_INFO_STAT_CATS' : '/xul/server/patron/info_stat_cats.xul',
+ 'XUL_PATRON_INFO_SURVEYS' : '/xul/server/patron/info_surveys.xul',
+ 'XUL_PATRON_INFO_GROUP' : '/xul/server/patron/info_group.xul',
+ 'XUL_PATRON_ITEMS' : '/xul/server/patron/items.xul',
+ 'XUL_PATRON_SEARCH_FORM' : '/xul/server/patron/search_form.xul',
+ 'XUL_PATRON_HORIZONTAL_SEARCH_FORM' : '/xul/server/patron/search_form_horiz.xul',
+ 'XUL_PATRON_SEARCH_RESULT' : '/xul/server/patron/search_result.xul',
+ 'XUL_PATRON_SUMMARY' : '/xul/server/patron/summary.xul',
+ 'XUL_PRE_CAT' : '/xul/server/circ/pre_cat_fields.xul',
+ 'XUL_PRINT_LIST_TEMPLATE_EDITOR' : '/xul/server/circ/print_list_template_editor.xul',
+ 'XUL_RECORD_BUCKETS' : '/xul/server/cat/record_buckets.xul',
+ 'XUL_RECORD_BUCKETS_QUICK' : '/xul/server/cat/record_buckets_quick.xul',
+ 'XUL_REMOTE_BROWSER' : '/xul/server/util/rbrowser.xul',
+ 'XUL_SPINE_LABEL' : '/xul/server/cat/spine_labels.xul',
+ 'XUL_STANDALONE' : 'chrome://open_ils_staff_client/content/circ/offline.xul',
+ 'XUL_STANDING_PENALTIES' : '/xul/server/patron/standing_penalties.xul',
+ 'XUL_NEW_STANDING_PENALTY' : '/xul/server/patron/new_standing_penalty.xul',
+ 'XUL_EDIT_STANDING_PENALTY' : '/xul/server/patron/edit_standing_penalty.xul',
+ 'XUL_STAT_CAT_EDIT' : '/xul/server/admin/stat_cat_editor.xhtml',
+ 'XUL_SURVEY_WIZARD' : 'chrome://open_ils_staff_client/content/admin/survey_wizard.xul',
+ 'XUL_USER_BUCKETS' : '/xul/server/patron/user_buckets.xul',
+ 'XUL_VERIFY_CREDENTIALS' : '/xul/server/main/verify_credentials.xul',
+ 'XUL_VOLUME_BUCKETS' : '/xul/server/cat/volume_buckets.xul',
+ 'XUL_VOLUME_COPY_CREATOR' : '/xul/server/cat/volume_copy_creator.xul',
+ 'XUL_VOLUME_EDITOR' : '/xul/server/cat/volume_editor.xul',
'XUL_WORK_LOG' : '/xul/server/admin/work_log.xul',
- 'XUL_Z3950_IMPORT' : '/xul/server/cat/z3950.xul',
- 'TEST_HTML' : '/xul/server/main/test.html',
- 'TEST_XUL' : '/xul/server/main/test.xul',
+ 'XUL_Z3950_IMPORT' : '/xul/server/cat/z3950.xul',
+ 'TEST_HTML' : '/xul/server/main/test.html',
+ 'TEST_XUL' : '/xul/server/main/test.xul',
'CONIFY' : '/conify/' + LOCALE + '/global',
'EG_WEB_BASE' : '/eg',
'XUL_LOCAL_ADMIN_BASE' : '/xul/server/admin',
var authStrings;
function grant_perms(url) {
- var perms = "UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead";
- dump('Granting ' + perms + ' to ' + url + '\n');
- if (G.pref) {
- G.pref.setCharPref("capability.principal.codebase.p0.granted", perms);
- G.pref.setCharPref("capability.principal.codebase.p0.id", url);
- G.pref.setCharPref("capability.principal.codebase.p1.granted", perms);
- G.pref.setCharPref("capability.principal.codebase.p1.id", url.replace('http:','https:'));
- G.pref.setBoolPref("dom.disable_open_during_load",false);
- G.pref.setBoolPref("browser.popups.showPopupBlocker",false);
- }
+ var perms = "UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead";
+ dump('Granting ' + perms + ' to ' + url + '\n');
+ if (G.pref) {
+ G.pref.setCharPref("capability.principal.codebase.p0.granted", perms);
+ G.pref.setCharPref("capability.principal.codebase.p0.id", url);
+ G.pref.setCharPref("capability.principal.codebase.p1.granted", perms);
+ G.pref.setCharPref("capability.principal.codebase.p1.id", url.replace('http:','https:'));
+ G.pref.setBoolPref("dom.disable_open_during_load",false);
+ G.pref.setBoolPref("browser.popups.showPopupBlocker",false);
+ }
}
function clear_the_cache() {
- try {
- var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
- var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
- cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
- cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
- } catch(E) {
- dump(E+'\n');alert(E);
- }
+ try {
+ var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
+ var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
+ cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
+ cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
+ } catch(E) {
+ dump(E+'\n');alert(E);
+ }
}
function toOpenWindowByType(inType, uri) { /* for Venkman */
try {
- var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
- window.open(uri, "_blank", winopts);
+ var winopts = "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar";
+ window.open(uri, "_blank", winopts);
} catch(E) {
alert(E); throw(E);
}
};
function main_init() {
- dump('entering main_init()\n');
- try {
- clear_the_cache();
+ dump('entering main_init()\n');
+ try {
+ clear_the_cache();
- // Now we can safely load the strings without the cache getting wiped
- offlineStrings = document.getElementById('offlineStrings');
- authStrings = document.getElementById('authStrings');
+ // Now we can safely load the strings without the cache getting wiped
+ offlineStrings = document.getElementById('offlineStrings');
+ authStrings = document.getElementById('authStrings');
- if (typeof JSAN == 'undefined') {
- throw(
- offlineStrings.getString('common.jsan.missing')
- );
- }
- /////////////////////////////////////////////////////////////////////////////
+ if (typeof JSAN == 'undefined') {
+ throw(
+ offlineStrings.getString('common.jsan.missing')
+ );
+ }
+ /////////////////////////////////////////////////////////////////////////////
- JSAN.errorLevel = "die"; // none, warn, or die
- JSAN.addRepository('..');
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
- //JSAN.use('test.test'); test.test.hello_world();
+ //JSAN.use('test.test'); test.test.hello_world();
- var mw = self;
- G = {};
+ var mw = self;
+ G = {};
- G.pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+ G.pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
- JSAN.use('util.error');
- G.error = new util.error();
- G.error.sdump('D_ERROR', offlineStrings.getString('main.testing'));
+ JSAN.use('util.error');
+ G.error = new util.error();
+ G.error.sdump('D_ERROR', offlineStrings.getString('main.testing'));
- JSAN.use('util.window');
- G.window = new util.window();
+ JSAN.use('util.window');
+ G.window = new util.window();
- JSAN.use('auth.controller');
- G.auth = new auth.controller( { 'window' : mw } );
+ JSAN.use('auth.controller');
+ G.auth = new auth.controller( { 'window' : mw } );
- JSAN.use('OpenILS.data');
- G.data = new OpenILS.data();
- G.data.on_error = G.auth.logoff;
+ JSAN.use('OpenILS.data');
+ G.data = new OpenILS.data();
+ G.data.on_error = G.auth.logoff;
- JSAN.use('util.file');
- G.file = new util.file();
- try {
- G.file.get('ws_info');
- G.ws_info = G.file.get_object(); G.file.close();
- } catch(E) {
- G.ws_info = {};
- }
- G.data.ws_info = G.ws_info; G.data.stash('ws_info');
+ JSAN.use('util.file');
+ G.file = new util.file();
+ try {
+ G.file.get('ws_info');
+ G.ws_info = G.file.get_object(); G.file.close();
+ } catch(E) {
+ G.ws_info = {};
+ }
+ G.data.ws_info = G.ws_info; G.data.stash('ws_info');
- G.auth.on_login = function() {
+ G.auth.on_login = function() {
- var url = G.auth.controller.view.server_prompt.value || urls.remote;
+ var url = G.auth.controller.view.server_prompt.value || urls.remote;
- G.data.server_unadorned = url; G.data.stash('server_unadorned'); G.data.stash_retrieve();
+ G.data.server_unadorned = url; G.data.stash('server_unadorned'); G.data.stash_retrieve();
- if (! url.match( '^http://' ) ) { url = 'http://' + url; }
+ if (! url.match( '^http://' ) ) { url = 'http://' + url; }
- G.data.server = url; G.data.stash('server');
- G.data.session = { 'key' : G.auth.session.key, 'auth' : G.auth.session.authtime }; G.data.stash('session');
- G.data.stash_retrieve();
+ G.data.server = url; G.data.stash('server');
+ G.data.session = { 'key' : G.auth.session.key, 'auth' : G.auth.session.authtime }; G.data.stash('session');
+ G.data.stash_retrieve();
try {
var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var cookieUri = ios.newURI("http://" + G.data.server_unadorned, null, null);
alert(offlineStrings.getFormattedString(main.session_cookie.error, [E]));
}
- grant_perms(url);
+ grant_perms(url);
- xulG = {
- 'auth' : G.auth,
- 'url' : url,
- 'window' : G.window,
+ xulG = {
+ 'auth' : G.auth,
+ 'url' : url,
+ 'window' : G.window,
'data' : G.data,
- 'pref' : G.pref
- };
-
- if (G.data.ws_info && G.data.ws_info[G.auth.controller.view.server_prompt.value]) {
- JSAN.use('util.widgets');
- var deck = document.getElementById('progress_space');
- util.widgets.remove_children( deck );
- var iframe = document.createElement('iframe'); deck.appendChild(iframe);
- iframe.setAttribute( 'src', url + '/xul/server/main/data.xul' );
- iframe.contentWindow.xulG = xulG;
+ 'pref' : G.pref
+ };
+
+ if (G.data.ws_info && G.data.ws_info[G.auth.controller.view.server_prompt.value]) {
+ JSAN.use('util.widgets');
+ var deck = document.getElementById('progress_space');
+ util.widgets.remove_children( deck );
+ var iframe = document.createElement('iframe'); deck.appendChild(iframe);
+ iframe.setAttribute( 'src', url + '/xul/server/main/data.xul' );
+ iframe.contentWindow.xulG = xulG;
G.data_xul = iframe.contentWindow;
- } else {
- xulG.file = G.file;
- var deck = G.auth.controller.view.ws_deck;
- JSAN.use('util.widgets'); util.widgets.remove_children('ws_deck');
- var iframe = document.createElement('iframe'); deck.appendChild(iframe);
- iframe.setAttribute( 'src', url + '/xul/server/main/ws_info.xul' );
- iframe.contentWindow.xulG = xulG;
- deck.selectedIndex = deck.childNodes.length - 1;
- }
- };
-
- G.auth.on_standalone = function() {
- try {
- G.window.open(urls.XUL_STANDALONE,'Offline','chrome,resizable');
- } catch(E) {
- alert(E);
- }
- };
-
- G.auth.on_standalone_export = function() {
- try {
- JSAN.use('util.file'); var file = new util.file('pending_xacts');
- if (file._file.exists()) {
+ } else {
+ xulG.file = G.file;
+ var deck = G.auth.controller.view.ws_deck;
+ JSAN.use('util.widgets'); util.widgets.remove_children('ws_deck');
+ var iframe = document.createElement('iframe'); deck.appendChild(iframe);
+ iframe.setAttribute( 'src', url + '/xul/server/main/ws_info.xul' );
+ iframe.contentWindow.xulG = xulG;
+ deck.selectedIndex = deck.childNodes.length - 1;
+ }
+ };
+
+ G.auth.on_standalone = function() {
+ try {
+ G.window.open(urls.XUL_STANDALONE,'Offline','chrome,resizable');
+ } catch(E) {
+ alert(E);
+ }
+ };
+
+ G.auth.on_standalone_export = function() {
+ try {
+ JSAN.use('util.file'); var file = new util.file('pending_xacts');
+ if (file._file.exists()) {
var file2 = new util.file('');
- var f = file2.pick_file( { 'mode' : 'save', 'title' : offlineStrings.getString('main.transaction_export.title') } );
- if (f) {
- if (f.exists()) {
- var r = G.error.yns_alert(
- offlineStrings.getFormattedString('main.transaction_export.prompt', [f.leafName]),
- offlineStrings.getString('main.transaction_export.prompt.title'),
- offlineStrings.getString('common.yes'),
- offlineStrings.getString('common.no'),
- null,
- offlineStrings.getString('common.confirm')
- );
- if (r != 0) { file.close(); return; }
- }
- var e_file = new util.file(''); e_file._file = f;
- e_file.write_content( 'truncate', file.get_content() );
- e_file.close();
- var r = G.error.yns_alert(
- offlineStrings.getFormattedString('main.transaction_export.success.prompt', [f.leafName]),
- offlineStrings.getString('main.transaction_export.success.title'),
- offlineStrings.getString('common.yes'),
- offlineStrings.getString('common.no'),
- null,
- offlineStrings.getString('common.confirm')
- );
- if (r == 0) {
- var count = 0;
- var filename = 'pending_xacts_exported_' + new Date().getTime();
- var t_file = new util.file(filename);
- while (t_file._file.exists()) {
- filename = 'pending_xacts_' + new Date().getTime() + '.exported';
- t_file = new util.file(filename);
- if (count++ > 100) {
- throw(offlineStrings.getString('main.transaction_export.filename.error'));
- }
- }
- file._file.moveTo(null,filename);
- } else {
- alert(offlineStrings.getString('main.transaction_export.duplicate.warning'));
- }
- } else {
- alert(offlineStrings.getString('main.transaction_export.no_filename.error'));
- }
- } else {
- alert(offlineStrings.getString('main.transaction_export.no_transactions.error'));
- }
- file.close();
- } catch(E) {
- alert(E);
- }
- };
-
- G.auth.on_standalone_import = function() {
- try {
- JSAN.use('util.file'); var file = new util.file('pending_xacts');
- if (file._file.exists()) {
- alert(offlineStrings.getString('main.transaction_import.outstanding.error'));
- } else {
+ var f = file2.pick_file( { 'mode' : 'save', 'title' : offlineStrings.getString('main.transaction_export.title') } );
+ if (f) {
+ if (f.exists()) {
+ var r = G.error.yns_alert(
+ offlineStrings.getFormattedString('main.transaction_export.prompt', [f.leafName]),
+ offlineStrings.getString('main.transaction_export.prompt.title'),
+ offlineStrings.getString('common.yes'),
+ offlineStrings.getString('common.no'),
+ null,
+ offlineStrings.getString('common.confirm')
+ );
+ if (r != 0) { file.close(); return; }
+ }
+ var e_file = new util.file(''); e_file._file = f;
+ e_file.write_content( 'truncate', file.get_content() );
+ e_file.close();
+ var r = G.error.yns_alert(
+ offlineStrings.getFormattedString('main.transaction_export.success.prompt', [f.leafName]),
+ offlineStrings.getString('main.transaction_export.success.title'),
+ offlineStrings.getString('common.yes'),
+ offlineStrings.getString('common.no'),
+ null,
+ offlineStrings.getString('common.confirm')
+ );
+ if (r == 0) {
+ var count = 0;
+ var filename = 'pending_xacts_exported_' + new Date().getTime();
+ var t_file = new util.file(filename);
+ while (t_file._file.exists()) {
+ filename = 'pending_xacts_' + new Date().getTime() + '.exported';
+ t_file = new util.file(filename);
+ if (count++ > 100) {
+ throw(offlineStrings.getString('main.transaction_export.filename.error'));
+ }
+ }
+ file._file.moveTo(null,filename);
+ } else {
+ alert(offlineStrings.getString('main.transaction_export.duplicate.warning'));
+ }
+ } else {
+ alert(offlineStrings.getString('main.transaction_export.no_filename.error'));
+ }
+ } else {
+ alert(offlineStrings.getString('main.transaction_export.no_transactions.error'));
+ }
+ file.close();
+ } catch(E) {
+ alert(E);
+ }
+ };
+
+ G.auth.on_standalone_import = function() {
+ try {
+ JSAN.use('util.file'); var file = new util.file('pending_xacts');
+ if (file._file.exists()) {
+ alert(offlineStrings.getString('main.transaction_import.outstanding.error'));
+ } else {
var file2 = new util.file('');
- var f = file2.pick_file( { 'mode' : 'open', 'title' : offlineStrings.getString('main.transaction_import.title')} );
- if (f && f.exists()) {
- var i_file = new util.file(''); i_file._file = f;
- file.write_content( 'truncate', i_file.get_content() );
- i_file.close();
- var r = G.error.yns_alert(
- offlineStrings.getFormattedString('main.transaction_import.delete.prompt', [f.leafName]),
- offlineStrings.getString('main.transaction_import.success'),
- offlineStrings.getString('common.yes'),
- offlineStrings.getString('common.no'),
- null,
- offlineStrings.getString('common.confirm')
- );
- if (r == 0) {
- f.remove(false);
- }
- }
- }
- file.close();
- } catch(E) {
- alert(E);
- }
- };
-
- G.auth.on_debug = function(action) {
- switch(action) {
- case 'js_console' :
- G.window.open(urls.XUL_DEBUG_CONSOLE,'testconsole','chrome,resizable');
- break;
- case 'clear_cache' :
- clear_the_cache();
- alert(offlineStrings.getString('main.on_debug.clear_cache'));
- break;
- default:
- alert(offlineStrings.getString('main.on_debug.debug'));
- break;
- }
- };
-
- G.auth.init();
- // XML_HTTP_SERVER will get reset to G.auth.controller.view.server_prompt.value
-
- /////////////////////////////////////////////////////////////////////////////
-
- var version = '/xul/server/'.split(/\//)[2];
- if (version == 'server') {
- version = 'versionless debug build';
- document.getElementById('debug_gb').hidden = false;
- }
+ var f = file2.pick_file( { 'mode' : 'open', 'title' : offlineStrings.getString('main.transaction_import.title')} );
+ if (f && f.exists()) {
+ var i_file = new util.file(''); i_file._file = f;
+ file.write_content( 'truncate', i_file.get_content() );
+ i_file.close();
+ var r = G.error.yns_alert(
+ offlineStrings.getFormattedString('main.transaction_import.delete.prompt', [f.leafName]),
+ offlineStrings.getString('main.transaction_import.success'),
+ offlineStrings.getString('common.yes'),
+ offlineStrings.getString('common.no'),
+ null,
+ offlineStrings.getString('common.confirm')
+ );
+ if (r == 0) {
+ f.remove(false);
+ }
+ }
+ }
+ file.close();
+ } catch(E) {
+ alert(E);
+ }
+ };
+
+ G.auth.on_debug = function(action) {
+ switch(action) {
+ case 'js_console' :
+ G.window.open(urls.XUL_DEBUG_CONSOLE,'testconsole','chrome,resizable');
+ break;
+ case 'clear_cache' :
+ clear_the_cache();
+ alert(offlineStrings.getString('main.on_debug.clear_cache'));
+ break;
+ default:
+ alert(offlineStrings.getString('main.on_debug.debug'));
+ break;
+ }
+ };
+
+ G.auth.init();
+ // XML_HTTP_SERVER will get reset to G.auth.controller.view.server_prompt.value
+
+ /////////////////////////////////////////////////////////////////////////////
+
+ var version = '/xul/server/'.split(/\//)[2];
+ if (version == 'server') {
+ version = 'versionless debug build';
+ document.getElementById('debug_gb').hidden = false;
+ }
if (G.pref && G.pref.getBoolPref('open-ils.debug_options')) {
- document.getElementById('debug_gb').hidden = false;
+ document.getElementById('debug_gb').hidden = false;
}
window.title = authStrings.getFormattedString('staff.auth.titlebar.label', version);
- var x = document.getElementById('about_btn');
- x.addEventListener(
- 'command',
- function() {
- try {
- G.window.open('about.html','about','chrome,resizable,width=800,height=600');
- } catch(E) { alert(E); }
- },
- false
- );
-
- var y = document.getElementById('new_window_btn');
- y.addEventListener(
- 'command',
- function() {
- if (G.data.session) {
- try {
- //G.data_xul.g.open_menu();
+ var x = document.getElementById('about_btn');
+ x.addEventListener(
+ 'command',
+ function() {
+ try {
+ G.window.open('about.html','about','chrome,resizable,width=800,height=600');
+ } catch(E) { alert(E); }
+ },
+ false
+ );
+
+ var y = document.getElementById('new_window_btn');
+ y.addEventListener(
+ 'command',
+ function() {
+ if (G.data.session) {
+ try {
+ //G.data_xul.g.open_menu();
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var mframe = xulG.window.open(( String(urls.XUL_MENU_FRAME).match(/^chrome:/) ? '' : G.data.server ) + urls.XUL_MENU_FRAME
+ '?server='+window.escape(G.data.server),
'main'+xulG.window.window_name_increment(),'chrome,resizable'
);
mframe.xulG = xulG;
- } catch(E) { alert(E); }
- } else {
- alert ( offlineStrings.getString('main.new_window_btn.login_first_warning') );
- }
- },
- false
- );
-
- JSAN.use('util.mozilla');
- var z = document.getElementById('locale_menupopup');
- if (z) {
- while (z.lastChild) z.removeChild(z.lastChild);
- var locales = util.mozilla.chromeRegistry().getLocalesForPackage( String( location.href ).split(/\//)[2] );
- var current_locale = util.mozilla.prefs().getCharPref('general.useragent.locale');
+ } catch(E) { alert(E); }
+ } else {
+ alert ( offlineStrings.getString('main.new_window_btn.login_first_warning') );
+ }
+ },
+ false
+ );
+
+ JSAN.use('util.mozilla');
+ var z = document.getElementById('locale_menupopup');
+ if (z) {
+ while (z.lastChild) z.removeChild(z.lastChild);
+ var locales = util.mozilla.chromeRegistry().getLocalesForPackage( String( location.href ).split(/\//)[2] );
+ var current_locale = util.mozilla.prefs().getCharPref('general.useragent.locale');
while (locales.hasMore()) {
var locale = locales.getNext();
var parts = locale.split(/-/);
} catch(E) {
label = locale;
}
- var mi = document.createElement('menuitem');
- mi.setAttribute('label',label);
- mi.setAttribute('value',locale);
+ var mi = document.createElement('menuitem');
+ mi.setAttribute('label',label);
+ mi.setAttribute('value',locale);
if (locale == current_locale) {
if (z.parentNode.tagName == 'menulist') {
mi.setAttribute('selected','true');
}
z.appendChild( mi );
}
- }
- var xx = document.getElementById('apply_locale_btn');
- xx.addEventListener(
- 'command',
- function() {
- util.mozilla.change_locale(z.parentNode.value);
- },
- false
- );
-
- if ( found_ws_info_in_Achrome() && G.pref && G.pref.getBoolPref("open-ils.write_in_user_chrome_directory") ) {
- //var hbox = x.parentNode; var b = document.createElement('button');
- //b.setAttribute('label','Migrate legacy settings'); hbox.appendChild(b);
- //b.addEventListener(
- // 'command',
- // function() {
- // try {
- // handle_migration();
- // } catch(E) { alert(E); }
- // },
- // false
- //);
- if (window.confirm(offlineStrings.getString('main.settings.migrate'))) {
- setTimeout( function() { handle_migration(); }, 0 );
- }
- }
-
- } catch(E) {
- var error = offlineStrings.getFormattedString('common.exception', [E, '']);
- try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
- alert(error);
- }
- dump('exiting main_init()\n');
+ }
+ var xx = document.getElementById('apply_locale_btn');
+ xx.addEventListener(
+ 'command',
+ function() {
+ util.mozilla.change_locale(z.parentNode.value);
+ },
+ false
+ );
+
+ if ( found_ws_info_in_Achrome() && G.pref && G.pref.getBoolPref("open-ils.write_in_user_chrome_directory") ) {
+ //var hbox = x.parentNode; var b = document.createElement('button');
+ //b.setAttribute('label','Migrate legacy settings'); hbox.appendChild(b);
+ //b.addEventListener(
+ // 'command',
+ // function() {
+ // try {
+ // handle_migration();
+ // } catch(E) { alert(E); }
+ // },
+ // false
+ //);
+ if (window.confirm(offlineStrings.getString('main.settings.migrate'))) {
+ setTimeout( function() { handle_migration(); }, 0 );
+ }
+ }
+
+ } catch(E) {
+ var error = offlineStrings.getFormattedString('common.exception', [E, '']);
+ try { G.error.sdump('D_ERROR',error); } catch(E) { dump(error); }
+ alert(error);
+ }
+ dump('exiting main_init()\n');
}
function found_ws_info_in_Achrome() {
- JSAN.use('util.file');
- var f = new util.file();
- var f_in_chrome = f.get('ws_info','chrome');
- var path = f_in_chrome.exists() ? f_in_chrome.path : false;
- f.close();
- return path;
+ JSAN.use('util.file');
+ var f = new util.file();
+ var f_in_chrome = f.get('ws_info','chrome');
+ var path = f_in_chrome.exists() ? f_in_chrome.path : false;
+ f.close();
+ return path;
}
function found_ws_info_in_Uchrome() {
- JSAN.use('util.file');
- var f = new util.file();
- var f_in_uchrome = f.get('ws_info','uchrome');
- var path = f_in_uchrome.exists() ? f_in_uchrome.path : false;
- f.close();
- return path;
+ JSAN.use('util.file');
+ var f = new util.file();
+ var f_in_uchrome = f.get('ws_info','uchrome');
+ var path = f_in_uchrome.exists() ? f_in_uchrome.path : false;
+ f.close();
+ return path;
}
function handle_migration() {
- if ( found_ws_info_in_Uchrome() ) {
- alert(offlineStrings.getFormattedString('main.settings.migrate.failed', [found_ws_info_in_Uchrome(), found_ws_info_in_Achrome()])
- );
- } else {
- var dirService = Components.classes["@mozilla.org/file/directory_service;1"].getService( Components.interfaces.nsIProperties );
- var f_new = dirService.get( "UChrm", Components.interfaces.nsIFile );
- var f_old = dirService.get( "AChrom", Components.interfaces.nsIFile );
- f_old.append(myPackageDir); f_old.append("content"); f_old.append("conf");
- if (window.confirm(offlineStrings.getFormattedString("main.settings.migrate.confirm", [f_old.path, f_new.path]))) {
- var files = f_old.directoryEntries;
- while (files.hasMoreElements()) {
- var file = files.getNext();
- var file2 = file.QueryInterface( Components.interfaces.nsILocalFile );
- try {
- file2.moveTo( f_new, '' );
- } catch(E) {
- alert(offlineStrings.getFormattedString('main.settings.migrate.error', [file2.path, f_new.path]) + '\n');
- }
- }
- location.href = location.href; // huh?
- }
- }
+ if ( found_ws_info_in_Uchrome() ) {
+ alert(offlineStrings.getFormattedString('main.settings.migrate.failed', [found_ws_info_in_Uchrome(), found_ws_info_in_Achrome()])
+ );
+ } else {
+ var dirService = Components.classes["@mozilla.org/file/directory_service;1"].getService( Components.interfaces.nsIProperties );
+ var f_new = dirService.get( "UChrm", Components.interfaces.nsIFile );
+ var f_old = dirService.get( "AChrom", Components.interfaces.nsIFile );
+ f_old.append(myPackageDir); f_old.append("content"); f_old.append("conf");
+ if (window.confirm(offlineStrings.getFormattedString("main.settings.migrate.confirm", [f_old.path, f_new.path]))) {
+ var files = f_old.directoryEntries;
+ while (files.hasMoreElements()) {
+ var file = files.getNext();
+ var file2 = file.QueryInterface( Components.interfaces.nsILocalFile );
+ try {
+ file2.moveTo( f_new, '' );
+ } catch(E) {
+ alert(offlineStrings.getFormattedString('main.settings.migrate.error', [file2.path, f_new.path]) + '\n');
+ }
+ }
+ location.href = location.href; // huh?
+ }
+ }
}
dump('exiting main/main.js\n');
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
offlineStrings = document.getElementById('offlineStrings');
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.window'); this.window = new util.window();
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.window'); this.window = new util.window();
- this.w = window;
+ this.w = window;
var x = document.getElementById('network_progress');
x.setAttribute('count','0');
x.addEventListener(
false
);
- if (xulG.pref.getBoolPref('open-ils.disable_accesskeys_on_tabs')) {
- var tabs = document.getElementById('main_tabs');
- for (var i = 0; i < tabs.childNodes.length; i++) {
- tabs.childNodes[i].setAttribute('accesskey','');
- }
- }
+ if (xulG.pref.getBoolPref('open-ils.disable_accesskeys_on_tabs')) {
+ var tabs = document.getElementById('main_tabs');
+ for (var i = 0; i < tabs.childNodes.length; i++) {
+ tabs.childNodes[i].setAttribute('accesskey','');
+ }
+ }
}
main.menu.prototype = {
- 'id_incr' : 0,
+ 'id_incr' : 0,
- 'url_prefix' : function(url) {
- if (url.match(/^\//)) url = urls.remote + url;
- if (! url.match(/^(http|chrome):\/\//) && ! url.match(/^data:/) ) url = 'http://' + url;
- dump('url_prefix = ' + url + '\n');
- return url;
- },
+ 'url_prefix' : function(url) {
+ if (url.match(/^\//)) url = urls.remote + url;
+ if (! url.match(/^(http|chrome):\/\//) && ! url.match(/^data:/) ) url = 'http://' + url;
+ dump('url_prefix = ' + url + '\n');
+ return url;
+ },
- 'init' : function( params ) {
+ 'init' : function( params ) {
- urls.remote = params['server'];
+ urls.remote = params['server'];
- var obj = this;
+ var obj = this;
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
var button_bar = String( obj.data.hash.aous['ui.general.button_bar'] ) == 'true';
if (button_bar) {
}
- var cmd_map = {
- 'cmd_broken' : [
- ['oncommand'],
- function() { alert(offlineStrings.getString('common.unimplemented')); }
- ],
-
- /* File Menu */
- 'cmd_close_window' : [
- ['oncommand'],
- function() { window.close(); }
- ],
- 'cmd_new_window' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- var mframe = obj.window.open(
- obj.url_prefix(urls.XUL_MENU_FRAME)
- + '?server='+window.escape(urls.remote),
- 'main' + obj.window.window_name_increment(),
- 'chrome,resizable');
+ var cmd_map = {
+ 'cmd_broken' : [
+ ['oncommand'],
+ function() { alert(offlineStrings.getString('common.unimplemented')); }
+ ],
+
+ /* File Menu */
+ 'cmd_close_window' : [
+ ['oncommand'],
+ function() { window.close(); }
+ ],
+ 'cmd_new_window' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ var mframe = obj.window.open(
+ obj.url_prefix(urls.XUL_MENU_FRAME)
+ + '?server='+window.escape(urls.remote),
+ 'main' + obj.window.window_name_increment(),
+ 'chrome,resizable');
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
mframe.xulG = xulG;
- }
- ],
- 'cmd_new_tab' : [
- ['oncommand'],
- function() { obj.new_tab(null,{'focus':true},null); }
- ],
- 'cmd_close_tab' : [
- ['oncommand'],
- function() { obj.close_tab(); }
- ],
- 'cmd_close_all_tabs' : [
- ['oncommand'],
- function() { obj.close_all_tabs(); }
- ],
-
- /* Edit Menu */
- 'cmd_edit_copy_buckets' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_COPY_BUCKETS),{'tab_name':offlineStrings.getString('menu.cmd_edit_copy_buckets.tab')},{});
- }
- ],
- 'cmd_edit_volume_buckets' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_VOLUME_BUCKETS),{'tab_name':offlineStrings.getString('menu.cmd_edit_volume_buckets.tab')},{});
- }
- ],
- 'cmd_edit_record_buckets' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_RECORD_BUCKETS),{'tab_name':offlineStrings.getString('menu.cmd_edit_record_buckets.tab')},{});
- }
- ],
- 'cmd_edit_user_buckets' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_USER_BUCKETS),{'tab_name':offlineStrings.getString('menu.cmd_edit_user_buckets.tab')},{});
- }
- ],
-
-
- 'cmd_replace_barcode' : [
- ['oncommand'],
- function() {
- try {
- JSAN.use('util.network');
- var network = new util.network();
-
- var old_bc = window.prompt(offlineStrings.getString('menu.cmd_replace_barcode.prompt'),'',offlineStrings.getString('menu.cmd_replace_barcode.label'));
- if (!old_bc) return;
-
- var copy;
+ }
+ ],
+ 'cmd_new_tab' : [
+ ['oncommand'],
+ function() { obj.new_tab(null,{'focus':true},null); }
+ ],
+ 'cmd_close_tab' : [
+ ['oncommand'],
+ function() { obj.close_tab(); }
+ ],
+ 'cmd_close_all_tabs' : [
+ ['oncommand'],
+ function() { obj.close_all_tabs(); }
+ ],
+
+ /* Edit Menu */
+ 'cmd_edit_copy_buckets' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_COPY_BUCKETS),{'tab_name':offlineStrings.getString('menu.cmd_edit_copy_buckets.tab')},{});
+ }
+ ],
+ 'cmd_edit_volume_buckets' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_VOLUME_BUCKETS),{'tab_name':offlineStrings.getString('menu.cmd_edit_volume_buckets.tab')},{});
+ }
+ ],
+ 'cmd_edit_record_buckets' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_RECORD_BUCKETS),{'tab_name':offlineStrings.getString('menu.cmd_edit_record_buckets.tab')},{});
+ }
+ ],
+ 'cmd_edit_user_buckets' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_USER_BUCKETS),{'tab_name':offlineStrings.getString('menu.cmd_edit_user_buckets.tab')},{});
+ }
+ ],
+
+
+ 'cmd_replace_barcode' : [
+ ['oncommand'],
+ function() {
+ try {
+ JSAN.use('util.network');
+ var network = new util.network();
+
+ var old_bc = window.prompt(offlineStrings.getString('menu.cmd_replace_barcode.prompt'),'',offlineStrings.getString('menu.cmd_replace_barcode.label'));
+ if (!old_bc) return;
+
+ var copy;
try {
copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
- if (typeof copy.ilsevent != 'undefined') throw(copy);
- if (!copy) throw(copy);
+ if (typeof copy.ilsevent != 'undefined') throw(copy);
+ if (!copy) throw(copy);
} catch(E) {
alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.retrieval.error', [old_bc]) + '\n');
return;
}
-
- // Why did I want to do this twice? Because this copy is more fleshed?
+
+ // Why did I want to do this twice? Because this copy is more fleshed?
try {
- copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
- if (typeof copy.ilsevent != 'undefined') throw(copy);
- if (!copy) throw(copy);
+ copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
+ if (typeof copy.ilsevent != 'undefined') throw(copy);
+ if (!copy) throw(copy);
} catch(E) {
try { alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.retrieval.error', [old_bc]) + '\n' + (typeof E.ilsevent == 'undefined' ? '' : E.textcode + ' : ' + E.desc)); } catch(F) { alert(E + '\n' + F); }
return;
}
-
- var new_bc = window.prompt(offlineStrings.getString('menu.cmd_replace_barcode.replacement.prompt'),'',offlineStrings.getString('menu.cmd_replace_barcode.replacement.label'));
- new_bc = String( new_bc ).replace(/\s/g,'');
- /* Casting a possibly null input value to a String turns it into "null" */
- if (!new_bc || new_bc == 'null') {
- alert(offlineStrings.getString('menu.cmd_replace_barcode.blank.error'));
- return;
- }
-
- var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ new_bc ]);
- if (typeof test.ilsevent == 'undefined') {
- alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.duplicate.error', [new_bc]));
- return;
- } else {
- if (test.ilsevent != 1502 /* ASSET_COPY_NOT_FOUND */) {
- obj.error.standard_unexpected_error_alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.testing.error', [new_bc]),test);
- return;
- }
- }
-
- copy.barcode(new_bc); copy.ischanged('1');
- var r = network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE', [ ses(), [ copy ] ]);
- if (typeof r.ilsevent != 'undefined') {
+
+ var new_bc = window.prompt(offlineStrings.getString('menu.cmd_replace_barcode.replacement.prompt'),'',offlineStrings.getString('menu.cmd_replace_barcode.replacement.label'));
+ new_bc = String( new_bc ).replace(/\s/g,'');
+ /* Casting a possibly null input value to a String turns it into "null" */
+ if (!new_bc || new_bc == 'null') {
+ alert(offlineStrings.getString('menu.cmd_replace_barcode.blank.error'));
+ return;
+ }
+
+ var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ new_bc ]);
+ if (typeof test.ilsevent == 'undefined') {
+ alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.duplicate.error', [new_bc]));
+ return;
+ } else {
+ if (test.ilsevent != 1502 /* ASSET_COPY_NOT_FOUND */) {
+ obj.error.standard_unexpected_error_alert(offlineStrings.getFormattedString('menu.cmd_replace_barcode.testing.error', [new_bc]),test);
+ return;
+ }
+ }
+
+ copy.barcode(new_bc); copy.ischanged('1');
+ var r = network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE', [ ses(), [ copy ] ]);
+ if (typeof r.ilsevent != 'undefined') {
if (r.ilsevent != 0) {
if (r.ilsevent == 5000 /* PERM_FAILURE */) {
alert(offlineStrings.getString('menu.cmd_replace_barcode.permission.error'));
}
}
}
- } catch(E) {
- obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.cmd_replace_barcode.renaming.failure'),copy);
- }
- }
- ],
-
- /* Search Menu */
- 'cmd_patron_search' : [
- ['oncommand'],
- function() {
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.cmd_replace_barcode.renaming.failure'),copy);
+ }
+ }
+ ],
+
+ /* Search Menu */
+ 'cmd_patron_search' : [
+ ['oncommand'],
+ function() {
obj.set_patron_tab();
- }
- ],
- 'cmd_search_opac' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- var content_params = { 'session' : ses(), 'authtime' : ses('authtime') };
- obj.set_tab(obj.url_prefix(urls.XUL_OPAC_WRAPPER), {'tab_name':offlineStrings.getString('menu.cmd_search_opac.tab')}, content_params);
- }
- ],
- 'cmd_search_tcn' : [
- ['oncommand'],
- function() {
- var tcn = prompt(offlineStrings.getString('menu.cmd_search_tcn.tab'),'',offlineStrings.getString('menu.cmd_search_tcn.prompt'));
-
- function spawn_tcn(r) {
- for (var i = 0; i < r.count; i++) {
- var id = r.ids[i];
- var opac_url = obj.url_prefix( urls.opac_rdetail ) + '?r=' + id;
- obj.data.stash_retrieve();
- var content_params = {
- 'session' : ses(),
- 'authtime' : ses('authtime'),
- 'opac_url' : opac_url,
- };
- if (i == 0) {
- obj.set_tab(
- obj.url_prefix(urls.XUL_OPAC_WRAPPER),
- {'tab_name':tcn},
- content_params
- );
- } else {
- obj.new_tab(
- obj.url_prefix(urls.XUL_OPAC_WRAPPER),
- {'tab_name':tcn},
- content_params
- );
- }
- }
- }
-
- if (tcn) {
- JSAN.use('util.network');
- var network = new util.network();
- var robj = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn]);
- if (robj.count != robj.ids.length) throw('FIXME -- FM_BRE_ID_SEARCH_VIA_TCN = ' + js2JSON(robj));
- if (robj.count == 0) {
- var robj2 = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn,1]);
- if (robj2.count == 0) {
- alert(offlineStrings.getFormattedString('menu.cmd_search_tcn.not_found.error', [tcn]));
- } else {
- if ( window.confirm(offlineStrings.getFormattedString('menu.cmd_search_tcn.deleted.error', [tcn])) ) {
- spawn_tcn(robj2);
- }
- }
- } else {
- spawn_tcn(robj);
- }
- }
- }
- ],
- 'cmd_search_bib_id' : [
- ['oncommand'],
- function() {
- var bib_id = prompt(offlineStrings.getString('menu.cmd_search_bib_id.tab'),'',offlineStrings.getString('menu.cmd_search_bib_id.prompt'));
+ }
+ ],
+ 'cmd_search_opac' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ var content_params = { 'session' : ses(), 'authtime' : ses('authtime') };
+ obj.set_tab(obj.url_prefix(urls.XUL_OPAC_WRAPPER), {'tab_name':offlineStrings.getString('menu.cmd_search_opac.tab')}, content_params);
+ }
+ ],
+ 'cmd_search_tcn' : [
+ ['oncommand'],
+ function() {
+ var tcn = prompt(offlineStrings.getString('menu.cmd_search_tcn.tab'),'',offlineStrings.getString('menu.cmd_search_tcn.prompt'));
+
+ function spawn_tcn(r) {
+ for (var i = 0; i < r.count; i++) {
+ var id = r.ids[i];
+ var opac_url = obj.url_prefix( urls.opac_rdetail ) + '?r=' + id;
+ obj.data.stash_retrieve();
+ var content_params = {
+ 'session' : ses(),
+ 'authtime' : ses('authtime'),
+ 'opac_url' : opac_url,
+ };
+ if (i == 0) {
+ obj.set_tab(
+ obj.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name':tcn},
+ content_params
+ );
+ } else {
+ obj.new_tab(
+ obj.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name':tcn},
+ content_params
+ );
+ }
+ }
+ }
+
+ if (tcn) {
+ JSAN.use('util.network');
+ var network = new util.network();
+ var robj = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn]);
+ if (robj.count != robj.ids.length) throw('FIXME -- FM_BRE_ID_SEARCH_VIA_TCN = ' + js2JSON(robj));
+ if (robj.count == 0) {
+ var robj2 = network.simple_request('FM_BRE_ID_SEARCH_VIA_TCN',[tcn,1]);
+ if (robj2.count == 0) {
+ alert(offlineStrings.getFormattedString('menu.cmd_search_tcn.not_found.error', [tcn]));
+ } else {
+ if ( window.confirm(offlineStrings.getFormattedString('menu.cmd_search_tcn.deleted.error', [tcn])) ) {
+ spawn_tcn(robj2);
+ }
+ }
+ } else {
+ spawn_tcn(robj);
+ }
+ }
+ }
+ ],
+ 'cmd_search_bib_id' : [
+ ['oncommand'],
+ function() {
+ var bib_id = prompt(offlineStrings.getString('menu.cmd_search_bib_id.tab'),'',offlineStrings.getString('menu.cmd_search_bib_id.prompt'));
if (!bib_id) return;
- var opac_url = obj.url_prefix( urls.opac_rdetail ) + '?r=' + bib_id;
- var content_params = {
- 'session' : ses(),
- 'authtime' : ses('authtime'),
- 'opac_url' : opac_url,
- };
- obj.set_tab(
- obj.url_prefix(urls.XUL_OPAC_WRAPPER),
- {'tab_name':'#' + bib_id},
- content_params
- );
- }
- ],
- 'cmd_copy_status' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_COPY_STATUS),{},{});
- }
- ],
-
- /* Circulation Menu */
- 'cmd_patron_register' : [
- ['oncommand'],
- function() {
- function spawn_editor(p) {
- var url = urls.XUL_PATRON_EDIT;
- var param_count = 0;
- for (var i in p) {
- if (param_count++ == 0) url += '?'; else url += '&';
- url += i + '=' + window.escape(p[i]);
- }
- var loc = obj.url_prefix( urls.XUL_BROWSER ) + '?url=' + window.escape( obj.url_prefix(url) );
- obj.new_tab(
- loc,
- {},
- {
- 'show_print_button' : true ,
- 'tab_name' : offline.getString('menu.cmd_patron_register.related.tab'),
- 'passthru_content_params' : {
- 'spawn_search' : function(s) { obj.spawn_search(s); },
- 'spawn_editor' : spawn_editor,
- }
- }
- );
- }
-
- obj.data.stash_retrieve();
- var loc = obj.url_prefix( urls.XUL_BROWSER )
- + '?url=' + window.escape( obj.url_prefix(urls.XUL_PATRON_EDIT) + '?ses=' + window.escape( ses() ) );
- obj.set_tab(
- loc,
- {},
- {
- 'show_print_button' : true ,
- 'tab_name' : offlineStrings.getString('menu.cmd_patron_register.tab'),
- 'passthru_content_params' : {
- 'spawn_search' : function(s) { obj.spawn_search(s); },
- 'spawn_editor' : spawn_editor,
- }
- }
- );
- }
- ],
- 'cmd_circ_checkin' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_CHECKIN),{},{});
- }
- ],
- 'cmd_circ_renew' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_RENEW),{},{});
- }
- ],
- 'cmd_circ_checkout' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_PATRON_BARCODE_ENTRY),{},{});
- }
- ],
- 'cmd_circ_hold_capture' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_CHECKIN)+'?hold_capture=1',{},{});
- }
- ],
- 'cmd_browse_holds' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_HOLDS_BROWSER),{ 'tab_name' : offlineStrings.getString('menu.cmd_browse_holds.tab') },{});
- }
- ],
- 'cmd_browse_holds_shelf' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_HOLDS_BROWSER)+'?shelf=1',{ 'tab_name' : offlineStrings.getString('menu.cmd_browse_holds_shelf.tab') },{});
- }
- ],
- 'cmd_circ_hold_pull_list' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- var loc = urls.XUL_BROWSER + '?url=' + window.escape(
- obj.url_prefix(urls.XUL_HOLD_PULL_LIST) + '?ses='+window.escape(ses())
- );
- obj.set_tab( loc, {'tab_name' : offlineStrings.getString('menu.cmd_browse_hold_pull_list.tab')}, { 'show_print_button' : true } );
- }
- ],
-
- 'cmd_in_house_use' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_IN_HOUSE_USE),{},{});
- }
- ],
-
- 'cmd_standalone' : [
- ['oncommand'],
- function() {
- obj.set_tab(obj.url_prefix(urls.XUL_STANDALONE),{},{});
- }
- ],
-
- 'cmd_local_admin' : [
- ['oncommand'],
- function() {
- //obj.set_tab(obj.url_prefix(urls.XUL_LOCAL_ADMIN)+'?ses='+window.escape(ses())+'&session='+window.escape(ses()),{},{});
- var loc = urls.XUL_BROWSER + '?url=' + window.escape(
+ var opac_url = obj.url_prefix( urls.opac_rdetail ) + '?r=' + bib_id;
+ var content_params = {
+ 'session' : ses(),
+ 'authtime' : ses('authtime'),
+ 'opac_url' : opac_url,
+ };
+ obj.set_tab(
+ obj.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name':'#' + bib_id},
+ content_params
+ );
+ }
+ ],
+ 'cmd_copy_status' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_COPY_STATUS),{},{});
+ }
+ ],
+
+ /* Circulation Menu */
+ 'cmd_patron_register' : [
+ ['oncommand'],
+ function() {
+ function spawn_editor(p) {
+ var url = urls.XUL_PATRON_EDIT;
+ var param_count = 0;
+ for (var i in p) {
+ if (param_count++ == 0) url += '?'; else url += '&';
+ url += i + '=' + window.escape(p[i]);
+ }
+ var loc = obj.url_prefix( urls.XUL_BROWSER ) + '?url=' + window.escape( obj.url_prefix(url) );
+ obj.new_tab(
+ loc,
+ {},
+ {
+ 'show_print_button' : true ,
+ 'tab_name' : offline.getString('menu.cmd_patron_register.related.tab'),
+ 'passthru_content_params' : {
+ 'spawn_search' : function(s) { obj.spawn_search(s); },
+ 'spawn_editor' : spawn_editor,
+ }
+ }
+ );
+ }
+
+ obj.data.stash_retrieve();
+ var loc = obj.url_prefix( urls.XUL_BROWSER )
+ + '?url=' + window.escape( obj.url_prefix(urls.XUL_PATRON_EDIT) + '?ses=' + window.escape( ses() ) );
+ obj.set_tab(
+ loc,
+ {},
+ {
+ 'show_print_button' : true ,
+ 'tab_name' : offlineStrings.getString('menu.cmd_patron_register.tab'),
+ 'passthru_content_params' : {
+ 'spawn_search' : function(s) { obj.spawn_search(s); },
+ 'spawn_editor' : spawn_editor,
+ }
+ }
+ );
+ }
+ ],
+ 'cmd_circ_checkin' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_CHECKIN),{},{});
+ }
+ ],
+ 'cmd_circ_renew' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_RENEW),{},{});
+ }
+ ],
+ 'cmd_circ_checkout' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_PATRON_BARCODE_ENTRY),{},{});
+ }
+ ],
+ 'cmd_circ_hold_capture' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_CHECKIN)+'?hold_capture=1',{},{});
+ }
+ ],
+ 'cmd_browse_holds' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_HOLDS_BROWSER),{ 'tab_name' : offlineStrings.getString('menu.cmd_browse_holds.tab') },{});
+ }
+ ],
+ 'cmd_browse_holds_shelf' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_HOLDS_BROWSER)+'?shelf=1',{ 'tab_name' : offlineStrings.getString('menu.cmd_browse_holds_shelf.tab') },{});
+ }
+ ],
+ 'cmd_circ_hold_pull_list' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ var loc = urls.XUL_BROWSER + '?url=' + window.escape(
+ obj.url_prefix(urls.XUL_HOLD_PULL_LIST) + '?ses='+window.escape(ses())
+ );
+ obj.set_tab( loc, {'tab_name' : offlineStrings.getString('menu.cmd_browse_hold_pull_list.tab')}, { 'show_print_button' : true } );
+ }
+ ],
+
+ 'cmd_in_house_use' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_IN_HOUSE_USE),{},{});
+ }
+ ],
+
+ 'cmd_standalone' : [
+ ['oncommand'],
+ function() {
+ obj.set_tab(obj.url_prefix(urls.XUL_STANDALONE),{},{});
+ }
+ ],
+
+ 'cmd_local_admin' : [
+ ['oncommand'],
+ function() {
+ //obj.set_tab(obj.url_prefix(urls.XUL_LOCAL_ADMIN)+'?ses='+window.escape(ses())+'&session='+window.escape(ses()),{},{});
+ var loc = urls.XUL_BROWSER + '?url=' + window.escape(
obj.url_prefix( urls.XUL_LOCAL_ADMIN+'?ses='+window.escape(ses())+'&session='+window.escape(ses()) )
- );
- obj.set_tab(
- loc,
- {'tab_name' : offlineStrings.getString('menu.cmd_local_admin.tab'), 'browser' : false },
- { 'no_xulG' : false, 'show_nav_buttons' : true, 'show_print_button' : true }
- );
+ );
+ obj.set_tab(
+ loc,
+ {'tab_name' : offlineStrings.getString('menu.cmd_local_admin.tab'), 'browser' : false },
+ { 'no_xulG' : false, 'show_nav_buttons' : true, 'show_print_button' : true }
+ );
- }
- ],
+ }
+ ],
'cmd_toggle_buttonbar' : [
['oncommand'],
}
],
- 'cmd_local_admin_reports' : [
- ['oncommand'],
- function() {
- var loc = urls.XUL_BROWSER + '?url=' + window.escape( obj.url_prefix(urls.XUL_REPORTS) + '?ses=' + ses());
- obj.set_tab(
- loc,
- {'tab_name' : offlineStrings.getString('menu.cmd_local_admin_reports.tab'), 'browser' : false },
- {'no_xulG' : false, 'show_print_button' : false, show_nav_buttons : true }
- );
- }
- ],
- 'cmd_open_vandelay' : [
- ['oncommand'],
+ 'cmd_local_admin_reports' : [
+ ['oncommand'],
+ function() {
+ var loc = urls.XUL_BROWSER + '?url=' + window.escape( obj.url_prefix(urls.XUL_REPORTS) + '?ses=' + ses());
+ obj.set_tab(
+ loc,
+ {'tab_name' : offlineStrings.getString('menu.cmd_local_admin_reports.tab'), 'browser' : false },
+ {'no_xulG' : false, 'show_print_button' : false, show_nav_buttons : true }
+ );
+ }
+ ],
+ 'cmd_open_vandelay' : [
+ ['oncommand'],
function() { open_eg_web_page('vandelay/vandelay'); }
- ],
+ ],
'cmd_local_admin_transit_list' : [
['oncommand'],
function() { open_admin_page('transit_list.xul', 'menu.cmd_local_admin_transit_list.tab'); }
['oncommand'],
function() { open_eg_web_page('conify/global/config/org_unit_setting_type'); }
],
- 'cmd_acq_view_picklist' : [
- ['oncommand'],
- function() { open_eg_web_page('acq/picklist/list', 'menu.cmd_acq_view_picklist.tab'); }
- ],
- 'cmd_acq_view_po' : [
- ['oncommand'],
- function() { open_eg_web_page('acq/po/search', 'menu.cmd_acq_view_po.tab'); }
- ],
- 'cmd_acq_upload' : [
- ['oncommand'],
- function() { open_eg_web_page('acq/picklist/upload', 'menu.cmd_acq_upload.tab'); }
- ],
- 'cmd_acq_bib_search' : [
- ['oncommand'],
- function() { open_eg_web_page('acq/picklist/bib_search', 'menu.cmd_acq_bib_search.tab'); }
- ],
- 'cmd_acq_new_brief_record' : [
- ['oncommand'],
- function() { open_eg_web_page('acq/picklist/brief_record', 'menu.cmd_acq_new_brief_record.tab'); }
- ],
+ 'cmd_acq_view_picklist' : [
+ ['oncommand'],
+ function() { open_eg_web_page('acq/picklist/list', 'menu.cmd_acq_view_picklist.tab'); }
+ ],
+ 'cmd_acq_view_po' : [
+ ['oncommand'],
+ function() { open_eg_web_page('acq/po/search', 'menu.cmd_acq_view_po.tab'); }
+ ],
+ 'cmd_acq_upload' : [
+ ['oncommand'],
+ function() { open_eg_web_page('acq/picklist/upload', 'menu.cmd_acq_upload.tab'); }
+ ],
+ 'cmd_acq_bib_search' : [
+ ['oncommand'],
+ function() { open_eg_web_page('acq/picklist/bib_search', 'menu.cmd_acq_bib_search.tab'); }
+ ],
+ 'cmd_acq_new_brief_record' : [
+ ['oncommand'],
+ function() { open_eg_web_page('acq/picklist/brief_record', 'menu.cmd_acq_new_brief_record.tab'); }
+ ],
'cmd_acq_view_fund' : [
- ['oncommand'],
- function() { open_eg_web_page('acq/fund/list', 'menu.cmd_acq_view_fund.tab'); }
- ],
+ ['oncommand'],
+ function() { open_eg_web_page('acq/fund/list', 'menu.cmd_acq_view_fund.tab'); }
+ ],
'cmd_acq_view_funding_source' : [
- ['oncommand'],
- function() { open_eg_web_page('acq/funding_source/list', 'menu.cmd_acq_view_funding_source.tab'); }
- ],
+ ['oncommand'],
+ function() { open_eg_web_page('acq/funding_source/list', 'menu.cmd_acq_view_funding_source.tab'); }
+ ],
'cmd_acq_view_provider' : [
- ['oncommand'],
- function() { open_eg_web_page('conify/global/acq/provider', 'menu.cmd_acq_view_provider.tab'); }
- ],
+ ['oncommand'],
+ function() { open_eg_web_page('conify/global/acq/provider', 'menu.cmd_acq_view_provider.tab'); }
+ ],
'cmd_acq_view_currency_type' : [
- ['oncommand'],
- function() { open_eg_web_page('acq/currency_type/list', 'menu.cmd_acq_view_currency_type.tab'); }
- ],
+ ['oncommand'],
+ function() { open_eg_web_page('acq/currency_type/list', 'menu.cmd_acq_view_currency_type.tab'); }
+ ],
'cmd_acq_view_exchange_rate' : [
- ['oncommand'],
- function() { open_eg_web_page('conify/global/acq/exchange_rate', 'menu.cmd_acq_view_exchange_rate.tab'); }
- ],
+ ['oncommand'],
+ function() { open_eg_web_page('conify/global/acq/exchange_rate', 'menu.cmd_acq_view_exchange_rate.tab'); }
+ ],
'cmd_acq_view_distrib_formula' : [
- ['oncommand'],
- function() { open_eg_web_page('conify/global/acq/distribution_formula', 'menu.cmd_acq_view_distrib_formula.tab'); }
- ],
-
- 'cmd_reprint' : [
- ['oncommand'],
- function() {
- try {
- JSAN.use('util.print'); var print = new util.print();
- print.reprint_last();
- } catch(E) {
- alert(E);
- }
- }
- ],
-
- 'cmd_retrieve_last_patron' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- if (!obj.data.last_patron) {
- alert(offlineStrings.getString('menu.cmd_retrieve_last_patron.session.error'));
- return;
- }
+ ['oncommand'],
+ function() { open_eg_web_page('conify/global/acq/distribution_formula', 'menu.cmd_acq_view_distrib_formula.tab'); }
+ ],
+
+ 'cmd_reprint' : [
+ ['oncommand'],
+ function() {
+ try {
+ JSAN.use('util.print'); var print = new util.print();
+ print.reprint_last();
+ } catch(E) {
+ alert(E);
+ }
+ }
+ ],
+
+ 'cmd_retrieve_last_patron' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ if (!obj.data.last_patron) {
+ alert(offlineStrings.getString('menu.cmd_retrieve_last_patron.session.error'));
+ return;
+ }
var horizontal_interface = String( obj.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
var url = obj.url_prefix( horizontal_interface ? urls.XUL_PATRON_HORIZ_DISPLAY : urls.XUL_PATRON_DISPLAY );
- obj.set_tab( url, {}, { 'id' : obj.data.last_patron } );
- }
- ],
-
- 'cmd_retrieve_last_record' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- if (!obj.data.last_record) {
- alert(offlineStrings.getString('menu.cmd_retrieve_last_record.session.error'));
- return;
- }
- var opac_url = obj.url_prefix( urls.opac_rdetail ) + '?r=' + obj.data.last_record;
- var content_params = {
- 'session' : ses(),
- 'authtime' : ses('authtime'),
- 'opac_url' : opac_url,
- };
- obj.set_tab(
- obj.url_prefix(urls.XUL_OPAC_WRAPPER),
- {'tab_name' : offlineStrings.getString('menu.cmd_retrieve_last_record.status')},
- content_params
- );
- }
- ],
+ obj.set_tab( url, {}, { 'id' : obj.data.last_patron } );
+ }
+ ],
+
+ 'cmd_retrieve_last_record' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ if (!obj.data.last_record) {
+ alert(offlineStrings.getString('menu.cmd_retrieve_last_record.session.error'));
+ return;
+ }
+ var opac_url = obj.url_prefix( urls.opac_rdetail ) + '?r=' + obj.data.last_record;
+ var content_params = {
+ 'session' : ses(),
+ 'authtime' : ses('authtime'),
+ 'opac_url' : opac_url,
+ };
+ obj.set_tab(
+ obj.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name' : offlineStrings.getString('menu.cmd_retrieve_last_record.status')},
+ content_params
+ );
+ }
+ ],
'cmd_verify_credentials' : [
['oncommand'],
function() {
- obj.set_tab(
- obj.url_prefix(urls.XUL_VERIFY_CREDENTIALS),
- { 'tab_name' : offlineStrings.getString('menu.cmd_verify_credentials.tabname') },
- {}
- );
+ obj.set_tab(
+ obj.url_prefix(urls.XUL_VERIFY_CREDENTIALS),
+ { 'tab_name' : offlineStrings.getString('menu.cmd_verify_credentials.tabname') },
+ {}
+ );
+ }
+ ],
+
+ /* Cataloging Menu */
+ 'cmd_z39_50_import' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_Z3950_IMPORT),{},{});
+ }
+ ],
+ 'cmd_create_marc' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_MARC_NEW),{},{});
}
],
- /* Cataloging Menu */
- 'cmd_z39_50_import' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_Z3950_IMPORT),{},{});
- }
- ],
- 'cmd_create_marc' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_MARC_NEW),{},{});
- }
- ],
-
- /* Admin menu */
- 'cmd_change_session' : [
- ['oncommand'],
- function() {
- try {
- obj.data.stash_retrieve();
- JSAN.use('util.network'); var network = new util.network();
- var x = document.getElementById('oc_menuitem');
- var x_label = x.getAttribute('label_orig');
- var temp_au = js2JSON( obj.data.list.au[0] );
- var temp_ses = js2JSON( obj.data.session );
- if (obj.data.list.au.length > 1) {
- obj.data.list.au = [ obj.data.list.au[1] ];
- obj.data.stash('list');
- network.reset_titlebars( obj.data );
- x.setAttribute('label', x_label );
- network.simple_request('AUTH_DELETE', [ obj.data.session.key ] );
- obj.data.session = obj.data.previous_session;
- obj.data.stash('session');
- try {
+ /* Admin menu */
+ 'cmd_change_session' : [
+ ['oncommand'],
+ function() {
+ try {
+ obj.data.stash_retrieve();
+ JSAN.use('util.network'); var network = new util.network();
+ var x = document.getElementById('oc_menuitem');
+ var x_label = x.getAttribute('label_orig');
+ var temp_au = js2JSON( obj.data.list.au[0] );
+ var temp_ses = js2JSON( obj.data.session );
+ if (obj.data.list.au.length > 1) {
+ obj.data.list.au = [ obj.data.list.au[1] ];
+ obj.data.stash('list');
+ network.reset_titlebars( obj.data );
+ x.setAttribute('label', x_label );
+ network.simple_request('AUTH_DELETE', [ obj.data.session.key ] );
+ obj.data.session = obj.data.previous_session;
+ obj.data.stash('session');
+ try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
- var cookieUri = ios.newURI("http://" + obj.data.server_unadorned, null, null);
- var cookieUriSSL = ios.newURI("https://" + obj.data.server_unadorned, null, null);
- var cookieSvc = Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService);
-
- cookieSvc.setCookieString(cookieUri, null, "ses="+obj.data.session.key, null);
- cookieSvc.setCookieString(cookieUriSSL, null, "ses="+obj.data.session.key, null);
-
- } catch(E) {
- alert(offlineStrings.getFormattedString(main.session_cookie.error, [E]));
- }
-
- removeCSSClass(document.getElementById('main_tabbox'),'operator_change');
- } else {
- if (network.get_new_session(offlineStrings.getString('menu.cmd_chg_session.label'),{'url_prefix':obj.url_prefix})) {
- obj.data.stash_retrieve();
- obj.data.list.au[1] = JSON2js( temp_au );
- obj.data.stash('list');
- obj.data.previous_session = JSON2js( temp_ses );
- obj.data.stash('previous_session');
- x.setAttribute('label', offlineStrings.getFormattedString('menu.cmd_chg_session.operator.label', [obj.data.list.au[1].usrname()]) );
- addCSSClass(document.getElementById('main_tabbox'),'operator_change');
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('cmd_change_session',E);
- }
- }
- ],
- 'cmd_manage_offline_xacts' : [
- ['oncommand'],
- function() {
- obj.set_tab(obj.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS), {'tab_name' : offlineStrings.getString('menu.cmd_manage_offline_xacts.tab')}, {});
- }
- ],
- 'cmd_download_patrons' : [
- ['oncommand'],
- function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- var x = new XMLHttpRequest();
- var url = 'http://' + XML_HTTP_SERVER + '/standalone/list.txt';
- x.open("GET",url,false);
- x.send(null);
- if (x.status == 200) {
- JSAN.use('util.file'); var file = new util.file('offline_patron_list');
- file.write_content('truncate',x.responseText);
- file.close();
- file = new util.file('offline_patron_list.date');
- file.write_content('truncate',new Date());
- file.close();
- alert(offlineStrings.getString('menu.cmd_download_patrons.complete.status'));
- } else {
- alert(offlineStrings.getFormattedString('menu.cmd_download_patrons.error', [x.status, x.statusText]));
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('cmd_download_patrons',E);
- }
- }
- ],
- 'cmd_adv_user_edit' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_PATRON_BARCODE_ENTRY), {}, { 'perm_editor' : true });
- }
- ],
- 'cmd_print_list_template_edit' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_PRINT_LIST_TEMPLATE_EDITOR), {}, {});
- }
- ],
- 'cmd_stat_cat_edit' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_STAT_CAT_EDIT) + '?ses='+window.escape(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_stat_cat_edit.tab')},{});
- }
- ],
- 'cmd_non_cat_type_edit' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_NON_CAT_LABEL_EDIT) + '?ses='+window.escape(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_non_cat_type_edit.tab')},{});
- }
- ],
- 'cmd_copy_location_edit' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.XUL_COPY_LOCATION_EDIT) + '?ses='+window.escape(ses()),{'tab_name' : offlineStrings.getString('menu.cmd_copy_location_edit.tab')},{});
- }
- ],
- 'cmd_test' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- var content_params = { 'session' : ses(), 'authtime' : ses('authtime') };
- obj.set_tab(obj.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
- }
- ],
- 'cmd_test_html' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.TEST_HTML) + '?ses='+window.escape(ses()),{ 'browser' : true },{});
- }
- ],
- 'cmd_test_xul' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- obj.set_tab(obj.url_prefix(urls.TEST_XUL) + '?ses='+window.escape(ses()),{ 'browser' : false },{});
- }
- ],
- 'cmd_console' : [
- ['oncommand'],
- function() {
- obj.set_tab(obj.url_prefix(urls.XUL_DEBUG_CONSOLE),{'tab_name' : offlineStrings.getString('menu.cmd_console.tab')},{});
- }
- ],
- 'cmd_shell' : [
- ['oncommand'],
- function() {
- obj.set_tab(obj.url_prefix(urls.XUL_DEBUG_SHELL),{'tab_name' : offlineStrings.getString('menu.cmd_shell.tab')},{});
- }
- ],
- 'cmd_xuleditor' : [
- ['oncommand'],
- function() {
- obj.set_tab(obj.url_prefix(urls.XUL_DEBUG_XULEDITOR),{'tab_name' : offlineStrings.getString('menu.cmd_xuleditor.tab')},{});
- }
- ],
- 'cmd_fieldmapper' : [
- ['oncommand'],
- function() {
- obj.set_tab(obj.url_prefix(urls.XUL_DEBUG_FIELDMAPPER),{'tab_name' : offlineStrings.getString('menu.cmd_fieldmapper.tab')},{});
- }
- ],
- 'cmd_survey_wizard' : [
- ['oncommand'],
- function() {
- obj.data.stash_retrieve();
- xulG.window.open(obj.url_prefix(urls.XUL_SURVEY_WIZARD),'survey_wizard','chrome');
- }
- ],
- 'cmd_public_opac' : [
- ['oncommand'],
- function() {
- var loc = urls.XUL_BROWSER + '?url=' + window.escape(
- obj.url_prefix(urls.remote)
- );
- obj.set_tab(
- loc,
- {'tab_name' : offlineStrings.getString('menu.cmd_public_opac.tab'), 'browser' : false},
- { 'no_xulG' : true, 'show_nav_buttons' : true, 'show_print_button' : true }
- );
- }
- ],
- 'cmd_clear_cache' : [
- ['oncommand'],
- function clear_the_cache() {
- try {
+ var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
+ var cookieUri = ios.newURI("http://" + obj.data.server_unadorned, null, null);
+ var cookieUriSSL = ios.newURI("https://" + obj.data.server_unadorned, null, null);
+ var cookieSvc = Components.classes["@mozilla.org/cookieService;1"].getService(Components.interfaces.nsICookieService);
+
+ cookieSvc.setCookieString(cookieUri, null, "ses="+obj.data.session.key, null);
+ cookieSvc.setCookieString(cookieUriSSL, null, "ses="+obj.data.session.key, null);
+
+ } catch(E) {
+ alert(offlineStrings.getFormattedString(main.session_cookie.error, [E]));
+ }
+
+ removeCSSClass(document.getElementById('main_tabbox'),'operator_change');
+ } else {
+ if (network.get_new_session(offlineStrings.getString('menu.cmd_chg_session.label'),{'url_prefix':obj.url_prefix})) {
+ obj.data.stash_retrieve();
+ obj.data.list.au[1] = JSON2js( temp_au );
+ obj.data.stash('list');
+ obj.data.previous_session = JSON2js( temp_ses );
+ obj.data.stash('previous_session');
+ x.setAttribute('label', offlineStrings.getFormattedString('menu.cmd_chg_session.operator.label', [obj.data.list.au[1].usrname()]) );
+ addCSSClass(document.getElementById('main_tabbox'),'operator_change');
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('cmd_change_session',E);
+ }
+ }
+ ],
+ 'cmd_manage_offline_xacts' : [
+ ['oncommand'],
+ function() {
+ obj.set_tab(obj.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS), {'tab_name' : offlineStrings.getString('menu.cmd_manage_offline_xacts.tab')}, {});
+ }
+ ],
+ 'cmd_download_patrons' : [
+ ['oncommand'],
+ function() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ var x = new XMLHttpRequest();
+ var url = 'http://' + XML_HTTP_SERVER + '/standalone/list.txt';
+ x.open("GET",url,false);
+ x.send(null);
+ if (x.status == 200) {
+ JSAN.use('util.file'); var file = new util.file('offline_patron_list');
+ file.write_content('truncate',x.responseText);
+ file.close();
+ file = new util.file('offline_patron_list.date');
+ file.write_content('truncate',new Date());
+ file.close();
+ alert(offlineStrings.getString('menu.cmd_download_patrons.complete.status'));
+ } else {
+ alert(offlineStrings.getFormattedString('menu.cmd_download_patrons.error', [x.status, x.statusText]));
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('cmd_download_patrons',E);
+ }
+ }
+ ],
+ 'cmd_adv_user_edit' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_PATRON_BARCODE_ENTRY), {}, { 'perm_editor' : true });
+ }
+ ],
+ 'cmd_print_list_template_edit' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_PRINT_LIST_TEMPLATE_EDITOR), {}, {});
+ }
+ ],
+ 'cmd_stat_cat_edit' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_STAT_CAT_EDIT) + '?ses='+window.escape(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_stat_cat_edit.tab')},{});
+ }
+ ],
+ 'cmd_non_cat_type_edit' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_NON_CAT_LABEL_EDIT) + '?ses='+window.escape(ses()), {'tab_name' : offlineStrings.getString('menu.cmd_non_cat_type_edit.tab')},{});
+ }
+ ],
+ 'cmd_copy_location_edit' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.XUL_COPY_LOCATION_EDIT) + '?ses='+window.escape(ses()),{'tab_name' : offlineStrings.getString('menu.cmd_copy_location_edit.tab')},{});
+ }
+ ],
+ 'cmd_test' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ var content_params = { 'session' : ses(), 'authtime' : ses('authtime') };
+ obj.set_tab(obj.url_prefix(urls.XUL_OPAC_WRAPPER), {}, content_params);
+ }
+ ],
+ 'cmd_test_html' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.TEST_HTML) + '?ses='+window.escape(ses()),{ 'browser' : true },{});
+ }
+ ],
+ 'cmd_test_xul' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ obj.set_tab(obj.url_prefix(urls.TEST_XUL) + '?ses='+window.escape(ses()),{ 'browser' : false },{});
+ }
+ ],
+ 'cmd_console' : [
+ ['oncommand'],
+ function() {
+ obj.set_tab(obj.url_prefix(urls.XUL_DEBUG_CONSOLE),{'tab_name' : offlineStrings.getString('menu.cmd_console.tab')},{});
+ }
+ ],
+ 'cmd_shell' : [
+ ['oncommand'],
+ function() {
+ obj.set_tab(obj.url_prefix(urls.XUL_DEBUG_SHELL),{'tab_name' : offlineStrings.getString('menu.cmd_shell.tab')},{});
+ }
+ ],
+ 'cmd_xuleditor' : [
+ ['oncommand'],
+ function() {
+ obj.set_tab(obj.url_prefix(urls.XUL_DEBUG_XULEDITOR),{'tab_name' : offlineStrings.getString('menu.cmd_xuleditor.tab')},{});
+ }
+ ],
+ 'cmd_fieldmapper' : [
+ ['oncommand'],
+ function() {
+ obj.set_tab(obj.url_prefix(urls.XUL_DEBUG_FIELDMAPPER),{'tab_name' : offlineStrings.getString('menu.cmd_fieldmapper.tab')},{});
+ }
+ ],
+ 'cmd_survey_wizard' : [
+ ['oncommand'],
+ function() {
+ obj.data.stash_retrieve();
+ xulG.window.open(obj.url_prefix(urls.XUL_SURVEY_WIZARD),'survey_wizard','chrome');
+ }
+ ],
+ 'cmd_public_opac' : [
+ ['oncommand'],
+ function() {
+ var loc = urls.XUL_BROWSER + '?url=' + window.escape(
+ obj.url_prefix(urls.remote)
+ );
+ obj.set_tab(
+ loc,
+ {'tab_name' : offlineStrings.getString('menu.cmd_public_opac.tab'), 'browser' : false},
+ { 'no_xulG' : true, 'show_nav_buttons' : true, 'show_print_button' : true }
+ );
+ }
+ ],
+ 'cmd_clear_cache' : [
+ ['oncommand'],
+ function clear_the_cache() {
+ try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
- var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
- cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
- cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
- } catch(E) {
- dump(E+'\n');alert(E);
- }
- }
- ],
- 'cmd_restore_all_tabs' : [
- ['oncommand'],
- function() {
- var tabs = obj.controller.view.tabs;
- for (var i = 0; i < tabs.childNodes.length; i++) {
- tabs.childNodes[i].hidden = false;
- }
- }
- ],
- 'cmd_extension_manager' : [
- ['oncommand'],
- function() {
- obj.set_tab('chrome://mozapps/content/extensions/extensions.xul?type=extensions',{'tab_name' : offlineStrings.getString('menu.cmd_extension_manager.tab')},{});
- }
- ],
- 'cmd_theme_manager' : [
- ['oncommand'],
- function() {
- obj.set_tab('chrome://mozapps/content/extensions/extensions.xul?type=themes',{'tab_name' : offlineStrings.getString('menu.cmd_theme_manager.tab')},{});
- }
- ],
- 'cmd_about_config' : [
- ['oncommand'],
- function() {
- obj.set_tab('chrome://global/content/config.xul',{'tab_name' : 'about:config'},{});
- }
- ],
- 'cmd_shutdown' : [
- ['oncommand'],
- function() {
- if (window.confirm(offlineStrings.getString('menu.cmd_shutdown.prompt'))) {
+ var cacheClass = Components.classes["@mozilla.org/network/cache-service;1"];
+ var cacheService = cacheClass.getService(Components.interfaces.nsICacheService);
+ cacheService.evictEntries(Components.interfaces.nsICache.STORE_ON_DISK);
+ cacheService.evictEntries(Components.interfaces.nsICache.STORE_IN_MEMORY);
+ } catch(E) {
+ dump(E+'\n');alert(E);
+ }
+ }
+ ],
+ 'cmd_restore_all_tabs' : [
+ ['oncommand'],
+ function() {
+ var tabs = obj.controller.view.tabs;
+ for (var i = 0; i < tabs.childNodes.length; i++) {
+ tabs.childNodes[i].hidden = false;
+ }
+ }
+ ],
+ 'cmd_extension_manager' : [
+ ['oncommand'],
+ function() {
+ obj.set_tab('chrome://mozapps/content/extensions/extensions.xul?type=extensions',{'tab_name' : offlineStrings.getString('menu.cmd_extension_manager.tab')},{});
+ }
+ ],
+ 'cmd_theme_manager' : [
+ ['oncommand'],
+ function() {
+ obj.set_tab('chrome://mozapps/content/extensions/extensions.xul?type=themes',{'tab_name' : offlineStrings.getString('menu.cmd_theme_manager.tab')},{});
+ }
+ ],
+ 'cmd_about_config' : [
+ ['oncommand'],
+ function() {
+ obj.set_tab('chrome://global/content/config.xul',{'tab_name' : 'about:config'},{});
+ }
+ ],
+ 'cmd_shutdown' : [
+ ['oncommand'],
+ function() {
+ if (window.confirm(offlineStrings.getString('menu.cmd_shutdown.prompt'))) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
- var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
- var enumerator = windowManagerInterface.getEnumerator(null);
- var w; // close all other windows
- while ( w = enumerator.getNext() ) {
- if (w != window) w.close();
- }
- window.close();
- }
- }
- ],
-
- };
-
- JSAN.use('util.controller');
- var cmd;
- obj.controller = new util.controller();
- obj.controller.init( { 'window_knows_me_by' : 'g.menu.controller', 'control_map' : cmd_map } );
-
- obj.controller.view.tabbox = window.document.getElementById('main_tabbox');
- obj.controller.view.tabs = obj.controller.view.tabbox.firstChild;
- obj.controller.view.panels = obj.controller.view.tabbox.lastChild;
-
- obj.new_tab(null,{'focus':true},null);
-
- obj.init_tab_focus_handlers();
- },
-
- 'spawn_search' : function(s) {
- var obj = this;
- obj.error.sdump('D_TRACE', offlineStrings.getFormattedString('menu.spawn_search.msg', [js2JSON(s)]) );
- obj.data.stash_retrieve();
- var loc = obj.url_prefix(urls.XUL_PATRON_DISPLAY);
- loc += '?doit=1&query=' + window.escape(js2JSON(s));
- obj.new_tab( loc, {}, {} );
- },
-
- 'init_tab_focus_handlers' : function() {
- var obj = this;
- for (var i = 0; i < obj.controller.view.tabs.childNodes.length; i++) {
- var tab = obj.controller.view.tabs.childNodes[i];
- var panel = obj.controller.view.panels.childNodes[i];
- tab.addEventListener(
- 'command',
- function(p) {
- return function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (p
- && p.firstChild
- && ( p.firstChild.nodeName == 'iframe' || p.firstChild.nodeName == 'browser' )
- && p.firstChild.contentWindow
- ) {
- if (typeof p.firstChild.contentWindow.default_focus == 'function') {
- p.firstChild.contentWindow.default_focus();
- } else {
- //p.firstChild.contentWindow.firstChild.focus();
- }
- }
- } catch(E) {
- obj.error.sdump('D_ERROR','init_tab_focus_handler: ' + js2JSON(E));
- }
- }
- }(panel),
- false
- );
- }
- },
-
- 'close_all_tabs' : function() {
- var obj = this;
- try {
- var count = obj.controller.view.tabs.childNodes.length;
- for (var i = 0; i < count; i++) obj.close_tab();
- setTimeout( function(){ obj.controller.view.tabs.firstChild.focus(); }, 0);
- } catch(E) {
- obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.close_all_tabs.error'),E);
- }
- },
-
- 'close_tab' : function () {
- var idx = this.controller.view.tabs.selectedIndex;
- var tab = this.controller.view.tabs.childNodes[idx];
- var panel = this.controller.view.panels.childNodes[ idx ];
- while ( panel.lastChild ) panel.removeChild( panel.lastChild );
- if (idx == 0) {
- try {
- this.controller.view.tabs.advanceSelectedTab(+1);
- } catch(E) {
- this.error.sdump('D_TAB','failed tabs.advanceSelectedTab(+1):'+js2JSON(E) + '\n');
- try {
- this.controller.view.tabs.advanceSelectedTab(-1);
- } catch(E) {
- this.error.sdump('D_TAB','failed again tabs.advanceSelectedTab(-1):'+
- js2JSON(E) + '\n');
- }
- }
- } else {
- try {
- this.controller.view.tabs.advanceSelectedTab(-1);
- } catch(E) {
- this.error.sdump('D_TAB','failed tabs.advanceSelectedTab(-1):'+js2JSON(E) + '\n');
- try {
- this.controller.view.tabs.advanceSelectedTab(+1);
- } catch(E) {
- this.error.sdump('D_TAB','failed again tabs.advanceSelectedTab(+1):'+
- js2JSON(E) + '\n');
- }
- }
-
- }
-
- this.error.sdump('D_TAB','\tnew tabbox.selectedIndex = ' + this.controller.view.tabbox.selectedIndex + '\n');
-
- this.controller.view.tabs.childNodes[ idx ].hidden = true;
- this.error.sdump('D_TAB','tabs.childNodes[ ' + idx + ' ].hidden = true;\n');
-
- // Make sure we keep at least one tab open.
- var tab_flag = true;
- for (var i = 0; i < this.controller.view.tabs.childNodes.length; i++) {
- var tab = this.controller.view.tabs.childNodes[i];
- if (!tab.hidden)
- tab_flag = false;
- }
- if (tab_flag) {
- this.controller.view.tabs.selectedIndex = 0;
- this.new_tab();
- }
- },
-
- 'find_free_tab' : function() {
- var last_not_hidden = -1;
- for (var i = 0; i<this.controller.view.tabs.childNodes.length; i++) {
- var tab = this.controller.view.tabs.childNodes[i];
- if (!tab.hidden)
- last_not_hidden = i;
- }
- if (last_not_hidden == this.controller.view.tabs.childNodes.length - 1)
- last_not_hidden = -1;
- // If the one next to last_not_hidden is hidden, we want it.
- // Basically, we fill in tabs after existing tabs for as
- // long as possible.
- var idx = last_not_hidden + 1;
- var candidate = this.controller.view.tabs.childNodes[ idx ];
- if (candidate.hidden)
- return idx;
- // Alright, find the first hidden then
- for (var i = 0; i<this.controller.view.tabs.childNodes.length; i++) {
- var tab = this.controller.view.tabs.childNodes[i];
- if (tab.hidden)
- return i;
- }
- return -1;
- },
-
- 'new_tab' : function(url,params,content_params) {
- var tc = this.find_free_tab();
- if (tc == -1) { return null; } // 9 tabs max
- var tab = this.controller.view.tabs.childNodes[ tc ];
- tab.hidden = false;
- if (!content_params) content_params = {};
- if (!params) params = {};
- if (!params.tab_name) params.tab_name = offlineStrings.getString('menu.new_tab.tab');
- if (!params.nofocus) params.focus = true; /* make focus the default */
- try {
- if (params.focus) this.controller.view.tabs.selectedIndex = tc;
- params.index = tc;
- this.set_tab(url,params,content_params);
- } catch(E) {
- this.error.sdump('D_ERROR',E);
- }
- },
+ var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
+ var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
+ var enumerator = windowManagerInterface.getEnumerator(null);
+ var w; // close all other windows
+ while ( w = enumerator.getNext() ) {
+ if (w != window) w.close();
+ }
+ window.close();
+ }
+ }
+ ],
+
+ };
+
+ JSAN.use('util.controller');
+ var cmd;
+ obj.controller = new util.controller();
+ obj.controller.init( { 'window_knows_me_by' : 'g.menu.controller', 'control_map' : cmd_map } );
+
+ obj.controller.view.tabbox = window.document.getElementById('main_tabbox');
+ obj.controller.view.tabs = obj.controller.view.tabbox.firstChild;
+ obj.controller.view.panels = obj.controller.view.tabbox.lastChild;
+
+ obj.new_tab(null,{'focus':true},null);
+
+ obj.init_tab_focus_handlers();
+ },
+
+ 'spawn_search' : function(s) {
+ var obj = this;
+ obj.error.sdump('D_TRACE', offlineStrings.getFormattedString('menu.spawn_search.msg', [js2JSON(s)]) );
+ obj.data.stash_retrieve();
+ var loc = obj.url_prefix(urls.XUL_PATRON_DISPLAY);
+ loc += '?doit=1&query=' + window.escape(js2JSON(s));
+ obj.new_tab( loc, {}, {} );
+ },
+
+ 'init_tab_focus_handlers' : function() {
+ var obj = this;
+ for (var i = 0; i < obj.controller.view.tabs.childNodes.length; i++) {
+ var tab = obj.controller.view.tabs.childNodes[i];
+ var panel = obj.controller.view.panels.childNodes[i];
+ tab.addEventListener(
+ 'command',
+ function(p) {
+ return function() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (p
+ && p.firstChild
+ && ( p.firstChild.nodeName == 'iframe' || p.firstChild.nodeName == 'browser' )
+ && p.firstChild.contentWindow
+ ) {
+ if (typeof p.firstChild.contentWindow.default_focus == 'function') {
+ p.firstChild.contentWindow.default_focus();
+ } else {
+ //p.firstChild.contentWindow.firstChild.focus();
+ }
+ }
+ } catch(E) {
+ obj.error.sdump('D_ERROR','init_tab_focus_handler: ' + js2JSON(E));
+ }
+ }
+ }(panel),
+ false
+ );
+ }
+ },
+
+ 'close_all_tabs' : function() {
+ var obj = this;
+ try {
+ var count = obj.controller.view.tabs.childNodes.length;
+ for (var i = 0; i < count; i++) obj.close_tab();
+ setTimeout( function(){ obj.controller.view.tabs.firstChild.focus(); }, 0);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(offlineStrings.getString('menu.close_all_tabs.error'),E);
+ }
+ },
+
+ 'close_tab' : function () {
+ var idx = this.controller.view.tabs.selectedIndex;
+ var tab = this.controller.view.tabs.childNodes[idx];
+ var panel = this.controller.view.panels.childNodes[ idx ];
+ while ( panel.lastChild ) panel.removeChild( panel.lastChild );
+ if (idx == 0) {
+ try {
+ this.controller.view.tabs.advanceSelectedTab(+1);
+ } catch(E) {
+ this.error.sdump('D_TAB','failed tabs.advanceSelectedTab(+1):'+js2JSON(E) + '\n');
+ try {
+ this.controller.view.tabs.advanceSelectedTab(-1);
+ } catch(E) {
+ this.error.sdump('D_TAB','failed again tabs.advanceSelectedTab(-1):'+
+ js2JSON(E) + '\n');
+ }
+ }
+ } else {
+ try {
+ this.controller.view.tabs.advanceSelectedTab(-1);
+ } catch(E) {
+ this.error.sdump('D_TAB','failed tabs.advanceSelectedTab(-1):'+js2JSON(E) + '\n');
+ try {
+ this.controller.view.tabs.advanceSelectedTab(+1);
+ } catch(E) {
+ this.error.sdump('D_TAB','failed again tabs.advanceSelectedTab(+1):'+
+ js2JSON(E) + '\n');
+ }
+ }
+
+ }
+
+ this.error.sdump('D_TAB','\tnew tabbox.selectedIndex = ' + this.controller.view.tabbox.selectedIndex + '\n');
+
+ this.controller.view.tabs.childNodes[ idx ].hidden = true;
+ this.error.sdump('D_TAB','tabs.childNodes[ ' + idx + ' ].hidden = true;\n');
+
+ // Make sure we keep at least one tab open.
+ var tab_flag = true;
+ for (var i = 0; i < this.controller.view.tabs.childNodes.length; i++) {
+ var tab = this.controller.view.tabs.childNodes[i];
+ if (!tab.hidden)
+ tab_flag = false;
+ }
+ if (tab_flag) {
+ this.controller.view.tabs.selectedIndex = 0;
+ this.new_tab();
+ }
+ },
+
+ 'find_free_tab' : function() {
+ var last_not_hidden = -1;
+ for (var i = 0; i<this.controller.view.tabs.childNodes.length; i++) {
+ var tab = this.controller.view.tabs.childNodes[i];
+ if (!tab.hidden)
+ last_not_hidden = i;
+ }
+ if (last_not_hidden == this.controller.view.tabs.childNodes.length - 1)
+ last_not_hidden = -1;
+ // If the one next to last_not_hidden is hidden, we want it.
+ // Basically, we fill in tabs after existing tabs for as
+ // long as possible.
+ var idx = last_not_hidden + 1;
+ var candidate = this.controller.view.tabs.childNodes[ idx ];
+ if (candidate.hidden)
+ return idx;
+ // Alright, find the first hidden then
+ for (var i = 0; i<this.controller.view.tabs.childNodes.length; i++) {
+ var tab = this.controller.view.tabs.childNodes[i];
+ if (tab.hidden)
+ return i;
+ }
+ return -1;
+ },
+
+ 'new_tab' : function(url,params,content_params) {
+ var tc = this.find_free_tab();
+ if (tc == -1) { return null; } // 9 tabs max
+ var tab = this.controller.view.tabs.childNodes[ tc ];
+ tab.hidden = false;
+ if (!content_params) content_params = {};
+ if (!params) params = {};
+ if (!params.tab_name) params.tab_name = offlineStrings.getString('menu.new_tab.tab');
+ if (!params.nofocus) params.focus = true; /* make focus the default */
+ try {
+ if (params.focus) this.controller.view.tabs.selectedIndex = tc;
+ params.index = tc;
+ this.set_tab(url,params,content_params);
+ } catch(E) {
+ this.error.sdump('D_ERROR',E);
+ }
+ },
'network_meter' : {
'inc' : function(app,method) {
var url = obj.url_prefix( horizontal_interface ? urls.XUL_PATRON_HORIZ_DISPLAY : urls.XUL_PATRON_DISPLAY );
obj.new_tab(url,params ? params : {},content_params ? content_params : {});
},
- 'set_tab' : function(url,params,content_params) {
- var obj = this;
- if (!url) url = '/xul/server/';
- if (!url.match(/:\/\//) && !url.match(/^data:/)) url = urls.remote + url;
- if (!params) params = {};
- if (!content_params) content_params = {};
- var idx = this.controller.view.tabs.selectedIndex;
- if (params && typeof params.index != 'undefined') idx = params.index;
- var tab = this.controller.view.tabs.childNodes[ idx ];
- if (params.focus) tab.focus();
- var panel = this.controller.view.panels.childNodes[ idx ];
- while ( panel.lastChild ) panel.removeChild( panel.lastChild );
-
- content_params.new_tab = function(a,b,c) { return obj.new_tab(a,b,c); };
- content_params.set_tab = function(a,b,c) { return obj.set_tab(a,b,c); };
- content_params.close_tab = function() { return obj.close_tab(); };
- content_params.new_patron_tab = function(a,b) { return obj.new_patron_tab(a,b); };
- content_params.set_patron_tab = function(a,b) { return obj.set_patron_tab(a,b); };
- content_params.set_tab_name = function(name) { tab.setAttribute('label',(idx + 1) + ' ' + name); };
- content_params.open_chrome_window = function(a,b,c) { return xulG.window.open(a,b,c); };
- content_params.url_prefix = function(url) { return obj.url_prefix(url); };
+ 'set_tab' : function(url,params,content_params) {
+ var obj = this;
+ if (!url) url = '/xul/server/';
+ if (!url.match(/:\/\//) && !url.match(/^data:/)) url = urls.remote + url;
+ if (!params) params = {};
+ if (!content_params) content_params = {};
+ var idx = this.controller.view.tabs.selectedIndex;
+ if (params && typeof params.index != 'undefined') idx = params.index;
+ var tab = this.controller.view.tabs.childNodes[ idx ];
+ if (params.focus) tab.focus();
+ var panel = this.controller.view.panels.childNodes[ idx ];
+ while ( panel.lastChild ) panel.removeChild( panel.lastChild );
+
+ content_params.new_tab = function(a,b,c) { return obj.new_tab(a,b,c); };
+ content_params.set_tab = function(a,b,c) { return obj.set_tab(a,b,c); };
+ content_params.close_tab = function() { return obj.close_tab(); };
+ content_params.new_patron_tab = function(a,b) { return obj.new_patron_tab(a,b); };
+ content_params.set_patron_tab = function(a,b) { return obj.set_patron_tab(a,b); };
+ content_params.set_tab_name = function(name) { tab.setAttribute('label',(idx + 1) + ' ' + name); };
+ content_params.open_chrome_window = function(a,b,c) { return xulG.window.open(a,b,c); };
+ content_params.url_prefix = function(url) { return obj.url_prefix(url); };
content_params.network_meter = obj.network_meter;
content_params.chrome_xulG = xulG;
- if (params && params.tab_name) content_params.set_tab_name( params.tab_name );
-
- var frame;
- try {
+ if (params && params.tab_name) content_params.set_tab_name( params.tab_name );
+
+ var frame;
+ try {
if (typeof params.browser == 'undefined') params.browser = false;
- if (params.browser) {
- obj.id_incr++;
- frame = this.w.document.createElement('browser');
- frame.setAttribute('flex','1');
- frame.setAttribute('type','content');
- frame.setAttribute('id','frame_'+obj.id_incr);
- panel.appendChild(frame);
- try {
- dump('creating browser with src = ' + url + '\n');
- JSAN.use('util.browser');
- var b = new util.browser();
- b.init(
- {
- 'url' : url,
- 'push_xulG' : true,
- 'alt_print' : false,
- 'browser_id' : 'frame_'+obj.id_incr,
- 'passthru_content_params' : content_params,
- }
- );
- } catch(E) {
- alert(E);
- }
- } else {
- frame = this.w.document.createElement('iframe');
- frame.setAttribute('flex','1');
- panel.appendChild(frame);
- dump('creating iframe with src = ' + url + '\n');
- frame.setAttribute('src',url);
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var cw = frame.contentWindow;
- if (typeof cw.wrappedJSObject != 'undefined') cw = cw.wrappedJSObject;
- cw.IAMXUL = true;
- cw.xulG = content_params;
- } catch(E) {
- this.error.sdump('D_ERROR', 'main.menu: ' + E);
- }
- }
- } catch(E) {
- this.error.sdump('D_ERROR', 'main.menu:2: ' + E);
- alert(offlineStrings.getString('menu.set_tab.error'));
- }
-
- return frame;
- }
+ if (params.browser) {
+ obj.id_incr++;
+ frame = this.w.document.createElement('browser');
+ frame.setAttribute('flex','1');
+ frame.setAttribute('type','content');
+ frame.setAttribute('id','frame_'+obj.id_incr);
+ panel.appendChild(frame);
+ try {
+ dump('creating browser with src = ' + url + '\n');
+ JSAN.use('util.browser');
+ var b = new util.browser();
+ b.init(
+ {
+ 'url' : url,
+ 'push_xulG' : true,
+ 'alt_print' : false,
+ 'browser_id' : 'frame_'+obj.id_incr,
+ 'passthru_content_params' : content_params,
+ }
+ );
+ } catch(E) {
+ alert(E);
+ }
+ } else {
+ frame = this.w.document.createElement('iframe');
+ frame.setAttribute('flex','1');
+ panel.appendChild(frame);
+ dump('creating iframe with src = ' + url + '\n');
+ frame.setAttribute('src',url);
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var cw = frame.contentWindow;
+ if (typeof cw.wrappedJSObject != 'undefined') cw = cw.wrappedJSObject;
+ cw.IAMXUL = true;
+ cw.xulG = content_params;
+ } catch(E) {
+ this.error.sdump('D_ERROR', 'main.menu: ' + E);
+ }
+ }
+ } catch(E) {
+ this.error.sdump('D_ERROR', 'main.menu:2: ' + E);
+ alert(offlineStrings.getString('menu.set_tab.error'));
+ }
+
+ return frame;
+ }
}
if (typeof test == 'undefined') var test = {};
test.test = {};
-test.test.EXPORT_OK = [ 'hello_world' ];
-test.test.EXPORT_TAGS = { ':all' : test.test.EXPORT_OK };
+test.test.EXPORT_OK = [ 'hello_world' ];
+test.test.EXPORT_TAGS = { ':all' : test.test.EXPORT_OK };
test.test.hello_world = function () {
- alert('Hello World');
+ alert('Hello World');
}
dump('exiting test/test.js\n');
if (typeof util == 'undefined') var util = {};
util.barcode = {};
-util.barcode.EXPORT_OK = [
- 'check', 'checkdigit',
+util.barcode.EXPORT_OK = [
+ 'check', 'checkdigit',
];
-util.barcode.EXPORT_TAGS = { ':all' : util.barcode.EXPORT_OK };
+util.barcode.EXPORT_TAGS = { ':all' : util.barcode.EXPORT_OK };
util.barcode.check = function(bc) {
- if (bc != Number(bc)) return false;
- bc = bc.toString();
- var last_digit = bc.substr(bc.length-1);
- var stripped_barcode = bc.substr(0,bc.length-1);
- return util.barcode.checkdigit(stripped_barcode).toString() == last_digit;
+ if (bc != Number(bc)) return false;
+ bc = bc.toString();
+ var last_digit = bc.substr(bc.length-1);
+ var stripped_barcode = bc.substr(0,bc.length-1);
+ return util.barcode.checkdigit(stripped_barcode).toString() == last_digit;
}
util.barcode.checkdigit = function(bc) {
- var reverse_barcode = bc.toString().split('').reverse();
- var check_sum = 0; var multiplier = 2;
- for (var i = 0; i < reverse_barcode.length; i++) {
- var digit = reverse_barcode[i];
- var product = digit * multiplier; product = product.toString();
- var temp_sum = 0;
- for (var j = 0; j < product.length; j++) {
- temp_sum += Number( product[j] );
- }
- check_sum += Number( temp_sum );
- multiplier = ( multiplier == 2 ? 1 : 2 );
- }
- check_sum = check_sum.toString();
- var next_multiple_of_10 = (check_sum.match(/(\d*)\d$/)[1] * 10) + 10;
- var check_digit = next_multiple_of_10 - Number(check_sum); if (check_digit == 10) check_digit = 0;
- return check_digit;
+ var reverse_barcode = bc.toString().split('').reverse();
+ var check_sum = 0; var multiplier = 2;
+ for (var i = 0; i < reverse_barcode.length; i++) {
+ var digit = reverse_barcode[i];
+ var product = digit * multiplier; product = product.toString();
+ var temp_sum = 0;
+ for (var j = 0; j < product.length; j++) {
+ temp_sum += Number( product[j] );
+ }
+ check_sum += Number( temp_sum );
+ multiplier = ( multiplier == 2 ? 1 : 2 );
+ }
+ check_sum = check_sum.toString();
+ var next_multiple_of_10 = (check_sum.match(/(\d*)\d$/)[1] * 10) + 10;
+ var check_digit = next_multiple_of_10 - Number(check_sum); if (check_digit == 10) check_digit = 0;
+ return check_digit;
}
dump('exiting util/barcode.js\n');
if (typeof util == 'undefined') util = {};
util.browser = function (params) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.error'); this.error = new util.error();
- } catch(E) {
- dump('util.browser: ' + E + '\n');
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.error'); this.error = new util.error();
+ } catch(E) {
+ dump('util.browser: ' + E + '\n');
+ }
}
util.browser.prototype = {
- 'init' : function( params ) {
+ 'init' : function( params ) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
+ var obj = this;
- obj.url = params['url'];
- obj.push_xulG = params['push_xulG'];
- obj.alt_print = params['alt_print'];
- obj.browser_id = params['browser_id'];
- obj.debug_label = params['debug_label'];
- obj.passthru_content_params = params['passthru_content_params'];
- obj.on_url_load = params['on_url_load'];
+ obj.url = params['url'];
+ obj.push_xulG = params['push_xulG'];
+ obj.alt_print = params['alt_print'];
+ obj.browser_id = params['browser_id'];
+ obj.debug_label = params['debug_label'];
+ obj.passthru_content_params = params['passthru_content_params'];
+ obj.on_url_load = params['on_url_load'];
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'cmd_broken' : [
- ['command'],
- function() { alert('Not Yet Implemented'); }
- ],
- 'cmd_print' : [
- ['command'],
- function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (obj.alt_print) {
- JSAN.use('util.print'); var p = new util.print();
- p.NSPrint(obj.get_content(),false,{});
- } else {
- obj.get_content().print();
- }
- }
- ],
- 'cmd_forward' : [
- ['command'],
- function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var n = obj.getWebNavigation();
- if (n.canGoForward) n.goForward();
- } catch(E) {
- var err = 'cmd_forward: ' + E;
- obj.error.sdump('D_ERROR',err);
- }
- }
- ],
- 'cmd_back' : [
- ['command'],
- function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var n = obj.getWebNavigation();
- if (n.canGoBack) n.goBack();
- } catch(E) {
- var err = 'cmd_back: ' + E;
- obj.error.sdump('D_ERROR',err);
- }
- }
- ]
- }
- }
- );
- obj.controller.render();
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert('Not Yet Implemented'); }
+ ],
+ 'cmd_print' : [
+ ['command'],
+ function() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (obj.alt_print) {
+ JSAN.use('util.print'); var p = new util.print();
+ p.NSPrint(obj.get_content(),false,{});
+ } else {
+ obj.get_content().print();
+ }
+ }
+ ],
+ 'cmd_forward' : [
+ ['command'],
+ function() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var n = obj.getWebNavigation();
+ if (n.canGoForward) n.goForward();
+ } catch(E) {
+ var err = 'cmd_forward: ' + E;
+ obj.error.sdump('D_ERROR',err);
+ }
+ }
+ ],
+ 'cmd_back' : [
+ ['command'],
+ function() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var n = obj.getWebNavigation();
+ if (n.canGoBack) n.goBack();
+ } catch(E) {
+ var err = 'cmd_back: ' + E;
+ obj.error.sdump('D_ERROR',err);
+ }
+ }
+ ]
+ }
+ }
+ );
+ obj.controller.render();
- var browser_id = 'browser_browser'; if (obj.browser_id) browser_id = obj.browser_id;
- obj.controller.view.browser_browser = document.getElementById(browser_id);
+ var browser_id = 'browser_browser'; if (obj.browser_id) browser_id = obj.browser_id;
+ obj.controller.view.browser_browser = document.getElementById(browser_id);
- obj.buildProgressListener();
- /*
- dump('obj.controller.view.browser_browser.addProgressListener = '
- + obj.controller.view.browser_browser.addProgressListener + '\n');
- */
- obj.controller.view.browser_browser.addProgressListener(obj.progressListener,
- Components.interfaces.nsIWebProgress.NOTIFY_ALL );
+ obj.buildProgressListener();
+ /*
+ dump('obj.controller.view.browser_browser.addProgressListener = '
+ + obj.controller.view.browser_browser.addProgressListener + '\n');
+ */
+ obj.controller.view.browser_browser.addProgressListener(obj.progressListener,
+ Components.interfaces.nsIWebProgress.NOTIFY_ALL );
- obj.controller.view.browser_browser.setAttribute('src',obj.url);
- //dump('browser url = ' + obj.url + '\n');
+ obj.controller.view.browser_browser.setAttribute('src',obj.url);
+ //dump('browser url = ' + obj.url + '\n');
- } catch(E) {
- this.error.sdump('D_ERROR','util.browser.init: ' + E + '\n');
- }
- },
+ } catch(E) {
+ this.error.sdump('D_ERROR','util.browser.init: ' + E + '\n');
+ }
+ },
- 'get_content' : function() {
- try {
- if (this.controller.view.browser_browser.contentWindow.wrappedJSObject) {
- return this.controller.view.browser_browser.contentWindow.wrappedJSObject;
- } else {
- return this.controller.view.browser_browser.contentWindow;
- }
- } catch(E) {
- this.error.sdump('D_ERROR','util.browser.get_content(): ' + E);
- }
- },
+ 'get_content' : function() {
+ try {
+ if (this.controller.view.browser_browser.contentWindow.wrappedJSObject) {
+ return this.controller.view.browser_browser.contentWindow.wrappedJSObject;
+ } else {
+ return this.controller.view.browser_browser.contentWindow;
+ }
+ } catch(E) {
+ this.error.sdump('D_ERROR','util.browser.get_content(): ' + E);
+ }
+ },
- 'push_variables' : function() {
- try {
- var obj = this;
- var s = '';
- try { s += obj.url + '\n' + obj.get_content().location.href + '\n'; } catch(E) { s+=E + '\n'; }
- if (!obj.push_xulG) return;
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var cw = this.get_content();
- cw.IAMXUL = true;
+ 'push_variables' : function() {
+ try {
+ var obj = this;
+ var s = '';
+ try { s += obj.url + '\n' + obj.get_content().location.href + '\n'; } catch(E) { s+=E + '\n'; }
+ if (!obj.push_xulG) return;
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var cw = this.get_content();
+ cw.IAMXUL = true;
cw.XUL_BUILD_ID = '/xul/server/'.split(/\//)[2];
- cw.xulG = obj.passthru_content_params || {};
- cw.xulG.set_tab = window.xulG.set_tab;
- cw.xulG.new_tab = window.xulG.new_tab;
- cw.xulG.url_prefix = window.xulG.url_prefix;
+ cw.xulG = obj.passthru_content_params || {};
+ cw.xulG.set_tab = window.xulG.set_tab;
+ cw.xulG.new_tab = window.xulG.new_tab;
+ cw.xulG.url_prefix = window.xulG.url_prefix;
cw.xulG.urls = window.urls;
- try { s += ('******** cw = ' + cw + ' cw.xulG = ' + (cw.xulG) + '\n'); } catch(E) { s+=E + '\n'; }
- obj.error.sdump('D_BROWSER',s);
- } catch(E) {
- this.error.sdump('D_ERROR','util.browser.push_variables: ' + E + '\n');
- }
- },
+ try { s += ('******** cw = ' + cw + ' cw.xulG = ' + (cw.xulG) + '\n'); } catch(E) { s+=E + '\n'; }
+ obj.error.sdump('D_BROWSER',s);
+ } catch(E) {
+ this.error.sdump('D_ERROR','util.browser.push_variables: ' + E + '\n');
+ }
+ },
- 'getWebNavigation' : function() {
- try {
- var wn = this.controller.view.browser_browser.webNavigation;
- var s = this.url + '\n' + this.get_content().location.href + '\n';
- s += ('getWebNavigation() = ' + wn + '\n');
- //this.error.sdump('D_BROWSER',s);
- return wn;
- } catch(E) {
- this.error.sdump('D_ERROR','util.browser.getWebNavigation(): ' + E );
- }
- },
+ 'getWebNavigation' : function() {
+ try {
+ var wn = this.controller.view.browser_browser.webNavigation;
+ var s = this.url + '\n' + this.get_content().location.href + '\n';
+ s += ('getWebNavigation() = ' + wn + '\n');
+ //this.error.sdump('D_BROWSER',s);
+ return wn;
+ } catch(E) {
+ this.error.sdump('D_ERROR','util.browser.getWebNavigation(): ' + E );
+ }
+ },
- 'updateNavButtons' : function() {
- var obj = this;
- var s = obj.url + '\n' + obj.get_content().location.href + '\n';
- try {
- var n = obj.getWebNavigation();
- s += ('webNavigation = ' + n + '\n');
- s += ('webNavigation.canGoForward = ' + n.canGoForward + '\n');
- if (n.canGoForward) {
- if (typeof obj.controller.view.cmd_forward != 'undefined') {
- obj.controller.view.cmd_forward.disabled = false;
- obj.controller.view.cmd_forward.setAttribute('disabled','false');
- }
- } else {
- if (typeof obj.controller.view.cmd_forward != 'undefined') {
- obj.controller.view.cmd_forward.disabled = true;
- obj.controller.view.cmd_forward.setAttribute('disabled','true');
- }
- }
- } catch(E) {
- s += E + '\n';
- }
- try {
- var n = obj.getWebNavigation();
- s += ('webNavigation = ' + n + '\n');
- s += ('webNavigation.canGoBack = ' + n.canGoBack + '\n');
- if (n.canGoBack) {
- if (typeof obj.controller.view.cmd_back != 'undefined') {
- obj.controller.view.cmd_back.disabled = false;
- obj.controller.view.cmd_back.setAttribute('disabled','false');
- }
- } else {
- if (typeof obj.controller.view.cmd_back != 'undefined') {
- obj.controller.view.cmd_back.disabled = true;
- obj.controller.view.cmd_back.setAttribute('disabled','true');
- }
- }
- } catch(E) {
- s += E + '\n';
- }
+ 'updateNavButtons' : function() {
+ var obj = this;
+ var s = obj.url + '\n' + obj.get_content().location.href + '\n';
+ try {
+ var n = obj.getWebNavigation();
+ s += ('webNavigation = ' + n + '\n');
+ s += ('webNavigation.canGoForward = ' + n.canGoForward + '\n');
+ if (n.canGoForward) {
+ if (typeof obj.controller.view.cmd_forward != 'undefined') {
+ obj.controller.view.cmd_forward.disabled = false;
+ obj.controller.view.cmd_forward.setAttribute('disabled','false');
+ }
+ } else {
+ if (typeof obj.controller.view.cmd_forward != 'undefined') {
+ obj.controller.view.cmd_forward.disabled = true;
+ obj.controller.view.cmd_forward.setAttribute('disabled','true');
+ }
+ }
+ } catch(E) {
+ s += E + '\n';
+ }
+ try {
+ var n = obj.getWebNavigation();
+ s += ('webNavigation = ' + n + '\n');
+ s += ('webNavigation.canGoBack = ' + n.canGoBack + '\n');
+ if (n.canGoBack) {
+ if (typeof obj.controller.view.cmd_back != 'undefined') {
+ obj.controller.view.cmd_back.disabled = false;
+ obj.controller.view.cmd_back.setAttribute('disabled','false');
+ }
+ } else {
+ if (typeof obj.controller.view.cmd_back != 'undefined') {
+ obj.controller.view.cmd_back.disabled = true;
+ obj.controller.view.cmd_back.setAttribute('disabled','true');
+ }
+ }
+ } catch(E) {
+ s += E + '\n';
+ }
- //this.error.sdump('D_BROWSER',s);
- },
+ //this.error.sdump('D_BROWSER',s);
+ },
- 'buildProgressListener' : function() {
+ 'buildProgressListener' : function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
- obj.progressListener = {
- onProgressChange : function(){},
- onLocationChange : function(){},
- onStatusChange : function(){},
- onSecurityChange : function(){},
- onStateChange : function ( webProgress, request, stateFlags, status) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege( "UniversalXPConnect" );
- var s = obj.url + '\n' + obj.get_content().location.href + '\n';
- const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
- const nsIChannel = Components.interfaces.nsIChannel;
- if (stateFlags == 65540 || stateFlags == 65537 || stateFlags == 65552) { return; }
- s += ('onStateChange: stateFlags = ' + stateFlags + ' status = ' + status + '\n');
- if (stateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
- s += ('\tSTATE_IS_REQUEST\n');
- }
- if (stateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) {
- s += ('\tSTATE_IS_DOCUMENT\n');
- if( stateFlags & nsIWebProgressListener.STATE_STOP ) {
- obj.push_variables(); obj.updateNavButtons();
- if (typeof obj.on_url_load == 'function') {
- try {
- obj.error.sdump('D_TRACE','calling on_url_load');
- obj.on_url_load( obj.controller.view.browser_browser );
- if (obj.debug_label) {
- try {
- document.getElementById(obj.debug_label).setAttribute('tooltiptext','url: ' + obj.get_content().location.href);
- } catch(E) {
- obj.error.sdump('D_ERROR','on_url_load, debug_label: ' + E );
- }
- }
- } catch(E) {
- obj.error.sdump('D_ERROR','on_url_load: ' + E );
- }
- }
- }
- }
- if (stateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
- s += ('\tSTATE_IS_NETWORK\n');
- }
- if (stateFlags & nsIWebProgressListener.STATE_IS_WINDOW) {
- s += ('\tSTATE_IS_WINDOW\n');
- }
- if (stateFlags & nsIWebProgressListener.STATE_START) {
- s += ('\tSTATE_START\n');
- }
- if (stateFlags & nsIWebProgressListener.STATE_REDIRECTING) {
- s += ('\tSTATE_REDIRECTING\n');
- }
- if (stateFlags & nsIWebProgressListener.STATE_TRANSFERING) {
- s += ('\tSTATE_TRANSFERING\n');
- }
- if (stateFlags & nsIWebProgressListener.STATE_NEGOTIATING) {
- s += ('\tSTATE_NEGOTIATING\n');
- }
- if (stateFlags & nsIWebProgressListener.STATE_STOP) {
- s += ('\tSTATE_STOP\n');
- }
- //obj.error.sdump('D_BROWSER',s);
- } catch(E) {
- obj.error.sdump('D_ERROR','util.browser.progresslistener.onstatechange: ' + (E));
- }
- }
- }
- obj.progressListener.QueryInterface = function(){return this;};
- } catch(E) {
- this.error.sdump('D_ERROR','util.browser.buildProgressListener: ' + E + '\n');
- }
- }
+ var obj = this;
+ obj.progressListener = {
+ onProgressChange : function(){},
+ onLocationChange : function(){},
+ onStatusChange : function(){},
+ onSecurityChange : function(){},
+ onStateChange : function ( webProgress, request, stateFlags, status) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege( "UniversalXPConnect" );
+ var s = obj.url + '\n' + obj.get_content().location.href + '\n';
+ const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
+ const nsIChannel = Components.interfaces.nsIChannel;
+ if (stateFlags == 65540 || stateFlags == 65537 || stateFlags == 65552) { return; }
+ s += ('onStateChange: stateFlags = ' + stateFlags + ' status = ' + status + '\n');
+ if (stateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
+ s += ('\tSTATE_IS_REQUEST\n');
+ }
+ if (stateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) {
+ s += ('\tSTATE_IS_DOCUMENT\n');
+ if( stateFlags & nsIWebProgressListener.STATE_STOP ) {
+ obj.push_variables(); obj.updateNavButtons();
+ if (typeof obj.on_url_load == 'function') {
+ try {
+ obj.error.sdump('D_TRACE','calling on_url_load');
+ obj.on_url_load( obj.controller.view.browser_browser );
+ if (obj.debug_label) {
+ try {
+ document.getElementById(obj.debug_label).setAttribute('tooltiptext','url: ' + obj.get_content().location.href);
+ } catch(E) {
+ obj.error.sdump('D_ERROR','on_url_load, debug_label: ' + E );
+ }
+ }
+ } catch(E) {
+ obj.error.sdump('D_ERROR','on_url_load: ' + E );
+ }
+ }
+ }
+ }
+ if (stateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
+ s += ('\tSTATE_IS_NETWORK\n');
+ }
+ if (stateFlags & nsIWebProgressListener.STATE_IS_WINDOW) {
+ s += ('\tSTATE_IS_WINDOW\n');
+ }
+ if (stateFlags & nsIWebProgressListener.STATE_START) {
+ s += ('\tSTATE_START\n');
+ }
+ if (stateFlags & nsIWebProgressListener.STATE_REDIRECTING) {
+ s += ('\tSTATE_REDIRECTING\n');
+ }
+ if (stateFlags & nsIWebProgressListener.STATE_TRANSFERING) {
+ s += ('\tSTATE_TRANSFERING\n');
+ }
+ if (stateFlags & nsIWebProgressListener.STATE_NEGOTIATING) {
+ s += ('\tSTATE_NEGOTIATING\n');
+ }
+ if (stateFlags & nsIWebProgressListener.STATE_STOP) {
+ s += ('\tSTATE_STOP\n');
+ }
+ //obj.error.sdump('D_BROWSER',s);
+ } catch(E) {
+ obj.error.sdump('D_ERROR','util.browser.progresslistener.onstatechange: ' + (E));
+ }
+ }
+ }
+ obj.progressListener.QueryInterface = function(){return this;};
+ } catch(E) {
+ this.error.sdump('D_ERROR','util.browser.buildProgressListener: ' + E + '\n');
+ }
+ }
}
dump('exiting util.browser.js\n');
if (typeof util == 'undefined') var util = {};
util.clipboard = {};
-util.clipboard.EXPORT_OK = [
- 'cut', 'copy', 'paste'
+util.clipboard.EXPORT_OK = [
+ 'cut', 'copy', 'paste'
];
-util.clipboard.EXPORT_TAGS = { ':all' : util.clipboard.EXPORT_OK };
+util.clipboard.EXPORT_TAGS = { ':all' : util.clipboard.EXPORT_OK };
util.clipboard.cut = function() {
try {
if (typeof util == 'undefined') util = {};
util.controller = function () {
- JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.error'); this.error = new util.error();
- return this;
+ return this;
};
util.controller.prototype = {
- 'cmds' : {},
+ 'cmds' : {},
- 'init' : function (params) {
+ 'init' : function (params) {
- if (typeof params.control_map == 'undefined') throw('util.controller.init: No control_map');
+ if (typeof params.control_map == 'undefined') throw('util.controller.init: No control_map');
- this.control_map = params.control_map;
- this.window_knows_me_by = params.window_knows_me_by;
- this.render_list = [];
- this.view = {};
-
- for (var i in this.control_map) {
- var cmd = document.getElementById(i);
- if (cmd) {
- for (var j in this.control_map[i][0]) {
- if (this.control_map[i][1]) {
- var ev_type = this.control_map[i][0][j];
- switch(ev_type) {
- case 'render':
- this.render_list.push( [i, this.control_map[i][1](cmd)] );
- break;
- case 'oncommand':
- if (!this.window_knows_me_by)
- throw('util.controller: on_command requires window_knows_me_by');
- var s = 'try{'+this.window_knows_me_by+".cmds."+i+"();}catch(E){alert(E);}";
- cmd.setAttribute(ev_type, s);
- this.cmds[i] = this.control_map[i][1];
- break;
- default: cmd.addEventListener(ev_type,this.control_map[i][1],false);
- }
- }
- }
- }
- this.view[i] = cmd;
- }
- },
+ this.control_map = params.control_map;
+ this.window_knows_me_by = params.window_knows_me_by;
+ this.render_list = [];
+ this.view = {};
+
+ for (var i in this.control_map) {
+ var cmd = document.getElementById(i);
+ if (cmd) {
+ for (var j in this.control_map[i][0]) {
+ if (this.control_map[i][1]) {
+ var ev_type = this.control_map[i][0][j];
+ switch(ev_type) {
+ case 'render':
+ this.render_list.push( [i, this.control_map[i][1](cmd)] );
+ break;
+ case 'oncommand':
+ if (!this.window_knows_me_by)
+ throw('util.controller: on_command requires window_knows_me_by');
+ var s = 'try{'+this.window_knows_me_by+".cmds."+i+"();}catch(E){alert(E);}";
+ cmd.setAttribute(ev_type, s);
+ this.cmds[i] = this.control_map[i][1];
+ break;
+ default: cmd.addEventListener(ev_type,this.control_map[i][1],false);
+ }
+ }
+ }
+ }
+ this.view[i] = cmd;
+ }
+ },
- 'render' : function(id,param) {
- for (var i in this.render_list) {
- try {
- if (id) {
- if (id == this.render_list[i][0]) this.render_list[i][1](param);
- } else {
- this.render_list[i][1](param);
- }
- } catch(E) {
- var error = 'Problem in util.controller.render with\n'
- + this.render_list[i] + '\n\n' + js2JSON(E);
- this.error.sdump('D_ERROR',error);
- }
- }
- }
+ 'render' : function(id,param) {
+ for (var i in this.render_list) {
+ try {
+ if (id) {
+ if (id == this.render_list[i][0]) this.render_list[i][1](param);
+ } else {
+ this.render_list[i][1](param);
+ }
+ } catch(E) {
+ var error = 'Problem in util.controller.render with\n'
+ + this.render_list[i] + '\n\n' + js2JSON(E);
+ this.error.sdump('D_ERROR',error);
+ }
+ }
+ }
}
dump('exiting util/controller.js\n');
if (typeof util == 'undefined') var util = {};
util.date = {};
-util.date.EXPORT_OK = [
- 'check', 'timer_init', 'timer_elapsed', 'db_date2Date', 'formatted_date', 'interval_to_seconds'
+util.date.EXPORT_OK = [
+ 'check', 'timer_init', 'timer_elapsed', 'db_date2Date', 'formatted_date', 'interval_to_seconds'
];
-util.date.EXPORT_TAGS = { ':all' : util.date.EXPORT_OK };
+util.date.EXPORT_TAGS = { ':all' : util.date.EXPORT_OK };
util.date.check = function(format,date) {
- if (format != 'YYYY-MM-DD') { throw('I only understand YYYY-MM-DD. Fix me if you want.'); }
- if (date.length != format.length) { return false; }
- if ((date.substr(4,1) != '-') || (date.substr(7,1) != '-')) { return false; }
- var yyyy = date.substr(0,4); var mm = date.substr(5,2); var dd = date.substr(8,2);
- var d = new Date( yyyy, mm - 1, dd );
- if (d.toString() == 'Invalid Date') { return false; }
- if (d.getMonth() != mm -1) { return false; }
- if (d.getFullYear() != yyyy) { return false; }
- if (dd.substr(0,1)=='0') { dd = dd.substr(1,1); }
- if (d.getDate() != dd) { return false; }
- return true;
+ if (format != 'YYYY-MM-DD') { throw('I only understand YYYY-MM-DD. Fix me if you want.'); }
+ if (date.length != format.length) { return false; }
+ if ((date.substr(4,1) != '-') || (date.substr(7,1) != '-')) { return false; }
+ var yyyy = date.substr(0,4); var mm = date.substr(5,2); var dd = date.substr(8,2);
+ var d = new Date( yyyy, mm - 1, dd );
+ if (d.toString() == 'Invalid Date') { return false; }
+ if (d.getMonth() != mm -1) { return false; }
+ if (d.getFullYear() != yyyy) { return false; }
+ if (dd.substr(0,1)=='0') { dd = dd.substr(1,1); }
+ if (d.getDate() != dd) { return false; }
+ return true;
}
util.date.check_past = function(format,date) {
- if (format != 'YYYY-MM-DD') { throw('I only understand YYYY-MM-DD. Fix me if you want.'); }
- var yyyy = date.substr(0,4); var mm = date.substr(5,2); var dd = date.substr(8,2);
- var test_date = new Date( yyyy, mm - 1, dd );
- date = util.date.formatted_date(new Date(),'%F');
- yyyy = date.substr(0,4); mm = date.substr(5,2); dd = date.substr(8,2);
- var today = new Date( yyyy, mm - 1, dd );
- return test_date < today;
+ if (format != 'YYYY-MM-DD') { throw('I only understand YYYY-MM-DD. Fix me if you want.'); }
+ var yyyy = date.substr(0,4); var mm = date.substr(5,2); var dd = date.substr(8,2);
+ var test_date = new Date( yyyy, mm - 1, dd );
+ date = util.date.formatted_date(new Date(),'%F');
+ yyyy = date.substr(0,4); mm = date.substr(5,2); dd = date.substr(8,2);
+ var today = new Date( yyyy, mm - 1, dd );
+ return test_date < today;
}
util.date.timer_init = function (id) {
- if (typeof util.date.timer_init.prototype.timer == 'undefined') {
- util.date.timer_init.prototype.timer = {};
- }
- util.date.timer_init.prototype.timer[id] = (new Date).getTime();
+ if (typeof util.date.timer_init.prototype.timer == 'undefined') {
+ util.date.timer_init.prototype.timer = {};
+ }
+ util.date.timer_init.prototype.timer[id] = (new Date).getTime();
}
util.date.timer_elapsed = function (id) {
- if (! util.date.timer_init.prototype.timer[id]) { util.date.timer_init(id); }
- var ms = (new Date).getTime() - util.date.timer_init.prototype.timer[id];
- return( ms + 'ms (' + ms/1000 + 's)' );
+ if (! util.date.timer_init.prototype.timer[id]) { util.date.timer_init(id); }
+ var ms = (new Date).getTime() - util.date.timer_init.prototype.timer[id];
+ return( ms + 'ms (' + ms/1000 + 's)' );
}
util.date.db_date2Date = function (date) {
- var y = date.substr(0,4);
- var mo = date.substr(5,2);
- var d = date.substr(8,2);
- var h = date.substr(11,2);
- var mi = date.substr(14,2);
- var s = date.substr(17,2);
- return new Date(y,mo-1,d,h,mi,s);
+ var y = date.substr(0,4);
+ var mo = date.substr(5,2);
+ var d = date.substr(8,2);
+ var h = date.substr(11,2);
+ var mi = date.substr(14,2);
+ var s = date.substr(17,2);
+ return new Date(y,mo-1,d,h,mi,s);
}
util.date.formatted_date = function (orig_date,format) {
- var _date = orig_date;
-
- try {
-
- // pass in a Date object or epoch seconds or a postgres style date string (2005-07-19 10:38:25.211964-04)
- if (typeof(_date) == 'string') {
- if (_date.match(/:/) || _date.match(/-/)) {
- _date = util.date.db_date2Date(_date);
- } else {
- _date = new Date( Number( _date + '000' ) );
- }
- } else if (typeof(_date) == 'number') {
- _date = new Date( _date * 1000 );
- }
-
- if (_date == null) {
- return '';
- }
-
- var mm = _date.getMonth() + 1; mm = mm.toString(); if (mm.length == 1) mm = '0' +mm;
- var dd = _date.getDate().toString(); if (dd.length == 1) dd = '0' +dd;
- var yyyy = _date.getFullYear().toString();
- var yy = yyyy.substr(2);
- var H = _date.getHours(); H = H.toString(); if (H.length == 1) H = '0' + H;
- var I = _date.getHours(); if (I > 12) I -= 12; I = I.toString();
- var M = _date.getMinutes(); M = M.toString(); if (M.length == 1) M = '0' + M;
- var sec = _date.getSeconds(); sec = sec.toString(); if (sec.length == 1) sec = '0' + sec;
-
- var s = format;
- if (s == '') { s = '%F %H:%M'; }
- if (typeof _date.iso8601Format != 'function') {
-
- try {
- var js = JSAN._loadJSFromUrl( urls.isodate_lib_remote );
- eval( js );
-
- } catch(E) {
-
- try {
- var js = JSAN._loadJSFromUrl( urls.isodate_lib_local );
- eval( js );
-
- } catch(F) {
-
- alert('Problem loading ISO8601 date extension:' + E + '\n' + F);
-
- }
- }
-
- }
- if (typeof _date.iso8601Format == 'function') {
- s = s.replace( /%\{iso8601\}/g, _date.iso8601Format("YMDHMS") );
- }
- s = s.replace( /%m/g, mm );
- s = s.replace( /%d/g, dd );
- s = s.replace( /%Y/g, yyyy );
- s = s.replace( /%D/g, mm + '/' + dd + '/' + yy );
- s = s.replace( /%F/g, yyyy + '-' + mm + '-' + dd );
- s = s.replace( /%H/g, H );
- s = s.replace( /%I/g, I );
- s = s.replace( /%M/g, M );
- s = s.replace( /%s/g, sec );
- return s;
-
- } catch(E) {
- alert('Error in util.date.formatted_date:\ntypeof orig_date = ' + typeof orig_date + ' orig_date = ' + orig_date + '\ntypeof _date = ' + typeof _date + ' _date = ' + _date + '\nformat = ' + format + '\n' + E);
- }
+ var _date = orig_date;
+
+ try {
+
+ // pass in a Date object or epoch seconds or a postgres style date string (2005-07-19 10:38:25.211964-04)
+ if (typeof(_date) == 'string') {
+ if (_date.match(/:/) || _date.match(/-/)) {
+ _date = util.date.db_date2Date(_date);
+ } else {
+ _date = new Date( Number( _date + '000' ) );
+ }
+ } else if (typeof(_date) == 'number') {
+ _date = new Date( _date * 1000 );
+ }
+
+ if (_date == null) {
+ return '';
+ }
+
+ var mm = _date.getMonth() + 1; mm = mm.toString(); if (mm.length == 1) mm = '0' +mm;
+ var dd = _date.getDate().toString(); if (dd.length == 1) dd = '0' +dd;
+ var yyyy = _date.getFullYear().toString();
+ var yy = yyyy.substr(2);
+ var H = _date.getHours(); H = H.toString(); if (H.length == 1) H = '0' + H;
+ var I = _date.getHours(); if (I > 12) I -= 12; I = I.toString();
+ var M = _date.getMinutes(); M = M.toString(); if (M.length == 1) M = '0' + M;
+ var sec = _date.getSeconds(); sec = sec.toString(); if (sec.length == 1) sec = '0' + sec;
+
+ var s = format;
+ if (s == '') { s = '%F %H:%M'; }
+ if (typeof _date.iso8601Format != 'function') {
+
+ try {
+ var js = JSAN._loadJSFromUrl( urls.isodate_lib_remote );
+ eval( js );
+
+ } catch(E) {
+
+ try {
+ var js = JSAN._loadJSFromUrl( urls.isodate_lib_local );
+ eval( js );
+
+ } catch(F) {
+
+ alert('Problem loading ISO8601 date extension:' + E + '\n' + F);
+
+ }
+ }
+
+ }
+ if (typeof _date.iso8601Format == 'function') {
+ s = s.replace( /%\{iso8601\}/g, _date.iso8601Format("YMDHMS") );
+ }
+ s = s.replace( /%m/g, mm );
+ s = s.replace( /%d/g, dd );
+ s = s.replace( /%Y/g, yyyy );
+ s = s.replace( /%D/g, mm + '/' + dd + '/' + yy );
+ s = s.replace( /%F/g, yyyy + '-' + mm + '-' + dd );
+ s = s.replace( /%H/g, H );
+ s = s.replace( /%I/g, I );
+ s = s.replace( /%M/g, M );
+ s = s.replace( /%s/g, sec );
+ return s;
+
+ } catch(E) {
+ alert('Error in util.date.formatted_date:\ntypeof orig_date = ' + typeof orig_date + ' orig_date = ' + orig_date + '\ntypeof _date = ' + typeof _date + ' _date = ' + _date + '\nformat = ' + format + '\n' + E);
+ }
}
util.date.interval_to_seconds = function ( $interval ) {
$interval = $interval.replace( /,/, ' ' );
var $amount = 0;
- var results = $interval.match( /\s*\+?\s*(\d+)\s*(\w{1})\w*\s*/g);
- for (var i in results) {
- var result = results[i].match( /\s*\+?\s*(\d+)\s*(\w{1})\w*\s*/ );
- if (result[2] == 's') $amount += result[1] ;
- if (result[2] == 'm') $amount += 60 * result[1] ;
- if (result[2] == 'h') $amount += 60 * 60 * result[1] ;
- if (result[2] == 'd') $amount += 60 * 60 * 24 * result[1] ;
- if (result[2] == 'w') $amount += 60 * 60 * 24 * 7 * result[1] ;
- if (result[2] == 'M') $amount += ((60 * 60 * 24 * 365)/12) * result[1] ;
- if (result[2] == 'y') $amount += 60 * 60 * 24 * 365 * result[1] ;
+ var results = $interval.match( /\s*\+?\s*(\d+)\s*(\w{1})\w*\s*/g);
+ for (var i in results) {
+ var result = results[i].match( /\s*\+?\s*(\d+)\s*(\w{1})\w*\s*/ );
+ if (result[2] == 's') $amount += result[1] ;
+ if (result[2] == 'm') $amount += 60 * result[1] ;
+ if (result[2] == 'h') $amount += 60 * 60 * result[1] ;
+ if (result[2] == 'd') $amount += 60 * 60 * 24 * result[1] ;
+ if (result[2] == 'w') $amount += 60 * 60 * 24 * 7 * result[1] ;
+ if (result[2] == 'M') $amount += ((60 * 60 * 24 * 365)/12) * result[1] ;
+ if (result[2] == 'y') $amount += 60 * 60 * 24 * 365 * result[1] ;
}
return $amount;
}
/*
- Lifted from /opac/common/js/util.js
+ Lifted from /opac/common/js/util.js
- builds a JS date object with the given info. The given data
- has to be valid (e.g. months == 30 is not valid). Returns NULL on
- invalid date
- Months are 1-12 (unlike the JS date object)
+ builds a JS date object with the given info. The given data
+ has to be valid (e.g. months == 30 is not valid). Returns NULL on
+ invalid date
+ Months are 1-12 (unlike the JS date object)
*/
util.date.buildDate = function ( year, month, day, hours, minutes, seconds ) {
- if(!year) year = 0;
- if(!month) month = 1;
- if(!day) day = 1;
- if(!hours) hours = 0;
- if(!minutes) minutes = 0;
- if(!seconds) seconds = 0;
-
- var d = new Date(year, month - 1, day, hours, minutes, seconds);
- //alert('util.date.buildDate\nyear='+year+' month='+month+' day='+day+' hours='+hours+' minutes='+minutes+' seconds='+seconds+'\nd = ' + d);
-
- if(
- (d.getYear() + 1900) == year &&
- d.getMonth() == (month - 1) &&
- d.getDate() == new Number(day) &&
- d.getHours() == new Number(hours) &&
- d.getMinutes() == new Number(minutes) &&
- d.getSeconds() == new Number(seconds) ) {
- return d;
- }
-
- return null;
+ if(!year) year = 0;
+ if(!month) month = 1;
+ if(!day) day = 1;
+ if(!hours) hours = 0;
+ if(!minutes) minutes = 0;
+ if(!seconds) seconds = 0;
+
+ var d = new Date(year, month - 1, day, hours, minutes, seconds);
+ //alert('util.date.buildDate\nyear='+year+' month='+month+' day='+day+' hours='+hours+' minutes='+minutes+' seconds='+seconds+'\nd = ' + d);
+
+ if(
+ (d.getYear() + 1900) == year &&
+ d.getMonth() == (month - 1) &&
+ d.getDate() == new Number(day) &&
+ d.getHours() == new Number(hours) &&
+ d.getMinutes() == new Number(minutes) &&
+ d.getSeconds() == new Number(seconds) ) {
+ return d;
+ }
+
+ return null;
}
if (typeof util == 'undefined') util = {};
util.deck = function (id) {
- this.node = document.getElementById(id);
-
- JSAN.use('util.error'); this.error = new util.error();
-
- if (!this.node) {
- var error = 'util.deck: Could not find element ' + id;
- this.error.sdump('D_ERROR',error);
- throw(error);
- }
- if (this.node.nodeName != 'deck') {
- var error = 'util.deck: ' + id + 'is not a deck' + "\nIt's a " + this.node.nodeName;
- this.error.sdump('D_ERROR',error);
- throw(error);
- }
-
- return this;
+ this.node = document.getElementById(id);
+
+ JSAN.use('util.error'); this.error = new util.error();
+
+ if (!this.node) {
+ var error = 'util.deck: Could not find element ' + id;
+ this.error.sdump('D_ERROR',error);
+ throw(error);
+ }
+ if (this.node.nodeName != 'deck') {
+ var error = 'util.deck: ' + id + 'is not a deck' + "\nIt's a " + this.node.nodeName;
+ this.error.sdump('D_ERROR',error);
+ throw(error);
+ }
+
+ return this;
};
util.deck.prototype = {
- 'clear' : function() {
- while (this.node.lastChild) this.node.removeChild( this.node.lastChild );
- },
-
- 'clear_all_except' : function(url) {
- var keep_me = this.find_index(url); var remove_me = [];
- for (var i = 0; i < this.node.childNodes.length; i++) {
- if (i != keep_me) remove_me.push( this.node.childNodes[i] );
- }
- for (var i = 0; i < remove_me.length; i++) this.node.removeChild( remove_me[i] );
- },
-
- 'find_index' : function (url) {
- var idx = -1;
- var nodes = this.node.childNodes;
- for (var i = 0; i < nodes.length; i++) {
- if (nodes[i].getAttribute('src') == url) idx = i;
- }
- return idx;
- },
-
- 'set_iframe' : function (url,params,content_params) {
- this.error.sdump('D_TRACE','util.deck.set_iframe: url = ' + url);
- var idx = this.find_index(url);
- if (idx>-1) {
- this.node.selectedIndex = idx;
-
- var iframe = this.node.childNodes[idx];
-
- if (content_params) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- this.error.sdump('D_DECK', 'set_iframe\nurl = ' + url + '\nframe.contentWindow = ' + iframe.contentWindow + '\n' + 'content_params = ' + (content_params) );
- var cw = iframe.contentWindow;
- if (typeof iframe.contentWindow.wrappedJSObject != 'undefined') cw = iframe.contentWindow.wrappedJSObject;
- cw.IAMXUL = true; cw.xulG = content_params;
- setTimeout( function() { if (typeof cw.default_focus == 'function') cw.default_focus(); }, 0 );
- } catch(E) {
- this.error.sdump('D_ERROR','E: ' + E + '\n');
- }
- }
-
- return iframe;
- } else {
- return this.new_iframe(url,params,content_params);
- }
-
- },
-
- 'reset_iframe' : function (url,params,content_params) {
- this.remove_iframe(url);
- return this.new_iframe(url,params,content_params);
- },
-
- 'new_iframe' : function (url,params,content_params) {
- var idx = this.find_index(url);
- if (idx>-1) throw('An iframe already exists in deck with url = ' + url);
-
- var iframe = document.createElement('iframe');
- iframe.setAttribute('src',url);
- //iframe.setAttribute('flex','1');
- //iframe.setAttribute('style','overflow: scroll');
- //iframe.setAttribute('style','border: solid thin red');
- this.node.appendChild( iframe );
- this.node.selectedIndex = this.node.childNodes.length - 1;
- if (content_params) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- this.error.sdump('D_DECK', 'new_iframe\nurl = ' + url + '\nframe.contentWindow = ' + iframe.contentWindow + '\n' + 'content_params = ' + (content_params) );
- var cw = iframe.contentWindow;
- if (typeof iframe.contentWindow.wrappedJSObject != 'undefined') cw = iframe.contentWindow.wrappedJSObject;
- cw.IAMXUL = true; cw.xulG = content_params;
- this.error.sdump('D_DECK', 'cw = ' + cw + ' cw.xulG = ' + (cw.xulG) );
- setTimeout( function() { if (typeof cw.default_focus == 'function') cw.default_focus(); }, 0 );
- } catch(E) {
- this.error.sdump('D_ERROR','E: ' + E + '\n');
- }
- }
- return iframe;
- },
-
- 'remove_iframe' : function (url) {
- var idx = this.find_index(url);
- if (idx>-1) {
- this.node.removeChild( this.node.childNodes[ idx ] );
- }
- },
-
- /* FIXME -- consider all the browser stuff broken.. very weird behavior in new_browser */
-
- 'set_browser' : function (url,params,content_params) {
- this.error.sdump('D_TRACE','util.deck.set_browser: url = ' + url);
- var idx = this.find_index(url);
- if (idx>-1) {
- this.node.selectedIndex = idx;
-
- var browser = this.node.childNodes[idx];
-
- if (content_params) {
- /* FIXME -- we'd need to reach in and change the passthru_content_params for the browser, as well as the xulG for the content */
- alert("we're in set_browser, content_params = true");
- }
-
- return browser;
- } else {
- return this.new_browser(url,params,content_params);
- }
-
- },
-
- 'reset_browser' : function (url,params,content_params) {
- this.remove_browser(url);
- return this.new_browser(url,params,content_params);
- },
-
- 'new_browser' : function (url,params,content_params) {
- try {
- alert('in new_browser.. typeof xulG == ' + typeof xulG);
- alert('in new_browser.. typeof content_params == ' + typeof content_params);
- var obj = this;
- var idx = this.find_index(url);
- if (idx>-1) throw('A browser already exists in deck with url = ' + url);
-
- var browser = document.createElement('browser');
- obj.id_incr++;
- browser.setAttribute('type','content');
- browser.setAttribute('id','frame_'+obj.id_incr);
- browser.setAttribute('src',url);
- this.node.appendChild( browser );
- alert('after append');
- this.node.selectedIndex = this.node.childNodes.length - 1;
- dump('creating browser with src = ' + url + '\n');
- alert('content_params = ' + content_params);
- JSAN.use('util.browser');
- var b = new util.browser();
- b.init(
- {
- 'url' : url,
- 'push_xulG' : true,
- 'alt_print' : false,
- 'browser_id' : 'frame_'+obj.id_incr,
- 'passthru_content_params' : content_params
- }
- );
- return browser;
- } catch(E) {
- alert(E);
- }
- },
-
- 'remove_browser' : function (url) {
- var idx = this.find_index(url);
- if (idx>-1) {
- this.node.removeChild( this.node.childNodes[ idx ] );
- }
- },
-
- 'id_incr' : 0
-}
+ 'clear' : function() {
+ while (this.node.lastChild) this.node.removeChild( this.node.lastChild );
+ },
+
+ 'clear_all_except' : function(url) {
+ var keep_me = this.find_index(url); var remove_me = [];
+ for (var i = 0; i < this.node.childNodes.length; i++) {
+ if (i != keep_me) remove_me.push( this.node.childNodes[i] );
+ }
+ for (var i = 0; i < remove_me.length; i++) this.node.removeChild( remove_me[i] );
+ },
+
+ 'find_index' : function (url) {
+ var idx = -1;
+ var nodes = this.node.childNodes;
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].getAttribute('src') == url) idx = i;
+ }
+ return idx;
+ },
+
+ 'set_iframe' : function (url,params,content_params) {
+ this.error.sdump('D_TRACE','util.deck.set_iframe: url = ' + url);
+ var idx = this.find_index(url);
+ if (idx>-1) {
+ this.node.selectedIndex = idx;
+
+ var iframe = this.node.childNodes[idx];
+
+ if (content_params) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ this.error.sdump('D_DECK', 'set_iframe\nurl = ' + url + '\nframe.contentWindow = ' + iframe.contentWindow + '\n' + 'content_params = ' + (content_params) );
+ var cw = iframe.contentWindow;
+ if (typeof iframe.contentWindow.wrappedJSObject != 'undefined') cw = iframe.contentWindow.wrappedJSObject;
+ cw.IAMXUL = true; cw.xulG = content_params;
+ setTimeout( function() { if (typeof cw.default_focus == 'function') cw.default_focus(); }, 0 );
+ } catch(E) {
+ this.error.sdump('D_ERROR','E: ' + E + '\n');
+ }
+ }
+
+ return iframe;
+ } else {
+ return this.new_iframe(url,params,content_params);
+ }
+
+ },
+
+ 'reset_iframe' : function (url,params,content_params) {
+ this.remove_iframe(url);
+ return this.new_iframe(url,params,content_params);
+ },
+
+ 'new_iframe' : function (url,params,content_params) {
+ var idx = this.find_index(url);
+ if (idx>-1) throw('An iframe already exists in deck with url = ' + url);
+
+ var iframe = document.createElement('iframe');
+ iframe.setAttribute('src',url);
+ //iframe.setAttribute('flex','1');
+ //iframe.setAttribute('style','overflow: scroll');
+ //iframe.setAttribute('style','border: solid thin red');
+ this.node.appendChild( iframe );
+ this.node.selectedIndex = this.node.childNodes.length - 1;
+ if (content_params) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ this.error.sdump('D_DECK', 'new_iframe\nurl = ' + url + '\nframe.contentWindow = ' + iframe.contentWindow + '\n' + 'content_params = ' + (content_params) );
+ var cw = iframe.contentWindow;
+ if (typeof iframe.contentWindow.wrappedJSObject != 'undefined') cw = iframe.contentWindow.wrappedJSObject;
+ cw.IAMXUL = true; cw.xulG = content_params;
+ this.error.sdump('D_DECK', 'cw = ' + cw + ' cw.xulG = ' + (cw.xulG) );
+ setTimeout( function() { if (typeof cw.default_focus == 'function') cw.default_focus(); }, 0 );
+ } catch(E) {
+ this.error.sdump('D_ERROR','E: ' + E + '\n');
+ }
+ }
+ return iframe;
+ },
+
+ 'remove_iframe' : function (url) {
+ var idx = this.find_index(url);
+ if (idx>-1) {
+ this.node.removeChild( this.node.childNodes[ idx ] );
+ }
+ },
+
+ /* FIXME -- consider all the browser stuff broken.. very weird behavior in new_browser */
+
+ 'set_browser' : function (url,params,content_params) {
+ this.error.sdump('D_TRACE','util.deck.set_browser: url = ' + url);
+ var idx = this.find_index(url);
+ if (idx>-1) {
+ this.node.selectedIndex = idx;
+
+ var browser = this.node.childNodes[idx];
+
+ if (content_params) {
+ /* FIXME -- we'd need to reach in and change the passthru_content_params for the browser, as well as the xulG for the content */
+ alert("we're in set_browser, content_params = true");
+ }
+
+ return browser;
+ } else {
+ return this.new_browser(url,params,content_params);
+ }
+
+ },
+
+ 'reset_browser' : function (url,params,content_params) {
+ this.remove_browser(url);
+ return this.new_browser(url,params,content_params);
+ },
+
+ 'new_browser' : function (url,params,content_params) {
+ try {
+ alert('in new_browser.. typeof xulG == ' + typeof xulG);
+ alert('in new_browser.. typeof content_params == ' + typeof content_params);
+ var obj = this;
+ var idx = this.find_index(url);
+ if (idx>-1) throw('A browser already exists in deck with url = ' + url);
+
+ var browser = document.createElement('browser');
+ obj.id_incr++;
+ browser.setAttribute('type','content');
+ browser.setAttribute('id','frame_'+obj.id_incr);
+ browser.setAttribute('src',url);
+ this.node.appendChild( browser );
+ alert('after append');
+ this.node.selectedIndex = this.node.childNodes.length - 1;
+ dump('creating browser with src = ' + url + '\n');
+ alert('content_params = ' + content_params);
+ JSAN.use('util.browser');
+ var b = new util.browser();
+ b.init(
+ {
+ 'url' : url,
+ 'push_xulG' : true,
+ 'alt_print' : false,
+ 'browser_id' : 'frame_'+obj.id_incr,
+ 'passthru_content_params' : content_params
+ }
+ );
+ return browser;
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+ 'remove_browser' : function (url) {
+ var idx = this.find_index(url);
+ if (idx>-1) {
+ this.node.removeChild( this.node.childNodes[ idx ] );
+ }
+ },
+
+ 'id_incr' : 0
+}
dump('exiting util/deck.js\n');
alert('Error in util.error constructor: ' + E);
}
- return this;
+ return this;
};
util.error.prototype = {
- 'printDebug' : true,
- 'consoleDump' : false,
- 'debugDump' : true,
- 'fileDump' : false,
- 'alertDump' : false,
- 'arg_dump_full' : false,
-
- 'debug' : function(e){
- dump('-----------------------------------------\n'
- + e + '\n-----------------------------------------\n' );
- },
-
- 'sdump_levels' : {
-
- 'D_NONE' : false,
- 'D_ALL' : false,
- 'D_ERROR' : { 'dump' : true, 'console' : true },
- 'D_DEBUG' : { 'dump' : true, 'console' : true },
- 'D_TRACE' : { 'dump' : true },
- 'D_ALERT' : { 'alert' : true, 'dump' : true },
- 'D_WARN' : false,
- 'D_COLUMN_RENDER_ERROR' : false,
- 'D_XULRUNNER' : false,
- 'D_DECK' : { 'dump' : true },
- 'D_TRACE_ENTER' : false,
- 'D_TRACE_EXIT' : false,
- 'D_TIMEOUT' : false,
- 'D_FILTER' : false,
- 'D_CONSTRUCTOR' : false,
- 'D_FIREFOX' : false,
- 'D_LEGACY' : false,
- 'D_DATA_STASH' : { 'alert' : false },
- 'D_DATA_RETRIEVE' : false,
-
- 'D_CLAM' : false,
- 'D_PAGED_TREE' : false,
- 'D_GRID_LIST' : false,
- 'D_HTML_TABLE' : false,
- 'D_TAB' : false,
- 'D_LIST' : false,
- 'D_LIST_DUMP_WITH_KEYS_ON_CLEAR' : false,
- 'D_LIST_DUMP_ON_CLEAR' : false,
-
- 'D_AUTH' : { 'dump' : true },
- 'D_OPAC' : { 'dump' : true },
- 'D_CAT' : false,
- 'D_BROWSER' : { 'dump' : true },
-
- 'D_PATRON_SEARCH' : false,
- 'D_PATRON_SEARCH_FORM' : false,
- 'D_PATRON_SEARCH_RESULTS' : false,
-
- 'D_PATRON_DISPLAY' : false,
- 'D_PATRON_DISPLAY_STATUS' : false,
- 'D_PATRON_DISPLAY_CONTACT' : false,
-
- 'D_PATRON_ITEMS' : false,
- 'D_PATRON_CHECKOUT_ITEMS' : false,
- 'D_PATRON_HOLDS' : false,
- 'D_PATRON_BILLS' : false,
- 'D_PATRON_EDIT' : false,
-
- 'D_CHECKIN' : false,
- 'D_CHECKIN_ITEMS' : false,
-
- 'D_HOLD_CAPTURE' : false,
- 'D_HOLD_CAPTURE_ITEMS' : false,
-
- 'D_PATRON_UTILS' : false,
- 'D_CIRC_UTILS' : false,
-
- 'D_FILE' : false,
- 'D_EXPLODE' : false,
- 'D_FM_UTILS' : false,
- 'D_PRINT' : { 'dump' : true },
- 'D_OBSERVERS' : { 'dump' : true, 'console' : false, 'alert' : false },
- 'D_CACHE' : { 'dump' : true, 'console' : false, 'alert' : false },
- 'D_SES' : { 'dump' : true, 'console' : false },
- 'D_SES_FUNC' : false,
- 'D_SES_RESULT' : { 'dump' : true },
- 'D_SES_ERROR' : { 'dump' : true, 'console' : true },
- 'D_SPAWN' : false,
- 'D_STRING' : false,
- 'D_UTIL' : false,
- 'D_WIN' : { 'dump' : true },
- 'D_WIDGETS' : false
- },
-
- 'filter_console_init' : function (p) {
- this.sdump('D_FILTER',this.arg_dump(arguments,{0:true}));
-
- var filterConsoleListener = {
- observe: function( msg ) {
- try {
- p.observe_msg( msg );
- } catch(E) {
- alert(E);
- }
- },
- QueryInterface: function (iid) {
- if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
- !iid.equals(Components.interfaces.nsISupports)) {
- throw Components.results.NS_ERROR_NO_INTERFACE;
- }
- return this;
- }
- };
- try {
- this.consoleService.registerListener(filterConsoleListener);
- } catch(E) {
- alert(E);
- }
-
- this.sdump('D_TRACE_EXIT',this.arg_dump(arguments));
- },
-
- 'sdump' : function (level,msg) {
- try {
- var now = new Date();
- var message = now.valueOf() + '\tdelta = ' + (now.valueOf() - this.sdump_last_time.valueOf()) + '\t' + level + '\n' + msg;
- if (this.sdump_levels['D_NONE']) return null;
- if (this.sdump_levels[level]||this.sdump_levels['D_ALL']) {
- this.sdump_last_time = now;
- if (this.debugDump || ( this.sdump_levels[level] && this.sdump_levels[level].debug ) ) this.debug(message);
- if (this.alertDump || ( this.sdump_levels[level] && this.sdump_levels[level].alert ) ) alert(message);
- if (this.consoleDump || ( this.sdump_levels[level] && this.sdump_levels[level].console ) ) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- this.consoleService.logStringMessage(message);
- }
- if (this.fileDump || ( this.sdump_levels[level] && this.sdump_levels[level].file ) ) {
- if (level!='D_FILE') {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.file'); var master_log = new util.file('log');
- master_log.write_content('append',message); master_log.close();
- var specific_log = new util.file('log_'+level);
- specific_log.write_content('append',message); specific_log.close();
- }
- }
- }
- } catch(E) {
- dump('Calling sdump but ' + E + '\n');
- }
- },
-
- 'arg_dump' : function (args,dump_these) {
- var s = '*>*>*> Called function ';
- try {
- if (!dump_these)
- dump_these = {};
- s += args.callee.toString().match(/\w+/g)[1] + ' : ';
- for (var i = 0; i < args.length; i++)
- s += typeof(args[i]) + ' ';
- s += '\n';
- for (var i = 0; i < args.length; i++)
- if (dump_these[i]) {
-
- var arg = args[i];
- //dump('dump_these[i] = ' + dump_these[i] + ' arg = ' + arg + '\n');
-
- if (typeof(dump_these[i])=='string') {
-
- if (dump_these[i].slice(0,1) == '.') {
- var cmd = 'arg' + dump_these[i];
- var result;
- try {
- result = eval( cmd );
- } catch(E) {
- result = cmd + ' ==> ' + E;
- }
- s += '\targ #' + i + ': ' + cmd + ' = ' + result;
- } else {
- var result;
- try {
- result = eval( dump_these[i] );
- } catch(E) {
- result = dump_these[i] + ' ==> ' + E;
- }
- s += '\targ #' + i + ': ' + result;
- }
-
- } else {
- s += '\targ #' + i + ' = ';
- try {
- //s += js2JSON( arg );
- s += arg;
- } catch(E) {
- s += arg;
- }
- }
-
- s += '\n';
- if (this.arg_dump_full)
- s += 'Definition: ' + args.callee.toString() + '\n';
-
- }
- return s;
- } catch(E) {
- return s + '\nDEBUG ME: ' + js2JSON(E) + '\n';
- }
- },
-
- 'handle_error' : function (E,annoy) {
- var s = '';
- if (instanceOf(E,ex)) {
- s += E.err_msg();
- //s += '\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n';
- //s += 'This error was anticipated.\n\n';
- //s += js2JSON(E).substr(0,200) + '...\n\n';
- if (snd_bad) snd_bad();
- } else {
- s += '\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n';
- s += 'This is a bug that we will fix later.\n\n';
- try {
- s += js2JSON(E).substr(0,1024) + '\n\n';
- } catch(E2) {
- try {
- s += E.substr(0,1024) + '\n\n';
- } catch(E3) {
- s += E + '\n\n';
- }
- }
- if (snd_really_bad) snd_really_bad();
- }
- sdump('D_ERROR',s);
- if (annoy)
- this.s_alert(s);
- else
- alert(s);
- },
-
- 's_alert' : function (s) { alert(s); },
-
- 'standard_network_error_alert' : function(msg) {
- var obj = this;
- if (!msg) msg = '';
- var alert_msg = 'We experienced a network/server communication failure. Please check your internet connection and try this action again. Repeated failures may require attention from your local IT staff or your friendly Evergreen developers.\n\n' + msg;
- obj.yns_alert(
- alert_msg,
- 'Communication Failure',
- 'Ok', null, null, 'Check here to confirm this message'
- );
- },
-
- 'standard_unexpected_error_alert' : function(msg,E) {
- var obj = this;
- if (E != null && typeof E.ilsevent != 'undefined') {
- if (E.ilsevent == 0 /* SUCCESS */ ) {
- msg = "The action involved likely succeeded, however, this part of the software needs to be updated to better understand success messages from the server, so please let us know about it.";
- }
- if (E.ilsevent == -1 /* Network/Server Problem */ ) {
- return obj.standard_network_error_alert(msg);
- }
- if (E.ilsevent == 5000 /* PERM_FAILURE */ ) {
- msg = "The action involved likely failed due to insufficient permissions. However, this part of the software needs to be updated to better understand permission messages from the server, so please let us know about it.";
- }
- }
- if (!msg) msg = '';
- var alert_msg = 'FIXME: If you encounter this alert, please inform your IT/ILS helpdesk staff or your friendly Evergreen developers.\n\n' + (new Date()) + '\n\n' + msg + '\n\n' + (typeof E.ilsevent != 'undefined' ? E.textcode + '\n' + (E.desc ? E.desc + '\n' : '') : '') + ( typeof E.status != 'undefined' ? 'Status: ' + E.status + '\n': '' ) + ( typeof E == 'string' ? E + '\n' : '' );
- obj.sdump('D_ERROR',msg + ' : ' + js2JSON(E));
- var r = obj.yns_alert(
- alert_msg,
- 'Unhandled Error',
- 'Ok', 'Debug Output to send to Helpdesk', null, 'Check here to confirm this message',
- '/xul/server/skin/media/images/skull.png'
- );
- if (r == 1) {
- JSAN.use('util.window'); var win = new util.window();
- win.open(
- 'data:text/plain,' + window.escape( 'Please open a helpdesk ticket and include the following text: \n\n' + (new Date()) + '\n\n' + msg + '\n\n' + obj.pretty_print(js2JSON(E)) ),
- 'error_alert',
- 'chrome,resizable,width=700,height=500'
- );
- }
- if (r==2) {
- alert('Not Yet Implemented');
- }
- },
-
- 'yns_alert' : function (s,title,b1,b2,b3,c,image) {
-
- try {
-
- if (location.href.match(/^chrome/)) return this.yns_alert_original(s,title,b1,b2,b3,c);
-
- /* The original purpose of yns_alert was to prevent errors from being scanned through accidentally with a barcode scanner.
- However, this can be done in a less annoying manner by rolling our own dialog and not having any of the options in focus */
-
- /*
- s = Message to display
- title = Text in Title Bar
- b1 = Text for button 1
- b2 = Text for button 2
- b3 = Text for button 3
- c = Text for confirmation checkbox. null for no confirm
- */
-
- dump('yns_alert:\n\ts = ' + s + '\n\ttitle = ' + title + '\n\tb1 = ' + b1 + '\n\tb2 = ' + b2 + '\n\tb3 = ' + b3 + '\n\tc = ' + c + '\n');
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
-
- this.sound.bad();
-
-
- //FIXME - is that good enough of an escape job?
- s = s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
-
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" flex="1">'
- + '<groupbox flex="1" style="overflow: auto; border: solid thin red;"><caption label="' + (title) + '"/>';
-
- if (image) xml += '<hbox><image src="' + image + '"/><spacer flex="1"/></hbox>';
- xml += '<description style="font-size: large">' + (s)
- + '</description></groupbox><groupbox><caption label="Options"/><hbox>';
- var b1_key = b1 ? b1[0] : '';
- var b2_key = b2 ? b2[0] : '';
- var b3_key = b3 ? b3[0] : ''; /* FIXME - need to check for collisions */
- if (b1) xml += '<button id="b1" accesskey="' + b1_key + '" label="' + (b1) + '" name="fancy_submit" value="b1"/>'
- if (b2) xml += '<button id="b2" accesskey="' + b2_key + '" label="' + (b2) + '" name="fancy_submit" value="b2"/>'
- if (b3) xml += '<button id="b3" accesskey="' + b3_key + '" label="' + (b3) + '" name="fancy_submit" value="b3"/>'
- xml += '</hbox></groupbox></vbox>';
- JSAN.use('OpenILS.data');
- //var data = new OpenILS.data(); data.init({'via':'stash'});
- //data.temp_yns_xml = xml; data.stash('temp_yns_xml');
- var url = urls.XUL_FANCY_PROMPT; // + '?xml_in_stash=temp_yns_xml' + '&title=' + window.escape(title);
- if (typeof xulG != 'undefined') if (typeof xulG.url_prefix == 'function') url = xulG.url_prefix( url );
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- url, 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500', { 'xml' : xml, 'title' : title }
- );
- if (fancy_prompt_data.fancy_status == 'complete') {
- switch(fancy_prompt_data.fancy_submit) {
- case 'b1' : return 0; break;
- case 'b2' : return 1; break;
- case 'b3' : return 2; break;
- }
- } else {
- //return this.yns_alert(s,title,b1,b2,b3,c,image);
- return null;
- }
-
- } catch(E) {
-
- dump('yns_alert failed: ' + E + '\ns = ' + s + '\ntitle = ' + title + '\nb1 = ' + b1 + '\nb2 = ' + b2 + '\nb3 = ' + b3 + '\nc = ' + c + '\nimage = ' + image + '\n');
-
- this.yns_alert_original(s + '\n\nAlso, yns_alert failed: ' + E,title,b1,b2,b3,c);
-
- }
- },
-
- 'yns_alert_formatted' : function (s,title,b1,b2,b3,c,image) {
-
- try {
-
- if (location.href.match(/^chrome/)) return this.yns_alert_original(s,title,b1,b2,b3,c);
-
- /* The original purpose of yns_alert was to prevent errors from being scanned through accidentally with a barcode scanner.
- However, this can be done in a less annoying manner by rolling our own dialog and not having any of the options in focus */
-
- /*
- s = Message to display
- title = Text in Title Bar
- b1 = Text for button 1
- b2 = Text for button 2
- b3 = Text for button 3
- c = Text for confirmation checkbox. null for no confirm
- */
-
- dump('yns_alert:\n\ts = ' + s + '\n\ttitle = ' + title + '\n\tb1 = ' + b1 + '\n\tb2 = ' + b2 + '\n\tb3 = ' + b3 + '\n\tc = ' + c + '\n');
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
-
- this.sound.bad();
-
-
- //FIXME - is that good enough of an escape job?
- s = s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
-
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" flex="1">'
- + '<groupbox flex="1" style="overflow: auto; border: solid thin red;"><caption label="' + (title) + '"/>';
-
- if (image) xml += '<hbox><image src="' + image + '"/><spacer flex="1"/></hbox>';
- xml += '<description style="font-size: large"><html:pre style="font-size: large">' + (s)
- + '</html:pre></description></groupbox><groupbox><caption label="Options"/><hbox>';
- var b1_key = b1 ? b1[0] : '';
- var b2_key = b2 ? b2[0] : '';
- var b3_key = b3 ? b3[0] : ''; /* FIXME - need to check for collisions */
- if (b1) xml += '<button id="b1" accesskey="' + b1_key + '" label="' + (b1) + '" name="fancy_submit" value="b1"/>'
- if (b2) xml += '<button id="b2" accesskey="' + b2_key + '" label="' + (b2) + '" name="fancy_submit" value="b2"/>'
- if (b3) xml += '<button id="b3" accesskey="' + b3_key + '" label="' + (b3) + '" name="fancy_submit" value="b3"/>'
- xml += '</hbox></groupbox></vbox>';
- JSAN.use('OpenILS.data');
- //var data = new OpenILS.data(); data.init({'via':'stash'});
- //data.temp_yns_xml = xml; data.stash('temp_yns_xml');
- var url = urls.XUL_FANCY_PROMPT; // + '?xml_in_stash=temp_yns_xml' + '&title=' + window.escape(title);
- if (typeof xulG != 'undefined') if (typeof xulG.url_prefix == 'function') url = xulG.url_prefix( url );
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- url, 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500', { 'xml' : xml, 'title' : title }
- );
- if (fancy_prompt_data.fancy_status == 'complete') {
- switch(fancy_prompt_data.fancy_submit) {
- case 'b1' : return 0; break;
- case 'b2' : return 1; break;
- case 'b3' : return 2; break;
- }
- } else {
- //return this.yns_alert(s,title,b1,b2,b3,c,image);
- return null;
- }
-
- } catch(E) {
-
- alert('yns_alert_formatted failed: ' + E + '\ns = ' + s + '\ntitle = ' + title + '\nb1 = ' + b1 + '\nb2 = ' + b2 + '\nb3 = ' + b3 + '\nc = ' + c + '\nimage = ' + image + '\n');
-
- }
-
- },
-
- 'yns_alert_original' : function (s,title,b1,b2,b3,c) {
-
- /*
- s = Message to display
- title = Text in Title Bar
- b1 = Text for button 1
- b2 = Text for button 2
- b3 = Text for button 3
- c = Text for confirmation checkbox. null for no confirm
- */
-
- dump('yns_alert_original:\n\ts = ' + s + '\n\ttitle = ' + title + '\n\tb1 = ' + b1 + '\n\tb2 = ' + b2 + '\n\tb3 = ' + b3 + '\n\tc = ' + c + '\n');
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
- this.sound.bad();
-
- // get a reference to the prompt service component.
- var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
- .getService(Components.interfaces.nsIPromptService);
-
- // set the buttons that will appear on the dialog. It should be
- // a set of constants multiplied by button position constants. In this case,
- // three buttons appear, Save, Cancel and a custom button.
- //var flags=promptService.BUTTON_TITLE_OK * promptService.BUTTON_POS_0 +
- // promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1 +
- // promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
- var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 +
- promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 +
- promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
-
- // display the dialog box. The flags set above are passed
- // as the fourth argument. The next three arguments are custom labels used for
- // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a
- // particular button. The last two arguments are for an optional check box.
- var check = {};
-
- // promptService.confirmEx does not offer scrollbars for long
- // content, so trim error lines to avoid spilling offscreen
- //
- // There's probably a better way of doing this.
-
- var maxlines = 30;
- var ss = '';
- var linefeeds = 0;
- for (var i=0, chr; linefeeds < maxlines && i < s.length; i++) {
- if ((chr = this.getWholeChar(s, i)) === false) {continue;}
- if (chr == '\u000A') { // \n
- linefeeds++;
- }
- ss = ss + chr;
- }
-
- var rv = promptService.confirmEx(window,title, ss, flags, b1, b2, b3, c, check);
- if (c && !check.value) {
- return this.yns_alert_original(ss,title,b1,b2,b3,c);
- }
- return rv;
- },
-
- 'print_tabs' : function(t) {
- var r = '';
- for (var j = 0; j < t; j++ ) { r = r + "\t"; }
- return r;
- },
-
- 'pretty_print' : function(s) {
- var r = ''; var t = 0;
- for (var i in s) {
- if (s[i] == '{') {
- r = r + "\n" + this.print_tabs(t) + s[i]; t++;
- r = r + "\n" + this.print_tabs(t);
- } else if (s[i] == '[') {
- r = r + "\n" + this.print_tabs(t) + s[i]; t++;
- r = r + "\n" + this.print_tabs(t);
- } else if (s[i] == '}') {
- t--; r = r + "\n" + this.print_tabs(t) + s[i];
- r = r + "\n" + this.print_tabs(t);
- } else if (s[i] == ']') {
- t--; r = r + "\n" + this.print_tabs(t) + s[i];
- r = r + "\n" + this.print_tabs(t);
- } else if (s[i] == ',') {
- r = r + s[i];
- r = r + "\n" + this.print_tabs(t);
- } else {
- r = r + s[i];
- }
- }
- return r;
- },
-
- // Copied from https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/charCodeAt
- 'getWholeChar' : function(str, i) {
- var code = str.charCodeAt(i);
- if (0xD800 <= code && code <= 0xDBFF) { // High surrogate(could change last hex to 0xDB7F to treat high private surrogates as single characters)
- if (str.length <= (i+1)) {
- throw 'High surrogate without following low surrogate';
- }
- var next = str.charCodeAt(i+1);
- if (0xDC00 > next || next > 0xDFFF) {
- throw 'High surrogate without following low surrogate';
- }
- return str[i]+str[i+1];
- }
- else if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
- if (i === 0) {
- throw 'Low surrogate without preceding high surrogate';
- }
- var prev = str.charCodeAt(i-1);
- if (0xD800 > prev || prev > 0xDBFF) { //(could change last hex to 0xDB7F to treat high private surrogates as single characters)
- throw 'Low surrogate without preceding high surrogate';
- }
- return false; // We can pass over low surrogates now as the second component in a pair which we have already processed
- }
- return str[i];
- },
+ 'printDebug' : true,
+ 'consoleDump' : false,
+ 'debugDump' : true,
+ 'fileDump' : false,
+ 'alertDump' : false,
+ 'arg_dump_full' : false,
+
+ 'debug' : function(e){
+ dump('-----------------------------------------\n'
+ + e + '\n-----------------------------------------\n' );
+ },
+
+ 'sdump_levels' : {
+
+ 'D_NONE' : false,
+ 'D_ALL' : false,
+ 'D_ERROR' : { 'dump' : true, 'console' : true },
+ 'D_DEBUG' : { 'dump' : true, 'console' : true },
+ 'D_TRACE' : { 'dump' : true },
+ 'D_ALERT' : { 'alert' : true, 'dump' : true },
+ 'D_WARN' : false,
+ 'D_COLUMN_RENDER_ERROR' : false,
+ 'D_XULRUNNER' : false,
+ 'D_DECK' : { 'dump' : true },
+ 'D_TRACE_ENTER' : false,
+ 'D_TRACE_EXIT' : false,
+ 'D_TIMEOUT' : false,
+ 'D_FILTER' : false,
+ 'D_CONSTRUCTOR' : false,
+ 'D_FIREFOX' : false,
+ 'D_LEGACY' : false,
+ 'D_DATA_STASH' : { 'alert' : false },
+ 'D_DATA_RETRIEVE' : false,
+
+ 'D_CLAM' : false,
+ 'D_PAGED_TREE' : false,
+ 'D_GRID_LIST' : false,
+ 'D_HTML_TABLE' : false,
+ 'D_TAB' : false,
+ 'D_LIST' : false,
+ 'D_LIST_DUMP_WITH_KEYS_ON_CLEAR' : false,
+ 'D_LIST_DUMP_ON_CLEAR' : false,
+
+ 'D_AUTH' : { 'dump' : true },
+ 'D_OPAC' : { 'dump' : true },
+ 'D_CAT' : false,
+ 'D_BROWSER' : { 'dump' : true },
+
+ 'D_PATRON_SEARCH' : false,
+ 'D_PATRON_SEARCH_FORM' : false,
+ 'D_PATRON_SEARCH_RESULTS' : false,
+
+ 'D_PATRON_DISPLAY' : false,
+ 'D_PATRON_DISPLAY_STATUS' : false,
+ 'D_PATRON_DISPLAY_CONTACT' : false,
+
+ 'D_PATRON_ITEMS' : false,
+ 'D_PATRON_CHECKOUT_ITEMS' : false,
+ 'D_PATRON_HOLDS' : false,
+ 'D_PATRON_BILLS' : false,
+ 'D_PATRON_EDIT' : false,
+
+ 'D_CHECKIN' : false,
+ 'D_CHECKIN_ITEMS' : false,
+
+ 'D_HOLD_CAPTURE' : false,
+ 'D_HOLD_CAPTURE_ITEMS' : false,
+
+ 'D_PATRON_UTILS' : false,
+ 'D_CIRC_UTILS' : false,
+
+ 'D_FILE' : false,
+ 'D_EXPLODE' : false,
+ 'D_FM_UTILS' : false,
+ 'D_PRINT' : { 'dump' : true },
+ 'D_OBSERVERS' : { 'dump' : true, 'console' : false, 'alert' : false },
+ 'D_CACHE' : { 'dump' : true, 'console' : false, 'alert' : false },
+ 'D_SES' : { 'dump' : true, 'console' : false },
+ 'D_SES_FUNC' : false,
+ 'D_SES_RESULT' : { 'dump' : true },
+ 'D_SES_ERROR' : { 'dump' : true, 'console' : true },
+ 'D_SPAWN' : false,
+ 'D_STRING' : false,
+ 'D_UTIL' : false,
+ 'D_WIN' : { 'dump' : true },
+ 'D_WIDGETS' : false
+ },
+
+ 'filter_console_init' : function (p) {
+ this.sdump('D_FILTER',this.arg_dump(arguments,{0:true}));
+
+ var filterConsoleListener = {
+ observe: function( msg ) {
+ try {
+ p.observe_msg( msg );
+ } catch(E) {
+ alert(E);
+ }
+ },
+ QueryInterface: function (iid) {
+ if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
+ !iid.equals(Components.interfaces.nsISupports)) {
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+ };
+ try {
+ this.consoleService.registerListener(filterConsoleListener);
+ } catch(E) {
+ alert(E);
+ }
+
+ this.sdump('D_TRACE_EXIT',this.arg_dump(arguments));
+ },
+
+ 'sdump' : function (level,msg) {
+ try {
+ var now = new Date();
+ var message = now.valueOf() + '\tdelta = ' + (now.valueOf() - this.sdump_last_time.valueOf()) + '\t' + level + '\n' + msg;
+ if (this.sdump_levels['D_NONE']) return null;
+ if (this.sdump_levels[level]||this.sdump_levels['D_ALL']) {
+ this.sdump_last_time = now;
+ if (this.debugDump || ( this.sdump_levels[level] && this.sdump_levels[level].debug ) ) this.debug(message);
+ if (this.alertDump || ( this.sdump_levels[level] && this.sdump_levels[level].alert ) ) alert(message);
+ if (this.consoleDump || ( this.sdump_levels[level] && this.sdump_levels[level].console ) ) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ this.consoleService.logStringMessage(message);
+ }
+ if (this.fileDump || ( this.sdump_levels[level] && this.sdump_levels[level].file ) ) {
+ if (level!='D_FILE') {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.file'); var master_log = new util.file('log');
+ master_log.write_content('append',message); master_log.close();
+ var specific_log = new util.file('log_'+level);
+ specific_log.write_content('append',message); specific_log.close();
+ }
+ }
+ }
+ } catch(E) {
+ dump('Calling sdump but ' + E + '\n');
+ }
+ },
+
+ 'arg_dump' : function (args,dump_these) {
+ var s = '*>*>*> Called function ';
+ try {
+ if (!dump_these)
+ dump_these = {};
+ s += args.callee.toString().match(/\w+/g)[1] + ' : ';
+ for (var i = 0; i < args.length; i++)
+ s += typeof(args[i]) + ' ';
+ s += '\n';
+ for (var i = 0; i < args.length; i++)
+ if (dump_these[i]) {
+
+ var arg = args[i];
+ //dump('dump_these[i] = ' + dump_these[i] + ' arg = ' + arg + '\n');
+
+ if (typeof(dump_these[i])=='string') {
+
+ if (dump_these[i].slice(0,1) == '.') {
+ var cmd = 'arg' + dump_these[i];
+ var result;
+ try {
+ result = eval( cmd );
+ } catch(E) {
+ result = cmd + ' ==> ' + E;
+ }
+ s += '\targ #' + i + ': ' + cmd + ' = ' + result;
+ } else {
+ var result;
+ try {
+ result = eval( dump_these[i] );
+ } catch(E) {
+ result = dump_these[i] + ' ==> ' + E;
+ }
+ s += '\targ #' + i + ': ' + result;
+ }
+
+ } else {
+ s += '\targ #' + i + ' = ';
+ try {
+ //s += js2JSON( arg );
+ s += arg;
+ } catch(E) {
+ s += arg;
+ }
+ }
+
+ s += '\n';
+ if (this.arg_dump_full)
+ s += 'Definition: ' + args.callee.toString() + '\n';
+
+ }
+ return s;
+ } catch(E) {
+ return s + '\nDEBUG ME: ' + js2JSON(E) + '\n';
+ }
+ },
+
+ 'handle_error' : function (E,annoy) {
+ var s = '';
+ if (instanceOf(E,ex)) {
+ s += E.err_msg();
+ //s += '\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n';
+ //s += 'This error was anticipated.\n\n';
+ //s += js2JSON(E).substr(0,200) + '...\n\n';
+ if (snd_bad) snd_bad();
+ } else {
+ s += '\n\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n';
+ s += 'This is a bug that we will fix later.\n\n';
+ try {
+ s += js2JSON(E).substr(0,1024) + '\n\n';
+ } catch(E2) {
+ try {
+ s += E.substr(0,1024) + '\n\n';
+ } catch(E3) {
+ s += E + '\n\n';
+ }
+ }
+ if (snd_really_bad) snd_really_bad();
+ }
+ sdump('D_ERROR',s);
+ if (annoy)
+ this.s_alert(s);
+ else
+ alert(s);
+ },
+
+ 's_alert' : function (s) { alert(s); },
+
+ 'standard_network_error_alert' : function(msg) {
+ var obj = this;
+ if (!msg) msg = '';
+ var alert_msg = 'We experienced a network/server communication failure. Please check your internet connection and try this action again. Repeated failures may require attention from your local IT staff or your friendly Evergreen developers.\n\n' + msg;
+ obj.yns_alert(
+ alert_msg,
+ 'Communication Failure',
+ 'Ok', null, null, 'Check here to confirm this message'
+ );
+ },
+
+ 'standard_unexpected_error_alert' : function(msg,E) {
+ var obj = this;
+ if (E != null && typeof E.ilsevent != 'undefined') {
+ if (E.ilsevent == 0 /* SUCCESS */ ) {
+ msg = "The action involved likely succeeded, however, this part of the software needs to be updated to better understand success messages from the server, so please let us know about it.";
+ }
+ if (E.ilsevent == -1 /* Network/Server Problem */ ) {
+ return obj.standard_network_error_alert(msg);
+ }
+ if (E.ilsevent == 5000 /* PERM_FAILURE */ ) {
+ msg = "The action involved likely failed due to insufficient permissions. However, this part of the software needs to be updated to better understand permission messages from the server, so please let us know about it.";
+ }
+ }
+ if (!msg) msg = '';
+ var alert_msg = 'FIXME: If you encounter this alert, please inform your IT/ILS helpdesk staff or your friendly Evergreen developers.\n\n' + (new Date()) + '\n\n' + msg + '\n\n' + (typeof E.ilsevent != 'undefined' ? E.textcode + '\n' + (E.desc ? E.desc + '\n' : '') : '') + ( typeof E.status != 'undefined' ? 'Status: ' + E.status + '\n': '' ) + ( typeof E == 'string' ? E + '\n' : '' );
+ obj.sdump('D_ERROR',msg + ' : ' + js2JSON(E));
+ var r = obj.yns_alert(
+ alert_msg,
+ 'Unhandled Error',
+ 'Ok', 'Debug Output to send to Helpdesk', null, 'Check here to confirm this message',
+ '/xul/server/skin/media/images/skull.png'
+ );
+ if (r == 1) {
+ JSAN.use('util.window'); var win = new util.window();
+ win.open(
+ 'data:text/plain,' + window.escape( 'Please open a helpdesk ticket and include the following text: \n\n' + (new Date()) + '\n\n' + msg + '\n\n' + obj.pretty_print(js2JSON(E)) ),
+ 'error_alert',
+ 'chrome,resizable,width=700,height=500'
+ );
+ }
+ if (r==2) {
+ alert('Not Yet Implemented');
+ }
+ },
+
+ 'yns_alert' : function (s,title,b1,b2,b3,c,image) {
+
+ try {
+
+ if (location.href.match(/^chrome/)) return this.yns_alert_original(s,title,b1,b2,b3,c);
+
+ /* The original purpose of yns_alert was to prevent errors from being scanned through accidentally with a barcode scanner.
+ However, this can be done in a less annoying manner by rolling our own dialog and not having any of the options in focus */
+
+ /*
+ s = Message to display
+ title = Text in Title Bar
+ b1 = Text for button 1
+ b2 = Text for button 2
+ b3 = Text for button 3
+ c = Text for confirmation checkbox. null for no confirm
+ */
+
+ dump('yns_alert:\n\ts = ' + s + '\n\ttitle = ' + title + '\n\tb1 = ' + b1 + '\n\tb2 = ' + b2 + '\n\tb3 = ' + b3 + '\n\tc = ' + c + '\n');
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
+
+ this.sound.bad();
+
+
+ //FIXME - is that good enough of an escape job?
+ s = s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
+
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" flex="1">'
+ + '<groupbox flex="1" style="overflow: auto; border: solid thin red;"><caption label="' + (title) + '"/>';
+
+ if (image) xml += '<hbox><image src="' + image + '"/><spacer flex="1"/></hbox>';
+ xml += '<description style="font-size: large">' + (s)
+ + '</description></groupbox><groupbox><caption label="Options"/><hbox>';
+ var b1_key = b1 ? b1[0] : '';
+ var b2_key = b2 ? b2[0] : '';
+ var b3_key = b3 ? b3[0] : ''; /* FIXME - need to check for collisions */
+ if (b1) xml += '<button id="b1" accesskey="' + b1_key + '" label="' + (b1) + '" name="fancy_submit" value="b1"/>'
+ if (b2) xml += '<button id="b2" accesskey="' + b2_key + '" label="' + (b2) + '" name="fancy_submit" value="b2"/>'
+ if (b3) xml += '<button id="b3" accesskey="' + b3_key + '" label="' + (b3) + '" name="fancy_submit" value="b3"/>'
+ xml += '</hbox></groupbox></vbox>';
+ JSAN.use('OpenILS.data');
+ //var data = new OpenILS.data(); data.init({'via':'stash'});
+ //data.temp_yns_xml = xml; data.stash('temp_yns_xml');
+ var url = urls.XUL_FANCY_PROMPT; // + '?xml_in_stash=temp_yns_xml' + '&title=' + window.escape(title);
+ if (typeof xulG != 'undefined') if (typeof xulG.url_prefix == 'function') url = xulG.url_prefix( url );
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ url, 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500', { 'xml' : xml, 'title' : title }
+ );
+ if (fancy_prompt_data.fancy_status == 'complete') {
+ switch(fancy_prompt_data.fancy_submit) {
+ case 'b1' : return 0; break;
+ case 'b2' : return 1; break;
+ case 'b3' : return 2; break;
+ }
+ } else {
+ //return this.yns_alert(s,title,b1,b2,b3,c,image);
+ return null;
+ }
+
+ } catch(E) {
+
+ dump('yns_alert failed: ' + E + '\ns = ' + s + '\ntitle = ' + title + '\nb1 = ' + b1 + '\nb2 = ' + b2 + '\nb3 = ' + b3 + '\nc = ' + c + '\nimage = ' + image + '\n');
+
+ this.yns_alert_original(s + '\n\nAlso, yns_alert failed: ' + E,title,b1,b2,b3,c);
+
+ }
+ },
+
+ 'yns_alert_formatted' : function (s,title,b1,b2,b3,c,image) {
+
+ try {
+
+ if (location.href.match(/^chrome/)) return this.yns_alert_original(s,title,b1,b2,b3,c);
+
+ /* The original purpose of yns_alert was to prevent errors from being scanned through accidentally with a barcode scanner.
+ However, this can be done in a less annoying manner by rolling our own dialog and not having any of the options in focus */
+
+ /*
+ s = Message to display
+ title = Text in Title Bar
+ b1 = Text for button 1
+ b2 = Text for button 2
+ b3 = Text for button 3
+ c = Text for confirmation checkbox. null for no confirm
+ */
+
+ dump('yns_alert:\n\ts = ' + s + '\n\ttitle = ' + title + '\n\tb1 = ' + b1 + '\n\tb2 = ' + b2 + '\n\tb3 = ' + b3 + '\n\tc = ' + c + '\n');
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
+
+ this.sound.bad();
+
+
+ //FIXME - is that good enough of an escape job?
+ s = s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
+
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" flex="1">'
+ + '<groupbox flex="1" style="overflow: auto; border: solid thin red;"><caption label="' + (title) + '"/>';
+
+ if (image) xml += '<hbox><image src="' + image + '"/><spacer flex="1"/></hbox>';
+ xml += '<description style="font-size: large"><html:pre style="font-size: large">' + (s)
+ + '</html:pre></description></groupbox><groupbox><caption label="Options"/><hbox>';
+ var b1_key = b1 ? b1[0] : '';
+ var b2_key = b2 ? b2[0] : '';
+ var b3_key = b3 ? b3[0] : ''; /* FIXME - need to check for collisions */
+ if (b1) xml += '<button id="b1" accesskey="' + b1_key + '" label="' + (b1) + '" name="fancy_submit" value="b1"/>'
+ if (b2) xml += '<button id="b2" accesskey="' + b2_key + '" label="' + (b2) + '" name="fancy_submit" value="b2"/>'
+ if (b3) xml += '<button id="b3" accesskey="' + b3_key + '" label="' + (b3) + '" name="fancy_submit" value="b3"/>'
+ xml += '</hbox></groupbox></vbox>';
+ JSAN.use('OpenILS.data');
+ //var data = new OpenILS.data(); data.init({'via':'stash'});
+ //data.temp_yns_xml = xml; data.stash('temp_yns_xml');
+ var url = urls.XUL_FANCY_PROMPT; // + '?xml_in_stash=temp_yns_xml' + '&title=' + window.escape(title);
+ if (typeof xulG != 'undefined') if (typeof xulG.url_prefix == 'function') url = xulG.url_prefix( url );
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ url, 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500', { 'xml' : xml, 'title' : title }
+ );
+ if (fancy_prompt_data.fancy_status == 'complete') {
+ switch(fancy_prompt_data.fancy_submit) {
+ case 'b1' : return 0; break;
+ case 'b2' : return 1; break;
+ case 'b3' : return 2; break;
+ }
+ } else {
+ //return this.yns_alert(s,title,b1,b2,b3,c,image);
+ return null;
+ }
+
+ } catch(E) {
+
+ alert('yns_alert_formatted failed: ' + E + '\ns = ' + s + '\ntitle = ' + title + '\nb1 = ' + b1 + '\nb2 = ' + b2 + '\nb3 = ' + b3 + '\nc = ' + c + '\nimage = ' + image + '\n');
+
+ }
+
+ },
+
+ 'yns_alert_original' : function (s,title,b1,b2,b3,c) {
+
+ /*
+ s = Message to display
+ title = Text in Title Bar
+ b1 = Text for button 1
+ b2 = Text for button 2
+ b3 = Text for button 3
+ c = Text for confirmation checkbox. null for no confirm
+ */
+
+ dump('yns_alert_original:\n\ts = ' + s + '\n\ttitle = ' + title + '\n\tb1 = ' + b1 + '\n\tb2 = ' + b2 + '\n\tb3 = ' + b3 + '\n\tc = ' + c + '\n');
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ this.sound.bad();
+
+ // get a reference to the prompt service component.
+ var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+
+ // set the buttons that will appear on the dialog. It should be
+ // a set of constants multiplied by button position constants. In this case,
+ // three buttons appear, Save, Cancel and a custom button.
+ //var flags=promptService.BUTTON_TITLE_OK * promptService.BUTTON_POS_0 +
+ // promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1 +
+ // promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
+ var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 +
+ promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 +
+ promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
+
+ // display the dialog box. The flags set above are passed
+ // as the fourth argument. The next three arguments are custom labels used for
+ // the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a
+ // particular button. The last two arguments are for an optional check box.
+ var check = {};
+
+ // promptService.confirmEx does not offer scrollbars for long
+ // content, so trim error lines to avoid spilling offscreen
+ //
+ // There's probably a better way of doing this.
+
+ var maxlines = 30;
+ var ss = '';
+ var linefeeds = 0;
+ for (var i=0, chr; linefeeds < maxlines && i < s.length; i++) {
+ if ((chr = this.getWholeChar(s, i)) === false) {continue;}
+ if (chr == '\u000A') { // \n
+ linefeeds++;
+ }
+ ss = ss + chr;
+ }
+
+ var rv = promptService.confirmEx(window,title, ss, flags, b1, b2, b3, c, check);
+ if (c && !check.value) {
+ return this.yns_alert_original(ss,title,b1,b2,b3,c);
+ }
+ return rv;
+ },
+
+ 'print_tabs' : function(t) {
+ var r = '';
+ for (var j = 0; j < t; j++ ) { r = r + "\t"; }
+ return r;
+ },
+
+ 'pretty_print' : function(s) {
+ var r = ''; var t = 0;
+ for (var i in s) {
+ if (s[i] == '{') {
+ r = r + "\n" + this.print_tabs(t) + s[i]; t++;
+ r = r + "\n" + this.print_tabs(t);
+ } else if (s[i] == '[') {
+ r = r + "\n" + this.print_tabs(t) + s[i]; t++;
+ r = r + "\n" + this.print_tabs(t);
+ } else if (s[i] == '}') {
+ t--; r = r + "\n" + this.print_tabs(t) + s[i];
+ r = r + "\n" + this.print_tabs(t);
+ } else if (s[i] == ']') {
+ t--; r = r + "\n" + this.print_tabs(t) + s[i];
+ r = r + "\n" + this.print_tabs(t);
+ } else if (s[i] == ',') {
+ r = r + s[i];
+ r = r + "\n" + this.print_tabs(t);
+ } else {
+ r = r + s[i];
+ }
+ }
+ return r;
+ },
+
+ // Copied from https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/charCodeAt
+ 'getWholeChar' : function(str, i) {
+ var code = str.charCodeAt(i);
+ if (0xD800 <= code && code <= 0xDBFF) { // High surrogate(could change last hex to 0xDB7F to treat high private surrogates as single characters)
+ if (str.length <= (i+1)) {
+ throw 'High surrogate without following low surrogate';
+ }
+ var next = str.charCodeAt(i+1);
+ if (0xDC00 > next || next > 0xDFFF) {
+ throw 'High surrogate without following low surrogate';
+ }
+ return str[i]+str[i+1];
+ }
+ else if (0xDC00 <= code && code <= 0xDFFF) { // Low surrogate
+ if (i === 0) {
+ throw 'Low surrogate without preceding high surrogate';
+ }
+ var prev = str.charCodeAt(i-1);
+ if (0xD800 > prev || prev > 0xDBFF) { //(could change last hex to 0xDB7F to treat high private surrogates as single characters)
+ throw 'Low surrogate without preceding high surrogate';
+ }
+ return false; // We can pass over low surrogates now as the second component in a pair which we have already processed
+ }
+ return str[i];
+ },
'work_log' : function(msg,row_data) {
try {
if (typeof util == 'undefined') var util = {};
util.exec = function(chunk_size) {
- //JSAN.use('util.error'); this.error = new util.error();
+ //JSAN.use('util.error'); this.error = new util.error();
- this.chunk_size = chunk_size || 1;
+ this.chunk_size = chunk_size || 1;
- return this;
+ return this;
};
util.exec.prototype = {
);
window.addEventListener('unload',function() { window.clearInterval(intervalId); },false);
},
- // This executes a series of functions, but tries to give other events/functions a chance to
- // execute between each one.
- 'chain' : function () {
- var args = [];
- var obj = this;
- for (var i = 0; i < arguments.length; i++) {
- var arg = arguments[i];
- switch(arg.constructor.name) {
- case 'Function' :
- args.push( arg );
- break;
- case 'Array' :
- for (var j = 0; j < arg.length; j++) {
- if (typeof arg[j] == 'function') args.push( arg[j] );
- }
- break;
- case 'Object' :
- for (var j in arg) {
- if (typeof arg[j] == 'function') args.push( arg[j] );
- }
- break;
- }
- }
- if (args.length > 0) setTimeout(
- function() {
- try {
- for (var i = 0; (i < args.length && i < obj.chunk_size) ; i++) {
- try {
- if (typeof args[i] == 'function') {
- args[i]();
- } else {
- alert('FIXME -- typeof args['+i+'] == ' + typeof args[i]);
- }
- } catch(E) {
- dump('util.exec.chain error: ' + js2JSON(E) + '\n');
- var keep_going = false;
- if (typeof obj.on_error == 'function') {
- keep_going = obj.on_error(E);
- }
- if (keep_going) {
- dump('chain not broken\n');
- try {
- if (args.length > 1 ) obj.chain( args.slice(1) );
+ // This executes a series of functions, but tries to give other events/functions a chance to
+ // execute between each one.
+ 'chain' : function () {
+ var args = [];
+ var obj = this;
+ for (var i = 0; i < arguments.length; i++) {
+ var arg = arguments[i];
+ switch(arg.constructor.name) {
+ case 'Function' :
+ args.push( arg );
+ break;
+ case 'Array' :
+ for (var j = 0; j < arg.length; j++) {
+ if (typeof arg[j] == 'function') args.push( arg[j] );
+ }
+ break;
+ case 'Object' :
+ for (var j in arg) {
+ if (typeof arg[j] == 'function') args.push( arg[j] );
+ }
+ break;
+ }
+ }
+ if (args.length > 0) setTimeout(
+ function() {
+ try {
+ for (var i = 0; (i < args.length && i < obj.chunk_size) ; i++) {
+ try {
+ if (typeof args[i] == 'function') {
+ args[i]();
+ } else {
+ alert('FIXME -- typeof args['+i+'] == ' + typeof args[i]);
+ }
+ } catch(E) {
+ dump('util.exec.chain error: ' + js2JSON(E) + '\n');
+ var keep_going = false;
+ if (typeof obj.on_error == 'function') {
+ keep_going = obj.on_error(E);
+ }
+ if (keep_going) {
+ dump('chain not broken\n');
+ try {
+ if (args.length > 1 ) obj.chain( args.slice(1) );
- } catch(E) {
- dump('another error: ' + js2JSON(E) + '\n');
- }
- } else {
- dump('chain broken\n');
+ } catch(E) {
+ dump('another error: ' + js2JSON(E) + '\n');
+ }
+ } else {
+ dump('chain broken\n');
return;
- }
- }
- }
- if (args.length > obj.chunk_size ) obj.chain( args.slice(obj.chunk_size) );
- } catch(E) {
- alert(E);
- }
- }, 0
- );
- }
+ }
+ }
+ }
+ if (args.length > obj.chunk_size ) obj.chain( args.slice(obj.chunk_size) );
+ } catch(E) {
+ alert(E);
+ }
+ }, 0
+ );
+ }
}
dump('exiting util/exec.js\n');
if (typeof util == 'undefined') util = {};
util.file = function (fname) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
- JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.error'); this.error = new util.error();
- this.dirService = Components.classes["@mozilla.org/file/directory_service;1"].
- getService( Components.interfaces.nsIProperties );
+ this.dirService = Components.classes["@mozilla.org/file/directory_service;1"].
+ getService( Components.interfaces.nsIProperties );
- if (fname) this.get(fname);
+ if (fname) this.get(fname);
- return this;
+ return this;
};
util.file.prototype = {
- 'myPackageDir' : 'open_ils_staff_client',
-
- 'name' : '',
- '_file' : null,
- '_input_stream' : null,
- '_output_stream' : null,
-
- 'get' : function( fname, path ) {
- try {
- if (!fname) { fname = this.name; } else { this.name = fname; }
- if (!fname) throw('Must specify a filename.');
-
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
- var pref = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
- if (!path && pref.getBoolPref("open-ils.write_in_user_chrome_directory")) path = 'uchrome';
- } catch(E) {
- // getBoolPref throws an exception if "open-ils.write_in_user_chrome_directory" is not defined at all
- // in defaults/preferences/prefs.js
- }
-
- switch(path) {
- case 'uchrome' :
- this._file = this.dirService.get( "UChrm", Components.interfaces.nsIFile );
- //this._file = this.dirService.get( "ProfD", Components.interfaces.nsIFile );
- break;
- default:
- case 'chrome' :
- this._file = this.dirService.get( "AChrom", Components.interfaces.nsIFile );
- this._file.append(myPackageDir);
- this._file.append("content");
- this._file.append("conf");
- break;
- }
- this._file.append(fname);
-
- dump('file: ' + this._file.path + '\n');
- this.error.sdump('D_FILE',this._file.path);
-
- return this._file;
-
- } catch(E) {
- this.error.standard_unexpected_error_alert('error in util.file.get('+fname+','+path+')',E);
- throw(E);
- }
- },
-
- 'close' : function() {
- try {
- if (!this._file) throw('Must .get() a file first.');
- if (this._input_stream) { this._input_stream.close(); this._input_stream = null; }
- if (this._output_stream) { this._output_stream.close(); this._output_stream = null; }
- if (this._istream) { this._istream.close(); this._istream = null; }
- if (this._f) { this._f = null; }
-
- } catch(E) {
- this.error.sdump('D_ERROR',this._file.path + '\nutil.file.close(): ' + E);
- throw(E);
- }
- },
-
- 'append_object' : function(obj) {
- try {
- this.write_object('append',obj);
- } catch(E) {
- this.error.sdump('D_ERROR',this._file.path + '\nutil.file.append_object(): ' + E);
- throw(E);
- }
- },
-
- 'set_object' : function(obj) {
- try {
- this.write_object('truncate',obj);
- this.close();
- } catch(E) {
- this.error.sdump('D_ERROR',this._file.path + '\nutil.file.set_object(): ' + E);
- throw(E);
- }
- },
-
- 'write_object' : function(write_type,obj) {
- try {
- if (!this._file) throw('Must .get() a file first.');
- if (!obj) throw('Must specify an object.');
-
- var obj_json;
- try { obj_json = js2JSON( obj ) + '\n'; } catch(E) { throw('Could not JSONify the object: ' + E); }
-
- this.write_content(write_type,obj_json);
-
- } catch(E) {
- this.error.sdump('D_ERROR',this._file.path + '\nutil.file.write_object(): ' + E);
- throw(E);
- }
- },
-
- 'write_content' : function(write_type,content) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
- if (!this._output_stream) this._create_output_stream(write_type);
- this._output_stream.write( content, String( content ).length );
- } catch(E) {
- this.error.sdump('D_ERROR',this._file.path + '\nutil.file.write_content(): ' + E);
- //dump('write_type = ' + write_type + '\n');
- //dump('content = ' + content + '\n');
- throw(E);
- }
- },
-
- 'get_object' : function() {
- try {
- var data = this.get_content();
- var obj; try { obj = JSON2js( data ); } catch(E) { throw('Could not js-ify the JSON: '+E); }
- return obj;
- } catch(E) {
- this.error.sdump('D_ERROR',this._file.path + '\nutil.file.get_object(): ' + E);
- throw(E);
- }
- },
-
- 'get_content' : function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
-
- if (!this._file) throw('Must .get() a file first.');
- if (!this._file.exists()) throw('File does not exist.');
-
- if (!this._input_stream) this._create_input_stream();
- var data = this._input_stream.read(-1);
- //var data = {}; this._istream.readLine(data);
- return data;
- } catch(E) {
- this.error.sdump('D_ERROR',this._file.path + '\nutil.file.get_content(): ' + E);
- throw(E);
- }
- },
-
- '_create_input_stream' : function() {
- try {
- //dump('_create_input_stream()\n');
-
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
-
- if (!this._file) throw('Must .get() a file first.');
- if (!this._file.exists()) throw('File does not exist.');
-
- this._f = Components.classes["@mozilla.org/network/file-input-stream;1"]
- .createInstance(Components.interfaces.nsIFileInputStream);
- this._f.init(this._file, MODE_RDONLY, 0, 0);
- /*
- this._f.QueryInterface(Components.interfaces.nsILineInputStream);
- this._istream = this._f;
- */
- this._input_stream = Components.classes["@mozilla.org/scriptableinputstream;1"]
- .createInstance(Components.interfaces.nsIScriptableInputStream);
- if (this._f) {
- this._input_stream.init(this._f);
- } else {
- throw('Could not instantiate input stream.');
- }
- return this._input_stream;
-
- } catch(E) {
- this.error.sdump('D_ERROR',this._file.path + '\nutil.file._create_input_stream(): ' + E);
- throw(E);
- }
- },
-
- '_create_output_stream' : function(param) {
- try {
- //dump('_create_output_stream('+param+') for '+this._file.path+'\n');
-
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
-
- if (!this._file) throw('Must .get() a file first.');
-
- if (! this._file.exists()) {
+ 'myPackageDir' : 'open_ils_staff_client',
+
+ 'name' : '',
+ '_file' : null,
+ '_input_stream' : null,
+ '_output_stream' : null,
+
+ 'get' : function( fname, path ) {
+ try {
+ if (!fname) { fname = this.name; } else { this.name = fname; }
+ if (!fname) throw('Must specify a filename.');
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
+ var pref = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+ if (!path && pref.getBoolPref("open-ils.write_in_user_chrome_directory")) path = 'uchrome';
+ } catch(E) {
+ // getBoolPref throws an exception if "open-ils.write_in_user_chrome_directory" is not defined at all
+ // in defaults/preferences/prefs.js
+ }
+
+ switch(path) {
+ case 'uchrome' :
+ this._file = this.dirService.get( "UChrm", Components.interfaces.nsIFile );
+ //this._file = this.dirService.get( "ProfD", Components.interfaces.nsIFile );
+ break;
+ default:
+ case 'chrome' :
+ this._file = this.dirService.get( "AChrom", Components.interfaces.nsIFile );
+ this._file.append(myPackageDir);
+ this._file.append("content");
+ this._file.append("conf");
+ break;
+ }
+ this._file.append(fname);
+
+ dump('file: ' + this._file.path + '\n');
+ this.error.sdump('D_FILE',this._file.path);
+
+ return this._file;
+
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('error in util.file.get('+fname+','+path+')',E);
+ throw(E);
+ }
+ },
+
+ 'close' : function() {
+ try {
+ if (!this._file) throw('Must .get() a file first.');
+ if (this._input_stream) { this._input_stream.close(); this._input_stream = null; }
+ if (this._output_stream) { this._output_stream.close(); this._output_stream = null; }
+ if (this._istream) { this._istream.close(); this._istream = null; }
+ if (this._f) { this._f = null; }
+
+ } catch(E) {
+ this.error.sdump('D_ERROR',this._file.path + '\nutil.file.close(): ' + E);
+ throw(E);
+ }
+ },
+
+ 'append_object' : function(obj) {
+ try {
+ this.write_object('append',obj);
+ } catch(E) {
+ this.error.sdump('D_ERROR',this._file.path + '\nutil.file.append_object(): ' + E);
+ throw(E);
+ }
+ },
+
+ 'set_object' : function(obj) {
+ try {
+ this.write_object('truncate',obj);
+ this.close();
+ } catch(E) {
+ this.error.sdump('D_ERROR',this._file.path + '\nutil.file.set_object(): ' + E);
+ throw(E);
+ }
+ },
+
+ 'write_object' : function(write_type,obj) {
+ try {
+ if (!this._file) throw('Must .get() a file first.');
+ if (!obj) throw('Must specify an object.');
+
+ var obj_json;
+ try { obj_json = js2JSON( obj ) + '\n'; } catch(E) { throw('Could not JSONify the object: ' + E); }
+
+ this.write_content(write_type,obj_json);
+
+ } catch(E) {
+ this.error.sdump('D_ERROR',this._file.path + '\nutil.file.write_object(): ' + E);
+ throw(E);
+ }
+ },
+
+ 'write_content' : function(write_type,content) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
+ if (!this._output_stream) this._create_output_stream(write_type);
+ this._output_stream.write( content, String( content ).length );
+ } catch(E) {
+ this.error.sdump('D_ERROR',this._file.path + '\nutil.file.write_content(): ' + E);
+ //dump('write_type = ' + write_type + '\n');
+ //dump('content = ' + content + '\n');
+ throw(E);
+ }
+ },
+
+ 'get_object' : function() {
+ try {
+ var data = this.get_content();
+ var obj; try { obj = JSON2js( data ); } catch(E) { throw('Could not js-ify the JSON: '+E); }
+ return obj;
+ } catch(E) {
+ this.error.sdump('D_ERROR',this._file.path + '\nutil.file.get_object(): ' + E);
+ throw(E);
+ }
+ },
+
+ 'get_content' : function() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
+
+ if (!this._file) throw('Must .get() a file first.');
+ if (!this._file.exists()) throw('File does not exist.');
+
+ if (!this._input_stream) this._create_input_stream();
+ var data = this._input_stream.read(-1);
+ //var data = {}; this._istream.readLine(data);
+ return data;
+ } catch(E) {
+ this.error.sdump('D_ERROR',this._file.path + '\nutil.file.get_content(): ' + E);
+ throw(E);
+ }
+ },
+
+ '_create_input_stream' : function() {
+ try {
+ //dump('_create_input_stream()\n');
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
+
+ if (!this._file) throw('Must .get() a file first.');
+ if (!this._file.exists()) throw('File does not exist.');
+
+ this._f = Components.classes["@mozilla.org/network/file-input-stream;1"]
+ .createInstance(Components.interfaces.nsIFileInputStream);
+ this._f.init(this._file, MODE_RDONLY, 0, 0);
+ /*
+ this._f.QueryInterface(Components.interfaces.nsILineInputStream);
+ this._istream = this._f;
+ */
+ this._input_stream = Components.classes["@mozilla.org/scriptableinputstream;1"]
+ .createInstance(Components.interfaces.nsIScriptableInputStream);
+ if (this._f) {
+ this._input_stream.init(this._f);
+ } else {
+ throw('Could not instantiate input stream.');
+ }
+ return this._input_stream;
+
+ } catch(E) {
+ this.error.sdump('D_ERROR',this._file.path + '\nutil.file._create_input_stream(): ' + E);
+ throw(E);
+ }
+ },
+
+ '_create_output_stream' : function(param) {
+ try {
+ //dump('_create_output_stream('+param+') for '+this._file.path+'\n');
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalPreferencesWrite UniversalBrowserWrite UniversalPreferencesRead UniversalBrowserRead UniversalFileRead");
+
+ if (!this._file) throw('Must .get() a file first.');
+
+ if (! this._file.exists()) {
if (param == 'truncate+exec') {
this._file.create( 0, 0777 );
} else {
this._file.create( 0, PERMS_FILE );
}
}
- this._output_stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
- .createInstance(Components.interfaces.nsIFileOutputStream);
- switch(param){
- case 'append' :
- this._output_stream.init(this._file, MODE_WRONLY | MODE_APPEND, PERMS_FILE, 0);
- break;
+ this._output_stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
+ .createInstance(Components.interfaces.nsIFileOutputStream);
+ switch(param){
+ case 'append' :
+ this._output_stream.init(this._file, MODE_WRONLY | MODE_APPEND, PERMS_FILE, 0);
+ break;
case 'truncate+exec' :
- this._output_stream.init(this._file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
+ this._output_stream.init(this._file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
+ break;
+ case 'truncate' :
+ default:
+ this._output_stream.init(this._file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
break;
- case 'truncate' :
- default:
- this._output_stream.init(this._file, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE, PERMS_FILE, 0);
- break;
- }
-
- return this._output_stream;
-
- } catch(E) {
- this.error.sdump('D_ERROR',this._file.path + '\nutil.file._create_output_stream(): ' + E);
- throw(E);
- }
- },
-
- 'pick_file' : function(params) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ }
+
+ return this._output_stream;
+
+ } catch(E) {
+ this.error.sdump('D_ERROR',this._file.path + '\nutil.file._create_output_stream(): ' + E);
+ throw(E);
+ }
+ },
+
+ 'pick_file' : function(params) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
if (typeof params == 'undefined') params = {};
if (typeof params.mode == 'undefined') params.mode = 'open';
- var nsIFilePicker = Components.interfaces.nsIFilePicker;
- var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance( nsIFilePicker );
- fp.init(
- window,
+ var nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance( nsIFilePicker );
+ fp.init(
+ window,
typeof params.title == 'undefined' ? params.mode : params.title,
- params.mode == 'open' ? nsIFilePicker.modeOpen : nsIFilePicker.modeSave
- );
+ params.mode == 'open' ? nsIFilePicker.modeOpen : nsIFilePicker.modeSave
+ );
if (params.defaultFileName) {
fp.defaultString = params.defaultFileName;
}
- fp.appendFilters( nsIFilePicker.filterAll );
- var fp_result = fp.show();
- if ( ( fp_result == nsIFilePicker.returnOK || fp_result == nsIFilePicker.returnReplace ) && fp.file ) {
- return fp.file;
- } else {
- return null;
- }
- } catch(E) {
- this.error.standard_unexpected_error_alert('error picking file',E);
- }
- },
-
- 'export_file' : function(params) {
- try {
- var obj = this;
+ fp.appendFilters( nsIFilePicker.filterAll );
+ var fp_result = fp.show();
+ if ( ( fp_result == nsIFilePicker.returnOK || fp_result == nsIFilePicker.returnReplace ) && fp.file ) {
+ return fp.file;
+ } else {
+ return null;
+ }
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('error picking file',E);
+ }
+ },
+
+ 'export_file' : function(params) {
+ try {
+ var obj = this;
if (typeof params == 'undefined') params = {};
params.mode = 'save';
if (typeof params.data == 'undefined') throw('Need a .data field to export');
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var f = obj.pick_file( params );
- if (f) {
- obj._file = f;
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var f = obj.pick_file( params );
+ if (f) {
+ obj._file = f;
var temp = params.data;
if (typeof params.not_json == 'undefined') {
temp = js2JSON( temp );
}
- obj.write_content( 'truncate', temp );
- obj.close();
- alert('Exported ' + f.leafName);
+ obj.write_content( 'truncate', temp );
+ obj.close();
+ alert('Exported ' + f.leafName);
return obj._file;
- } else {
- alert('File not chosen for export.');
+ } else {
+ alert('File not chosen for export.');
return null;
- }
+ }
- } catch(E) {
- this.error.standard_unexpected_error_alert('Error exporting file',E);
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('Error exporting file',E);
return null;
- }
- },
+ }
+ },
- 'import_file' : function(params) {
- try {
- var obj = this;
+ 'import_file' : function(params) {
+ try {
+ var obj = this;
if (typeof params == 'undefined') params = {};
params.mode = 'open';
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var f = obj.pick_file(params);
- if (f && f.exists()) {
- obj._file = f;
- var temp = obj.get_content();
- obj.close();
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var f = obj.pick_file(params);
+ if (f && f.exists()) {
+ obj._file = f;
+ var temp = obj.get_content();
+ obj.close();
if (typeof params.not_json == 'undefined') {
temp = JSON2js( obj.get_content() );
}
return temp;
- } else {
- alert('File not chosen for import.');
+ } else {
+ alert('File not chosen for import.');
return null;
- }
- } catch(E) {
- this.error.standard_unexpected_error_alert('Error importing file',E);
+ }
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('Error importing file',E);
return null;
- }
- }
+ }
+ }
}
if (typeof util == 'undefined') var util = {};
util.fm_utils = {};
-util.fm_utils.EXPORT_OK = [ 'flatten_ou_branch', 'find_ou', 'compare_aou_a_is_b_or_ancestor', 'sort_func_aou_by_depth_and_then_string', 'find_common_aou_ancestor', 'find_common_aou_ancestors' ];
-util.fm_utils.EXPORT_TAGS = { ':all' : util.fm_utils.EXPORT_OK };
+util.fm_utils.EXPORT_OK = [ 'flatten_ou_branch', 'find_ou', 'compare_aou_a_is_b_or_ancestor', 'sort_func_aou_by_depth_and_then_string', 'find_common_aou_ancestor', 'find_common_aou_ancestors' ];
+util.fm_utils.EXPORT_TAGS = { ':all' : util.fm_utils.EXPORT_OK };
util.fm_utils.flatten_ou_branch = function(branch) {
- var my_array = new Array();
- my_array.push( branch );
- if (typeof branch.children == 'function') for (var i in branch.children() ) {
- var child = branch.children()[i];
- if (child != null) {
- var temp_array = util.fm_utils.flatten_ou_branch(child);
- for (var j in temp_array) {
- my_array.push( temp_array[j] );
- }
- }
- }
- return my_array;
+ var my_array = new Array();
+ my_array.push( branch );
+ if (typeof branch.children == 'function') for (var i in branch.children() ) {
+ var child = branch.children()[i];
+ if (child != null) {
+ var temp_array = util.fm_utils.flatten_ou_branch(child);
+ for (var j in temp_array) {
+ my_array.push( temp_array[j] );
+ }
+ }
+ }
+ return my_array;
}
util.fm_utils.find_ou = function(tree,id) {
- if (typeof(id)=='object') { id = id.id(); }
- if (tree.id()==id) {
- return tree;
- }
- for (var i in tree.children()) {
- var child = tree.children()[i];
- ou = util.fm_utils.find_ou( child, id );
- if (ou) { return ou; }
- }
- return null;
+ if (typeof(id)=='object') { id = id.id(); }
+ if (tree.id()==id) {
+ return tree;
+ }
+ for (var i in tree.children()) {
+ var child = tree.children()[i];
+ ou = util.fm_utils.find_ou( child, id );
+ if (ou) { return ou; }
+ }
+ return null;
}
util.fm_utils.compare_aou_a_is_b_or_ancestor = function(a,b) {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
- if (typeof a != 'object') a = data.hash.aou[ a ];
- if (typeof b != 'object') b = data.hash.aou[ b ];
- var node = b;
- while ( node != null ) {
- if (a.id() == node.id()) return true;
- node = typeof node.parent_ou() == 'object' ? node.parent_ou() : data.hash.aou[ node.parent_ou() ];
- }
- return false;
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+ if (typeof a != 'object') a = data.hash.aou[ a ];
+ if (typeof b != 'object') b = data.hash.aou[ b ];
+ var node = b;
+ while ( node != null ) {
+ if (a.id() == node.id()) return true;
+ node = typeof node.parent_ou() == 'object' ? node.parent_ou() : data.hash.aou[ node.parent_ou() ];
+ }
+ return false;
}
util.fm_utils.sort_func_aou_by_depth_and_then_string = function(a,b) {
- try {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
- var a_aou = a[0]; var b_aou = b[0];
- var a_string = a[1]; var b_string = b[1];
- if (typeof a_aou != 'object') a_aou = data.hash.aou[ a_aou ];
- if (typeof b_aou != 'object') b_aou = data.hash.aou[ b_aou ];
- var A = data.hash.aout[ a_aou.ou_type() ].depth();
- var B = data.hash.aout[ b_aou.ou_type() ].depth();
- if (A < B) return 1;
- if (A > B) return -1;
- if (a_string < b_string ) return -1;
- if (a_string > b_string ) return 1;
- return 0;
- } catch(E) {
- alert('error in util.fm_utils.sort_func_aou_by_depth_and_string: ' + E);
- return 0;
- }
+ try {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+ var a_aou = a[0]; var b_aou = b[0];
+ var a_string = a[1]; var b_string = b[1];
+ if (typeof a_aou != 'object') a_aou = data.hash.aou[ a_aou ];
+ if (typeof b_aou != 'object') b_aou = data.hash.aou[ b_aou ];
+ var A = data.hash.aout[ a_aou.ou_type() ].depth();
+ var B = data.hash.aout[ b_aou.ou_type() ].depth();
+ if (A < B) return 1;
+ if (A > B) return -1;
+ if (a_string < b_string ) return -1;
+ if (a_string > b_string ) return 1;
+ return 0;
+ } catch(E) {
+ alert('error in util.fm_utils.sort_func_aou_by_depth_and_string: ' + E);
+ return 0;
+ }
}
util.fm_utils.find_common_aou_ancestor = function(orgs) {
- try {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ try {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- var candidates = {};
- for (var i = 0; i < orgs.length; i++) {
+ var candidates = {};
+ for (var i = 0; i < orgs.length; i++) {
- var node = orgs[i];
+ var node = orgs[i];
- while (node) {
+ while (node) {
- if (typeof node != 'object') node = data.hash.aou[ node ];
- if (!node) continue;
+ if (typeof node != 'object') node = data.hash.aou[ node ];
+ if (!node) continue;
- if ( candidates[node.id()] ) {
+ if ( candidates[node.id()] ) {
- candidates[node.id()]++;
-
- } else {
+ candidates[node.id()]++;
+
+ } else {
- candidates[node.id()] = 1;
- }
+ candidates[node.id()] = 1;
+ }
- if (candidates[node.id()] == orgs.length) return node;
+ if (candidates[node.id()] == orgs.length) return node;
- node = node.parent_ou();
- }
+ node = node.parent_ou();
+ }
- }
+ }
- return null;
+ return null;
- } catch(E) {
- alert('error in util.fm_utils.find_common_aou_ancestor: ' + E);
- return null;
- }
+ } catch(E) {
+ alert('error in util.fm_utils.find_common_aou_ancestor: ' + E);
+ return null;
+ }
}
util.fm_utils.find_common_aou_ancestors = function(orgs) {
- try {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ try {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- var candidates = {}; var winners = [];
- for (var i = 0; i < orgs.length; i++) {
+ var candidates = {}; var winners = [];
+ for (var i = 0; i < orgs.length; i++) {
- var node = orgs[i];
+ var node = orgs[i];
- while (node) {
+ while (node) {
- if (typeof node != 'object') node = data.hash.aou[ node ];
- if (!node) continue;
+ if (typeof node != 'object') node = data.hash.aou[ node ];
+ if (!node) continue;
- if ( candidates[node.id()] ) {
+ if ( candidates[node.id()] ) {
- candidates[node.id()]++;
-
- } else {
+ candidates[node.id()]++;
+
+ } else {
- candidates[node.id()] = 1;
- }
+ candidates[node.id()] = 1;
+ }
- node = node.parent_ou();
- }
+ node = node.parent_ou();
+ }
- }
+ }
- for (var i in candidates) {
+ for (var i in candidates) {
- if (candidates[i] == orgs.length) winners.push( i );
- }
+ if (candidates[i] == orgs.length) winners.push( i );
+ }
- return winners;
+ return winners;
- } catch(E) {
- alert('error in util.fm_utils.find_common_aou_ancestors: ' + E);
- return [];
- }
+ } catch(E) {
+ alert('error in util.fm_utils.find_common_aou_ancestors: ' + E);
+ return [];
+ }
}
if (typeof util == 'undefined') var util = {};
util.functional = {};
-util.functional.EXPORT_OK = [
- 'filter_list', 'filter_object', 'find_list', 'find_object', 'map_list', 'map_flat_list',
- 'map_object', 'map_object_to_list', 'convert_object_list_to_hash', 'find_id_object_in_list',
- 'find_attr_object_in_list', 'walk_tree_preorder',
+util.functional.EXPORT_OK = [
+ 'filter_list', 'filter_object', 'find_list', 'find_object', 'map_list', 'map_flat_list',
+ 'map_object', 'map_object_to_list', 'convert_object_list_to_hash', 'find_id_object_in_list',
+ 'find_attr_object_in_list', 'walk_tree_preorder',
];
-util.functional.EXPORT_TAGS = { ':all' : util.functional.EXPORT_OK };
+util.functional.EXPORT_TAGS = { ':all' : util.functional.EXPORT_OK };
util.functional.filter_list = function(list,f) {
- var new_list = [];
- for (var i = 0; i < list.length; i++) {
- var t = f( list[i] );
- if (t) new_list.push( list[i] );
- }
- return new_list;
+ var new_list = [];
+ for (var i = 0; i < list.length; i++) {
+ var t = f( list[i] );
+ if (t) new_list.push( list[i] );
+ }
+ return new_list;
}
util.functional.filter_object = function(obj,f) {
- var new_obj = {};
- for (var i in obj) {
- var t = f( i, obj[i] );
- if (t) new_obj[i] = obj[i];
- }
- return new_obj;
+ var new_obj = {};
+ for (var i in obj) {
+ var t = f( i, obj[i] );
+ if (t) new_obj[i] = obj[i];
+ }
+ return new_obj;
}
util.functional.find_list = function(list,f) {
- for (var i = 0; i < list.length; i++) {
- var t = f( list[i] );
- if (t) return list[i];
- }
- return null;
+ for (var i = 0; i < list.length; i++) {
+ var t = f( list[i] );
+ if (t) return list[i];
+ }
+ return null;
}
util.functional.find_object = function(obj,f) {
- for (var i in obj) {
- var t = f( i, obj[i] );
- if (t) return obj[i];
- }
- return null;
+ for (var i in obj) {
+ var t = f( i, obj[i] );
+ if (t) return obj[i];
+ }
+ return null;
}
util.functional.walk_tree_preorder = function(node,children_func,f,parent_node) {
- f(node,parent_node);
- var children = children_func( node );
- if (children) for (var i = 0; i < children.length; i++) {
- util.functional.walk_tree_preorder(
- children[i],
- children_func,
- f,
- node
- );
- }
+ f(node,parent_node);
+ var children = children_func( node );
+ if (children) for (var i = 0; i < children.length; i++) {
+ util.functional.walk_tree_preorder(
+ children[i],
+ children_func,
+ f,
+ node
+ );
+ }
}
util.functional.map_list = function(list,f) {
- var new_list = []; var idx = 0;
- for (var i in list) {
- new_list.push( f( list[i], idx++ ) );
- }
- return new_list;
+ var new_list = []; var idx = 0;
+ for (var i in list) {
+ new_list.push( f( list[i], idx++ ) );
+ }
+ return new_list;
}
util.functional.map_flat_list = function(list,f) {
- var new_list = [];
- for (var i in list) {
- new_list = new_list.concat( f( list[i] ) );
- }
- return new_list;
+ var new_list = [];
+ for (var i in list) {
+ new_list = new_list.concat( f( list[i] ) );
+ }
+ return new_list;
}
util.functional.map_object = function(obj,f) {
- var new_obj = {};
- for (var i in obj) {
- new_obj[ f( i, obj[i] )[0] ] = f( i, obj[i] )[1];
- }
- return new_obj;
+ var new_obj = {};
+ for (var i in obj) {
+ new_obj[ f( i, obj[i] )[0] ] = f( i, obj[i] )[1];
+ }
+ return new_obj;
}
util.functional.map_object_to_list = function(obj,f) {
- var new_list = [];
- for (var i in obj) {
- new_list.push( f( obj, i ) );
- }
- return new_list;
+ var new_list = [];
+ for (var i in obj) {
+ new_list.push( f( obj, i ) );
+ }
+ return new_list;
}
util.functional.convert_object_list_to_hash = function(list) {
- var my_hash = new Object();
- if (list) {
- for (var i = 0; i < list.length; i++) {
- if (typeof list[i].id == 'function') {
- my_hash[ list[i].id() ] = list[i];
- } else if (typeof list[i].code == 'function') {
- my_hash[ list[i].code() ] = list[i];
- }
- }
- }
- return my_hash;
+ var my_hash = new Object();
+ if (list) {
+ for (var i = 0; i < list.length; i++) {
+ if (typeof list[i].id == 'function') {
+ my_hash[ list[i].id() ] = list[i];
+ } else if (typeof list[i].code == 'function') {
+ my_hash[ list[i].code() ] = list[i];
+ }
+ }
+ }
+ return my_hash;
}
util.functional.find_id_object_in_list = function(list,id) {
- if (list) {
- for (var i = 0; i < list.length; i++ ) {
- try {
- if ( list[i].id() == id ) {
- return list[i];
- }
- } catch(E) {
- throw(E);
- }
- }
- }
- return null;
+ if (list) {
+ for (var i = 0; i < list.length; i++ ) {
+ try {
+ if ( list[i].id() == id ) {
+ return list[i];
+ }
+ } catch(E) {
+ throw(E);
+ }
+ }
+ }
+ return null;
}
util.functional.find_attr_object_in_list = function(list,attr,value) {
- if (list) {
- for (var i = 0; i < list.length; i++ ) {
- try {
- var command = 'list[' + i + '].'+attr+'() == ' + value;
- if ( eval(command) ) {
- return list[i];
- }
- } catch(E) {
- throw(E);
- }
- }
- }
- return null;
+ if (list) {
+ for (var i = 0; i < list.length; i++ ) {
+ try {
+ var command = 'list[' + i + '].'+attr+'() == ' + value;
+ if ( eval(command) ) {
+ return list[i];
+ }
+ } catch(E) {
+ throw(E);
+ }
+ }
+ }
+ return null;
}
dump('exiting util/functional.js\n');
if (typeof main == 'undefined') main = {};
util.list = function (id) {
- this.node = document.getElementById(id);
+ this.node = document.getElementById(id);
- this.row_count = { 'total' : 0, 'fleshed' : 0 };
+ this.row_count = { 'total' : 0, 'fleshed' : 0 };
- if (!this.node) throw('Could not find element ' + id);
- switch(this.node.nodeName) {
- case 'listbox' :
- case 'tree' : break;
- case 'richlistbox' :
- throw(this.node.nodeName + ' not yet supported'); break;
- default: throw(this.node.nodeName + ' not supported'); break;
- }
+ if (!this.node) throw('Could not find element ' + id);
+ switch(this.node.nodeName) {
+ case 'listbox' :
+ case 'tree' : break;
+ case 'richlistbox' :
+ throw(this.node.nodeName + ' not yet supported'); break;
+ default: throw(this.node.nodeName + ' not supported'); break;
+ }
- JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.error'); this.error = new util.error();
- return this;
+ return this;
};
util.list.prototype = {
- 'init' : function (params) {
-
- var obj = this;
-
- JSAN.use('util.widgets');
-
- if (typeof params.map_row_to_column == 'function') obj.map_row_to_column = params.map_row_to_column;
- if (typeof params.map_row_to_columns == 'function') obj.map_row_to_columns = params.map_row_to_columns;
- if (typeof params.retrieve_row == 'function') obj.retrieve_row = params.retrieve_row;
-
- obj.prebuilt = false;
- if (typeof params.prebuilt != 'undefined') obj.prebuilt = params.prebuilt;
-
- if (typeof params.columns == 'undefined') throw('util.list.init: No columns');
- obj.columns = params.columns;
-
- switch(obj.node.nodeName) {
- case 'tree' : obj._init_tree(params); break;
- case 'listbox' : obj._init_listbox(params); break;
- default: throw('NYI: Need ._init() for ' + obj.node.nodeName); break;
- }
- },
-
- '_init_tree' : function (params) {
- var obj = this;
- if (this.prebuilt) {
-
- this.treechildren = this.node.lastChild;
-
- } else {
- var treecols = document.createElement('treecols');
- this.node.appendChild(treecols);
- this.treecols = treecols;
-
- for (var i = 0; i < this.columns.length; i++) {
- var treecol = document.createElement('treecol');
- for (var j in this.columns[i]) {
- treecol.setAttribute(j,this.columns[i][j]);
- }
- treecols.appendChild(treecol);
+ 'init' : function (params) {
+
+ var obj = this;
+
+ JSAN.use('util.widgets');
+
+ if (typeof params.map_row_to_column == 'function') obj.map_row_to_column = params.map_row_to_column;
+ if (typeof params.map_row_to_columns == 'function') obj.map_row_to_columns = params.map_row_to_columns;
+ if (typeof params.retrieve_row == 'function') obj.retrieve_row = params.retrieve_row;
+
+ obj.prebuilt = false;
+ if (typeof params.prebuilt != 'undefined') obj.prebuilt = params.prebuilt;
+
+ if (typeof params.columns == 'undefined') throw('util.list.init: No columns');
+ obj.columns = params.columns;
+
+ switch(obj.node.nodeName) {
+ case 'tree' : obj._init_tree(params); break;
+ case 'listbox' : obj._init_listbox(params); break;
+ default: throw('NYI: Need ._init() for ' + obj.node.nodeName); break;
+ }
+ },
+
+ '_init_tree' : function (params) {
+ var obj = this;
+ if (this.prebuilt) {
+
+ this.treechildren = this.node.lastChild;
+
+ } else {
+ var treecols = document.createElement('treecols');
+ this.node.appendChild(treecols);
+ this.treecols = treecols;
+
+ for (var i = 0; i < this.columns.length; i++) {
+ var treecol = document.createElement('treecol');
+ for (var j in this.columns[i]) {
+ treecol.setAttribute(j,this.columns[i][j]);
+ }
+ treecols.appendChild(treecol);
if (this.columns[i].type == 'checkbox') {
treecol.addEventListener(
'click',
false
);
}
- var splitter = document.createElement('splitter');
- splitter.setAttribute('class','tree-splitter');
- treecols.appendChild(splitter);
- }
-
- var treechildren = document.createElement('treechildren');
- this.node.appendChild(treechildren);
- this.treechildren = treechildren;
- }
+ var splitter = document.createElement('splitter');
+ splitter.setAttribute('class','tree-splitter');
+ treecols.appendChild(splitter);
+ }
+
+ var treechildren = document.createElement('treechildren');
+ this.node.appendChild(treechildren);
+ this.treechildren = treechildren;
+ }
if (typeof params.on_sort == 'function') {
this.on_sort = params.on_sort;
}
},
false
);
- if (typeof params.on_click == 'function') {
- this.node.addEventListener(
- 'click',
- params.on_click,
- false
- );
- }
- /*
- this.node.addEventListener(
- 'mousemove',
- function(ev) { obj.detect_visible(); },
- false
- );
- */
- this.node.addEventListener(
- 'keypress',
- function(ev) { obj.auto_retrieve(); },
- false
- );
- this.node.addEventListener(
- 'click',
- function(ev) { obj.auto_retrieve(); },
- false
- );
- window.addEventListener(
- 'resize',
- function(ev) { obj.auto_retrieve(); },
- false
- );
- /* FIXME -- find events on scrollbar to trigger this */
- obj.detect_visible_polling();
- /*
- var scrollbar = document.getAnonymousNodes( document.getAnonymousNodes(this.node)[1] )[1];
- var slider = document.getAnonymousNodes( scrollbar )[2];
- alert('scrollbar = ' + scrollbar.nodeName + ' grippy = ' + slider.nodeName);
- scrollbar.addEventListener('click',function(){alert('sb click');},false);
- scrollbar.addEventListener('command',function(){alert('sb command');},false);
- scrollbar.addEventListener('scroll',function(){alert('sb scroll');},false);
- slider.addEventListener('click',function(){alert('slider click');},false);
- slider.addEventListener('command',function(){alert('slider command');},false);
- slider.addEventListener('scroll',function(){alert('slider scroll');},false);
- */
- this.node.addEventListener('scroll',function(){ obj.auto_retrieve(); },false);
-
- this.restores_columns(params);
- },
-
- '_init_listbox' : function (params) {
- if (this.prebuilt) {
- } else {
- var listhead = document.createElement('listhead');
- this.node.appendChild(listhead);
-
- var listcols = document.createElement('listcols');
- this.node.appendChild(listcols);
-
- for (var i = 0; i < this.columns.length; i++) {
- var listheader = document.createElement('listheader');
- listhead.appendChild(listheader);
- var listcol = document.createElement('listcol');
- listcols.appendChild(listcol);
- for (var j in this.columns[i]) {
- listheader.setAttribute(j,this.columns[i][j]);
- listcol.setAttribute(j,this.columns[i][j]);
- };
- }
- }
- },
-
- 'save_columns' : function (params) {
- var obj = this;
- switch (this.node.nodeName) {
- case 'tree' : this._save_columns_tree(params); break;
- default: throw('NYI: Need .save_columns() for ' + this.node.nodeName); break;
- }
- },
-
- '_save_columns_tree' : function (params) {
- var obj = this;
- try {
- var id = obj.node.getAttribute('id'); if (!id) {
- alert("FIXME: The columns for this list cannot be saved because the list has no id.");
- return;
- }
- var my_cols = {};
- var nl = obj.node.getElementsByTagName('treecol');
- for (var i = 0; i < nl.length; i++) {
- var col = nl[i];
- var col_id = col.getAttribute('id');
- if (!col_id) {
- alert('FIXME: A column in this list does not have an id and cannot be saved');
- continue;
- }
- var col_hidden = col.getAttribute('hidden');
- var col_width = col.getAttribute('width');
- var col_ordinal = col.getAttribute('ordinal');
- my_cols[ col_id ] = { 'hidden' : col_hidden, 'width' : col_width, 'ordinal' : col_ordinal };
- }
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('tree_columns_for_'+window.escape(id));
- file.set_object(my_cols);
- file.close();
- alert(document.getElementById('offlineStrings').getString('list.columns_saved'));
- } catch(E) {
- obj.error.standard_unexpected_error_alert('_save_columns_tree',E);
- }
- },
-
- 'restores_columns' : function (params) {
- var obj = this;
- switch (this.node.nodeName) {
- case 'tree' : this._restores_columns_tree(params); break;
- default: throw('NYI: Need .restores_columns() for ' + this.node.nodeName); break;
- }
- },
-
- '_restores_columns_tree' : function (params) {
- var obj = this;
- try {
- var id = obj.node.getAttribute('id'); if (!id) {
- alert("FIXME: The columns for this list cannot be restored because the list has no id.");
- return;
- }
-
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('tree_columns_for_'+window.escape(id));
- if (file._file.exists()) {
- var my_cols = file.get_object(); file.close();
- var nl = obj.node.getElementsByTagName('treecol');
- for (var i = 0; i < nl.length; i++) {
- var col = nl[i];
- var col_id = col.getAttribute('id');
- if (!col_id) {
- alert('FIXME: A column in this list does not have an id and cannot be saved');
- continue;
- }
- if (typeof my_cols[col_id] != 'undefined') {
- col.setAttribute('hidden',my_cols[col_id].hidden);
- col.setAttribute('width',my_cols[col_id].width);
- col.setAttribute('ordinal',my_cols[col_id].ordinal);
- } else {
- obj.error.sdump('D_ERROR','WARNING: Column ' + col_id + ' did not have a saved state.');
- }
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('_restore_columns_tree',E);
- }
- },
-
- 'clear' : function (params) {
- var obj = this;
- switch (this.node.nodeName) {
- case 'tree' : this._clear_tree(params); break;
- case 'listbox' : this._clear_listbox(params); break;
- default: throw('NYI: Need .clear() for ' + this.node.nodeName); break;
- }
- this.error.sdump('D_LIST','Clearing list ' + this.node.getAttribute('id') + '\n');
- this.row_count.total = 0;
- this.row_count.fleshed = 0;
- setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
- },
-
- '_clear_tree' : function(params) {
- var obj = this;
- if (obj.error.sdump_levels.D_LIST_DUMP_ON_CLEAR) {
- obj.error.sdump('D_LIST_DUMP_ON_CLEAR',obj.dump());
- }
- if (obj.error.sdump_levels.D_LIST_DUMP_WITH_KEYS_ON_CLEAR) {
- obj.error.sdump('D_LIST_DUMP_WITH_KEYS_ON_CLEAR',obj.dump_with_keys());
- }
- while (obj.treechildren.lastChild) obj.treechildren.removeChild( obj.treechildren.lastChild );
- },
-
- '_clear_listbox' : function(params) {
- var obj = this;
- var items = [];
- var nl = this.node.getElementsByTagName('listitem');
- for (var i = 0; i < nl.length; i++) {
- items.push( nl[i] );
- }
- for (var i = 0; i < items.length; i++) {
- this.node.removeChild(items[i]);
- }
- },
-
- 'append' : function (params) {
- var rnode;
- var obj = this;
- switch (this.node.nodeName) {
- case 'tree' : rparams = this._append_to_tree(params); break;
- case 'listbox' : rparams = this._append_to_listbox(params); break;
- default: throw('NYI: Need .append() for ' + this.node.nodeName); break;
- }
- if (rparams && params.attributes) {
- for (var i in params.attributes) {
- rparams.my_node.setAttribute(i,params.attributes[i]);
- }
- }
- this.row_count.total++;
- if (this.row_count.fleshed == this.row_count.total) {
- setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
- }
- return rparams;
- },
-
- 'refresh_row' : function (params) {
- var rnode;
- var obj = this;
- switch (this.node.nodeName) {
- case 'tree' : rparams = this._refresh_row_in_tree(params); break;
- default: throw('NYI: Need .refresh_row() for ' + this.node.nodeName); break;
- }
- if (rparams && params.attributes) {
- for (var i in params.attributes) {
- rparams.my_node.setAttribute(i,params.attributes[i]);
- }
- }
+ if (typeof params.on_click == 'function') {
+ this.node.addEventListener(
+ 'click',
+ params.on_click,
+ false
+ );
+ }
+ /*
+ this.node.addEventListener(
+ 'mousemove',
+ function(ev) { obj.detect_visible(); },
+ false
+ );
+ */
+ this.node.addEventListener(
+ 'keypress',
+ function(ev) { obj.auto_retrieve(); },
+ false
+ );
+ this.node.addEventListener(
+ 'click',
+ function(ev) { obj.auto_retrieve(); },
+ false
+ );
+ window.addEventListener(
+ 'resize',
+ function(ev) { obj.auto_retrieve(); },
+ false
+ );
+ /* FIXME -- find events on scrollbar to trigger this */
+ obj.detect_visible_polling();
+ /*
+ var scrollbar = document.getAnonymousNodes( document.getAnonymousNodes(this.node)[1] )[1];
+ var slider = document.getAnonymousNodes( scrollbar )[2];
+ alert('scrollbar = ' + scrollbar.nodeName + ' grippy = ' + slider.nodeName);
+ scrollbar.addEventListener('click',function(){alert('sb click');},false);
+ scrollbar.addEventListener('command',function(){alert('sb command');},false);
+ scrollbar.addEventListener('scroll',function(){alert('sb scroll');},false);
+ slider.addEventListener('click',function(){alert('slider click');},false);
+ slider.addEventListener('command',function(){alert('slider command');},false);
+ slider.addEventListener('scroll',function(){alert('slider scroll');},false);
+ */
+ this.node.addEventListener('scroll',function(){ obj.auto_retrieve(); },false);
+
+ this.restores_columns(params);
+ },
+
+ '_init_listbox' : function (params) {
+ if (this.prebuilt) {
+ } else {
+ var listhead = document.createElement('listhead');
+ this.node.appendChild(listhead);
+
+ var listcols = document.createElement('listcols');
+ this.node.appendChild(listcols);
+
+ for (var i = 0; i < this.columns.length; i++) {
+ var listheader = document.createElement('listheader');
+ listhead.appendChild(listheader);
+ var listcol = document.createElement('listcol');
+ listcols.appendChild(listcol);
+ for (var j in this.columns[i]) {
+ listheader.setAttribute(j,this.columns[i][j]);
+ listcol.setAttribute(j,this.columns[i][j]);
+ };
+ }
+ }
+ },
+
+ 'save_columns' : function (params) {
+ var obj = this;
+ switch (this.node.nodeName) {
+ case 'tree' : this._save_columns_tree(params); break;
+ default: throw('NYI: Need .save_columns() for ' + this.node.nodeName); break;
+ }
+ },
+
+ '_save_columns_tree' : function (params) {
+ var obj = this;
+ try {
+ var id = obj.node.getAttribute('id'); if (!id) {
+ alert("FIXME: The columns for this list cannot be saved because the list has no id.");
+ return;
+ }
+ var my_cols = {};
+ var nl = obj.node.getElementsByTagName('treecol');
+ for (var i = 0; i < nl.length; i++) {
+ var col = nl[i];
+ var col_id = col.getAttribute('id');
+ if (!col_id) {
+ alert('FIXME: A column in this list does not have an id and cannot be saved');
+ continue;
+ }
+ var col_hidden = col.getAttribute('hidden');
+ var col_width = col.getAttribute('width');
+ var col_ordinal = col.getAttribute('ordinal');
+ my_cols[ col_id ] = { 'hidden' : col_hidden, 'width' : col_width, 'ordinal' : col_ordinal };
+ }
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('tree_columns_for_'+window.escape(id));
+ file.set_object(my_cols);
+ file.close();
+ alert(document.getElementById('offlineStrings').getString('list.columns_saved'));
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('_save_columns_tree',E);
+ }
+ },
+
+ 'restores_columns' : function (params) {
+ var obj = this;
+ switch (this.node.nodeName) {
+ case 'tree' : this._restores_columns_tree(params); break;
+ default: throw('NYI: Need .restores_columns() for ' + this.node.nodeName); break;
+ }
+ },
+
+ '_restores_columns_tree' : function (params) {
+ var obj = this;
+ try {
+ var id = obj.node.getAttribute('id'); if (!id) {
+ alert("FIXME: The columns for this list cannot be restored because the list has no id.");
+ return;
+ }
+
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('tree_columns_for_'+window.escape(id));
+ if (file._file.exists()) {
+ var my_cols = file.get_object(); file.close();
+ var nl = obj.node.getElementsByTagName('treecol');
+ for (var i = 0; i < nl.length; i++) {
+ var col = nl[i];
+ var col_id = col.getAttribute('id');
+ if (!col_id) {
+ alert('FIXME: A column in this list does not have an id and cannot be saved');
+ continue;
+ }
+ if (typeof my_cols[col_id] != 'undefined') {
+ col.setAttribute('hidden',my_cols[col_id].hidden);
+ col.setAttribute('width',my_cols[col_id].width);
+ col.setAttribute('ordinal',my_cols[col_id].ordinal);
+ } else {
+ obj.error.sdump('D_ERROR','WARNING: Column ' + col_id + ' did not have a saved state.');
+ }
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('_restore_columns_tree',E);
+ }
+ },
+
+ 'clear' : function (params) {
+ var obj = this;
+ switch (this.node.nodeName) {
+ case 'tree' : this._clear_tree(params); break;
+ case 'listbox' : this._clear_listbox(params); break;
+ default: throw('NYI: Need .clear() for ' + this.node.nodeName); break;
+ }
+ this.error.sdump('D_LIST','Clearing list ' + this.node.getAttribute('id') + '\n');
+ this.row_count.total = 0;
+ this.row_count.fleshed = 0;
+ setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
+ },
+
+ '_clear_tree' : function(params) {
+ var obj = this;
+ if (obj.error.sdump_levels.D_LIST_DUMP_ON_CLEAR) {
+ obj.error.sdump('D_LIST_DUMP_ON_CLEAR',obj.dump());
+ }
+ if (obj.error.sdump_levels.D_LIST_DUMP_WITH_KEYS_ON_CLEAR) {
+ obj.error.sdump('D_LIST_DUMP_WITH_KEYS_ON_CLEAR',obj.dump_with_keys());
+ }
+ while (obj.treechildren.lastChild) obj.treechildren.removeChild( obj.treechildren.lastChild );
+ },
+
+ '_clear_listbox' : function(params) {
+ var obj = this;
+ var items = [];
+ var nl = this.node.getElementsByTagName('listitem');
+ for (var i = 0; i < nl.length; i++) {
+ items.push( nl[i] );
+ }
+ for (var i = 0; i < items.length; i++) {
+ this.node.removeChild(items[i]);
+ }
+ },
+
+ 'append' : function (params) {
+ var rnode;
+ var obj = this;
+ switch (this.node.nodeName) {
+ case 'tree' : rparams = this._append_to_tree(params); break;
+ case 'listbox' : rparams = this._append_to_listbox(params); break;
+ default: throw('NYI: Need .append() for ' + this.node.nodeName); break;
+ }
+ if (rparams && params.attributes) {
+ for (var i in params.attributes) {
+ rparams.my_node.setAttribute(i,params.attributes[i]);
+ }
+ }
+ this.row_count.total++;
+ if (this.row_count.fleshed == this.row_count.total) {
+ setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
+ }
+ return rparams;
+ },
+
+ 'refresh_row' : function (params) {
+ var rnode;
+ var obj = this;
+ switch (this.node.nodeName) {
+ case 'tree' : rparams = this._refresh_row_in_tree(params); break;
+ default: throw('NYI: Need .refresh_row() for ' + this.node.nodeName); break;
+ }
+ if (rparams && params.attributes) {
+ for (var i in params.attributes) {
+ rparams.my_node.setAttribute(i,params.attributes[i]);
+ }
+ }
this.row_count.fleshed--;
- return rparams;
- },
-
-
- '_append_to_tree' : function (params) {
-
- var obj = this;
-
- if (typeof params.row == 'undefined') throw('util.list.append: Object must contain a row');
-
- var s = ('util.list.append: params = ' + (params) + '\n');
-
- var treechildren_node = this.treechildren;
-
- if (params.node && params.node.nodeName == 'treeitem') {
- params.node.setAttribute('container','true'); /* params.node.setAttribute('open','true'); */
- if (params.node.lastChild.nodeName == 'treechildren') {
- treechildren_node = params.node.lastChild;
- } else {
- treechildren_node = document.createElement('treechildren');
- params.node.appendChild(treechildren_node);
- }
- }
-
- var treeitem = document.createElement('treeitem');
- treeitem.setAttribute('retrieve_id',params.retrieve_id);
- if (typeof params.to_bottom != 'undefined') {
- treechildren_node.appendChild( treeitem );
- if (typeof params.no_auto_select == 'undefined') {
- if (!obj.auto_select_pending) {
- obj.auto_select_pending = true;
- setTimeout(function() {
- dump('auto-selecting\n');
- var idx = Number(obj.node.view.rowCount)-1;
- try { obj.node.view.selection.select(idx); } catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
- try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
- obj.auto_select_pending = false;
- try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(idx).firstChild); } catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
- }, 1000);
- }
- }
- } else {
- if (treechildren_node.firstChild) {
- treechildren_node.insertBefore( treeitem, treechildren_node.firstChild );
- } else {
- treechildren_node.appendChild( treeitem );
- }
- if (typeof params.no_auto_select == 'undefined') {
- if (!obj.auto_select_pending) {
- obj.auto_select_pending = true;
- setTimeout(function() {
- try { obj.node.view.selection.select(0); } catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
- try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
- obj.auto_select_pending = false;
- try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(0).firstChild); } catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
- }, 1000);
- }
- }
- }
- var treerow = document.createElement('treerow');
- treeitem.appendChild( treerow );
- treerow.setAttribute('retrieve_id',params.retrieve_id);
+ return rparams;
+ },
+
+
+ '_append_to_tree' : function (params) {
+
+ var obj = this;
+
+ if (typeof params.row == 'undefined') throw('util.list.append: Object must contain a row');
+
+ var s = ('util.list.append: params = ' + (params) + '\n');
+
+ var treechildren_node = this.treechildren;
+
+ if (params.node && params.node.nodeName == 'treeitem') {
+ params.node.setAttribute('container','true'); /* params.node.setAttribute('open','true'); */
+ if (params.node.lastChild.nodeName == 'treechildren') {
+ treechildren_node = params.node.lastChild;
+ } else {
+ treechildren_node = document.createElement('treechildren');
+ params.node.appendChild(treechildren_node);
+ }
+ }
+
+ var treeitem = document.createElement('treeitem');
+ treeitem.setAttribute('retrieve_id',params.retrieve_id);
+ if (typeof params.to_bottom != 'undefined') {
+ treechildren_node.appendChild( treeitem );
+ if (typeof params.no_auto_select == 'undefined') {
+ if (!obj.auto_select_pending) {
+ obj.auto_select_pending = true;
+ setTimeout(function() {
+ dump('auto-selecting\n');
+ var idx = Number(obj.node.view.rowCount)-1;
+ try { obj.node.view.selection.select(idx); } catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
+ try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
+ obj.auto_select_pending = false;
+ try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(idx).firstChild); } catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
+ }, 1000);
+ }
+ }
+ } else {
+ if (treechildren_node.firstChild) {
+ treechildren_node.insertBefore( treeitem, treechildren_node.firstChild );
+ } else {
+ treechildren_node.appendChild( treeitem );
+ }
+ if (typeof params.no_auto_select == 'undefined') {
+ if (!obj.auto_select_pending) {
+ obj.auto_select_pending = true;
+ setTimeout(function() {
+ try { obj.node.view.selection.select(0); } catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
+ try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
+ obj.auto_select_pending = false;
+ try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(0).firstChild); } catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
+ }, 1000);
+ }
+ }
+ }
+ var treerow = document.createElement('treerow');
+ treeitem.appendChild( treerow );
+ treerow.setAttribute('retrieve_id',params.retrieve_id);
if (params.row_properties) treerow.setAttribute('properties',params.row_properties);
- s += ('tree = ' + this.node + ' treechildren = ' + treechildren_node + '\n');
- s += ('treeitem = ' + treeitem + ' treerow = ' + treerow + '\n');
-
- if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
-
- obj.put_retrieving_label(treerow);
- treerow.addEventListener(
- 'flesh',
- function() {
-
- if (treerow.getAttribute('retrieved') == 'true') return; /* already running */
-
- treerow.setAttribute('retrieved','true');
-
- //dump('fleshing = ' + params.retrieve_id + '\n');
-
- function inc_fleshed() {
- if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
- treerow.setAttribute('fleshed','true');
- obj.row_count.fleshed++;
- if (obj.row_count.fleshed >= obj.row_count.total) {
- setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
- }
- }
-
- params.row_node = treeitem;
- params.on_retrieve = function(p) {
- try {
- p.row = params.row;
- obj._map_row_to_treecell(p,treerow);
- inc_fleshed();
- var idx = obj.node.contentView.getIndexOfItem( params.row_node );
- dump('idx = ' + idx + '\n');
- // if current row is selected, send another select event to re-sync data that the client code fetches on selects
- if ( obj.node.view.selection.isSelected( idx ) ) {
- dump('dispatching select event for on_retrieve for idx = ' + idx + '\n');
- util.widgets.dispatch('select',obj.node);
- }
- } catch(E) {
+ s += ('tree = ' + this.node + ' treechildren = ' + treechildren_node + '\n');
+ s += ('treeitem = ' + treeitem + ' treerow = ' + treerow + '\n');
+
+ if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
+
+ obj.put_retrieving_label(treerow);
+ treerow.addEventListener(
+ 'flesh',
+ function() {
+
+ if (treerow.getAttribute('retrieved') == 'true') return; /* already running */
+
+ treerow.setAttribute('retrieved','true');
+
+ //dump('fleshing = ' + params.retrieve_id + '\n');
+
+ function inc_fleshed() {
+ if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
+ treerow.setAttribute('fleshed','true');
+ obj.row_count.fleshed++;
+ if (obj.row_count.fleshed >= obj.row_count.total) {
+ setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
+ }
+ }
+
+ params.row_node = treeitem;
+ params.on_retrieve = function(p) {
+ try {
+ p.row = params.row;
+ obj._map_row_to_treecell(p,treerow);
+ inc_fleshed();
+ var idx = obj.node.contentView.getIndexOfItem( params.row_node );
+ dump('idx = ' + idx + '\n');
+ // if current row is selected, send another select event to re-sync data that the client code fetches on selects
+ if ( obj.node.view.selection.isSelected( idx ) ) {
+ dump('dispatching select event for on_retrieve for idx = ' + idx + '\n');
+ util.widgets.dispatch('select',obj.node);
+ }
+ } catch(E) {
// Let's not alert on this for now. Getting contentView has no properties in record buckets under certain conditions
- dump('fixme2: ' + E + '\n');
- }
- }
-
- if (typeof params.retrieve_row == 'function') {
-
- params.retrieve_row( params );
-
- } else if (typeof obj.retrieve_row == 'function') {
-
- obj.retrieve_row( params );
-
- } else {
-
- inc_fleshed();
- }
- },
- false
- );
- /*
- setTimeout(
- function() {
- util.widgets.dispatch('flesh',treerow);
- }, 0
- );
- */
- } else {
- obj.put_retrieving_label(treerow);
- treerow.addEventListener(
- 'flesh',
- function() {
- //dump('fleshing anon\n');
- if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
- obj._map_row_to_treecell(params,treerow);
- treerow.setAttribute('retrieved','true');
- treerow.setAttribute('fleshed','true');
- obj.row_count.fleshed++;
- if (obj.row_count.fleshed >= obj.row_count.total) {
- setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
- }
- },
- false
- );
- /*
- setTimeout(
- function() {
- util.widgets.dispatch('flesh',treerow);
- }, 0
- );
- */
- }
- this.error.sdump('D_LIST',s);
-
- try {
-
- if (obj.trim_list && obj.row_count.total >= obj.trim_list) {
- // Remove oldest row
- //if (typeof params.to_bottom != 'undefined')
- if (typeof params.to_top == 'undefined') {
- treechildren_node.removeChild( treechildren_node.firstChild );
- } else {
- treechildren_node.removeChild( treechildren_node.lastChild );
- }
- }
- } catch(E) {
- }
-
- setTimeout( function() { obj.auto_retrieve(); }, 0 );
-
- params.my_node = treeitem;
- return params;
- },
-
- '_refresh_row_in_tree' : function (params) {
-
- var obj = this;
-
- if (typeof params.row == 'undefined') throw('util.list.refresh_row: Object must contain a row');
- if (typeof params.my_node == 'undefined') throw('util.list.refresh_row: Object must contain a my_node');
- if (params.my_node.nodeName != 'treeitem') throw('util.list.refresh_rwo: my_node must be a treeitem');
-
- var s = ('util.list.refresh_row: params = ' + (params) + '\n');
-
- var treeitem = params.my_node;
- treeitem.setAttribute('retrieve_id',params.retrieve_id);
- if (typeof params.to_bottom != 'undefined') {
- if (typeof params.no_auto_select == 'undefined') {
- if (!obj.auto_select_pending) {
- obj.auto_select_pending = true;
- setTimeout(function() {
- dump('auto-selecting\n');
- var idx = Number(obj.node.view.rowCount)-1;
- try { obj.node.view.selection.select(idx); } catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
- try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
- obj.auto_select_pending = false;
- try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(idx).firstChild); } catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
- }, 1000);
- }
- }
- }
- var delete_me = [];
- for (var i in treeitem.childNodes) if (treeitem.childNodes[i].nodeName == 'treerow') delete_me.push(treeitem.childNodes[i]);
- for (var i = 0; i < delete_me.length; i++) treeitem.removeChild(delete_me[i]);
- var treerow = document.createElement('treerow');
- treeitem.appendChild( treerow );
- treerow.setAttribute('retrieve_id',params.retrieve_id);
-
- s += ('tree = ' + this.node + '\n');
- s += ('treeitem = ' + treeitem + ' treerow = ' + treerow + '\n');
-
- if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
-
- obj.put_retrieving_label(treerow);
- treerow.addEventListener(
- 'flesh',
- function() {
-
- if (treerow.getAttribute('retrieved') == 'true') return; /* already running */
-
- treerow.setAttribute('retrieved','true');
-
- //dump('fleshing = ' + params.retrieve_id + '\n');
-
- function inc_fleshed() {
- if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
- treerow.setAttribute('fleshed','true');
- obj.row_count.fleshed++;
- if (obj.row_count.fleshed >= obj.row_count.total) {
- setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
- }
- }
-
- params.row_node = treeitem;
- params.on_retrieve = function(p) {
- try {
- p.row = params.row;
- obj._map_row_to_treecell(p,treerow);
- inc_fleshed();
- var idx = obj.node.contentView.getIndexOfItem( params.row_node );
- dump('idx = ' + idx + '\n');
- // if current row is selected, send another select event to re-sync data that the client code fetches on selects
- if ( obj.node.view.selection.isSelected( idx ) ) {
- dump('dispatching select event for on_retrieve for idx = ' + idx + '\n');
- util.widgets.dispatch('select',obj.node);
- }
- } catch(E) {
+ dump('fixme2: ' + E + '\n');
+ }
+ }
+
+ if (typeof params.retrieve_row == 'function') {
+
+ params.retrieve_row( params );
+
+ } else if (typeof obj.retrieve_row == 'function') {
+
+ obj.retrieve_row( params );
+
+ } else {
+
+ inc_fleshed();
+ }
+ },
+ false
+ );
+ /*
+ setTimeout(
+ function() {
+ util.widgets.dispatch('flesh',treerow);
+ }, 0
+ );
+ */
+ } else {
+ obj.put_retrieving_label(treerow);
+ treerow.addEventListener(
+ 'flesh',
+ function() {
+ //dump('fleshing anon\n');
+ if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
+ obj._map_row_to_treecell(params,treerow);
+ treerow.setAttribute('retrieved','true');
+ treerow.setAttribute('fleshed','true');
+ obj.row_count.fleshed++;
+ if (obj.row_count.fleshed >= obj.row_count.total) {
+ setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
+ }
+ },
+ false
+ );
+ /*
+ setTimeout(
+ function() {
+ util.widgets.dispatch('flesh',treerow);
+ }, 0
+ );
+ */
+ }
+ this.error.sdump('D_LIST',s);
+
+ try {
+
+ if (obj.trim_list && obj.row_count.total >= obj.trim_list) {
+ // Remove oldest row
+ //if (typeof params.to_bottom != 'undefined')
+ if (typeof params.to_top == 'undefined') {
+ treechildren_node.removeChild( treechildren_node.firstChild );
+ } else {
+ treechildren_node.removeChild( treechildren_node.lastChild );
+ }
+ }
+ } catch(E) {
+ }
+
+ setTimeout( function() { obj.auto_retrieve(); }, 0 );
+
+ params.my_node = treeitem;
+ return params;
+ },
+
+ '_refresh_row_in_tree' : function (params) {
+
+ var obj = this;
+
+ if (typeof params.row == 'undefined') throw('util.list.refresh_row: Object must contain a row');
+ if (typeof params.my_node == 'undefined') throw('util.list.refresh_row: Object must contain a my_node');
+ if (params.my_node.nodeName != 'treeitem') throw('util.list.refresh_rwo: my_node must be a treeitem');
+
+ var s = ('util.list.refresh_row: params = ' + (params) + '\n');
+
+ var treeitem = params.my_node;
+ treeitem.setAttribute('retrieve_id',params.retrieve_id);
+ if (typeof params.to_bottom != 'undefined') {
+ if (typeof params.no_auto_select == 'undefined') {
+ if (!obj.auto_select_pending) {
+ obj.auto_select_pending = true;
+ setTimeout(function() {
+ dump('auto-selecting\n');
+ var idx = Number(obj.node.view.rowCount)-1;
+ try { obj.node.view.selection.select(idx); } catch(E) { obj.error.sdump('D_WARN','tree auto select: ' + E + '\n'); }
+ try { if (typeof params.on_select == 'function') params.on_select(); } catch(E) { obj.error.sdump('D_WARN','tree auto select, on_select: ' + E + '\n'); }
+ obj.auto_select_pending = false;
+ try { util.widgets.dispatch('flesh',obj.node.contentView.getItemAtIndex(idx).firstChild); } catch(E) { obj.error.sdump('D_WARN','tree auto select, flesh: ' + E + '\n'); }
+ }, 1000);
+ }
+ }
+ }
+ var delete_me = [];
+ for (var i in treeitem.childNodes) if (treeitem.childNodes[i].nodeName == 'treerow') delete_me.push(treeitem.childNodes[i]);
+ for (var i = 0; i < delete_me.length; i++) treeitem.removeChild(delete_me[i]);
+ var treerow = document.createElement('treerow');
+ treeitem.appendChild( treerow );
+ treerow.setAttribute('retrieve_id',params.retrieve_id);
+
+ s += ('tree = ' + this.node + '\n');
+ s += ('treeitem = ' + treeitem + ' treerow = ' + treerow + '\n');
+
+ if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
+
+ obj.put_retrieving_label(treerow);
+ treerow.addEventListener(
+ 'flesh',
+ function() {
+
+ if (treerow.getAttribute('retrieved') == 'true') return; /* already running */
+
+ treerow.setAttribute('retrieved','true');
+
+ //dump('fleshing = ' + params.retrieve_id + '\n');
+
+ function inc_fleshed() {
+ if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
+ treerow.setAttribute('fleshed','true');
+ obj.row_count.fleshed++;
+ if (obj.row_count.fleshed >= obj.row_count.total) {
+ setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
+ }
+ }
+
+ params.row_node = treeitem;
+ params.on_retrieve = function(p) {
+ try {
+ p.row = params.row;
+ obj._map_row_to_treecell(p,treerow);
+ inc_fleshed();
+ var idx = obj.node.contentView.getIndexOfItem( params.row_node );
+ dump('idx = ' + idx + '\n');
+ // if current row is selected, send another select event to re-sync data that the client code fetches on selects
+ if ( obj.node.view.selection.isSelected( idx ) ) {
+ dump('dispatching select event for on_retrieve for idx = ' + idx + '\n');
+ util.widgets.dispatch('select',obj.node);
+ }
+ } catch(E) {
// Let's not alert on this for now. Getting contentView has no properties in record buckets under certain conditions
- dump('fixme2: ' + E + '\n');
- }
- }
-
- if (typeof params.retrieve_row == 'function') {
-
- params.retrieve_row( params );
-
- } else if (typeof obj.retrieve_row == 'function') {
-
- obj.retrieve_row( params );
-
- } else {
-
- inc_fleshed();
- }
- },
- false
- );
- /*
- setTimeout(
- function() {
- util.widgets.dispatch('flesh',treerow);
- }, 0
- );
- */
- } else {
- obj.put_retrieving_label(treerow);
- treerow.addEventListener(
- 'flesh',
- function() {
- //dump('fleshing anon\n');
- if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
- obj._map_row_to_treecell(params,treerow);
- treerow.setAttribute('retrieved','true');
- treerow.setAttribute('fleshed','true');
- obj.row_count.fleshed++;
- if (obj.row_count.fleshed >= obj.row_count.total) {
- setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
- }
- },
- false
- );
- /*
- setTimeout(
- function() {
- util.widgets.dispatch('flesh',treerow);
- }, 0
- );
- */
- }
- this.error.sdump('D_LIST',s);
-
- try {
-
- if (obj.trim_list && obj.row_count.total >= obj.trim_list) {
- // Remove oldest row
- //if (typeof params.to_bottom != 'undefined')
- if (typeof params.to_top == 'undefined') {
- treechildren_node.removeChild( treechildren_node.firstChild );
- } else {
- treechildren_node.removeChild( treechildren_node.lastChild );
- }
- }
- } catch(E) {
- }
-
- setTimeout( function() { obj.auto_retrieve(); }, 0 );
+ dump('fixme2: ' + E + '\n');
+ }
+ }
+
+ if (typeof params.retrieve_row == 'function') {
+
+ params.retrieve_row( params );
+
+ } else if (typeof obj.retrieve_row == 'function') {
+
+ obj.retrieve_row( params );
+
+ } else {
+
+ inc_fleshed();
+ }
+ },
+ false
+ );
+ /*
+ setTimeout(
+ function() {
+ util.widgets.dispatch('flesh',treerow);
+ }, 0
+ );
+ */
+ } else {
+ obj.put_retrieving_label(treerow);
+ treerow.addEventListener(
+ 'flesh',
+ function() {
+ //dump('fleshing anon\n');
+ if (treerow.getAttribute('fleshed') == 'true') return; /* already fleshed */
+ obj._map_row_to_treecell(params,treerow);
+ treerow.setAttribute('retrieved','true');
+ treerow.setAttribute('fleshed','true');
+ obj.row_count.fleshed++;
+ if (obj.row_count.fleshed >= obj.row_count.total) {
+ setTimeout( function() { obj.exec_on_all_fleshed(); }, 0 );
+ }
+ },
+ false
+ );
+ /*
+ setTimeout(
+ function() {
+ util.widgets.dispatch('flesh',treerow);
+ }, 0
+ );
+ */
+ }
+ this.error.sdump('D_LIST',s);
+
+ try {
+
+ if (obj.trim_list && obj.row_count.total >= obj.trim_list) {
+ // Remove oldest row
+ //if (typeof params.to_bottom != 'undefined')
+ if (typeof params.to_top == 'undefined') {
+ treechildren_node.removeChild( treechildren_node.firstChild );
+ } else {
+ treechildren_node.removeChild( treechildren_node.lastChild );
+ }
+ }
+ } catch(E) {
+ }
+
+ setTimeout( function() { obj.auto_retrieve(); }, 0 );
JSAN.use('util.widgets'); util.widgets.dispatch('select',obj.node);
- return params;
- },
-
- 'put_retrieving_label' : function(treerow) {
- var obj = this;
- try {
- /*
- var cols_idx = 0;
- dump('put_retrieving_label. columns = ' + js2JSON(obj.columns) + '\n');
- while( obj.columns[cols_idx] && obj.columns[cols_idx].hidden && obj.columns[cols_idx].hidden == 'true') {
- dump('\t' + cols_idx);
- var treecell = document.createElement('treecell');
- treerow.appendChild(treecell);
- cols_idx++;
- }
- */
- for (var i = 0; i < obj.columns.length; i++) {
- var treecell = document.createElement('treecell'); treecell.setAttribute('label',document.getElementById('offlineStrings').getString('list.row_retrieving'));
- treerow.appendChild(treecell);
- }
- /*
- dump('\t' + cols_idx + '\n');
- */
- } catch(E) {
- alert(E);
- }
- },
-
- 'detect_visible' : function() {
- var obj = this;
- try {
- //dump('detect_visible obj.node = ' + obj.node + '\n');
- /* FIXME - this is a hack.. if the implementation of tree changes, this could break */
- try {
+ return params;
+ },
+
+ 'put_retrieving_label' : function(treerow) {
+ var obj = this;
+ try {
+ /*
+ var cols_idx = 0;
+ dump('put_retrieving_label. columns = ' + js2JSON(obj.columns) + '\n');
+ while( obj.columns[cols_idx] && obj.columns[cols_idx].hidden && obj.columns[cols_idx].hidden == 'true') {
+ dump('\t' + cols_idx);
+ var treecell = document.createElement('treecell');
+ treerow.appendChild(treecell);
+ cols_idx++;
+ }
+ */
+ for (var i = 0; i < obj.columns.length; i++) {
+ var treecell = document.createElement('treecell'); treecell.setAttribute('label',document.getElementById('offlineStrings').getString('list.row_retrieving'));
+ treerow.appendChild(treecell);
+ }
+ /*
+ dump('\t' + cols_idx + '\n');
+ */
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+ 'detect_visible' : function() {
+ var obj = this;
+ try {
+ //dump('detect_visible obj.node = ' + obj.node + '\n');
+ /* FIXME - this is a hack.. if the implementation of tree changes, this could break */
+ try {
/*var s = ''; var A = document.getAnonymousNodes(obj.node);
for (var i in A) {
var B = A[i];
}
}
obj.error.sdump('D_XULRUNNER','document.getAnonymousNodes(' + obj.node.nodeName + ') = \n' + s + '\n');*/
- var scrollbar = document.getAnonymousNodes(obj.node)[2].firstChild;
- var curpos = scrollbar.getAttribute('curpos');
- var maxpos = scrollbar.getAttribute('maxpos');
- //alert('curpos = ' + curpos + ' maxpos = ' + maxpos + ' obj.curpos = ' + obj.curpos + ' obj.maxpos = ' + obj.maxpos + '\n');
- if ((curpos != obj.curpos) || (maxpos != obj.maxpos)) {
- if ( obj.auto_retrieve() > 0 ) {
- obj.curpos = curpos; obj.maxpos = maxpos;
- }
- }
- } catch(E) {
- obj.error.sdump('D_XULRUNNER', 'List implementation changed? ' + E);
- }
- } catch(E) { obj.error.sdump('D_ERROR',E); }
- },
-
- 'detect_visible_polling' : function() {
- try {
- //alert('detect_visible_polling');
- var obj = this;
- obj.detect_visible();
- setTimeout(function() { try { obj.detect_visible_polling(); } catch(E) { alert(E); } },2000);
- } catch(E) {
- alert(E);
- }
- },
-
-
- 'auto_retrieve' : function(params) {
- var obj = this;
- switch (this.node.nodeName) {
- case 'tree' : obj._auto_retrieve_tree(params); break;
- default: throw('NYI: Need .auto_retrieve() for ' + obj.node.nodeName); break;
- }
- },
-
- '_auto_retrieve_tree' : function (params) {
- var obj = this;
- if (!obj.auto_retrieve_in_progress) {
- obj.auto_retrieve_in_progress = true;
- setTimeout(
- function() {
- try {
- //alert('auto_retrieve\n');
- var count = 0;
- var startpos = obj.node.treeBoxObject.getFirstVisibleRow();
- var endpos = obj.node.treeBoxObject.getLastVisibleRow();
- if (startpos > endpos) endpos = obj.node.treeBoxObject.getPageLength();
- //dump('startpos = ' + startpos + ' endpos = ' + endpos + '\n');
- for (var i = startpos; i < endpos + 4; i++) {
- try {
- //dump('trying index ' + i + '\n');
- var item = obj.node.contentView.getItemAtIndex(i).firstChild;
- if (item && item.getAttribute('retrieved') != 'true' ) {
- //dump('\tgot an unfleshed item = ' + item + ' = ' + item.nodeName + '\n');
- util.widgets.dispatch('flesh',item); count++;
- }
- } catch(E) {
- //dump(i + ' : ' + E + '\n');
- }
- }
- obj.auto_retrieve_in_progress = false;
- return count;
- } catch(E) { alert(E); }
- }, 1
- );
- }
- },
+ var scrollbar = document.getAnonymousNodes(obj.node)[2].firstChild;
+ var curpos = scrollbar.getAttribute('curpos');
+ var maxpos = scrollbar.getAttribute('maxpos');
+ //alert('curpos = ' + curpos + ' maxpos = ' + maxpos + ' obj.curpos = ' + obj.curpos + ' obj.maxpos = ' + obj.maxpos + '\n');
+ if ((curpos != obj.curpos) || (maxpos != obj.maxpos)) {
+ if ( obj.auto_retrieve() > 0 ) {
+ obj.curpos = curpos; obj.maxpos = maxpos;
+ }
+ }
+ } catch(E) {
+ obj.error.sdump('D_XULRUNNER', 'List implementation changed? ' + E);
+ }
+ } catch(E) { obj.error.sdump('D_ERROR',E); }
+ },
+
+ 'detect_visible_polling' : function() {
+ try {
+ //alert('detect_visible_polling');
+ var obj = this;
+ obj.detect_visible();
+ setTimeout(function() { try { obj.detect_visible_polling(); } catch(E) { alert(E); } },2000);
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+
+ 'auto_retrieve' : function(params) {
+ var obj = this;
+ switch (this.node.nodeName) {
+ case 'tree' : obj._auto_retrieve_tree(params); break;
+ default: throw('NYI: Need .auto_retrieve() for ' + obj.node.nodeName); break;
+ }
+ },
+
+ '_auto_retrieve_tree' : function (params) {
+ var obj = this;
+ if (!obj.auto_retrieve_in_progress) {
+ obj.auto_retrieve_in_progress = true;
+ setTimeout(
+ function() {
+ try {
+ //alert('auto_retrieve\n');
+ var count = 0;
+ var startpos = obj.node.treeBoxObject.getFirstVisibleRow();
+ var endpos = obj.node.treeBoxObject.getLastVisibleRow();
+ if (startpos > endpos) endpos = obj.node.treeBoxObject.getPageLength();
+ //dump('startpos = ' + startpos + ' endpos = ' + endpos + '\n');
+ for (var i = startpos; i < endpos + 4; i++) {
+ try {
+ //dump('trying index ' + i + '\n');
+ var item = obj.node.contentView.getItemAtIndex(i).firstChild;
+ if (item && item.getAttribute('retrieved') != 'true' ) {
+ //dump('\tgot an unfleshed item = ' + item + ' = ' + item.nodeName + '\n');
+ util.widgets.dispatch('flesh',item); count++;
+ }
+ } catch(E) {
+ //dump(i + ' : ' + E + '\n');
+ }
+ }
+ obj.auto_retrieve_in_progress = false;
+ return count;
+ } catch(E) { alert(E); }
+ }, 1
+ );
+ }
+ },
'exec_on_all_fleshed' : function() {
var obj = this;
try {
if (obj.on_all_fleshed) {
- if (typeof obj.on_all_fleshed == 'function') {
+ if (typeof obj.on_all_fleshed == 'function') {
dump('exec_on_all_fleshed == function\n');
- setTimeout(
+ setTimeout(
function() {
try { obj.on_all_fleshed(); } catch(E) { obj.error.standard_unexpected_error_alert('_full_retrieve_tree callback',obj.on_all_fleshed); }
}, 0
);
- } else if (typeof obj.on_all_fleshed.length != 'undefined') {
+ } else if (typeof obj.on_all_fleshed.length != 'undefined') {
dump('exec_on_all_fleshed == array\n');
setTimeout(
function() {
}
}, 0
);
- } else {
+ } else {
obj.error.standard_unexpected_error_alert('unexpected on_all_fleshed object: ', obj.on_all_fleshed);
}
}
}
},
- 'full_retrieve' : function(params) {
- var obj = this;
- switch (this.node.nodeName) {
- case 'tree' : obj._full_retrieve_tree(params); break;
- default: throw('NYI: Need .full_retrieve() for ' + obj.node.nodeName); break;
- }
- },
-
- '_full_retrieve_tree' : function(params) {
- var obj = this;
- try {
- if (obj.row_count.fleshed >= obj.row_count.total) {
- dump('Full retrieve... tree seems to be in sync\n' + js2JSON(obj.row_count) + '\n');
- obj.exec_on_all_fleshed();
- } else {
- dump('Full retrieve... syncing tree' + js2JSON(obj.row_count) + '\n');
- JSAN.use('util.widgets');
- var nodes = obj.treechildren.childNodes;
- for (var i = 0; i < nodes.length; i++) {
- util.widgets.dispatch('flesh',nodes[i].firstChild);
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('_full_retrieve_tree',E);
- }
- },
+ 'full_retrieve' : function(params) {
+ var obj = this;
+ switch (this.node.nodeName) {
+ case 'tree' : obj._full_retrieve_tree(params); break;
+ default: throw('NYI: Need .full_retrieve() for ' + obj.node.nodeName); break;
+ }
+ },
- '_append_to_listbox' : function (params) {
+ '_full_retrieve_tree' : function(params) {
+ var obj = this;
+ try {
+ if (obj.row_count.fleshed >= obj.row_count.total) {
+ dump('Full retrieve... tree seems to be in sync\n' + js2JSON(obj.row_count) + '\n');
+ obj.exec_on_all_fleshed();
+ } else {
+ dump('Full retrieve... syncing tree' + js2JSON(obj.row_count) + '\n');
+ JSAN.use('util.widgets');
+ var nodes = obj.treechildren.childNodes;
+ for (var i = 0; i < nodes.length; i++) {
+ util.widgets.dispatch('flesh',nodes[i].firstChild);
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('_full_retrieve_tree',E);
+ }
+ },
- var obj = this;
+ '_append_to_listbox' : function (params) {
- if (typeof params.row == 'undefined') throw('util.list.append: Object must contain a row');
+ var obj = this;
- var s = ('util.list.append: params = ' + (params) + '\n');
+ if (typeof params.row == 'undefined') throw('util.list.append: Object must contain a row');
- var listitem = document.createElement('listitem');
+ var s = ('util.list.append: params = ' + (params) + '\n');
- s += ('listbox = ' + this.node + ' listitem = ' + listitem + '\n');
+ var listitem = document.createElement('listitem');
- if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
+ s += ('listbox = ' + this.node + ' listitem = ' + listitem + '\n');
- setTimeout(
- function() {
- listitem.setAttribute('retrieve_id',params.retrieve_id);
- //FIXME//Make async and fire when row is visible in list
- var row;
+ if (typeof params.retrieve_row == 'function' || typeof this.retrieve_row == 'function') {
- params.row_node = listitem;
- params.on_retrieve = function(row) {
- params.row = row;
- obj._map_row_to_listcell(params,listitem);
- obj.node.appendChild( listitem );
- util.widgets.dispatch('select',obj.node);
- }
+ setTimeout(
+ function() {
+ listitem.setAttribute('retrieve_id',params.retrieve_id);
+ //FIXME//Make async and fire when row is visible in list
+ var row;
+
+ params.row_node = listitem;
+ params.on_retrieve = function(row) {
+ params.row = row;
+ obj._map_row_to_listcell(params,listitem);
+ obj.node.appendChild( listitem );
+ util.widgets.dispatch('select',obj.node);
+ }
- if (typeof params.retrieve_row == 'function') {
+ if (typeof params.retrieve_row == 'function') {
- row = params.retrieve_row( params );
+ row = params.retrieve_row( params );
- } else {
+ } else {
- if (typeof obj.retrieve_row == 'function') {
+ if (typeof obj.retrieve_row == 'function') {
- row = obj.retrieve_row( params );
+ row = obj.retrieve_row( params );
- }
- }
- }, 0
- );
- } else {
- this._map_row_to_listcell(params,listitem);
- this.node.appendChild( listitem );
- }
+ }
+ }
+ }, 0
+ );
+ } else {
+ this._map_row_to_listcell(params,listitem);
+ this.node.appendChild( listitem );
+ }
- this.error.sdump('D_LIST',s);
- params.my_node = listitem;
- return params;
+ this.error.sdump('D_LIST',s);
+ params.my_node = listitem;
+ return params;
- },
+ },
- '_map_row_to_treecell' : function(params,treerow) {
- var obj = this;
- var s = '';
- util.widgets.remove_children(treerow);
+ '_map_row_to_treecell' : function(params,treerow) {
+ var obj = this;
+ var s = '';
+ util.widgets.remove_children(treerow);
- if (typeof params.map_row_to_column == 'function' || typeof this.map_row_to_column == 'function') {
+ if (typeof params.map_row_to_column == 'function' || typeof this.map_row_to_column == 'function') {
- for (var i = 0; i < this.columns.length; i++) {
- var treecell = document.createElement('treecell');
+ for (var i = 0; i < this.columns.length; i++) {
+ var treecell = document.createElement('treecell');
if ( this.columns[i].editable == false ) { treecell.setAttribute('editable','false'); }
- var label = '';
- if (params.skip_columns && (params.skip_columns.indexOf(i) != -1)) {
- treecell.setAttribute('label',label);
- treerow.appendChild( treecell );
- s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
- continue;
- }
- if (params.skip_all_columns_except && (params.skip_all_columns_except.indexOf(i) == -1)) {
- treecell.setAttribute('label',label);
- treerow.appendChild( treecell );
- s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
- continue;
- }
-
- if (typeof params.map_row_to_column == 'function') {
-
- label = params.map_row_to_column(params.row,this.columns[i]);
-
- } else if (typeof this.map_row_to_column == 'function') {
-
- label = this.map_row_to_column(params.row,this.columns[i]);
-
- }
- if (this.columns[i].type == 'checkbox') { treecell.setAttribute('value',label); } else { treecell.setAttribute('label',label ? label : ''); }
- treerow.appendChild( treecell );
- s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
- }
- } else if (typeof params.map_row_to_columns == 'function' || typeof this.map_row_to_columns == 'function') {
-
- var labels = [];
-
- if (typeof params.map_row_to_columns == 'function') {
-
- labels = params.map_row_to_columns(params.row,this.columns);
-
- } else if (typeof this.map_row_to_columns == 'function') {
-
- labels = this.map_row_to_columns(params.row,this.columns);
-
- }
- for (var i = 0; i < labels.length; i++) {
- var treecell = document.createElement('treecell');
+ var label = '';
+ if (params.skip_columns && (params.skip_columns.indexOf(i) != -1)) {
+ treecell.setAttribute('label',label);
+ treerow.appendChild( treecell );
+ s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
+ continue;
+ }
+ if (params.skip_all_columns_except && (params.skip_all_columns_except.indexOf(i) == -1)) {
+ treecell.setAttribute('label',label);
+ treerow.appendChild( treecell );
+ s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
+ continue;
+ }
+
+ if (typeof params.map_row_to_column == 'function') {
+
+ label = params.map_row_to_column(params.row,this.columns[i]);
+
+ } else if (typeof this.map_row_to_column == 'function') {
+
+ label = this.map_row_to_column(params.row,this.columns[i]);
+
+ }
+ if (this.columns[i].type == 'checkbox') { treecell.setAttribute('value',label); } else { treecell.setAttribute('label',label ? label : ''); }
+ treerow.appendChild( treecell );
+ s += ('treecell = ' + treecell + ' with label = ' + label + '\n');
+ }
+ } else if (typeof params.map_row_to_columns == 'function' || typeof this.map_row_to_columns == 'function') {
+
+ var labels = [];
+
+ if (typeof params.map_row_to_columns == 'function') {
+
+ labels = params.map_row_to_columns(params.row,this.columns);
+
+ } else if (typeof this.map_row_to_columns == 'function') {
+
+ labels = this.map_row_to_columns(params.row,this.columns);
+
+ }
+ for (var i = 0; i < labels.length; i++) {
+ var treecell = document.createElement('treecell');
if ( this.columns[i].editable == false ) { treecell.setAttribute('editable','false'); }
if ( this.columns[i].type == 'checkbox') {
treecell.setAttribute('value', labels[i]);
} else {
- treecell.setAttribute('label',typeof labels[i] == 'string' || typeof labels[i] == 'number' ? labels[i] : '');
+ treecell.setAttribute('label',typeof labels[i] == 'string' || typeof labels[i] == 'number' ? labels[i] : '');
+ }
+ treerow.appendChild( treecell );
+ s += ('treecell = ' + treecell + ' with label = ' + labels[i] + '\n');
+ }
+
+ } else {
+
+ throw('No row to column mapping function.');
+ }
+ this.error.sdump('D_LIST',s);
+ },
+
+ '_map_row_to_listcell' : function(params,listitem) {
+ var obj = this;
+ var s = '';
+ for (var i = 0; i < this.columns.length; i++) {
+ var value = '';
+ if (typeof params.map_row_to_column == 'function') {
+
+ value = params.map_row_to_column(params.row,this.columns[i]);
+
+ } else {
+
+ if (typeof this.map_row_to_column == 'function') {
+
+ value = this.map_row_to_column(params.row,this.columns[i]);
+ }
+ }
+ if (typeof value == 'string' || typeof value == 'number') {
+ var listcell = document.createElement('listcell');
+ listcell.setAttribute('label',value);
+ listitem.appendChild(listcell);
+ s += ('listcell = ' + listcell + ' with label = ' + value + '\n');
+ } else {
+ listitem.appendChild(value);
+ s += ('listcell = ' + value + ' is really a ' + value.nodeName + '\n');
+ }
+ }
+ this.error.sdump('D_LIST',s);
+ },
+
+ 'select_all' : function(params) {
+ var obj = this;
+ switch(this.node.nodeName) {
+ case 'tree' : return this._select_all_from_tree(params); break;
+ default: throw('NYI: Need ._select_all_from_() for ' + this.node.nodeName); break;
+ }
+ },
+
+ '_select_all_from_tree' : function(params) {
+ var obj = this;
+ this.node.view.selection.selectAll();
+ },
+
+ 'retrieve_selection' : function(params) {
+ var obj = this;
+ switch(this.node.nodeName) {
+ case 'tree' : return this._retrieve_selection_from_tree(params); break;
+ default: throw('NYI: Need ._retrieve_selection_from_() for ' + this.node.nodeName); break;
+ }
+ },
+
+ '_retrieve_selection_from_tree' : function(params) {
+ var obj = this;
+ var list = [];
+ var start = new Object();
+ var end = new Object();
+ var numRanges = this.node.view.selection.getRangeCount();
+ for (var t=0; t<numRanges; t++){
+ this.node.view.selection.getRangeAt(t,start,end);
+ for (var v=start.value; v<=end.value; v++){
+ var i = this.node.contentView.getItemAtIndex(v);
+ list.push( i );
+ }
+ }
+ return list;
+ },
+
+ 'dump' : function(params) {
+ var obj = this;
+ switch(this.node.nodeName) {
+ case 'tree' : return this._dump_tree(params); break;
+ default: throw('NYI: Need .dump() for ' + this.node.nodeName); break;
+ }
+ },
+
+ '_dump_tree' : function(params) {
+ var obj = this;
+ var dump = [];
+ for (var i = 0; i < this.treechildren.childNodes.length; i++) {
+ var row = [];
+ var treeitem = this.treechildren.childNodes[i];
+ var treerow = treeitem.firstChild;
+ for (var j = 0; j < treerow.childNodes.length; j++) {
+ row.push( treerow.childNodes[j].getAttribute('label') );
+ }
+ dump.push( row );
+ }
+ return dump;
+ },
+
+ 'dump_with_keys' : function(params) {
+ var obj = this;
+ switch(this.node.nodeName) {
+ case 'tree' : return this._dump_tree_with_keys(params); break;
+ default: throw('NYI: Need .dump_with_keys() for ' + this.node.nodeName); break;
+ }
+
+ },
+
+ '_dump_tree_with_keys' : function(params) {
+ var obj = this;
+ var dump = [];
+ for (var i = 0; i < this.treechildren.childNodes.length; i++) {
+ var row = {};
+ var treeitem = this.treechildren.childNodes[i];
+ var treerow = treeitem.firstChild;
+ for (var j = 0; j < treerow.childNodes.length; j++) {
+ row[ obj.columns[j].id ] = treerow.childNodes[j].getAttribute('label');
+ }
+ dump.push( row );
+ }
+ return dump;
+ },
+
+ 'dump_csv' : function(params) {
+ var obj = this;
+ switch(this.node.nodeName) {
+ case 'tree' : return this._dump_tree_csv(params); break;
+ default: throw('NYI: Need .dump_csv() for ' + this.node.nodeName); break;
+ }
+
+ },
+
+ '_dump_tree_csv' : function(params) {
+ var obj = this;
+ var dump = '';
+ for (var j = 0; j < obj.columns.length; j++) {
+ if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') {
+ /* skip */
+ } else {
+ if (dump) dump += ',';
+ dump += '"' + obj.columns[j].label.replace(/"/g, '""') + '"';
+ }
+ }
+ dump += '\r\n';
+ for (var i = 0; i < this.treechildren.childNodes.length; i++) {
+ var row = '';
+ var treeitem = this.treechildren.childNodes[i];
+ var treerow = treeitem.firstChild;
+ for (var j = 0; j < treerow.childNodes.length; j++) {
+ if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') {
+ /* skip */
+ } else {
+ if (row) row += ',';
+ row += '"' + treerow.childNodes[j].getAttribute('label').replace(/"/g, '""') + '"';
}
- treerow.appendChild( treecell );
- s += ('treecell = ' + treecell + ' with label = ' + labels[i] + '\n');
- }
-
- } else {
-
- throw('No row to column mapping function.');
- }
- this.error.sdump('D_LIST',s);
- },
-
- '_map_row_to_listcell' : function(params,listitem) {
- var obj = this;
- var s = '';
- for (var i = 0; i < this.columns.length; i++) {
- var value = '';
- if (typeof params.map_row_to_column == 'function') {
-
- value = params.map_row_to_column(params.row,this.columns[i]);
-
- } else {
-
- if (typeof this.map_row_to_column == 'function') {
-
- value = this.map_row_to_column(params.row,this.columns[i]);
- }
- }
- if (typeof value == 'string' || typeof value == 'number') {
- var listcell = document.createElement('listcell');
- listcell.setAttribute('label',value);
- listitem.appendChild(listcell);
- s += ('listcell = ' + listcell + ' with label = ' + value + '\n');
- } else {
- listitem.appendChild(value);
- s += ('listcell = ' + value + ' is really a ' + value.nodeName + '\n');
- }
- }
- this.error.sdump('D_LIST',s);
- },
-
- 'select_all' : function(params) {
- var obj = this;
- switch(this.node.nodeName) {
- case 'tree' : return this._select_all_from_tree(params); break;
- default: throw('NYI: Need ._select_all_from_() for ' + this.node.nodeName); break;
- }
- },
-
- '_select_all_from_tree' : function(params) {
- var obj = this;
- this.node.view.selection.selectAll();
- },
-
- 'retrieve_selection' : function(params) {
- var obj = this;
- switch(this.node.nodeName) {
- case 'tree' : return this._retrieve_selection_from_tree(params); break;
- default: throw('NYI: Need ._retrieve_selection_from_() for ' + this.node.nodeName); break;
- }
- },
-
- '_retrieve_selection_from_tree' : function(params) {
- var obj = this;
- var list = [];
- var start = new Object();
- var end = new Object();
- var numRanges = this.node.view.selection.getRangeCount();
- for (var t=0; t<numRanges; t++){
- this.node.view.selection.getRangeAt(t,start,end);
- for (var v=start.value; v<=end.value; v++){
- var i = this.node.contentView.getItemAtIndex(v);
- list.push( i );
- }
- }
- return list;
- },
-
- 'dump' : function(params) {
- var obj = this;
- switch(this.node.nodeName) {
- case 'tree' : return this._dump_tree(params); break;
- default: throw('NYI: Need .dump() for ' + this.node.nodeName); break;
- }
- },
-
- '_dump_tree' : function(params) {
- var obj = this;
- var dump = [];
- for (var i = 0; i < this.treechildren.childNodes.length; i++) {
- var row = [];
- var treeitem = this.treechildren.childNodes[i];
- var treerow = treeitem.firstChild;
- for (var j = 0; j < treerow.childNodes.length; j++) {
- row.push( treerow.childNodes[j].getAttribute('label') );
- }
- dump.push( row );
- }
- return dump;
- },
-
- 'dump_with_keys' : function(params) {
- var obj = this;
- switch(this.node.nodeName) {
- case 'tree' : return this._dump_tree_with_keys(params); break;
- default: throw('NYI: Need .dump_with_keys() for ' + this.node.nodeName); break;
- }
-
- },
-
- '_dump_tree_with_keys' : function(params) {
- var obj = this;
- var dump = [];
- for (var i = 0; i < this.treechildren.childNodes.length; i++) {
- var row = {};
- var treeitem = this.treechildren.childNodes[i];
- var treerow = treeitem.firstChild;
- for (var j = 0; j < treerow.childNodes.length; j++) {
- row[ obj.columns[j].id ] = treerow.childNodes[j].getAttribute('label');
- }
- dump.push( row );
- }
- return dump;
- },
-
- 'dump_csv' : function(params) {
- var obj = this;
- switch(this.node.nodeName) {
- case 'tree' : return this._dump_tree_csv(params); break;
- default: throw('NYI: Need .dump_csv() for ' + this.node.nodeName); break;
- }
-
- },
-
- '_dump_tree_csv' : function(params) {
- var obj = this;
- var dump = '';
- for (var j = 0; j < obj.columns.length; j++) {
- if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') {
- /* skip */
- } else {
- if (dump) dump += ',';
- dump += '"' + obj.columns[j].label.replace(/"/g, '""') + '"';
- }
- }
- dump += '\r\n';
- for (var i = 0; i < this.treechildren.childNodes.length; i++) {
- var row = '';
- var treeitem = this.treechildren.childNodes[i];
- var treerow = treeitem.firstChild;
- for (var j = 0; j < treerow.childNodes.length; j++) {
- if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') {
- /* skip */
- } else {
- if (row) row += ',';
- row += '"' + treerow.childNodes[j].getAttribute('label').replace(/"/g, '""') + '"';
- }
- }
- dump += row + '\r\n';
- }
- return dump;
- },
+ }
+ dump += row + '\r\n';
+ }
+ return dump;
+ },
'dump_csv_to_clipboard' : function(params) {
var obj = this;
'print' : function(params) {
if (!params) params = {};
- switch(this.node.nodeName) {
- case 'tree' : return this._print_tree(params); break;
- default: throw('NYI: Need ._print() for ' + this.node.nodeName); break;
- }
+ switch(this.node.nodeName) {
+ case 'tree' : return this._print_tree(params); break;
+ default: throw('NYI: Need ._print() for ' + this.node.nodeName); break;
+ }
},
'_print_tree' : function(params) {
var obj = this;
try {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
if (!params.staff && data.list.au && data.list.au[0]) {
params.staff = data.list.au[0];
}
print.tree_list( params );
if (typeof params.callback == 'function') params.callback();
} catch(E) {
- obj.error.standard_unexpected_error_alert('inner _print_tree',E);
+ obj.error.standard_unexpected_error_alert('inner _print_tree',E);
}
}
);
} catch(E) {
- obj.error.standard_unexpected_error_alert('_print_tree',E);
+ obj.error.standard_unexpected_error_alert('_print_tree',E);
+ }
+ },
+
+ 'dump_selected_with_keys' : function(params) {
+ var obj = this;
+ switch(this.node.nodeName) {
+ case 'tree' : return this._dump_tree_selection_with_keys(params); break;
+ default: throw('NYI: Need .dump_selection_with_keys() for ' + this.node.nodeName); break;
+ }
+
+ },
+
+ '_dump_tree_selection_with_keys' : function(params) {
+ var obj = this;
+ var dump = [];
+ var list = obj._retrieve_selection_from_tree();
+ for (var i = 0; i < list.length; i++) {
+ var row = {};
+ var treeitem = list[i];
+ var treerow = treeitem.firstChild;
+ for (var j = 0; j < treerow.childNodes.length; j++) {
+ var value = treerow.childNodes[j].getAttribute('label');
+ if (params.skip_hidden_columns) if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') continue;
+ var id = obj.columns[j].id; if (params.labels_instead_of_ids) id = obj.columns[j].label;
+ row[ id ] = value;
+ }
+ dump.push( row );
}
+ return dump;
},
- 'dump_selected_with_keys' : function(params) {
- var obj = this;
- switch(this.node.nodeName) {
- case 'tree' : return this._dump_tree_selection_with_keys(params); break;
- default: throw('NYI: Need .dump_selection_with_keys() for ' + this.node.nodeName); break;
- }
-
- },
-
- '_dump_tree_selection_with_keys' : function(params) {
- var obj = this;
- var dump = [];
- var list = obj._retrieve_selection_from_tree();
- for (var i = 0; i < list.length; i++) {
- var row = {};
- var treeitem = list[i];
- var treerow = treeitem.firstChild;
- for (var j = 0; j < treerow.childNodes.length; j++) {
- var value = treerow.childNodes[j].getAttribute('label');
- if (params.skip_hidden_columns) if (obj.node.treeBoxObject.columns.getColumnAt(j).element.getAttribute('hidden') == 'true') continue;
- var id = obj.columns[j].id; if (params.labels_instead_of_ids) id = obj.columns[j].label;
- row[ id ] = value;
- }
- dump.push( row );
- }
- return dump;
- },
-
- 'clipboard' : function(params) {
- try {
- var obj = this;
- var dump = obj.dump_selected_with_keys({'skip_hidden_columns':true,'labels_instead_of_ids':true});
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
- data.list_clipboard = dump; data.stash('list_clipboard');
- JSAN.use('util.window'); var win = new util.window();
- win.open(urls.XUL_LIST_CLIPBOARD,'list_clipboard','chrome,resizable,modal');
+ 'clipboard' : function(params) {
+ try {
+ var obj = this;
+ var dump = obj.dump_selected_with_keys({'skip_hidden_columns':true,'labels_instead_of_ids':true});
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+ data.list_clipboard = dump; data.stash('list_clipboard');
+ JSAN.use('util.window'); var win = new util.window();
+ win.open(urls.XUL_LIST_CLIPBOARD,'list_clipboard','chrome,resizable,modal');
window.focus(); // sometimes the main window will lower after a clipboard action
- } catch(E) {
- this.error.standard_unexpected_error_alert('clipboard',E);
- }
- },
-
- 'dump_retrieve_ids' : function(params) {
- var obj = this;
- switch(this.node.nodeName) {
- case 'tree' : return this._dump_retrieve_ids_tree(params); break;
- default: throw('NYI: Need .dump_retrieve_ids() for ' + this.node.nodeName); break;
- }
- },
-
- '_dump_retrieve_ids_tree' : function(params) {
- var obj = this;
- var dump = [];
- for (var i = 0; i < this.treechildren.childNodes.length; i++) {
- var treeitem = this.treechildren.childNodes[i];
- dump.push( treeitem.getAttribute('retrieve_id') );
- }
- return dump;
- },
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('clipboard',E);
+ }
+ },
+
+ 'dump_retrieve_ids' : function(params) {
+ var obj = this;
+ switch(this.node.nodeName) {
+ case 'tree' : return this._dump_retrieve_ids_tree(params); break;
+ default: throw('NYI: Need .dump_retrieve_ids() for ' + this.node.nodeName); break;
+ }
+ },
+
+ '_dump_retrieve_ids_tree' : function(params) {
+ var obj = this;
+ var dump = [];
+ for (var i = 0; i < this.treechildren.childNodes.length; i++) {
+ var treeitem = this.treechildren.childNodes[i];
+ dump.push( treeitem.getAttribute('retrieve_id') );
+ }
+ return dump;
+ },
'wrap_in_full_retrieve' : function(f) {
var obj = this;
- if (typeof obj.on_all_fleshed == 'function') { // legacy
+ if (typeof obj.on_all_fleshed == 'function') { // legacy
obj.on_all_fleshed = [ obj.on_all_fleshed ];
- }
+ }
if (! obj.on_all_fleshed) obj.on_all_fleshed = [];
obj.on_all_fleshed.push(f);
obj.full_retrieve();
},
- '_sort_tree' : function(col,sortDir) {
- var obj = this;
- try {
- if (obj.node.getAttribute('no_sort')) {
- return;
- }
- var col_pos;
- for (var i = 0; i < obj.columns.length; i++) {
- if (obj.columns[i].id == col.id) col_pos = function(a){return a;}(i);
- }
+ '_sort_tree' : function(col,sortDir) {
+ var obj = this;
+ try {
+ if (obj.node.getAttribute('no_sort')) {
+ return;
+ }
+ var col_pos;
+ for (var i = 0; i < obj.columns.length; i++) {
+ if (obj.columns[i].id == col.id) col_pos = function(a){return a;}(i);
+ }
obj.wrap_in_full_retrieve(
function() {
- try {
- JSAN.use('util.money');
- var rows = [];
- var treeitems = obj.treechildren.childNodes;
- for (var i = 0; i < treeitems.length; i++) {
- var treeitem = treeitems[i];
- var treerow = treeitem.firstChild;
- var treecell = treerow.childNodes[ col_pos ];
- value = ( { 'value' : treecell ? treecell.getAttribute('label') : '', 'node' : treeitem } );
- rows.push( value );
- }
- rows = rows.sort( function(a,b) {
- a = a.value; b = b.value;
- if (col.getAttribute('sort_type')) {
- switch(col.getAttribute('sort_type')) {
- case 'number' :
- a = Number(a); b = Number(b);
- break;
- case 'money' :
- a = util.money.dollars_float_to_cents_integer(a);
- b = util.money.dollars_float_to_cents_integer(b);
- break;
- case 'title' : /* special case for "a" and "the". doesn't use marc 245 indicator */
- a = String( a ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
- b = String( b ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
- break;
- default:
- a = String( a ).toUpperCase();
- b = String( b ).toUpperCase();
- break;
- }
- } else {
- if (typeof a == 'string' || typeof b == 'string') {
- a = String( a ).toUpperCase();
- b = String( b ).toUpperCase();
- }
- }
- if (a < b) return -1;
- if (a > b) return 1;
- return 0;
- } );
- if (sortDir == 'asc') rows = rows.reverse();
- while(obj.treechildren.lastChild) obj.treechildren.removeChild( obj.treechildren.lastChild );
- for (var i = 0; i < rows.length; i++) {
- obj.treechildren.appendChild( rows[i].node );
- }
+ try {
+ JSAN.use('util.money');
+ var rows = [];
+ var treeitems = obj.treechildren.childNodes;
+ for (var i = 0; i < treeitems.length; i++) {
+ var treeitem = treeitems[i];
+ var treerow = treeitem.firstChild;
+ var treecell = treerow.childNodes[ col_pos ];
+ value = ( { 'value' : treecell ? treecell.getAttribute('label') : '', 'node' : treeitem } );
+ rows.push( value );
+ }
+ rows = rows.sort( function(a,b) {
+ a = a.value; b = b.value;
+ if (col.getAttribute('sort_type')) {
+ switch(col.getAttribute('sort_type')) {
+ case 'number' :
+ a = Number(a); b = Number(b);
+ break;
+ case 'money' :
+ a = util.money.dollars_float_to_cents_integer(a);
+ b = util.money.dollars_float_to_cents_integer(b);
+ break;
+ case 'title' : /* special case for "a" and "the". doesn't use marc 245 indicator */
+ a = String( a ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
+ b = String( b ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
+ break;
+ default:
+ a = String( a ).toUpperCase();
+ b = String( b ).toUpperCase();
+ break;
+ }
+ } else {
+ if (typeof a == 'string' || typeof b == 'string') {
+ a = String( a ).toUpperCase();
+ b = String( b ).toUpperCase();
+ }
+ }
+ if (a < b) return -1;
+ if (a > b) return 1;
+ return 0;
+ } );
+ if (sortDir == 'asc') rows = rows.reverse();
+ while(obj.treechildren.lastChild) obj.treechildren.removeChild( obj.treechildren.lastChild );
+ for (var i = 0; i < rows.length; i++) {
+ obj.treechildren.appendChild( rows[i].node );
+ }
if (typeof obj.on_sort == 'function') obj.on_sort();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('sorting',E);
- }
- }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('sorting',E);
+ }
+ }
);
- } catch(E) {
- obj.error.standard_unexpected_error_alert('pre sorting', E);
- }
- },
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('pre sorting', E);
+ }
+ },
'_toggle_checkbox_column' : function(col,toggle) {
var obj = this;
}
},
- 'render_list_actions' : function(params) {
- var obj = this;
- switch(this.node.nodeName) {
- case 'tree' : return this._render_list_actions_for_tree(params); break;
- default: throw('NYI: Need ._render_list_actions() for ' + this.node.nodeName); break;
- }
- },
+ 'render_list_actions' : function(params) {
+ var obj = this;
+ switch(this.node.nodeName) {
+ case 'tree' : return this._render_list_actions_for_tree(params); break;
+ default: throw('NYI: Need ._render_list_actions() for ' + this.node.nodeName); break;
+ }
+ },
'_render_list_actions_for_tree' : function(params) {
var obj = this;
}
},
- 'set_list_actions' : function(params) {
- var obj = this;
- switch(this.node.nodeName) {
- case 'tree' : return this._set_list_actions_for_tree(params); break;
- default: throw('NYI: Need ._set_list_actions() for ' + this.node.nodeName); break;
- }
- },
+ 'set_list_actions' : function(params) {
+ var obj = this;
+ switch(this.node.nodeName) {
+ case 'tree' : return this._set_list_actions_for_tree(params); break;
+ default: throw('NYI: Need ._set_list_actions() for ' + this.node.nodeName); break;
+ }
+ },
'_set_list_actions_for_tree' : function(params) {
// This should be called after the button element from render_list_actions has been appended to the DOM
if (typeof util == 'undefined') var util = {};
util.money = {};
-util.money.EXPORT_OK = [
- 'sanitize', 'dollars_float_to_cents_integer', 'cents_as_dollars'
+util.money.EXPORT_OK = [
+ 'sanitize', 'dollars_float_to_cents_integer', 'cents_as_dollars'
];
-util.money.EXPORT_TAGS = { ':all' : util.money.EXPORT_OK };
+util.money.EXPORT_TAGS = { ':all' : util.money.EXPORT_OK };
util.money.dollars_float_to_cents_integer = function( money ) {
- try {
- if (money == '' || money == null || money == undefined) money = 0;
- // careful to avoid fractions of pennies
- var negative; negative = money.toString().match(/-/) ? -1 : 1;
- var money_s = money.toString().replace(/[^\.\d]/g, '');
- var marray = money_s.split(".");
- var dollars = marray[0];
- var cents = marray[1];
- try {
- if (cents.length < 2) {
- cents = cents + '0';
- }
- } catch(E) {
- }
- try {
- if (cents.length > 2) {
- dump("util.money: We don't round money\n");
- cents = cents.substr(0,2);
- }
- } catch(E) {
- }
- var total = 0;
- try {
- if (Number(cents)) total += Number(cents);
- } catch(E) {
- }
- try {
- if (Number(dollars)) total += (Number(dollars) * 100);
- } catch(E) {
- }
- return total * negative;
- } catch(E) {
- alert('util.money.dollars_float_to_cents_integer:\n' + E);
- }
+ try {
+ if (money == '' || money == null || money == undefined) money = 0;
+ // careful to avoid fractions of pennies
+ var negative; negative = money.toString().match(/-/) ? -1 : 1;
+ var money_s = money.toString().replace(/[^\.\d]/g, '');
+ var marray = money_s.split(".");
+ var dollars = marray[0];
+ var cents = marray[1];
+ try {
+ if (cents.length < 2) {
+ cents = cents + '0';
+ }
+ } catch(E) {
+ }
+ try {
+ if (cents.length > 2) {
+ dump("util.money: We don't round money\n");
+ cents = cents.substr(0,2);
+ }
+ } catch(E) {
+ }
+ var total = 0;
+ try {
+ if (Number(cents)) total += Number(cents);
+ } catch(E) {
+ }
+ try {
+ if (Number(dollars)) total += (Number(dollars) * 100);
+ } catch(E) {
+ }
+ return total * negative;
+ } catch(E) {
+ alert('util.money.dollars_float_to_cents_integer:\n' + E);
+ }
}
util.money.cents_as_dollars = function( cents ) {
- try {
- if (cents == '' || cents == null || cents == undefined) cents = 0;
- var negative; negative = cents.toString().match(/-/) ? '-' : '';
- cents = cents.toString().replace(/[^\.\d]/g, '');
- if (cents.match(/\./)) cents = util.money.dollars_float_to_cents_integer( cents ).toString();
- try {
- switch( cents.length ) {
- case 0: cents = '000'; break;
- case 1: cents = '00' + cents; break;
- }
- } catch(E) {
- }
- return negative + cents.substr(0,cents.length-2) + '.' + cents.substr(cents.length - 2);
- } catch(E) {
- alert('util.money.cents_as_dollars:\n' + E);
- }
+ try {
+ if (cents == '' || cents == null || cents == undefined) cents = 0;
+ var negative; negative = cents.toString().match(/-/) ? '-' : '';
+ cents = cents.toString().replace(/[^\.\d]/g, '');
+ if (cents.match(/\./)) cents = util.money.dollars_float_to_cents_integer( cents ).toString();
+ try {
+ switch( cents.length ) {
+ case 0: cents = '000'; break;
+ case 1: cents = '00' + cents; break;
+ }
+ } catch(E) {
+ }
+ return negative + cents.substr(0,cents.length-2) + '.' + cents.substr(cents.length - 2);
+ } catch(E) {
+ alert('util.money.cents_as_dollars:\n' + E);
+ }
}
util.money.sanitize = function( money ) {
- return util.money.cents_as_dollars( util.money.dollars_float_to_cents_integer( money ) );
+ return util.money.cents_as_dollars( util.money.dollars_float_to_cents_integer( money ) );
}
if (typeof util == 'undefined') var util = {};
util.mozilla = {};
-util.mozilla.EXPORT_OK = [
- 'chromeRegistry', 'languages', 'regions', 'prefs'
+util.mozilla.EXPORT_OK = [
+ 'chromeRegistry', 'languages', 'regions', 'prefs'
];
-util.mozilla.EXPORT_TAGS = { ':all' : util.mozilla.EXPORT_OK };
+util.mozilla.EXPORT_TAGS = { ':all' : util.mozilla.EXPORT_OK };
util.mozilla.chromeRegistry = function() {
- try {
+ try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
return Cc['@mozilla.org/chrome/chrome-registry;1'].getService(Ci['nsIToolkitChromeRegistry']);
- } catch(E) {
- alert("FIXME: util.mozilla.reloadChrome() = " + E);
- }
+ } catch(E) {
+ alert("FIXME: util.mozilla.reloadChrome() = " + E);
+ }
}
util.mozilla.languages = function() {
- try {
+ try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var stringBundles = Cc['@mozilla.org/intl/stringbundle;1'].getService(Ci['nsIStringBundleService']);
return stringBundles.createBundle('chrome://global/locale/languageNames.properties');
- } catch(E) {
- alert("FIXME: util.mozilla.reloadChrome() = " + E);
- }
+ } catch(E) {
+ alert("FIXME: util.mozilla.reloadChrome() = " + E);
+ }
}
util.mozilla.regions = function() {
- try {
+ try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var stringBundles = Cc['@mozilla.org/intl/stringbundle;1'].getService(Ci['nsIStringBundleService']);
return stringBundles.createBundle('chrome://global/locale/regionNames.properties');
- } catch(E) {
- alert("FIXME: util.mozilla.reloadChrome() = " + E);
- }
+ } catch(E) {
+ alert("FIXME: util.mozilla.reloadChrome() = " + E);
+ }
}
util.mozilla.prefs = function() {
- try {
+ try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
return Cc['@mozilla.org/preferences-service;1'].getService(Ci['nsIPrefBranch']);
- } catch(E) {
- alert("FIXME: util.mozilla.reloadChrome() = " + E);
- }
+ } catch(E) {
+ alert("FIXME: util.mozilla.reloadChrome() = " + E);
+ }
}
util.mozilla.change_locale = function( locale ) {
- try {
+ try {
var current_locale = 'en-US';
try { current_locale = util.mozilla.prefs().getCharPref('general.useragent.locale'); } catch(E) { alert('util.locale.change, prefs() = ' + E); }
if (locale != current_locale) {
util.mozilla.chromeRegistry().reloadChrome();
}
- } catch(E) {
- alert('FIXME: util.mozilla.change_locale( "' + locale + ") = " + E);
- }
+ } catch(E) {
+ alert('FIXME: util.mozilla.change_locale( "' + locale + ") = " + E);
+ }
}
throw(E);
}
- return this;
+ return this;
};
util.network.prototype = {
- 'link_id' : 0,
+ 'link_id' : 0,
'network_timeout' : 55, /* seconds */
- 'NETWORK_FAILURE' : null,
-
- 'simple_request' : function(method_id,params,f,override_params) {
- //var obj = this;
- //var sparams = js2JSON(params);
- //obj.error.sdump('D_SES','simple_request '+ method_id +' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
- // '\noverride_params = ' + override_params + '\n');
- if (typeof api[method_id] == 'undefined') {
- throw( offlineStrings.getFormattedString('network.method_not_found.error', [method_id]) );
- }
- var secure = true; if (typeof api[method_id].secure != 'undefined') secure = api[method_id].secure;
- return this.request(api[method_id].app,api[method_id].method,params,f,override_params,{ 'secure' : secure, 'method_id' : method_id });
- },
-
- 'get_result' : function (req) {
- var obj = this;
- var result;
+ 'NETWORK_FAILURE' : null,
+
+ 'simple_request' : function(method_id,params,f,override_params) {
+ //var obj = this;
+ //var sparams = js2JSON(params);
+ //obj.error.sdump('D_SES','simple_request '+ method_id +' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
+ // '\noverride_params = ' + override_params + '\n');
+ if (typeof api[method_id] == 'undefined') {
+ throw( offlineStrings.getFormattedString('network.method_not_found.error', [method_id]) );
+ }
+ var secure = true; if (typeof api[method_id].secure != 'undefined') secure = api[method_id].secure;
+ return this.request(api[method_id].app,api[method_id].method,params,f,override_params,{ 'secure' : secure, 'method_id' : method_id });
+ },
+
+ 'get_result' : function (req) {
+ var obj = this;
+ var result;
var fake_ilsevent_for_network_errors = { 'ilsevent' : -1, 'textcode' : offlineStrings.getString('network.server_or_method.error') };
- try {
+ try {
if (req.cancelled) {
result = fake_ilsevent_for_network_errors;
} else {
- result = req.getResultObject();
+ result = req.getResultObject();
+ }
+ } catch(E) {
+ try {
+ if (instanceOf(E, NetworkFailure)) {
+ obj.NETWORK_FAILURE = E;
+ } else {
+ try { obj.NETWORK_FAILURE = js2JSON(E); } catch(F) { dump(F + '\n'); obj.NETWORK_FAILURE = E; };
+ }
+ } catch(I) {
+ obj.NETWORK_FAILURE = offlineStrings.getString('network.unknown_status');
}
- } catch(E) {
- try {
- if (instanceOf(E, NetworkFailure)) {
- obj.NETWORK_FAILURE = E;
- } else {
- try { obj.NETWORK_FAILURE = js2JSON(E); } catch(F) { dump(F + '\n'); obj.NETWORK_FAILURE = E; };
- }
- } catch(I) {
- obj.NETWORK_FAILURE = offlineStrings.getString('network.unknown_status');
- }
result = fake_ilsevent_for_network_errors;
}
- return result;
- },
-
- 'request' : function (app,name,params,f,override_params,_params) {
-
- var obj = this;
-
- //var sparams = js2JSON(params);
- //obj.error.sdump('D_SES','request '+ app + ' ' + name +' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
- // '\noverride_params = ' + override_params + '\n_params = ' + _params + '\n');
-
- try {
-
- var request = this._request(app,name,params,f,override_params,_params);
- if (request) {
- return this.get_result(request);
- } else {
- return null;
- }
-
- } catch(E) {
- alert('1: ' + E);
- }
- },
-
- '_request' : function (app,name,params,f,override_params,_params) {
- var obj = this;
- try {
- var sparams = js2JSON(params);
- obj.error.sdump('D_SES','_request '+app+' '+name+' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
- '\noverride_params = ' + override_params + '\n_params = ' + _params +
- '\nResult #' + (++obj.link_id) + ( f ? ' asynced' : ' synced' ) );
+ return result;
+ },
+
+ 'request' : function (app,name,params,f,override_params,_params) {
+
+ var obj = this;
+
+ //var sparams = js2JSON(params);
+ //obj.error.sdump('D_SES','request '+ app + ' ' + name +' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
+ // '\noverride_params = ' + override_params + '\n_params = ' + _params + '\n');
+
+ try {
+
+ var request = this._request(app,name,params,f,override_params,_params);
+ if (request) {
+ return this.get_result(request);
+ } else {
+ return null;
+ }
+
+ } catch(E) {
+ alert('1: ' + E);
+ }
+ },
+
+ '_request' : function (app,name,params,f,override_params,_params) {
+ var obj = this;
+ try {
+ var sparams = js2JSON(params);
+ obj.error.sdump('D_SES','_request '+app+' '+name+' '+obj.error.pretty_print(sparams.slice(1,sparams.length-1))+
+ '\noverride_params = ' + override_params + '\n_params = ' + _params +
+ '\nResult #' + (++obj.link_id) + ( f ? ' asynced' : ' synced' ) );
if (document.getElementById('network_progress')) {
if (g && g.menu && g.menu.network_meter && typeof g.menu.network_meter.inc == 'function') g.menu.network_meter.inc(app,name);
if (xulG && xulG.network_meter && typeof xulG.network_meter.inc == 'function') xulG.network_meter.inc(app,name);
}
- var request = new RemoteRequest( app, name );
- if (_params && _params.secure) {
- request.setSecure(true);
- } else {
- request.setSecure(false);
- }
- for(var index in params) {
- request.addParam(params[index]);
- }
-
- var start_timer = (new Date).getTime();
- if (f) {
- request.setCompleteCallback(
- function(req) {
- try {
+ var request = new RemoteRequest( app, name );
+ if (_params && _params.secure) {
+ request.setSecure(true);
+ } else {
+ request.setSecure(false);
+ }
+ for(var index in params) {
+ request.addParam(params[index]);
+ }
+
+ var start_timer = (new Date).getTime();
+ if (f) {
+ request.setCompleteCallback(
+ function(req) {
+ try {
var duration = ( (new Date).getTime() - start_timer )/1000;
if ( obj.get_result(req) == null && duration > obj.network_timeout ) req.cancelled = true;
if (xulG && xulG.network_meter && typeof xulG.network_meter.dec == 'function') xulG.network_meter.dec(app,name);
}
- var json_string = js2JSON(obj.get_result(req));
- obj.error.sdump('D_SES_RESULT','asynced result #'
- + obj.link_id + '\n\n'
- + (json_string.length > 80 ? obj.error.pretty_print(json_string) : json_string)
- + '\n\nOriginal Request:\n\n'
- + 'request '+app+' '+name+' '+ sparams.slice(1,sparams.length-1));
- req = obj.rerequest_on_session_timeout(app,name,params,req,override_params,_params);
- req = obj.rerequest_on_perm_failure(app,name,params,req,override_params,_params);
- if (override_params) {
- req = obj.rerequest_on_override(app,name,params,req,override_params,_params);
- }
- req = obj.check_for_offline(app,name,params,req,override_params,_params);
- f(req);
- obj.NETWORK_FAILURE = null;
- } catch(E) {
- try {
- E.ilsevent = -2;
- E.textcode = offlineStrings.getString('network.server_or_method.error');
- } catch(F) {}
- f( { 'getResultObject' : function() { return E; } } );
- }
- }
- );
- try {
- request.send(false);
- } catch(E) {
- throw(E);
- }
- return null;
- } else {
- try {
- request.send(true);
+ var json_string = js2JSON(obj.get_result(req));
+ obj.error.sdump('D_SES_RESULT','asynced result #'
+ + obj.link_id + '\n\n'
+ + (json_string.length > 80 ? obj.error.pretty_print(json_string) : json_string)
+ + '\n\nOriginal Request:\n\n'
+ + 'request '+app+' '+name+' '+ sparams.slice(1,sparams.length-1));
+ req = obj.rerequest_on_session_timeout(app,name,params,req,override_params,_params);
+ req = obj.rerequest_on_perm_failure(app,name,params,req,override_params,_params);
+ if (override_params) {
+ req = obj.rerequest_on_override(app,name,params,req,override_params,_params);
+ }
+ req = obj.check_for_offline(app,name,params,req,override_params,_params);
+ f(req);
+ obj.NETWORK_FAILURE = null;
+ } catch(E) {
+ try {
+ E.ilsevent = -2;
+ E.textcode = offlineStrings.getString('network.server_or_method.error');
+ } catch(F) {}
+ f( { 'getResultObject' : function() { return E; } } );
+ }
+ }
+ );
+ try {
+ request.send(false);
+ } catch(E) {
+ throw(E);
+ }
+ return null;
+ } else {
+ try {
+ request.send(true);
var duration = ( (new Date).getTime() - start_timer )/1000;
if ( obj.get_result(request) == null && duration > obj.network_timeout ) request.cancelled = true;
if (xulG && xulG.network_meter && typeof xulG.network_meter.dec == 'function') xulG.network_meter.dec(app,name);
}
- } catch(E) {
- throw(E);
- }
- var result = obj.get_result(request);
- var json_string = js2JSON(result);
- this.error.sdump('D_SES_RESULT','synced result #'
- + obj.link_id + '\n\n' + ( json_string.length > 80 ? obj.error.pretty_print(json_string) : json_string )
- + '\n\nOriginal Request:\n\n'
- + 'request '+app+' '+name+' '+ sparams.slice(1,sparams.length-1));
- request = obj.rerequest_on_session_timeout(app,name,params,request,override_params,_params);
- request = obj.rerequest_on_perm_failure(app,name,params,request,override_params,_params);
- if (override_params) {
- request = obj.rerequest_on_override(app,name,params,request,override_params,_params);
- }
- request = obj.check_for_offline(app,name,params,request,override_params,_params);
- obj.NETWORK_FAILURE = null;
- return request;
- }
-
- } catch(E) {
- alert('2: ' + E);
- if (instanceOf(E,perm_ex)) {
- alert('in util.network, _request : permission exception: ' + js2JSON(E));
- }
- throw(E);
- }
- },
-
- 'check_for_offline' : function (app,name,params,req,override_params,_params) {
+ } catch(E) {
+ throw(E);
+ }
+ var result = obj.get_result(request);
+ var json_string = js2JSON(result);
+ this.error.sdump('D_SES_RESULT','synced result #'
+ + obj.link_id + '\n\n' + ( json_string.length > 80 ? obj.error.pretty_print(json_string) : json_string )
+ + '\n\nOriginal Request:\n\n'
+ + 'request '+app+' '+name+' '+ sparams.slice(1,sparams.length-1));
+ request = obj.rerequest_on_session_timeout(app,name,params,request,override_params,_params);
+ request = obj.rerequest_on_perm_failure(app,name,params,request,override_params,_params);
+ if (override_params) {
+ request = obj.rerequest_on_override(app,name,params,request,override_params,_params);
+ }
+ request = obj.check_for_offline(app,name,params,request,override_params,_params);
+ obj.NETWORK_FAILURE = null;
+ return request;
+ }
+
+ } catch(E) {
+ alert('2: ' + E);
+ if (instanceOf(E,perm_ex)) {
+ alert('in util.network, _request : permission exception: ' + js2JSON(E));
+ }
+ throw(E);
+ }
+ },
+
+ 'check_for_offline' : function (app,name,params,req,override_params,_params) {
try {
var obj = this;
var result = obj.get_result(req);
}
}
} catch(E) {
- alert('4: ' + E);
+ alert('4: ' + E);
throw(E);
}
- },
-
- 'reset_titlebars' : function(data) {
- var obj = this;
- data.stash_retrieve();
- try {
- JSAN.use('util.window'); var win = new util.window();
- var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
- var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
- var enumerator = windowManagerInterface.getEnumerator(null);
-
- var w; // set title on all appshell windows
- while ( w = enumerator.getNext() ) {
- if (w.document.title.match(/^\d/)) {
- w.document.title =
- win.appshell_name_increment()
- + ': ' + data.list.au[0].usrname()
- + '@' + data.ws_name;
- + '.' + data.server_unadorned
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(offlineStrings.getString('network.window_title.error'),E);
- }
- },
-
- 'get_new_session' : function(name,xulG,text) {
- var obj = this;
- try {
-
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- var url = urls.XUL_AUTH_SIMPLE;
- if (typeof xulG != 'undefined' && typeof xulG.url_prefix == 'function') url = xulG.url_prefix( url );
- JSAN.use('util.window'); var win = new util.window();
- var my_xulG = win.open(
- url,
- //+ '?login_type=staff'
- //+ '&desc_brief=' + window.escape( text ? 'Session Expired' : 'Operator Change' )
- //+ '&desc_full=' + window.escape( text ? 'Please enter the credentials for a new login session.' : 'Please enter the credentials for the new login session. Note that the previous session is still active.'),
- //'simple_auth' + (new Date()).toString(),
- offlineStrings.getString('network.new_session.authorize'),
- 'chrome,resizable,modal,width=700,height=500',
- {
- 'login_type' : 'staff',
- 'desc_brief' : text ? offlineStrings.getString('network.new_session.expired') : offlineStrings.getString('network.new_session.operator_change'),
- 'desc_full' : text ? offlineStrings.getString('network.new_session.expired.prompt') : offlineStrings.getString('network.new_session.operator_change.prompt')
- //'simple_auth' : (new Date()).toString(),
- }
- );
- JSAN.use('OpenILS.data');
- var data = new OpenILS.data(); data.init({'via':'stash'});
- if (typeof data.temporary_session != 'undefined' && data.temporary_session != '') {
- data.session.key = data.temporary_session.key;
- data.session.authtime = data.temporary_session.authtime;
- data.stash('session');
+ },
+
+ 'reset_titlebars' : function(data) {
+ var obj = this;
+ data.stash_retrieve();
+ try {
+ JSAN.use('util.window'); var win = new util.window();
+ var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
+ var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
+ var enumerator = windowManagerInterface.getEnumerator(null);
+
+ var w; // set title on all appshell windows
+ while ( w = enumerator.getNext() ) {
+ if (w.document.title.match(/^\d/)) {
+ w.document.title =
+ win.appshell_name_increment()
+ + ': ' + data.list.au[0].usrname()
+ + '@' + data.ws_name;
+ + '.' + data.server_unadorned
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(offlineStrings.getString('network.window_title.error'),E);
+ }
+ },
+
+ 'get_new_session' : function(name,xulG,text) {
+ var obj = this;
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ var url = urls.XUL_AUTH_SIMPLE;
+ if (typeof xulG != 'undefined' && typeof xulG.url_prefix == 'function') url = xulG.url_prefix( url );
+ JSAN.use('util.window'); var win = new util.window();
+ var my_xulG = win.open(
+ url,
+ //+ '?login_type=staff'
+ //+ '&desc_brief=' + window.escape( text ? 'Session Expired' : 'Operator Change' )
+ //+ '&desc_full=' + window.escape( text ? 'Please enter the credentials for a new login session.' : 'Please enter the credentials for the new login session. Note that the previous session is still active.'),
+ //'simple_auth' + (new Date()).toString(),
+ offlineStrings.getString('network.new_session.authorize'),
+ 'chrome,resizable,modal,width=700,height=500',
+ {
+ 'login_type' : 'staff',
+ 'desc_brief' : text ? offlineStrings.getString('network.new_session.expired') : offlineStrings.getString('network.new_session.operator_change'),
+ 'desc_full' : text ? offlineStrings.getString('network.new_session.expired.prompt') : offlineStrings.getString('network.new_session.operator_change.prompt')
+ //'simple_auth' : (new Date()).toString(),
+ }
+ );
+ JSAN.use('OpenILS.data');
+ var data = new OpenILS.data(); data.init({'via':'stash'});
+ if (typeof data.temporary_session != 'undefined' && data.temporary_session != '') {
+ data.session.key = data.temporary_session.key;
+ data.session.authtime = data.temporary_session.authtime;
+ data.stash('session');
try {
var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var cookieUri = ios.newURI("http://" + data.server_unadorned, null, null);
} catch(E) {
alert(offineStrings.getFormattedString('main.session_cookie.error', [E]));
}
- if (! data.list.au ) data.list.au = [];
- data.list.au[0] = JSON2js( data.temporary_session.usr );
- data.stash('list');
- obj.reset_titlebars(data);
- return true;
+ if (! data.list.au ) data.list.au = [];
+ data.list.au[0] = JSON2js( data.temporary_session.usr );
+ data.stash('list');
+ obj.reset_titlebars(data);
+ return true;
} else {
obj.error.sdump('D_TRACE','No new session key after simple_auth in util/network\n');
}
- return false;
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert('util.network.get_new_session',E);
- }
- },
-
- 'rerequest_on_session_timeout' : function(app,name,params,req,override_params,_params) {
- try {
- var obj = this;
- var robj = obj.get_result(req);
- if (robj != null && robj.ilsevent && robj.ilsevent == 1001) {
-
- if (obj.get_new_session(name,undefined,true)) {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- params[0] = data.session.key;
- req = obj._request(app,name,params,null,override_params,_params);
- }
- }
- } catch(E) {
- this.error.standard_unexpected_error_alert('rerequest_on_session_timeout',E);
- }
- return req;
- },
-
- 'rerequest_on_perm_failure' : function(app,name,params,req,override_params,_params) {
- try {
- var obj = this;
- var robj = obj.get_result(req);
- if (robj != null && robj.ilsevent && robj.ilsevent == 5000) {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- if (location.href.match(/^chrome/)) {
- //alert('Permission denied.');
- } else {
- JSAN.use('util.window'); var win = new util.window();
- var my_xulG = win.open(
- urls.XUL_AUTH_SIMPLE,
- //+ '?login_type=temp'
- //+ '&desc_brief=' + window.escape('Permission Denied: ' + robj.ilsperm)
- //+ '&desc_full=' + window.escape('Another staff member with the above permission may authorize this specific action. Please notify your library administrator if you need this permission. If you feel you have received this exception in error, inform your friendly Evergreen developers of the above permission and this debug information: ' + name),
- //'simple_auth' + (new Date()).toString(),
- offlineStrings.getFormattedString('network.permission.authorize'),
- 'chrome,resizable,modal,width=700,height=500',
- {
- 'login_type' : 'temp',
- 'desc_brief' : offlineStrings.getFormattedString('network.permission.description.brief', [robj.ilsperm]),
- 'desc_full' : offlineStrings.getFormattedString('network.permission.description.full', [name])
- //'simple_auth' : (new Date()).toString(),
- }
- );
- JSAN.use('OpenILS.data');
- //var data = new OpenILS.data(); data.init({'via':'stash'});
- if (typeof my_xulG.temporary_session != 'undefined' && my_xulG.temporary_session != '') {
- params[0] = my_xulG.temporary_session.key;
- req = obj._request(app,name,params,null,override_params,_params);
- }
- }
- }
- } catch(E) {
- this.error.sdump('D_ERROR',E);
- }
- return req;
- },
-
- 'rerequest_on_override' : function (app,name,params,req,override_params,_params) {
- var obj = this;
- try {
- if (!override_params.text) override_params.text = {};
- function override(r) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- obj.sound.bad();
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">' +
- '<groupbox><caption label="' + offlineStrings.getString('network.override.exceptions') + '"/>' +
- '<grid><columns><column/><column/></columns><rows>';
- for (var i = 0; i < r.length; i++) {
- var t1 = String(r[i].ilsevent).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
- var t2 = String(r[i].textcode).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
- var t3 = String((override_params.text[r[i].ilsevent] ? override_params.text[r[i].ilsevent](r[i]) : '')).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
- var t4 = String(r[i].desc).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
- xml += '<row>' +
- '<description class="oils_event" tooltiptext="' + t1 + '">' + t2 + '</description>' +
- '<description>' + t3 + '</description>' +
- '</row><row>' + '<description>' + t4 + '</description>' + '</row>';
- }
- xml += '</rows></grid></groupbox><groupbox><caption label="' + offlineStrings.getString('network.override.override') +'"/><hbox>' +
- '<description>' + offlineStrings.getString('network.override.force.prompt') + '</description>' +
- '<button accesskey="' + offlineStrings.getString('common.no.accesskey') + '" label="' + offlineStrings.getString('common.no') + '" name="fancy_cancel"/>' +
- '<button id="override" accesskey="' + offlineStrings.getString('common.yes.accesskey') + '" label="' + offlineStrings.getString('common.yes') + '" name="fancy_submit" value="override"/></hbox></groupbox></vbox>';
- //JSAN.use('OpenILS.data');
- //var data = new OpenILS.data(); data.init({'via':'stash'});
- //data.temp_override_xml = xml; data.stash('temp_override_xml');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_override_xml'
- //+ '&title=' + window.escape(override_params.title),
- 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
- { 'xml' : xml, 'title' : override_params.title }
- );
- if (fancy_prompt_data.fancy_status == 'complete') {
- req = obj._request(app,name + '.override',params);
- }
- return req;
- } catch(E) {
- alert('in util.network, rerequest_on_override, override:' + E);
- }
- }
-
- var result = obj.get_result(req);
- if (!result) return req;
-
- if (
+ return false;
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('util.network.get_new_session',E);
+ }
+ },
+
+ 'rerequest_on_session_timeout' : function(app,name,params,req,override_params,_params) {
+ try {
+ var obj = this;
+ var robj = obj.get_result(req);
+ if (robj != null && robj.ilsevent && robj.ilsevent == 1001) {
+
+ if (obj.get_new_session(name,undefined,true)) {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ params[0] = data.session.key;
+ req = obj._request(app,name,params,null,override_params,_params);
+ }
+ }
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('rerequest_on_session_timeout',E);
+ }
+ return req;
+ },
+
+ 'rerequest_on_perm_failure' : function(app,name,params,req,override_params,_params) {
+ try {
+ var obj = this;
+ var robj = obj.get_result(req);
+ if (robj != null && robj.ilsevent && robj.ilsevent == 5000) {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ if (location.href.match(/^chrome/)) {
+ //alert('Permission denied.');
+ } else {
+ JSAN.use('util.window'); var win = new util.window();
+ var my_xulG = win.open(
+ urls.XUL_AUTH_SIMPLE,
+ //+ '?login_type=temp'
+ //+ '&desc_brief=' + window.escape('Permission Denied: ' + robj.ilsperm)
+ //+ '&desc_full=' + window.escape('Another staff member with the above permission may authorize this specific action. Please notify your library administrator if you need this permission. If you feel you have received this exception in error, inform your friendly Evergreen developers of the above permission and this debug information: ' + name),
+ //'simple_auth' + (new Date()).toString(),
+ offlineStrings.getFormattedString('network.permission.authorize'),
+ 'chrome,resizable,modal,width=700,height=500',
+ {
+ 'login_type' : 'temp',
+ 'desc_brief' : offlineStrings.getFormattedString('network.permission.description.brief', [robj.ilsperm]),
+ 'desc_full' : offlineStrings.getFormattedString('network.permission.description.full', [name])
+ //'simple_auth' : (new Date()).toString(),
+ }
+ );
+ JSAN.use('OpenILS.data');
+ //var data = new OpenILS.data(); data.init({'via':'stash'});
+ if (typeof my_xulG.temporary_session != 'undefined' && my_xulG.temporary_session != '') {
+ params[0] = my_xulG.temporary_session.key;
+ req = obj._request(app,name,params,null,override_params,_params);
+ }
+ }
+ }
+ } catch(E) {
+ this.error.sdump('D_ERROR',E);
+ }
+ return req;
+ },
+
+ 'rerequest_on_override' : function (app,name,params,req,override_params,_params) {
+ var obj = this;
+ try {
+ if (!override_params.text) override_params.text = {};
+ function override(r) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ obj.sound.bad();
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">' +
+ '<groupbox><caption label="' + offlineStrings.getString('network.override.exceptions') + '"/>' +
+ '<grid><columns><column/><column/></columns><rows>';
+ for (var i = 0; i < r.length; i++) {
+ var t1 = String(r[i].ilsevent).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
+ var t2 = String(r[i].textcode).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
+ var t3 = String((override_params.text[r[i].ilsevent] ? override_params.text[r[i].ilsevent](r[i]) : '')).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
+ var t4 = String(r[i].desc).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
+ xml += '<row>' +
+ '<description class="oils_event" tooltiptext="' + t1 + '">' + t2 + '</description>' +
+ '<description>' + t3 + '</description>' +
+ '</row><row>' + '<description>' + t4 + '</description>' + '</row>';
+ }
+ xml += '</rows></grid></groupbox><groupbox><caption label="' + offlineStrings.getString('network.override.override') +'"/><hbox>' +
+ '<description>' + offlineStrings.getString('network.override.force.prompt') + '</description>' +
+ '<button accesskey="' + offlineStrings.getString('common.no.accesskey') + '" label="' + offlineStrings.getString('common.no') + '" name="fancy_cancel"/>' +
+ '<button id="override" accesskey="' + offlineStrings.getString('common.yes.accesskey') + '" label="' + offlineStrings.getString('common.yes') + '" name="fancy_submit" value="override"/></hbox></groupbox></vbox>';
+ //JSAN.use('OpenILS.data');
+ //var data = new OpenILS.data(); data.init({'via':'stash'});
+ //data.temp_override_xml = xml; data.stash('temp_override_xml');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_override_xml'
+ //+ '&title=' + window.escape(override_params.title),
+ 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
+ { 'xml' : xml, 'title' : override_params.title }
+ );
+ if (fancy_prompt_data.fancy_status == 'complete') {
+ req = obj._request(app,name + '.override',params);
+ }
+ return req;
+ } catch(E) {
+ alert('in util.network, rerequest_on_override, override:' + E);
+ }
+ }
+
+ var result = obj.get_result(req);
+ if (!result) return req;
+
+ if (
(typeof result.ilsevent != 'undefined') &&
(
(override_params.overridable_events.indexOf( result.ilsevent == null ? null : Number(result.ilsevent) ) != -1) ||
(override_params.overridable_events.indexOf( result.textcode ) != -1)
)
) {
- req = override([result]);
- } else {
- var found_good = false; var found_bad = false;
- for (var i = 0; i < result.length; i++) {
- if (
+ req = override([result]);
+ } else {
+ var found_good = false; var found_bad = false;
+ for (var i = 0; i < result.length; i++) {
+ if (
(result[i].ilsevent != 'undefined') &&
(
(override_params.overridable_events.indexOf( result[i].ilsevent == null ? null : Number(result[i].ilsevent) ) != -1) ||
(override_params.overridable_events.indexOf( result[i].textcode ) != -1)
)
) {
- found_good = true;
- } else {
- found_bad = true;
- }
- }
- if (found_good && (!found_bad)) req = override(result);
- }
-
- return req;
- } catch(E) {
- throw(E);
- }
- },
+ found_good = true;
+ } else {
+ found_bad = true;
+ }
+ }
+ if (found_good && (!found_bad)) req = override(result);
+ }
+
+ return req;
+ } catch(E) {
+ throw(E);
+ }
+ },
'ping' : function() {
try {
JSAN.use('util.file'); JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- var file = new util.file('ping.bat');
+ var file = new util.file('ping.bat');
var path = file._file.path;
- file.write_content('truncate+exec',
+ file.write_content('truncate+exec',
'#!/bin/sh\n' +
'ping -n 15 ' + data.server_unadorned + ' > "' + path + '.txt"\n' + /* windows */
'ping -c 15 ' + data.server_unadorned + ' >> "' + path + '.txt"\n' /* unix */
);
file.close();
- file = new util.file('ping.bat');
+ file = new util.file('ping.bat');
- var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
- process.init(file._file);
+ var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
+ process.init(file._file);
- var args = [];
+ var args = [];
- dump('process.run = ' + process.run(true, args, args.length) + '\n');
+ dump('process.run = ' + process.run(true, args, args.length) + '\n');
file.close();
/*
function sample_callback(request) {
- var result = request.getResultObject();
+ var result = request.getResultObject();
}
*/
if (typeof util == 'undefined') util = {};
util.print = function () {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init( { 'via':'stash' } );
- JSAN.use('util.window'); this.win = new util.window();
- JSAN.use('util.functional');
- JSAN.use('util.file');
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init( { 'via':'stash' } );
+ JSAN.use('util.window'); this.win = new util.window();
+ JSAN.use('util.functional');
+ JSAN.use('util.file');
- return this;
+ return this;
};
util.print.prototype = {
- 'reprint_last' : function() {
- try {
- var obj = this; obj.data.init({'via':'stash'});
- if (!obj.data.last_print) {
- alert('Nothing to re-print');
- return;
- }
- var msg = obj.data.last_print.msg;
- var params = obj.data.last_print.params; params.no_prompt = false;
- obj.simple( msg, params );
- } catch(E) {
- this.error.standard_unexpected_error_alert('util.print.reprint_last',E);
- }
- },
-
- 'simple' : function(msg,params) {
- try {
- if (!params) params = {};
-
- var obj = this;
-
- obj.data.last_print = { 'msg' : msg, 'params' : params}; obj.data.stash('last_print');
-
- var silent = false;
- if ( params && params.no_prompt && (params.no_prompt == true || params.no_prompt == 'true') ) {
- silent = true;
- }
-
- var content_type;
- if (params && params.content_type) {
- content_type = params.content_type;
- } else {
- content_type = 'text/html';
- }
-
- var w;
-
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.data.init({'via':'stash'});
-
- if (params.print_strategy || obj.data.print_strategy) {
-
- switch(params.print_strategy || obj.data.print_strategy) {
- case 'dos.print':
- /* FIXME - this it a kludge.. we're going to sidestep window-based html rendering for printing */
- /* I'm using regexps to mangle the html receipt templates; it'd be nice to use xsl but the */
- /* templates aren't guaranteed to be valid xml */
- if (content_type=='text/html') {
- w = msg.replace(/<br.*?>/gi,'\r\n').replace(/<table.*?>/gi,'\r\n').replace(/<tr.*?>/gi,'\r\n').replace(/<hr.*?>/gi,'\r\n').replace(/<p.*?>/gi,'\r\n').replace(/<block.*?>/gi,'\r\n').replace(/<li.*?>/gi,'\r\n * ').replace(/<.+?>/gi,'');
- } else {
- w = msg;
- }
- if (! params.no_form_feed) { w = w + '\r\n\r\n\r\n\r\n\r\n\r\n\f'; }
- obj.NSPrint(w, silent, params);
- return;
- break;
- }
- }
-
- switch(content_type) {
- case 'text/html' :
- var jsrc = 'data:text/javascript,' + window.escape('var params = { "data" : ' + js2JSON(params.data) + ', "list" : ' + js2JSON(params.list) + '}; function my_init() { if (typeof go_print == "function") { go_print(); } else { setTimeout( function() { if (typeof go_print == "function") { alert("Please tell the developers that the 2-second go_print workaround executed, and let them know whether this job printed successfully. Thanks!"); go_print(); } else { alert("Please tell the developers that the 2-second go_print workaround did not work. We will try to print one more time; there have been reports of wasted receipt paper at this point. Please check the settings in the print dialog and/or prepare to power off your printer. Thanks!"); window.print(); } }, 2000 ); } /* FIXME - mozilla bug#301560 - xpcom kills it too */ }');
- w = obj.win.open('data:text/html,<html id="top"><head><script src="/xul/server/main/JSAN.js"></script><script src="' + window.escape(jsrc) + '"></script></head><body onload="try{my_init();}catch(E){alert(E);}">' + window.escape(msg) + '</body></html>','receipt_temp','chrome,resizable');
- w.minimize();
- w.go_print = function() {
- try {
- obj.NSPrint(w, silent, params);
- } catch(E) {
- obj.error.standard_unexpected_error_alert("Print Error in util.print.simple. After this dialog we'll try a second print attempt. content_type = " + content_type,E);
- w.print();
- }
- w.minimize(); w.close();
- }
- break;
- default:
- w = obj.win.open('data:' + content_type + ',' + window.escape(msg),'receipt_temp','chrome,resizable');
- w.minimize();
- setTimeout(
- function() {
- try {
- obj.NSPrint(w, silent, params);
- } catch(E) {
- obj.error.standard_unexpected_error_alert("Print Error in util.print.simple. After this dialog we'll try a second print attempt. content_type = " + content_type,E);
- w.print();
- }
- w.minimize(); w.close();
- }, 1000
- );
- break;
- }
-
- } catch(E) {
- this.error.standard_unexpected_error_alert('util.print.simple',E);
- }
- },
-
- 'tree_list' : function (params) {
- try {
- dump('print.tree_list.params.list = \n' + this.error.pretty_print(js2JSON(params.list)) + '\n');
- dump('print.tree_list.params.data = \n' + this.error.pretty_print(js2JSON(params.data)) + '\n');
- } catch(E) {
- dump(E+'\n');
- }
- var cols = [];
- var s = '';
- if (params.header) s += this.template_sub( params.header, cols, params );
- if (params.list) {
- for (var i = 0; i < params.list.length; i++) {
- params.row = params.list[i];
- params.row_idx = i;
- s += this.template_sub( params.line_item, cols, params );
- }
- }
- if (params.footer) s += this.template_sub( params.footer, cols, params );
-
- if (params.sample_frame) {
- var jsrc = 'data:text/javascript,' + window.escape('var params = { "data" : ' + js2JSON(params.data) + ', "list" : ' + js2JSON(params.list) + '};');
- params.sample_frame.setAttribute('src','data:text/html,<html id="top"><head><script src="' + window.escape(jsrc) + '"></script></head><body>' + window.escape(s) + '</body></html>');
- } else {
- this.simple(s,params);
- }
- },
-
- 'template_sub' : function( msg, cols, params ) {
+ 'reprint_last' : function() {
+ try {
+ var obj = this; obj.data.init({'via':'stash'});
+ if (!obj.data.last_print) {
+ alert('Nothing to re-print');
+ return;
+ }
+ var msg = obj.data.last_print.msg;
+ var params = obj.data.last_print.params; params.no_prompt = false;
+ obj.simple( msg, params );
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('util.print.reprint_last',E);
+ }
+ },
+
+ 'simple' : function(msg,params) {
+ try {
+ if (!params) params = {};
+
+ var obj = this;
+
+ obj.data.last_print = { 'msg' : msg, 'params' : params}; obj.data.stash('last_print');
+
+ var silent = false;
+ if ( params && params.no_prompt && (params.no_prompt == true || params.no_prompt == 'true') ) {
+ silent = true;
+ }
+
+ var content_type;
+ if (params && params.content_type) {
+ content_type = params.content_type;
+ } else {
+ content_type = 'text/html';
+ }
+
+ var w;
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.data.init({'via':'stash'});
+
+ if (params.print_strategy || obj.data.print_strategy) {
+
+ switch(params.print_strategy || obj.data.print_strategy) {
+ case 'dos.print':
+ /* FIXME - this it a kludge.. we're going to sidestep window-based html rendering for printing */
+ /* I'm using regexps to mangle the html receipt templates; it'd be nice to use xsl but the */
+ /* templates aren't guaranteed to be valid xml */
+ if (content_type=='text/html') {
+ w = msg.replace(/<br.*?>/gi,'\r\n').replace(/<table.*?>/gi,'\r\n').replace(/<tr.*?>/gi,'\r\n').replace(/<hr.*?>/gi,'\r\n').replace(/<p.*?>/gi,'\r\n').replace(/<block.*?>/gi,'\r\n').replace(/<li.*?>/gi,'\r\n * ').replace(/<.+?>/gi,'');
+ } else {
+ w = msg;
+ }
+ if (! params.no_form_feed) { w = w + '\r\n\r\n\r\n\r\n\r\n\r\n\f'; }
+ obj.NSPrint(w, silent, params);
+ return;
+ break;
+ }
+ }
+
+ switch(content_type) {
+ case 'text/html' :
+ var jsrc = 'data:text/javascript,' + window.escape('var params = { "data" : ' + js2JSON(params.data) + ', "list" : ' + js2JSON(params.list) + '}; function my_init() { if (typeof go_print == "function") { go_print(); } else { setTimeout( function() { if (typeof go_print == "function") { alert("Please tell the developers that the 2-second go_print workaround executed, and let them know whether this job printed successfully. Thanks!"); go_print(); } else { alert("Please tell the developers that the 2-second go_print workaround did not work. We will try to print one more time; there have been reports of wasted receipt paper at this point. Please check the settings in the print dialog and/or prepare to power off your printer. Thanks!"); window.print(); } }, 2000 ); } /* FIXME - mozilla bug#301560 - xpcom kills it too */ }');
+ w = obj.win.open('data:text/html,<html id="top"><head><script src="/xul/server/main/JSAN.js"></script><script src="' + window.escape(jsrc) + '"></script></head><body onload="try{my_init();}catch(E){alert(E);}">' + window.escape(msg) + '</body></html>','receipt_temp','chrome,resizable');
+ w.minimize();
+ w.go_print = function() {
+ try {
+ obj.NSPrint(w, silent, params);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert("Print Error in util.print.simple. After this dialog we'll try a second print attempt. content_type = " + content_type,E);
+ w.print();
+ }
+ w.minimize(); w.close();
+ }
+ break;
+ default:
+ w = obj.win.open('data:' + content_type + ',' + window.escape(msg),'receipt_temp','chrome,resizable');
+ w.minimize();
+ setTimeout(
+ function() {
+ try {
+ obj.NSPrint(w, silent, params);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert("Print Error in util.print.simple. After this dialog we'll try a second print attempt. content_type = " + content_type,E);
+ w.print();
+ }
+ w.minimize(); w.close();
+ }, 1000
+ );
+ break;
+ }
+
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('util.print.simple',E);
+ }
+ },
+
+ 'tree_list' : function (params) {
+ try {
+ dump('print.tree_list.params.list = \n' + this.error.pretty_print(js2JSON(params.list)) + '\n');
+ dump('print.tree_list.params.data = \n' + this.error.pretty_print(js2JSON(params.data)) + '\n');
+ } catch(E) {
+ dump(E+'\n');
+ }
+ var cols = [];
+ var s = '';
+ if (params.header) s += this.template_sub( params.header, cols, params );
+ if (params.list) {
+ for (var i = 0; i < params.list.length; i++) {
+ params.row = params.list[i];
+ params.row_idx = i;
+ s += this.template_sub( params.line_item, cols, params );
+ }
+ }
+ if (params.footer) s += this.template_sub( params.footer, cols, params );
+
+ if (params.sample_frame) {
+ var jsrc = 'data:text/javascript,' + window.escape('var params = { "data" : ' + js2JSON(params.data) + ', "list" : ' + js2JSON(params.list) + '};');
+ params.sample_frame.setAttribute('src','data:text/html,<html id="top"><head><script src="' + window.escape(jsrc) + '"></script></head><body>' + window.escape(s) + '</body></html>');
+ } else {
+ this.simple(s,params);
+ }
+ },
+
+ 'template_sub' : function( msg, cols, params ) {
try {
if (!msg) { dump('template sub called with empty string\n'); return; }
JSAN.use('util.date');
} catch(E) {
alert('Error in print.js, template_sub(): ' + E);
}
- },
+ },
- 'NSPrint' : function(w,silent,params) {
- if (!w) w = window;
- var obj = this;
- try {
- if (!params) params = {};
+ 'NSPrint' : function(w,silent,params) {
+ if (!w) w = window;
+ var obj = this;
+ try {
+ if (!params) params = {};
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.data.init({'via':'stash'});
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.data.init({'via':'stash'});
- if (params.print_strategy || obj.data.print_strategy) {
+ if (params.print_strategy || obj.data.print_strategy) {
- switch(params.print_strategy || obj.data.print_strategy) {
- case 'dos.print':
+ switch(params.print_strategy || obj.data.print_strategy) {
+ case 'dos.print':
if (typeof w != 'string') {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- w.getSelection().selectAllChildren(w.document.firstChild);
- w = w.getSelection().toString();
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ w.getSelection().selectAllChildren(w.document.firstChild);
+ w = w.getSelection().toString();
}
- obj._NSPrint_dos_print(w,silent,params);
- break;
- case 'window.print':
- w.print();
- break;
- case 'webBrowserPrint':
- obj._NSPrint_webBrowserPrint(w,silent,params);
- break;
- default:
- //w.print();
- obj._NSPrint_webBrowserPrint(w,silent,params);
- break;
- }
-
- } else {
- //w.print();
- obj._NSPrint_webBrowserPrint(w,silent,params);
- }
-
- } catch (e) {
- alert('Probably not printing: ' + e);
- this.error.sdump('D_ERROR','PRINT EXCEPTION: ' + js2JSON(e) + '\n');
- }
-
- },
-
- '_NSPrint_dos_print' : function(w,silent,params) {
- var obj = this;
- try {
-
- /* OLD way: This is a kludge/workaround. webBrowserPrint doesn't always work. So we're going to let
- the html window handle our receipt template rendering, and then force a selection of all
- the text nodes and dump that to a file, for printing through a dos utility */
-
- /* NEW way: we just pass in the text */
-
- var text = w;
-
- var file = new util.file('receipt.txt');
- file.write_content('truncate',text);
+ obj._NSPrint_dos_print(w,silent,params);
+ break;
+ case 'window.print':
+ w.print();
+ break;
+ case 'webBrowserPrint':
+ obj._NSPrint_webBrowserPrint(w,silent,params);
+ break;
+ default:
+ //w.print();
+ obj._NSPrint_webBrowserPrint(w,silent,params);
+ break;
+ }
+
+ } else {
+ //w.print();
+ obj._NSPrint_webBrowserPrint(w,silent,params);
+ }
+
+ } catch (e) {
+ alert('Probably not printing: ' + e);
+ this.error.sdump('D_ERROR','PRINT EXCEPTION: ' + js2JSON(e) + '\n');
+ }
+
+ },
+
+ '_NSPrint_dos_print' : function(w,silent,params) {
+ var obj = this;
+ try {
+
+ /* OLD way: This is a kludge/workaround. webBrowserPrint doesn't always work. So we're going to let
+ the html window handle our receipt template rendering, and then force a selection of all
+ the text nodes and dump that to a file, for printing through a dos utility */
+
+ /* NEW way: we just pass in the text */
+
+ var text = w;
+
+ var file = new util.file('receipt.txt');
+ file.write_content('truncate',text);
var path = file._file.path;
file.close();
-
- file = new util.file('receipt.bat');
- file.write_content('truncate+exec','#!/bin/sh\ncopy "' + path + '" lpt1 /b\nlpr ' + path + '\n');
+
+ file = new util.file('receipt.bat');
+ file.write_content('truncate+exec','#!/bin/sh\ncopy "' + path + '" lpt1 /b\nlpr ' + path + '\n');
file.close();
- file = new util.file('receipt.bat');
+ file = new util.file('receipt.bat');
- var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
- process.init(file._file);
+ var process = Components.classes["@mozilla.org/process/util;1"].createInstance(Components.interfaces.nsIProcess);
+ process.init(file._file);
- var args = [];
+ var args = [];
- dump('process.run = ' + process.run(true, args, args.length) + '\n');
+ dump('process.run = ' + process.run(true, args, args.length) + '\n');
file.close();
- } catch (e) {
- //alert('Probably not printing: ' + e);
- this.error.sdump('D_ERROR','_NSPrint_dos_print PRINT EXCEPTION: ' + js2JSON(e) + '\n');
- }
- },
-
- '_NSPrint_webBrowserPrint' : function(w,silent,params) {
- var obj = this;
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var webBrowserPrint = w
- .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
- .getInterface(Components.interfaces.nsIWebBrowserPrint);
- this.error.sdump('D_PRINT','webBrowserPrint = ' + webBrowserPrint);
- if (webBrowserPrint) {
- var gPrintSettings = obj.GetPrintSettings();
- if (silent) gPrintSettings.printSilent = true;
- else gPrintSettings.printSilent = false;
- if (params) {
- if (params.marginLeft) gPrintSettings.marginLeft = params.marginLeft;
- }
- webBrowserPrint.print(gPrintSettings, null);
- this.error.sdump('D_PRINT','Should be printing\n');
- } else {
- this.error.sdump('D_ERROR','Should not be printing\n');
- }
- } catch (e) {
- //alert('Probably not printing: ' + e);
- // Pressing cancel is expressed as an NS_ERROR_ABORT return value,
- // causing an exception to be thrown which we catch here.
- // Unfortunately this will also consume helpful failures
- this.error.sdump('D_ERROR','_NSPrint_webBrowserPrint PRINT EXCEPTION: ' + js2JSON(e) + '\n');
- }
- },
-
- 'GetPrintSettings' : function() {
- try {
- //alert('entering GetPrintSettings');
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var pref = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
- //alert('pref = ' + pref);
- if (pref) {
- this.gPrintSettingsAreGlobal = pref.getBoolPref("print.use_global_printsettings", false);
- this.gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false);
- //alert('gPrintSettingsAreGlobal = ' + this.gPrintSettingsAreGlobal + ' gSavePrintSettings = ' + this.gSavePrintSettings);
- }
+ } catch (e) {
+ //alert('Probably not printing: ' + e);
+ this.error.sdump('D_ERROR','_NSPrint_dos_print PRINT EXCEPTION: ' + js2JSON(e) + '\n');
+ }
+ },
+
+ '_NSPrint_webBrowserPrint' : function(w,silent,params) {
+ var obj = this;
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var webBrowserPrint = w
+ .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIWebBrowserPrint);
+ this.error.sdump('D_PRINT','webBrowserPrint = ' + webBrowserPrint);
+ if (webBrowserPrint) {
+ var gPrintSettings = obj.GetPrintSettings();
+ if (silent) gPrintSettings.printSilent = true;
+ else gPrintSettings.printSilent = false;
+ if (params) {
+ if (params.marginLeft) gPrintSettings.marginLeft = params.marginLeft;
+ }
+ webBrowserPrint.print(gPrintSettings, null);
+ this.error.sdump('D_PRINT','Should be printing\n');
+ } else {
+ this.error.sdump('D_ERROR','Should not be printing\n');
+ }
+ } catch (e) {
+ //alert('Probably not printing: ' + e);
+ // Pressing cancel is expressed as an NS_ERROR_ABORT return value,
+ // causing an exception to be thrown which we catch here.
+ // Unfortunately this will also consume helpful failures
+ this.error.sdump('D_ERROR','_NSPrint_webBrowserPrint PRINT EXCEPTION: ' + js2JSON(e) + '\n');
+ }
+ },
+
+ 'GetPrintSettings' : function() {
+ try {
+ //alert('entering GetPrintSettings');
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var pref = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
+ //alert('pref = ' + pref);
+ if (pref) {
+ this.gPrintSettingsAreGlobal = pref.getBoolPref("print.use_global_printsettings", false);
+ this.gSavePrintSettings = pref.getBoolPref("print.save_print_settings", false);
+ //alert('gPrintSettingsAreGlobal = ' + this.gPrintSettingsAreGlobal + ' gSavePrintSettings = ' + this.gSavePrintSettings);
+ }
- var printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
- .getService(Components.interfaces.nsIPrintSettingsService);
- if (this.gPrintSettingsAreGlobal) {
- this.gPrintSettings = printService.globalPrintSettings;
- //alert('called setPrinterDefaultsForSelectedPrinter');
- this.setPrinterDefaultsForSelectedPrinter(printService);
- } else {
- this.gPrintSettings = printService.newPrintSettings;
- //alert('used printService.newPrintSettings');
- }
- } catch (e) {
- this.error.sdump('D_ERROR',"GetPrintSettings() "+e+"\n");
- //alert("GetPrintSettings() "+e+"\n");
- }
+ var printService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
+ .getService(Components.interfaces.nsIPrintSettingsService);
+ if (this.gPrintSettingsAreGlobal) {
+ this.gPrintSettings = printService.globalPrintSettings;
+ //alert('called setPrinterDefaultsForSelectedPrinter');
+ this.setPrinterDefaultsForSelectedPrinter(printService);
+ } else {
+ this.gPrintSettings = printService.newPrintSettings;
+ //alert('used printService.newPrintSettings');
+ }
+ } catch (e) {
+ this.error.sdump('D_ERROR',"GetPrintSettings() "+e+"\n");
+ //alert("GetPrintSettings() "+e+"\n");
+ }
- return this.gPrintSettings;
- },
-
- 'setPrinterDefaultsForSelectedPrinter' : function (aPrintService) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (this.gPrintSettings.printerName == "") {
- this.gPrintSettings.printerName = aPrintService.defaultPrinterName;
- //alert('used .defaultPrinterName');
- }
- //alert('printerName = ' + this.gPrintSettings.printerName);
-
- // First get any defaults from the printer
- aPrintService.initPrintSettingsFromPrinter(this.gPrintSettings.printerName, this.gPrintSettings);
-
- // now augment them with any values from last time
- aPrintService.initPrintSettingsFromPrefs(this.gPrintSettings, true, this.gPrintSettings.kInitSaveAll);
-
- // now augment from our own saved settings if they exist
- this.load_settings();
-
- } catch(E) {
- this.error.sdump('D_ERROR',"setPrinterDefaultsForSelectedPrinter() "+E+"\n");
- }
- },
-
- 'page_settings' : function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- this.GetPrintSettings();
- var PO = Components.classes["@mozilla.org/gfx/printsettings-service;1"].getService(Components.interfaces.nsIPrintOptions);
- PO.ShowPrintSetupDialog(this.gPrintSettings);
- } catch(E) {
- this.error.standard_unexpected_error_alert("page_settings()",E);
- }
- },
-
- 'load_settings' : function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var file = new util.file('gPrintSettings');
- if (file._file.exists()) {
- temp = file.get_object(); file.close();
- for (var i in temp) {
- this.gPrintSettings[i] = temp[i];
- }
- } else {
- this.gPrintSettings.marginTop = 0;
- this.gPrintSettings.marginLeft = 0;
- this.gPrintSettings.marginBottom = 0;
- this.gPrintSettings.marginRight = 0;
- this.gPrintSettings.headerStrLeft = '';
- this.gPrintSettings.headerStrCenter = '';
- this.gPrintSettings.headerStrRight = '';
- this.gPrintSettings.footerStrLeft = '';
- this.gPrintSettings.footerStrCenter = '';
- this.gPrintSettings.footerStrRight = '';
- }
- } catch(E) {
- this.error.standard_unexpected_error_alert("load_settings()",E);
- }
- },
-
- 'save_settings' : function() {
- try {
- var obj = this;
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var file = new util.file('gPrintSettings');
- if (typeof obj.gPrintSettings == 'undefined') obj.GetPrintSettings();
- if (obj.gPrintSettings) file.set_object(obj.gPrintSettings);
- file.close();
- } catch(E) {
- this.error.standard_unexpected_error_alert("save_settings()",E);
- }
- }
+ return this.gPrintSettings;
+ },
+
+ 'setPrinterDefaultsForSelectedPrinter' : function (aPrintService) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (this.gPrintSettings.printerName == "") {
+ this.gPrintSettings.printerName = aPrintService.defaultPrinterName;
+ //alert('used .defaultPrinterName');
+ }
+ //alert('printerName = ' + this.gPrintSettings.printerName);
+
+ // First get any defaults from the printer
+ aPrintService.initPrintSettingsFromPrinter(this.gPrintSettings.printerName, this.gPrintSettings);
+
+ // now augment them with any values from last time
+ aPrintService.initPrintSettingsFromPrefs(this.gPrintSettings, true, this.gPrintSettings.kInitSaveAll);
+
+ // now augment from our own saved settings if they exist
+ this.load_settings();
+
+ } catch(E) {
+ this.error.sdump('D_ERROR',"setPrinterDefaultsForSelectedPrinter() "+E+"\n");
+ }
+ },
+
+ 'page_settings' : function() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ this.GetPrintSettings();
+ var PO = Components.classes["@mozilla.org/gfx/printsettings-service;1"].getService(Components.interfaces.nsIPrintOptions);
+ PO.ShowPrintSetupDialog(this.gPrintSettings);
+ } catch(E) {
+ this.error.standard_unexpected_error_alert("page_settings()",E);
+ }
+ },
+
+ 'load_settings' : function() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var file = new util.file('gPrintSettings');
+ if (file._file.exists()) {
+ temp = file.get_object(); file.close();
+ for (var i in temp) {
+ this.gPrintSettings[i] = temp[i];
+ }
+ } else {
+ this.gPrintSettings.marginTop = 0;
+ this.gPrintSettings.marginLeft = 0;
+ this.gPrintSettings.marginBottom = 0;
+ this.gPrintSettings.marginRight = 0;
+ this.gPrintSettings.headerStrLeft = '';
+ this.gPrintSettings.headerStrCenter = '';
+ this.gPrintSettings.headerStrRight = '';
+ this.gPrintSettings.footerStrLeft = '';
+ this.gPrintSettings.footerStrCenter = '';
+ this.gPrintSettings.footerStrRight = '';
+ }
+ } catch(E) {
+ this.error.standard_unexpected_error_alert("load_settings()",E);
+ }
+ },
+
+ 'save_settings' : function() {
+ try {
+ var obj = this;
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var file = new util.file('gPrintSettings');
+ if (typeof obj.gPrintSettings == 'undefined') obj.GetPrintSettings();
+ if (obj.gPrintSettings) file.set_object(obj.gPrintSettings);
+ file.close();
+ } catch(E) {
+ this.error.standard_unexpected_error_alert("save_settings()",E);
+ }
+ }
}
dump('exiting util/print.js\n');
if (typeof util == 'undefined') util = {};
util.sound = function () {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var SOUNDContractID = "@mozilla.org/sound;1";
- var SOUNDIID = Components.interfaces.nsISound;
- this.SOUND = Components.classes[SOUNDContractID].createInstance(SOUNDIID);
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var SOUNDContractID = "@mozilla.org/sound;1";
+ var SOUNDIID = Components.interfaces.nsISound;
+ this.SOUND = Components.classes[SOUNDContractID].createInstance(SOUNDIID);
- } catch(E) {
- dump('util.sound constructor: ' + E + '\n');
- }
+ } catch(E) {
+ dump('util.sound constructor: ' + E + '\n');
+ }
- return this;
+ return this;
};
util.sound.prototype = {
- 'xp_url_init' : function (aURL) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var URLContractID = "@mozilla.org/network/standard-url;1";
- var URLIID = Components.classes[URLContractID].createInstance( );
- var URL = URLIID.QueryInterface(Components.interfaces.nsIURL);
- if (aURL) {
- URL.spec = aURL;
- }
- return URL;
- } catch(E) {
- alert('xp_url_init(): ' + E);
- }
- },
+ 'xp_url_init' : function (aURL) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var URLContractID = "@mozilla.org/network/standard-url;1";
+ var URLIID = Components.classes[URLContractID].createInstance( );
+ var URL = URLIID.QueryInterface(Components.interfaces.nsIURL);
+ if (aURL) {
+ URL.spec = aURL;
+ }
+ return URL;
+ } catch(E) {
+ alert('xp_url_init(): ' + E);
+ }
+ },
- 'play_url' : function(url) {
+ 'play_url' : function(url) {
- var obj = this;
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- var url2 = obj.xp_url_init( data.server + url );
- dump('url = ' + url2 + '\n');
- if (typeof data.no_sound == 'undefined' || data.no_sound == false || data.no_sound == 'false') obj.SOUND.play( url2 );
- } catch(E) {
- try { if (data.no_sound == 'undefined' || data.no_sound == false || data.no_sound == 'false') obj.SOUND.beep(); } catch(F) {
- dump('beep(): ' + F + '\n');
- }
- dump('play_url(): ' + E + '\n');
- }
+ var obj = this;
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ var url2 = obj.xp_url_init( data.server + url );
+ dump('url = ' + url2 + '\n');
+ if (typeof data.no_sound == 'undefined' || data.no_sound == false || data.no_sound == 'false') obj.SOUND.play( url2 );
+ } catch(E) {
+ try { if (data.no_sound == 'undefined' || data.no_sound == false || data.no_sound == 'false') obj.SOUND.beep(); } catch(F) {
+ dump('beep(): ' + F + '\n');
+ }
+ dump('play_url(): ' + E + '\n');
+ }
- },
+ },
- 'good' : function(e){
- this.play_url( urls.AUDIO_GOOD_SOUND );
- },
+ 'good' : function(e){
+ this.play_url( urls.AUDIO_GOOD_SOUND );
+ },
- 'bad' : function(e){
- this.play_url( urls.AUDIO_BAD_SOUND );
- },
+ 'bad' : function(e){
+ this.play_url( urls.AUDIO_BAD_SOUND );
+ },
- 'horrible' : function(e){
- this.play_url( urls.AUDIO_HORRIBLE_SOUND );
- },
+ 'horrible' : function(e){
+ this.play_url( urls.AUDIO_HORRIBLE_SOUND );
+ },
- 'circ_good' : function(e){
- this.play_url( urls.AUDIO_CIRC_GOOD_SOUND );
- },
+ 'circ_good' : function(e){
+ this.play_url( urls.AUDIO_CIRC_GOOD_SOUND );
+ },
- 'circ_bad' : function(e){
- this.play_url( urls.AUDIO_CIRC_BAD_SOUND );
- },
+ 'circ_bad' : function(e){
+ this.play_url( urls.AUDIO_CIRC_BAD_SOUND );
+ },
}
dump('exiting util/sound.js\n');
var pad = function(str,ch,len) { var ps='';
for(var i=0; i<Math.abs(len); i++) {
- ps+=ch;
- }
+ ps+=ch;
+ }
return len>0?str+ps:ps+str;
};
var processFlags = function(flags,width,rs,arg) {
var pn = function(flags,arg,rs) {
if(arg>=0) {
if(flags.indexOf(' ')>=0) {
- rs = ' ' + rs;
- } else if(flags.indexOf('+')>=0) {
- rs = '+' + rs;
- }
+ rs = ' ' + rs;
+ } else if(flags.indexOf('+')>=0) {
+ rs = '+' + rs;
+ }
} else {
rs = '-' + rs;
- }
+ }
return rs;
};
var iWidth = parseInt(width,10);
if(width.charAt(0) == '0') {
var ec=0;
if(flags.indexOf(' ')>=0 || flags.indexOf('+')>=0) {
- ec++;
- }
+ ec++;
+ }
if(rs.length<(iWidth-ec)) {
- rs = pad(rs,'0',rs.length-(iWidth-ec));
- }
+ rs = pad(rs,'0',rs.length-(iWidth-ec));
+ }
return pn(flags,arg,rs);
}
rs = pn(flags,arg,rs);
if(rs.length<iWidth) {
if(flags.indexOf('-')<0) {
- rs = pad(rs,' ',rs.length-iWidth);
- } else {
- rs = pad(rs,' ',iWidth - rs.length);
- }
+ rs = pad(rs,' ',rs.length-iWidth);
+ } else {
+ rs = pad(rs,' ',iWidth - rs.length);
+ }
}
return rs;
};
var converters = [];
converters.c = function(flags,width,precision,arg) {
if (typeof(arg) == 'number') {
- return String.fromCharCode(arg);
- } else if (typeof(arg) == 'string') {
- return arg.charAt(0);
- } else {
- return '';
- }
+ return String.fromCharCode(arg);
+ } else if (typeof(arg) == 'string') {
+ return arg.charAt(0);
+ } else {
+ return '';
+ }
};
converters.d = function(flags,width,precision,arg) {
return converters.i(flags,width,precision,arg);
var iPrecision=parseInt(precision, 10);
var rs = ((Math.abs(arg)).toString().split('.'))[0];
if(rs.length<iPrecision) {
- rs=pad(rs,' ',iPrecision - rs.length);
- }
+ rs=pad(rs,' ',iPrecision - rs.length);
+ }
return processFlags(flags,width,rs,arg);
};
converters.E = function(flags,width,precision,arg) {
converters.e = function(flags,width,precision,arg) {
iPrecision = parseInt(precision, 10);
if(isNaN(iPrecision)) {
- iPrecision = 6;
- }
+ iPrecision = 6;
+ }
rs = (Math.abs(arg)).toExponential(iPrecision);
if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) {
- rs = rs.replace(/^(.*)(e.*)$/,'$1.$2');
- }
+ rs = rs.replace(/^(.*)(e.*)$/,'$1.$2');
+ }
return processFlags(flags,width,rs,arg);
};
converters.f = function(flags,width,precision,arg) {
iPrecision = parseInt(precision, 10);
if(isNaN(iPrecision)) {
- iPrecision = 6;
- }
+ iPrecision = 6;
+ }
rs = (Math.abs(arg)).toFixed(iPrecision);
if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) {
- rs = rs + '.';
- }
+ rs = rs + '.';
+ }
return processFlags(flags,width,rs,arg);
};
converters.G = function(flags,width,precision,arg) {
rsf = rsfp.length < rsf.length ? rsfp : rsf;
}
if(rse.indexOf('.')<0 && flags.indexOf('#')>=0) {
- rse = rse.replace(/^(.*)(e.*)$/,'$1.$2');
- }
+ rse = rse.replace(/^(.*)(e.*)$/,'$1.$2');
+ }
if(rsf.indexOf('.')<0 && flags.indexOf('#')>=0) {
- rsf = rsf + '.';
- }
+ rsf = rsf + '.';
+ }
rs = rse.length<rsf.length ? rse : rsf;
return processFlags(flags,width,rs,arg);
};
var iPrecision=parseInt(precision, 10);
var rs = Math.round(Math.abs(arg)).toString(8);
if(rs.length<iPrecision) {
- rs=pad(rs,' ',iPrecision - rs.length);
- }
+ rs=pad(rs,' ',iPrecision - rs.length);
+ }
if(flags.indexOf('#')>=0) {
- rs='0'+rs;
- }
+ rs='0'+rs;
+ }
return processFlags(flags,width,rs,arg);
};
converters.X = function(flags,width,precision,arg) {
arg = Math.abs(arg);
var rs = Math.round(arg).toString(16);
if(rs.length<iPrecision) {
- rs=pad(rs,' ',iPrecision - rs.length);
- }
+ rs=pad(rs,' ',iPrecision - rs.length);
+ }
if(flags.indexOf('#')>=0) {
- rs='0x'+rs;
- }
+ rs='0x'+rs;
+ }
return processFlags(flags,width,rs,arg);
};
converters.s = function(flags,width,precision,arg) {
var iPrecision=parseInt(precision, 10);
var rs = arg;
if(rs.length > iPrecision) {
- rs = rs.substring(0,iPrecision);
- }
+ rs = rs.substring(0,iPrecision);
+ }
return processFlags(flags,width,rs,0);
};
for(var i = 1; i<farr.length; i++) {
fps=fpRE.exec(farr[i]);
if(!fps) {
- continue;
- }
- var my_i = fps[2] ? fps[2] : i;
+ continue;
+ }
+ var my_i = fps[2] ? fps[2] : i;
if(arguments[my_i-1]) {
retstr+=converters[fps[5]](fps[1],fps[3],fps[4],arguments[my_i-1]);
}
if (typeof util == 'undefined') var util = {};
util.text = {};
-util.text.EXPORT_OK = [
- 'wrap_on_space', 'preserve_string_in_html',
+util.text.EXPORT_OK = [
+ 'wrap_on_space', 'preserve_string_in_html',
];
-util.text.EXPORT_TAGS = { ':all' : util.text.EXPORT_OK };
+util.text.EXPORT_TAGS = { ':all' : util.text.EXPORT_OK };
util.text.wrap_on_space = function( text, length ) {
- try {
+ try {
- if (String(text).length <= length) return [ text, '' ];
+ if (String(text).length <= length) return [ text, '' ];
- var truncated_text = String(text).substr(0,length);
+ var truncated_text = String(text).substr(0,length);
- var pivot_pos = truncated_text.lastIndexOf(' ');
+ var pivot_pos = truncated_text.lastIndexOf(' ');
- return [ text.substr(0,pivot_pos).replace(/\s*$/,''), String(text).substr(pivot_pos+1) ];
+ return [ text.substr(0,pivot_pos).replace(/\s*$/,''), String(text).substr(pivot_pos+1) ];
- } catch(E) {
- alert('FIXME: util.text.wrap_on_space( "' + text + '", ' + length + ")");
- return [ String(text).substr(0,length), String(text).substr(length) ];
- }
+ } catch(E) {
+ alert('FIXME: util.text.wrap_on_space( "' + text + '", ' + length + ")");
+ return [ String(text).substr(0,length), String(text).substr(length) ];
+ }
}
util.text.preserve_string_in_html = function( text ) {
- text = text.replace(/&/g,'&');
- text = text.replace(/"/g,'"');
- text = text.replace(/'/g,''');
- text = text.replace(/ /g,' ');
- text = text.replace(/</g,'<');
- text = text.replace(/>/g,'>');
- return text;
+ text = text.replace(/&/g,'&');
+ text = text.replace(/"/g,'"');
+ text = text.replace(/'/g,''');
+ text = text.replace(/ /g,' ');
+ text = text.replace(/</g,'<');
+ text = text.replace(/>/g,'>');
+ return text;
}
dump('exiting util/text.js\n');
if (typeof util == 'undefined') var util = {};
util.widgets = {};
-util.widgets.EXPORT_OK = [
- 'get',
- 'apply',
- 'save_xml',
- 'serialize_node',
- 'xul_from_string',
- 'store_disable',
- 'restore_disable',
- 'disable',
- 'get_list_from_tree_selection',
- 'disable_accesskeys_in_node_and_children',
- 'enable_accesskeys_in_node_and_children',
- 'remove_children',
- 'make_grid',
- 'make_menulist',
- 'insertAfter',
- 'apply_vertical_tab_on_enter_handler',
- 'vertical_tab',
- 'click',
- 'dispatch',
- 'stop_event',
- 'set_text',
- 'save_attributes',
- 'load_attributes',
+util.widgets.EXPORT_OK = [
+ 'get',
+ 'apply',
+ 'save_xml',
+ 'serialize_node',
+ 'xul_from_string',
+ 'store_disable',
+ 'restore_disable',
+ 'disable',
+ 'get_list_from_tree_selection',
+ 'disable_accesskeys_in_node_and_children',
+ 'enable_accesskeys_in_node_and_children',
+ 'remove_children',
+ 'make_grid',
+ 'make_menulist',
+ 'insertAfter',
+ 'apply_vertical_tab_on_enter_handler',
+ 'vertical_tab',
+ 'click',
+ 'dispatch',
+ 'stop_event',
+ 'set_text',
+ 'save_attributes',
+ 'load_attributes',
];
-util.widgets.EXPORT_TAGS = { ':all' : util.widgets.EXPORT_OK };
+util.widgets.EXPORT_TAGS = { ':all' : util.widgets.EXPORT_OK };
util.widgets.get = function(e) {
- if (typeof e == 'object') {
- return e;
- } else {
- return document.getElementById(e);
- }
+ if (typeof e == 'object') {
+ return e;
+ } else {
+ return document.getElementById(e);
+ }
}
util.widgets.apply = function(e,attr,attr_value,f) {
- var node = util.widgets.get(e);
- var nl = node.getElementsByAttribute(attr,attr_value);
- for (var i = 0; i < nl.length; i++) {
- f( nl[i] );
- }
+ var node = util.widgets.get(e);
+ var nl = node.getElementsByAttribute(attr,attr_value);
+ for (var i = 0; i < nl.length; i++) {
+ f( nl[i] );
+ }
}
util.widgets.save_xml = function (filename,node) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.file'); var file = new util.file(filename);
+ JSAN.use('util.file'); var file = new util.file(filename);
- node = util.widgets.get(node);
- var xml = util.widgets.serialize_node(node);
+ node = util.widgets.get(node);
+ var xml = util.widgets.serialize_node(node);
- file.write_content('truncate',xml);
- file.close();
- } catch(E) {
- alert('Error in util.widgets.save_xml: ' + E);
- }
+ file.write_content('truncate',xml);
+ file.close();
+ } catch(E) {
+ alert('Error in util.widgets.save_xml: ' + E);
+ }
}
util.widgets.serialize_node = function(node) {
- var serializer = new XMLSerializer();
- var xml = serializer.serializeToString(node);
- return xml;
+ var serializer = new XMLSerializer();
+ var xml = serializer.serializeToString(node);
+ return xml;
}
util.widgets.xul_from_string = function(xml) {
- var parser = new DOMParser();
- var doc = parser.parseFromString(xml, "text/xml");
- var node = doc.documentElement;
- return node;
+ var parser = new DOMParser();
+ var doc = parser.parseFromString(xml, "text/xml");
+ var node = doc.documentElement;
+ return node;
}
util.widgets.store_disable = function() {
- for (var i = 0; i < arguments.length; i++) {
- var e = util.widgets.get( arguments[i] );
- e.setAttribute('_disabled',e.getAttribute('disabled'));
- }
+ for (var i = 0; i < arguments.length; i++) {
+ var e = util.widgets.get( arguments[i] );
+ e.setAttribute('_disabled',e.getAttribute('disabled'));
+ }
}
util.widgets.restore_disable = function() {
- for (var i = 0; i < arguments.length; i++) {
- var e = util.widgets.get( arguments[i] );
- e.setAttribute('disabled',e.getAttribute('_disabled'));
- }
+ for (var i = 0; i < arguments.length; i++) {
+ var e = util.widgets.get( arguments[i] );
+ e.setAttribute('disabled',e.getAttribute('_disabled'));
+ }
}
util.widgets.disable = function() {
- for (var i = 0; i < arguments.length; i++) {
- var e = util.widgets.get( arguments[i] );
- e.setAttribute('disabled',true);
- }
+ for (var i = 0; i < arguments.length; i++) {
+ var e = util.widgets.get( arguments[i] );
+ e.setAttribute('disabled',true);
+ }
}
util.widgets.click = function(e) {
- var evt = document.createEvent("MouseEvent");
- evt.initMouseEvent( "click", true, true, window, 0, 0, 0, 0, 0, false,false,false,false,0,null);
- util.widgets.get(e).dispatchEvent(evt);
+ var evt = document.createEvent("MouseEvent");
+ evt.initMouseEvent( "click", true, true, window, 0, 0, 0, 0, 0, false,false,false,false,0,null);
+ util.widgets.get(e).dispatchEvent(evt);
}
util.widgets.dispatch = function(ev,el) {
- var evt = document.createEvent("Events");
- //var evt = document.createEvent();
- evt.initEvent( ev, true, true );
- util.widgets.get(el).dispatchEvent(evt);
+ var evt = document.createEvent("Events");
+ //var evt = document.createEvent();
+ evt.initEvent( ev, true, true );
+ util.widgets.get(el).dispatchEvent(evt);
}
util.widgets.make_menulist = function( items, dvalue ) {
- var menulist = document.createElement('menulist');
- var menupopup = document.createElement('menupopup'); menulist.appendChild(menupopup);
- for (var i = 0; i < items.length; i++) {
- var label = items[i][0]; var value = items[i][1]; var disabled = items[i][2]; var indent = items[i][3];
- if (indent) {
- for (var j = 0; j < Number(indent); j++) {
- //label = ' ' + label;
- }
- }
- var menuitem = document.createElement('menuitem'); menupopup.appendChild(menuitem);
- menuitem.setAttribute('label',label);
- menuitem.setAttribute('value',value);
- if (indent) {
- menuitem.setAttribute('style','font-family: monospace; padding-left: ' + indent + 'em;');
- } else {
- menuitem.setAttribute('style','font-family: monospace;');
- }
- if ( (disabled == true) || (disabled == "true") ) {
- menuitem.disabled = true;
- menuitem.setAttribute('disabled','true');
- }
- }
- menulist.setAttribute('value',dvalue);
- return menulist;
+ var menulist = document.createElement('menulist');
+ var menupopup = document.createElement('menupopup'); menulist.appendChild(menupopup);
+ for (var i = 0; i < items.length; i++) {
+ var label = items[i][0]; var value = items[i][1]; var disabled = items[i][2]; var indent = items[i][3];
+ if (indent) {
+ for (var j = 0; j < Number(indent); j++) {
+ //label = ' ' + label;
+ }
+ }
+ var menuitem = document.createElement('menuitem'); menupopup.appendChild(menuitem);
+ menuitem.setAttribute('label',label);
+ menuitem.setAttribute('value',value);
+ if (indent) {
+ menuitem.setAttribute('style','font-family: monospace; padding-left: ' + indent + 'em;');
+ } else {
+ menuitem.setAttribute('style','font-family: monospace;');
+ }
+ if ( (disabled == true) || (disabled == "true") ) {
+ menuitem.disabled = true;
+ menuitem.setAttribute('disabled','true');
+ }
+ }
+ menulist.setAttribute('value',dvalue);
+ return menulist;
}
util.widgets.make_grid = function( cols ) {
- var grid = document.createElement('grid');
- var columns = document.createElement('columns'); grid.appendChild(columns);
- for (var i = 0; i < cols.length; i++) {
- var column = document.createElement('column'); columns.appendChild(column);
- for (var j in cols[i]) {
- column.setAttribute(j,cols[i][j]);
- }
- }
- var rows = document.createElement('rows'); grid.appendChild(rows);
- return grid;
+ var grid = document.createElement('grid');
+ var columns = document.createElement('columns'); grid.appendChild(columns);
+ for (var i = 0; i < cols.length; i++) {
+ var column = document.createElement('column'); columns.appendChild(column);
+ for (var j in cols[i]) {
+ column.setAttribute(j,cols[i][j]);
+ }
+ }
+ var rows = document.createElement('rows'); grid.appendChild(rows);
+ return grid;
}
util.widgets.get_list_from_tree_selection = function(tree_w) {
- var hitlist;
- var tree = util.widgets.get(tree_w);
- var list = [];
- var start = new Object();
- var end = new Object();
- var numRanges = tree.view.selection.getRangeCount();
- for (var t=0; t<numRanges; t++){
- tree.view.selection.getRangeAt(t,start,end);
- for (var v=start.value; v<=end.value; v++){
- var i = tree.contentView.getItemAtIndex(v);
- list.push( i );
- }
- }
- return list;
+ var hitlist;
+ var tree = util.widgets.get(tree_w);
+ var list = [];
+ var start = new Object();
+ var end = new Object();
+ var numRanges = tree.view.selection.getRangeCount();
+ for (var t=0; t<numRanges; t++){
+ tree.view.selection.getRangeAt(t,start,end);
+ for (var v=start.value; v<=end.value; v++){
+ var i = tree.contentView.getItemAtIndex(v);
+ list.push( i );
+ }
+ }
+ return list;
}
util.widgets.remove_children = function() {
- for (var i = 0; i < arguments.length; i++) {
- var e = util.widgets.get( arguments[i] );
- while(e.lastChild) e.removeChild( e.lastChild );
- }
+ for (var i = 0; i < arguments.length; i++) {
+ var e = util.widgets.get( arguments[i] );
+ while(e.lastChild) e.removeChild( e.lastChild );
+ }
}
util.widgets.disable_accesskeys_in_node_and_children = function( node ) {
- return; /* what was I doing here? */
- if (node.getAttribute('accesskey')) {
- node.setAttribute('oldaccesskey', node.getAttribute('accesskey'));
- node.setAttribute('accesskey',''); node.accessKey = '';
- }
- for (var i = 0; i < node.childNodes.length; i++) {
- util.widgets.disable_accesskeys_in_node_and_children( node.childNodes[i] );
- }
- dump('- node = <' + node.id + '> accesskey = <' + node.accessKey + '> accesskey = <' + node.getAttribute('accesskey') + '> oldaccesskey = <' + node.getAttribute('oldaccesskey') + '>\n');
+ return; /* what was I doing here? */
+ if (node.getAttribute('accesskey')) {
+ node.setAttribute('oldaccesskey', node.getAttribute('accesskey'));
+ node.setAttribute('accesskey',''); node.accessKey = '';
+ }
+ for (var i = 0; i < node.childNodes.length; i++) {
+ util.widgets.disable_accesskeys_in_node_and_children( node.childNodes[i] );
+ }
+ dump('- node = <' + node.id + '> accesskey = <' + node.accessKey + '> accesskey = <' + node.getAttribute('accesskey') + '> oldaccesskey = <' + node.getAttribute('oldaccesskey') + '>\n');
}
util.widgets.enable_accesskeys_in_node_and_children = function( node ) {
- return; /* what was I doing here? */
- if (node.getAttribute('oldaccesskey')) {
- node.setAttribute('accesskey', node.getAttribute('oldaccesskey'));
- node.accessKey = node.getAttribute('oldaccesskey');
- node.setAttribute('oldaccesskey','');
- }
- for (var i = 0; i < node.childNodes.length; i++) {
- util.widgets.enable_accesskeys_in_node_and_children( node.childNodes[i] );
- }
- dump('+ node = <' + node.id + '> accesskey = <' + node.accessKey + '> accesskey = <' + node.getAttribute('accesskey') + '> oldaccesskey = <' + node.getAttribute('oldaccesskey') + '>\n');
+ return; /* what was I doing here? */
+ if (node.getAttribute('oldaccesskey')) {
+ node.setAttribute('accesskey', node.getAttribute('oldaccesskey'));
+ node.accessKey = node.getAttribute('oldaccesskey');
+ node.setAttribute('oldaccesskey','');
+ }
+ for (var i = 0; i < node.childNodes.length; i++) {
+ util.widgets.enable_accesskeys_in_node_and_children( node.childNodes[i] );
+ }
+ dump('+ node = <' + node.id + '> accesskey = <' + node.accessKey + '> accesskey = <' + node.getAttribute('accesskey') + '> oldaccesskey = <' + node.getAttribute('oldaccesskey') + '>\n');
}
util.widgets.insertAfter = function(parent_node,new_node,sibling_node) {
- sibling_node = sibling_node.nextSibling;
- if (sibling_node) {
- parent_node.insertBefore(new_node,sibling_node);
- } else {
- parent_node.appendChild(new_node);
- }
+ sibling_node = sibling_node.nextSibling;
+ if (sibling_node) {
+ parent_node.insertBefore(new_node,sibling_node);
+ } else {
+ parent_node.appendChild(new_node);
+ }
}
util.widgets.apply_vertical_tab_on_enter_handler = function(node,onfailure) {
- try {
- node.addEventListener(
- 'keypress',
- function(ev) {
- dump('keypress: ev.target.tagName = ' + ev.target.tagName
- + ' ev.target.nodeName = ' + ev.target.nodeName
- + ' ev.keyCode = ' + ev.keyCode
- + ' ev.charCode = ' + ev.charCode + '\n');
- if (ev.keyCode == 13) {
- dump('trying vertical tab\n');
- if (util.widgets.vertical_tab(ev.target)) {
- ev.preventDefault(); ev.stopPropagation();
- return true;
- } else {
- if (typeof onfailure == 'function') return onfailure(ev);
- return false;
- }
- }
- },
- false
- );
- } catch(E) {
- alert(E);
- }
+ try {
+ node.addEventListener(
+ 'keypress',
+ function(ev) {
+ dump('keypress: ev.target.tagName = ' + ev.target.tagName
+ + ' ev.target.nodeName = ' + ev.target.nodeName
+ + ' ev.keyCode = ' + ev.keyCode
+ + ' ev.charCode = ' + ev.charCode + '\n');
+ if (ev.keyCode == 13) {
+ dump('trying vertical tab\n');
+ if (util.widgets.vertical_tab(ev.target)) {
+ ev.preventDefault(); ev.stopPropagation();
+ return true;
+ } else {
+ if (typeof onfailure == 'function') return onfailure(ev);
+ return false;
+ }
+ }
+ },
+ false
+ );
+ } catch(E) {
+ alert(E);
+ }
}
util.widgets.vertical_tab = function(node) {
- try {
- var rel_vert_pos = node.getAttribute('rel_vert_pos') || 0;
- dump('vertical_tab -> node = ' + node.nodeName + ' rel_vert_pos = ' + rel_vert_pos + '\n');
+ try {
+ var rel_vert_pos = node.getAttribute('rel_vert_pos') || 0;
+ dump('vertical_tab -> node = ' + node.nodeName + ' rel_vert_pos = ' + rel_vert_pos + '\n');
- var nl = document.getElementsByTagName( node.nodeName );
+ var nl = document.getElementsByTagName( node.nodeName );
- var found_self = false; var next_node; var max_rel_vert_pos = 0;
- for (var i = 0; i < nl.length; i++) {
+ var found_self = false; var next_node; var max_rel_vert_pos = 0;
+ for (var i = 0; i < nl.length; i++) {
- var candidate_node = nl[i];
- var test_rel_vert_pos = candidate_node.getAttribute('rel_vert_pos') || 0;
+ var candidate_node = nl[i];
+ var test_rel_vert_pos = candidate_node.getAttribute('rel_vert_pos') || 0;
- if (found_self && !next_node && (test_rel_vert_pos == rel_vert_pos) && !candidate_node.disabled) {
-
- next_node = candidate_node;
+ if (found_self && !next_node && (test_rel_vert_pos == rel_vert_pos) && !candidate_node.disabled) {
+
+ next_node = candidate_node;
- }
- if (candidate_node == node) found_self = true;
+ }
+ if (candidate_node == node) found_self = true;
- if (test_rel_vert_pos > max_rel_vert_pos) max_rel_vert_pos = test_rel_vert_pos;
- }
+ if (test_rel_vert_pos > max_rel_vert_pos) max_rel_vert_pos = test_rel_vert_pos;
+ }
- dump('intermediate: next_node = ' + next_node + ' max_rel_vert_pos = ' + max_rel_vert_pos + '\n');
+ dump('intermediate: next_node = ' + next_node + ' max_rel_vert_pos = ' + max_rel_vert_pos + '\n');
- if (!next_node) {
+ if (!next_node) {
- found_self = false;
- for (var next_pos = rel_vert_pos; next_pos <= max_rel_vert_pos; next_pos++) {
+ found_self = false;
+ for (var next_pos = rel_vert_pos; next_pos <= max_rel_vert_pos; next_pos++) {
- for (var i = 0; i < nl.length; i++) {
- var candidate_node = nl[i];
- var test_rel_vert_pos = candidate_node.getAttribute('rel_vert_pos') || 0;
+ for (var i = 0; i < nl.length; i++) {
+ var candidate_node = nl[i];
+ var test_rel_vert_pos = candidate_node.getAttribute('rel_vert_pos') || 0;
- if (found_self && !next_node && (test_rel_vert_pos == next_pos) && !candidate_node.disabled ) {
- next_node = candidate_node;
- }
+ if (found_self && !next_node && (test_rel_vert_pos == next_pos) && !candidate_node.disabled ) {
+ next_node = candidate_node;
+ }
- if (candidate_node == node) found_self = true;
- }
+ if (candidate_node == node) found_self = true;
+ }
- }
+ }
- }
+ }
- if (next_node) {
- dump('focusing\n');
- next_node.focus();
- }
- return next_node;
- } catch(E) {
- alert(E);
- }
+ if (next_node) {
+ dump('focusing\n');
+ next_node.focus();
+ }
+ return next_node;
+ } catch(E) {
+ alert(E);
+ }
}
util.widgets.stop_event = function(ev) {
- ev.preventDefault();
- return false;
+ ev.preventDefault();
+ return false;
}
util.widgets.set_text = function(n,t) {
- n = util.widgets.get(n);
- switch(n.nodeName) {
- case 'button' :
- case 'caption' :
- n.setAttribute('label',t);
- break;
- case 'label' :
- n.setAttribute('value',t);
- break;
- case 'description' :
- case 'H1': case 'H2': case 'H3': case 'H4': case 'SPAN': case 'P': case 'BLOCKQUOTE':
- util.widgets.remove_children(n);
- n.appendChild( document.createTextNode(t) );
- break;
- case 'textbox' :
- n.value = t; n.setAttribute('value',t);
- break;
- default:
- alert("FIXME: util.widgets.set_text doesn't know how to handle " + n.nodeName);
- break;
- }
+ n = util.widgets.get(n);
+ switch(n.nodeName) {
+ case 'button' :
+ case 'caption' :
+ n.setAttribute('label',t);
+ break;
+ case 'label' :
+ n.setAttribute('value',t);
+ break;
+ case 'description' :
+ case 'H1': case 'H2': case 'H3': case 'H4': case 'SPAN': case 'P': case 'BLOCKQUOTE':
+ util.widgets.remove_children(n);
+ n.appendChild( document.createTextNode(t) );
+ break;
+ case 'textbox' :
+ n.value = t; n.setAttribute('value',t);
+ break;
+ default:
+ alert("FIXME: util.widgets.set_text doesn't know how to handle " + n.nodeName);
+ break;
+ }
}
util.widgets.get_text = function(n) {
- n = util.widgets.get(n);
- switch(n.nodeName) {
- case 'button' :
- case 'caption' :
- return n.getAttribute('label');
- break;
- case 'label' :
- return n.getAttribute('value');
- break;
- case 'description' :
- case 'H1': case 'H2': case 'H3': case 'H4': case 'SPAN': case 'P': case 'BLOCKQUOTE':
- return n.textContent;
- break;
- case 'textbox' :
- return n.value;
- break;
- default:
- alert("FIXME: util.widgets.get_text doesn't know how to handle " + n.nodeName);
+ n = util.widgets.get(n);
+ switch(n.nodeName) {
+ case 'button' :
+ case 'caption' :
+ return n.getAttribute('label');
+ break;
+ case 'label' :
+ return n.getAttribute('value');
+ break;
+ case 'description' :
+ case 'H1': case 'H2': case 'H3': case 'H4': case 'SPAN': case 'P': case 'BLOCKQUOTE':
+ return n.textContent;
+ break;
+ case 'textbox' :
+ return n.value;
+ break;
+ default:
+ alert("FIXME: util.widgets.get_text doesn't know how to handle " + n.nodeName);
return null;
- break;
- }
+ break;
+ }
}
util.widgets.save_attributes = function (file,ids_attrs) {
- try {
- var blob = {};
- for (var element_id in ids_attrs) {
- var attribute_list = ids_attrs[ element_id ];
- if (! blob[ element_id ] ) blob[ element_id ] = {};
+ try {
+ var blob = {};
+ for (var element_id in ids_attrs) {
+ var attribute_list = ids_attrs[ element_id ];
+ if (! blob[ element_id ] ) blob[ element_id ] = {};
var x = document.getElementById( element_id );
if (x) {
for (var j = 0; j < attribute_list.length; j++) {
dump('Error in util.widgets.save_attributes('+file._file.path+','+js2JSON(ids_attrs)+'):\n');
dump('\telement_id = ' + element_id + '\n');
}
- }
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- //FIXME - WHY DOES THIS NOT WORK?// JSAN.use('util.file'); var file = new util.file(filename);
- file.set_object(blob); file.close();
- } catch(E) {
- alert('Error saving preferences: ' + E);
- }
+ }
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ //FIXME - WHY DOES THIS NOT WORK?// JSAN.use('util.file'); var file = new util.file(filename);
+ file.set_object(blob); file.close();
+ } catch(E) {
+ alert('Error saving preferences: ' + E);
+ }
}
-util.widgets.load_attributes = function (file) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- //FIXME - WHY DOES THIS NOT WORK?// JSAN.use('util.file'); var file = new util.file(filename);
- if (file._file.exists()) {
- var blob = file.get_object(); file.close();
- for (var element_id in blob) {
- for (var attribute in blob[ element_id ]) {
- var x = document.getElementById( element_id );
- if (x) {
- if (x.nodeName == 'menulist' && attribute == 'value') {
- var popup = x.firstChild;
- var children = popup.childNodes;
- for (var i = 0; i < children.length; i++) {
- if (children[i].getAttribute('value') == blob[ element_id ][ attribute ]) {
- dump('setting ' + x.nodeName + ' ' + element_id + ' @value to ' + blob[ element_id ][ attribute ] + '\n' );
- x.setAttribute(attribute, blob[ element_id ][ attribute ]);
- }
- }
- } else {
- dump('setting ' + x.nodeName + ' ' + element_id + ' @value to ' + blob[ element_id ][ attribute ] + '\n');
- x.setAttribute(attribute, blob[ element_id ][ attribute ]);
- }
- } else {
- dump('Error in util.widgets.load_attributes('+file._file.path+'):\n');
- dump('\telement_id = ' + element_id + '\n');
- dump('\tattribute = ' + attribute + '\n');
- dump('\tblob[id][attr] = ' + blob[element_id][attribute] + '\n');
- }
- }
- }
- return blob;
- }
- return {};
- } catch(E) {
- alert('Error loading preferences: ' + E);
- }
+util.widgets.load_attributes = function (file) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ //FIXME - WHY DOES THIS NOT WORK?// JSAN.use('util.file'); var file = new util.file(filename);
+ if (file._file.exists()) {
+ var blob = file.get_object(); file.close();
+ for (var element_id in blob) {
+ for (var attribute in blob[ element_id ]) {
+ var x = document.getElementById( element_id );
+ if (x) {
+ if (x.nodeName == 'menulist' && attribute == 'value') {
+ var popup = x.firstChild;
+ var children = popup.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].getAttribute('value') == blob[ element_id ][ attribute ]) {
+ dump('setting ' + x.nodeName + ' ' + element_id + ' @value to ' + blob[ element_id ][ attribute ] + '\n' );
+ x.setAttribute(attribute, blob[ element_id ][ attribute ]);
+ }
+ }
+ } else {
+ dump('setting ' + x.nodeName + ' ' + element_id + ' @value to ' + blob[ element_id ][ attribute ] + '\n');
+ x.setAttribute(attribute, blob[ element_id ][ attribute ]);
+ }
+ } else {
+ dump('Error in util.widgets.load_attributes('+file._file.path+'):\n');
+ dump('\telement_id = ' + element_id + '\n');
+ dump('\tattribute = ' + attribute + '\n');
+ dump('\tblob[id][attr] = ' + blob[element_id][attribute] + '\n');
+ }
+ }
+ }
+ return blob;
+ }
+ return {};
+ } catch(E) {
+ alert('Error loading preferences: ' + E);
+ }
}
dump('exiting util/widgets.js\n');
if (typeof util == 'undefined') util = {};
util.window = function () {
- JSAN.use('util.error'); this.error = new util.error(); this.win = window;
- return this;
+ JSAN.use('util.error'); this.error = new util.error(); this.win = window;
+ return this;
};
util.window.prototype = {
-
- // list of open window references, used for debugging in shell
- 'win_list' : [],
+
+ // list of open window references, used for debugging in shell
+ 'win_list' : [],
- // list of Top Level menu interface window references
- 'appshell_list' : [],
+ // list of Top Level menu interface window references
+ 'appshell_list' : [],
- // list of documents for debugging. BROKEN
- 'doc_list' : [],
+ // list of documents for debugging. BROKEN
+ 'doc_list' : [],
- // Windows need unique names. This number helps.
- 'window_name_increment' : function() {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- if (typeof data.window_name_increment == 'undefined') {
- data.window_name_increment = 1;
- } else {
- data.window_name_increment++;
- }
- data.stash('window_name_increment');
- return data.window_name_increment;
- },
+ // Windows need unique names. This number helps.
+ 'window_name_increment' : function() {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ if (typeof data.window_name_increment == 'undefined') {
+ data.window_name_increment = 1;
+ } else {
+ data.window_name_increment++;
+ }
+ data.stash('window_name_increment');
+ return data.window_name_increment;
+ },
- // This number gets put into the title bar for Top Level menu interface windows
- 'appshell_name_increment' : function() {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- if (typeof data.appshell_name_increment == 'undefined') {
- data.appshell_name_increment = 1;
- } else {
- data.appshell_name_increment++;
- }
- data.stash('appshell_name_increment');
- return data.appshell_name_increment;
- },
+ // This number gets put into the title bar for Top Level menu interface windows
+ 'appshell_name_increment' : function() {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ if (typeof data.appshell_name_increment == 'undefined') {
+ data.appshell_name_increment = 1;
+ } else {
+ data.appshell_name_increment++;
+ }
+ data.stash('appshell_name_increment');
+ return data.appshell_name_increment;
+ },
- // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
- // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
- // Modified by Jason for Evergreen
- 'SafeWindowOpen' : function (url,title,features) {
- var w;
+ // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
+ // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
+ // Modified by Jason for Evergreen
+ 'SafeWindowOpen' : function (url,title,features) {
+ var w;
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead");
- netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
- netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
- netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead");
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
- const CI = Components.interfaces;
- const PB = Components.classes["@mozilla.org/preferences-service;1"].getService(CI.nsIPrefBranch);
+ const CI = Components.interfaces;
+ const PB = Components.classes["@mozilla.org/preferences-service;1"].getService(CI.nsIPrefBranch);
- var blocked = false;
- try {
- // pref 'dom.disable_open_during_load' is the main popup blocker preference
- blocked = PB.getBoolPref("dom.disable_open_during_load");
- if(blocked) PB.setBoolPref("dom.disable_open_during_load",false);
- w = this.win.open(url,title,features);
- } catch(E) {
- this.error.sdump('D_ERROR','window.SafeWindowOpen: ' + E + '\n');
- throw(E);
- }
- if(blocked) PB.setBoolPref("dom.disable_open_during_load",true);
+ var blocked = false;
+ try {
+ // pref 'dom.disable_open_during_load' is the main popup blocker preference
+ blocked = PB.getBoolPref("dom.disable_open_during_load");
+ if(blocked) PB.setBoolPref("dom.disable_open_during_load",false);
+ w = this.win.open(url,title,features);
+ } catch(E) {
+ this.error.sdump('D_ERROR','window.SafeWindowOpen: ' + E + '\n');
+ throw(E);
+ }
+ if(blocked) PB.setBoolPref("dom.disable_open_during_load",true);
- return w;
- },
+ return w;
+ },
- 'open' : function(url,title,features,my_xulG) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var key;
- if (!title) title = 'anon' + this.window_name_increment();
- if (!features) features = 'chrome';
- this.error.sdump('D_WIN', 'opening ' + url + ', ' + title + ', ' + features + ' from ' + this.win + '\n');
- var data;
- if (features.match(/modal/) && my_xulG) {
- JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.init({'via':'stash'});
- if (typeof data.modal_xulG_stack == 'undefined') data.modal_xulG_stack = {};
- /* FIXME - not a perfect key.. could imagine two top-level windows both opening modal windows */
- key = url;
- if (typeof xulG == 'object') {
+ 'open' : function(url,title,features,my_xulG) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var key;
+ if (!title) title = 'anon' + this.window_name_increment();
+ if (!features) features = 'chrome';
+ this.error.sdump('D_WIN', 'opening ' + url + ', ' + title + ', ' + features + ' from ' + this.win + '\n');
+ var data;
+ if (features.match(/modal/) && my_xulG) {
+ JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.init({'via':'stash'});
+ if (typeof data.modal_xulG_stack == 'undefined') data.modal_xulG_stack = {};
+ /* FIXME - not a perfect key.. could imagine two top-level windows both opening modal windows */
+ key = url;
+ if (typeof xulG == 'object') {
if (typeof xulG.url_prefix == 'function') {
- key = key.replace( xulG.url_prefix('/'), '/' );
- }
+ key = key.replace( xulG.url_prefix('/'), '/' );
+ }
} else if (typeof url_prefix == 'function') {
- key = key.replace( url_prefix('/'), '/' );
+ key = key.replace( url_prefix('/'), '/' );
}
- if (typeof data.modal_xulG_stack[key] == 'undefined') data.modal_xulG_stack[key] = [];
- data.modal_xulG_stack[key].push( my_xulG );
- data.stash('modal_xulG_stack');
- this.error.sdump('D_WIN','modal key = ' + key);
- }
- var w = this.SafeWindowOpen(url,title,features);
- if (features.match(/modal/) && my_xulG) {
+ if (typeof data.modal_xulG_stack[key] == 'undefined') data.modal_xulG_stack[key] = [];
+ data.modal_xulG_stack[key].push( my_xulG );
+ data.stash('modal_xulG_stack');
+ this.error.sdump('D_WIN','modal key = ' + key);
+ }
+ var w = this.SafeWindowOpen(url,title,features);
+ if (features.match(/modal/) && my_xulG) {
data.init({'via':'stash'});
- var x = data.modal_xulG_stack[key].pop();
- data.stash('modal_xulG_stack');
- return x;
- } else {
- if (my_xulG) {
- if (get_contentWindow(w)) {
- get_contentWindow(w).xulG = my_xulG;
- } else {
- w.xulG = my_xulG;
- }
- }
- }
- /*
- setTimeout(
- function() {
- try { w.title = title; } catch(E) { dump('**'+E+'\n'); }
- try { w.document.title = title; } catch(E) { dump('**'+E+'\n'); }
- }, 0
- );
- */
- return w;
- }
+ var x = data.modal_xulG_stack[key].pop();
+ data.stash('modal_xulG_stack');
+ return x;
+ } else {
+ if (my_xulG) {
+ if (get_contentWindow(w)) {
+ get_contentWindow(w).xulG = my_xulG;
+ } else {
+ w.xulG = my_xulG;
+ }
+ }
+ }
+ /*
+ setTimeout(
+ function() {
+ try { w.title = title; } catch(E) { dump('**'+E+'\n'); }
+ try { w.document.title = title; } catch(E) { dump('**'+E+'\n'); }
+ }, 0
+ );
+ */
+ return w;
+ }
}
dump('exiting util/window.js\n');
OpenILS.prototype = {
help: function () {
- dump("Ah ha! This xpcom isn't really 'xp'. We make use of the .wrappedJSObject method to get a truly global place to stick data.\n");
+ dump("Ah ha! This xpcom isn't really 'xp'. We make use of the .wrappedJSObject method to get a truly global place to stick data.\n");
},
data: {},
if (typeof example == 'undefined') example = {};
example.template = function (params) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.error'); this.error = new util.error();
- } catch(E) {
- dump('example.template: ' + E + '\n');
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.error'); this.error = new util.error();
+ } catch(E) {
+ dump('example.template: ' + E + '\n');
+ }
}
example.template.prototype = {
- 'init' : function( params ) {
-
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-
- var obj = this;
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'cmd_broken' : [
- ['command'],
- function() { alert('Not Yet Implemented'); }
- ],
- }
- }
- );
-
- } catch(E) {
- this.error.sdump('D_ERROR','example.template.init: ' + E + '\n');
- }
- },
+ 'init' : function( params ) {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+ var obj = this;
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert('Not Yet Implemented'); }
+ ],
+ }
+ }
+ );
+
+ } catch(E) {
+ this.error.sdump('D_ERROR','example.template.init: ' + E + '\n');
+ }
+ },
}
dump('exiting example.template.js\n');
function debug(str) { try { dump(str + '\n'); } catch(e){} }
function fetchUser(session) {
- if(session == null ) {
- cgi = new CGI();
- session = cgi.param('ses');
- }
- if(!session) throw "User session is not defined";
- SESSION = session;
- var request = new Request(FETCH_SESSION, session, 1);
- request.send(true);
- var user = request.result();
- if(checkILSEvent(user)) throw user;
- USER = user;
- return user;
+ if(session == null ) {
+ cgi = new CGI();
+ session = cgi.param('ses');
+ }
+ if(!session) throw "User session is not defined";
+ SESSION = session;
+ var request = new Request(FETCH_SESSION, session, 1);
+ request.send(true);
+ var user = request.result();
+ if(checkILSEvent(user)) throw user;
+ USER = user;
+ return user;
}
/* if defined, callback will get the user object asynchronously */
function fetchFleshedUser(id, callback) {
- if(id == null) return null;
- var req = new Request(
- 'open-ils.actor:open-ils.actor.user.fleshed.retrieve', SESSION, id );
-
- if( callback ) {
- req.callback( function(r){callback(r.getResultObject());} );
- req.send();
-
- } else {
- req.send(true);
- return req.result();
- }
+ if(id == null) return null;
+ var req = new Request(
+ 'open-ils.actor:open-ils.actor.user.fleshed.retrieve', SESSION, id );
+
+ if( callback ) {
+ req.callback( function(r){callback(r.getResultObject());} );
+ req.send();
+
+ } else {
+ req.send(true);
+ return req.result();
+ }
}
/**
* PERMS[ permName ]. It also returns the org list to the caller
*/
function fetchHighestPermOrgs( session, userId, perms ) {
- var req = new RemoteRequest(
- 'open-ils.actor',
- 'open-ils.actor.user.perm.highest_org.batch',
- session, userId, perms );
- req.send(true);
- var orgs = req.getResultObject();
- for( var i = 0; i != orgs.length; i++ )
- PERMS[perms[i]] = orgs[i];
- //PERMS[ perms[i] ] = ( orgs[i] != null ) ? orgs[i] : -1 ;
- return orgs;
+ var req = new RemoteRequest(
+ 'open-ils.actor',
+ 'open-ils.actor.user.perm.highest_org.batch',
+ session, userId, perms );
+ req.send(true);
+ var orgs = req.getResultObject();
+ for( var i = 0; i != orgs.length; i++ )
+ PERMS[perms[i]] = orgs[i];
+ //PERMS[ perms[i] ] = ( orgs[i] != null ) ? orgs[i] : -1 ;
+ return orgs;
}
function fetchHighestWorkPermOrgs(session, userId, perms, onload) {
/* offset is the depth of the highest org
- in the tree we're building
+ in the tree we're building
*/
/* XXX Moved to opac_utils.js */
/*
function buildOrgSel(selector, org, offset) {
- insertSelectorVal( selector, -1,
- org.name(), org.id(), null, findOrgDepth(org) - offset );
- for( var c in org.children() )
- buildOrgSel( selector, org.children()[c], offset);
+ insertSelectorVal( selector, -1,
+ org.name(), org.id(), null, findOrgDepth(org) - offset );
+ for( var c in org.children() )
+ buildOrgSel( selector, org.children()[c], offset);
}
*/
/** removes all child nodes in 'tbody' that have the attribute 'key' defined */
function cleanTbody(tbody, key) {
- for( var c = 0; c < tbody.childNodes.length; c++ ) {
- var child = tbody.childNodes[c];
- if(child && child.getAttribute(key)) tbody.removeChild(child);
- }
+ for( var c = 0; c < tbody.childNodes.length; c++ ) {
+ var child = tbody.childNodes[c];
+ if(child && child.getAttribute(key)) tbody.removeChild(child);
+ }
}
* newRow is the new row to insert
*/
function insRow( tbody, row, newRow ) {
- if(row.nextSibling) tbody.insertBefore( newRow, row.nextSibling );
- else{ tbody.appendChild(newRow); }
+ if(row.nextSibling) tbody.insertBefore( newRow, row.nextSibling );
+ else{ tbody.appendChild(newRow); }
}
* I.e. I can edit the context item because it's "below" me
*/
function checkDisabled( node, itemOrg, perm ) {
- var itemDepth = findOrgDepth(itemOrg);
- var mydepth = findOrgDepth(PERMS[perm]);
- if( mydepth != -1 && mydepth <= itemDepth ) node.disabled = false;
+ var itemDepth = findOrgDepth(itemOrg);
+ var mydepth = findOrgDepth(PERMS[perm]);
+ if( mydepth != -1 && mydepth <= itemDepth ) node.disabled = false;
}
/**
function fetchOrgUnit(id, callback) {
- if(ORG_CACHE[id]) return ORG_CACHE[id];
- var req = new Request(FETCH_ORG_UNIT, SESSION, id);
-
- if(callback) {
- req.callback(
- function(r) {
- var org = r.getResultObject();
- ORG_CACHE[id] = org;
- callback(org);
- }
- );
- req.send();
-
- } else {
- req.send(true);
- var org = req.result();
- ORG_CACHE[id] = org;
- return org;
- }
+ if(ORG_CACHE[id]) return ORG_CACHE[id];
+ var req = new Request(FETCH_ORG_UNIT, SESSION, id);
+
+ if(callback) {
+ req.callback(
+ function(r) {
+ var org = r.getResultObject();
+ ORG_CACHE[id] = org;
+ callback(org);
+ }
+ );
+ req.send();
+
+ } else {
+ req.send(true);
+ var org = req.result();
+ ORG_CACHE[id] = org;
+ return org;
+ }
}
var crBaseOrg;
function crInit() {
- fetchUser();
- $('user').appendChild(text(USER.usrname()));
-
- setTimeout(
- function() {
- fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
- crSetCals();
- crBuildOrgs();
- crDrawRange();
- },
- 20
- );
+ fetchUser();
+ $('user').appendChild(text(USER.usrname()));
+
+ setTimeout(
+ function() {
+ fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
+ crSetCals();
+ crBuildOrgs();
+ crDrawRange();
+ },
+ 20
+ );
}
function crSetCals() {
- Calendar.setup({
- inputField : "cr_start",
- ifFormat : "%Y-%m-%d",
- button : "cr_start_trigger",
- align : "Tl",
- singleClick : true
- });
-
- Calendar.setup({
- inputField : "cr_end",
- ifFormat : "%Y-%m-%d",
- button : "cr_end_trigger",
- align : "Tl",
- singleClick : true
- });
-
- var d = new Date();
- var y = d.getYear()+1900;
- var m = ((d.getMonth()+1)+'').replace(/^(\d)$/,'0$1');
- var da = (d.getDate()+'').replace(/^(\d)$/,'0$1');
-
- var dat = y+'-'+m+'-'+da;
- $('cr_start').value = dat;
- $('cr_end').value = dat;
+ Calendar.setup({
+ inputField : "cr_start",
+ ifFormat : "%Y-%m-%d",
+ button : "cr_start_trigger",
+ align : "Tl",
+ singleClick : true
+ });
+
+ Calendar.setup({
+ inputField : "cr_end",
+ ifFormat : "%Y-%m-%d",
+ button : "cr_end_trigger",
+ align : "Tl",
+ singleClick : true
+ });
+
+ var d = new Date();
+ var y = d.getYear()+1900;
+ var m = ((d.getMonth()+1)+'').replace(/^(\d)$/,'0$1');
+ var da = (d.getDate()+'').replace(/^(\d)$/,'0$1');
+
+ var dat = y+'-'+m+'-'+da;
+ $('cr_start').value = dat;
+ $('cr_end').value = dat;
}
function crCurrentOrg() {
- var selector = $('cr_orgs');
- return getSelectorVal(selector);
+ var selector = $('cr_orgs');
+ return getSelectorVal(selector);
}
function crBuildOrgs() {
- var org = findOrgUnit(PERMS['VIEW_TRANSACTION']);
+ var org = findOrgUnit(PERMS['VIEW_TRANSACTION']);
- if(!org) {
- $('cr_orgs').disabled = true;
- return;
- }
+ if(!org) {
+ $('cr_orgs').disabled = true;
+ return;
+ }
- org = findOrgUnit(org);
- var type = findOrgType(org.ou_type()) ;
+ org = findOrgUnit(org);
+ var type = findOrgType(org.ou_type()) ;
- var selector = $('cr_orgs');
- buildOrgSel(selector, org, type.depth());
+ var selector = $('cr_orgs');
+ buildOrgSel(selector, org, type.depth());
- for( var i = 0; i < selector.options.length; i++ ) {
- var opt = selector.options[i];
- if( !isTrue(findOrgType( findOrgUnit(opt.value).ou_type() ).can_have_users()) )
- opt.disabled = true;
- }
+ for( var i = 0; i < selector.options.length; i++ ) {
+ var opt = selector.options[i];
+ if( !isTrue(findOrgType( findOrgUnit(opt.value).ou_type() ).can_have_users()) )
+ opt.disabled = true;
+ }
- selector.onchange = crDrawRange;
+ selector.onchange = crDrawRange;
- crBaseOrg = org;
+ crBaseOrg = org;
- var gotoOrg = USER.ws_ou();
- if( ! setSelector( selector, gotoOrg ) ) {
- gotoOrg = USER.home_ou();
- setSelector( selector, gotoOrg );
- }
+ var gotoOrg = USER.ws_ou();
+ if( ! setSelector( selector, gotoOrg ) ) {
+ gotoOrg = USER.home_ou();
+ setSelector( selector, gotoOrg );
+ }
- return gotoOrg;
+ return gotoOrg;
}
function crDrawRange() {
- var org = crCurrentOrg();
-
- removeChildren($('cr_desk_payments'));
- removeChildren($('cr_user_payments'));
-
- var req = new Request( FETCH_DESK_PAYMENTS, SESSION,
- org, $('cr_start').value, $('cr_end').value );
- req.callback(
- function(r) {
- drawFMObjectTable( { dest : 'cr_desk_payments', obj : r.getResultObject(), moneySummaryRow : true });
- sortables_init();
- }
- );
- req.send();
-
- var req = new Request( FETCH_USER_PAYMENTS, SESSION,
- org, $('cr_start').value, $('cr_end').value );
- req.callback(
- function(r) {
- drawFMObjectTable( { dest : 'cr_user_payments', obj : r.getResultObject(), moneySummaryRow : true });
- sortables_init();
- }
- );
- req.send();
+ var org = crCurrentOrg();
+
+ removeChildren($('cr_desk_payments'));
+ removeChildren($('cr_user_payments'));
+
+ var req = new Request( FETCH_DESK_PAYMENTS, SESSION,
+ org, $('cr_start').value, $('cr_end').value );
+ req.callback(
+ function(r) {
+ drawFMObjectTable( { dest : 'cr_desk_payments', obj : r.getResultObject(), moneySummaryRow : true });
+ sortables_init();
+ }
+ );
+ req.send();
+
+ var req = new Request( FETCH_USER_PAYMENTS, SESSION,
+ org, $('cr_start').value, $('cr_end').value );
+ req.callback(
+ function(r) {
+ drawFMObjectTable( { dest : 'cr_user_payments', obj : r.getResultObject(), moneySummaryRow : true });
+ sortables_init();
+ }
+ );
+ req.send();
}
-var FETCH_CLOSED_DATES = 'open-ils.actor:open-ils.actor.org_unit.closed.retrieve.all';
-var FETCH_CLOSED_DATE = 'open-ils.actor:open-ils.actor.org_unit.closed.retrieve';
-var CREATE_CLOSED_DATE = 'open-ils.actor:open-ils.actor.org_unit.closed.create';
-var DELETE_CLOSED_DATE = 'open-ils.actor:open-ils.actor.org_unit.closed.delete';
+var FETCH_CLOSED_DATES = 'open-ils.actor:open-ils.actor.org_unit.closed.retrieve.all';
+var FETCH_CLOSED_DATE = 'open-ils.actor:open-ils.actor.org_unit.closed.retrieve';
+var CREATE_CLOSED_DATE = 'open-ils.actor:open-ils.actor.org_unit.closed.create';
+var DELETE_CLOSED_DATE = 'open-ils.actor:open-ils.actor.org_unit.closed.delete';
var cdRowTemplate;
var cdAllDayTemplate;
var myPerms = [
- 'actor.org_unit.closed_date.delete',
- 'actor.org_unit.closed_date.create',
- ];
+ 'actor.org_unit.closed_date.delete',
+ 'actor.org_unit.closed_date.create',
+ ];
function cdEditorInit() {
- /* set the various template rows */
- cdTbody = $('cd_tbody');
- cdRowTemplate = cdTbody.removeChild($('cd_row'));
- cdAllDayTemplate = cdTbody.removeChild($('cd_allday_row'));
- cdAllMultiDayTemplate = cdTbody.removeChild($('cd_allmultiday_row'));
-
- cdInitCals();
-
- fetchUser();
- $('cd_user').appendChild(text(USER.usrname()));
-
- setTimeout(
- function() {
- fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
- cdBuildOrgs();
- cdDrawRange();
- },
- 20
- );
+ /* set the various template rows */
+ cdTbody = $('cd_tbody');
+ cdRowTemplate = cdTbody.removeChild($('cd_row'));
+ cdAllDayTemplate = cdTbody.removeChild($('cd_allday_row'));
+ cdAllMultiDayTemplate = cdTbody.removeChild($('cd_allmultiday_row'));
+
+ cdInitCals();
+
+ fetchUser();
+ $('cd_user').appendChild(text(USER.usrname()));
+
+ setTimeout(
+ function() {
+ fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
+ cdBuildOrgs();
+ cdDrawRange();
+ },
+ 20
+ );
}
function cdCurrentOrg() {
- var selector = $('cd_orgs');
- return getSelectorVal(selector);
+ var selector = $('cd_orgs');
+ return getSelectorVal(selector);
}
function cdBuildOrgs() {
- var org = findOrgUnit(PERMS['actor.org_unit.closed_date.create']);
- if( !org || org == -1 ) org = findOrgUnit(USER.ws_ou());
- var type = findOrgType(org.ou_type()) ;
+ var org = findOrgUnit(PERMS['actor.org_unit.closed_date.create']);
+ if( !org || org == -1 ) org = findOrgUnit(USER.ws_ou());
+ var type = findOrgType(org.ou_type()) ;
- var selector = $('cd_orgs');
- buildOrgSel(selector, org, type.depth());
- if(!type.can_have_users()) selector.options[0].disabled = true;
+ var selector = $('cd_orgs');
+ buildOrgSel(selector, org, type.depth());
+ if(!type.can_have_users()) selector.options[0].disabled = true;
- selector.onchange = function() { cdDrawRange(); };
+ selector.onchange = function() { cdDrawRange(); };
- cdBaseOrg = org;
+ cdBaseOrg = org;
- if( cdBaseOrg.children() && cdBaseOrg.children().length > 0 )
- unHideMe($('cd_apply_all_div'));
+ if( cdBaseOrg.children() && cdBaseOrg.children().length > 0 )
+ unHideMe($('cd_apply_all_div'));
- var gotoOrg = USER.ws_ou();
- if( ! setSelector( selector, gotoOrg ) ) {
- gotoOrg = USER.home_ou();
- setSelector( selector, gotoOrg );
- }
+ var gotoOrg = USER.ws_ou();
+ if( ! setSelector( selector, gotoOrg ) ) {
+ gotoOrg = USER.home_ou();
+ setSelector( selector, gotoOrg );
+ }
- var neworg = findOrgUnit(PERMS['actor.org_unit.closed_date.create']);
- if(!neworg || neworg == -1 || !orgIsMine(neworg, findOrgUnit(cdCurrentOrg()))) {
- $('cd_new_allday').disabled = true;
- $('cd_new_multiday').disabled = true;
- $('cd_new').disabled = true;
- }
+ var neworg = findOrgUnit(PERMS['actor.org_unit.closed_date.create']);
+ if(!neworg || neworg == -1 || !orgIsMine(neworg, findOrgUnit(cdCurrentOrg()))) {
+ $('cd_new_allday').disabled = true;
+ $('cd_new_multiday').disabled = true;
+ $('cd_new').disabled = true;
+ }
- return gotoOrg;
+ return gotoOrg;
}
function cdInitCals() {
- Calendar.setup({
- inputField : "cd_edit_allday_start_date",
- ifFormat : "%Y-%m-%d",
- button : "cd_edit_allday_start_date_img",
- align : "Tl",
- singleClick : true
- });
-
- Calendar.setup({
- inputField : "cd_edit_allmultiday_start_date",
- ifFormat : "%Y-%m-%d",
- button : "cd_edit_allmultiday_start_date_img",
- align : "Tl",
- singleClick : true
- });
-
- Calendar.setup({
- inputField : "cd_edit_allmultiday_end_date",
- ifFormat : "%Y-%m-%d",
- button : "cd_edit_allmultiday_end_date_img",
- align : "Tl",
- singleClick : true
- });
-
- Calendar.setup({
- inputField : "cd_edit_end_date",
- ifFormat : "%Y-%m-%d",
- button : "cd_edit_end_date_img",
- align : "Tl",
- singleClick : true
- });
-
- Calendar.setup({
- inputField : "cd_edit_start_date",
- ifFormat : "%Y-%m-%d",
- button : "cd_edit_start_date_img",
- align : "Tl",
- singleClick : true
- });
+ Calendar.setup({
+ inputField : "cd_edit_allday_start_date",
+ ifFormat : "%Y-%m-%d",
+ button : "cd_edit_allday_start_date_img",
+ align : "Tl",
+ singleClick : true
+ });
+
+ Calendar.setup({
+ inputField : "cd_edit_allmultiday_start_date",
+ ifFormat : "%Y-%m-%d",
+ button : "cd_edit_allmultiday_start_date_img",
+ align : "Tl",
+ singleClick : true
+ });
+
+ Calendar.setup({
+ inputField : "cd_edit_allmultiday_end_date",
+ ifFormat : "%Y-%m-%d",
+ button : "cd_edit_allmultiday_end_date_img",
+ align : "Tl",
+ singleClick : true
+ });
+
+ Calendar.setup({
+ inputField : "cd_edit_end_date",
+ ifFormat : "%Y-%m-%d",
+ button : "cd_edit_end_date_img",
+ align : "Tl",
+ singleClick : true
+ });
+
+ Calendar.setup({
+ inputField : "cd_edit_start_date",
+ ifFormat : "%Y-%m-%d",
+ button : "cd_edit_start_date_img",
+ align : "Tl",
+ singleClick : true
+ });
}
function cdDrawRange( start, end, alertSuccess ) {
- start = (start) ? start : new Date().getYear() + 1899 + '-01-01'; /* include last year's closed info for comparison */
- end = (end) ? end : '3001-01-01';
+ start = (start) ? start : new Date().getYear() + 1899 + '-01-01'; /* include last year's closed info for comparison */
+ end = (end) ? end : '3001-01-01';
if(alertSuccess) alertId('cd_update_success');
- selectedStart = start;
- selectedEnd = end;
-
- var req = new Request(
- FETCH_CLOSED_DATES, SESSION,
- {
- orgid : cdCurrentOrg(),
- start_date : start,
- end_date : end,
- idlist : 0
- }
- );
-
- req.callback( cdBuild );
- req.send();
+ selectedStart = start;
+ selectedEnd = end;
+
+ var req = new Request(
+ FETCH_CLOSED_DATES, SESSION,
+ {
+ orgid : cdCurrentOrg(),
+ start_date : start,
+ end_date : end,
+ idlist : 0
+ }
+ );
+
+ req.callback( cdBuild );
+ req.send();
}
/* adds one row in the display table per date */
function cdBuild(r) {
- var dates = r.getResultObject();
- removeChildren(cdTbody);
- for( var d = 0; d < dates.length; d++ ) {
- var date = dates[d];
- var row = cdBuildRow( date );
- cdTbody.appendChild(row);
- }
+ var dates = r.getResultObject();
+ removeChildren(cdTbody);
+ for( var d = 0; d < dates.length; d++ ) {
+ var date = dates[d];
+ var row = cdBuildRow( date );
+ cdTbody.appendChild(row);
+ }
}
function cdDateToHours(date) {
- var d = new Date.W3CDTF();
- d.setW3CDTF(date.replace(/\.\d+/,'') + ":00");
+ var d = new Date.W3CDTF();
+ d.setW3CDTF(date.replace(/\.\d+/,'') + ":00");
- var h = d.getHours() +'';
- var m = d.getMinutes() +'';
- var s = d.getSeconds() +'';
+ var h = d.getHours() +'';
+ var m = d.getMinutes() +'';
+ var s = d.getSeconds() +'';
- if(h.length == 1) h = '0'+h;
- if(m.length == 1) m = '0'+m;
- if(s.length == 1) s = '0'+s;
+ if(h.length == 1) h = '0'+h;
+ if(m.length == 1) m = '0'+m;
+ if(s.length == 1) s = '0'+s;
- return h + ':' + m + ':' + s;
+ return h + ':' + m + ':' + s;
}
function cdDateToDate(date) {
- var d = new Date.W3CDTF();
- d.setW3CDTF(date.replace(/\.\d+/,'') + ":00");
+ var d = new Date.W3CDTF();
+ d.setW3CDTF(date.replace(/\.\d+/,'') + ":00");
- var y = d.getFullYear()+'';
- var m = (d.getMonth() + 1)+'';
- var d = d.getDate()+'';
+ var y = d.getFullYear()+'';
+ var m = (d.getMonth() + 1)+'';
+ var d = d.getDate()+'';
- if(m.length == 1) m = '0'+m;
- if(d.length == 1) d = '0'+d;
+ if(m.length == 1) m = '0'+m;
+ if(d.length == 1) d = '0'+d;
- return y + '-' + m + '-' + d;
+ return y + '-' + m + '-' + d;
}
/* fleshes a single date */
function cdBuildRow( date ) {
- cdDateCache[date.id()] = date;
+ cdDateCache[date.id()] = date;
- var sh = cdDateToHours(date.close_start());
- var sd = cdDateToDate(date.close_start());
- var eh = cdDateToHours(date.close_end());
- var ed = cdDateToDate(date.close_end());
+ var sh = cdDateToHours(date.close_start());
+ var sd = cdDateToDate(date.close_start());
+ var eh = cdDateToHours(date.close_end());
+ var ed = cdDateToDate(date.close_end());
- var row;
- var flesh = false;
+ var row;
+ var flesh = false;
- if( sh == '00:00:00' && eh == '23:59:59' ) {
+ if( sh == '00:00:00' && eh == '23:59:59' ) {
- if( sd == ed ) {
- row = cdAllDayTemplate.cloneNode(true);
- $n(row, 'start_date').appendChild(text(sd));
+ if( sd == ed ) {
+ row = cdAllDayTemplate.cloneNode(true);
+ $n(row, 'start_date').appendChild(text(sd));
- } else {
- row = cdAllMultiDayTemplate.cloneNode(true);
- $n(row, 'start_date').appendChild(text(sd));
- $n(row, 'end_date').appendChild(text(ed));
- }
+ } else {
+ row = cdAllMultiDayTemplate.cloneNode(true);
+ $n(row, 'start_date').appendChild(text(sd));
+ $n(row, 'end_date').appendChild(text(ed));
+ }
- } else {
+ } else {
- row = cdRowTemplate.cloneNode(true);
- cdEditFleshRow(row, date);
- }
+ row = cdRowTemplate.cloneNode(true);
+ cdEditFleshRow(row, date);
+ }
- $n(row,'delete').onclick = function() { cdDelete(row, date); };
- $n(row, 'note').appendChild(text(date.reason()));
+ $n(row,'delete').onclick = function() { cdDelete(row, date); };
+ $n(row, 'note').appendChild(text(date.reason()));
- /* if we don't have delete perms for this location, disable the button */
- var delorg = findOrgUnit(PERMS['actor.org_unit.closed_date.delete']);
- if(!orgIsMine(delorg, findOrgUnit(cdCurrentOrg()))) $n(row,'delete').disabled = true;
+ /* if we don't have delete perms for this location, disable the button */
+ var delorg = findOrgUnit(PERMS['actor.org_unit.closed_date.delete']);
+ if(!orgIsMine(delorg, findOrgUnit(cdCurrentOrg()))) $n(row,'delete').disabled = true;
- return row;
+ return row;
}
function cdEditFleshRow(row, date) {
- $n(row, 'start_time').appendChild(text(cdDateToHours(date.close_start())));
- $n(row, 'start_date').appendChild(text(cdDateToDate(date.close_start())));
- $n(row, 'end_time').appendChild(text(cdDateToHours(date.close_end())));
- $n(row, 'end_date').appendChild(text(cdDateToDate(date.close_end())));
+ $n(row, 'start_time').appendChild(text(cdDateToHours(date.close_start())));
+ $n(row, 'start_date').appendChild(text(cdDateToDate(date.close_start())));
+ $n(row, 'end_time').appendChild(text(cdDateToHours(date.close_end())));
+ $n(row, 'end_date').appendChild(text(cdDateToDate(date.close_end())));
}
function cdShowEditRow(id) {
- cdCancelEdit();
- unHideMe($(id));
- unHideMe($('cd_edit_submit'));
- unHideMe($('cd_edit_note_row'));
+ cdCancelEdit();
+ unHideMe($(id));
+ unHideMe($('cd_edit_submit'));
+ unHideMe($('cd_edit_note_row'));
}
function cdCancelEdit() {
- hideMe($('cd_edit_row'));
- hideMe($('cd_edit_allday_row'));
- hideMe($('cd_edit_allmultiday_row'));
- hideMe($('cd_edit_submit'));
- hideMe($('cd_edit_note_row'));
+ hideMe($('cd_edit_row'));
+ hideMe($('cd_edit_allday_row'));
+ hideMe($('cd_edit_allmultiday_row'));
+ hideMe($('cd_edit_submit'));
+ hideMe($('cd_edit_note_row'));
}
function cdDelete(row, date) {
- if(!confirmId('cd_confirm_delete')) return;
- var req = new Request(DELETE_CLOSED_DATE, SESSION, date.id() );
- req.callback(
- function(r) {
- var res = r.getResultObject();
- if( checkILSEvent(res) ) alertILSEvent(res);
- cdDrawRange(selectedStart, selectedEnd, true);
- }
- )
- req.send();
+ if(!confirmId('cd_confirm_delete')) return;
+ var req = new Request(DELETE_CLOSED_DATE, SESSION, date.id() );
+ req.callback(
+ function(r) {
+ var res = r.getResultObject();
+ if( checkILSEvent(res) ) alertILSEvent(res);
+ cdDrawRange(selectedStart, selectedEnd, true);
+ }
+ )
+ req.send();
}
/* getW3CDTF */
function cdVerifyDate(d) {
- return d && d.match(/\d{4}-\d{2}-\d{2}/);
+ return d && d.match(/\d{4}-\d{2}-\d{2}/);
}
function cdVerifyTime(t) {
- return t && t.match(/\d{2}:\d{2}:\d{2}/);
+ return t && t.match(/\d{2}:\d{2}:\d{2}/);
}
function cdDateStrToDate( str ) {
- var date = new Date.W3CDTF();
- var data = str.split(/ /);
+ var date = new Date.W3CDTF();
+ var data = str.split(/ /);
- var year = data[0];
- var time = data[1];
+ var year = data[0];
+ var time = data[1];
- if(!cdVerifyDate(year)) return alertId('cd_invalid_date');
- if(!cdVerifyTime(time)) return alertId('cd_invalid_time');
+ if(!cdVerifyDate(year)) return alertId('cd_invalid_date');
+ if(!cdVerifyTime(time)) return alertId('cd_invalid_time');
- var yeardata = year.split(/-/);
- var timedata = time.split(/:/);
+ var yeardata = year.split(/-/);
+ var timedata = time.split(/:/);
/* seed the date with day = 1, which is a valid day for any month.
this prevents automatic date correction by the date code for days that
fall outside of the current or target month */
date.setDate(1);
- date.setFullYear(new Number(yeardata[0]));
- date.setMonth(new Number(yeardata[1]) - 1);
+ date.setFullYear(new Number(yeardata[0]));
+ date.setMonth(new Number(yeardata[1]) - 1);
date.setDate(new Number(yeardata[2]));
- date.setHours(new Number(timedata[0]));
- date.setMinutes(new Number(timedata[1]));
- date.setSeconds(new Number(timedata[2]));
+ date.setHours(new Number(timedata[0]));
+ date.setMinutes(new Number(timedata[1]));
+ date.setSeconds(new Number(timedata[2]));
- return date;
+ return date;
}
function cdNew() {
- var start;
- var end;
+ var start;
+ var end;
- if( ! $('cd_edit_allday_row').className.match(/hide_me/) ) {
+ if( ! $('cd_edit_allday_row').className.match(/hide_me/) ) {
- var date = $('cd_edit_allday_start_date').value;
+ var date = $('cd_edit_allday_start_date').value;
- start = cdDateStrToDate(date + ' 00:00:00');
- end = cdDateStrToDate(date + ' 23:59:59');
+ start = cdDateStrToDate(date + ' 00:00:00');
+ end = cdDateStrToDate(date + ' 23:59:59');
- } else if( ! $('cd_edit_allmultiday_row').className.match(/hide_me/) ) {
+ } else if( ! $('cd_edit_allmultiday_row').className.match(/hide_me/) ) {
- var sdate = $('cd_edit_allmultiday_start_date').value;
- var edate = $('cd_edit_allmultiday_end_date').value;
- start = cdDateStrToDate(sdate + ' 00:00:00');
- end = cdDateStrToDate(edate + ' 23:59:59');
+ var sdate = $('cd_edit_allmultiday_start_date').value;
+ var edate = $('cd_edit_allmultiday_end_date').value;
+ start = cdDateStrToDate(sdate + ' 00:00:00');
+ end = cdDateStrToDate(edate + ' 23:59:59');
- } else {
+ } else {
- var sdate = $('cd_edit_start_date').value;
- var edate = $('cd_edit_end_date').value;
- var stime;
- var etime;
+ var sdate = $('cd_edit_start_date').value;
+ var edate = $('cd_edit_end_date').value;
+ var stime;
+ var etime;
- if($('cd_edit_start_time_allday').checked) {
- stime = '00:00';
- } else {
- stime = $('cd_edit_start_time').value;
- }
+ if($('cd_edit_start_time_allday').checked) {
+ stime = '00:00';
+ } else {
+ stime = $('cd_edit_start_time').value;
+ }
- stime += ':00';
+ stime += ':00';
- if($('cd_edit_end_time_allday').checked) {
- etime = '23:59:59';
- } else {
- etime = $('cd_edit_end_time').value;
- etime += ':00';
- }
+ if($('cd_edit_end_time_allday').checked) {
+ etime = '23:59:59';
+ } else {
+ etime = $('cd_edit_end_time').value;
+ etime += ':00';
+ }
- start = cdDateStrToDate(sdate + ' ' + stime);
- end = cdDateStrToDate(edate + ' ' + etime);
- }
+ start = cdDateStrToDate(sdate + ' ' + stime);
+ end = cdDateStrToDate(edate + ' ' + etime);
+ }
- cdCreate(start, end, $('cd_edit_note').value);
+ cdCreate(start, end, $('cd_edit_note').value);
}
function cdCreate(start, end, note) {
- if( $('cd_apply_all').checked ) {
- var list = cdGetOrgList();
- for( var o = 0; o < list.length; o++ ) {
- var id = list[o].id();
- cdCreateOne( id, start, end, note, (id == cdCurrentOrg()) );
- }
+ if( $('cd_apply_all').checked ) {
+ var list = cdGetOrgList();
+ for( var o = 0; o < list.length; o++ ) {
+ var id = list[o].id();
+ cdCreateOne( id, start, end, note, (id == cdCurrentOrg()) );
+ }
- } else {
+ } else {
- cdCreateOne( cdCurrentOrg(), start, end, note, true );
- }
+ cdCreateOne( cdCurrentOrg(), start, end, note, true );
+ }
}
function cdGetOrgList(org) {
- if(!org) org = cdBaseOrg;
-
- var list = [];
- var type = findOrgType(org.ou_type()) ;
- if( type.can_have_users() ) list.push(org);
-
- if( org.children() ) {
- for( var i = 0; i < org.children().length; i++ ) {
- var child = org.children()[i];
- if( child ) {
- var l = cdGetOrgList(child);
- for( var j = 0; j < l.length; j++ )
- list.push(l[j]);
- }
- }
- }
-
- return list;
+ if(!org) org = cdBaseOrg;
+
+ var list = [];
+ var type = findOrgType(org.ou_type()) ;
+ if( type.can_have_users() ) list.push(org);
+
+ if( org.children() ) {
+ for( var i = 0; i < org.children().length; i++ ) {
+ var child = org.children()[i];
+ if( child ) {
+ var l = cdGetOrgList(child);
+ for( var j = 0; j < l.length; j++ )
+ list.push(l[j]);
+ }
+ }
+ }
+
+ return list;
}
function cdCreateOne( org, start, end, note, refresh ) {
- var date = new aoucd();
-
- date.close_start(start.getW3CDTF());
- date.close_end(end.getW3CDTF());
- date.org_unit(org);
- date.reason(note);
-
- var req = new Request(CREATE_CLOSED_DATE, SESSION, date);
- req.callback(
- function(r) {
- var res = r.getResultObject();
- if( checkILSEvent(res) ) alertILSEvent(res);
- if(refresh) cdDrawRange(selectedStart, selectedEnd, true);
- }
- );
- req.send();
+ var date = new aoucd();
+
+ date.close_start(start.getW3CDTF());
+ date.close_end(end.getW3CDTF());
+ date.org_unit(org);
+ date.reason(note);
+
+ var req = new Request(CREATE_CLOSED_DATE, SESSION, date);
+ req.callback(
+ function(r) {
+ var res = r.getResultObject();
+ if( checkILSEvent(res) ) alertILSEvent(res);
+ if(refresh) cdDrawRange(selectedStart, selectedEnd, true);
+ }
+ );
+ req.send();
}
var focusOrg;
var myPerms = [
- 'CREATE_COPY_LOCATION',
- 'UPDATE_COPY_LOCATION',
- 'DELETE_COPY_LOCATION',
- ];
+ 'CREATE_COPY_LOCATION',
+ 'UPDATE_COPY_LOCATION',
+ 'DELETE_COPY_LOCATION',
+ ];
function clEditorInit() {
- cgi = new CGI();
- session = cgi.param('ses');
- if(!session) throw "User session is not defined!";
- fetchUser(session);
- $('user').appendChild(text(USER.usrname()));
- YES = $('yes').innerHTML;
- NO = $('no').innerHTML;
+ cgi = new CGI();
+ session = cgi.param('ses');
+ if(!session) throw "User session is not defined!";
+ fetchUser(session);
+ $('user').appendChild(text(USER.usrname()));
+ YES = $('yes').innerHTML;
+ NO = $('no').innerHTML;
_TRUE = $('true');
_FALSE = $('false');
locationSet = [];
- setTimeout(
- function() {
- fetchHighestWorkPermOrgs( SESSION, USER.id(), myPerms );
- $('cl_new_name').focus();
- clBuildNew();
- clGo();
- }, 20 );
+ setTimeout(
+ function() {
+ fetchHighestWorkPermOrgs( SESSION, USER.id(), myPerms );
+ $('cl_new_name').focus();
+ clBuildNew();
+ clGo();
+ }, 20 );
}
function clHoldMsg() {
- alert($('cl_hold_msg').innerHTML);
+ alert($('cl_hold_msg').innerHTML);
}
-function clGo() {
+function clGo() {
setTimeout(function(){clGo2();}, 500);
}
-function clGo2() {
+function clGo2() {
locationSet = {};
var req = new Request(RETRIEVE_CL, focusOrg);
req.request._last = true;
/* if we need to add view-all ability, can use this...
var org_list = OILS_WORK_PERMS['CREATE_COPY_LOCATION'];
for(var i = 0; i < org_list.length; i++) {
- var req = new Request(RETRIEVE_CL, org_list[i]);
- req.callback(clAppendLocation);
+ var req = new Request(RETRIEVE_CL, org_list[i]);
+ req.callback(clAppendLocation);
if(i == org_list.length - 1)
req.request._last = true;
req.send();
function clAppendLocation(r) {
var cls = r.getResultObject();
- if(checkILSEvent(cls)) throw cls;
+ if(checkILSEvent(cls)) throw cls;
for(var i = 0; i < cls.length; i++)
locationSet[cls[i].id()] = cls[i];
if(r._last)
}
function clBuildNew() {
- org_list = OILS_WORK_PERMS['CREATE_COPY_LOCATION'];
+ org_list = OILS_WORK_PERMS['CREATE_COPY_LOCATION'];
var org;
if(org_list.length == 0)
return;
- var selector = $('cl_new_owner');
- var fselector = $('cl_org_filter');
- buildMergedOrgSel(selector, org_list, 0, 'shortname');
- buildMergedOrgSel(fselector, org_list, 0, 'shortname');
+ var selector = $('cl_new_owner');
+ var fselector = $('cl_org_filter');
+ buildMergedOrgSel(selector, org_list, 0, 'shortname');
+ buildMergedOrgSel(fselector, org_list, 0, 'shortname');
var org = findOrgUnit(org_list[0]);
if(org_list.length > 1 || (org.children() && org.children()[0])) {
- selector.disabled = false;
+ selector.disabled = false;
fselector.disabled = false;
}
setSelector(fselector, focusOrg);
- var sub = $('sc_new_submit');
- sub.disabled = false;
- sub.onclick = clCreateNew;
+ var sub = $('sc_new_submit');
+ sub.disabled = false;
+ sub.onclick = clCreateNew;
}
function clCreateNew() {
- var cl = new acpl();
- cl.name( $('cl_new_name').value );
- cl.owning_lib( getSelectorVal( $('cl_new_owner')));
- cl.holdable( ($('cl_new_hold_yes').checked) ? 1 : 0 );
- cl.hold_verify( ($('cl_new_hold_verify_yes').checked) ? 1 : 0 );
- cl.opac_visible( ($('cl_new_vis_yes').checked) ? 1 : 0 );
- cl.circulate( ($('cl_new_circulate_yes').checked) ? 1 : 0 );
-
- var req = new Request(CREATE_CL, SESSION, cl);
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- alertId('cl_update_success');
- clGo();
+ var cl = new acpl();
+ cl.name( $('cl_new_name').value );
+ cl.owning_lib( getSelectorVal( $('cl_new_owner')));
+ cl.holdable( ($('cl_new_hold_yes').checked) ? 1 : 0 );
+ cl.hold_verify( ($('cl_new_hold_verify_yes').checked) ? 1 : 0 );
+ cl.opac_visible( ($('cl_new_vis_yes').checked) ? 1 : 0 );
+ cl.circulate( ($('cl_new_circulate_yes').checked) ? 1 : 0 );
+
+ var req = new Request(CREATE_CL, SESSION, cl);
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ alertId('cl_update_success');
+ clGo();
}
var rowTemplate;
for(var x in locationSet)
cls.push(locationSet[x]);
- var tbody = $('cl_tbody');
- if(!rowTemplate)
- rowTemplate = tbody.removeChild($('cl_row'));
- removeChildren(tbody);
+ var tbody = $('cl_tbody');
+ if(!rowTemplate)
+ rowTemplate = tbody.removeChild($('cl_row'));
+ removeChildren(tbody);
for(var i = 0; i < cls.length; i++) /* force stringify */
cls[i].name(new String(cls[i].name()));
- cls = cls.sort( function(a,b) {
- if( a.name().toLowerCase() > b.name().toLowerCase() ) return 1;
- if( a.name().toLowerCase() < b.name().toLowerCase() ) return -1;
- return 0;
- });
-
- for( var c in cls ) {
- var cl = cls[c];
- var row = rowTemplate.cloneNode(true);
- clBuildRow( tbody, row, cl );
- tbody.appendChild(row);
- }
+ cls = cls.sort( function(a,b) {
+ if( a.name().toLowerCase() > b.name().toLowerCase() ) return 1;
+ if( a.name().toLowerCase() < b.name().toLowerCase() ) return -1;
+ return 0;
+ });
+
+ for( var c in cls ) {
+ var cl = cls[c];
+ var row = rowTemplate.cloneNode(true);
+ clBuildRow( tbody, row, cl );
+ tbody.appendChild(row);
+ }
}
function clBuildRow( tbody, row, cl ) {
- $n( row, 'cl_name').appendChild(text(cl.name()));
- $n( row, 'cl_owner').appendChild(text(findOrgUnit(cl.owning_lib()).shortname()));
+ $n( row, 'cl_name').appendChild(text(cl.name()));
+ $n( row, 'cl_owner').appendChild(text(findOrgUnit(cl.owning_lib()).shortname()));
- appendClear($n( row, 'cl_holdable'), (isTrue(cl.holdable())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
- appendClear($n( row, 'cl_hold_verify'), (isTrue(cl.hold_verify())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
- appendClear($n( row, 'cl_visible'), (isTrue(cl.opac_visible())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
- appendClear($n( row, 'cl_circulate'), (isTrue(cl.circulate())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
+ appendClear($n( row, 'cl_holdable'), (isTrue(cl.holdable())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
+ appendClear($n( row, 'cl_hold_verify'), (isTrue(cl.hold_verify())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
+ appendClear($n( row, 'cl_visible'), (isTrue(cl.opac_visible())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
+ appendClear($n( row, 'cl_circulate'), (isTrue(cl.circulate())) ? _TRUE.cloneNode(true) : _FALSE.cloneNode(true) );
- var edit = $n( row, 'cl_edit');
- edit.onclick = function() { clEdit( cl, tbody, row ); };
+ var edit = $n( row, 'cl_edit');
+ edit.onclick = function() { clEdit( cl, tbody, row ); };
checkPermOrgDisabled(edit, cl.owning_lib(), 'UPDATE_COPY_LOCATION');
- var del = $n( row, 'cl_delete' );
- del.onclick = function() { clDelete( cl, tbody, row ); };
- checkPermOrgDisabled(del, cl.owning_lib(), 'DELETE_COPY_LOCATION');
+ var del = $n( row, 'cl_delete' );
+ del.onclick = function() { clDelete( cl, tbody, row ); };
+ checkPermOrgDisabled(del, cl.owning_lib(), 'DELETE_COPY_LOCATION');
}
function clEdit( cl, tbody, row ) {
- cleanTbody(tbody, 'edit');
- var r = $('cl_edit').cloneNode(true);
- r.setAttribute('edit','1');
-
- var name = $n(r, 'cl_edit_name');
- name.setAttribute('size', cl.name().length + 3);
- name.value = cl.name();
-
- $n(r, 'cl_edit_owner').appendChild(text(findOrgUnit(cl.owning_lib()).shortname()));
-
- var arr = _clOptions(r);
- if(isTrue(cl.holdable())) arr[0].checked = true;
- else arr[1].checked = true;
- if(isTrue(cl.opac_visible())) arr[2].checked = true;
- else arr[3].checked = true;
- if(isTrue(cl.circulate())) arr[4].checked = true;
- else arr[5].checked = true;
- if(isTrue(cl.hold_verify())) arr[6].checked = true;
- else arr[7].checked = true;
-
- $n(r, 'cl_edit_cancel').onclick = function(){cleanTbody(tbody,'edit');}
- $n(r, 'cl_edit_commit').onclick = function(){clEditCommit( tbody, r, cl ); }
-
- insRow(tbody, row, r);
- name.focus();
- name.select();
+ cleanTbody(tbody, 'edit');
+ var r = $('cl_edit').cloneNode(true);
+ r.setAttribute('edit','1');
+
+ var name = $n(r, 'cl_edit_name');
+ name.setAttribute('size', cl.name().length + 3);
+ name.value = cl.name();
+
+ $n(r, 'cl_edit_owner').appendChild(text(findOrgUnit(cl.owning_lib()).shortname()));
+
+ var arr = _clOptions(r);
+ if(isTrue(cl.holdable())) arr[0].checked = true;
+ else arr[1].checked = true;
+ if(isTrue(cl.opac_visible())) arr[2].checked = true;
+ else arr[3].checked = true;
+ if(isTrue(cl.circulate())) arr[4].checked = true;
+ else arr[5].checked = true;
+ if(isTrue(cl.hold_verify())) arr[6].checked = true;
+ else arr[7].checked = true;
+
+ $n(r, 'cl_edit_cancel').onclick = function(){cleanTbody(tbody,'edit');}
+ $n(r, 'cl_edit_commit').onclick = function(){clEditCommit( tbody, r, cl ); }
+
+ insRow(tbody, row, r);
+ name.focus();
+ name.select();
}
function _clOptions(r) {
- var arr = [];
- arr[0] = $n( $n(r,'cl_edit_holdable_yes'), 'cl_edit_holdable');
- arr[1] = $n( $n(r,'cl_edit_holdable_no'), 'cl_edit_holdable');
- arr[2] = $n( $n(r,'cl_edit_visible_yes'), 'cl_edit_visible');
- arr[3] = $n( $n(r,'cl_edit_visible_no'), 'cl_edit_visible');
- arr[4] = $n( $n(r,'cl_edit_circulate_yes'), 'cl_edit_circulate');
- arr[5] = $n( $n(r,'cl_edit_circulate_no'), 'cl_edit_circulate');
- arr[6] = $n( $n(r,'cl_edit_hold_verify_yes'), 'cl_edit_hold_verify');
- arr[7] = $n( $n(r,'cl_edit_hold_verify_no'), 'cl_edit_hold_verify');
- return arr;
+ var arr = [];
+ arr[0] = $n( $n(r,'cl_edit_holdable_yes'), 'cl_edit_holdable');
+ arr[1] = $n( $n(r,'cl_edit_holdable_no'), 'cl_edit_holdable');
+ arr[2] = $n( $n(r,'cl_edit_visible_yes'), 'cl_edit_visible');
+ arr[3] = $n( $n(r,'cl_edit_visible_no'), 'cl_edit_visible');
+ arr[4] = $n( $n(r,'cl_edit_circulate_yes'), 'cl_edit_circulate');
+ arr[5] = $n( $n(r,'cl_edit_circulate_no'), 'cl_edit_circulate');
+ arr[6] = $n( $n(r,'cl_edit_hold_verify_yes'), 'cl_edit_hold_verify');
+ arr[7] = $n( $n(r,'cl_edit_hold_verify_no'), 'cl_edit_hold_verify');
+ return arr;
}
function clEditCommit( tbody, r, cl ) {
- var arr = _clOptions(r);
- if(arr[0].checked) cl.holdable(1);
- else cl.holdable(0);
- if(arr[2].checked) cl.opac_visible(1);
- else cl.opac_visible(0);
- if(arr[4].checked) cl.circulate(1);
- else cl.circulate(0);
- if(arr[6].checked) cl.hold_verify(1);
- else cl.hold_verify(0);
- cl.name($n(r, 'cl_edit_name').value);
-
- var req = new Request( UPDATE_CL, SESSION, cl );
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- alertId('cl_update_success');
-
- clGo();
+ var arr = _clOptions(r);
+ if(arr[0].checked) cl.holdable(1);
+ else cl.holdable(0);
+ if(arr[2].checked) cl.opac_visible(1);
+ else cl.opac_visible(0);
+ if(arr[4].checked) cl.circulate(1);
+ else cl.circulate(0);
+ if(arr[6].checked) cl.hold_verify(1);
+ else cl.hold_verify(0);
+ cl.name($n(r, 'cl_edit_name').value);
+
+ var req = new Request( UPDATE_CL, SESSION, cl );
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ alertId('cl_update_success');
+
+ clGo();
}
function clDelete( cl, tbody, row ) {
- if(!confirm($('cl_delete_confirm').innerHTML)) return;
- var req = new Request( DELETE_CL, SESSION, cl.id() );
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- alertId('cl_update_success');
- clGo();
+ if(!confirm($('cl_delete_confirm').innerHTML)) return;
+ var req = new Request( DELETE_CL, SESSION, cl.id() );
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ alertId('cl_update_success');
+ clGo();
}
-var FETCH_HOLD_LIST = 'open-ils.circ:open-ils.circ.hold_pull_list.retrieve';
-var FETCH_COPY = 'open-ils.search:open-ils.search.asset.copy.fleshed.custom';
-var FETCH_USER = 'open-ils.actor:open-ils.actor.user.fleshed.retrieve';
-var FETCH_VOLUME = 'open-ils.search:open-ils.search.callnumber.retrieve';
+var FETCH_HOLD_LIST = 'open-ils.circ:open-ils.circ.hold_pull_list.retrieve';
+var FETCH_COPY = 'open-ils.search:open-ils.search.asset.copy.fleshed.custom';
+var FETCH_USER = 'open-ils.actor:open-ils.actor.user.fleshed.retrieve';
+var FETCH_VOLUME = 'open-ils.search:open-ils.search.callnumber.retrieve';
-var myPerms = [ 'VIEW_HOLD' ];
-var HOLD_LIST_LIMIT = 100;
-var numHolds = 0;
+var myPerms = [ 'VIEW_HOLD' ];
+var HOLD_LIST_LIMIT = 100;
+var numHolds = 0;
-var listOffset = 0;
+var listOffset = 0;
function pullListInit() {
- fetchUser();
- $('pl_user').appendChild(text(USER.usrname()));
- $('pl_org').appendChild(text(findOrgUnit(USER.ws_ou()).name()));
- setTimeout( function() {
- fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
- pullListFetchHolds();
- }, 20 );
+ fetchUser();
+ $('pl_user').appendChild(text(USER.usrname()));
+ $('pl_org').appendChild(text(findOrgUnit(USER.ws_ou()).name()));
+ setTimeout( function() {
+ fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
+ pullListFetchHolds();
+ }, 20 );
}
function pullListFetchHolds() {
- var req = new Request(FETCH_HOLD_LIST, SESSION, HOLD_LIST_LIMIT, listOffset );
- req.callback(pullListDrawHolds);
- req.send();
+ var req = new Request(FETCH_HOLD_LIST, SESSION, HOLD_LIST_LIMIT, listOffset );
+ req.callback(pullListDrawHolds);
+ req.send();
}
var holdRowTemplate;
function pullListDrawHolds(r) {
- var holds = r.getResultObject();
+ var holds = r.getResultObject();
- var tbody = $('pull_list_tbody');
- if(!holdRowTemplate)
- holdRowTemplate = tbody.removeChild($('pull_list_row'));
- numHolds = holds.length;
+ var tbody = $('pull_list_tbody');
+ if(!holdRowTemplate)
+ holdRowTemplate = tbody.removeChild($('pull_list_row'));
+ numHolds = holds.length;
- for( var h in holds ) {
- var hold = holds[h];
- var row = holdRowTemplate.cloneNode(true);
- tbody.appendChild(row);
- pullListDrawHold( tbody, row, hold, h );
- }
+ for( var h in holds ) {
+ var hold = holds[h];
+ var row = holdRowTemplate.cloneNode(true);
+ tbody.appendChild(row);
+ pullListDrawHold( tbody, row, hold, h );
+ }
}
function pullListDrawHold( tbody, row, hold, idx ) {
- $n(row, 'date').appendChild(text(hold.request_time().replace(/\ .*/, "")));
-
- switch( hold.hold_type() ) {
- case 'C' : unHideMe($n(row, 'copy_hold')); break;
- case 'V' : unHideMe($n(row, 'volume_hold')); break;
- case 'T' : unHideMe($n(row, 'title_hold')); break;
- case 'M' : unHideMe($n(row, 'mr_hold')); break;
- }
-
- var treq = new Request( FETCH_MODS_FROM_COPY, hold.current_copy() );
- treq.callback(
- function(r) {
- pullListDrawTitle( tbody, row, hold, idx, r.getResultObject() ); });
- treq.send();
-
- var creq = new Request( FETCH_COPY, hold.current_copy(), ['location'] );
- creq.callback(
- function(r) {
- pullListDrawCopy( tbody, row, hold, idx, r.getResultObject() ); });
- creq.send();
-
- var ureq = new Request( FETCH_USER, SESSION, hold.usr(), ['card'] );
- ureq.callback(
- function(r) {
- pullListDrawUser( tbody, row, hold, idx, r.getResultObject() ); });
- ureq.send();
+ $n(row, 'date').appendChild(text(hold.request_time().replace(/\ .*/, "")));
+
+ switch( hold.hold_type() ) {
+ case 'C' : unHideMe($n(row, 'copy_hold')); break;
+ case 'V' : unHideMe($n(row, 'volume_hold')); break;
+ case 'T' : unHideMe($n(row, 'title_hold')); break;
+ case 'M' : unHideMe($n(row, 'mr_hold')); break;
+ }
+
+ var treq = new Request( FETCH_MODS_FROM_COPY, hold.current_copy() );
+ treq.callback(
+ function(r) {
+ pullListDrawTitle( tbody, row, hold, idx, r.getResultObject() ); });
+ treq.send();
+
+ var creq = new Request( FETCH_COPY, hold.current_copy(), ['location'] );
+ creq.callback(
+ function(r) {
+ pullListDrawCopy( tbody, row, hold, idx, r.getResultObject() ); });
+ creq.send();
+
+ var ureq = new Request( FETCH_USER, SESSION, hold.usr(), ['card'] );
+ ureq.callback(
+ function(r) {
+ pullListDrawUser( tbody, row, hold, idx, r.getResultObject() ); });
+ ureq.send();
}
function pullListDrawTitle( tbody, row, hold, idx, record ) {
- $n(row, 'title').appendChild(text(record.title()));
- $n(row, 'author').appendChild(text(record.author()));
+ $n(row, 'title').appendChild(text(record.title()));
+ $n(row, 'author').appendChild(text(record.author()));
- var type = modsFormatToMARC(record.types_of_resource()[0]);
- unHideMe($n(row, 'format_' + type));
+ var type = modsFormatToMARC(record.types_of_resource()[0]);
+ unHideMe($n(row, 'format_' + type));
}
function pullListDrawCopy( tbody, row, hold, idx, copy ) {
- $n(row, 'barcode').appendChild(text(copy.barcode()));
- $n(row, 'copy_location').appendChild(text(copy.location().name()));
- $n(row, 'copy_number').appendChild(text(copy.copy_number()));
+ $n(row, 'barcode').appendChild(text(copy.barcode()));
+ $n(row, 'copy_location').appendChild(text(copy.location().name()));
+ $n(row, 'copy_number').appendChild(text(copy.copy_number()));
- var vreq = new Request(FETCH_VOLUME, copy.call_number());
- vreq.callback(
- function(r) { pullListDrawVolume( tbody, row, hold, idx, r.getResultObject() ); } );
- vreq.send();
+ var vreq = new Request(FETCH_VOLUME, copy.call_number());
+ vreq.callback(
+ function(r) { pullListDrawVolume( tbody, row, hold, idx, r.getResultObject() ); } );
+ vreq.send();
}
function pullListDrawUser( tbody, row, hold, idx, user ) {
- $n(row, 'patron').appendChild(text(user.card().barcode()));
+ $n(row, 'patron').appendChild(text(user.card().barcode()));
}
var callNumbers = [];
function pullListDrawVolume( tbody, row, hold, idx, volume ) {
- $n(row, 'call_number').appendChild(text(volume.label()));
- callNumbers.push(volume.label());
+ $n(row, 'call_number').appendChild(text(volume.label()));
+ callNumbers.push(volume.label());
- if( (parseInt(idx) +1) == numHolds )
- ts_resortTable($('pl_callnumber').getElementsByTagName('a')[0]);
+ if( (parseInt(idx) +1) == numHolds )
+ ts_resortTable($('pl_callnumber').getElementsByTagName('a')[0]);
}
var g = {};
-var FETCH_HOLD_LIST = 'open-ils.circ:open-ils.circ.hold_pull_list.retrieve';
-var FETCH_COPY = 'open-ils.search:open-ils.search.asset.copy.fleshed.custom';
-var FETCH_USER = 'open-ils.actor:open-ils.actor.user.fleshed.retrieve';
-var FETCH_VOLUME = 'open-ils.search:open-ils.search.callnumber.retrieve';
+var FETCH_HOLD_LIST = 'open-ils.circ:open-ils.circ.hold_pull_list.retrieve';
+var FETCH_COPY = 'open-ils.search:open-ils.search.asset.copy.fleshed.custom';
+var FETCH_USER = 'open-ils.actor:open-ils.actor.user.fleshed.retrieve';
+var FETCH_VOLUME = 'open-ils.search:open-ils.search.callnumber.retrieve';
-var myPerms = [ 'VIEW_HOLD' ];
-var HOLD_LIST_LIMIT = 100;
-var numHolds = 0;
+var myPerms = [ 'VIEW_HOLD' ];
+var HOLD_LIST_LIMIT = 100;
+var numHolds = 0;
-var listOffset = 0;
+var listOffset = 0;
function pullListInit() {
- 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('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
-
- fetchUser();
- $('pl_user').appendChild(text(USER.usrname()));
- $('pl_org').appendChild(text(findOrgUnit(USER.ws_ou()).name()));
- setTimeout( function() {
- fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
- pullListFetchHolds();
- }, 20 );
+ 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('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
+
+ fetchUser();
+ $('pl_user').appendChild(text(USER.usrname()));
+ $('pl_org').appendChild(text(findOrgUnit(USER.ws_ou()).name()));
+ setTimeout( function() {
+ fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
+ pullListFetchHolds();
+ }, 20 );
}
function pullListFetchHolds() {
- var req = new Request(FETCH_HOLD_LIST, SESSION, HOLD_LIST_LIMIT, listOffset );
- req.callback(pullListDrawHolds);
- req.send();
+ var req = new Request(FETCH_HOLD_LIST, SESSION, HOLD_LIST_LIMIT, listOffset );
+ req.callback(pullListDrawHolds);
+ req.send();
}
var holdRowTemplate;
function pullListDrawHolds(r) {
- var holds = r.getResultObject();
+ var holds = r.getResultObject();
- var tbody = $('pull_list_tbody');
- if(!holdRowTemplate)
- holdRowTemplate = tbody.removeChild($('pull_list_row'));
- numHolds = holds.length;
+ var tbody = $('pull_list_tbody');
+ if(!holdRowTemplate)
+ holdRowTemplate = tbody.removeChild($('pull_list_row'));
+ numHolds = holds.length;
- for( var h in holds ) {
- var hold = holds[h];
- var row = holdRowTemplate.cloneNode(true);
- tbody.appendChild(row);
- pullListDrawHold( tbody, row, hold, h );
- }
+ for( var h in holds ) {
+ var hold = holds[h];
+ var row = holdRowTemplate.cloneNode(true);
+ tbody.appendChild(row);
+ pullListDrawHold( tbody, row, hold, h );
+ }
}
function pullListDrawHold( tbody, row, hold, idx ) {
- $n(row, 'date').appendChild(text(hold.request_time().replace(/\ .*/, "")));
- var pl = typeof hold.pickup_lib() == 'object' ? hold.pickup_lib().shortname() : g.data.hash.aou[ hold.pickup_lib() ].shortname();
- $n(row, 'pickup').appendChild(text(pl));
-
- switch( hold.hold_type() ) {
- case 'C' : unHideMe($n(row, 'copy_hold')); break;
- case 'V' : unHideMe($n(row, 'volume_hold')); break;
- case 'T' : unHideMe($n(row, 'title_hold')); break;
- case 'M' : unHideMe($n(row, 'mr_hold')); break;
- }
-
- var treq = new Request( FETCH_MODS_FROM_COPY, hold.current_copy() );
- treq.callback(
- function(r) {
- pullListDrawTitle( tbody, row, hold, idx, r.getResultObject() ); });
- treq.send();
-
- var creq = new Request( FETCH_COPY, hold.current_copy(), ['location'] );
- creq.callback(
- function(r) {
- pullListDrawCopy( tbody, row, hold, idx, r.getResultObject() ); });
- creq.send();
-
- var ureq = new Request( FETCH_USER, SESSION, hold.usr(), ['card'] );
- ureq.callback(
- function(r) {
- pullListDrawUser( tbody, row, hold, idx, r.getResultObject() ); });
- ureq.send();
+ $n(row, 'date').appendChild(text(hold.request_time().replace(/\ .*/, "")));
+ var pl = typeof hold.pickup_lib() == 'object' ? hold.pickup_lib().shortname() : g.data.hash.aou[ hold.pickup_lib() ].shortname();
+ $n(row, 'pickup').appendChild(text(pl));
+
+ switch( hold.hold_type() ) {
+ case 'C' : unHideMe($n(row, 'copy_hold')); break;
+ case 'V' : unHideMe($n(row, 'volume_hold')); break;
+ case 'T' : unHideMe($n(row, 'title_hold')); break;
+ case 'M' : unHideMe($n(row, 'mr_hold')); break;
+ }
+
+ var treq = new Request( FETCH_MODS_FROM_COPY, hold.current_copy() );
+ treq.callback(
+ function(r) {
+ pullListDrawTitle( tbody, row, hold, idx, r.getResultObject() ); });
+ treq.send();
+
+ var creq = new Request( FETCH_COPY, hold.current_copy(), ['location'] );
+ creq.callback(
+ function(r) {
+ pullListDrawCopy( tbody, row, hold, idx, r.getResultObject() ); });
+ creq.send();
+
+ var ureq = new Request( FETCH_USER, SESSION, hold.usr(), ['card'] );
+ ureq.callback(
+ function(r) {
+ pullListDrawUser( tbody, row, hold, idx, r.getResultObject() ); });
+ ureq.send();
}
function pullListDrawTitle( tbody, row, hold, idx, record ) {
- $n(row, 'title').appendChild(text(record.title()));
- $n(row, 'author').appendChild(text(record.author()));
+ $n(row, 'title').appendChild(text(record.title()));
+ $n(row, 'author').appendChild(text(record.author()));
- var type = modsFormatToMARC(record.types_of_resource()[0]);
- unHideMe($n(row, 'format_' + type));
- if( (parseInt(idx) +1) == numHolds ) update_ready('title');
+ var type = modsFormatToMARC(record.types_of_resource()[0]);
+ unHideMe($n(row, 'format_' + type));
+ if( (parseInt(idx) +1) == numHolds ) update_ready('title');
}
function pullListDrawCopy( tbody, row, hold, idx, copy ) {
- $n(row, 'barcode').appendChild(text(copy.barcode()));
- $n(row, 'copy_location').appendChild(text(copy.location().name()));
- $n(row, 'copy_number').appendChild(text(copy.copy_number()));
- try {
- if (copy.age_protect()) {
- $n(row, 'age_protect').appendChild(text( (copy.age_protect() == null ? '<Unset>' : ( typeof copy.age_protect() == 'object' ? copy.age_protect().name() : g.data.hash.crahp[ copy.age_protect() ].name() )) + ' (' + copy.create_date().substr(0,10) + ')' ));
- unHideMe($n(row, 'age_protect_span'));
- }
- } catch(E) { alert(E); }
-
- var vreq = new Request(FETCH_VOLUME, copy.call_number());
- vreq.callback(
- function(r) { pullListDrawVolume( tbody, row, hold, idx, r.getResultObject() ); } );
- vreq.send();
+ $n(row, 'barcode').appendChild(text(copy.barcode()));
+ $n(row, 'copy_location').appendChild(text(copy.location().name()));
+ $n(row, 'copy_number').appendChild(text(copy.copy_number()));
+ try {
+ if (copy.age_protect()) {
+ $n(row, 'age_protect').appendChild(text( (copy.age_protect() == null ? '<Unset>' : ( typeof copy.age_protect() == 'object' ? copy.age_protect().name() : g.data.hash.crahp[ copy.age_protect() ].name() )) + ' (' + copy.create_date().substr(0,10) + ')' ));
+ unHideMe($n(row, 'age_protect_span'));
+ }
+ } catch(E) { alert(E); }
+
+ var vreq = new Request(FETCH_VOLUME, copy.call_number());
+ vreq.callback(
+ function(r) { pullListDrawVolume( tbody, row, hold, idx, r.getResultObject() ); } );
+ vreq.send();
}
function pullListDrawUser( tbody, row, hold, idx, user ) {
- $n(row, 'patron').appendChild(text(user.card().barcode()));
- if( (parseInt(idx) +1) == numHolds ) update_ready('patron');
+ $n(row, 'patron').appendChild(text(user.card().barcode()));
+ if( (parseInt(idx) +1) == numHolds ) update_ready('patron');
}
var callNumbers = [];
function pullListDrawVolume( tbody, row, hold, idx, volume ) {
- $n(row, 'call_number').appendChild(text(volume.label()));
- callNumbers.push(volume.label());
+ $n(row, 'call_number').appendChild(text(volume.label()));
+ callNumbers.push(volume.label());
- if( (parseInt(idx) +1) == numHolds ) update_ready('call_number');
+ if( (parseInt(idx) +1) == numHolds ) update_ready('call_number');
}
function ts_getInnerText(el) {
- try {
- if (el == null) { alert('null'); return ''; }
- if (typeof el == "string") return el;
- if (typeof el == "undefined") { return el };
- if (el.innerText) return el.innerText; //Not needed but it is faster
- var str = "";
-
- var cs = el.childNodes;
- var l = cs.length;
- for (var i = 0; i < l; i++) {
- switch (cs[i].nodeType) {
- case 1: //ELEMENT_NODE
- str += ts_getInnerText(cs[i]);
- break;
- case 3: //TEXT_NODE
- str += cs[i].nodeValue;
- break;
- }
- }
- return str;
- } catch(E) {
- try {
- alert('el = ' + el + '\nel.nodeName = ' + el.nodeName + ' el.nodeType = ' + el.nodeType + '\nE = ' + E);
- } catch(F) {
- alert('el = ' + el + '\nF = ' + F + '\nE = ' + E);
- }
- }
+ try {
+ if (el == null) { alert('null'); return ''; }
+ if (typeof el == "string") return el;
+ if (typeof el == "undefined") { return el };
+ if (el.innerText) return el.innerText; //Not needed but it is faster
+ var str = "";
+
+ var cs = el.childNodes;
+ var l = cs.length;
+ for (var i = 0; i < l; i++) {
+ switch (cs[i].nodeType) {
+ case 1: //ELEMENT_NODE
+ str += ts_getInnerText(cs[i]);
+ break;
+ case 3: //TEXT_NODE
+ str += cs[i].nodeValue;
+ break;
+ }
+ }
+ return str;
+ } catch(E) {
+ try {
+ alert('el = ' + el + '\nel.nodeName = ' + el.nodeName + ' el.nodeType = ' + el.nodeType + '\nE = ' + E);
+ } catch(F) {
+ alert('el = ' + el + '\nF = ' + F + '\nE = ' + E);
+ }
+ }
}
function get_unhidden_span(node) {
- var nl = node.childNodes;
- var s = '';
- for (var i = 0; i < nl.length; i++) {
- if (nl[i].nodeName != 'span') continue;
- if (nl[i].getAttribute('class') != 'hide_me') s += ts_getInnerText(nl[i]);
- }
- return s;
+ var nl = node.childNodes;
+ var s = '';
+ for (var i = 0; i < nl.length; i++) {
+ if (nl[i].nodeName != 'span') continue;
+ if (nl[i].getAttribute('class') != 'hide_me') s += ts_getInnerText(nl[i]);
+ }
+ return s;
}
function $f(parent,name) {
- var nl = parent.childNodes;
- for (var i = 0; i < nl.length; i++) {
- if (typeof nl[i].getAttribute != 'undefined' && nl[i].getAttribute('name') == name) {
- return nl[i];
- }
- }
+ var nl = parent.childNodes;
+ for (var i = 0; i < nl.length; i++) {
+ if (typeof nl[i].getAttribute != 'undefined' && nl[i].getAttribute('name') == name) {
+ return nl[i];
+ }
+ }
}
function update_ready(which_update) {
- g[which_update] = true;
- if (typeof g.title != 'undefined' && typeof g.patron != 'undefined' && typeof g.call_number != 'undefined') {
- setTimeout( function() { update_ready_do_it(); }, 1000);
- }
+ g[which_update] = true;
+ if (typeof g.title != 'undefined' && typeof g.patron != 'undefined' && typeof g.call_number != 'undefined') {
+ setTimeout( function() { update_ready_do_it(); }, 1000);
+ }
}
function update_ready_do_it() {
- unHideMe($('pull_list_tbody')); hideMe($('inprogress'));
- var rows = [];
- var div = $('pull_list_tbody');
- var div_children = div.childNodes;
- for (var i = 0; i < div_children.length; i++) {
- var pre = div_children[i];
- if (pre.nodeName != 'pre') continue;
- value = (
- {
- 'call_number' : ts_getInnerText($f(pre,'call_number')),
- 'title' : ts_getInnerText($f(pre,'title')),
- 'author' : ts_getInnerText($f(pre,'author')),
- 'location' : ts_getInnerText($f(pre,'copy_location')),
- 'copy_number' : ts_getInnerText($f(pre,'copy_number')),
- 'item_type' : get_unhidden_span($f(pre,'item_type')),
- 'node' : pre
- }
- );
- rows.push( value );
- }
- rows = rows.sort( function(a,b) {
- function inner_sort(sort_type,a,b) {
- switch(sort_type) {
- case 'number' :
- a = Number(a); b = Number(b);
- break;
- case 'title' : /* special case for "a" and "the". doesn't use marc 245 indicator */
- a = String( a ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
- b = String( b ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
- break;
- default:
- a = String( a ).toUpperCase();
- b = String( b ).toUpperCase();
- break;
- }
-
- if (a < b) return -1;
- if (a > b) return 1;
- return 0;
- }
- var value = inner_sort('string',a.call_number,b.call_number);
- if (value == 0) value = inner_sort('title',a.title,b.title);
- if (value == 0) value = inner_sort('string',a.author,b.author);
- if (value == 0) value = inner_sort('string',a.location,b.location);
- if (value == 0) value = inner_sort('number',a.copy_number,b.copy_number);
- if (value == 0) value = inner_sort('string',a.item_type,b.item_type);
- return value;
- } );
- while(div.lastChild) div.removeChild( div.lastChild );
- for (var i = 0; i < rows.length; i++) {
- div.appendChild( rows[i].node );
- }
+ unHideMe($('pull_list_tbody')); hideMe($('inprogress'));
+ var rows = [];
+ var div = $('pull_list_tbody');
+ var div_children = div.childNodes;
+ for (var i = 0; i < div_children.length; i++) {
+ var pre = div_children[i];
+ if (pre.nodeName != 'pre') continue;
+ value = (
+ {
+ 'call_number' : ts_getInnerText($f(pre,'call_number')),
+ 'title' : ts_getInnerText($f(pre,'title')),
+ 'author' : ts_getInnerText($f(pre,'author')),
+ 'location' : ts_getInnerText($f(pre,'copy_location')),
+ 'copy_number' : ts_getInnerText($f(pre,'copy_number')),
+ 'item_type' : get_unhidden_span($f(pre,'item_type')),
+ 'node' : pre
+ }
+ );
+ rows.push( value );
+ }
+ rows = rows.sort( function(a,b) {
+ function inner_sort(sort_type,a,b) {
+ switch(sort_type) {
+ case 'number' :
+ a = Number(a); b = Number(b);
+ break;
+ case 'title' : /* special case for "a" and "the". doesn't use marc 245 indicator */
+ a = String( a ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
+ b = String( b ).toUpperCase().replace( /^\s*(THE|A|AN)\s+/, '' );
+ break;
+ default:
+ a = String( a ).toUpperCase();
+ b = String( b ).toUpperCase();
+ break;
+ }
+
+ if (a < b) return -1;
+ if (a > b) return 1;
+ return 0;
+ }
+ var value = inner_sort('string',a.call_number,b.call_number);
+ if (value == 0) value = inner_sort('title',a.title,b.title);
+ if (value == 0) value = inner_sort('string',a.author,b.author);
+ if (value == 0) value = inner_sort('string',a.location,b.location);
+ if (value == 0) value = inner_sort('number',a.copy_number,b.copy_number);
+ if (value == 0) value = inner_sort('string',a.item_type,b.item_type);
+ return value;
+ } );
+ while(div.lastChild) div.removeChild( div.lastChild );
+ for (var i = 0; i < rows.length; i++) {
+ div.appendChild( rows[i].node );
+ }
}
var UPDATE_NON_CAT_TYPE = "open-ils.circ:open-ils.circ.non_cat_type.update";
var DELETE_NON_CAT_TYPE = 'open-ils.circ:open-ils.circ.non_cataloged_type.delete';
var myPerms = [
- 'CREATE_NON_CAT_TYPE',
- 'UPDATE_NON_CAT_TYPE',
- 'DELETE_NON_CAT_TYPE' ];
+ 'CREATE_NON_CAT_TYPE',
+ 'UPDATE_NON_CAT_TYPE',
+ 'DELETE_NON_CAT_TYPE' ];
var focusOrg;
function ncEditorInit() {
- fetchUser();
- $('nc_user').appendChild(text(USER.usrname()));
- setTimeout(
+ fetchUser();
+ $('nc_user').appendChild(text(USER.usrname()));
+ setTimeout(
function() {
fetchHighestWorkPermOrgs(SESSION, USER.id(), myPerms,
function() {
ncSetupFocus();
- ncBuildNew();
- ncFetchTypes();
+ ncBuildNew();
+ ncFetchTypes();
}
);
}, 20 );
}
function ncSetupFocus() {
- var fselector = $('nc_org_filter');
+ var fselector = $('nc_org_filter');
var org_list = OILS_WORK_PERMS.UPDATE_NON_CAT_TYPE;
if(org_list.length == 0)
return;
- fselector.disabled = false;
- buildMergedOrgSel(fselector, org_list, 0, 'shortname');
+ fselector.disabled = false;
+ buildMergedOrgSel(fselector, org_list, 0, 'shortname');
fselector.onchange = function() {
focusOrg = getSelectorVal(fselector);
ncBuildNew();
function ncBuildNew() {
- var name = $('nc_new_name');
- name.focus();
+ var name = $('nc_new_name');
+ name.focus();
var org_list = OILS_WORK_PERMS.CREATE_NON_CAT_TYPE;
if(org_list.length == 0) return;
- var selector = $('nc_new_owner');
- buildMergedOrgSel(selector, org_list, 0, 'shortname');
- selector.disabled = false;
+ var selector = $('nc_new_owner');
+ buildMergedOrgSel(selector, org_list, 0, 'shortname');
+ selector.disabled = false;
- $('nc_new_submit').disabled = false;
- $('nc_new_submit').onclick = ncCreateNew;
+ $('nc_new_submit').disabled = false;
+ $('nc_new_submit').onclick = ncCreateNew;
}
function ncFetchTypes() {
- var req = new Request( FETCH_NON_CAT_TYPES, focusOrg );
- req.callback(ncDisplayTypes);
- setTimeout(function(){req.send();}, 500);
+ var req = new Request( FETCH_NON_CAT_TYPES, focusOrg );
+ req.callback(ncDisplayTypes);
+ setTimeout(function(){req.send();}, 500);
}
function ncCreateNew() {
- var name = $('nc_new_name').value;
- if(!name) return;
- var org = getSelectorVal($('nc_new_owner'));
- var time = $('nc_new_interval_count').value;
- var type = getSelectorVal($('nc_new_interval_type'));
- var inh = $('nc_new_inhouse').checked ? 1 : null;
-
- var req = new Request(CREATE_NON_CAT_TYPE, SESSION, name, org, time + ' ' + type, inh );
- req.request.alertEvent = false;
- req.send(true);
- var res = req.result();
-
- if(checkILSEvent(res)) {
- if( res.textcode == 'NON_CAT_TYPE_EXISTS' )
- return alertId('nc_type_exists');
- alert(js2JSON(res));
- }
-
- alertId('nc_update_success');
- ncFetchTypes();
+ var name = $('nc_new_name').value;
+ if(!name) return;
+ var org = getSelectorVal($('nc_new_owner'));
+ var time = $('nc_new_interval_count').value;
+ var type = getSelectorVal($('nc_new_interval_type'));
+ var inh = $('nc_new_inhouse').checked ? 1 : null;
+
+ var req = new Request(CREATE_NON_CAT_TYPE, SESSION, name, org, time + ' ' + type, inh );
+ req.request.alertEvent = false;
+ req.send(true);
+ var res = req.result();
+
+ if(checkILSEvent(res)) {
+ if( res.textcode == 'NON_CAT_TYPE_EXISTS' )
+ return alertId('nc_type_exists');
+ alert(js2JSON(res));
+ }
+
+ alertId('nc_update_success');
+ ncFetchTypes();
}
var rowTemplate;
function ncDisplayTypes(r) {
- var types = r.getResultObject();
- var tbody = $('nc_tbody');
- if(!rowTemplate)
- rowTemplate = tbody.removeChild($('nc_row_template'));
+ var types = r.getResultObject();
+ var tbody = $('nc_tbody');
+ if(!rowTemplate)
+ rowTemplate = tbody.removeChild($('nc_row_template'));
- removeChildren(tbody);
- types = types.sort(
- function(a,b) {
- try {
- if( a.name()+''.toLowerCase() > b.name()+''.toLowerCase() ) return 1;
- if( a.name()+''.toLowerCase() < b.name()+''.toLowerCase() ) return -1;
- } catch(e) {}
- return 0;
- });
+ removeChildren(tbody);
+ types = types.sort(
+ function(a,b) {
+ try {
+ if( a.name()+''.toLowerCase() > b.name()+''.toLowerCase() ) return 1;
+ if( a.name()+''.toLowerCase() < b.name()+''.toLowerCase() ) return -1;
+ } catch(e) {}
+ return 0;
+ });
- for( var idx = 0; idx != types.length; idx++ ) {
+ for( var idx = 0; idx != types.length; idx++ ) {
- var type = types[idx];
- var org = findOrgUnit( type.owning_lib() );
- var row = rowTemplate.cloneNode(true);
+ var type = types[idx];
+ var org = findOrgUnit( type.owning_lib() );
+ var row = rowTemplate.cloneNode(true);
- row.id = 'nc_row_' + type.id();
- $n(row, 'nc_name').appendChild(text(type.name()));
- $n(row, 'nc_owner').appendChild(text(org.name()));
- $n(row, 'nc_inhouse').checked = isTrue(type.in_house());
+ row.id = 'nc_row_' + type.id();
+ $n(row, 'nc_name').appendChild(text(type.name()));
+ $n(row, 'nc_owner').appendChild(text(org.name()));
+ $n(row, 'nc_inhouse').checked = isTrue(type.in_house());
- var idata = _splitInterval(type.circ_duration());
- $n(row, 'nc_interval_count').value = idata[0];
- setSelector( $n(row, 'nc_interval_type'), idata[1]);
+ var idata = _splitInterval(type.circ_duration());
+ $n(row, 'nc_interval_count').value = idata[0];
+ setSelector( $n(row, 'nc_interval_type'), idata[1]);
- ncSetRowCallbacks( type, org, tbody, row );
- tbody.appendChild(row);
- }
+ ncSetRowCallbacks( type, org, tbody, row );
+ tbody.appendChild(row);
+ }
}
/* this is a kind of brittle, but works with the data we create */
function _splitInterval( interval ) {
- interval = interval.split(/ /);
- var time = interval[0];
- var type = interval[1];
-
- if( time.match(/:/) ) {
- var d = time.split(/:/);
- if(d[0] == '00') return [ d[1], 'minutes' ];
- if(d[0] != '00' && d[1] != '00')
- return [ parseInt(d[1]) + (d[0]*60), 'minutes' ];
- return [ d[0], 'hours' ]
- }
-
- if( type.match(/mi/i) ) return [ time, 'minutes' ];
- if( type.match(/h/i) ) return [ time, 'hours' ];
- if( type.match(/d/i) ) return [ time, 'days' ];
- if( type.match(/w/i) ) return [ time, 'weeks' ];
- if( type.match(/mo/i) ) return [ time, 'months' ];
+ interval = interval.split(/ /);
+ var time = interval[0];
+ var type = interval[1];
+
+ if( time.match(/:/) ) {
+ var d = time.split(/:/);
+ if(d[0] == '00') return [ d[1], 'minutes' ];
+ if(d[0] != '00' && d[1] != '00')
+ return [ parseInt(d[1]) + (d[0]*60), 'minutes' ];
+ return [ d[0], 'hours' ]
+ }
+
+ if( type.match(/mi/i) ) return [ time, 'minutes' ];
+ if( type.match(/h/i) ) return [ time, 'hours' ];
+ if( type.match(/d/i) ) return [ time, 'days' ];
+ if( type.match(/w/i) ) return [ time, 'weeks' ];
+ if( type.match(/mo/i) ) return [ time, 'months' ];
}
function ncSetRowCallbacks( type, owner, tbody, row ) {
- checkPermOrgDisabled($n(row, 'nc_edit'), owner, 'UPDATE_NON_CAT_TYPE');
+ checkPermOrgDisabled($n(row, 'nc_edit'), owner, 'UPDATE_NON_CAT_TYPE');
- checkPermOrgDisabled($n(row, 'nc_delete'), owner, 'DELETE_NON_CAT_TYPE');
+ checkPermOrgDisabled($n(row, 'nc_delete'), owner, 'DELETE_NON_CAT_TYPE');
- $n(row, 'nc_edit').onclick =
- function() { ncEditType( tbody, row, type ); };
+ $n(row, 'nc_edit').onclick =
+ function() { ncEditType( tbody, row, type ); };
- $n(row, 'nc_delete').onclick =
- function() { ncDeleteType( tbody, row, type ); };
+ $n(row, 'nc_delete').onclick =
+ function() { ncDeleteType( tbody, row, type ); };
}
function ncEditType( tbody, row, type ) {
- cleanTbody(row.parentNode, 'edit');
- var row = $('nc_edit_row_template').cloneNode(true);
+ cleanTbody(row.parentNode, 'edit');
+ var row = $('nc_edit_row_template').cloneNode(true);
- var name = $n(row, 'nc_edit_name');
- name.value = type.name();
+ var name = $n(row, 'nc_edit_name');
+ name.value = type.name();
- var idata = _splitInterval(type.circ_duration());
- $n(row, 'nc_edit_interval_count').value = idata[0];
- setSelector( $n(row, 'nc_edit_interval_type'), idata[1]);
+ var idata = _splitInterval(type.circ_duration());
+ $n(row, 'nc_edit_interval_count').value = idata[0];
+ setSelector( $n(row, 'nc_edit_interval_type'), idata[1]);
- $n(row, 'nc_edit_inhouse').checked = isTrue(type.in_house());
- $n(row, 'nc_edit_owner').appendChild(text( findOrgUnit(type.owning_lib()).name() ));
+ $n(row, 'nc_edit_inhouse').checked = isTrue(type.in_house());
+ $n(row, 'nc_edit_owner').appendChild(text( findOrgUnit(type.owning_lib()).name() ));
- $n(row, 'nc_edit_submit').onclick = function() {
- var name = $n(row, 'nc_edit_name').value;
- var time = $n(row, 'nc_edit_interval_count').value;
- var tp = getSelectorVal($n(row, 'nc_edit_interval_type'));
- var inh = $n(row, 'nc_edit_inhouse').checked ? 't' : 'f';
- ncEditSubmit( type, name, time + ' ' + tp, inh );
- };
+ $n(row, 'nc_edit_submit').onclick = function() {
+ var name = $n(row, 'nc_edit_name').value;
+ var time = $n(row, 'nc_edit_interval_count').value;
+ var tp = getSelectorVal($n(row, 'nc_edit_interval_type'));
+ var inh = $n(row, 'nc_edit_inhouse').checked ? 't' : 'f';
+ ncEditSubmit( type, name, time + ' ' + tp, inh );
+ };
- $n(row, 'nc_edit_cancel').onclick =
- function(){cleanTbody(row.parentNode, 'edit'); }
+ $n(row, 'nc_edit_cancel').onclick =
+ function(){cleanTbody(row.parentNode, 'edit'); }
- var r = $('nc_row_' + type.id());
- if(r.nextSibling) tbody.insertBefore( row, r.nextSibling );
- else{ tbody.appendChild(row); }
+ var r = $('nc_row_' + type.id());
+ if(r.nextSibling) tbody.insertBefore( row, r.nextSibling );
+ else{ tbody.appendChild(row); }
- name.focus();
- name.select();
+ name.focus();
+ name.select();
}
function ncEditSubmit( type, name, interval, inhouse ) {
- if(!name) return;
- type.name(name);
- type.circ_duration(interval);
- type.in_house(inhouse);
- var req = new Request( UPDATE_NON_CAT_TYPE, SESSION, type );
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- alertId('nc_update_success');
- ncFetchTypes();
+ if(!name) return;
+ type.name(name);
+ type.circ_duration(interval);
+ type.in_house(inhouse);
+ var req = new Request( UPDATE_NON_CAT_TYPE, SESSION, type );
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ alertId('nc_update_success');
+ ncFetchTypes();
}
function ncDeleteType( tbody, row, type ) {
- if( ! confirm($('nc_delete_confirm').innerHTML) ) return;
- var req = new Request(DELETE_NON_CAT_TYPE, SESSION, type.id());
- req.callback(
- function(r) {
- var res = r.getResultObject();
- if(checkILSEvent(res)) alertILSEvent(res);
- alertId('nc_update_success');
- ncFetchTypes();
- }
- );
- req.send();
+ if( ! confirm($('nc_delete_confirm').innerHTML) ) return;
+ var req = new Request(DELETE_NON_CAT_TYPE, SESSION, type.id());
+ req.callback(
+ function(r) {
+ var res = r.getResultObject();
+ if(checkILSEvent(res)) alertILSEvent(res);
+ alertId('nc_update_success');
+ ncFetchTypes();
+ }
+ );
+ req.send();
}
if (typeof admin == 'undefined') admin = {};
admin.offline_manage_xacts = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
}
admin.offline_manage_xacts.prototype = {
- 'sel_list' : [],
- 'seslist' : [],
- 'sel_errors' : [],
-
- 'init' : function( params ) {
-
- var obj = this;
-
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
-
- obj.init_list(); obj.init_script_list(); obj.init_error_list();
-
- obj.retrieve_seslist(); obj.render_seslist();
-
- var x = document.getElementById('create');
- if (obj.check_perm(['OFFLINE_UPLOAD'])) {
- x.disabled = false;
- x.addEventListener('command',function() { try{obj.create_ses();}catch(E){alert(E);} },false);
- }
-
- x = obj.$('upload');
- x.addEventListener('command',function() { try{obj.upload();}catch(E){alert(E);} },false);
-
- x = obj.$('refresh');
- x.addEventListener('command',function() { try{$('deck').selectedIndex=0;obj.retrieve_seslist();obj.render_seslist();}catch(E){alert(E);} },false);
-
- x = obj.$('execute');
- x.addEventListener('command',function() { try{obj.execute_ses();}catch(E){alert(E);} },false);
-
- x = obj.$('retrieve_item');
- x.addEventListener('command',function() { try{obj.retrieve_item();}catch(E){alert(E);} },false);
-
- x = obj.$('retrieve_patron');
- x.addEventListener('command',function() { try{obj.retrieve_patron();}catch(E){alert(E);} },false);
-
- x = obj.$('retrieve_details');
- x.addEventListener('command',function() { try{obj.retrieve_details();}catch(E){alert(E);} },false);
-
- obj.$('deck').selectedIndex = 0;
- },
-
- '$' : function(id) { return document.getElementById(id); },
-
- 'init_list' : function() {
- var obj = this; JSAN.use('util.list'); JSAN.use('util.date'); JSAN.use('patron.util');
- obj.list = new util.list('session_tree');
- obj.list.init( {
- 'columns' : [
- {
- 'id' : 'org', 'hidden' : 'true', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.organization'),
- 'render' : function(my) { return obj.data.hash.aou[ my.org ].shortname(); }
- },
- {
- 'id' : 'description', 'flex' : '2',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.description'),
- 'render' : function(my) { return my.description; }
- },
- {
- 'id' : 'create_time', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.date_created'),
- 'render' : function(my) { if (my.create_time) { var x = new Date(); x.setTime(my.create_time+"000"); return util.date.formatted_date(x,"%F %H:%M"); } else { return ""; }; }
- },
- {
- 'id' : 'creator', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.created_by'),
- 'render' : function(my) { var staff_obj = patron.util.retrieve_name_via_id( ses(), my.creator ); return staff_obj[0] + " @ " + obj.data.hash.aou[ staff_obj[3] ].shortname(); }
- },
- {
- 'id' : 'count', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.upload_count'),
- 'render' : function(my) { return my.scripts.length; }
- },
- {
- 'id' : 'num_complete', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.transactions_processed'),
- 'render' : function(my) { return my.num_complete; }
- },
- {
- 'id' : 'in_process', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.processing'),
- 'render' : function(my) {
- if (my.end_time) {
- return $('adminStrings').getString('staff.admin.offline_manage_xacts.completed')
- } else {
- return get_bool(my.in_process) ? $('adminStrings').getString('staff.admin.offline_manage_xacts.yes') : $('adminStrings').getString('staff.admin.offline_manage_xacts.no')
- };
- }
- },
- {
- 'id' : 'start_time', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.date_started'),
- 'render' : function(my) { if (my.start_time) {var x = new Date(); x.setTime(my.start_time+"000"); return util.date.formatted_date(x,"%F %H:%M");} else { return ""; }; }
- },
- {
- 'id' : 'end_time', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.date_completed'),
- 'render' : function(my) { if (my.end_time) {var x = new Date(); x.setTime(my.end_time+"000"); return util.date.formatted_date(x,"%F %H:%M");} else { return ""; }; }
- },
- {
- 'id' : 'key', 'hidden' : 'true', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.session'),
- 'render' : function(my) { return my.key; }
- },
- ],
- 'map_row_to_columns' : patron.util.std_map_row_to_columns(),
- 'on_select' : function(ev) {
- try {
- $('deck').selectedIndex = 0;
- $('execute').disabled = true;
- $('upload').disabled = true;
- setTimeout(
- function() {
- try {
- JSAN.use('util.functional');
- var sel = obj.list.retrieve_selection();
- obj.sel_list = util.functional.map_list(
- sel,
- function(o) { return o.getAttribute('retrieve_id'); }
- );
- if (obj.sel_list.length == 0) return;
- {
- var upload = true; var process = true;
-
- if (obj.sel_list.length > 1) upload = false;
-
- if (obj.seslist[ obj.sel_list[0] ].end_time) {
- upload = false; process = false;
- }
- if (obj.seslist[ obj.sel_list[0] ].in_process == 1) {
- upload = false; process = false;
- }
-
- /* should we really have this next restriction? */
- for (var i = 0; i < obj.seslist[ obj.sel_list[0] ].scripts.length; i++) {
- if (obj.seslist[ obj.sel_list[0] ].scripts[i].workstation ==
- obj.data.ws_name ) upload = false;
- }
-
- if (upload) {
- if (obj.check_perm(['OFFLINE_UPLOAD'])) {
- document.getElementById('upload').disabled = false;
- }
- } else {
- document.getElementById('upload').disabled = true;
- }
- if (process) {
- if (obj.check_perm(['OFFLINE_EXECUTE'])) {
- document.getElementById('execute').disabled = false;
- }
- } else {
- document.getElementById('execute').disabled = true;
- }
- }
- var complete = false;
- for (var i = 0; i < obj.sel_list.length; i++) {
- if (obj.seslist[ obj.sel_list[i] ].end_time) { complete = true; }
- }
- if (complete) {
- obj.render_errorlist();
- } else {
- if (obj.seslist[ obj.sel_list[0] ].in_process == 1) {
- obj.render_status();
- } else {
- obj.render_scriptlist();
- }
- }
- } catch(E) {
- alert('on_select: ' + E);
- }
- }, 0
- );
- } catch(E) {
- alert('on_select:\nobj.seslist.length = ' + obj.seslist.length + ' obj.sel_list.length = ' + obj.sel_list.length + '\nerror: ' + E);
- }
- }
- } );
-
-
- },
-
- 'init_script_list' : function() {
- var obj = this; JSAN.use('util.list'); JSAN.use('util.date'); JSAN.use('patron.util');
- obj.script_list = new util.list('script_tree');
- obj.script_list.init( {
- 'columns' : [
- {
- 'id' : 'create_time', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_script_list.date_uploaded'),
- 'render' : function(my) { if (my.create_time) { var x = new Date(); x.setTime(my.create_time+"000"); return util.date.formatted_date(x,"%F %H:%M"); } else { return ""; }; }
- },
- {
- 'id' : 'requestor', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_script_list.uploaded_by'),
- 'render' : function(my) { var staff_obj = patron.util.retrieve_name_via_id( ses(), my.requestor ); return staff_obj[0] + " @ " + obj.data.hash.aou[ staff_obj[3] ].shortname(); }
- },
- {
- 'id' : 'time_delta', 'hidden' : 'true', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_script_list.time_delta'),
- 'render' : function(my) { return my.time_delta; }
- },
- {
- 'id' : 'workstation', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_script_list.workstation'),
- 'render' : function(my) { return my.workstation; }
- },
- ],
- 'map_row_to_columns' : patron.util.std_map_row_to_columns()
- } );
-
-
- },
-
- 'init_error_list' : function() {
- var obj = this; JSAN.use('util.list'); JSAN.use('util.date'); JSAN.use('patron.util'); JSAN.use('util.functional');
- obj.error_list = new util.list('error_tree');
- obj.error_list.init( {
- 'columns' : [
- {
- 'id' : 'workstation', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.workstation'),
- 'render' : function(my) { return my.command._workstation ? my.command._workstation : my.command._worksation; }
- },
- {
- 'id' : 'timestamp', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.timestamp'),
- 'render' : function(my) { if (my.command.timestamp) { var x = new Date(); x.setTime(my.command.timestamp+"000"); return util.date.formatted_date(x,"%F %H:%M"); } else { return my.command._realtime; }; }
- },
- {
- 'id' : 'type', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.type'),
- 'render' : function(my) { return my.command.type; }
- },
- {
- 'id' : 'ilsevent', 'hidden' : 'true', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.event_code'),
- 'render' : function(my) { return my.event.ilsevent; }
- },
- {
- 'id' : 'textcode', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.event_name'),
- 'render' : function(my) { return typeof my.event.textcode != 'undefined' ? my.event.textcode : util.functional.map_list( my.event, function(o) { return o.textcode; }).join('/'); }
- },
- {
- 'id' : 'desc', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.event_description'),
- 'render' : function(my) { return my.event.desc; }
- },
- {
- 'id' : 'i_barcode', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.item_barcode'),
- 'render' : function(my) { return my.command.barcode ? my.command.barcode : ""; }
- },
- {
- 'id' : 'p_barcode', 'flex' : '1',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.patron_barcode'),
- 'render' : function(my) { if (my.command.patron_barcode) { return my.command.patron_barcode; } else { if (my.command.user.card.barcode) { return my.command.user.card.barcode; } else { return ""; } }; }
- },
- {
- 'id' : 'duedate', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.due_date'),
- 'render' : function(my) { return my.command.due_date || ""; }
- },
- {
- 'id' : 'backdate', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.backdate'),
- 'render' : function(my) { return my.command.backdate || ""; }
- },
- {
- 'id' : 'count', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.count'),
- 'render' : function(my) { return my.command.count || ""; }
- },
- {
- 'id' : 'noncat', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.noncat'),
- 'render' : function(my) { return get_bool(my.command.noncat) ? $('adminStrings').getString('staff.admin.offline_manage_xacts.yes') : $('adminStrings').getString('staff.admin.offline_manage_xacts.no'); }
- },
- {
- 'id' : 'noncat_type', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.noncat_type'),
- 'render' : function(my) { return data.hash.cnct[ my.command.noncat_type ] ? obj.data.hash.cnct[ my.command.noncat_type ].name() : ""; }
- },
- {
- 'id' : 'noncat_count', 'flex' : '1', 'hidden' : 'true',
- 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.noncat_count'),
- 'render' : function(my) { return my.command.noncat_count || ""; }
- },
- ],
- 'map_row_to_columns' : patron.util.std_map_row_to_columns(),
- 'on_select' : function(ev) {
- try {
- var sel = obj.error_list.retrieve_selection();
- obj.sel_errors = util.functional.map_list(
- sel,
- function(o) { return o.getAttribute('retrieve_id'); }
- );
- if (obj.sel_errors.length > 0) {
- obj.$('retrieve_item').disabled = false;
- obj.$('retrieve_patron').disabled = false;
- obj.$('retrieve_details').disabled = false;
- } else {
- obj.$('retrieve_item').disabled = true;
- obj.$('retrieve_patron').disabled = true;
- obj.$('retrieve_details').disabled = true;
- }
- } catch(E) {
- alert(E);
- }
- }
- } );
-
- var export_button = document.getElementById('export_btn');
- if (export_button) export_button.addEventListener(
- 'command',
- function(ev) {
- try {
- obj.error_list.dump_csv_to_clipboard();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('export',E);
- }
- },
- false
- );
-
- var print_export_button = document.getElementById('print_export_btn');
- if (print_export_button) print_export_button.addEventListener(
- 'command',
- function(ev) {
- try {
- obj.error_list.on_all_fleshed =
- function() {
- try {
- dump( obj.error_list.dump_csv() + '\n' );
- //copy_to_clipboard(obj.error_list.dump_csv());
- JSAN.use('util.print'); var p = new util.print();
- p.simple( obj.error_list.dump_csv(), { 'content_type' : 'text/plain' } );
- setTimeout(function(){ obj.error_list.on_all_fleshed = null; },0);
- } catch(E) {
- obj.error.standard_unexpected_error_alert('export',E);
- }
- }
- obj.error_list.full_retrieve();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('print export',E);
- }
- },
- false
- );
-
- },
-
- 'check_perm' : function(perms) {
- var obj = this;
- try {
- var robj = obj.network.simple_request('PERM_CHECK',[ses(),obj.data.list.au[0].id(),obj.data.list.au[0].ws_ou(),perms]);
- if (typeof robj.ilsevent != 'undefined') {
- obj.error.standard_unexpected_error_alert('check permission',E);
- return false;
- }
- return robj.length == 0 ? true : false;
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.check_perm'),E);
- }
- },
-
- 'execute_ses' : function() {
- var obj = this;
-
- try {
-
- clear_the_cache();
- obj.data.stash_retrieve();
-
- for (var i = 0; i < obj.sel_list.length; i++) {
-
- var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
- + "?ses=" + window.escape(ses())
- + "&action=execute"
- + "&seskey=" + window.escape(obj.seslist[obj.sel_list[i]].key)
- + "&ws=" + window.escape(obj.data.ws_name);
- var x = new XMLHttpRequest();
- x.open("GET",url,false);
- x.send(null);
-
- dump(url + ' = ' + x.responseText + '\n' );
- if (!x.responseText) {
- throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
- }
- var robj = JSON2js(x.responseText);
-
- if (robj.ilsevent != 0) { alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.execute_error') + ' ' + x.responseText); }
-
- obj.retrieve_seslist(); obj.render_seslist();
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.session_execute_error'),E);
- }
- },
-
- 'ses_errors' : function() {
- var obj = this;
-
- try {
-
- clear_the_cache();
- obj.data.stash_retrieve();
-
- var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
- + "?ses=" + window.escape(ses())
- + "&action=status"
- + "&seskey=" + window.escape(obj.seslist[ obj.sel_list[0] ].key)
- + "&ws=" + window.escape(obj.data.ws_name)
- + '&status_type=exceptions';
- var x = new XMLHttpRequest();
- x.open("GET",url,false);
- x.send(null);
-
- dump(url + ' = ' + x.responseText + '\n' );
- if (!x.responseText) {
- throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
- }
- var robj = JSON2js(x.responseText);
-
- return { 'errors' : robj, 'description' : obj.seslist[ obj.sel_list[0] ].description };
-
- } catch(E) {
- throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.session_retrieval') + ' ' + E);
- }
-
- },
-
- 'rename_file' : function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
-
- try {
-
- JSAN.use('util.file');
- var pending = new util.file('pending_xacts');
- if ( !pending._file.exists() ) {
- throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.non_existent_file'));
- }
- obj.transition_filename = 'pending_xacts_' + new Date().getTime();
- var count = 0;
- var file = new util.file(obj.transition_filename);
- while (file._file.exists()) {
- obj.transition_filename = 'pending_xacts_' + new Date().getTime();
- file = new util.file(obj.transition_filename);
- if (count++>100) {
- throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.unique_file'));
- }
- }
- pending._file.moveTo(null,obj.transition_filename);
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.renaming_file'),E);
- }
- },
-
- 'revert_file' : function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
-
- try {
-
- JSAN.use('util.file');
- var pending = new util.file('pending_xacts');
- if (pending._file.exists()) {
- obj.error.yns_alert(
- $('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.error.transaction_conflicts', [obj.transition_filename]),
- $('adminStrings').getString('staff.admin.offline_manage_xacts.error.transaction_conflicts.title'),
- $('adminStrings').getString('staff.admin.offline_manage_xacts.error.transaction_conflicts.ok'),
- null,
- null,
- $('adminStrings').getString('staff.admin.offline_manage_xacts.error.transaction_conflicts.confirm')
- );
- return;
- }
- var file = new util.file(obj.transition_filename);
- file._file.moveTo(null,'pending_xacts');
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.reverting_file'),E);
- }
- },
-
- 'archive_file' : function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
-
- try {
-
- JSAN.use('util.file');
- var file = new util.file(obj.transition_filename);
- if (file._file.exists()) file._file.moveTo(null,obj.transition_filename + '.complete');
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.archiving_file'),E);
- }
- },
-
- 'upload' : function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
-
- try {
-
- if (obj.sel_list.length == 0) {
- alert($('adminStrings').getString('staff.admin.offline_manage_xacts.session_upload'));
- return;
- }
- if (obj.sel_list.length > 1) {
- alert($('adminStrings').getString('staff.admin.offline_manage_xacts.single_session_upload'));
- return;
- }
-
- JSAN.use('util.file');
-
- var file = new util.file('pending_xacts');
- if (!file._file.exists()) {
- alert($('adminStrings').getString('staff.admin.offline_manage_xacts.no_transactions'));
- return;
- }
-
- obj.rename_file();
-
- obj.data.stash_retrieve();
- var seskey = obj.seslist[ obj.sel_list[0] ].key;
- JSAN.use('util.widgets');
- var xx = document.getElementById('iframe_placeholder'); util.widgets.remove_children(xx);
- var x = document.createElement('iframe'); xx.appendChild(x); x.flex = 1;
- x.setAttribute(
- 'src',
- window.xulG.url_prefix( urls.XUL_REMOTE_BROWSER )
- /*
- + '?url=' + window.escape(
- urls.XUL_OFFLINE_UPLOAD_XACTS
- + '?ses=' + window.escape(ses())
- + '&seskey=' + window.escape(seskey)
- + '&ws=' + window.escape(obj.data.ws_name)
- + '&delta=' + window.escape('0')
- + '&filename=' + window.escape( obj.transition_filename )
- )
- */
- );
- var newG = {
- 'url' : urls.XUL_OFFLINE_UPLOAD_XACTS,
- 'url_prefix' : window.xulG.url_prefix,
- 'passthru_content_params' : {
- 'ses' : ses(),
- 'seskey' : seskey,
- 'ws' : obj.data.ws_name,
- 'delta' : 0,
- 'filename' : obj.transition_filename,
- 'url_prefix' : window.xulG.url_prefix,
- 'handle_event' : function(robj){
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- try {
- dump('robj = ' + js2JSON(robj) + '\n');
- if ( robj.ilsevent != 0 ) {
- obj.revert_file();
- alert($('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.error.uploading_file') + '\n' + js2JSON(robj));
- } else {
- obj.archive_file();
- }
- obj.retrieve_seslist(); obj.render_seslist();
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.remove_children('iframe_placeholder');
- },0
- );
- } catch(E) {
- alert('handle_event error: ' + E);
- }
- }
- }
- };
- get_contentWindow(x).xulG = newG;
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.uploading_transactions'),E);
- }
- },
-
- 'ses_status' : function() {
- var obj = this;
-
- try {
-
- clear_the_cache();
- obj.data.stash_retrieve();
-
- var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
- + "?ses=" + window.escape(ses())
- + "&action=status"
- + "&seskey=" + window.escape(obj.seslist[obj.sel_list[0]].key)
- + "&ws=" + window.escape(obj.data.ws_name)
- + "&status_type=scripts";
- var x = new XMLHttpRequest();
- x.open("GET",url,false);
- x.send(null);
-
- dump(url + ' = ' + x.responseText + '\n' );
- if (!x.responseText) {
- throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
- }
- var robj = JSON2js(x.responseText);
-
- return robj;
-
- } catch(E) {
-
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.retrieving_session'),E);
- return { 'ilsevent' : -2 };
-
- }
- },
-
- 'create_ses' : function() {
-
- var obj = this;
-
- try {
-
- var desc = window.prompt(
- $('adminStrings').getString('staff.admin.offline_manage_xacts.create_session.prompt'),
- '',
- $('adminStrings').getString('staff.admin.offline_manage_xacts.create_session')
- );
- if (desc=='' || desc==null) { return; }
-
- clear_the_cache();
- obj.data.stash_retrieve();
-
- var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
- + "?ses=" + window.escape(ses())
- + "&action=create"
- + "&desc=" + window.escape(desc)
- + "&ws=" + window.escape(obj.data.ws_name);
- var x = new XMLHttpRequest();
- x.open("GET",url,false);
- x.send(null);
-
- dump(url + ' = ' + x.responseText + '\n' );
- if (!x.responseText) {
- throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
- }
- var robj = JSON2js(x.responseText);
- if (robj.ilsevent == 0) {
- obj.retrieve_seslist(); obj.render_seslist();
- } else {
- alert($('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.error.create_session.alert', [x.responseText]));
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.create_session'), E);
- }
-
- },
-
- 'retrieve_seslist' : function() {
-
- var obj = this;
-
- try {
-
- clear_the_cache();
- obj.data.stash_retrieve();
-
- var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
- + "?ses=" + window.escape(ses())
- + "&action=status"
- + "&org=" + window.escape(obj.data.list.au[0].ws_ou())
- + "&status_type=sessions";
- var x = new XMLHttpRequest();
- x.open("GET",url,false);
- x.send(null);
+ 'sel_list' : [],
+ 'seslist' : [],
+ 'sel_errors' : [],
+
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+
+ obj.init_list(); obj.init_script_list(); obj.init_error_list();
+
+ obj.retrieve_seslist(); obj.render_seslist();
+
+ var x = document.getElementById('create');
+ if (obj.check_perm(['OFFLINE_UPLOAD'])) {
+ x.disabled = false;
+ x.addEventListener('command',function() { try{obj.create_ses();}catch(E){alert(E);} },false);
+ }
+
+ x = obj.$('upload');
+ x.addEventListener('command',function() { try{obj.upload();}catch(E){alert(E);} },false);
+
+ x = obj.$('refresh');
+ x.addEventListener('command',function() { try{$('deck').selectedIndex=0;obj.retrieve_seslist();obj.render_seslist();}catch(E){alert(E);} },false);
+
+ x = obj.$('execute');
+ x.addEventListener('command',function() { try{obj.execute_ses();}catch(E){alert(E);} },false);
+
+ x = obj.$('retrieve_item');
+ x.addEventListener('command',function() { try{obj.retrieve_item();}catch(E){alert(E);} },false);
+
+ x = obj.$('retrieve_patron');
+ x.addEventListener('command',function() { try{obj.retrieve_patron();}catch(E){alert(E);} },false);
+
+ x = obj.$('retrieve_details');
+ x.addEventListener('command',function() { try{obj.retrieve_details();}catch(E){alert(E);} },false);
+
+ obj.$('deck').selectedIndex = 0;
+ },
+
+ '$' : function(id) { return document.getElementById(id); },
+
+ 'init_list' : function() {
+ var obj = this; JSAN.use('util.list'); JSAN.use('util.date'); JSAN.use('patron.util');
+ obj.list = new util.list('session_tree');
+ obj.list.init( {
+ 'columns' : [
+ {
+ 'id' : 'org', 'hidden' : 'true', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.organization'),
+ 'render' : function(my) { return obj.data.hash.aou[ my.org ].shortname(); }
+ },
+ {
+ 'id' : 'description', 'flex' : '2',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.description'),
+ 'render' : function(my) { return my.description; }
+ },
+ {
+ 'id' : 'create_time', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.date_created'),
+ 'render' : function(my) { if (my.create_time) { var x = new Date(); x.setTime(my.create_time+"000"); return util.date.formatted_date(x,"%F %H:%M"); } else { return ""; }; }
+ },
+ {
+ 'id' : 'creator', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.created_by'),
+ 'render' : function(my) { var staff_obj = patron.util.retrieve_name_via_id( ses(), my.creator ); return staff_obj[0] + " @ " + obj.data.hash.aou[ staff_obj[3] ].shortname(); }
+ },
+ {
+ 'id' : 'count', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.upload_count'),
+ 'render' : function(my) { return my.scripts.length; }
+ },
+ {
+ 'id' : 'num_complete', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.transactions_processed'),
+ 'render' : function(my) { return my.num_complete; }
+ },
+ {
+ 'id' : 'in_process', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.processing'),
+ 'render' : function(my) {
+ if (my.end_time) {
+ return $('adminStrings').getString('staff.admin.offline_manage_xacts.completed')
+ } else {
+ return get_bool(my.in_process) ? $('adminStrings').getString('staff.admin.offline_manage_xacts.yes') : $('adminStrings').getString('staff.admin.offline_manage_xacts.no')
+ };
+ }
+ },
+ {
+ 'id' : 'start_time', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.date_started'),
+ 'render' : function(my) { if (my.start_time) {var x = new Date(); x.setTime(my.start_time+"000"); return util.date.formatted_date(x,"%F %H:%M");} else { return ""; }; }
+ },
+ {
+ 'id' : 'end_time', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.date_completed'),
+ 'render' : function(my) { if (my.end_time) {var x = new Date(); x.setTime(my.end_time+"000"); return util.date.formatted_date(x,"%F %H:%M");} else { return ""; }; }
+ },
+ {
+ 'id' : 'key', 'hidden' : 'true', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_list.session'),
+ 'render' : function(my) { return my.key; }
+ },
+ ],
+ 'map_row_to_columns' : patron.util.std_map_row_to_columns(),
+ 'on_select' : function(ev) {
+ try {
+ $('deck').selectedIndex = 0;
+ $('execute').disabled = true;
+ $('upload').disabled = true;
+ setTimeout(
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var sel = obj.list.retrieve_selection();
+ obj.sel_list = util.functional.map_list(
+ sel,
+ function(o) { return o.getAttribute('retrieve_id'); }
+ );
+ if (obj.sel_list.length == 0) return;
+ {
+ var upload = true; var process = true;
+
+ if (obj.sel_list.length > 1) upload = false;
+
+ if (obj.seslist[ obj.sel_list[0] ].end_time) {
+ upload = false; process = false;
+ }
+ if (obj.seslist[ obj.sel_list[0] ].in_process == 1) {
+ upload = false; process = false;
+ }
+
+ /* should we really have this next restriction? */
+ for (var i = 0; i < obj.seslist[ obj.sel_list[0] ].scripts.length; i++) {
+ if (obj.seslist[ obj.sel_list[0] ].scripts[i].workstation ==
+ obj.data.ws_name ) upload = false;
+ }
+
+ if (upload) {
+ if (obj.check_perm(['OFFLINE_UPLOAD'])) {
+ document.getElementById('upload').disabled = false;
+ }
+ } else {
+ document.getElementById('upload').disabled = true;
+ }
+ if (process) {
+ if (obj.check_perm(['OFFLINE_EXECUTE'])) {
+ document.getElementById('execute').disabled = false;
+ }
+ } else {
+ document.getElementById('execute').disabled = true;
+ }
+ }
+ var complete = false;
+ for (var i = 0; i < obj.sel_list.length; i++) {
+ if (obj.seslist[ obj.sel_list[i] ].end_time) { complete = true; }
+ }
+ if (complete) {
+ obj.render_errorlist();
+ } else {
+ if (obj.seslist[ obj.sel_list[0] ].in_process == 1) {
+ obj.render_status();
+ } else {
+ obj.render_scriptlist();
+ }
+ }
+ } catch(E) {
+ alert('on_select: ' + E);
+ }
+ }, 0
+ );
+ } catch(E) {
+ alert('on_select:\nobj.seslist.length = ' + obj.seslist.length + ' obj.sel_list.length = ' + obj.sel_list.length + '\nerror: ' + E);
+ }
+ }
+ } );
+
+
+ },
+
+ 'init_script_list' : function() {
+ var obj = this; JSAN.use('util.list'); JSAN.use('util.date'); JSAN.use('patron.util');
+ obj.script_list = new util.list('script_tree');
+ obj.script_list.init( {
+ 'columns' : [
+ {
+ 'id' : 'create_time', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_script_list.date_uploaded'),
+ 'render' : function(my) { if (my.create_time) { var x = new Date(); x.setTime(my.create_time+"000"); return util.date.formatted_date(x,"%F %H:%M"); } else { return ""; }; }
+ },
+ {
+ 'id' : 'requestor', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_script_list.uploaded_by'),
+ 'render' : function(my) { var staff_obj = patron.util.retrieve_name_via_id( ses(), my.requestor ); return staff_obj[0] + " @ " + obj.data.hash.aou[ staff_obj[3] ].shortname(); }
+ },
+ {
+ 'id' : 'time_delta', 'hidden' : 'true', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_script_list.time_delta'),
+ 'render' : function(my) { return my.time_delta; }
+ },
+ {
+ 'id' : 'workstation', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_script_list.workstation'),
+ 'render' : function(my) { return my.workstation; }
+ },
+ ],
+ 'map_row_to_columns' : patron.util.std_map_row_to_columns()
+ } );
+
+
+ },
+
+ 'init_error_list' : function() {
+ var obj = this; JSAN.use('util.list'); JSAN.use('util.date'); JSAN.use('patron.util'); JSAN.use('util.functional');
+ obj.error_list = new util.list('error_tree');
+ obj.error_list.init( {
+ 'columns' : [
+ {
+ 'id' : 'workstation', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.workstation'),
+ 'render' : function(my) { return my.command._workstation ? my.command._workstation : my.command._worksation; }
+ },
+ {
+ 'id' : 'timestamp', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.timestamp'),
+ 'render' : function(my) { if (my.command.timestamp) { var x = new Date(); x.setTime(my.command.timestamp+"000"); return util.date.formatted_date(x,"%F %H:%M"); } else { return my.command._realtime; }; }
+ },
+ {
+ 'id' : 'type', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.type'),
+ 'render' : function(my) { return my.command.type; }
+ },
+ {
+ 'id' : 'ilsevent', 'hidden' : 'true', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.event_code'),
+ 'render' : function(my) { return my.event.ilsevent; }
+ },
+ {
+ 'id' : 'textcode', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.event_name'),
+ 'render' : function(my) { return typeof my.event.textcode != 'undefined' ? my.event.textcode : util.functional.map_list( my.event, function(o) { return o.textcode; }).join('/'); }
+ },
+ {
+ 'id' : 'desc', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.event_description'),
+ 'render' : function(my) { return my.event.desc; }
+ },
+ {
+ 'id' : 'i_barcode', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.item_barcode'),
+ 'render' : function(my) { return my.command.barcode ? my.command.barcode : ""; }
+ },
+ {
+ 'id' : 'p_barcode', 'flex' : '1',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.patron_barcode'),
+ 'render' : function(my) { if (my.command.patron_barcode) { return my.command.patron_barcode; } else { if (my.command.user.card.barcode) { return my.command.user.card.barcode; } else { return ""; } }; }
+ },
+ {
+ 'id' : 'duedate', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.due_date'),
+ 'render' : function(my) { return my.command.due_date || ""; }
+ },
+ {
+ 'id' : 'backdate', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.backdate'),
+ 'render' : function(my) { return my.command.backdate || ""; }
+ },
+ {
+ 'id' : 'count', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.count'),
+ 'render' : function(my) { return my.command.count || ""; }
+ },
+ {
+ 'id' : 'noncat', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.noncat'),
+ 'render' : function(my) { return get_bool(my.command.noncat) ? $('adminStrings').getString('staff.admin.offline_manage_xacts.yes') : $('adminStrings').getString('staff.admin.offline_manage_xacts.no'); }
+ },
+ {
+ 'id' : 'noncat_type', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.noncat_type'),
+ 'render' : function(my) { return data.hash.cnct[ my.command.noncat_type ] ? obj.data.hash.cnct[ my.command.noncat_type ].name() : ""; }
+ },
+ {
+ 'id' : 'noncat_count', 'flex' : '1', 'hidden' : 'true',
+ 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_error_list.noncat_count'),
+ 'render' : function(my) { return my.command.noncat_count || ""; }
+ },
+ ],
+ 'map_row_to_columns' : patron.util.std_map_row_to_columns(),
+ 'on_select' : function(ev) {
+ try {
+ var sel = obj.error_list.retrieve_selection();
+ obj.sel_errors = util.functional.map_list(
+ sel,
+ function(o) { return o.getAttribute('retrieve_id'); }
+ );
+ if (obj.sel_errors.length > 0) {
+ obj.$('retrieve_item').disabled = false;
+ obj.$('retrieve_patron').disabled = false;
+ obj.$('retrieve_details').disabled = false;
+ } else {
+ obj.$('retrieve_item').disabled = true;
+ obj.$('retrieve_patron').disabled = true;
+ obj.$('retrieve_details').disabled = true;
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }
+ } );
+
+ var export_button = document.getElementById('export_btn');
+ if (export_button) export_button.addEventListener(
+ 'command',
+ function(ev) {
+ try {
+ obj.error_list.dump_csv_to_clipboard();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('export',E);
+ }
+ },
+ false
+ );
+
+ var print_export_button = document.getElementById('print_export_btn');
+ if (print_export_button) print_export_button.addEventListener(
+ 'command',
+ function(ev) {
+ try {
+ obj.error_list.on_all_fleshed =
+ function() {
+ try {
+ dump( obj.error_list.dump_csv() + '\n' );
+ //copy_to_clipboard(obj.error_list.dump_csv());
+ JSAN.use('util.print'); var p = new util.print();
+ p.simple( obj.error_list.dump_csv(), { 'content_type' : 'text/plain' } );
+ setTimeout(function(){ obj.error_list.on_all_fleshed = null; },0);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('export',E);
+ }
+ }
+ obj.error_list.full_retrieve();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('print export',E);
+ }
+ },
+ false
+ );
+
+ },
+
+ 'check_perm' : function(perms) {
+ var obj = this;
+ try {
+ var robj = obj.network.simple_request('PERM_CHECK',[ses(),obj.data.list.au[0].id(),obj.data.list.au[0].ws_ou(),perms]);
+ if (typeof robj.ilsevent != 'undefined') {
+ obj.error.standard_unexpected_error_alert('check permission',E);
+ return false;
+ }
+ return robj.length == 0 ? true : false;
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.check_perm'),E);
+ }
+ },
+
+ 'execute_ses' : function() {
+ var obj = this;
+
+ try {
+
+ clear_the_cache();
+ obj.data.stash_retrieve();
+
+ for (var i = 0; i < obj.sel_list.length; i++) {
+
+ var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
+ + "?ses=" + window.escape(ses())
+ + "&action=execute"
+ + "&seskey=" + window.escape(obj.seslist[obj.sel_list[i]].key)
+ + "&ws=" + window.escape(obj.data.ws_name);
+ var x = new XMLHttpRequest();
+ x.open("GET",url,false);
+ x.send(null);
+
+ dump(url + ' = ' + x.responseText + '\n' );
+ if (!x.responseText) {
+ throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
+ }
+ var robj = JSON2js(x.responseText);
+
+ if (robj.ilsevent != 0) { alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.execute_error') + ' ' + x.responseText); }
+
+ obj.retrieve_seslist(); obj.render_seslist();
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.session_execute_error'),E);
+ }
+ },
+
+ 'ses_errors' : function() {
+ var obj = this;
+
+ try {
+
+ clear_the_cache();
+ obj.data.stash_retrieve();
+
+ var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
+ + "?ses=" + window.escape(ses())
+ + "&action=status"
+ + "&seskey=" + window.escape(obj.seslist[ obj.sel_list[0] ].key)
+ + "&ws=" + window.escape(obj.data.ws_name)
+ + '&status_type=exceptions';
+ var x = new XMLHttpRequest();
+ x.open("GET",url,false);
+ x.send(null);
+
+ dump(url + ' = ' + x.responseText + '\n' );
+ if (!x.responseText) {
+ throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
+ }
+ var robj = JSON2js(x.responseText);
+
+ return { 'errors' : robj, 'description' : obj.seslist[ obj.sel_list[0] ].description };
+
+ } catch(E) {
+ throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.session_retrieval') + ' ' + E);
+ }
+
+ },
+
+ 'rename_file' : function() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var obj = this;
+
+ try {
+
+ JSAN.use('util.file');
+ var pending = new util.file('pending_xacts');
+ if ( !pending._file.exists() ) {
+ throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.non_existent_file'));
+ }
+ obj.transition_filename = 'pending_xacts_' + new Date().getTime();
+ var count = 0;
+ var file = new util.file(obj.transition_filename);
+ while (file._file.exists()) {
+ obj.transition_filename = 'pending_xacts_' + new Date().getTime();
+ file = new util.file(obj.transition_filename);
+ if (count++>100) {
+ throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.unique_file'));
+ }
+ }
+ pending._file.moveTo(null,obj.transition_filename);
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.renaming_file'),E);
+ }
+ },
+
+ 'revert_file' : function() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var obj = this;
+
+ try {
+
+ JSAN.use('util.file');
+ var pending = new util.file('pending_xacts');
+ if (pending._file.exists()) {
+ obj.error.yns_alert(
+ $('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.error.transaction_conflicts', [obj.transition_filename]),
+ $('adminStrings').getString('staff.admin.offline_manage_xacts.error.transaction_conflicts.title'),
+ $('adminStrings').getString('staff.admin.offline_manage_xacts.error.transaction_conflicts.ok'),
+ null,
+ null,
+ $('adminStrings').getString('staff.admin.offline_manage_xacts.error.transaction_conflicts.confirm')
+ );
+ return;
+ }
+ var file = new util.file(obj.transition_filename);
+ file._file.moveTo(null,'pending_xacts');
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.reverting_file'),E);
+ }
+ },
+
+ 'archive_file' : function() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var obj = this;
+
+ try {
+
+ JSAN.use('util.file');
+ var file = new util.file(obj.transition_filename);
+ if (file._file.exists()) file._file.moveTo(null,obj.transition_filename + '.complete');
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.archiving_file'),E);
+ }
+ },
+
+ 'upload' : function() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var obj = this;
+
+ try {
+
+ if (obj.sel_list.length == 0) {
+ alert($('adminStrings').getString('staff.admin.offline_manage_xacts.session_upload'));
+ return;
+ }
+ if (obj.sel_list.length > 1) {
+ alert($('adminStrings').getString('staff.admin.offline_manage_xacts.single_session_upload'));
+ return;
+ }
+
+ JSAN.use('util.file');
+
+ var file = new util.file('pending_xacts');
+ if (!file._file.exists()) {
+ alert($('adminStrings').getString('staff.admin.offline_manage_xacts.no_transactions'));
+ return;
+ }
+
+ obj.rename_file();
+
+ obj.data.stash_retrieve();
+ var seskey = obj.seslist[ obj.sel_list[0] ].key;
+ JSAN.use('util.widgets');
+ var xx = document.getElementById('iframe_placeholder'); util.widgets.remove_children(xx);
+ var x = document.createElement('iframe'); xx.appendChild(x); x.flex = 1;
+ x.setAttribute(
+ 'src',
+ window.xulG.url_prefix( urls.XUL_REMOTE_BROWSER )
+ /*
+ + '?url=' + window.escape(
+ urls.XUL_OFFLINE_UPLOAD_XACTS
+ + '?ses=' + window.escape(ses())
+ + '&seskey=' + window.escape(seskey)
+ + '&ws=' + window.escape(obj.data.ws_name)
+ + '&delta=' + window.escape('0')
+ + '&filename=' + window.escape( obj.transition_filename )
+ )
+ */
+ );
+ var newG = {
+ 'url' : urls.XUL_OFFLINE_UPLOAD_XACTS,
+ 'url_prefix' : window.xulG.url_prefix,
+ 'passthru_content_params' : {
+ 'ses' : ses(),
+ 'seskey' : seskey,
+ 'ws' : obj.data.ws_name,
+ 'delta' : 0,
+ 'filename' : obj.transition_filename,
+ 'url_prefix' : window.xulG.url_prefix,
+ 'handle_event' : function(robj){
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ try {
+ dump('robj = ' + js2JSON(robj) + '\n');
+ if ( robj.ilsevent != 0 ) {
+ obj.revert_file();
+ alert($('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.error.uploading_file') + '\n' + js2JSON(robj));
+ } else {
+ obj.archive_file();
+ }
+ obj.retrieve_seslist(); obj.render_seslist();
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.remove_children('iframe_placeholder');
+ },0
+ );
+ } catch(E) {
+ alert('handle_event error: ' + E);
+ }
+ }
+ }
+ };
+ get_contentWindow(x).xulG = newG;
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.uploading_transactions'),E);
+ }
+ },
+
+ 'ses_status' : function() {
+ var obj = this;
+
+ try {
+
+ clear_the_cache();
+ obj.data.stash_retrieve();
+
+ var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
+ + "?ses=" + window.escape(ses())
+ + "&action=status"
+ + "&seskey=" + window.escape(obj.seslist[obj.sel_list[0]].key)
+ + "&ws=" + window.escape(obj.data.ws_name)
+ + "&status_type=scripts";
+ var x = new XMLHttpRequest();
+ x.open("GET",url,false);
+ x.send(null);
+
+ dump(url + ' = ' + x.responseText + '\n' );
+ if (!x.responseText) {
+ throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
+ }
+ var robj = JSON2js(x.responseText);
+
+ return robj;
+
+ } catch(E) {
+
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.retrieving_session'),E);
+ return { 'ilsevent' : -2 };
+
+ }
+ },
+
+ 'create_ses' : function() {
+
+ var obj = this;
+
+ try {
+
+ var desc = window.prompt(
+ $('adminStrings').getString('staff.admin.offline_manage_xacts.create_session.prompt'),
+ '',
+ $('adminStrings').getString('staff.admin.offline_manage_xacts.create_session')
+ );
+ if (desc=='' || desc==null) { return; }
+
+ clear_the_cache();
+ obj.data.stash_retrieve();
+
+ var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
+ + "?ses=" + window.escape(ses())
+ + "&action=create"
+ + "&desc=" + window.escape(desc)
+ + "&ws=" + window.escape(obj.data.ws_name);
+ var x = new XMLHttpRequest();
+ x.open("GET",url,false);
+ x.send(null);
+
+ dump(url + ' = ' + x.responseText + '\n' );
+ if (!x.responseText) {
+ throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
+ }
+ var robj = JSON2js(x.responseText);
+ if (robj.ilsevent == 0) {
+ obj.retrieve_seslist(); obj.render_seslist();
+ } else {
+ alert($('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.error.create_session.alert', [x.responseText]));
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.create_session'), E);
+ }
+
+ },
+
+ 'retrieve_seslist' : function() {
+
+ var obj = this;
+
+ try {
+
+ clear_the_cache();
+ obj.data.stash_retrieve();
+
+ var url = xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI)
+ + "?ses=" + window.escape(ses())
+ + "&action=status"
+ + "&org=" + window.escape(obj.data.list.au[0].ws_ou())
+ + "&status_type=sessions";
+ var x = new XMLHttpRequest();
+ x.open("GET",url,false);
+ x.send(null);
- dump(url + ' = ' + typeof(x.responseText) + '\n' );
+ dump(url + ' = ' + typeof(x.responseText) + '\n' );
- if (!x.responseText) {
- throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
- }
+ if (!x.responseText) {
+ throw($('adminStrings').getString('staff.admin.offline_manage_xacts.error.bad_cgi_response'));
+ }
- var robj = JSON2js( x.responseText );
- if (typeof robj.ilsevent != 'undefined') throw(robj);
+ var robj = JSON2js( x.responseText );
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
- if (!robj) throw(robj);
+ if (!robj) throw(robj);
- obj.seslist = robj.sort(
- function(a,b) {
- return b.create_time - a.create_time;
- }
- );
+ obj.seslist = robj.sort(
+ function(a,b) {
+ return b.create_time - a.create_time;
+ }
+ );
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.retrieving_sessions'),E);
- }
- },
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.retrieving_sessions'),E);
+ }
+ },
- 'render_seslist' : function() {
+ 'render_seslist' : function() {
- var obj = this;
+ var obj = this;
- try {
+ try {
- var old_idx = obj.list.node.currentIndex;
- if (old_idx < 0) old_idx = 0;
+ var old_idx = obj.list.node.currentIndex;
+ if (old_idx < 0) old_idx = 0;
- obj.list.clear();
+ obj.list.clear();
- var funcs = [];
- for (var i = 0; i < obj.seslist.length; i++) {
- funcs.push(
- function(idx,row){
- return function(){
- obj.list.append( { 'retrieve_id' : idx, 'row' : row, 'no_auto_select' : true, 'to_bottom' : true } );
- //if (idx == old_idx) obj.list.node.view.selection.select(idx);
- };
- }(i,{ 'my' : obj.seslist[i] })
- );
- }
-
- JSAN.use('util.exec'); var exec = new util.exec();
- exec.chain( funcs );
-
- document.getElementById('execute').disabled = true;
- document.getElementById('upload').disabled = true;
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.rendering_session'),E);
- }
- },
-
- 'render_scriptlist' : function() {
-
- dump('render_scriptlist\n');
-
- var obj = this;
-
- try {
-
- document.getElementById('deck').selectedIndex = 1;
-
- obj.script_list.clear();
-
- var status = obj.ses_status();
- $('status_caption').setAttribute('label', $('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.upload_status', [status.description]));
-
- var scripts = status.scripts;
-
- var funcs = [];
- for (var i = 0; i < scripts.length; i++) {
- funcs.push(
- function(row){
- return function(){
- obj.script_list.append( { 'row' : row, 'no_auto_select' : true } );
- };
- }({ 'my' : scripts[i] })
- );
- }
- JSAN.use('util.exec'); var exec = new util.exec();
- exec.chain( funcs );
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.rendering_script'),E);
- }
- },
-
- 'render_errorlist' : function() {
-
- dump('render_errorlist\n');
-
- var obj = this;
-
- try {
-
- document.getElementById('deck').selectedIndex = 2;
-
- obj.error_list.clear();
-
- var error_meta = obj.ses_errors();
- $('errors_caption').setAttribute('label',$('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.error.rendering_errors', [error_meta.description]));
-
- obj.errors = error_meta.errors;
-
- var funcs = [];
- for (var i = 0; i < obj.errors.length; i++) {
- funcs.push(
- function(idx,row){
- return function(){
- obj.error_list.append( { 'retrieve_id' : idx, 'row' : row, 'no_auto_select' : true } );
- };
- }(i,{ 'my' : obj.errors[i] })
- );
- }
- JSAN.use('util.exec'); var exec = new util.exec();
- exec.chain( funcs );
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.rendering_error_list'),E);
- }
- },
-
- 'render_status' : function() {
-
- dump('render_status\n');
-
- document.getElementById('deck').selectedIndex = 3;
-
- },
-
- 'retrieve_item' : function() {
- var obj = this;
- try {
- var barcodes = [];
- for (var i = 0; i < obj.sel_errors.length; i++) {
- var error = obj.errors[ obj.sel_errors[i] ];
- if ( ! error.command.barcode ) continue;
- if ( [ '', ' ', '???' ].indexOf( error.command.barcode ) != -1 ) continue;
- barcodes.push( error.command.barcode );
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
- try {
- var url = urls.XUL_COPY_STATUS;
- //+ '?barcodes=' + window.escape( js2JSON(barcodes) );
- window.xulG.new_tab(
- url, {}, { 'barcodes' : barcodes }
- );
- } catch(E) {
- alert(E);
- }
- }
- } catch(E) {
- alert(E);
- }
- },
-
- 'retrieve_patron' : function() {
- var obj = this;
- var patrons = {};
- try {
- for (var i = 0; i < obj.sel_errors.length; i++) {
- var error = obj.errors[ obj.sel_errors[i] ];
- if ( ! error.command.patron_barcode ) continue;
- if ( [ '', ' ', '???' ].indexOf( error.command.patron_barcode ) != -1 ) continue;
- patrons[ error.command.patron_barcode ] = true;
- }
- for (var barcode in patrons) {
- if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
- try {
- window.xulG.new_patron_tab(
- {}, { 'barcode' : barcode }
- );
- } catch(E) {
- alert(E);
- }
- }
-
- }
- } catch(E) {
- alert(E);
- }
- },
-
- 'retrieve_details' : function() {
- var obj = this;
- JSAN.use('util.window'); var win = new util.window();
- try {
- for (var i = 0; i < obj.sel_errors.length; i++) {
- var error = obj.errors[ obj.sel_errors[i] ];
- win.open(
- 'data:text/plain,' + window.escape(
- 'Details:\n' + obj.error.pretty_print(js2JSON(error))
- ),
- 'offline_error_details',
- 'height=780,width=580,scrollbars=yes,chrome,resizable,modal'
- );
- }
- } catch(E) {
- alert(E);
- }
-
- }
+ var funcs = [];
+ for (var i = 0; i < obj.seslist.length; i++) {
+ funcs.push(
+ function(idx,row){
+ return function(){
+ obj.list.append( { 'retrieve_id' : idx, 'row' : row, 'no_auto_select' : true, 'to_bottom' : true } );
+ //if (idx == old_idx) obj.list.node.view.selection.select(idx);
+ };
+ }(i,{ 'my' : obj.seslist[i] })
+ );
+ }
+
+ JSAN.use('util.exec'); var exec = new util.exec();
+ exec.chain( funcs );
+
+ document.getElementById('execute').disabled = true;
+ document.getElementById('upload').disabled = true;
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.rendering_session'),E);
+ }
+ },
+
+ 'render_scriptlist' : function() {
+
+ dump('render_scriptlist\n');
+
+ var obj = this;
+
+ try {
+
+ document.getElementById('deck').selectedIndex = 1;
+
+ obj.script_list.clear();
+
+ var status = obj.ses_status();
+ $('status_caption').setAttribute('label', $('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.upload_status', [status.description]));
+
+ var scripts = status.scripts;
+
+ var funcs = [];
+ for (var i = 0; i < scripts.length; i++) {
+ funcs.push(
+ function(row){
+ return function(){
+ obj.script_list.append( { 'row' : row, 'no_auto_select' : true } );
+ };
+ }({ 'my' : scripts[i] })
+ );
+ }
+ JSAN.use('util.exec'); var exec = new util.exec();
+ exec.chain( funcs );
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.rendering_script'),E);
+ }
+ },
+
+ 'render_errorlist' : function() {
+
+ dump('render_errorlist\n');
+
+ var obj = this;
+
+ try {
+
+ document.getElementById('deck').selectedIndex = 2;
+
+ obj.error_list.clear();
+
+ var error_meta = obj.ses_errors();
+ $('errors_caption').setAttribute('label',$('adminStrings').getFormattedString('staff.admin.offline_manage_xacts.error.rendering_errors', [error_meta.description]));
+
+ obj.errors = error_meta.errors;
+
+ var funcs = [];
+ for (var i = 0; i < obj.errors.length; i++) {
+ funcs.push(
+ function(idx,row){
+ return function(){
+ obj.error_list.append( { 'retrieve_id' : idx, 'row' : row, 'no_auto_select' : true } );
+ };
+ }(i,{ 'my' : obj.errors[i] })
+ );
+ }
+ JSAN.use('util.exec'); var exec = new util.exec();
+ exec.chain( funcs );
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('adminStrings').getString('staff.admin.offline_manage_xacts.error.rendering_error_list'),E);
+ }
+ },
+
+ 'render_status' : function() {
+
+ dump('render_status\n');
+
+ document.getElementById('deck').selectedIndex = 3;
+
+ },
+
+ 'retrieve_item' : function() {
+ var obj = this;
+ try {
+ var barcodes = [];
+ for (var i = 0; i < obj.sel_errors.length; i++) {
+ var error = obj.errors[ obj.sel_errors[i] ];
+ if ( ! error.command.barcode ) continue;
+ if ( [ '', ' ', '???' ].indexOf( error.command.barcode ) != -1 ) continue;
+ barcodes.push( error.command.barcode );
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
+ try {
+ var url = urls.XUL_COPY_STATUS;
+ //+ '?barcodes=' + window.escape( js2JSON(barcodes) );
+ window.xulG.new_tab(
+ url, {}, { 'barcodes' : barcodes }
+ );
+ } catch(E) {
+ alert(E);
+ }
+ }
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+ 'retrieve_patron' : function() {
+ var obj = this;
+ var patrons = {};
+ try {
+ for (var i = 0; i < obj.sel_errors.length; i++) {
+ var error = obj.errors[ obj.sel_errors[i] ];
+ if ( ! error.command.patron_barcode ) continue;
+ if ( [ '', ' ', '???' ].indexOf( error.command.patron_barcode ) != -1 ) continue;
+ patrons[ error.command.patron_barcode ] = true;
+ }
+ for (var barcode in patrons) {
+ if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
+ try {
+ window.xulG.new_patron_tab(
+ {}, { 'barcode' : barcode }
+ );
+ } catch(E) {
+ alert(E);
+ }
+ }
+
+ }
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+ 'retrieve_details' : function() {
+ var obj = this;
+ JSAN.use('util.window'); var win = new util.window();
+ try {
+ for (var i = 0; i < obj.sel_errors.length; i++) {
+ var error = obj.errors[ obj.sel_errors[i] ];
+ win.open(
+ 'data:text/plain,' + window.escape(
+ 'Details:\n' + obj.error.pretty_print(js2JSON(error))
+ ),
+ 'offline_error_details',
+ 'height=780,width=580,scrollbars=yes,chrome,resizable,modal'
+ );
+ }
+ } catch(E) {
+ alert(E);
+ }
+
+ }
}
dump('exiting admin/offline_manage_xacts.js\n');
var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
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 printer_settings.xul');
-
- JSAN.use('util.print'); g.print = new util.print();
-
- /*
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- g.PSSVC = Components.classes["@mozilla.org/gfx/printsettings-service;1"].getService(Components.interfaces.nsIPrintSettingsService);
- g.PO = Components.classes["@mozilla.org/gfx/printsettings-service;1"].getService(Components.interfaces.nsIPrintOptions);
- g.PPSVC = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"].getService(Components.interfaces.nsIPrintingPromptService);
- g.settings = g.PSSVC.globalPrintSettings;
- */
-
- } catch(E) {
- try { g.error.standard_unexpected_error_dialog('admin/printer_settings.xul',E); } catch(F) { alert(E); }
- }
+ 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 printer_settings.xul');
+
+ JSAN.use('util.print'); g.print = new util.print();
+
+ /*
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ g.PSSVC = Components.classes["@mozilla.org/gfx/printsettings-service;1"].getService(Components.interfaces.nsIPrintSettingsService);
+ g.PO = Components.classes["@mozilla.org/gfx/printsettings-service;1"].getService(Components.interfaces.nsIPrintOptions);
+ g.PPSVC = Components.classes["@mozilla.org/embedcomp/printingprompt-service;1"].getService(Components.interfaces.nsIPrintingPromptService);
+ g.settings = g.PSSVC.globalPrintSettings;
+ */
+
+ } catch(E) {
+ try { g.error.standard_unexpected_error_dialog('admin/printer_settings.xul',E); } catch(F) { alert(E); }
+ }
}
g.page_settings = function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- g.print.page_settings();
- g.print.save_settings();
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ g.print.page_settings();
+ g.print.save_settings();
}
g.printer_settings = function() {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var w = get_contentWindow(document.getElementById('sample'));
- g.print.NSPrint(w ? w : window, false, {});
- g.print.save_settings();
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var w = get_contentWindow(document.getElementById('sample'));
+ g.print.NSPrint(w ? w : window, false, {});
+ g.print.save_settings();
}
g.set_print_strategy = function(which) {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('print_strategy');
- file.write_content( 'truncate', String( which ) );
- file.close();
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- data.print_strategy = which; data.stash('print_strategy');
- alert('Print strategy (' + which + ') saved to file system.');
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('print_strategy');
+ file.write_content( 'truncate', String( which ) );
+ file.close();
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ data.print_strategy = which; data.stash('print_strategy');
+ alert('Print strategy (' + which + ') saved to file system.');
}
g.save_settings = function() { g.print.save_settings(); }
-var SC_FETCH_ALL = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.retrieve.all';
-var SC_CREATE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.create';
-var SC_UPDATE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.update';
-var SC_DELETE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.delete';
-var SC_ENTRY_CREATE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.entry.create';
-var SC_ENTRY_UPDATE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.entry.update';
-var SC_ENTRY_DELETE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.entry.delete';
-
-var ACTOR = 'actor';
-var ASSET = 'asset';
-var session = null;
-var user = null;
-
-var scCache = {};
-var PERMS = {};
-PERMS[ACTOR] = {};
-PERMS[ASSET] = {};
+var SC_FETCH_ALL = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.retrieve.all';
+var SC_CREATE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.create';
+var SC_UPDATE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.update';
+var SC_DELETE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.delete';
+var SC_ENTRY_CREATE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.entry.create';
+var SC_ENTRY_UPDATE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.entry.update';
+var SC_ENTRY_DELETE = 'open-ils.circ:open-ils.circ.stat_cat.TYPE.entry.delete';
+
+var ACTOR = 'actor';
+var ASSET = 'asset';
+var session = null;
+var user = null;
+
+var scCache = {};
+var PERMS = {};
+PERMS[ACTOR] = {};
+PERMS[ASSET] = {};
var currentlyVisible;
-var opacVisible = false;
+var opacVisible = false;
var cgi;
var focusOrg;
-var myPerms = [
+var myPerms = [
'CREATE_PATRON_STAT_CAT',
'UPDATE_PATRON_STAT_CAT',
'DELETE_PATRON_STAT_CAT',
PERMS[ASSET].delete_stat_cat_entry = OILS_WORK_PERMS.DELETE_COPY_STAT_CAT_ENTRY;
// set up the fitler select
- var fselector = $('sc_org_filter');
+ var fselector = $('sc_org_filter');
var org_list = PERMS[currentlyVisible].update_stat_cat;
- buildMergedOrgSel(fselector, org_list, 0, 'shortname');
+ buildMergedOrgSel(fselector, org_list, 0, 'shortname');
var org = findOrgUnit(org_list[0]);
if(org_list.length > 1 || (org.children() && org.children()[0]))
fselector.disabled = false;
}
function scEditorInit() {
- cgi = new CGI();
- session = cgi.param('ses');
- if(!session) throw "User session is not defined";
- user = fetchUser(session);
+ cgi = new CGI();
+ session = cgi.param('ses');
+ if(!session) throw "User session is not defined";
+ user = fetchUser(session);
$('sc_type_selector').onchange = scBuildNew;
- setTimeout(
+ setTimeout(
function() {
- fetchHighestWorkPermOrgs(
+ fetchHighestWorkPermOrgs(
session, user.id(), myPerms, function(){scGo();});
}, 20 );
}
function scGo() {
- var show = cgi.param('show');
- if(!show) currentlyVisible = ASSET;
+ var show = cgi.param('show');
+ if(!show) currentlyVisible = ASSET;
scSetPerms();
- scShow(currentlyVisible);
- scBuildNew();
- $('sc_user').appendChild(text(user.usrname()));
+ scShow(currentlyVisible);
+ scBuildNew();
+ $('sc_user').appendChild(text(user.usrname()));
}
function scFetchAll( session, type, orgid, callback, args ) {
- var req = new Request(
- SC_FETCH_ALL.replace(/TYPE/, type) , session, orgid );
- req.send(true);
- return req.result();
+ var req = new Request(
+ SC_FETCH_ALL.replace(/TYPE/, type) , session, orgid );
+ req.send(true);
+ return req.result();
}
function scShow(type) {
- setTimeout(function(){_scShow(type)}, 500);
+ setTimeout(function(){_scShow(type)}, 500);
}
function _scShow(type) {
- currentlyVisible = type;
+ currentlyVisible = type;
- if( type == ASSET ) {
- addCSSClass($('sc_show_copy'), 'has_color');
- removeCSSClass($('sc_show_actor'), 'has_color');
+ if( type == ASSET ) {
+ addCSSClass($('sc_show_copy'), 'has_color');
+ removeCSSClass($('sc_show_actor'), 'has_color');
- } else if( type == ACTOR ) {
- addCSSClass($('sc_show_actor'), 'has_color');
- removeCSSClass($('sc_show_copy'), 'has_color');
- }
+ } else if( type == ACTOR ) {
+ addCSSClass($('sc_show_actor'), 'has_color');
+ removeCSSClass($('sc_show_copy'), 'has_color');
+ }
- scCache[type] = scFetchAll(session, type, focusOrg); /* XXX */
- scDraw( type, scCache[type] );
+ scCache[type] = scFetchAll(session, type, focusOrg); /* XXX */
+ scDraw( type, scCache[type] );
}
var scRow; var scCounter;
function scDraw( type, cats ) {
- hideMe($('loading'));
+ hideMe($('loading'));
- var tbody = $('sc_tbody');
- if(!scRow) scRow = tbody.removeChild($('sc_tr'));
- removeChildren(tbody);
+ var tbody = $('sc_tbody');
+ if(!scRow) scRow = tbody.removeChild($('sc_tr'));
+ removeChildren(tbody);
- if(!cats || cats.length == 0) {
- hideMe($('sc_table'));
- unHideMe($('sc_none'));
- return;
- }
+ if(!cats || cats.length == 0) {
+ hideMe($('sc_table'));
+ unHideMe($('sc_none'));
+ return;
+ }
- hideMe($('sc_none'));
- unHideMe($('sc_table'));
+ hideMe($('sc_none'));
+ unHideMe($('sc_table'));
if(type == 'actor')
unHideMe($('sc_usr_summary_label'));
else
hideMe($('sc_usr_summary_label'));
- scCounter = 0;
- for( var c in cats ) scInsertCat( tbody, cats[c], type );
+ scCounter = 0;
+ for( var c in cats ) scInsertCat( tbody, cats[c], type );
}
var scEntryCounter;
function scInsertCat( tbody, cat, type ) {
- var row = scRow.cloneNode(true);
- row.id = 'sc_tr_' + cat.id();
- var name_td = $n(row, 'sc_name');
- name_td.appendChild( text(cat.name()) );
- if(scCounter++ % 2) addCSSClass(row, 'has_color');
+ var row = scRow.cloneNode(true);
+ row.id = 'sc_tr_' + cat.id();
+ var name_td = $n(row, 'sc_name');
+ name_td.appendChild( text(cat.name()) );
+ if(scCounter++ % 2) addCSSClass(row, 'has_color');
- $n(row, 'sc_new_entry').onclick = function() { scNewEntry(type, cat, tbody); }
- $n(row, 'sc_edit').onclick = function(){ scEdit(tbody, type, cat); };
- $n(row, 'sc_owning_lib').appendChild( text( findOrgUnit(cat.owner()).name() ));
+ $n(row, 'sc_new_entry').onclick = function() { scNewEntry(type, cat, tbody); }
+ $n(row, 'sc_edit').onclick = function(){ scEdit(tbody, type, cat); };
+ $n(row, 'sc_owning_lib').appendChild( text( findOrgUnit(cat.owner()).name() ));
if(isTrue(cat.opac_visible()))
- unHideMe($n(row, 'sc_opac_visible'));
- else
+ unHideMe($n(row, 'sc_opac_visible'));
+ else
unHideMe($n(row, 'sc_opac_invisible'));
if(type == 'actor') {
if(isTrue(cat.usr_summary()))
- unHideMe($n(row, 'sc_usr_summary_on'));
- else
+ unHideMe($n(row, 'sc_usr_summary_on'));
+ else
unHideMe($n(row, 'sc_usr_summary'));
} else {
hideMe($n(row, 'sc_usr_summary_td'));
}
- tbody.appendChild(row);
- scEntryCounter = 0;
+ tbody.appendChild(row);
+ scEntryCounter = 0;
- cat.entries().sort( /* sort the entries by value */
- function( a, b ) {
+ cat.entries().sort( /* sort the entries by value */
+ function( a, b ) {
a = new String(a.value()).toLowerCase();
b = new String(b.value()).toLowerCase();
- if( a > b ) return 1;
- if( a < b ) return -1;
- return 0;
- }
- );
-
- for( var e in cat.entries() )
- scInsertEntry( cat, cat.entries()[e], $n(row, 'sc_entries_selector'), tbody, type );
+ if( a > b ) return 1;
+ if( a < b ) return -1;
+ return 0;
+ }
+ );
+
+ for( var e in cat.entries() )
+ scInsertEntry( cat, cat.entries()[e], $n(row, 'sc_entries_selector'), tbody, type );
}
function scInsertEntry( cat, entry, selector, tbody, type ) {
- setSelectorVal( selector, scEntryCounter++, entry.value(), entry.id(),
- function(){ scUpdateEntry( cat, entry, tbody, type );} );
+ setSelectorVal( selector, scEntryCounter++, entry.value(), entry.id(),
+ function(){ scUpdateEntry( cat, entry, tbody, type );} );
}
function scDelete(type, id) {
- if(!confirm($('sc_delete_confirm').innerHTML)) return;
- var req = new Request( SC_DELETE.replace(/TYPE/,type), session, id );
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- alertId('sc_update_success');
- scShow(type);
+ if(!confirm($('sc_delete_confirm').innerHTML)) return;
+ var req = new Request( SC_DELETE.replace(/TYPE/,type), session, id );
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ alertId('sc_update_success');
+ scShow(type);
}
function scCreateEntry( type, id, row ) {
- var value = $n(row, 'sc_new_entry_name').value;
- if(!value) return;
- var entry;
- if( type == ACTOR ) entry = new actsce();
- if( type == ASSET ) entry = new asce();
-
- entry.isnew(1);
- entry.stat_cat(id);
- entry.owner(getSelectorVal($n(row, 'sc_new_entry_lib')));
- entry.value(value);
-
- var req = new Request( SC_ENTRY_CREATE.replace(/TYPE/, type), session, entry );
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- alertId('sc_update_success');
- scShow(type);
+ var value = $n(row, 'sc_new_entry_name').value;
+ if(!value) return;
+ var entry;
+ if( type == ACTOR ) entry = new actsce();
+ if( type == ASSET ) entry = new asce();
+
+ entry.isnew(1);
+ entry.stat_cat(id);
+ entry.owner(getSelectorVal($n(row, 'sc_new_entry_lib')));
+ entry.value(value);
+
+ var req = new Request( SC_ENTRY_CREATE.replace(/TYPE/, type), session, entry );
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ alertId('sc_update_success');
+ scShow(type);
}
function scNewEntry( type, cat, tbody ) {
- cleanTbody(tbody, 'edit');
- var row = $('sc_new_entry_row').cloneNode(true);
- row.setAttribute('edit', '1');
+ cleanTbody(tbody, 'edit');
+ var row = $('sc_new_entry_row').cloneNode(true);
+ row.setAttribute('edit', '1');
- var r = $('sc_tr_' + cat.id());
- if(r.nextSibling) tbody.insertBefore( row, r.nextSibling );
- else{ tbody.appendChild(row); }
+ var r = $('sc_tr_' + cat.id());
+ if(r.nextSibling) tbody.insertBefore( row, r.nextSibling );
+ else{ tbody.appendChild(row); }
- $n(row, 'sc_new_entry_create').onclick =
- function() {
- if( scCreateEntry( type, cat.id(), row ) )
- tbody.removeChild(row); };
- $n(row, 'sc_new_entry_cancel').onclick = function(){tbody.removeChild(row);}
+ $n(row, 'sc_new_entry_create').onclick =
+ function() {
+ if( scCreateEntry( type, cat.id(), row ) )
+ tbody.removeChild(row); };
+ $n(row, 'sc_new_entry_cancel').onclick = function(){tbody.removeChild(row);}
var org_list = PERMS[type].create_stat_cat_entry;
if(org_list.length == 0) {
- $n(row, 'sc_new_entry_create').disabled = true;
- $n(row, 'sc_new_entry_lib').disabled = true;
- return;
+ $n(row, 'sc_new_entry_create').disabled = true;
+ $n(row, 'sc_new_entry_lib').disabled = true;
+ return;
}
var rootOrg = findReleventRootOrg(org_list, cat.owner());
if(!rootOrg) {
- $n(row, 'sc_new_entry_create').disabled = true;
- $n(row, 'sc_new_entry_lib').disabled = true;
- return;
+ $n(row, 'sc_new_entry_create').disabled = true;
+ $n(row, 'sc_new_entry_lib').disabled = true;
+ return;
}
buildOrgSel($n(row, 'sc_new_entry_lib'), rootOrg, 0, 'shortname');
- $n(row, 'sc_new_entry_name').focus();
+ $n(row, 'sc_new_entry_name').focus();
}
function scBuildNew() {
var libSel = $('sc_owning_lib_selector');
var typeSel = $('sc_type_selector');
- var type = getSelectorVal(typeSel);
+ var type = getSelectorVal(typeSel);
var org_list = PERMS[type].create_stat_cat;
if(org_list.length == 0) { /* no create perms */
$('sc_new').disabled = true;
libSel.disabled = true;
return;
}
- buildMergedOrgSel(libSel, org_list, 0, 'shortname');
+ buildMergedOrgSel(libSel, org_list, 0, 'shortname');
}
function scNew() {
- var name = $('sc_new_name').value;
- var type = getSelectorVal($('sc_type_selector'));
+ var name = $('sc_new_name').value;
+ var type = getSelectorVal($('sc_type_selector'));
- var visible = 0;
- if( $('sc_make_opac_visible').checked) visible = 1;
+ var visible = 0;
+ if( $('sc_make_opac_visible').checked) visible = 1;
- var cat;
- if( type == ACTOR ) cat = new actsc();
- if( type == ASSET ) cat = new asc();
+ var cat;
+ if( type == ACTOR ) cat = new actsc();
+ if( type == ASSET ) cat = new asc();
- cat.opac_visible(visible);
- cat.name(name);
- cat.owner(getSelectorVal($('sc_owning_lib_selector')));
- cat.isnew(1);
+ cat.opac_visible(visible);
+ cat.name(name);
+ cat.owner(getSelectorVal($('sc_owning_lib_selector')));
+ cat.isnew(1);
- var req = new Request( SC_CREATE.replace(/TYPE/, type), session, cat );
+ var req = new Request( SC_CREATE.replace(/TYPE/, type), session, cat );
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- alertId('sc_update_success');
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ alertId('sc_update_success');
- scShow(type);
+ scShow(type);
}
function scEdit( tbody, type, cat ) {
- cleanTbody(tbody, 'edit');
- var row = $('sc_edit_row').cloneNode(true);
- row.setAttribute('edit', '1');
+ cleanTbody(tbody, 'edit');
+ var row = $('sc_edit_row').cloneNode(true);
+ row.setAttribute('edit', '1');
- var r = $('sc_tr_' + cat.id());
- if(r.nextSibling) { tbody.insertBefore( row, r.nextSibling ); }
- else{ tbody.appendChild(row); }
+ var r = $('sc_tr_' + cat.id());
+ if(r.nextSibling) { tbody.insertBefore( row, r.nextSibling ); }
+ else{ tbody.appendChild(row); }
- $n(row, 'sc_edit_name').value = cat.name();
+ $n(row, 'sc_edit_name').value = cat.name();
if(type == 'actor') {
var cb = $n(row, 'sc_edit_usr_summary');
hideMe($n(row, 'sc_edit_usr_summary_td'));
}
- var name = $n(row, 'sc_edit_cancel');
- name.onclick = function() { tbody.removeChild(row); };
-
- var show = $n(row, 'sc_edit_show_owning_lib');
-
- var myorg = findOrgUnit(user.home_ou());
- var ownerorg = findOrgUnit(cat.owner());
- show.appendChild(text(ownerorg.name()));
-
- var selector = null;
- if( myorg.children() && myorg.children().length > 0 ) {
- selector = $n(row, 'sc_edit_owning_lib');
- buildOrgSel( selector, myorg, findOrgDepth(myorg), 'shortname');
- setSelector( selector, cat.owner() );
- unHideMe(selector);
-
- } else { unHideMe(show); }
-
- name.focus();
- name.select();
-
- if( cat.opac_visible() != 0 && cat.opac_visible() != '0' ) {
- $n( $n(row, 'sc_edit_opac_vis'),
- 'sc_edit_opac_visibility').checked = true;
- } else {
- $n( $n(row, 'sc_edit_opac_invis'),
- 'sc_edit_opac_visibility').checked = true;
+ var name = $n(row, 'sc_edit_cancel');
+ name.onclick = function() { tbody.removeChild(row); };
+
+ var show = $n(row, 'sc_edit_show_owning_lib');
+
+ var myorg = findOrgUnit(user.home_ou());
+ var ownerorg = findOrgUnit(cat.owner());
+ show.appendChild(text(ownerorg.name()));
+
+ var selector = null;
+ if( myorg.children() && myorg.children().length > 0 ) {
+ selector = $n(row, 'sc_edit_owning_lib');
+ buildOrgSel( selector, myorg, findOrgDepth(myorg), 'shortname');
+ setSelector( selector, cat.owner() );
+ unHideMe(selector);
+
+ } else { unHideMe(show); }
+
+ name.focus();
+ name.select();
+
+ if( cat.opac_visible() != 0 && cat.opac_visible() != '0' ) {
+ $n( $n(row, 'sc_edit_opac_vis'),
+ 'sc_edit_opac_visibility').checked = true;
+ } else {
+ $n( $n(row, 'sc_edit_opac_invis'),
+ 'sc_edit_opac_visibility').checked = true;
}
- $n(row, 'sc_edit_submit').onclick =
- function() { scEditGo( type, cat, row, selector ); };
+ $n(row, 'sc_edit_submit').onclick =
+ function() { scEditGo( type, cat, row, selector ); };
- $n(row, 'sc_edit_delete').onclick =
- function(){ scDelete(type, cat.id()); };
+ $n(row, 'sc_edit_delete').onclick =
+ function(){ scDelete(type, cat.id()); };
var rootEditOrg = findReleventRootOrg(PERMS[type].update_stat_cat, cat.owner());
var rootDelOrg = findReleventRootOrg(PERMS[type].delete_stat_cat, cat.owner());
if(!rootEditOrg || rootEditOrg.id() != cat.owner())
- $n(row,'sc_edit_submit').disabled = true;
+ $n(row,'sc_edit_submit').disabled = true;
if(!rootDelOrg || rootDelOrg.id() != cat.owner())
- $n(row,'sc_edit_delete').disabled = true;
+ $n(row,'sc_edit_delete').disabled = true;
}
function scEditGo( type, cat, row, selector ) {
- var name = $n(row, 'sc_edit_name').value;
- var visible =
- $n( $n(row, 'sc_edit_opac_vis'), 'sc_edit_opac_visibility').checked;
+ var name = $n(row, 'sc_edit_name').value;
+ var visible =
+ $n( $n(row, 'sc_edit_opac_vis'), 'sc_edit_opac_visibility').checked;
- var newlib = cat.owner();
- if(selector) newlib = getSelectorVal( selector );
+ var newlib = cat.owner();
+ if(selector) newlib = getSelectorVal( selector );
- if(!name) return false;
+ if(!name) return false;
- var isvisible = false;
- if( cat.opac_visible() != 0 && cat.opac_visible() != '0' ) isvisible = true;
+ var isvisible = false;
+ if( cat.opac_visible() != 0 && cat.opac_visible() != '0' ) isvisible = true;
var usr_summary = $n(row, 'sc_edit_usr_summary').checked;
- if( (name == cat.name()) &&
+ if( (name == cat.name()) &&
(visible == isvisible) &&
(newlib == cat.owner()) &&
(usr_summary == isTrue(cat.usr_summary())) )
return true;
- cat.name( name );
- cat.owner( newlib );
- cat.entries(null);
- cat.opac_visible(0);
- if( visible ) cat.opac_visible(1);
+ cat.name( name );
+ cat.owner( newlib );
+ cat.entries(null);
+ cat.opac_visible(0);
+ if( visible ) cat.opac_visible(1);
cat.usr_summary( (usr_summary) ? 1 : 0 );
- var req = new Request( SC_UPDATE.replace(/TYPE/,type), session, cat );
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- alertId('sc_update_success');
- scShow(type);
+ var req = new Request( SC_UPDATE.replace(/TYPE/,type), session, cat );
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ alertId('sc_update_success');
+ scShow(type);
- return true;
+ return true;
}
function scUpdateEntry( cat, entry, tbody, type ) {
- cleanTbody(tbody, 'edit');
- var row = $('sc_edit_entry_row').cloneNode(true);
- row.setAttribute('edit', '1');
+ cleanTbody(tbody, 'edit');
+ var row = $('sc_edit_entry_row').cloneNode(true);
+ row.setAttribute('edit', '1');
- var r = $('sc_tr_' + cat.id());
- if(r.nextSibling) tbody.insertBefore( row, r.nextSibling );
- else{ tbody.appendChild(row); }
+ var r = $('sc_tr_' + cat.id());
+ if(r.nextSibling) tbody.insertBefore( row, r.nextSibling );
+ else{ tbody.appendChild(row); }
- $n(row, 'sc_edit_entry_owner').appendChild(text(findOrgUnit(entry.owner()).name()));
+ $n(row, 'sc_edit_entry_owner').appendChild(text(findOrgUnit(entry.owner()).name()));
- var name = $n(row, 'sc_edit_entry_name');
- name.value = entry.value();
- name.focus();
- name.select();
+ var name = $n(row, 'sc_edit_entry_name');
+ name.value = entry.value();
+ name.focus();
+ name.select();
- $n(row,'sc_edit_entry_name_submit').onclick =
- function(){
- if( scEditEntry(cat, entry, name.value, type ) )
- tbody.removeChild(row);
- };
+ $n(row,'sc_edit_entry_name_submit').onclick =
+ function(){
+ if( scEditEntry(cat, entry, name.value, type ) )
+ tbody.removeChild(row);
+ };
- $n(row,'sc_edit_entry_cancel').onclick = function(){tbody.removeChild(row);};
- $n(row,'sc_edit_entry_delete').onclick =
- function(){ scEntryDelete( cat, entry, type ); }
+ $n(row,'sc_edit_entry_cancel').onclick = function(){tbody.removeChild(row);};
+ $n(row,'sc_edit_entry_delete').onclick =
+ function(){ scEntryDelete( cat, entry, type ); }
var rootEditOrg = findReleventRootOrg(PERMS[type].update_stat_cat_entry, entry.owner());
var rootDelOrg = findReleventRootOrg(PERMS[type].delete_stat_cat_entry, entry.owner());
if(!rootEditOrg || rootEditOrg.id() != entry.owner())
- $n(row,'sc_edit_submit').disabled = true;
+ $n(row,'sc_edit_submit').disabled = true;
if(!rootDelOrg || rootDelOrg.id() != entry.owner())
- $n(row,'sc_edit_delete').disabled = true;
+ $n(row,'sc_edit_delete').disabled = true;
}
function scEntryDelete( cat, entry, type ) {
- if(!confirm($('sc_entry_delete_confirm').innerHTML)) return;
- var req = new Request( SC_ENTRY_DELETE.replace(/TYPE/,type), session, entry.id() );
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- alertId('sc_update_success');
- scShow(type);
+ if(!confirm($('sc_entry_delete_confirm').innerHTML)) return;
+ var req = new Request( SC_ENTRY_DELETE.replace(/TYPE/,type), session, entry.id() );
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ alertId('sc_update_success');
+ scShow(type);
}
function scEditEntry( cat, entry, newvalue, type ) {
- if(entry.value() == newvalue) return;
- entry.value( newvalue );
- var req = new Request(
- SC_ENTRY_UPDATE.replace(/TYPE/, type), session, entry );
- req.send(true);
- var res = req.result();
- if(checkILSEvent(res)) throw res;
- scShow(type);
+ if(entry.value() == newvalue) return;
+ entry.value( newvalue );
+ var req = new Request(
+ SC_ENTRY_UPDATE.replace(/TYPE/, type), session, entry );
+ req.send(true);
+ var res = req.result();
+ if(checkILSEvent(res)) throw res;
+ scShow(type);
}
if (typeof admin == 'undefined') admin = {};
admin.transit_list = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network(); JSAN.use('util.file');
- JSAN.use('util.date'); JSAN.use('util.widgets'); JSAN.use('util.fm_utils'); JSAN.use('util.functional');
- JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network(); JSAN.use('util.file');
+ JSAN.use('util.date'); JSAN.use('util.widgets'); JSAN.use('util.fm_utils'); JSAN.use('util.functional');
+ JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
}
admin.transit_list.prototype = {
- 'init' : function( params ) {
-
- var obj = this;
-
- var x = document.getElementById('libmenu_placeholder');
- util.widgets.remove_children( x );
-
- var file; var list_data; var ml;
-
- file = new util.file('offline_ou_list');
- if (file._file.exists()) {
- list_data = file.get_object(); file.close();
- ml = util.widgets.make_menulist( list_data[0], list_data[1] );
- ml.setAttribute('id','libmenu'); document.getElementById('libmenu_placeholder').appendChild(ml);
- ml.addEventListener(
- 'command',
- function(ev) {
- var file = new util.file('transit_list_prefs.'+obj.data.server_unadorned);
- util.widgets.save_attributes(file, { 'libmenu' : [ 'value' ] });
- },
- false
- );
- } else {
- throw(document.getElementById('adminStrings').getString('staff.admin.transit_list.missing_list') + '\n');
- }
-
- file = new util.file('transit_list_prefs.'+obj.data.server_unadorned);
- util.widgets.load_attributes(file);
- ml.value = ml.getAttribute('value');
- if (! ml.value) {
- ml.value = obj.data.list.au[0].ws_ou();
- ml.setAttribute('value',ml.value);
- }
-
- x.appendChild( ml );
-
- obj.list_init();
- obj.controller_init();
- //obj.kick_off();
-
- },
-
- 'sdate' : null,
- 'edate' : null,
-
- 'handle_date' : function(value,end_of_day) {
- try {
- var _date = null;
-
- /* The Beginning */
- if (value.match(/The Beginning/)) {
- _date = new Date(); _date.setTime( 0 );
- }
-
- /* Today */
- if (value.match(/^Today$/i)) {
- _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
- }
-
- /* handle YYYY-MM-DD */
- var _string = value.match(/(\d\d\d\d)[\-\/](\d\d?)[\-\/](\d\d?)/);
- if (_string) {
- if (util.date.check('YYYY-MM-DD',_string[1]+'-'+_string[2]+'-'+_string[3])) {
- _date = util.date.buildDate( _string[1], _string[2], _string[3], 0, 0, 0);
- } else {
- alert(document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.invalid_date', [_string]));
- _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
- }
- }
-
- /* handle relative dates */
- var interval = value.match(/Today \- (.+)/);
- if (interval) {
- _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
- _date.setTime( _date.getTime() - util.date.interval_to_seconds(interval[1])*1000 );
- }
-
- if (! util.date.check('YYYY-MM-DD',util.date.formatted_date(_date,"%F")) ) {
- alert(document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.invalid_date', [_date, util.date.formatted_date(_date,"%F")]));
- _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
- }
-
- if (end_of_day) { // This just handles calendar days.. if we wanted to support (Today-1 month,Today-1 month), I'll need a better library, or a query to postgres
- _date.setTime( _date.getTime() + util.date.interval_to_seconds('1 day')*1000 - util.date.interval_to_seconds('1 second')*1000 );
- }
-
- return util.date.formatted_date(_date,'%{iso8601}');
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.date_processing.error'),E); } catch(F) { alert(E); }
- _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
- return util.date.formatted_date(_date,'%{iso8601}');
- }
- },
-
- 'kick_off' : function() {
- var obj = this;
- try {
- obj.list.clear();
- obj.sdate = obj.handle_date( document.getElementById('sdate').value, false );
- obj.edate = obj.handle_date( document.getElementById('edate').value, true );
- var sdate; var edate;
- if (obj.sdate < obj.edate) {
- sdate = obj.sdate; edate = obj.edate;
- } else {
- sdate = obj.edate; edate = obj.sdate;
- }
- obj.network.simple_request('FM_ATC_RETRIEVE_VIA_AOU',[ ses(), /*obj.data.list.au[ 0 ].ws_ou()*/ document.getElementById('libmenu').value, sdate, edate ],
- function(req) {
- try {
- var robj = req.getResultObject();
- if (typeof robj.ilsevent != 'undefined') throw(robj);
-
- JSAN.use('util.exec');
- var exec = new util.exec(2);
- var exec2 = new util.exec(2);
-
- function gen_list_append(id,which_list) {
- return function() {
- switch(which_list) {
- case 0: obj.list.append( { 'row' : { 'my' : { 'transit_id' : id } }, 'no_auto_select' : true } ); break;
- case 1: obj.list.append( { 'row' : { 'my' : { 'transit_id' : id } }, 'no_auto_select' : true } ); break;
- }
- };
- }
-
- var rows = [];
-
- if (document.getElementById('transit_direction').value=='transit_from') for (var i = 0; i < robj.from.length; i++) {
- //get_transit(robj.from[i], 0);
- rows.push( gen_list_append(robj.from[i],0) );
- }
-
- if (document.getElementById('transit_direction').value=='transit_to') for (var i = 0; i < robj.to.length; i++) {
- //get_transit(robj.to[i], 1);
- rows.push( gen_list_append(robj.to[i],1) );
- }
-
- if (rows.length > 0) {
- exec.chain( rows );
- } else {
- alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.no_match'));
- }
-
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.retrieving_transit.error'),E); } catch(F) { alert(E); }
- }
- }
- );
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.preretrieving_transit.error'),E); } catch(F) { alert(E); }
- }
- },
-
- 'list_init' : function() {
-
- var obj = this;
-
- obj.selection_list = [];
-
- JSAN.use('circ.util');
- var columns = circ.util.transit_columns(
- {
- 'transit_source' : { 'hidden' : false },
- 'transit_source_send_time' : { 'hidden' : false },
- 'transit_dest_lib' : { 'hidden' : false },
- 'transit_item_barcode' : { 'hidden' : false },
- 'transit_item_title' : { 'hidden' : false },
- },
- {
- 'just_these' : [
- 'transit_id',
- 'transit_source',
- 'transit_source_send_time',
- 'transit_dest_lib',
- 'transit_item_barcode',
- 'transit_item_title',
- 'transit_item_author',
- 'transit_item_callnumber',
- 'transit_target_copy',
- ]
- }
- ).concat(
- circ.util.hold_columns(
- {
- 'request_time' : { 'hidden' : false },
- },
- {
- 'just_these' : [
- 'request_timestamp',
- 'request_time',
- 'capture_timestamp',
- 'capture_time',
- 'hold_type',
- 'expire_time',
- 'patron_first_given_name',
- 'patron_family_name',
- 'patron_barcode',
- ],
- }
- )
- );
-
- JSAN.use('util.list');
- obj.list = new util.list('transit_list');
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
- 'retrieve_row' : function(params) {
- var row = params.row;
- try {
- obj.get_transit_and_hold_and_run_func(
- row.my.transit_id,
- function(transit,hold) { return obj.get_rest_of_row_given_transit_and_hold(params,transit,hold); }
- );
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.retrieving_row.error'),E); } catch(F) { alert(E); }
- }
- },
- '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','admin.transit_list: selection list = ' + js2JSON(obj.selection_list) );
- if (obj.selection_list.length == 0) {
- obj.controller.view.sel_edit.setAttribute('disabled','true');
- obj.controller.view.sel_opac.setAttribute('disabled','true');
- obj.controller.view.sel_bucket.setAttribute('disabled','true');
- obj.controller.view.sel_copy_details.setAttribute('disabled','true');
- obj.controller.view.sel_patron.setAttribute('disabled','true');
- obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
- obj.controller.view.sel_clip.setAttribute('disabled','true');
- } else {
- obj.controller.view.sel_edit.setAttribute('disabled','false');
- obj.controller.view.sel_opac.setAttribute('disabled','false');
- obj.controller.view.sel_patron.setAttribute('disabled','false');
- obj.controller.view.sel_bucket.setAttribute('disabled','false');
- obj.controller.view.sel_copy_details.setAttribute('disabled','false');
- obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
- obj.controller.view.sel_clip.setAttribute('disabled','false');
- }
- } catch(E) {
- alert('FIXME: ' + E);
- }
- },
- }
- );
- },
-
- 'get_transit_and_hold_and_run_func' : function (transit_id,do_this) {
- var obj = this;
- obj.network.simple_request('FM_ATC_RETRIEVE', [ ses(), transit_id ],
- function(req2) {
- try {
- var r_atc = req2.getResultObject();
- if (typeof r_atc.ilsevent != 'undefined') throw(r_atc);
-
- if (instanceOf(r_atc,atc)) {
- do_this(r_atc,null);
- } else if (instanceOf(r_atc,ahtc)) {
- obj.network.simple_request('FM_AHR_RETRIEVE', [ ses(), r_atc.hold() ],
- function(req3) {
- try {
- var r_ahr = req3.getResultObject();
- if (typeof r_ahr.ilsevent != 'undefined') throw(r_ahr);
- if (r_ahr.length == 0) {
- try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.empty_array.error') + document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.empty_array.error', [r_atc.hold(), transit_id]),E); } catch(F) { alert(E); }
- do_this(r_atc,null);
- } else {
- if (instanceOf(r_ahr[0],ahr)) {
- do_this(r_atc,r_ahr[0]);
- } else {
- throw(r_ahr);
- }
- }
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.empty_array.error', [r_atc.hold(), transit_id]),E); } catch(F) { alert(E); }
- do_this(r_atc,null);
- }
- }
- );
- } else {
- throw(r_atc);
- }
-
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.transit_id.error', [transit_id]),E); } catch(F) { alert(E); }
- }
- }
- );
- },
-
- 'get_rest_of_row_given_transit_and_hold' : function(params,transit,hold) {
- var obj = this;
- var row = params.row;
-
- row.my.atc = transit;
- if (hold) row.my.ahr = hold;
-
- obj.network.simple_request(
- 'FM_ACP_RETRIEVE',
- [ row.my.atc.target_copy() ],
- function(req) {
- try {
- var r_acp = req.getResultObject();
- if (typeof r_acp.ilsevent != 'undefined') throw(r_acp);
- row.my.acp = r_acp;
-
- obj.network.simple_request(
- 'FM_ACN_RETRIEVE.authoritative',
- [ r_acp.call_number() ],
- function(req2) {
- try {
- var r_acn = req2.getResultObject();
- if (typeof r_acn.ilsevent != 'undefined') throw(r_acn);
- row.my.acn = r_acn;
-
- if (row.my.acn.record() > 0) {
- obj.network.simple_request(
- 'MODS_SLIM_RECORD_RETRIEVE.authoritative',
- [ r_acn.record() ],
- function(req3) {
- try {
- var r_mvr = req3.getResultObject();
- if (typeof r_mvr.ilsevent != 'undefined') throw(r_mvr);
- row.my.mvr = r_mvr;
-
- params.row_node.setAttribute(
- 'retrieve_id', js2JSON( {
- 'copy_id' : row.my.acp ? row.my.acp.id() : null,
- 'doc_id' : row.my.mvr ? row.my.mvr.doc_id() : null,
- 'barcode' : row.my.acp ? row.my.acp.barcode() : null,
- 'acp_id' : row.my.acp ? row.my.acp.id() : null,
- 'acn_id' : row.my.acn ? row.my.acn.id() : null,
- 'atc_id' : row.my.atc ? row.my.atc.id() : null,
- 'ahr_id' : row.my.ahr ? row.my.ahr.id() : null,
- } )
- );
- if (typeof params.on_retrieve == 'function') {
- params.on_retrieve(row);
- }
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert('retrieving mvr',E); } catch(F) { alert(E); }
- }
- }
- );
- } else {
- params.row_node.setAttribute(
- 'retrieve_id', js2JSON( {
- 'copy_id' : row.my.acp ? row.my.acp.id() : null,
- 'doc_id' : row.my.mvr ? row.my.mvr.doc_id() : null,
- 'barcode' : row.my.acp ? row.my.acp.barcode() : null,
- 'acp_id' : row.my.acp ? row.my.acp.id() : null,
- 'acn_id' : row.my.acn ? row.my.acn.id() : null,
- 'atc_id' : row.my.atc ? row.my.atc.id() : null,
- 'ahr_id' : row.my.ahr ? row.my.ahr.id() : null,
- } )
- );
- if (typeof params.on_retrieve == 'function') {
- params.on_retrieve(row);
- }
- }
-
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert('retrieving acn',E); } catch(F) { alert(E); }
- }
- }
- );
-
-
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert('retrieving acp',E); } catch(F) { alert(E); }
- }
- }
- );
- },
-
- 'controller_init' : function() {
- var obj = this;
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
- 'sel_clip' : [ ['command'], function() { obj.list.clipboard(); } ],
- 'sel_edit' : [ ['command'], function() { try { obj.spawn_copy_editor(0); } catch(E) { alert(E); } } ],
- 'sel_opac' : [ ['command'], function() { JSAN.use('cat.util'); cat.util.show_in_opac(obj.selection_list); } ],
- 'sel_transit_abort' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.abort_transits(obj.selection_list); } ],
- 'sel_patron' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.selection_list); } ],
- 'sel_copy_details' : [ ['command'], function() { JSAN.use('circ.util'); for (var i = 0; i < obj.selection_list.length; i++) { circ.util.show_copy_details( obj.selection_list[i].copy_id ); } } ],
- 'sel_bucket' : [ ['command'], function() { JSAN.use('cat.util'); cat.util.add_copies_to_bucket(obj.selection_list); } ],
- 'cmd_print_list' : [ ['command'], function() { obj.print_list(0); } ],
- 'cmd_kick_off' : [ ['command'], function(ev) { ev.target.disabled = true; obj.kick_off(); } ],
- 'sdate' : [ ['change'], function(ev) { ev.target.value = obj.handle_date(ev.target.value,false); obj.sdate = ev.target.value; /*alert('obj.sdate='+obj.sdate);*/ } ],
- 'edate' : [ ['change'], function(ev) { ev.target.value = obj.handle_date(ev.target.value,true); obj.edate = ev.target.value; /*alert('obj.edate='+obj.edate);*/ } ],
- }
- }
- );
- this.controller.render();
-
- },
-
- 'print_list' : function(which_list) {
- var obj = this;
- try {
- var list = which_list == 0 ? obj.list : obj.list2;
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ var x = document.getElementById('libmenu_placeholder');
+ util.widgets.remove_children( x );
+
+ var file; var list_data; var ml;
+
+ file = new util.file('offline_ou_list');
+ if (file._file.exists()) {
+ list_data = file.get_object(); file.close();
+ ml = util.widgets.make_menulist( list_data[0], list_data[1] );
+ ml.setAttribute('id','libmenu'); document.getElementById('libmenu_placeholder').appendChild(ml);
+ ml.addEventListener(
+ 'command',
+ function(ev) {
+ var file = new util.file('transit_list_prefs.'+obj.data.server_unadorned);
+ util.widgets.save_attributes(file, { 'libmenu' : [ 'value' ] });
+ },
+ false
+ );
+ } else {
+ throw(document.getElementById('adminStrings').getString('staff.admin.transit_list.missing_list') + '\n');
+ }
+
+ file = new util.file('transit_list_prefs.'+obj.data.server_unadorned);
+ util.widgets.load_attributes(file);
+ ml.value = ml.getAttribute('value');
+ if (! ml.value) {
+ ml.value = obj.data.list.au[0].ws_ou();
+ ml.setAttribute('value',ml.value);
+ }
+
+ x.appendChild( ml );
+
+ obj.list_init();
+ obj.controller_init();
+ //obj.kick_off();
+
+ },
+
+ 'sdate' : null,
+ 'edate' : null,
+
+ 'handle_date' : function(value,end_of_day) {
+ try {
+ var _date = null;
+
+ /* The Beginning */
+ if (value.match(/The Beginning/)) {
+ _date = new Date(); _date.setTime( 0 );
+ }
+
+ /* Today */
+ if (value.match(/^Today$/i)) {
+ _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
+ }
+
+ /* handle YYYY-MM-DD */
+ var _string = value.match(/(\d\d\d\d)[\-\/](\d\d?)[\-\/](\d\d?)/);
+ if (_string) {
+ if (util.date.check('YYYY-MM-DD',_string[1]+'-'+_string[2]+'-'+_string[3])) {
+ _date = util.date.buildDate( _string[1], _string[2], _string[3], 0, 0, 0);
+ } else {
+ alert(document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.invalid_date', [_string]));
+ _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
+ }
+ }
+
+ /* handle relative dates */
+ var interval = value.match(/Today \- (.+)/);
+ if (interval) {
+ _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
+ _date.setTime( _date.getTime() - util.date.interval_to_seconds(interval[1])*1000 );
+ }
+
+ if (! util.date.check('YYYY-MM-DD',util.date.formatted_date(_date,"%F")) ) {
+ alert(document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.invalid_date', [_date, util.date.formatted_date(_date,"%F")]));
+ _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
+ }
+
+ if (end_of_day) { // This just handles calendar days.. if we wanted to support (Today-1 month,Today-1 month), I'll need a better library, or a query to postgres
+ _date.setTime( _date.getTime() + util.date.interval_to_seconds('1 day')*1000 - util.date.interval_to_seconds('1 second')*1000 );
+ }
+
+ return util.date.formatted_date(_date,'%{iso8601}');
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.date_processing.error'),E); } catch(F) { alert(E); }
+ _date = new Date(); _date = util.date.buildDate( _date.getFullYear(), _date.getMonth()+1, _date.getDate(), 0, 0, 0); // morning
+ return util.date.formatted_date(_date,'%{iso8601}');
+ }
+ },
+
+ 'kick_off' : function() {
+ var obj = this;
+ try {
+ obj.list.clear();
+ obj.sdate = obj.handle_date( document.getElementById('sdate').value, false );
+ obj.edate = obj.handle_date( document.getElementById('edate').value, true );
+ var sdate; var edate;
+ if (obj.sdate < obj.edate) {
+ sdate = obj.sdate; edate = obj.edate;
+ } else {
+ sdate = obj.edate; edate = obj.sdate;
+ }
+ obj.network.simple_request('FM_ATC_RETRIEVE_VIA_AOU',[ ses(), /*obj.data.list.au[ 0 ].ws_ou()*/ document.getElementById('libmenu').value, sdate, edate ],
+ function(req) {
+ try {
+ var robj = req.getResultObject();
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+
+ JSAN.use('util.exec');
+ var exec = new util.exec(2);
+ var exec2 = new util.exec(2);
+
+ function gen_list_append(id,which_list) {
+ return function() {
+ switch(which_list) {
+ case 0: obj.list.append( { 'row' : { 'my' : { 'transit_id' : id } }, 'no_auto_select' : true } ); break;
+ case 1: obj.list.append( { 'row' : { 'my' : { 'transit_id' : id } }, 'no_auto_select' : true } ); break;
+ }
+ };
+ }
+
+ var rows = [];
+
+ if (document.getElementById('transit_direction').value=='transit_from') for (var i = 0; i < robj.from.length; i++) {
+ //get_transit(robj.from[i], 0);
+ rows.push( gen_list_append(robj.from[i],0) );
+ }
+
+ if (document.getElementById('transit_direction').value=='transit_to') for (var i = 0; i < robj.to.length; i++) {
+ //get_transit(robj.to[i], 1);
+ rows.push( gen_list_append(robj.to[i],1) );
+ }
+
+ if (rows.length > 0) {
+ exec.chain( rows );
+ } else {
+ alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.no_match'));
+ }
+
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.retrieving_transit.error'),E); } catch(F) { alert(E); }
+ }
+ }
+ );
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.preretrieving_transit.error'),E); } catch(F) { alert(E); }
+ }
+ },
+
+ 'list_init' : function() {
+
+ var obj = this;
+
+ obj.selection_list = [];
+
+ JSAN.use('circ.util');
+ var columns = circ.util.transit_columns(
+ {
+ 'transit_source' : { 'hidden' : false },
+ 'transit_source_send_time' : { 'hidden' : false },
+ 'transit_dest_lib' : { 'hidden' : false },
+ 'transit_item_barcode' : { 'hidden' : false },
+ 'transit_item_title' : { 'hidden' : false },
+ },
+ {
+ 'just_these' : [
+ 'transit_id',
+ 'transit_source',
+ 'transit_source_send_time',
+ 'transit_dest_lib',
+ 'transit_item_barcode',
+ 'transit_item_title',
+ 'transit_item_author',
+ 'transit_item_callnumber',
+ 'transit_target_copy',
+ ]
+ }
+ ).concat(
+ circ.util.hold_columns(
+ {
+ 'request_time' : { 'hidden' : false },
+ },
+ {
+ 'just_these' : [
+ 'request_timestamp',
+ 'request_time',
+ 'capture_timestamp',
+ 'capture_time',
+ 'hold_type',
+ 'expire_time',
+ 'patron_first_given_name',
+ 'patron_family_name',
+ 'patron_barcode',
+ ],
+ }
+ )
+ );
+
+ JSAN.use('util.list');
+ obj.list = new util.list('transit_list');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'retrieve_row' : function(params) {
+ var row = params.row;
+ try {
+ obj.get_transit_and_hold_and_run_func(
+ row.my.transit_id,
+ function(transit,hold) { return obj.get_rest_of_row_given_transit_and_hold(params,transit,hold); }
+ );
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.retrieving_row.error'),E); } catch(F) { alert(E); }
+ }
+ },
+ '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','admin.transit_list: selection list = ' + js2JSON(obj.selection_list) );
+ if (obj.selection_list.length == 0) {
+ obj.controller.view.sel_edit.setAttribute('disabled','true');
+ obj.controller.view.sel_opac.setAttribute('disabled','true');
+ obj.controller.view.sel_bucket.setAttribute('disabled','true');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','true');
+ obj.controller.view.sel_patron.setAttribute('disabled','true');
+ obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
+ obj.controller.view.sel_clip.setAttribute('disabled','true');
+ } else {
+ obj.controller.view.sel_edit.setAttribute('disabled','false');
+ obj.controller.view.sel_opac.setAttribute('disabled','false');
+ obj.controller.view.sel_patron.setAttribute('disabled','false');
+ obj.controller.view.sel_bucket.setAttribute('disabled','false');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','false');
+ obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
+ obj.controller.view.sel_clip.setAttribute('disabled','false');
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ },
+ }
+ );
+ },
+
+ 'get_transit_and_hold_and_run_func' : function (transit_id,do_this) {
+ var obj = this;
+ obj.network.simple_request('FM_ATC_RETRIEVE', [ ses(), transit_id ],
+ function(req2) {
+ try {
+ var r_atc = req2.getResultObject();
+ if (typeof r_atc.ilsevent != 'undefined') throw(r_atc);
+
+ if (instanceOf(r_atc,atc)) {
+ do_this(r_atc,null);
+ } else if (instanceOf(r_atc,ahtc)) {
+ obj.network.simple_request('FM_AHR_RETRIEVE', [ ses(), r_atc.hold() ],
+ function(req3) {
+ try {
+ var r_ahr = req3.getResultObject();
+ if (typeof r_ahr.ilsevent != 'undefined') throw(r_ahr);
+ if (r_ahr.length == 0) {
+ try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getString('staff.admin.transit_list.empty_array.error') + document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.empty_array.error', [r_atc.hold(), transit_id]),E); } catch(F) { alert(E); }
+ do_this(r_atc,null);
+ } else {
+ if (instanceOf(r_ahr[0],ahr)) {
+ do_this(r_atc,r_ahr[0]);
+ } else {
+ throw(r_ahr);
+ }
+ }
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.empty_array.error', [r_atc.hold(), transit_id]),E); } catch(F) { alert(E); }
+ do_this(r_atc,null);
+ }
+ }
+ );
+ } else {
+ throw(r_atc);
+ }
+
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert(document.getElementById('adminStrings').getFormattedString('staff.admin.transit_list.transit_id.error', [transit_id]),E); } catch(F) { alert(E); }
+ }
+ }
+ );
+ },
+
+ 'get_rest_of_row_given_transit_and_hold' : function(params,transit,hold) {
+ var obj = this;
+ var row = params.row;
+
+ row.my.atc = transit;
+ if (hold) row.my.ahr = hold;
+
+ obj.network.simple_request(
+ 'FM_ACP_RETRIEVE',
+ [ row.my.atc.target_copy() ],
+ function(req) {
+ try {
+ var r_acp = req.getResultObject();
+ if (typeof r_acp.ilsevent != 'undefined') throw(r_acp);
+ row.my.acp = r_acp;
+
+ obj.network.simple_request(
+ 'FM_ACN_RETRIEVE.authoritative',
+ [ r_acp.call_number() ],
+ function(req2) {
+ try {
+ var r_acn = req2.getResultObject();
+ if (typeof r_acn.ilsevent != 'undefined') throw(r_acn);
+ row.my.acn = r_acn;
+
+ if (row.my.acn.record() > 0) {
+ obj.network.simple_request(
+ 'MODS_SLIM_RECORD_RETRIEVE.authoritative',
+ [ r_acn.record() ],
+ function(req3) {
+ try {
+ var r_mvr = req3.getResultObject();
+ if (typeof r_mvr.ilsevent != 'undefined') throw(r_mvr);
+ row.my.mvr = r_mvr;
+
+ params.row_node.setAttribute(
+ 'retrieve_id', js2JSON( {
+ 'copy_id' : row.my.acp ? row.my.acp.id() : null,
+ 'doc_id' : row.my.mvr ? row.my.mvr.doc_id() : null,
+ 'barcode' : row.my.acp ? row.my.acp.barcode() : null,
+ 'acp_id' : row.my.acp ? row.my.acp.id() : null,
+ 'acn_id' : row.my.acn ? row.my.acn.id() : null,
+ 'atc_id' : row.my.atc ? row.my.atc.id() : null,
+ 'ahr_id' : row.my.ahr ? row.my.ahr.id() : null,
+ } )
+ );
+ if (typeof params.on_retrieve == 'function') {
+ params.on_retrieve(row);
+ }
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert('retrieving mvr',E); } catch(F) { alert(E); }
+ }
+ }
+ );
+ } else {
+ params.row_node.setAttribute(
+ 'retrieve_id', js2JSON( {
+ 'copy_id' : row.my.acp ? row.my.acp.id() : null,
+ 'doc_id' : row.my.mvr ? row.my.mvr.doc_id() : null,
+ 'barcode' : row.my.acp ? row.my.acp.barcode() : null,
+ 'acp_id' : row.my.acp ? row.my.acp.id() : null,
+ 'acn_id' : row.my.acn ? row.my.acn.id() : null,
+ 'atc_id' : row.my.atc ? row.my.atc.id() : null,
+ 'ahr_id' : row.my.ahr ? row.my.ahr.id() : null,
+ } )
+ );
+ if (typeof params.on_retrieve == 'function') {
+ params.on_retrieve(row);
+ }
+ }
+
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert('retrieving acn',E); } catch(F) { alert(E); }
+ }
+ }
+ );
+
+
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert('retrieving acp',E); } catch(F) { alert(E); }
+ }
+ }
+ );
+ },
+
+ 'controller_init' : function() {
+ var obj = this;
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
+ 'sel_clip' : [ ['command'], function() { obj.list.clipboard(); } ],
+ 'sel_edit' : [ ['command'], function() { try { obj.spawn_copy_editor(0); } catch(E) { alert(E); } } ],
+ 'sel_opac' : [ ['command'], function() { JSAN.use('cat.util'); cat.util.show_in_opac(obj.selection_list); } ],
+ 'sel_transit_abort' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.abort_transits(obj.selection_list); } ],
+ 'sel_patron' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.selection_list); } ],
+ 'sel_copy_details' : [ ['command'], function() { JSAN.use('circ.util'); for (var i = 0; i < obj.selection_list.length; i++) { circ.util.show_copy_details( obj.selection_list[i].copy_id ); } } ],
+ 'sel_bucket' : [ ['command'], function() { JSAN.use('cat.util'); cat.util.add_copies_to_bucket(obj.selection_list); } ],
+ 'cmd_print_list' : [ ['command'], function() { obj.print_list(0); } ],
+ 'cmd_kick_off' : [ ['command'], function(ev) { ev.target.disabled = true; obj.kick_off(); } ],
+ 'sdate' : [ ['change'], function(ev) { ev.target.value = obj.handle_date(ev.target.value,false); obj.sdate = ev.target.value; /*alert('obj.sdate='+obj.sdate);*/ } ],
+ 'edate' : [ ['change'], function(ev) { ev.target.value = obj.handle_date(ev.target.value,true); obj.edate = ev.target.value; /*alert('obj.edate='+obj.edate);*/ } ],
+ }
+ }
+ );
+ this.controller.render();
+
+ },
+
+ 'print_list' : function(which_list) {
+ var obj = this;
+ try {
+ var list = which_list == 0 ? obj.list : obj.list2;
var p = {
'template' : 'transit_list'
};
- list.print(p);
- } catch(E) {
- obj.error.standard_unexpected_error_alert('print',E);
- }
- },
-
- 'spawn_copy_editor' : function(which_list) {
+ list.print(p);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('print',E);
+ }
+ },
+
+ 'spawn_copy_editor' : function(which_list) {
- var obj = this;
+ var obj = this;
- JSAN.use('util.functional');
+ JSAN.use('util.functional');
- var list = which_list == 0 ? obj.selection_list : obj.selection_list2;
+ var list = which_list == 0 ? obj.selection_list : obj.selection_list2;
- list = util.functional.map_list(
- list,
- function (o) {
- return o.copy_id;
- }
- );
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.copy_id;
+ }
+ );
- JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
+ JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
- },
+ },
}
var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
function $(id) {
- return document.getElementById(id);
+ return document.getElementById(id);
}
function my_init() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalFileRead");
- if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
- JSAN.errorLevel = "die"; // none, warn, or die
- JSAN.addRepository('..');
- JSAN.use('util.error'); g.error = new util.error();
- g.error.sdump('D_TRACE','my_init() for upload_xacts.html');
-
- if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
- try { window.xulG.set_tab_name('Upload Offline Transactions'); } catch(E) { alert(E); }
- }
-
- JSAN.use('util.file'); g.file = new util.file( xul_param('filename') );
-
- if (g.file._file.exists()) {
- $('submit').disabled = false;
- $('file').value = g.file._file.path;
- } else {
- alert('No transactions to upload.');
- return;
- }
-
- $( 'ws' ).setAttribute('value', xul_param('ws'));
- $( 'ses' ).setAttribute('value', xul_param('ses'));
- $( 'seskey' ).setAttribute('value', xul_param('seskey'));
- $( 'delta' ).setAttribute('value', xul_param('delta'));
-
- $( 'form' ).setAttribute('action', xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI));
-
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.click('submit');
- }, 0
- );
-
- } catch(E) {
- var err_msg = "!! This software has encountered an error. Please tell your friendly " +
- "system administrator or software developer the following:\nmain/upload_xacts.xhtml\n" + E + '\n';
- try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
- alert(err_msg);
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalFileRead");
+ if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('..');
+ JSAN.use('util.error'); g.error = new util.error();
+ g.error.sdump('D_TRACE','my_init() for upload_xacts.html');
+
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name('Upload Offline Transactions'); } catch(E) { alert(E); }
+ }
+
+ JSAN.use('util.file'); g.file = new util.file( xul_param('filename') );
+
+ if (g.file._file.exists()) {
+ $('submit').disabled = false;
+ $('file').value = g.file._file.path;
+ } else {
+ alert('No transactions to upload.');
+ return;
+ }
+
+ $( 'ws' ).setAttribute('value', xul_param('ws'));
+ $( 'ses' ).setAttribute('value', xul_param('ses'));
+ $( 'seskey' ).setAttribute('value', xul_param('seskey'));
+ $( 'delta' ).setAttribute('value', xul_param('delta'));
+
+ $( 'form' ).setAttribute('action', xulG.url_prefix(urls.XUL_OFFLINE_MANAGE_XACTS_CGI));
+
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.click('submit');
+ }, 0
+ );
+
+ } catch(E) {
+ var err_msg = "!! This software has encountered an error. Please tell your friendly " +
+ "system administrator or software developer the following:\nmain/upload_xacts.xhtml\n" + E + '\n';
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
+ alert(err_msg);
+ }
}
if (typeof cat == 'undefined') cat = {};
cat.copy_browser = function (params) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.error'); this.error = new util.error();
- } catch(E) {
- dump('cat.copy_browser: ' + E + '\n');
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.error'); this.error = new util.error();
+ } catch(E) {
+ dump('cat.copy_browser: ' + E + '\n');
+ }
}
cat.copy_browser.prototype = {
- 'map_tree' : {},
- 'map_acn' : {},
- 'map_acp' : {},
- 'sel_list' : [],
+ 'map_tree' : {},
+ 'map_acn' : {},
+ 'map_acp' : {},
+ 'sel_list' : [],
'funcs' : [],
- 'init' : function( params ) {
-
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
-
- obj.docid = params.docid;
-
- JSAN.use('util.network'); obj.network = new util.network();
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
- 'sel_clip' : [
- ['command'],
- function() { obj.list.clipboard(); }
- ],
- 'cmd_broken' : [
- ['command'],
- function() {
- alert(document.getElementById('commonStrings').getString('common.unimplemented'));
- }
- ],
- 'cmd_show_my_libs' : [
- ['command'],
- function() {
- obj.show_my_libs();
- }
- ],
- 'cmd_show_all_libs' : [
- ['command'],
- function() {
- obj.show_all_libs();
- }
- ],
- 'cmd_show_libs_with_copies' : [
- ['command'],
- function() {
- obj.show_libs_with_copies();
- }
- ],
- 'cmd_clear' : [
- ['command'],
- function() {
- obj.map_tree = {};
- obj.list.clear();
- }
- ],
- 'sel_mark_items_damaged' : [
- ['command'],
- function() {
- JSAN.use('cat.util'); JSAN.use('util.functional');
-
- var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
-
- list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
-
- cat.util.mark_item_damaged( list );
-
- obj.refresh_list();
- }
- ],
- 'sel_mark_items_missing' : [
- ['command'],
- function() {
- JSAN.use('cat.util'); JSAN.use('util.functional');
-
- var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
-
- list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
-
- cat.util.mark_item_missing( list );
-
- obj.refresh_list();
- }
- ],
- 'sel_patron' : [
- ['command'],
- function() {
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acp';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return { 'copy_id' : o.split(/_/)[1] };
- }
- );
-
- JSAN.use('circ.util');
- circ.util.show_last_few_circs(list);
- }
- ],
- 'sel_copy_details' : [
- ['command'],
- function() {
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acp';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return o.split(/_/)[1];
- }
- );
-
- JSAN.use('circ.util');
- for (var i = 0; i < list.length; i++) {
- circ.util.show_copy_details( list[i] );
- }
- }
- ],
- 'cmd_add_items' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
- var list = util.functional.map_list(
- util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acn';
- }
- ),
- function (o) {
- return o.split(/_/)[1];
- }
- );
- if (list.length == 0) return;
-
- var copy_shortcut = {};
- list = util.functional.map_list(
- list,
- function (o) {
- var ou_id = obj.map_acn['acn_' + o].owning_lib();
- var volume_id = o;
- var label = obj.map_acn['acn_' + o].label();
- if (!copy_shortcut[ou_id]) copy_shortcut[ou_id] = {};
- copy_shortcut[ou_id][ label ] = volume_id;
-
- return ou_id;
- }
- );
- /* quick fix */ /* what was this fixing? */
- list = []; for (var i in copy_shortcut) { list.push( i ); }
-
- var edit = 0;
- try {
- edit = obj.network.request(
- api.PERM_MULTI_ORG_CHECK.app,
- api.PERM_MULTI_ORG_CHECK.method,
- [
- ses(),
- obj.data.list.au[0].id(),
- list,
- [ 'CREATE_COPY' ]
- ]
- ).length == 0 ? 1 : 0;
- } catch(E) {
- obj.error.sdump('D_ERROR','batch permission check: ' + E);
- }
-
- if (edit==0) return; // no read-only view for this interface
-
- var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.title');
-
- JSAN.use('util.window'); var win = new util.window();
- var w = win.open(
- window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
- //+'?doc_id=' + window.escape(obj.docid)
- //+'&ou_ids=' + window.escape( js2JSON(list) )
- //+'©_shortcut=' + window.escape( js2JSON(copy_shortcut) ),
- title,
- 'chrome,resizable'
- );
- w.refresh = function() { obj.refresh_list(); }
- w.xulG = { 'doc_id':obj.docid, 'ou_ids' : list, 'copy_shortcut' : copy_shortcut };
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.error'),E);
- }
- }
- ],
- 'cmd_add_items_to_buckets' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acp';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return o.split(/_/)[1];
- }
- );
-
- JSAN.use('cat.util');
- cat.util.add_copies_to_bucket( list );
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_items_bucket.error'),E);
- }
- }
- ],
- 'cmd_replace_barcode' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acp';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return obj.map_acp[ o ].barcode();
- }
- );
-
- JSAN.use('cat.util');
- for (var i = 0; i < list.length; i++) {
- try {
- cat.util.replace_barcode(list[i]);
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.replace_barcode.failed', [list[i]]),E);
- }
- }
- obj.refresh_list();
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.replace_barcode.error'),E);
- obj.refresh_list();
- }
- }
- ],
- 'cmd_edit_items' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acp';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return o.split(/_/)[1];
- }
- );
-
- JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
- obj.refresh_list();
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
- }
- }
- ],
- 'cmd_delete_items' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acp';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return JSON2js( js2JSON( obj.map_acp[ 'acp_' + o.split(/_/)[1] ] ) );
- }
- );
-
- var delete_msg;
- if (list.length != 1) {
- delete_msg = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_items.confirm.plural', [list.length]);
- } else {
- delete_msg = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.confirm');
- }
- var r = obj.error.yns_alert(
- delete_msg,
- document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.title'),
- document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.delete'),
- document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.cancel'),
- null,
- document.getElementById('commonStrings').getString('common.confirm')
- );
-
- if (r == 0) {
- var acn_hash = {}; var acn_list = [];
- for (var i = 0; i < list.length; i++) {
- list[i].isdeleted('1');
- var acn_id = list[i].call_number();
- if ( ! acn_hash[ acn_id ] ) {
- acn_hash[ acn_id ] = obj.map_acn[ 'acn_' + acn_id ];
- acn_hash[ acn_id ].copies( [] );
- }
- var temp = acn_hash[ acn_id ].copies();
- temp.push( list[i] );
- acn_hash[ acn_id ].copies( temp );
- }
- for (var i in acn_hash) acn_list.push( acn_hash[i] );
- var robj = obj.network.simple_request(
- 'FM_ACN_TREE_UPDATE',
- [ ses(), acn_list, true ],
- null,
- {
- 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.override'),
- 'overridable_events' : [
- 1208 /* TITLE_LAST_COPY */,
- 1227 /* COPY_DELETE_WARNING */,
- ]
- }
- );
- if (robj == null) throw(robj);
- if (typeof robj.ilsevent != 'undefined') {
- if ( (robj.ilsevent != 0) && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */) && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */) ) throw(robj);
- }
- obj.refresh_list();
- }
-
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.error'),E);
- obj.refresh_list();
- }
- }
- ],
- 'cmd_print_spine_labels' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acp';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return obj.map_acp[ o ];
- }
- );
-
- obj.data.temp_barcodes_for_labels = util.functional.map_list( list, function(o){return o.barcode();}) ;
- obj.data.stash('temp_barcodes_for_labels');
- xulG.new_tab(
- xulG.url_prefix( urls.XUL_SPINE_LABEL ),
- { 'tab_name' : document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.tab') },
- {}
- );
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.error'),E);
- }
- }
- ],
- 'cmd_add_volumes' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'aou';
- }
- );
- list = util.functional.map_list(
- list,
- function (o) {
- return o.split(/_/)[1];
- }
- );
- var edit = 0;
- try {
- edit = obj.network.request(
- api.PERM_MULTI_ORG_CHECK.app,
- api.PERM_MULTI_ORG_CHECK.method,
- [
- ses(),
- obj.data.list.au[0].id(),
- list,
- [ 'CREATE_VOLUME', 'CREATE_COPY' ]
- ]
- ).length == 0 ? 1 : 0;
- } catch(E) {
- obj.error.sdump('D_ERROR','batch permission check: ' + E);
- }
-
- if (edit==0) {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.permission_error'));
- return; // no read-only view for this interface
- }
-
- var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.title');
-
- JSAN.use('util.window'); var win = new util.window();
- var w = win.open(
- window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
- //+'?doc_id=' + window.escape(obj.docid)
- //+'&ou_ids=' + window.escape( js2JSON(list) ),
- title,
- 'chrome,resizable'
- );
-
- w.refresh = function() { obj.refresh_list() };
- w.xulG = { 'doc_id' : obj.docid, 'ou_ids' : list };
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.error'),E);
- }
- }
- ],
- 'cmd_edit_volumes' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
- var list = util.functional.map_list(
- util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acn';
- }
- ),
- function (o) {
- return o.split(/_/)[1];
- }
- );
- if (list.length == 0) return;
-
- var edit = 0;
- try {
- edit = obj.network.request(
- api.PERM_MULTI_ORG_CHECK.app,
- api.PERM_MULTI_ORG_CHECK.method,
- [
- ses(),
- obj.data.list.au[0].id(),
- util.functional.map_list(
- list,
- function (o) {
- return obj.map_acn[ 'acn_' + o ].owning_lib();
- }
- ),
- [ 'UPDATE_VOLUME' ]
- ]
- ).length == 0 ? 1 : 0;
- } catch(E) {
- obj.error.sdump('D_ERROR','batch permission check: ' + E);
- }
-
- if (edit==0) {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.permission_error'));
- return; // no read-only view for this interface
- }
-
- list = util.functional.map_list(
- list,
- function (o) {
- var my_acn = obj.map_acn['acn_' + o];
- return function(r){return r;}(my_acn);
- }
- );
-
- var title;
- if (list.length == 1) {
- title = document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.title');
- } else {
- title = document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.title.plural');
- }
-
- JSAN.use('util.window'); var win = new util.window();
- //obj.data.volumes_temp = js2JSON( list );
- //obj.data.stash('volumes_temp');
- var my_xulG = win.open(
- window.xulG.url_prefix(urls.XUL_VOLUME_EDITOR),
- title,
- 'chrome,modal,resizable',
- { 'volumes' : JSON2js(js2JSON(list)) }
- );
-
- /* FIXME -- need to unique the temp space, and not rely on modalness of window */
- //obj.data.stash_retrieve();
+ 'init' : function( params ) {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var obj = this;
+
+ obj.docid = params.docid;
+
+ JSAN.use('util.network'); obj.network = new util.network();
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
+ 'sel_clip' : [
+ ['command'],
+ function() { obj.list.clipboard(); }
+ ],
+ 'cmd_broken' : [
+ ['command'],
+ function() {
+ alert(document.getElementById('commonStrings').getString('common.unimplemented'));
+ }
+ ],
+ 'cmd_show_my_libs' : [
+ ['command'],
+ function() {
+ obj.show_my_libs();
+ }
+ ],
+ 'cmd_show_all_libs' : [
+ ['command'],
+ function() {
+ obj.show_all_libs();
+ }
+ ],
+ 'cmd_show_libs_with_copies' : [
+ ['command'],
+ function() {
+ obj.show_libs_with_copies();
+ }
+ ],
+ 'cmd_clear' : [
+ ['command'],
+ function() {
+ obj.map_tree = {};
+ obj.list.clear();
+ }
+ ],
+ 'sel_mark_items_damaged' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+
+ var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
+
+ list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
+
+ cat.util.mark_item_damaged( list );
+
+ obj.refresh_list();
+ }
+ ],
+ 'sel_mark_items_missing' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+
+ var list = util.functional.filter_list( obj.sel_list, function (o) { return o.split(/_/)[0] == 'acp'; });
+
+ list = util.functional.map_list( list, function (o) { return o.split(/_/)[1]; });
+
+ cat.util.mark_item_missing( list );
+
+ obj.refresh_list();
+ }
+ ],
+ 'sel_patron' : [
+ ['command'],
+ function() {
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acp';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return { 'copy_id' : o.split(/_/)[1] };
+ }
+ );
+
+ JSAN.use('circ.util');
+ circ.util.show_last_few_circs(list);
+ }
+ ],
+ 'sel_copy_details' : [
+ ['command'],
+ function() {
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acp';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+
+ JSAN.use('circ.util');
+ for (var i = 0; i < list.length; i++) {
+ circ.util.show_copy_details( list[i] );
+ }
+ }
+ ],
+ 'cmd_add_items' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var list = util.functional.map_list(
+ util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acn';
+ }
+ ),
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+ if (list.length == 0) return;
+
+ var copy_shortcut = {};
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ var ou_id = obj.map_acn['acn_' + o].owning_lib();
+ var volume_id = o;
+ var label = obj.map_acn['acn_' + o].label();
+ if (!copy_shortcut[ou_id]) copy_shortcut[ou_id] = {};
+ copy_shortcut[ou_id][ label ] = volume_id;
+
+ return ou_id;
+ }
+ );
+ /* quick fix */ /* what was this fixing? */
+ list = []; for (var i in copy_shortcut) { list.push( i ); }
+
+ var edit = 0;
+ try {
+ edit = obj.network.request(
+ api.PERM_MULTI_ORG_CHECK.app,
+ api.PERM_MULTI_ORG_CHECK.method,
+ [
+ ses(),
+ obj.data.list.au[0].id(),
+ list,
+ [ 'CREATE_COPY' ]
+ ]
+ ).length == 0 ? 1 : 0;
+ } catch(E) {
+ obj.error.sdump('D_ERROR','batch permission check: ' + E);
+ }
+
+ if (edit==0) return; // no read-only view for this interface
+
+ var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.title');
+
+ JSAN.use('util.window'); var win = new util.window();
+ var w = win.open(
+ window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
+ //+'?doc_id=' + window.escape(obj.docid)
+ //+'&ou_ids=' + window.escape( js2JSON(list) )
+ //+'©_shortcut=' + window.escape( js2JSON(copy_shortcut) ),
+ title,
+ 'chrome,resizable'
+ );
+ w.refresh = function() { obj.refresh_list(); }
+ w.xulG = { 'doc_id':obj.docid, 'ou_ids' : list, 'copy_shortcut' : copy_shortcut };
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_item.error'),E);
+ }
+ }
+ ],
+ 'cmd_add_items_to_buckets' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acp';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+
+ JSAN.use('cat.util');
+ cat.util.add_copies_to_bucket( list );
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_items_bucket.error'),E);
+ }
+ }
+ ],
+ 'cmd_replace_barcode' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acp';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return obj.map_acp[ o ].barcode();
+ }
+ );
+
+ JSAN.use('cat.util');
+ for (var i = 0; i < list.length; i++) {
+ try {
+ cat.util.replace_barcode(list[i]);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.replace_barcode.failed', [list[i]]),E);
+ }
+ }
+ obj.refresh_list();
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.replace_barcode.error'),E);
+ obj.refresh_list();
+ }
+ }
+ ],
+ 'cmd_edit_items' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acp';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+
+ JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
+ obj.refresh_list();
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_items.error'),E);
+ }
+ }
+ ],
+ 'cmd_delete_items' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acp';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return JSON2js( js2JSON( obj.map_acp[ 'acp_' + o.split(/_/)[1] ] ) );
+ }
+ );
+
+ var delete_msg;
+ if (list.length != 1) {
+ delete_msg = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_items.confirm.plural', [list.length]);
+ } else {
+ delete_msg = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.confirm');
+ }
+ var r = obj.error.yns_alert(
+ delete_msg,
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.title'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.delete'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.cancel'),
+ null,
+ document.getElementById('commonStrings').getString('common.confirm')
+ );
+
+ if (r == 0) {
+ var acn_hash = {}; var acn_list = [];
+ for (var i = 0; i < list.length; i++) {
+ list[i].isdeleted('1');
+ var acn_id = list[i].call_number();
+ if ( ! acn_hash[ acn_id ] ) {
+ acn_hash[ acn_id ] = obj.map_acn[ 'acn_' + acn_id ];
+ acn_hash[ acn_id ].copies( [] );
+ }
+ var temp = acn_hash[ acn_id ].copies();
+ temp.push( list[i] );
+ acn_hash[ acn_id ].copies( temp );
+ }
+ for (var i in acn_hash) acn_list.push( acn_hash[i] );
+ var robj = obj.network.simple_request(
+ 'FM_ACN_TREE_UPDATE',
+ [ ses(), acn_list, true ],
+ null,
+ {
+ 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.override'),
+ 'overridable_events' : [
+ 1208 /* TITLE_LAST_COPY */,
+ 1227 /* COPY_DELETE_WARNING */,
+ ]
+ }
+ );
+ if (robj == null) throw(robj);
+ if (typeof robj.ilsevent != 'undefined') {
+ if ( (robj.ilsevent != 0) && (robj.ilsevent != 1227 /* COPY_DELETE_WARNING */) && (robj.ilsevent != 1208 /* TITLE_LAST_COPY */) ) throw(robj);
+ }
+ obj.refresh_list();
+ }
+
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_items.error'),E);
+ obj.refresh_list();
+ }
+ }
+ ],
+ 'cmd_print_spine_labels' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acp';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return obj.map_acp[ o ];
+ }
+ );
+
+ obj.data.temp_barcodes_for_labels = util.functional.map_list( list, function(o){return o.barcode();}) ;
+ obj.data.stash('temp_barcodes_for_labels');
+ xulG.new_tab(
+ xulG.url_prefix( urls.XUL_SPINE_LABEL ),
+ { 'tab_name' : document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.tab') },
+ {}
+ );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.print_spine.error'),E);
+ }
+ }
+ ],
+ 'cmd_add_volumes' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'aou';
+ }
+ );
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+ var edit = 0;
+ try {
+ edit = obj.network.request(
+ api.PERM_MULTI_ORG_CHECK.app,
+ api.PERM_MULTI_ORG_CHECK.method,
+ [
+ ses(),
+ obj.data.list.au[0].id(),
+ list,
+ [ 'CREATE_VOLUME', 'CREATE_COPY' ]
+ ]
+ ).length == 0 ? 1 : 0;
+ } catch(E) {
+ obj.error.sdump('D_ERROR','batch permission check: ' + E);
+ }
+
+ if (edit==0) {
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.permission_error'));
+ return; // no read-only view for this interface
+ }
+
+ var title = document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.title');
+
+ JSAN.use('util.window'); var win = new util.window();
+ var w = win.open(
+ window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
+ //+'?doc_id=' + window.escape(obj.docid)
+ //+'&ou_ids=' + window.escape( js2JSON(list) ),
+ title,
+ 'chrome,resizable'
+ );
+
+ w.refresh = function() { obj.refresh_list() };
+ w.xulG = { 'doc_id' : obj.docid, 'ou_ids' : list };
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.add_volume.error'),E);
+ }
+ }
+ ],
+ 'cmd_edit_volumes' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var list = util.functional.map_list(
+ util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acn';
+ }
+ ),
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+ if (list.length == 0) return;
+
+ var edit = 0;
+ try {
+ edit = obj.network.request(
+ api.PERM_MULTI_ORG_CHECK.app,
+ api.PERM_MULTI_ORG_CHECK.method,
+ [
+ ses(),
+ obj.data.list.au[0].id(),
+ util.functional.map_list(
+ list,
+ function (o) {
+ return obj.map_acn[ 'acn_' + o ].owning_lib();
+ }
+ ),
+ [ 'UPDATE_VOLUME' ]
+ ]
+ ).length == 0 ? 1 : 0;
+ } catch(E) {
+ obj.error.sdump('D_ERROR','batch permission check: ' + E);
+ }
+
+ if (edit==0) {
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.permission_error'));
+ return; // no read-only view for this interface
+ }
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ var my_acn = obj.map_acn['acn_' + o];
+ return function(r){return r;}(my_acn);
+ }
+ );
+
+ var title;
+ if (list.length == 1) {
+ title = document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.title');
+ } else {
+ title = document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.title.plural');
+ }
+
+ JSAN.use('util.window'); var win = new util.window();
+ //obj.data.volumes_temp = js2JSON( list );
+ //obj.data.stash('volumes_temp');
+ var my_xulG = win.open(
+ window.xulG.url_prefix(urls.XUL_VOLUME_EDITOR),
+ title,
+ 'chrome,modal,resizable',
+ { 'volumes' : JSON2js(js2JSON(list)) }
+ );
+
+ /* FIXME -- need to unique the temp space, and not rely on modalness of window */
+ //obj.data.stash_retrieve();
if (typeof my_xulG.update_these_volumes == 'undefined') { return; }
- var volumes = my_xulG.volumes;
- if (!volumes) return;
-
- volumes = util.functional.filter_list(
- volumes,
- function (o) {
- return o.ischanged() == '1';
- }
- );
-
- volumes = util.functional.map_list(
- volumes,
- function (o) {
- o.record( obj.docid ); // staff client 2 did not do this. Does it matter?
- return o;
- }
- );
-
- if (volumes.length == 0) return;
-
- try {
- var r = obj.network.request(
- api.FM_ACN_TREE_UPDATE.app,
- api.FM_ACN_TREE_UPDATE.method,
- [ ses(), volumes, true ]
- );
- if (typeof r.ilsevent != 'undefined') {
+ var volumes = my_xulG.volumes;
+ if (!volumes) return;
+
+ volumes = util.functional.filter_list(
+ volumes,
+ function (o) {
+ return o.ischanged() == '1';
+ }
+ );
+
+ volumes = util.functional.map_list(
+ volumes,
+ function (o) {
+ o.record( obj.docid ); // staff client 2 did not do this. Does it matter?
+ return o;
+ }
+ );
+
+ if (volumes.length == 0) return;
+
+ try {
+ var r = obj.network.request(
+ api.FM_ACN_TREE_UPDATE.app,
+ api.FM_ACN_TREE_UPDATE.method,
+ [ ses(), volumes, true ]
+ );
+ if (typeof r.ilsevent != 'undefined') {
switch(Number(r.ilsevent)) {
case 1705 /* VOLUME_LABEL_EXISTS */ :
alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.failed'));
default: throw(r);
}
} else {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.success'));
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.success'));
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.error'),E);
+ }
+ obj.refresh_list();
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.exception'),E);
+ }
+ }
+ ],
+ 'cmd_delete_volumes' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acn';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return JSON2js( js2JSON( obj.map_acn[ 'acn_' + o.split(/_/)[1] ] ) );
+ }
+ );
+
+ var del_prompt;
+ if (list.length == 1) {
+ del_prompt = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.prompt');
+ } else {
+ del_prompt = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_volume.prompt.plural', [list.length]);
+ }
+
+ var r = obj.error.yns_alert(
+ del_prompt,
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.title'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.delete'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.cancel'),
+ null,
+ document.getElementById('commonStrings').getString('common.confirm')
+ );
+
+ if (r == 0) {
+ for (var i = 0; i < list.length; i++) {
+ list[i].isdeleted('1');
+ }
+ var robj = obj.network.simple_request(
+ 'FM_ACN_TREE_UPDATE',
+ [ ses(), list, true ],
+ null,
+ {
+ 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
+ 'overridable_events' : [
+ ]
+ }
+ );
+ if (robj == null) throw(robj);
+ if (typeof robj.ilsevent != 'undefined') {
+ if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain'));
+ return;
+ }
+ if (robj.ilsevent != 0) throw(robj);
+ }
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.success'));
+ obj.refresh_list();
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.exception'),E);
+ obj.refresh_list();
+ }
+
+ }
+ ],
+ 'cmd_mark_library' : [
+ ['command'],
+ function() {
+ try {
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'aou';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+
+ if (list.length == 1) {
+ obj.data.marked_library = { 'lib' : list[0], 'docid' : obj.docid };
+ obj.data.stash('marked_library');
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.alert'));
+ } else {
+ obj.error.yns_alert(
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.prompt'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.title'),
+ document.getElementById('commonStrings').getString('common.ok'),
+ null,
+ null,
+ document.getElementById('commonStrings').getString('common.confirm')
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('copy browser -> mark library',E);
+ }
+ }
+ ],
+
+ 'cmd_mark_volume' : [
+ ['command'],
+ function() {
+ try {
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acn';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+
+ if (list.length == 1) {
+ obj.data.marked_volume = list[0];
+ obj.data.stash('marked_volume');
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.alert'));
+ } else {
+ obj.error.yns_alert(
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.prompt'),
+ document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.title'),
+ document.getElementById('commonStrings').getString('common.ok'),
+ null,
+ null,
+ document.getElementById('commonStrings').getString('common.confirm')
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('copy browser -> mark volume',E);
+ }
+ }
+ ],
+ 'cmd_refresh_list' : [
+ ['command'],
+ function() {
+ obj.refresh_list();
+ }
+ ],
+ 'cmd_transfer_volume' : [
+ ['command'],
+ function() {
+ try {
+ obj.data.stash_retrieve();
+ if (!obj.data.marked_library) {
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_volume.alert'));
+ return;
+ }
+
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acn';
}
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.error'),E);
- }
- obj.refresh_list();
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.edit_volume.exception'),E);
- }
- }
- ],
- 'cmd_delete_volumes' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acn';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return JSON2js( js2JSON( obj.map_acn[ 'acn_' + o.split(/_/)[1] ] ) );
- }
- );
-
- var del_prompt;
- if (list.length == 1) {
- del_prompt = document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.prompt');
- } else {
- del_prompt = document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.delete_volume.prompt.plural', [list.length]);
- }
-
- var r = obj.error.yns_alert(
- del_prompt,
- document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.title'),
- document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.delete'),
- document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.cancel'),
- null,
- document.getElementById('commonStrings').getString('common.confirm')
- );
-
- if (r == 0) {
- for (var i = 0; i < list.length; i++) {
- list[i].isdeleted('1');
- }
- var robj = obj.network.simple_request(
- 'FM_ACN_TREE_UPDATE',
- [ ses(), list, true ],
- null,
- {
- 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.override'),
- 'overridable_events' : [
- ]
- }
- );
- if (robj == null) throw(robj);
- if (typeof robj.ilsevent != 'undefined') {
- if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.copies_remain'));
- return;
- }
- if (robj.ilsevent != 0) throw(robj);
- }
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.success'));
- obj.refresh_list();
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.delete_volume.exception'),E);
- obj.refresh_list();
- }
-
- }
- ],
- 'cmd_mark_library' : [
- ['command'],
- function() {
- try {
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'aou';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return o.split(/_/)[1];
- }
- );
-
- if (list.length == 1) {
- obj.data.marked_library = { 'lib' : list[0], 'docid' : obj.docid };
- obj.data.stash('marked_library');
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.alert'));
- } else {
- obj.error.yns_alert(
- document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.prompt'),
- document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_library.title'),
- document.getElementById('commonStrings').getString('common.ok'),
- null,
- null,
- document.getElementById('commonStrings').getString('common.confirm')
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('copy browser -> mark library',E);
- }
- }
- ],
-
- 'cmd_mark_volume' : [
- ['command'],
- function() {
- try {
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acn';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return o.split(/_/)[1];
- }
- );
-
- if (list.length == 1) {
- obj.data.marked_volume = list[0];
- obj.data.stash('marked_volume');
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.alert'));
- } else {
- obj.error.yns_alert(
- document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.prompt'),
- document.getElementById('catStrings').getString('staff.cat.copy_browser.mark_volume.title'),
- document.getElementById('commonStrings').getString('common.ok'),
- null,
- null,
- document.getElementById('commonStrings').getString('common.confirm')
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('copy browser -> mark volume',E);
- }
- }
- ],
- 'cmd_refresh_list' : [
- ['command'],
- function() {
- obj.refresh_list();
- }
- ],
- 'cmd_transfer_volume' : [
- ['command'],
- function() {
- try {
- obj.data.stash_retrieve();
- if (!obj.data.marked_library) {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_volume.alert'));
- return;
- }
-
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acn';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return o.split(/_/)[1];
- }
- );
-
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
-
- var acn_list = util.functional.map_list(
- list,
- function (o) {
- return obj.map_acn[ 'acn_' + o ].label();
- }
- ).join(document.getElementById('commonStrings').getString('common.grouping_string'));
-
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
- xml += '<description>';
- xml += document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.transfer.prompt', [acn_list, obj.data.hash.aou[ obj.data.marked_library.lib ].shortname()]);
- xml += '</description>';
- xml += '<hbox><button label="' + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.submit.label') + '" name="fancy_submit"/>';
- xml += '<button label="'
- + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.label')
- + '" accesskey="'
- + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.accesskey')
- + '" name="fancy_cancel"/></hbox>';
- xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
- xml += '</vbox>';
- JSAN.use('OpenILS.data');
- var data = new OpenILS.data(); data.init({'via':'stash'});
- //data.temp_transfer = xml; data.stash('temp_transfer');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_transfer'
- //+ '&title=' + window.escape('Volume Transfer'),
- 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
- {
- 'xml' : xml,
- 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.title')
- }
- );
-
- if (fancy_prompt_data.fancy_status == 'incomplete') {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.incomplete'));
- return;
- }
-
- var robj = obj.network.simple_request(
- 'FM_ACN_TRANSFER',
- [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : list } ],
- null,
- {
- 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.override.failure'),
- 'overridable_events' : [
- 1208 /* TITLE_LAST_COPY */,
- 1219 /* COPY_REMOTE_CIRC_LIB */,
- ],
- }
- );
-
- if (typeof robj.ilsevent != 'undefined') {
- if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.ineligible_destination'));
- } else {
- throw(robj);
- }
- } else {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.success'));
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.unexpected_error'),E);
- }
- obj.refresh_list();
- }
- ],
-
- 'cmd_transfer_items' : [
- ['command'],
- function() {
- try {
- obj.data.stash_retrieve();
- if (!obj.data.marked_volume) {
- alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.missing_volume'));
- return;
- }
-
- JSAN.use('util.functional');
-
- var list = util.functional.filter_list(
- obj.sel_list,
- function (o) {
- return o.split(/_/)[0] == 'acp';
- }
- );
-
- list = util.functional.map_list(
- list,
- function (o) {
- return o.split(/_/)[1];
- }
- );
-
- var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
-
- JSAN.use('cat.util'); cat.util.transfer_copies( {
- 'copy_ids' : list,
- 'docid' : volume.record(),
- 'volume_label' : volume.label(),
- 'owning_lib' : volume.owning_lib(),
- } );
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.unexpected_error'),E);
- }
- obj.refresh_list();
- }
- ],
- }
- }
- );
-
- obj.list_init(params);
-
- obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
- if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+
+ var acn_list = util.functional.map_list(
+ list,
+ function (o) {
+ return obj.map_acn[ 'acn_' + o ].label();
+ }
+ ).join(document.getElementById('commonStrings').getString('common.grouping_string'));
+
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
+ xml += '<description>';
+ xml += document.getElementById('catStrings').getFormattedString('staff.cat.copy_browser.transfer.prompt', [acn_list, obj.data.hash.aou[ obj.data.marked_library.lib ].shortname()]);
+ xml += '</description>';
+ xml += '<hbox><button label="' + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.submit.label') + '" name="fancy_submit"/>';
+ xml += '<button label="'
+ + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.label')
+ + '" accesskey="'
+ + document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.cancel.accesskey')
+ + '" name="fancy_cancel"/></hbox>';
+ xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
+ xml += '</vbox>';
+ JSAN.use('OpenILS.data');
+ var data = new OpenILS.data(); data.init({'via':'stash'});
+ //data.temp_transfer = xml; data.stash('temp_transfer');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_transfer'
+ //+ '&title=' + window.escape('Volume Transfer'),
+ 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
+ {
+ 'xml' : xml,
+ 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.title')
+ }
+ );
+
+ if (fancy_prompt_data.fancy_status == 'incomplete') {
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.incomplete'));
+ return;
+ }
+
+ var robj = obj.network.simple_request(
+ 'FM_ACN_TRANSFER',
+ [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : list } ],
+ null,
+ {
+ 'title' : document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.override.failure'),
+ 'overridable_events' : [
+ 1208 /* TITLE_LAST_COPY */,
+ 1219 /* COPY_REMOTE_CIRC_LIB */,
+ ],
+ }
+ );
+
+ if (typeof robj.ilsevent != 'undefined') {
+ if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.ineligible_destination'));
+ } else {
+ throw(robj);
+ }
+ } else {
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.success'));
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer.unexpected_error'),E);
+ }
+ obj.refresh_list();
+ }
+ ],
+
+ 'cmd_transfer_items' : [
+ ['command'],
+ function() {
+ try {
+ obj.data.stash_retrieve();
+ if (!obj.data.marked_volume) {
+ alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.missing_volume'));
+ return;
+ }
+
+ JSAN.use('util.functional');
+
+ var list = util.functional.filter_list(
+ obj.sel_list,
+ function (o) {
+ return o.split(/_/)[0] == 'acp';
+ }
+ );
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.split(/_/)[1];
+ }
+ );
+
+ var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
+
+ JSAN.use('cat.util'); cat.util.transfer_copies( {
+ 'copy_ids' : list,
+ 'docid' : volume.record(),
+ 'volume_label' : volume.label(),
+ 'owning_lib' : volume.owning_lib(),
+ } );
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.transfer_items.unexpected_error'),E);
+ }
+ obj.refresh_list();
+ }
+ ],
+ }
+ }
+ );
+
+ obj.list_init(params);
+
+ obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
+ if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
JSAN.use('util.functional');
obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
- var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
- //obj.show_libs( org );
-
- //obj.show_my_libs();
-
- JSAN.use('util.file'); JSAN.use('util.widgets');
-
- var file; var list_data; var ml;
-
- file = new util.file('offline_ou_list');
- if (file._file.exists()) {
- list_data = file.get_object(); file.close();
- ml = util.widgets.make_menulist( list_data[0], list_data[1] );
- ml.setAttribute('id','lib_menu'); document.getElementById('x_lib_menu').appendChild(ml);
- for (var i = 0; i < obj.org_ids.length; i++) {
- ml.getElementsByAttribute('value',obj.org_ids[i])[0].setAttribute('class','has_copies');
- }
- ml.firstChild.addEventListener(
- 'popupshown',
- function(ev) {
- document.getElementById('legend').setAttribute('hidden','false');
- },
- false
- );
- ml.firstChild.addEventListener(
- 'popuphidden',
- function(ev) {
- document.getElementById('legend').setAttribute('hidden','true');
- },
- false
- );
- ml.addEventListener(
- 'command',
- function(ev) {
- //obj.show_my_libs(ev.target.value);
- //alert('lib picker, command caught - ml = ' + ml + '\nml.value = ' + ml.value + '\n');
- if (document.getElementById('refresh_button')) document.getElementById('refresh_button').focus();
- JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
- util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
- obj.refresh_list();
- },
- false
- );
- } else {
- throw(document.getElementById('catStrings').getString('staff.cat.copy_browser.missing_library') + '\n');
- }
-
- JSAN.use('util.widgets');
-
- file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
- util.widgets.load_attributes(file);
- ml.value = ml.getAttribute('value');
- if (! ml.value) {
- ml.value = org.id();
- ml.setAttribute('value',ml.value);
- }
-
- document.getElementById('show_acns').addEventListener(
- 'command',
- function(ev) {
- JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
- util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
- },
- false
- );
-
- document.getElementById('show_acps').addEventListener(
- 'command',
- function(ev) {
- JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
- util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
- },
- false
- );
-
- obj.show_my_libs( ml.value );
+ var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
+ //obj.show_libs( org );
+
+ //obj.show_my_libs();
+
+ JSAN.use('util.file'); JSAN.use('util.widgets');
+
+ var file; var list_data; var ml;
+
+ file = new util.file('offline_ou_list');
+ if (file._file.exists()) {
+ list_data = file.get_object(); file.close();
+ ml = util.widgets.make_menulist( list_data[0], list_data[1] );
+ ml.setAttribute('id','lib_menu'); document.getElementById('x_lib_menu').appendChild(ml);
+ for (var i = 0; i < obj.org_ids.length; i++) {
+ ml.getElementsByAttribute('value',obj.org_ids[i])[0].setAttribute('class','has_copies');
+ }
+ ml.firstChild.addEventListener(
+ 'popupshown',
+ function(ev) {
+ document.getElementById('legend').setAttribute('hidden','false');
+ },
+ false
+ );
+ ml.firstChild.addEventListener(
+ 'popuphidden',
+ function(ev) {
+ document.getElementById('legend').setAttribute('hidden','true');
+ },
+ false
+ );
+ ml.addEventListener(
+ 'command',
+ function(ev) {
+ //obj.show_my_libs(ev.target.value);
+ //alert('lib picker, command caught - ml = ' + ml + '\nml.value = ' + ml.value + '\n');
+ if (document.getElementById('refresh_button')) document.getElementById('refresh_button').focus();
+ JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
+ util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
+ obj.refresh_list();
+ },
+ false
+ );
+ } else {
+ throw(document.getElementById('catStrings').getString('staff.cat.copy_browser.missing_library') + '\n');
+ }
+
+ JSAN.use('util.widgets');
+
+ file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
+ util.widgets.load_attributes(file);
+ ml.value = ml.getAttribute('value');
+ if (! ml.value) {
+ ml.value = org.id();
+ ml.setAttribute('value',ml.value);
+ }
+
+ document.getElementById('show_acns').addEventListener(
+ 'command',
+ function(ev) {
+ JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
+ util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
+ },
+ false
+ );
+
+ document.getElementById('show_acps').addEventListener(
+ 'command',
+ function(ev) {
+ JSAN.use('util.file'); var file = new util.file('copy_browser_prefs.'+obj.data.server_unadorned);
+ util.widgets.save_attributes(file, { 'lib_menu' : [ 'value' ], 'show_acns' : [ 'checked' ], 'show_acps' : [ 'checked' ] });
+ },
+ false
+ );
+
+ obj.show_my_libs( ml.value );
JSAN.use('util.exec'); var exec = new util.exec(20); exec.timer(obj.funcs,100);
- obj.show_consortial_count();
-
- } catch(E) {
- this.error.standard_unexpected_error_alert('cat.copy_browser.init: ',E);
- }
- },
-
- 'show_consortial_count' : function() {
- var obj = this;
- try {
- obj.network.simple_request('FM_ACP_COUNT.authoritative',[ obj.data.tree.aou.id(), obj.docid ],function(req){
- try {
- var robj = req.getResultObject();
- var x = document.getElementById('consortial_total');
- if (x) x.setAttribute('value',robj[0].count);
- x = document.getElementById('consortial_available');
- if (x) x.setAttribute('value',robj[0].available);
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.consortial_copy_count.error'),E);
- }
- });
- } catch(E) {
- this.error.standard_unexpected_error_alert('cat.copy_browser.show_consortial_count: ',E);
- }
- },
-
- 'show_my_libs' : function(org) {
- var obj = this;
- try {
- if (!org) {
- org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
- } else {
- if (typeof org != 'object') org = obj.data.hash.aou[ org ];
- }
- obj.show_libs( org, false );
-
- var p_org = obj.data.hash.aou[ org.parent_ou() ];
- if (p_org) {
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
- document.getElementById('lib_menu').setAttribute('disabled','true');
- } );
- for (var i = 0; i < p_org.children().length; i++) {
- obj.funcs.push(
- function(o) {
- return function() {
- obj.show_libs( o, false );
- }
- }( p_org.children()[i] )
- );
- }
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
- document.getElementById('lib_menu').setAttribute('disabled','false');
- } );
- }
- } catch(E) {
- alert(E);
- }
- },
-
- 'show_all_libs' : function() {
- var obj = this;
- try {
- obj.show_my_libs();
-
- obj.show_libs( obj.data.tree.aou );
-
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
- document.getElementById('lib_menu').setAttribute('disabled','true');
- } );
-
- for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
- obj.funcs.push(
- function(o) {
- return function() {
- obj.show_libs( o );
- }
- }( obj.data.tree.aou.children()[i] )
- );
- }
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
- document.getElementById('lib_menu').setAttribute('disabled','false');
- } );
-
- } catch(E) {
- alert(E);
- }
- },
-
- 'show_libs_with_copies' : function() {
- var obj = this;
- try {
- JSAN.use('util.functional');
-
- var orgs = util.functional.map_list(
- obj.org_ids,
- function(id) { return obj.data.hash.aou[id]; }
- ).sort(
- function( a, b ) {
- if (a.shortname() < b.shortname()) return -1;
- if (a.shortname() > b.shortname()) return 1;
- return 0;
- }
- );
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
- document.getElementById('lib_menu').setAttribute('disabled','true');
- } );
-
- for (var i = 0; i < orgs.length; i++) {
- obj.funcs.push(
- function(o) {
- return function() {
- obj.show_libs(o,false);
- }
- }( orgs[i] )
- );
- }
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
- document.getElementById('lib_menu').setAttribute('disabled','false');
- } );
-
- } catch(E) {
- alert(E);
- }
- },
-
- 'show_libs' : function(start_aou,show_open) {
- var obj = this;
- try {
- if (!start_aou) throw('show_libs: Need a start_aou');
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
- JSAN.use('util.functional');
-
- var parents = [];
- var temp_aou = start_aou;
- while ( temp_aou.parent_ou() ) {
- temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
- parents.push( temp_aou );
- }
- parents.reverse();
-
- for (var i = 0; i < parents.length; i++) {
- obj.funcs.push(
- function(o,p) {
- return function() {
+ obj.show_consortial_count();
+
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('cat.copy_browser.init: ',E);
+ }
+ },
+
+ 'show_consortial_count' : function() {
+ var obj = this;
+ try {
+ obj.network.simple_request('FM_ACP_COUNT.authoritative',[ obj.data.tree.aou.id(), obj.docid ],function(req){
+ try {
+ var robj = req.getResultObject();
+ var x = document.getElementById('consortial_total');
+ if (x) x.setAttribute('value',robj[0].count);
+ x = document.getElementById('consortial_available');
+ if (x) x.setAttribute('value',robj[0].available);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.consortial_copy_count.error'),E);
+ }
+ });
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('cat.copy_browser.show_consortial_count: ',E);
+ }
+ },
+
+ 'show_my_libs' : function(org) {
+ var obj = this;
+ try {
+ if (!org) {
+ org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
+ } else {
+ if (typeof org != 'object') org = obj.data.hash.aou[ org ];
+ }
+ obj.show_libs( org, false );
+
+ var p_org = obj.data.hash.aou[ org.parent_ou() ];
+ if (p_org) {
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
+ document.getElementById('lib_menu').setAttribute('disabled','true');
+ } );
+ for (var i = 0; i < p_org.children().length; i++) {
+ obj.funcs.push(
+ function(o) {
+ return function() {
+ obj.show_libs( o, false );
+ }
+ }( p_org.children()[i] )
+ );
+ }
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
+ document.getElementById('lib_menu').setAttribute('disabled','false');
+ } );
+ }
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+ 'show_all_libs' : function() {
+ var obj = this;
+ try {
+ obj.show_my_libs();
+
+ obj.show_libs( obj.data.tree.aou );
+
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
+ document.getElementById('lib_menu').setAttribute('disabled','true');
+ } );
+
+ for (var i = 0; i < obj.data.tree.aou.children().length; i++) {
+ obj.funcs.push(
+ function(o) {
+ return function() {
+ obj.show_libs( o );
+ }
+ }( obj.data.tree.aou.children()[i] )
+ );
+ }
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
+ document.getElementById('lib_menu').setAttribute('disabled','false');
+ } );
+
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+ 'show_libs_with_copies' : function() {
+ var obj = this;
+ try {
+ JSAN.use('util.functional');
+
+ var orgs = util.functional.map_list(
+ obj.org_ids,
+ function(id) { return obj.data.hash.aou[id]; }
+ ).sort(
+ function( a, b ) {
+ if (a.shortname() < b.shortname()) return -1;
+ if (a.shortname() > b.shortname()) return 1;
+ return 0;
+ }
+ );
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
+ document.getElementById('lib_menu').setAttribute('disabled','true');
+ } );
+
+ for (var i = 0; i < orgs.length; i++) {
+ obj.funcs.push(
+ function(o) {
+ return function() {
+ obj.show_libs(o,false);
+ }
+ }( orgs[i] )
+ );
+ }
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
+ document.getElementById('lib_menu').setAttribute('disabled','false');
+ } );
+
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+ 'show_libs' : function(start_aou,show_open) {
+ var obj = this;
+ try {
+ if (!start_aou) throw('show_libs: Need a start_aou');
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+ JSAN.use('util.functional');
+
+ var parents = [];
+ var temp_aou = start_aou;
+ while ( temp_aou.parent_ou() ) {
+ temp_aou = obj.data.hash.aou[ temp_aou.parent_ou() ];
+ parents.push( temp_aou );
+ }
+ parents.reverse();
+
+ for (var i = 0; i < parents.length; i++) {
+ obj.funcs.push(
+ function(o,p) {
+ return function() {
obj.append_org(o,p,{'container':'true','open':'true'});
- };
- }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
- );
- }
-
- obj.funcs.push(
- function(o,p) {
- return function() { obj.append_org(o,p); };
- }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
- );
-
- obj.funcs.push(
- function() {
- if (start_aou.children()) {
- var x = obj.map_tree[ 'aou_' + start_aou.id() ];
- x.setAttribute('container','true');
- if (show_open) x.setAttribute('open','true');
- for (var i = 0; i < start_aou.children().length; i++) {
- obj.funcs.push(
- function(o,p) {
- return function() { obj.append_org(o,p); };
- }( start_aou.children()[i], start_aou )
- );
- }
- }
- }
- );
-
- } catch(E) {
- alert(E);
- }
- },
-
- 'on_select' : function(list,twisty) {
- var obj = this;
- for (var i = 0; i < list.length; i++) {
- var node = obj.map_tree[ list[i] ];
- //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
- var row_type = list[i].split('_')[0];
- var id = list[i].split('_')[1];
- switch(row_type) {
- case 'aou' : obj.on_select_org(id,twisty); break;
- case 'acn' : obj.on_select_acn(id,twisty); break;
- default: break;
- }
- }
- },
-
- 'on_select_acn' : function(acn_id,twisty) {
- var obj = this;
- try {
- var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
- document.getElementById('lib_menu').setAttribute('disabled','true');
- } );
- if (acn_tree.copies()) {
- for (var i = 0; i < acn_tree.copies().length; i++) {
- obj.funcs.push(
- function(c,a) {
- return function() {
- obj.append_acp(c,a);
- }
- }( acn_tree.copies()[i], acn_tree )
- )
- }
- }
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
- document.getElementById('lib_menu').setAttribute('disabled','false');
- } );
- } catch(E) {
- alert(E);
- }
- },
-
- 'on_select_org' : function(org_id,twisty) {
- var obj = this;
- var org = obj.data.hash.aou[ org_id ];
+ };
+ }(parents[i], obj.data.hash.aou[ parents[i].parent_ou() ])
+ );
+ }
+
+ obj.funcs.push(
+ function(o,p) {
+ return function() { obj.append_org(o,p); };
+ }(start_aou,obj.data.hash.aou[ start_aou.parent_ou() ])
+ );
+
+ obj.funcs.push(
+ function() {
+ if (start_aou.children()) {
+ var x = obj.map_tree[ 'aou_' + start_aou.id() ];
+ x.setAttribute('container','true');
+ if (show_open) x.setAttribute('open','true');
+ for (var i = 0; i < start_aou.children().length; i++) {
+ obj.funcs.push(
+ function(o,p) {
+ return function() { obj.append_org(o,p); };
+ }( start_aou.children()[i], start_aou )
+ );
+ }
+ }
+ }
+ );
+
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+ 'on_select' : function(list,twisty) {
+ var obj = this;
+ for (var i = 0; i < list.length; i++) {
+ var node = obj.map_tree[ list[i] ];
+ //if (node.lastChild.nodeName == 'treechildren') { continue; } else { alert(node.lastChild.nodeName); }
+ var row_type = list[i].split('_')[0];
+ var id = list[i].split('_')[1];
+ switch(row_type) {
+ case 'aou' : obj.on_select_org(id,twisty); break;
+ case 'acn' : obj.on_select_acn(id,twisty); break;
+ default: break;
+ }
+ }
+ },
+
+ 'on_select_acn' : function(acn_id,twisty) {
+ var obj = this;
+ try {
+ var acn_tree = obj.map_acp[ 'acn_' + acn_id ];
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
+ document.getElementById('lib_menu').setAttribute('disabled','true');
+ } );
+ if (acn_tree.copies()) {
+ for (var i = 0; i < acn_tree.copies().length; i++) {
+ obj.funcs.push(
+ function(c,a) {
+ return function() {
+ obj.append_acp(c,a);
+ }
+ }( acn_tree.copies()[i], acn_tree )
+ )
+ }
+ }
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
+ document.getElementById('lib_menu').setAttribute('disabled','false');
+ } );
+ } catch(E) {
+ alert(E);
+ }
+ },
+
+ 'on_select_org' : function(org_id,twisty) {
+ var obj = this;
+ var org = obj.data.hash.aou[ org_id ];
if (obj.data.hash.aout[ org.ou_type() ].depth() == 0 && ! get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) return;
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
- document.getElementById('lib_menu').setAttribute('disabled','true');
- } );
- if (org.children()) {
- for (var i = 0; i < org.children().length; i++) {
- obj.funcs.push(
- function(o,p) {
- return function() {
- obj.append_org(o,p)
- }
- }(org.children()[i],org)
- );
- }
- }
- if (obj.map_acn[ 'aou_' + org_id ]) {
- for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
- obj.funcs.push(
- function(o,a) {
- return function() {
- obj.append_acn(o,a);
- }
- }( org, obj.map_acn[ 'aou_' + org_id ][i] )
- );
- }
- }
- obj.funcs.push( function() {
- document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
- document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
- document.getElementById('lib_menu').setAttribute('disabled','false');
- } );
- },
-
- 'append_org' : function (org,parent_org,params) {
- var obj = this;
- try {
- if (obj.map_tree[ 'aou_' + org.id() ]) {
- var x = obj.map_tree[ 'aou_' + org.id() ];
- if (params) {
- for (var i in params) {
- x.setAttribute(i,params[i]);
- }
- }
- return x;
- }
-
- var data = {
- 'row' : {
- 'my' : {
- 'aou' : org,
- }
- },
- 'skip_all_columns_except' : [0,1,2],
- 'retrieve_id' : 'aou_' + org.id(),
- 'to_bottom' : true,
- 'no_auto_select' : true,
- };
-
- var acn_tree_list;
- if ( obj.org_ids.indexOf( Number( org.id() ) ) == -1 ) {
- if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
- data.row.my.volume_count = '0';
- data.row.my.copy_count = '<0>';
- } else {
- data.row.my.volume_count = '';
- data.row.my.copy_count = '';
- }
- } else {
- var v_count = 0; var c_count = 0;
- acn_tree_list = obj.network.simple_request(
- 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative',
- [ ses(), obj.docid, [ org.id() ] ]
- );
- for (var i = 0; i < acn_tree_list.length; i++) {
- v_count++;
- obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
- var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
- for (var j = 0; j < copies.length; j++) {
- obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
- }
- }
- data.row.my.volume_count = v_count;
- data.row.my.copy_count = '<' + c_count + '>';
- }
- if (parent_org) {
- data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
- }
- var nparams = obj.list.append(data);
- var node = nparams.my_node;
- if (params) {
- for (var i in params) {
- node.setAttribute(i,params[i]);
- }
- }
- obj.map_tree[ 'aou_' + org.id() ] = node;
-
- if (org.children()) {
- node.setAttribute('container','true');
- }
-
- if (parent_org) {
- if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
- data.node.setAttribute('open','true');
- }
- } else {
- obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
- }
-
- if (acn_tree_list) {
- obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
- node.setAttribute('container','true');
- }
-
- if (document.getElementById('show_acns').checked) {
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','true');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','true');
+ document.getElementById('lib_menu').setAttribute('disabled','true');
+ } );
+ if (org.children()) {
+ for (var i = 0; i < org.children().length; i++) {
+ obj.funcs.push(
+ function(o,p) {
+ return function() {
+ obj.append_org(o,p)
+ }
+ }(org.children()[i],org)
+ );
+ }
+ }
+ if (obj.map_acn[ 'aou_' + org_id ]) {
+ for (var i = 0; i < obj.map_acn[ 'aou_' + org_id ].length; i++) {
+ obj.funcs.push(
+ function(o,a) {
+ return function() {
+ obj.append_acn(o,a);
+ }
+ }( org, obj.map_acn[ 'aou_' + org_id ][i] )
+ );
+ }
+ }
+ obj.funcs.push( function() {
+ document.getElementById('cmd_refresh_list').setAttribute('disabled','false');
+ document.getElementById('cmd_show_libs_with_copies').setAttribute('disabled','false');
+ document.getElementById('lib_menu').setAttribute('disabled','false');
+ } );
+ },
+
+ 'append_org' : function (org,parent_org,params) {
+ var obj = this;
+ try {
+ if (obj.map_tree[ 'aou_' + org.id() ]) {
+ var x = obj.map_tree[ 'aou_' + org.id() ];
+ if (params) {
+ for (var i in params) {
+ x.setAttribute(i,params[i]);
+ }
+ }
+ return x;
+ }
+
+ var data = {
+ 'row' : {
+ 'my' : {
+ 'aou' : org,
+ }
+ },
+ 'skip_all_columns_except' : [0,1,2],
+ 'retrieve_id' : 'aou_' + org.id(),
+ 'to_bottom' : true,
+ 'no_auto_select' : true,
+ };
+
+ var acn_tree_list;
+ if ( obj.org_ids.indexOf( Number( org.id() ) ) == -1 ) {
+ if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
+ data.row.my.volume_count = '0';
+ data.row.my.copy_count = '<0>';
+ } else {
+ data.row.my.volume_count = '';
+ data.row.my.copy_count = '';
+ }
+ } else {
+ var v_count = 0; var c_count = 0;
+ acn_tree_list = obj.network.simple_request(
+ 'FM_ACN_TREE_LIST_RETRIEVE_VIA_RECORD_ID_AND_ORG_IDS.authoritative',
+ [ ses(), obj.docid, [ org.id() ] ]
+ );
+ for (var i = 0; i < acn_tree_list.length; i++) {
+ v_count++;
+ obj.map_acn[ 'acn_' + acn_tree_list[i].id() ] = function(r){return r;}(acn_tree_list[i]);
+ var copies = acn_tree_list[i].copies(); if (copies) c_count += copies.length;
+ for (var j = 0; j < copies.length; j++) {
+ obj.map_acp[ 'acp_' + copies[j].id() ] = function(r){return r;}(copies[j]);
+ }
+ }
+ data.row.my.volume_count = v_count;
+ data.row.my.copy_count = '<' + c_count + '>';
+ }
+ if (parent_org) {
+ data.node = obj.map_tree[ 'aou_' + parent_org.id() ];
+ }
+ var nparams = obj.list.append(data);
+ var node = nparams.my_node;
+ if (params) {
+ for (var i in params) {
+ node.setAttribute(i,params[i]);
+ }
+ }
+ obj.map_tree[ 'aou_' + org.id() ] = node;
+
+ if (org.children()) {
+ node.setAttribute('container','true');
+ }
+
+ if (parent_org) {
+ if ( obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].parent_ou() == parent_org.id() ) {
+ data.node.setAttribute('open','true');
+ }
+ } else {
+ obj.map_tree[ 'aou_' + org.id() ].setAttribute('open','true');
+ }
+
+ if (acn_tree_list) {
+ obj.map_acn[ 'aou_' + org.id() ] = acn_tree_list;
+ node.setAttribute('container','true');
+ }
+
+ if (document.getElementById('show_acns').checked) {
if (! ( obj.data.hash.aout[ org.ou_type() ].depth() == 0 && ! get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) )) {
- node.setAttribute('open','true');
- obj.funcs.push( function() { obj.on_select_org( org.id() ); } );
- }
- }
-
- } catch(E) {
- dump(E+'\n');
- alert(E);
- }
- },
-
- 'append_acn' : function( org, acn_tree, params ) {
- var obj = this;
- try {
- if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
- var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
- if (params) {
- for (var i in params) {
- x.setAttribute(i,params[i]);
- }
- }
- return x;
- }
-
- var parent_node = obj.map_tree[ 'aou_' + org.id() ];
- var data = {
- 'row' : {
- 'my' : {
- 'aou' : org,
- 'acn' : acn_tree,
- 'volume_count' : '',
- 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
- }
- },
- 'skip_all_columns_except' : [0,1,2],
- 'retrieve_id' : 'acn_' + acn_tree.id(),
- 'node' : parent_node,
- 'to_bottom' : true,
- 'no_auto_select' : true,
- };
- var nparams = obj.list.append(data);
- var node = nparams.my_node;
- obj.map_tree[ 'acn_' + acn_tree.id() ] = node;
- if (params) {
- for (var i in params) {
- node.setAttribute(i,params[i]);
- }
- }
- if (acn_tree.copies()) {
- obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
- node.setAttribute('container','true');
- }
- if (document.getElementById('show_acps').checked) {
- node.setAttribute('open','true');
- obj.funcs.push( function() { obj.on_select_acn( acn_tree.id() ); } );
- }
-
- } catch(E) {
- dump(E+'\n');
- alert(E);
- }
- },
-
- 'append_acp' : function( acp_item, acn_tree, params ) {
- var obj = this;
- try {
- if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
- var x = obj.map_tree[ 'acp_' + acp_item.id() ];
- if (params) {
- for (var i in params) {
- x.setAttribute(i,params[i]);
- }
- }
- return x;
- }
-
- var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
- var data = {
- 'row' : {
- 'my' : {
- 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
- 'acn' : acn_tree,
- 'acp' : acp_item,
- 'volume_count' : '',
- 'copy_count' : '',
- }
- },
- 'retrieve_id' : 'acp_' + acp_item.id(),
- 'node' : parent_node,
- 'to_bottom' : true,
- 'no_auto_select' : true,
- };
- var nparams = obj.list.append(data);
- var node = nparams.my_node;
- obj.map_tree[ 'acp_' + acp_item.id() ] = node;
- if (params) {
- for (var i in params) {
- node.setAttribute(i,params[i]);
- }
- }
-
- } catch(E) {
- dump(E+'\n');
- alert(E);
- }
- },
-
- 'list_init' : function( params ) {
-
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
-
- JSAN.use('circ.util');
- var columns = [
- {
- 'id' : 'tree_location',
- 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.tree_location'),
- 'flex' : 1, 'primary' : true, 'hidden' : false,
- 'render' : function(my) { return my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"; },
- },
- {
- 'id' : 'volume_count',
- 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.volume_count'),
- 'flex' : 0, 'primary' : false, 'hidden' : false,
- 'render' : function(my) { return my.volume_count; },
- },
- {
- 'id' : 'copy_count',
- 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.copy_count'),
- 'flex' : 0,
- 'primary' : false, 'hidden' : false,
- 'render' : function(my) { return my.copy_count; },
- },
- ].concat(
- circ.util.columns(
- {
- 'location' : { 'hidden' : false },
- 'circ_lib' : { 'hidden' : false },
- 'owning_lib' : { 'hidden' : false },
- 'call_number' : { 'hidden' : false },
- 'due_date' : { 'hidden' : false },
- 'status' : { 'hidden' : false },
- },
- {
- 'just_these' : [
- 'due_date',
- 'owning_lib',
- 'circ_lib',
- 'call_number',
- 'copy_number',
- 'location',
- 'barcode',
- 'loan_duration',
- 'fine_level',
- 'circulate',
- 'holdable',
- 'opac_visible',
- 'ref',
- 'deposit',
- 'deposit_amount',
- 'price',
- 'circ_as_type',
- 'circ_modifier',
- 'status',
- 'alert_message',
- 'acp_id',
- ]
- }
- )
- );
- JSAN.use('util.list'); obj.list = new util.list('copy_tree');
- obj.list.init(
- {
- 'no_auto_select' : true,
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(' '),
- 'retrieve_row' : function(params) {
-
- var row = params.row;
-
- /*
- if (!row.my.mvr) obj.funcs.push(
- function() {
-
- row.my.mvr = obj.network.request(
- api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
- api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
- [ row.my.circ.target_copy() ]
- );
-
- }
- );
- if (!row.my.acp) {
- obj.funcs.push(
- function() {
-
- row.my.acp = obj.network.request(
- api.FM_ACP_RETRIEVE.app,
- api.FM_ACP_RETRIEVE.method,
- [ row.my.circ.target_copy() ]
- );
-
- params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
-
- }
- );
- } else {
- params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
- }
- */
- obj.funcs.push(
- function() {
-
- if (typeof params.on_retrieve == 'function') {
- params.on_retrieve(row);
- }
-
- }
- );
-
- return row;
- },
- 'on_click' : function(ev) {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
- var row = {}; var col = {}; var nobj = {};
- obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
- if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
- var node = obj.list.node.contentView.getItemAtIndex(row.value);
- var list = [ node.getAttribute('retrieve_id') ];
- if (typeof obj.on_select == 'function') {
- obj.on_select(list,true);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
- window.xulG.on_select(list);
- }
- },
- 'on_select' : function(ev) {
- JSAN.use('util.functional');
- var sel = obj.list.retrieve_selection();
- obj.controller.view.sel_clip.disabled = sel.length < 1;
- obj.sel_list = util.functional.map_list(
- sel,
- function(o) { return o.getAttribute('retrieve_id'); }
- );
- obj.toggle_actions();
- if (typeof obj.on_select == 'function') {
- obj.on_select(obj.sel_list);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
- window.xulG.on_select(obj.sel_list);
- }
- },
- }
- );
-
- obj.controller.render();
-
- } catch(E) {
- this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
- alert(E);
- }
- },
-
- 'toggle_actions' : function() {
- var obj = this;
- try {
- var found_aou = false; var found_acn = false; var found_acp = false;
- var found_aou_with_can_have_vols = false;
- for (var i = 0; i < obj.sel_list.length; i++) {
- var type = obj.sel_list[i].split(/_/)[0];
- switch(type) {
- case 'aou' :
- found_aou = true;
- var org = obj.data.hash.aou[ obj.sel_list[i].split(/_/)[1] ];
- if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) found_aou_with_can_have_vols = true;
- break;
- case 'acn' : found_acn = true; break;
- case 'acp' : found_acp = true; break;
- }
- }
- obj.controller.view.cmd_add_items.setAttribute('disabled','true');
- obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
- obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
- obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
- obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
- obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
- obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
- obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
- obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
- obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
- obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
- obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
- obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
- obj.controller.view.sel_copy_details.setAttribute('disabled','true');
- obj.controller.view.sel_patron.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
- if (found_aou && found_aou_with_can_have_vols) {
- obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
- obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
- }
- if (found_acn) {
- obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
- obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
- obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
- obj.controller.view.cmd_add_items.setAttribute('disabled','false');
- obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
- }
- if (found_acp) {
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
- obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
- obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
- obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
- obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
- obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
- obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
- obj.controller.view.sel_copy_details.setAttribute('disabled','false');
- obj.controller.view.sel_patron.setAttribute('disabled','false');
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.actions.error'),E);
- }
- },
-
- 'refresh_list' : function() {
- try {
- var obj = this;
- obj.list.clear();
- obj.map_tree = {};
- obj.map_acn = {};
- obj.map_acp = {};
- obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
- if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
+ node.setAttribute('open','true');
+ obj.funcs.push( function() { obj.on_select_org( org.id() ); } );
+ }
+ }
+
+ } catch(E) {
+ dump(E+'\n');
+ alert(E);
+ }
+ },
+
+ 'append_acn' : function( org, acn_tree, params ) {
+ var obj = this;
+ try {
+ if (obj.map_tree[ 'acn_' + acn_tree.id() ]) {
+ var x = obj.map_tree[ 'acn_' + acn_tree.id() ];
+ if (params) {
+ for (var i in params) {
+ x.setAttribute(i,params[i]);
+ }
+ }
+ return x;
+ }
+
+ var parent_node = obj.map_tree[ 'aou_' + org.id() ];
+ var data = {
+ 'row' : {
+ 'my' : {
+ 'aou' : org,
+ 'acn' : acn_tree,
+ 'volume_count' : '',
+ 'copy_count' : acn_tree.copies() ? acn_tree.copies().length : '0',
+ }
+ },
+ 'skip_all_columns_except' : [0,1,2],
+ 'retrieve_id' : 'acn_' + acn_tree.id(),
+ 'node' : parent_node,
+ 'to_bottom' : true,
+ 'no_auto_select' : true,
+ };
+ var nparams = obj.list.append(data);
+ var node = nparams.my_node;
+ obj.map_tree[ 'acn_' + acn_tree.id() ] = node;
+ if (params) {
+ for (var i in params) {
+ node.setAttribute(i,params[i]);
+ }
+ }
+ if (acn_tree.copies()) {
+ obj.map_acp[ 'acn_' + acn_tree.id() ] = acn_tree;
+ node.setAttribute('container','true');
+ }
+ if (document.getElementById('show_acps').checked) {
+ node.setAttribute('open','true');
+ obj.funcs.push( function() { obj.on_select_acn( acn_tree.id() ); } );
+ }
+
+ } catch(E) {
+ dump(E+'\n');
+ alert(E);
+ }
+ },
+
+ 'append_acp' : function( acp_item, acn_tree, params ) {
+ var obj = this;
+ try {
+ if (obj.map_tree[ 'acp_' + acp_item.id() ]) {
+ var x = obj.map_tree[ 'acp_' + acp_item.id() ];
+ if (params) {
+ for (var i in params) {
+ x.setAttribute(i,params[i]);
+ }
+ }
+ return x;
+ }
+
+ var parent_node = obj.map_tree[ 'acn_' + acn_tree.id() ];
+ var data = {
+ 'row' : {
+ 'my' : {
+ 'aou' : obj.data.hash.aou[ acn_tree.owning_lib() ],
+ 'acn' : acn_tree,
+ 'acp' : acp_item,
+ 'volume_count' : '',
+ 'copy_count' : '',
+ }
+ },
+ 'retrieve_id' : 'acp_' + acp_item.id(),
+ 'node' : parent_node,
+ 'to_bottom' : true,
+ 'no_auto_select' : true,
+ };
+ var nparams = obj.list.append(data);
+ var node = nparams.my_node;
+ obj.map_tree[ 'acp_' + acp_item.id() ] = node;
+ if (params) {
+ for (var i in params) {
+ node.setAttribute(i,params[i]);
+ }
+ }
+
+ } catch(E) {
+ dump(E+'\n');
+ alert(E);
+ }
+ },
+
+ 'list_init' : function( params ) {
+
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ var obj = this;
+
+ JSAN.use('circ.util');
+ var columns = [
+ {
+ 'id' : 'tree_location',
+ 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.tree_location'),
+ 'flex' : 1, 'primary' : true, 'hidden' : false,
+ 'render' : function(my) { return my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"; },
+ },
+ {
+ 'id' : 'volume_count',
+ 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.volume_count'),
+ 'flex' : 0, 'primary' : false, 'hidden' : false,
+ 'render' : function(my) { return my.volume_count; },
+ },
+ {
+ 'id' : 'copy_count',
+ 'label' : document.getElementById('catStrings').getString('staff.cat.copy_browser.list_init.copy_count'),
+ 'flex' : 0,
+ 'primary' : false, 'hidden' : false,
+ 'render' : function(my) { return my.copy_count; },
+ },
+ ].concat(
+ circ.util.columns(
+ {
+ 'location' : { 'hidden' : false },
+ 'circ_lib' : { 'hidden' : false },
+ 'owning_lib' : { 'hidden' : false },
+ 'call_number' : { 'hidden' : false },
+ 'due_date' : { 'hidden' : false },
+ 'status' : { 'hidden' : false },
+ },
+ {
+ 'just_these' : [
+ 'due_date',
+ 'owning_lib',
+ 'circ_lib',
+ 'call_number',
+ 'copy_number',
+ 'location',
+ 'barcode',
+ 'loan_duration',
+ 'fine_level',
+ 'circulate',
+ 'holdable',
+ 'opac_visible',
+ 'ref',
+ 'deposit',
+ 'deposit_amount',
+ 'price',
+ 'circ_as_type',
+ 'circ_modifier',
+ 'status',
+ 'alert_message',
+ 'acp_id',
+ ]
+ }
+ )
+ );
+ JSAN.use('util.list'); obj.list = new util.list('copy_tree');
+ obj.list.init(
+ {
+ 'no_auto_select' : true,
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(' '),
+ 'retrieve_row' : function(params) {
+
+ var row = params.row;
+
+ /*
+ if (!row.my.mvr) obj.funcs.push(
+ function() {
+
+ row.my.mvr = obj.network.request(
+ api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.app,
+ api.MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.method,
+ [ row.my.circ.target_copy() ]
+ );
+
+ }
+ );
+ if (!row.my.acp) {
+ obj.funcs.push(
+ function() {
+
+ row.my.acp = obj.network.request(
+ api.FM_ACP_RETRIEVE.app,
+ api.FM_ACP_RETRIEVE.method,
+ [ row.my.circ.target_copy() ]
+ );
+
+ params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
+
+ }
+ );
+ } else {
+ params.row_node.setAttribute( 'retrieve_id',row.my.acp.barcode() );
+ }
+ */
+ obj.funcs.push(
+ function() {
+
+ if (typeof params.on_retrieve == 'function') {
+ params.on_retrieve(row);
+ }
+
+ }
+ );
+
+ return row;
+ },
+ 'on_click' : function(ev) {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserRead');
+ var row = {}; var col = {}; var nobj = {};
+ obj.list.node.treeBoxObject.getCellAt(ev.clientX,ev.clientY,row,col,nobj);
+ if ((row.value == -1)||(nobj.value != 'twisty')) { return; }
+ var node = obj.list.node.contentView.getItemAtIndex(row.value);
+ var list = [ node.getAttribute('retrieve_id') ];
+ if (typeof obj.on_select == 'function') {
+ obj.on_select(list,true);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
+ window.xulG.on_select(list);
+ }
+ },
+ 'on_select' : function(ev) {
+ JSAN.use('util.functional');
+ var sel = obj.list.retrieve_selection();
+ obj.controller.view.sel_clip.disabled = sel.length < 1;
+ obj.sel_list = util.functional.map_list(
+ sel,
+ function(o) { return o.getAttribute('retrieve_id'); }
+ );
+ obj.toggle_actions();
+ if (typeof obj.on_select == 'function') {
+ obj.on_select(obj.sel_list);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
+ window.xulG.on_select(obj.sel_list);
+ }
+ },
+ }
+ );
+
+ obj.controller.render();
+
+ } catch(E) {
+ this.error.sdump('D_ERROR','cat.copy_browser.list_init: ' + E + '\n');
+ alert(E);
+ }
+ },
+
+ 'toggle_actions' : function() {
+ var obj = this;
+ try {
+ var found_aou = false; var found_acn = false; var found_acp = false;
+ var found_aou_with_can_have_vols = false;
+ for (var i = 0; i < obj.sel_list.length; i++) {
+ var type = obj.sel_list[i].split(/_/)[0];
+ switch(type) {
+ case 'aou' :
+ found_aou = true;
+ var org = obj.data.hash.aou[ obj.sel_list[i].split(/_/)[1] ];
+ if ( get_bool( obj.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) found_aou_with_can_have_vols = true;
+ break;
+ case 'acn' : found_acn = true; break;
+ case 'acp' : found_acp = true; break;
+ }
+ }
+ obj.controller.view.cmd_add_items.setAttribute('disabled','true');
+ obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','true');
+ obj.controller.view.cmd_edit_items.setAttribute('disabled','true');
+ obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
+ obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
+ obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','true');
+ obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
+ obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
+ obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
+ obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
+ obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
+ obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
+ obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','true');
+ obj.controller.view.sel_patron.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
+ if (found_aou && found_aou_with_can_have_vols) {
+ obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
+ obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
+ }
+ if (found_acn) {
+ obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
+ obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
+ obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
+ obj.controller.view.cmd_add_items.setAttribute('disabled','false');
+ obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
+ }
+ if (found_acp) {
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
+ obj.controller.view.cmd_add_items_to_buckets.setAttribute('disabled','false');
+ obj.controller.view.cmd_edit_items.setAttribute('disabled','false');
+ obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
+ obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
+ obj.controller.view.cmd_print_spine_labels.setAttribute('disabled','false');
+ obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','false');
+ obj.controller.view.sel_patron.setAttribute('disabled','false');
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.actions.error'),E);
+ }
+ },
+
+ 'refresh_list' : function() {
+ try {
+ var obj = this;
+ obj.list.clear();
+ obj.map_tree = {};
+ obj.map_acn = {};
+ obj.map_acp = {};
+ obj.org_ids = obj.network.simple_request('FM_AOU_IDS_RETRIEVE_VIA_RECORD_ID.authoritative',[ obj.docid ]);
+ if (typeof obj.org_ids.ilsevent != 'undefined') throw(obj.org_ids);
JSAN.use('util.functional');
obj.org_ids = util.functional.map_list( obj.org_ids, function (o) { return Number(o); });
- /*
- var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
- obj.show_libs( org );
- */
- obj.show_my_libs( document.getElementById('lib_menu').value );
- // FIXME - we get a null from the copy_count call if we call it too quickly here
- setTimeout( function() { obj.show_consortial_count(); }, 2000 );
- } catch(E) {
- this.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.refresh_list.error'),E);
- }
- },
+ /*
+ var org = obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ];
+ obj.show_libs( org );
+ */
+ obj.show_my_libs( document.getElementById('lib_menu').value );
+ // FIXME - we get a null from the copy_count call if we call it too quickly here
+ setTimeout( function() { obj.show_consortial_count(); }, 2000 );
+ } catch(E) {
+ this.error.standard_unexpected_error_alert(document.getElementById('catStrings').getString('staff.cat.copy_browser.refresh_list.error'),E);
+ }
+ },
}
dump('exiting cat.copy_browser.js\n');
if (typeof cat == 'undefined') cat = {};
cat.copy_buckets = 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'});
+ 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'});
}
cat.copy_buckets.prototype = {
- 'selection_list1' : [],
- 'selection_list2' : [],
- 'bucket_id_name_map' : {},
+ 'selection_list1' : [],
+ 'selection_list2' : [],
+ 'bucket_id_name_map' : {},
'copy_hash' : {},
- 'render_pending_copies' : function() {
- var obj = this;
- obj.list1.clear();
- for (var i = 0; i < obj.copy_ids.length; i++) {
- var item = obj.prep_item_for_list( obj.copy_ids[i] );
- if (item) obj.list1.append( item );
- }
- },
+ 'render_pending_copies' : function() {
+ var obj = this;
+ obj.list1.clear();
+ for (var i = 0; i < obj.copy_ids.length; i++) {
+ var item = obj.prep_item_for_list( obj.copy_ids[i] );
+ if (item) obj.list1.append( item );
+ }
+ },
- 'init' : function( params ) {
+ 'init' : function( params ) {
- var obj = this;
+ var obj = this;
- obj.copy_ids = params['copy_ids'] || [];
+ obj.copy_ids = params['copy_ids'] || [];
- 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 },
- 'deleted' : { 'hidden' : false },
- }
- );
+ 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 },
+ 'deleted' : { 'hidden' : false },
+ }
+ );
- JSAN.use('util.list');
+ JSAN.use('util.list');
function retrieve_row(params) {
var row = params.row;
return row;
}
- obj.list1 = new util.list('pending_copies_list');
- obj.list1.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ obj.list1 = new util.list('pending_copies_list');
+ obj.list1.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
'retrieve_row' : retrieve_row,
- 'on_select' : function(ev) {
- try {
- JSAN.use('util.functional');
- var sel = obj.list1.retrieve_selection();
- obj.selection_list1 = util.functional.map_list(
- sel,
- function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
- );
- obj.error.sdump('D_TRACE','circ/copy_buckets: selection list 1 = ' + js2JSON(obj.selection_list1) );
- if (obj.selection_list1.length == 0) {
- obj.controller.view.copy_buckets_sel_add.disabled = true;
- } else {
- obj.controller.view.copy_buckets_sel_add.disabled = false;
- }
- } catch(E) {
- alert('FIXME: ' + E);
- }
- },
-
- }
- );
-
- obj.render_pending_copies();
-
- obj.list2 = new util.list('copies_in_bucket_list');
- obj.list2.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'on_select' : function(ev) {
+ try {
+ JSAN.use('util.functional');
+ var sel = obj.list1.retrieve_selection();
+ obj.selection_list1 = util.functional.map_list(
+ sel,
+ function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
+ );
+ obj.error.sdump('D_TRACE','circ/copy_buckets: selection list 1 = ' + js2JSON(obj.selection_list1) );
+ if (obj.selection_list1.length == 0) {
+ obj.controller.view.copy_buckets_sel_add.disabled = true;
+ } else {
+ obj.controller.view.copy_buckets_sel_add.disabled = false;
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ },
+
+ }
+ );
+
+ obj.render_pending_copies();
+
+ obj.list2 = new util.list('copies_in_bucket_list');
+ obj.list2.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
'retrieve_row' : retrieve_row,
- 'on_select' : function(ev) {
- try {
- JSAN.use('util.functional');
- var sel = obj.list2.retrieve_selection();
- obj.selection_list2 = util.functional.map_list(
- sel,
- function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
- );
- obj.error.sdump('D_TRACE','circ/copy_buckets: selection list 2 = ' + js2JSON(obj.selection_list2) );
- if (obj.selection_list2.length == 0) {
- obj.controller.view.copy_buckets_delete_item.disabled = true;
- obj.controller.view.copy_buckets_delete_item.setAttribute('disabled','true');
- obj.controller.view.copy_buckets_export.disabled = true;
- obj.controller.view.copy_buckets_export.setAttribute('disabled','true');
- } else {
- obj.controller.view.copy_buckets_delete_item.disabled = false;
- obj.controller.view.copy_buckets_delete_item.setAttribute('disabled','false');
- obj.controller.view.copy_buckets_export.disabled = false;
- obj.controller.view.copy_buckets_export.setAttribute('disabled','false');
- }
- } catch(E) {
- alert('FIXME: ' + E);
- }
- },
- }
- );
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
+ 'on_select' : function(ev) {
+ try {
+ JSAN.use('util.functional');
+ var sel = obj.list2.retrieve_selection();
+ obj.selection_list2 = util.functional.map_list(
+ sel,
+ function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
+ );
+ obj.error.sdump('D_TRACE','circ/copy_buckets: selection list 2 = ' + js2JSON(obj.selection_list2) );
+ if (obj.selection_list2.length == 0) {
+ obj.controller.view.copy_buckets_delete_item.disabled = true;
+ obj.controller.view.copy_buckets_delete_item.setAttribute('disabled','true');
+ obj.controller.view.copy_buckets_export.disabled = true;
+ obj.controller.view.copy_buckets_export.setAttribute('disabled','true');
+ } else {
+ obj.controller.view.copy_buckets_delete_item.disabled = false;
+ obj.controller.view.copy_buckets_delete_item.setAttribute('disabled','false');
+ obj.controller.view.copy_buckets_export.disabled = false;
+ obj.controller.view.copy_buckets_export.setAttribute('disabled','false');
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ },
+ }
+ );
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
'list_actions1' : [
['render'],
function(e) {
};
}
],
- 'copy_bucket_barcode_entry_textbox' : [
- ['keypress'],
- function(ev) {
- if (ev.keyCode && ev.keyCode == 13) {
- obj.scan_barcode();
- }
- }
- ],
+ 'copy_bucket_barcode_entry_textbox' : [
+ ['keypress'],
+ function(ev) {
+ if (ev.keyCode && ev.keyCode == 13) {
+ obj.scan_barcode();
+ }
+ }
+ ],
'cmd_copy_bucket_submit_barcode' : [
['command'],
function() {
obj.scan_barcode();
}
],
- 'copy_buckets_menulist_placeholder' : [
- ['render'],
- function(e) {
- return function() {
- JSAN.use('util.widgets'); JSAN.use('util.functional');
- var items = [
- [$('catStrings').getString('staff.cat.copy_buckets.menulist.render.choose_bucket'),''],
- [$('catStrings').getString('staff.cat.copy_buckets.menulist.render.retrieve_bucket'),-1]
- ].concat(
- util.functional.map_list(
- obj.network.simple_request(
- 'BUCKET_RETRIEVE_VIA_USER',
- [ ses(), obj.data.list.au[0].id() ]
- ).copy,
- function(o) {
- obj.bucket_id_name_map[ o.id() ] = o.name();
- return [ o.name(), o.id() ];
- }
- ).sort(
- function( a, b ) {
- if (a[0] < b[0]) return -1;
- if (a[0] > b[0]) return 1;
- return 0;
- }
- )
- );
- obj.error.sdump('D_TRACE','items = ' + js2JSON(items));
- util.widgets.remove_children( e );
- var ml = util.widgets.make_menulist(
- items
- );
- e.appendChild( ml );
- ml.setAttribute('id','bucket_menulist');
- ml.setAttribute('accesskey','');
-
- function change_bucket(ev) {
- var bucket_id = ev.target.value;
- if (bucket_id < 0 ) {
- bucket_id = window.prompt($('catStrings').getString('staff.cat.copy_buckets.menulist.change_bucket.prompt'));
- ev.target.value = bucket_id;
- ev.target.setAttribute('value',bucket_id);
- }
- if (!bucket_id) return;
- var bucket = obj.network.simple_request(
- 'BUCKET_FLESH',
- [ ses(), 'copy', bucket_id ]
- );
- if (typeof bucket.ilsevent != 'undefined') {
- if (bucket.ilsevent == 1506 /* CONTAINER_NOT_FOUND */) {
- alert($('catStrings').getFormattedString('staff.cat.copy_buckets.menulist.change_bucket.undefined', [bucket_id]));
- } else {
- obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.menulist.change_bucket.error'),bucket);
- }
- return;
- }
- try {
- var x = document.getElementById('info_box');
- x.setAttribute('hidden','false');
- x = document.getElementById('bucket_number');
- x.setAttribute('value',bucket.id());
- x = document.getElementById('bucket_name');
- x.setAttribute('value',bucket.name());
- x = document.getElementById('bucket_owner');
- var s = bucket.owner(); JSAN.use('patron.util');
- if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s);
- x.setAttribute('value',s.card().barcode() + " @ " + obj.data.hash.aou[ s.home_ou() ].shortname());
-
- } catch(E) {
- alert(E);
- }
- var items = bucket.items() || [];
- obj.list2.clear();
- for (var i = 0; i < items.length; i++) {
- var item = obj.prep_item_for_list(
- items[i].target_copy(),
- items[i].id()
- );
- if (item) obj.list2.append( item );
- }
- }
-
- ml.addEventListener( 'change_bucket', change_bucket , false);
- ml.addEventListener( 'command', function() {
- JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
- }, false);
- obj.controller.view.bucket_menulist = ml;
- JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
- document.getElementById('refresh').addEventListener( 'command', function() {
- JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
- }, false);
- };
- },
- ],
-
- 'copy_buckets_add' : [
- ['command'],
- function() {
+ 'copy_buckets_menulist_placeholder' : [
+ ['render'],
+ function(e) {
+ return function() {
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+ var items = [
+ [$('catStrings').getString('staff.cat.copy_buckets.menulist.render.choose_bucket'),''],
+ [$('catStrings').getString('staff.cat.copy_buckets.menulist.render.retrieve_bucket'),-1]
+ ].concat(
+ util.functional.map_list(
+ obj.network.simple_request(
+ 'BUCKET_RETRIEVE_VIA_USER',
+ [ ses(), obj.data.list.au[0].id() ]
+ ).copy,
+ function(o) {
+ obj.bucket_id_name_map[ o.id() ] = o.name();
+ return [ o.name(), o.id() ];
+ }
+ ).sort(
+ function( a, b ) {
+ if (a[0] < b[0]) return -1;
+ if (a[0] > b[0]) return 1;
+ return 0;
+ }
+ )
+ );
+ obj.error.sdump('D_TRACE','items = ' + js2JSON(items));
+ util.widgets.remove_children( e );
+ var ml = util.widgets.make_menulist(
+ items
+ );
+ e.appendChild( ml );
+ ml.setAttribute('id','bucket_menulist');
+ ml.setAttribute('accesskey','');
+
+ function change_bucket(ev) {
+ var bucket_id = ev.target.value;
+ if (bucket_id < 0 ) {
+ bucket_id = window.prompt($('catStrings').getString('staff.cat.copy_buckets.menulist.change_bucket.prompt'));
+ ev.target.value = bucket_id;
+ ev.target.setAttribute('value',bucket_id);
+ }
+ if (!bucket_id) return;
+ var bucket = obj.network.simple_request(
+ 'BUCKET_FLESH',
+ [ ses(), 'copy', bucket_id ]
+ );
+ if (typeof bucket.ilsevent != 'undefined') {
+ if (bucket.ilsevent == 1506 /* CONTAINER_NOT_FOUND */) {
+ alert($('catStrings').getFormattedString('staff.cat.copy_buckets.menulist.change_bucket.undefined', [bucket_id]));
+ } else {
+ obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.menulist.change_bucket.error'),bucket);
+ }
+ return;
+ }
+ try {
+ var x = document.getElementById('info_box');
+ x.setAttribute('hidden','false');
+ x = document.getElementById('bucket_number');
+ x.setAttribute('value',bucket.id());
+ x = document.getElementById('bucket_name');
+ x.setAttribute('value',bucket.name());
+ x = document.getElementById('bucket_owner');
+ var s = bucket.owner(); JSAN.use('patron.util');
+ if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s);
+ x.setAttribute('value',s.card().barcode() + " @ " + obj.data.hash.aou[ s.home_ou() ].shortname());
+
+ } catch(E) {
+ alert(E);
+ }
+ var items = bucket.items() || [];
+ obj.list2.clear();
+ for (var i = 0; i < items.length; i++) {
+ var item = obj.prep_item_for_list(
+ items[i].target_copy(),
+ items[i].id()
+ );
+ if (item) obj.list2.append( item );
+ }
+ }
+
+ ml.addEventListener( 'change_bucket', change_bucket , false);
+ ml.addEventListener( 'command', function() {
+ JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
+ }, false);
+ obj.controller.view.bucket_menulist = ml;
+ JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
+ document.getElementById('refresh').addEventListener( 'command', function() {
+ JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
+ }, false);
+ };
+ },
+ ],
+
+ 'copy_buckets_add' : [
+ ['command'],
+ function() {
try {
var bucket_id = obj.controller.view.bucket_menulist.value;
if (!bucket_id) return;
} catch(E) {
alert(E);
}
- }
- ],
- 'copy_buckets_sel_add' : [
- ['command'],
- function() {
- var bucket_id = obj.controller.view.bucket_menulist.value;
- if (!bucket_id) return;
- for (var i = 0; i < obj.selection_list1.length; i++) {
+ }
+ ],
+ 'copy_buckets_sel_add' : [
+ ['command'],
+ function() {
+ var bucket_id = obj.controller.view.bucket_menulist.value;
+ if (!bucket_id) return;
+ for (var i = 0; i < obj.selection_list1.length; i++) {
var acp_id = obj.selection_list1[i][0];
- //var barcode = obj.selection_list1[i][1];
- var bucket_item = new ccbi();
- bucket_item.isnew('1');
- bucket_item.bucket(bucket_id);
- bucket_item.target_copy( acp_id );
- try {
- var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
- [ ses(), 'copy', bucket_item ]);
-
- if (typeof robj == 'object') throw robj;
-
- var item = obj.prep_item_for_list( acp_id, robj );
- if (!item) continue;
-
- obj.list2.append( item );
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_sel_add.error'), E);
- }
- }
-
- }
- ],
- 'copy_buckets_export' : [
- ['command'],
- function() {
- for (var i = 0; i < obj.selection_list2.length; i++) {
- var acp_id = obj.selection_list2[i][0];
- //var barcode = obj.selection_list1[i][1];
- //var bucket_item_id = obj.selection_list1[i][2];
- var item = obj.prep_item_for_list( acp_id );
- if (item) {
- obj.list1.append( item );
- obj.copy_ids.push( acp_id );
- }
- }
- }
- ],
-
- 'copy_buckets_delete_item' : [
- ['command'],
- function() {
- for (var i = 0; i < obj.selection_list2.length; i++) {
- try {
- //var acp_id = obj.selection_list2[i][0];
- //var barcode = obj.selection_list2[i][1];
- var bucket_item_id = obj.selection_list2[i][2];
- var robj = obj.network.simple_request('BUCKET_ITEM_DELETE',
- [ ses(), 'copy', bucket_item_id ]);
- if (typeof robj == 'object') throw robj;
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_delete_item.error'), E);
- }
- }
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
- }
- ],
- 'copy_buckets_delete_bucket' : [
- ['command'],
- function() {
- try {
- var bucket = obj.controller.view.bucket_menulist.value;
- var name = obj.bucket_id_name_map[ bucket ];
- var conf = window.confirm($('catStrings').getFormattedString('staff.cat.copy_buckets.copy_buckets_delete_bucket.confirm', [name]));
- if (!conf) return;
- obj.list2.clear();
- var robj = obj.network.simple_request('BUCKET_DELETE',[ses(),'copy',bucket]);
- if (typeof robj == 'object') throw robj;
- obj.controller.render('copy_buckets_menulist_placeholder');
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_delete_bucket.error'),E);
- }
- }
- ],
- 'copy_buckets_new_bucket' : [
- ['command'],
- function() {
- try {
- var name = prompt(
- $('catStrings').getString('staff.cat.copy_buckets.copy_buckets_new_bucket.prompt'),
- '',
- $('catStrings').getString('staff.cat.copy_buckets.copy_buckets_new_bucket.title')
- );
-
- if (name) {
- var bucket = new ccb();
- bucket.btype('staff_client');
- bucket.owner( obj.data.list.au[0].id() );
- bucket.name( name );
-
- var robj = obj.network.simple_request('BUCKET_CREATE',[ses(),'copy',bucket]);
-
- if (typeof robj == 'object') {
- if (robj.ilsevent == 1710 /* CONTAINER_EXISTS */) {
- alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_new_bucket.container_exists'));
- return;
- }
- throw robj;
- }
-
- obj.controller.render('copy_buckets_menulist_placeholder');
- obj.controller.view.bucket_menulist.value = robj;
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_new_bucket.error'),E);
- }
- }
- ],
- 'copy_buckets_batch_copy_edit' : [
- ['command'],
- function() {
- try {
-
- obj.list2.select_all();
-
- JSAN.use('util.widgets'); JSAN.use('util.functional');
-
- var list = util.functional.map_list(
- obj.list2.dump_retrieve_ids(),
- function (o) {
- return JSON2js(o)[0]; // acp_id
- }
- );
-
- JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
-
- obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
- setTimeout(
- function() {
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
- } catch(E) {
- alert( js2JSON(E) );
- }
- }
- ],
- 'copy_buckets_batch_copy_delete' : [
- ['command'],
- function() {
- try {
-
- obj.list2.select_all();
-
- JSAN.use('util.widgets'); JSAN.use('util.functional');
-
- var list = util.functional.map_list(
- obj.list2.dump_retrieve_ids(),
- function (o) {
- return JSON2js(o)[0]; // acp_id
- }
- );
-
- var copies = util.functional.map_list(
- list,
- function (acp_id) {
- return obj.network.simple_request('FM_ACP_RETRIEVE',[acp_id]);
- }
- );
-
- for (var i = 0; i < copies.length; i++) {
- copies[i].ischanged(1);
- copies[i].isdeleted(1);
- }
-
- var robj = obj.network.simple_request(
- 'FM_ACP_FLESHED_BATCH_UPDATE',
- [ ses(), copies, true],
- null, // no callback
- {
- 'title' : document.getElementById('catStrings').getString('staff.cat.copy_buckets.batch.error'),
- 'overridable_events' : [
- 1208 /* TITLE_LAST_COPY */
- ]
- }
- );
- if (typeof robj.ilsevent != 'undefined') {
- switch(Number(robj.ilsevent)) {
- case 1208 /* TITLE_LAST_COPY */ :
- // ignore this
- break;
- case 1227 /* COPY_DELETE_WARNING */ :
- var copy;
- for (var i = 0; i < copies.length; i++) { if (copies[i].id()==robj.payload) copy = function(a){return a;}(copies[i]); }
- /* The copy in question is not in an ideal status for deleting */
- var err = '*** ' + robj.desc + ' ***\n';
- /* The barcode for the item is {1} */
- err += $('catStrings').getFormattedString('cat.barcode_for_item',[ copy.barcode() ]) + '\n';
- /* The whole batch operation failed */
- err += $('catStrings').getString('cat.batch_operation_failed') + '\n';
- alert(err);
- break;
- default:
- obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.batch.error'), robj);
- }
- }
-
- obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
- } catch(E) {
- alert( js2JSON(E) );
- }
- }
- ],
-
- 'copy_buckets_transfer_to_volume' : [
- ['command'],
- function() {
- try {
- obj.list2.select_all();
-
- obj.data.stash_retrieve();
- if (!obj.data.marked_volume) {
- alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_transfer_to_volume.no_volume'));
- return;
- }
-
- var copy_ids = util.functional.map_list(
- obj.list2.dump_retrieve_ids(),
- function (o) {
- return JSON2js(o)[0]; // acp_id
- }
- )
-
- var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
-
- var msg = $('catStrings').getFormattedString(
- 'staff.cat.copy_buckets.copy_buckets_transfer_to_volume.confirm',
- [
- obj.controller.view.bucket_menulist.getAttribute('label'),
- volume.label(),
- obj.data.hash.aou[ volume.owning_lib() ].shortname()
- ]
- );
-
- JSAN.use('cat.util'); cat.util.transfer_copies( {
- 'copy_ids' : copy_ids,
- 'message' : msg,
- 'docid' : volume.record(),
- 'volume_label' : volume.label(),
- 'owning_lib' : volume.owning_lib(),
- } );
-
- obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_transfer_to_volume.error'), E);
- }
- }
- ],
- 'cmd_broken' : [
- ['command'],
- function() { alert($('commonStrings').getString('common.unimplemented')); }
- ],
- 'cmd_copy_buckets_print' : [
- ['command'],
- function() {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- obj.list2.on_all_fleshed = function() {
- try {
- dump( js2JSON( obj.list2.dump_with_keys() ) + '\n' );
- data.stash_retrieve();
- var lib = data.hash.aou[ data.list.au[0].ws_ou() ];
- lib.children(null);
- var p = {
- 'lib' : lib,
- 'staff' : data.list.au[0],
- 'header' : data.print_list_templates.item_status.header,
- 'line_item' : data.print_list_templates.item_status.line_item,
- 'footer' : data.print_list_templates.item_status.footer,
- 'type' : data.print_list_templates.item_status.type,
- 'list' : obj.list2.dump_with_keys(),
- };
- JSAN.use('util.print'); var print = new util.print();
- print.tree_list( p );
- setTimeout(function(){obj.list2.on_all_fleshed = null;},0);
- } catch(E) {
- alert(E);
- }
- }
- obj.list2.full_retrieve();
- }
- ],
- 'cmd_copy_buckets_export' : [
- ['command'],
- function() {
- obj.list2.dump_csv_to_clipboard();
- }
- ],
- 'cmd_copy_buckets_reprint' : [
- ['command'],
- function() {
- }
- ],
- 'cmd_export_to_copy_status' : [
- ['command'],
- function() {
- try {
+ //var barcode = obj.selection_list1[i][1];
+ var bucket_item = new ccbi();
+ bucket_item.isnew('1');
+ bucket_item.bucket(bucket_id);
+ bucket_item.target_copy( acp_id );
+ try {
+ var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
+ [ ses(), 'copy', bucket_item ]);
+
+ if (typeof robj == 'object') throw robj;
+
+ var item = obj.prep_item_for_list( acp_id, robj );
+ if (!item) continue;
+
+ obj.list2.append( item );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_sel_add.error'), E);
+ }
+ }
+
+ }
+ ],
+ 'copy_buckets_export' : [
+ ['command'],
+ function() {
+ for (var i = 0; i < obj.selection_list2.length; i++) {
+ var acp_id = obj.selection_list2[i][0];
+ //var barcode = obj.selection_list1[i][1];
+ //var bucket_item_id = obj.selection_list1[i][2];
+ var item = obj.prep_item_for_list( acp_id );
+ if (item) {
+ obj.list1.append( item );
+ obj.copy_ids.push( acp_id );
+ }
+ }
+ }
+ ],
+
+ 'copy_buckets_delete_item' : [
+ ['command'],
+ function() {
+ for (var i = 0; i < obj.selection_list2.length; i++) {
+ try {
+ //var acp_id = obj.selection_list2[i][0];
+ //var barcode = obj.selection_list2[i][1];
+ var bucket_item_id = obj.selection_list2[i][2];
+ var robj = obj.network.simple_request('BUCKET_ITEM_DELETE',
+ [ ses(), 'copy', bucket_item_id ]);
+ if (typeof robj == 'object') throw robj;
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_delete_item.error'), E);
+ }
+ }
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+ }
+ ],
+ 'copy_buckets_delete_bucket' : [
+ ['command'],
+ function() {
+ try {
+ var bucket = obj.controller.view.bucket_menulist.value;
+ var name = obj.bucket_id_name_map[ bucket ];
+ var conf = window.confirm($('catStrings').getFormattedString('staff.cat.copy_buckets.copy_buckets_delete_bucket.confirm', [name]));
+ if (!conf) return;
+ obj.list2.clear();
+ var robj = obj.network.simple_request('BUCKET_DELETE',[ses(),'copy',bucket]);
+ if (typeof robj == 'object') throw robj;
+ obj.controller.render('copy_buckets_menulist_placeholder');
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_delete_bucket.error'),E);
+ }
+ }
+ ],
+ 'copy_buckets_new_bucket' : [
+ ['command'],
+ function() {
+ try {
+ var name = prompt(
+ $('catStrings').getString('staff.cat.copy_buckets.copy_buckets_new_bucket.prompt'),
+ '',
+ $('catStrings').getString('staff.cat.copy_buckets.copy_buckets_new_bucket.title')
+ );
+
+ if (name) {
+ var bucket = new ccb();
+ bucket.btype('staff_client');
+ bucket.owner( obj.data.list.au[0].id() );
+ bucket.name( name );
+
+ var robj = obj.network.simple_request('BUCKET_CREATE',[ses(),'copy',bucket]);
+
+ if (typeof robj == 'object') {
+ if (robj.ilsevent == 1710 /* CONTAINER_EXISTS */) {
+ alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_new_bucket.container_exists'));
+ return;
+ }
+ throw robj;
+ }
+
+ obj.controller.render('copy_buckets_menulist_placeholder');
+ obj.controller.view.bucket_menulist.value = robj;
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_new_bucket.error'),E);
+ }
+ }
+ ],
+ 'copy_buckets_batch_copy_edit' : [
+ ['command'],
+ function() {
+ try {
+
+ obj.list2.select_all();
+
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+
+ var list = util.functional.map_list(
+ obj.list2.dump_retrieve_ids(),
+ function (o) {
+ return JSON2js(o)[0]; // acp_id
+ }
+ );
+
+ JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
+
+ obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
+ setTimeout(
+ function() {
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+ } catch(E) {
+ alert( js2JSON(E) );
+ }
+ }
+ ],
+ 'copy_buckets_batch_copy_delete' : [
+ ['command'],
+ function() {
+ try {
+
+ obj.list2.select_all();
+
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+
+ var list = util.functional.map_list(
+ obj.list2.dump_retrieve_ids(),
+ function (o) {
+ return JSON2js(o)[0]; // acp_id
+ }
+ );
+
+ var copies = util.functional.map_list(
+ list,
+ function (acp_id) {
+ return obj.network.simple_request('FM_ACP_RETRIEVE',[acp_id]);
+ }
+ );
+
+ for (var i = 0; i < copies.length; i++) {
+ copies[i].ischanged(1);
+ copies[i].isdeleted(1);
+ }
+
+ var robj = obj.network.simple_request(
+ 'FM_ACP_FLESHED_BATCH_UPDATE',
+ [ ses(), copies, true],
+ null, // no callback
+ {
+ 'title' : document.getElementById('catStrings').getString('staff.cat.copy_buckets.batch.error'),
+ 'overridable_events' : [
+ 1208 /* TITLE_LAST_COPY */
+ ]
+ }
+ );
+ if (typeof robj.ilsevent != 'undefined') {
+ switch(Number(robj.ilsevent)) {
+ case 1208 /* TITLE_LAST_COPY */ :
+ // ignore this
+ break;
+ case 1227 /* COPY_DELETE_WARNING */ :
+ var copy;
+ for (var i = 0; i < copies.length; i++) { if (copies[i].id()==robj.payload) copy = function(a){return a;}(copies[i]); }
+ /* The copy in question is not in an ideal status for deleting */
+ var err = '*** ' + robj.desc + ' ***\n';
+ /* The barcode for the item is {1} */
+ err += $('catStrings').getFormattedString('cat.barcode_for_item',[ copy.barcode() ]) + '\n';
+ /* The whole batch operation failed */
+ err += $('catStrings').getString('cat.batch_operation_failed') + '\n';
+ alert(err);
+ break;
+ default:
+ obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.batch.error'), robj);
+ }
+ }
+
+ obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+ } catch(E) {
+ alert( js2JSON(E) );
+ }
+ }
+ ],
+
+ 'copy_buckets_transfer_to_volume' : [
+ ['command'],
+ function() {
+ try {
+ obj.list2.select_all();
+
+ obj.data.stash_retrieve();
+ if (!obj.data.marked_volume) {
+ alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_transfer_to_volume.no_volume'));
+ return;
+ }
+
+ var copy_ids = util.functional.map_list(
+ obj.list2.dump_retrieve_ids(),
+ function (o) {
+ return JSON2js(o)[0]; // acp_id
+ }
+ )
+
+ var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
+
+ var msg = $('catStrings').getFormattedString(
+ 'staff.cat.copy_buckets.copy_buckets_transfer_to_volume.confirm',
+ [
+ obj.controller.view.bucket_menulist.getAttribute('label'),
+ volume.label(),
+ obj.data.hash.aou[ volume.owning_lib() ].shortname()
+ ]
+ );
+
+ JSAN.use('cat.util'); cat.util.transfer_copies( {
+ 'copy_ids' : copy_ids,
+ 'message' : msg,
+ 'docid' : volume.record(),
+ 'volume_label' : volume.label(),
+ 'owning_lib' : volume.owning_lib(),
+ } );
+
+ obj.render_pending_copies(); // FIXME -- need a generic refresh for lists
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.copy_buckets_transfer_to_volume.error'), E);
+ }
+ }
+ ],
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert($('commonStrings').getString('common.unimplemented')); }
+ ],
+ 'cmd_copy_buckets_print' : [
+ ['command'],
+ function() {
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ obj.list2.on_all_fleshed = function() {
+ try {
+ dump( js2JSON( obj.list2.dump_with_keys() ) + '\n' );
+ data.stash_retrieve();
+ var lib = data.hash.aou[ data.list.au[0].ws_ou() ];
+ lib.children(null);
+ var p = {
+ 'lib' : lib,
+ 'staff' : data.list.au[0],
+ 'header' : data.print_list_templates.item_status.header,
+ 'line_item' : data.print_list_templates.item_status.line_item,
+ 'footer' : data.print_list_templates.item_status.footer,
+ 'type' : data.print_list_templates.item_status.type,
+ 'list' : obj.list2.dump_with_keys(),
+ };
+ JSAN.use('util.print'); var print = new util.print();
+ print.tree_list( p );
+ setTimeout(function(){obj.list2.on_all_fleshed = null;},0);
+ } catch(E) {
+ alert(E);
+ }
+ }
+ obj.list2.full_retrieve();
+ }
+ ],
+ 'cmd_copy_buckets_export' : [
+ ['command'],
+ function() {
+ obj.list2.dump_csv_to_clipboard();
+ }
+ ],
+ 'cmd_copy_buckets_reprint' : [
+ ['command'],
+ function() {
+ }
+ ],
+ 'cmd_export_to_copy_status' : [
+ ['command'],
+ function() {
+ try {
obj.list2.on_all_fleshed =
function() {
try {
);
var url = urls.XUL_COPY_STATUS;
xulG.new_tab( url, {}, { 'barcodes' : barcodes });
- setTimeout(function(){obj.list2.on_all_fleshed = null;},0);
+ setTimeout(function(){obj.list2.on_all_fleshed = null;},0);
} catch(E) {
obj.error.standard_unexpected_error_alert('export to copy status',E);
}
}
obj.list2.full_retrieve();
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.cmd_export_to_copy_status.error'), E);
- }
- }
- ],
- }
- }
- );
- this.controller.render();
-
- if (typeof xulG == 'undefined') {
- obj.controller.view.cmd_export_to_copy_status.disabled = true;
- obj.controller.view.cmd_export_to_copy_status.setAttribute('disabled',true);
- }
-
- },
-
- 'prep_item_for_list' : function(acp_id,bucket_item_id) {
- var obj = this;
- try {
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.cmd_export_to_copy_status.error'), E);
+ }
+ }
+ ],
+ }
+ }
+ );
+ this.controller.render();
+
+ if (typeof xulG == 'undefined') {
+ obj.controller.view.cmd_export_to_copy_status.disabled = true;
+ obj.controller.view.cmd_export_to_copy_status.setAttribute('disabled',true);
+ }
+
+ },
+
+ 'prep_item_for_list' : function(acp_id,bucket_item_id) {
+ var obj = this;
+ try {
var item = {
'retrieve_id' : js2JSON( [ acp_id, null, bucket_item_id ] ),
'row' : {
}
};
return item;
- } catch(E) {
- obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.prep_item_for_list.error'), E);
- return null;
- }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_buckets.prep_item_for_list.error'), E);
+ return null;
+ }
- },
+ },
'scan_barcode' : function() {
var obj = this;
obj.controller.view.copy_bucket_barcode_entry_textbox.focus();
alert(E);
}
- }
+ }
}
dump('exiting cat.copy_buckets.js\n');
function $(id) { return document.getElementById(id); }
function my_init() {
- try {
- /******************************************************************************************************/
- /* setup JSAN and some initial libraries */
+ try {
+ /******************************************************************************************************/
+ /* setup JSAN and some initial libraries */
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (typeof JSAN == 'undefined') {
- throw( $('commonStrings').getString('common.jsan.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 cat/copy_editor.xul');
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') {
+ throw( $('commonStrings').getString('common.jsan.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 cat/copy_editor.xul');
- JSAN.use('util.functional');
- JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
- JSAN.use('util.network'); g.network = new util.network();
+ JSAN.use('util.functional');
+ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+ JSAN.use('util.network'); g.network = new util.network();
- g.docid = xul_param('docid',{'modal_xulG':true});
- g.handle_update = xul_param('handle_update',{'modal_xulG':true});
+ g.docid = xul_param('docid',{'modal_xulG':true});
+ g.handle_update = xul_param('handle_update',{'modal_xulG':true});
- /******************************************************************************************************/
- /* Get the copy ids from various sources and flesh them */
+ /******************************************************************************************************/
+ /* Get the copy ids from various sources and flesh them */
- var copy_ids = xul_param('copy_ids',{'concat':true,'JSON2js_if_cgi':true,'JSON2js_if_xulG':true,'JSON2js_if_xpcom':true,'stash_name':'temp_copy_ids','clear_xpcom':true,'modal_xulG':true});
- if (!copy_ids) copy_ids = [];
+ var copy_ids = xul_param('copy_ids',{'concat':true,'JSON2js_if_cgi':true,'JSON2js_if_xulG':true,'JSON2js_if_xpcom':true,'stash_name':'temp_copy_ids','clear_xpcom':true,'modal_xulG':true});
+ if (!copy_ids) copy_ids = [];
- if (copy_ids.length > 0) g.copies = g.network.simple_request(
- 'FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative',
- [ copy_ids ]
- );
+ if (copy_ids.length > 0) g.copies = g.network.simple_request(
+ 'FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative',
+ [ copy_ids ]
+ );
- /******************************************************************************************************/
- /* And other fleshed copies if any */
+ /******************************************************************************************************/
+ /* And other fleshed copies if any */
- if (!g.copies) g.copies = [];
- var c = xul_param('copies',{'concat':true,'JSON2js_if_cgi':true,'JSON2js_if_xpcom':true,'stash_name':'temp_copies','clear_xpcom':true,'modal_xulG':true})
- if (c) g.copies = g.copies.concat(c);
+ if (!g.copies) g.copies = [];
+ var c = xul_param('copies',{'concat':true,'JSON2js_if_cgi':true,'JSON2js_if_xpcom':true,'stash_name':'temp_copies','clear_xpcom':true,'modal_xulG':true})
+ if (c) g.copies = g.copies.concat(c);
- /******************************************************************************************************/
- /* We try to retrieve callnumbers for existing copies, but for new copies, we rely on this */
+ /******************************************************************************************************/
+ /* We try to retrieve callnumbers for existing copies, but for new copies, we rely on this */
- g.callnumbers = xul_param('callnumbers',{'concat':true,'JSON2js_if_cgi':true,'JSON2js_if_xpcom':true,'stash_name':'temp_callnumbers','clear_xpcom':true,'modal_xulG':true});
+ g.callnumbers = xul_param('callnumbers',{'concat':true,'JSON2js_if_cgi':true,'JSON2js_if_xpcom':true,'stash_name':'temp_callnumbers','clear_xpcom':true,'modal_xulG':true});
- /******************************************************************************************************/
- /* Quick fix, this was defined inline in the global scope but now needs g.error and g.copies from my_init */
- /* Quick fix, messagecatalog only usable during/after onload */
+ /******************************************************************************************************/
+ /* Quick fix, this was defined inline in the global scope but now needs g.error and g.copies from my_init */
+ /* Quick fix, messagecatalog only usable during/after onload */
init_panes0();
init_panes();
- /******************************************************************************************************/
- /* Is the interface an editor or a viewer, single or multi copy, existing copies or new copies? */
+ /******************************************************************************************************/
+ /* Is the interface an editor or a viewer, single or multi copy, existing copies or new copies? */
- if (xul_param('edit',{'modal_xulG':true}) == '1') {
+ if (xul_param('edit',{'modal_xulG':true}) == '1') {
// Editor desired, but let's check permissions
- g.edit = false;
+ g.edit = false;
try {
var check = g.network.simple_request(
g.error.standard_unexpected_error_alert('batch permission check',E);
}
- if (g.edit) {
+ if (g.edit) {
$('caption').setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.caption'));
- $('save').setAttribute('hidden','false');
- g.retrieve_templates();
+ $('save').setAttribute('hidden','false');
+ g.retrieve_templates();
} else {
- $('top_nav').setAttribute('hidden','true');
+ $('top_nav').setAttribute('hidden','true');
}
- } else {
- $('top_nav').setAttribute('hidden','true');
- }
-
- if (g.copies.length > 0 && g.copies[0].id() < 0) {
- document.getElementById('copy_notes').setAttribute('hidden','true');
- g.apply("status",5 /* In Process */);
- $('save').setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.create_copies'));
- } else {
- g.panes_and_field_names.left_pane =
- [
- [
- $('catStrings').getString('staff.cat.copy_editor.status'),
- {
- render: 'typeof fm.status() == "object" ? fm.status().name() : g.data.hash.ccs[ fm.status() ].name()',
- input: g.safe_to_edit_copy_status() ? 'c = function(v){ g.apply("status",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.ccs, function(obj) { return [ obj.name(), obj.id(), typeof my_constants.magical_statuses[obj.id()] != "undefined" ? true : false ]; } ).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);' : undefined,
- //input: 'c = function(v){ g.apply("status",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( util.functional.filter_list( g.data.list.ccs, function(obj) { return typeof my_constants.magical_statuses[obj.id()] == "undefined"; } ), function(obj) { return [ obj.name(), obj.id() ]; } ).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ]
- ].concat(g.panes_and_field_names.left_pane);
- }
-
- if (g.copies.length != 1) {
- document.getElementById('copy_notes').setAttribute('hidden','true');
- }
-
- /******************************************************************************************************/
- /* Show the Record Details? */
+ } else {
+ $('top_nav').setAttribute('hidden','true');
+ }
+
+ if (g.copies.length > 0 && g.copies[0].id() < 0) {
+ document.getElementById('copy_notes').setAttribute('hidden','true');
+ g.apply("status",5 /* In Process */);
+ $('save').setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.create_copies'));
+ } else {
+ g.panes_and_field_names.left_pane =
+ [
+ [
+ $('catStrings').getString('staff.cat.copy_editor.status'),
+ {
+ render: 'typeof fm.status() == "object" ? fm.status().name() : g.data.hash.ccs[ fm.status() ].name()',
+ input: g.safe_to_edit_copy_status() ? 'c = function(v){ g.apply("status",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.ccs, function(obj) { return [ obj.name(), obj.id(), typeof my_constants.magical_statuses[obj.id()] != "undefined" ? true : false ]; } ).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);' : undefined,
+ //input: 'c = function(v){ g.apply("status",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( util.functional.filter_list( g.data.list.ccs, function(obj) { return typeof my_constants.magical_statuses[obj.id()] == "undefined"; } ), function(obj) { return [ obj.name(), obj.id() ]; } ).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ]
+ ].concat(g.panes_and_field_names.left_pane);
+ }
+
+ if (g.copies.length != 1) {
+ document.getElementById('copy_notes').setAttribute('hidden','true');
+ }
+
+ /******************************************************************************************************/
+ /* Show the Record Details? */
var bdb = document.getElementById('brief_display_box'); while(bdb.firstChild) bdb.removeChild(bdb.lastChild);
- if (g.docid) {
+ if (g.docid) {
var brief_display = document.createElement('iframe'); bdb.appendChild(brief_display);
- brief_display.setAttribute( 'src', urls.XUL_BIB_BRIEF + '?docid=' + g.docid); // this is a modal window, so can't push in xulG
- brief_display.setAttribute( 'flex','1' );
- }
+ brief_display.setAttribute( 'src', urls.XUL_BIB_BRIEF + '?docid=' + g.docid); // this is a modal window, so can't push in xulG
+ brief_display.setAttribute( 'flex','1' );
+ }
- /******************************************************************************************************/
- /* Add stat cats to the panes_and_field_names.right_pane4 */
+ /******************************************************************************************************/
+ /* Add stat cats to the panes_and_field_names.right_pane4 */
g.populate_stat_cats();
- /******************************************************************************************************/
- /* Backup copies :) */
+ /******************************************************************************************************/
+ /* Backup copies :) */
- g.original_copies = js2JSON( g.copies );
+ g.original_copies = js2JSON( g.copies );
- /******************************************************************************************************/
- /* Do it */
+ /******************************************************************************************************/
+ /* Do it */
- g.summarize( g.copies );
- g.render();
+ g.summarize( g.copies );
+ g.render();
- } catch(E) {
- var err_msg = $("commonStrings").getFormattedString('common.exception', ['cat/copy_editor.js', E]);
- try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); dump(js2JSON(E)); }
- alert(err_msg);
- }
+ } catch(E) {
+ var err_msg = $("commonStrings").getFormattedString('common.exception', ['cat/copy_editor.js', E]);
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); dump(js2JSON(E)); }
+ alert(err_msg);
+ }
}
/******************************************************************************************************/
/* Retrieve Templates */
g.retrieve_templates = function() {
- try {
- JSAN.use('util.widgets'); JSAN.use('util.functional');
- g.templates = {};
- var robj = g.network.simple_request('FM_AUS_RETRIEVE',[ses(),g.data.list.au[0].id()]);
- if (typeof robj['staff_client.copy_editor.templates'] != 'undefined') {
- g.templates = robj['staff_client.copy_editor.templates'];
- }
- util.widgets.remove_children('template_placeholder');
- var list = util.functional.map_object_to_list( g.templates, function(obj,i) { return [i, i]; } ).sort();
-
- g.template_menu = util.widgets.make_menulist( list );
+ try {
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+ g.templates = {};
+ var robj = g.network.simple_request('FM_AUS_RETRIEVE',[ses(),g.data.list.au[0].id()]);
+ if (typeof robj['staff_client.copy_editor.templates'] != 'undefined') {
+ g.templates = robj['staff_client.copy_editor.templates'];
+ }
+ util.widgets.remove_children('template_placeholder');
+ var list = util.functional.map_object_to_list( g.templates, function(obj,i) { return [i, i]; } ).sort();
+
+ g.template_menu = util.widgets.make_menulist( list );
g.template_menu.setAttribute('id','template_menu');
- $('template_placeholder').appendChild(g.template_menu);
+ $('template_placeholder').appendChild(g.template_menu);
g.template_menu.addEventListener(
'command',
function() { g.copy_editor_prefs[ 'template_menu' ] = { 'value' : g.template_menu.value }; g.save_attributes(); },
false
);
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.retrieve_templates.error'), E);
- }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.retrieve_templates.error'), E);
+ }
}
/******************************************************************************************************/
/* Apply Template */
g.apply_template = function() {
- try {
- var name = g.template_menu.value;
- if (g.templates[ name ] != 'undefined') {
- var template = g.templates[ name ];
- for (var i in template) {
- g.changed[ i ] = template[ i ];
- switch( template[i].type ) {
- case 'attribute' :
- g.apply(template[i].field,template[i].value);
- break;
- case 'stat_cat' :
- if (g.stat_cat_seen[ template[i].field ]) g.apply_stat_cat(template[i].field,template[i].value);
- break;
- case 'owning_lib' :
- g.apply_owning_lib(template[i].value);
- break;
- }
- }
- g.summarize( g.copies );
- g.render();
- }
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.apply_templates.error'), E);
- }
+ try {
+ var name = g.template_menu.value;
+ if (g.templates[ name ] != 'undefined') {
+ var template = g.templates[ name ];
+ for (var i in template) {
+ g.changed[ i ] = template[ i ];
+ switch( template[i].type ) {
+ case 'attribute' :
+ g.apply(template[i].field,template[i].value);
+ break;
+ case 'stat_cat' :
+ if (g.stat_cat_seen[ template[i].field ]) g.apply_stat_cat(template[i].field,template[i].value);
+ break;
+ case 'owning_lib' :
+ g.apply_owning_lib(template[i].value);
+ break;
+ }
+ }
+ g.summarize( g.copies );
+ g.render();
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.apply_templates.error'), E);
+ }
}
/******************************************************************************************************/
/* Save as Template */
g.save_template = function() {
- try {
- var name = window.prompt(
- $('catStrings').getString('staff.cat.copy_editor.save_as_template.prompt'),
- '',
- $('catStrings').getString('staff.cat.copy_editor.save_as_template.title')
- );
- if (!name) return;
- g.templates[name] = g.changed;
- var robj = g.network.simple_request(
- 'FM_AUS_UPDATE',[ses(),g.data.list.au[0].id(), { 'staff_client.copy_editor.templates' : g.templates }]
- );
- if (typeof robj.ilsevent != 'undefined') {
- throw(robj);
- } else {
- alert($('catStrings').getFormattedString('staff.cat.copy_editor.save_as_template.success', [name]));
- setTimeout(
- function() {
- try {
- g.retrieve_templates();
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.save_as_template.error'), E);
- }
- },0
- );
- }
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.save_as_template.error'), E);
- }
+ try {
+ var name = window.prompt(
+ $('catStrings').getString('staff.cat.copy_editor.save_as_template.prompt'),
+ '',
+ $('catStrings').getString('staff.cat.copy_editor.save_as_template.title')
+ );
+ if (!name) return;
+ g.templates[name] = g.changed;
+ var robj = g.network.simple_request(
+ 'FM_AUS_UPDATE',[ses(),g.data.list.au[0].id(), { 'staff_client.copy_editor.templates' : g.templates }]
+ );
+ if (typeof robj.ilsevent != 'undefined') {
+ throw(robj);
+ } else {
+ alert($('catStrings').getFormattedString('staff.cat.copy_editor.save_as_template.success', [name]));
+ setTimeout(
+ function() {
+ try {
+ g.retrieve_templates();
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.save_as_template.error'), E);
+ }
+ },0
+ );
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.save_as_template.error'), E);
+ }
}
/******************************************************************************************************/
/* Delete Template */
g.delete_template = function() {
- try {
- var name = g.template_menu.value;
- if (!name) return;
- if (! window.confirm($('catStrings').getFormattedString('staff.cat.copy_editor.delete_template.confirm', [name]))) return;
- delete(g.templates[name]);
- var robj = g.network.simple_request(
- 'FM_AUS_UPDATE',[ses(),g.data.list.au[0].id(), { 'staff_client.copy_editor.templates' : g.templates }]
- );
- if (typeof robj.ilsevent != 'undefined') {
- throw(robj);
- } else {
- alert($('catStrings').getFormattedString('staff.cat.copy_editor.delete_template.confirm', [name]));
- setTimeout(
- function() {
- try {
- g.retrieve_templates();
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.delete_template.error'), E);
- }
- },0
- );
- }
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.delete_template.error'), E);
- }
+ try {
+ var name = g.template_menu.value;
+ if (!name) return;
+ if (! window.confirm($('catStrings').getFormattedString('staff.cat.copy_editor.delete_template.confirm', [name]))) return;
+ delete(g.templates[name]);
+ var robj = g.network.simple_request(
+ 'FM_AUS_UPDATE',[ses(),g.data.list.au[0].id(), { 'staff_client.copy_editor.templates' : g.templates }]
+ );
+ if (typeof robj.ilsevent != 'undefined') {
+ throw(robj);
+ } else {
+ alert($('catStrings').getFormattedString('staff.cat.copy_editor.delete_template.confirm', [name]));
+ setTimeout(
+ function() {
+ try {
+ g.retrieve_templates();
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.delete_template.error'), E);
+ }
+ },0
+ );
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.delete_template.error'), E);
+ }
}
/******************************************************************************************************/
/* Export Templates */
g.export_templates = function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.file'); var f = new util.file('');
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.file'); var f = new util.file('');
f.export_file( { 'title' : $('catStrings').getString('staff.cat.copy_editor.export_templates.title'), 'data' : g.templates } );
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.export_templates.error'), E);
- }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.export_templates.error'), E);
+ }
}
/******************************************************************************************************/
/* Import Templates */
g.import_templates = function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.file'); var f = new util.file('');
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.file'); var f = new util.file('');
var temp = f.import_file( { 'title' : $('catStrings').getString('staff.cat.copy_editor.import_templates.title') } );
- if (temp) {
- for (var i in temp) {
-
- if (g.templates[i]) {
-
- var r = g.error.yns_alert(
- $('catStrings').getString('staff.cat.copy_editor.import_templates.replace.prompt') + '\n' + g.error.pretty_print( js2JSON( temp[i] ) ),
- $('catStrings').getFormattedString('staff.cat.copy_editor.import_templates.replace.title', [i]),
- $('catStrings').getString('staff.cat.copy_editor.import_templates.replace.yes'),
- $('catStrings').getString('staff.cat.copy_editor.import_templates.replace.no'),
- null,
- $('catStrings').getString('staff.cat.copy_editor.import_templates.replace.click_here')
- );
-
- if (r == 0 /* Yes */) g.templates[i] = temp[i];
-
- } else {
-
- g.templates[i] = temp[i];
-
- }
-
- }
-
- var r = g.error.yns_alert(
- $('catStrings').getString('staff.cat.copy_editor.import_templates.save.prompt'),
- $('catStrings').getFormattedString('staff.cat.copy_editor.import_templates.save.title'),
- $('catStrings').getString('staff.cat.copy_editor.import_templates.save.yes'),
- $('catStrings').getString('staff.cat.copy_editor.import_templates.save.no'),
- null,
- $('catStrings').getString('staff.cat.copy_editor.import_templates.save.click_here')
- );
-
- if (r == 0 /* Yes */) {
- var robj = g.network.simple_request(
- 'FM_AUS_UPDATE',[ses(),g.data.list.au[0].id(), { 'staff_client.copy_editor.templates' : g.templates }]
- );
- if (typeof robj.ilsevent != 'undefined') {
- throw(robj);
- } else {
- alert($('catStrings').getString('staff.cat.copy_editor.import_templates.save.success'));
- setTimeout(
- function() {
- try {
- g.retrieve_templates();
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.import_templates.save.error'), E);
- }
- },0
- );
- }
- } else {
- util.widgets.remove_children('template_placeholder');
- var list = util.functional.map_object_to_list( g.templates, function(obj,i) { return [i, i]; } );
- g.template_menu = util.widgets.make_menulist( list );
- $('template_placeholder').appendChild(g.template_menu);
- alert($('catStrings').getString('staff.cat.copy_editor.import_templates.note'));
- }
-
- }
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.import_templates.error'), E);
- }
+ if (temp) {
+ for (var i in temp) {
+
+ if (g.templates[i]) {
+
+ var r = g.error.yns_alert(
+ $('catStrings').getString('staff.cat.copy_editor.import_templates.replace.prompt') + '\n' + g.error.pretty_print( js2JSON( temp[i] ) ),
+ $('catStrings').getFormattedString('staff.cat.copy_editor.import_templates.replace.title', [i]),
+ $('catStrings').getString('staff.cat.copy_editor.import_templates.replace.yes'),
+ $('catStrings').getString('staff.cat.copy_editor.import_templates.replace.no'),
+ null,
+ $('catStrings').getString('staff.cat.copy_editor.import_templates.replace.click_here')
+ );
+
+ if (r == 0 /* Yes */) g.templates[i] = temp[i];
+
+ } else {
+
+ g.templates[i] = temp[i];
+
+ }
+
+ }
+
+ var r = g.error.yns_alert(
+ $('catStrings').getString('staff.cat.copy_editor.import_templates.save.prompt'),
+ $('catStrings').getFormattedString('staff.cat.copy_editor.import_templates.save.title'),
+ $('catStrings').getString('staff.cat.copy_editor.import_templates.save.yes'),
+ $('catStrings').getString('staff.cat.copy_editor.import_templates.save.no'),
+ null,
+ $('catStrings').getString('staff.cat.copy_editor.import_templates.save.click_here')
+ );
+
+ if (r == 0 /* Yes */) {
+ var robj = g.network.simple_request(
+ 'FM_AUS_UPDATE',[ses(),g.data.list.au[0].id(), { 'staff_client.copy_editor.templates' : g.templates }]
+ );
+ if (typeof robj.ilsevent != 'undefined') {
+ throw(robj);
+ } else {
+ alert($('catStrings').getString('staff.cat.copy_editor.import_templates.save.success'));
+ setTimeout(
+ function() {
+ try {
+ g.retrieve_templates();
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.import_templates.save.error'), E);
+ }
+ },0
+ );
+ }
+ } else {
+ util.widgets.remove_children('template_placeholder');
+ var list = util.functional.map_object_to_list( g.templates, function(obj,i) { return [i, i]; } );
+ g.template_menu = util.widgets.make_menulist( list );
+ $('template_placeholder').appendChild(g.template_menu);
+ alert($('catStrings').getString('staff.cat.copy_editor.import_templates.note'));
+ }
+
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.import_templates.error'), E);
+ }
}
/* Restore backup copies */
g.reset = function() {
- g.changed = {};
- g.copies = JSON2js( g.original_copies );
- g.summarize( g.copies );
- g.render();
+ g.changed = {};
+ g.copies = JSON2js( g.original_copies );
+ g.summarize( g.copies );
+ g.render();
}
/******************************************************************************************************/
/* Apply a value to a specific field on all the copies being edited */
g.apply = function(field,value) {
- g.error.sdump('D_TRACE','applying field = <' + field + '> value = <' + value + '>\n');
- if (value == '<HACK:KLUDGE:NULL>') value = null;
- if (field == 'alert_message') { value = value.replace(/^\W+$/g,''); }
- if (field == 'price' || field == 'deposit_amount') {
- if (value == '') { value = null; } else { JSAN.use('util.money'); value = util.money.sanitize( value ); }
- }
- for (var i = 0; i < g.copies.length; i++) {
- var copy = g.copies[i];
- try {
- copy[field]( value ); copy.ischanged('1');
- } catch(E) {
- alert(E);
- }
- }
+ g.error.sdump('D_TRACE','applying field = <' + field + '> value = <' + value + '>\n');
+ if (value == '<HACK:KLUDGE:NULL>') value = null;
+ if (field == 'alert_message') { value = value.replace(/^\W+$/g,''); }
+ if (field == 'price' || field == 'deposit_amount') {
+ if (value == '') { value = null; } else { JSAN.use('util.money'); value = util.money.sanitize( value ); }
+ }
+ for (var i = 0; i < g.copies.length; i++) {
+ var copy = g.copies[i];
+ try {
+ copy[field]( value ); copy.ischanged('1');
+ } catch(E) {
+ alert(E);
+ }
+ }
}
/******************************************************************************************************/
/* Apply a stat cat entry to all the copies being edited. An entry_id of < 0 signifies the stat cat is being removed. */
g.apply_stat_cat = function(sc_id,entry_id) {
- g.error.sdump('D_TRACE','sc_id = ' + sc_id + ' entry_id = ' + entry_id + '\n');
- for (var i = 0; i < g.copies.length; i++) {
- var copy = g.copies[i];
- try {
- copy.ischanged('1');
- var temp = copy.stat_cat_entries();
- if (!temp) temp = [];
- temp = util.functional.filter_list(
- temp,
- function (obj) {
- return (obj.stat_cat() != sc_id);
- }
- );
- if (entry_id > -1) temp.push(
- util.functional.find_id_object_in_list(
- g.data.hash.asc[sc_id].entries(),
- entry_id
- )
- );
- copy.stat_cat_entries( temp );
-
- } catch(E) {
- g.error.standard_unexpected_error_alert('apply_stat_cat',E);
- }
- }
+ g.error.sdump('D_TRACE','sc_id = ' + sc_id + ' entry_id = ' + entry_id + '\n');
+ for (var i = 0; i < g.copies.length; i++) {
+ var copy = g.copies[i];
+ try {
+ copy.ischanged('1');
+ var temp = copy.stat_cat_entries();
+ if (!temp) temp = [];
+ temp = util.functional.filter_list(
+ temp,
+ function (obj) {
+ return (obj.stat_cat() != sc_id);
+ }
+ );
+ if (entry_id > -1) temp.push(
+ util.functional.find_id_object_in_list(
+ g.data.hash.asc[sc_id].entries(),
+ entry_id
+ )
+ );
+ copy.stat_cat_entries( temp );
+
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('apply_stat_cat',E);
+ }
+ }
}
/******************************************************************************************************/
/* Apply an "owning lib" to all the copies being edited. That is, change and auto-vivicating volumes */
g.apply_owning_lib = function(ou_id) {
- g.error.sdump('D_TRACE','ou_id = ' + ou_id + '\n');
- for (var i = 0; i < g.copies.length; i++) {
- var copy = g.copies[i];
- try {
- if (!g.map_acn[copy.call_number()]) {
- var volume = g.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ copy.call_number() ]);
- if (typeof volume.ilsevent != 'undefined') {
- g.error.standard_unexpected_error_alert($('catStrings').getFormattedString('staff.cat.copy_editor.apply_owning_lib.undefined_volume.error', [copy.barcode()]), volume);
- continue;
- }
- g.map_acn[copy.call_number()] = volume;
- }
- var old_volume = g.map_acn[copy.call_number()];
- var acn_id = g.network.simple_request(
- 'FM_ACN_FIND_OR_CREATE',
- [ses(),old_volume.label(),old_volume.record(),ou_id]
- );
- if (typeof acn_id.ilsevent != 'undefined') {
- g.error.standard_unexpected_error_alert($('catStrings').getFormattedString('staff.cat.copy_editor.apply_owning_lib.call_number.error', [copy.barcode()]), acn_id);
- continue;
- }
- copy.call_number(acn_id);
- copy.ischanged('1');
- } catch(E) {
- g.error.standard_unexpected_error_alert('apply_stat_cat',E);
- }
- }
+ g.error.sdump('D_TRACE','ou_id = ' + ou_id + '\n');
+ for (var i = 0; i < g.copies.length; i++) {
+ var copy = g.copies[i];
+ try {
+ if (!g.map_acn[copy.call_number()]) {
+ var volume = g.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ copy.call_number() ]);
+ if (typeof volume.ilsevent != 'undefined') {
+ g.error.standard_unexpected_error_alert($('catStrings').getFormattedString('staff.cat.copy_editor.apply_owning_lib.undefined_volume.error', [copy.barcode()]), volume);
+ continue;
+ }
+ g.map_acn[copy.call_number()] = volume;
+ }
+ var old_volume = g.map_acn[copy.call_number()];
+ var acn_id = g.network.simple_request(
+ 'FM_ACN_FIND_OR_CREATE',
+ [ses(),old_volume.label(),old_volume.record(),ou_id]
+ );
+ if (typeof acn_id.ilsevent != 'undefined') {
+ g.error.standard_unexpected_error_alert($('catStrings').getFormattedString('staff.cat.copy_editor.apply_owning_lib.call_number.error', [copy.barcode()]), acn_id);
+ continue;
+ }
+ copy.call_number(acn_id);
+ copy.ischanged('1');
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('apply_stat_cat',E);
+ }
+ }
}
/******************************************************************************************************/
/* This returns true if none of the copies being edited are pre-cats */
g.safe_to_change_owning_lib = function() {
- try {
- var safe = true;
- for (var i = 0; i < g.copies.length; i++) {
- var cn = g.copies[i].call_number();
- if (typeof cn == 'object') { cn = cn.id(); }
- if (cn == -1) { safe = false; }
- }
- return safe;
- } catch(E) {
+ try {
+ var safe = true;
+ for (var i = 0; i < g.copies.length; i++) {
+ var cn = g.copies[i].call_number();
+ if (typeof cn == 'object') { cn = cn.id(); }
+ if (cn == -1) { safe = false; }
+ }
+ return safe;
+ } catch(E) {
g.error.standard_unexpected_error_alert('safe_to_change_owning_lib?',E);
- return false;
- }
+ return false;
+ }
}
/******************************************************************************************************/
/* This returns true if none of the copies being edited have a magical status found in my_constants.magical_statuses */
g.safe_to_edit_copy_status = function() {
- try {
- var safe = true;
- for (var i = 0; i < g.copies.length; i++) {
- var status = g.copies[i].status(); if (typeof status == 'object') status = status.id();
- if (typeof my_constants.magical_statuses[ status ] != 'undefined') safe = false;
- }
- return safe;
- } catch(E) {
- g.error.standard_unexpected_error_alert('safe_to_edit_copy_status?',E);
- return false;
- }
+ try {
+ var safe = true;
+ for (var i = 0; i < g.copies.length; i++) {
+ var status = g.copies[i].status(); if (typeof status == 'object') status = status.id();
+ if (typeof my_constants.magical_statuses[ status ] != 'undefined') safe = false;
+ }
+ return safe;
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('safe_to_edit_copy_status?',E);
+ return false;
+ }
}
/******************************************************************************************************/
/* This concats and uniques all the alert messages for use as the default value for a new alert message */
g.populate_alert_message_input = function(tb) {
- try {
- var seen = {}; var s = '';
- for (var i = 0; i < g.copies.length; i++) {
- var msg = g.copies[i].alert_message();
- if (msg) {
- if (typeof seen[msg] == 'undefined') {
- s += msg + '\n';
- seen[msg] = true;
- }
- }
- }
- tb.setAttribute('value',s);
- } catch(E) {
- g.error.standard_unexpected_error_alert('populate_alert_message_input',E);
- }
+ try {
+ var seen = {}; var s = '';
+ for (var i = 0; i < g.copies.length; i++) {
+ var msg = g.copies[i].alert_message();
+ if (msg) {
+ if (typeof seen[msg] == 'undefined') {
+ s += msg + '\n';
+ seen[msg] = true;
+ }
+ }
+ }
+ tb.setAttribute('value',s);
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('populate_alert_message_input',E);
+ }
}
/***************************************************************************************************************/
/* This returns a list of acpl's appropriate for the copies being edited */
g.get_acpl_list = function() {
- try {
+ try {
- JSAN.use('util.functional');
+ JSAN.use('util.functional');
var my_acpls = {};
/**************************************/
/* get owning libs from call numbers */
- var owning_libs = {};
- for (var i = 0; i < g.copies.length; i++) {
+ var owning_libs = {};
+ for (var i = 0; i < g.copies.length; i++) {
var callnumber = g.copies[i].call_number();
if (!callnumber) continue;
- var cn_id = typeof callnumber == 'object' ? callnumber.id() : callnumber;
- if (cn_id > 0) {
- if (! g.map_acn[ cn_id ]) {
- var req = g.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ cn_id ]);
+ var cn_id = typeof callnumber == 'object' ? callnumber.id() : callnumber;
+ if (cn_id > 0) {
+ if (! g.map_acn[ cn_id ]) {
+ var req = g.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ cn_id ]);
if (typeof req.ilsevent == 'undefined') {
- g.map_acn[ cn_id ] = req;
+ g.map_acn[ cn_id ] = req;
} else {
continue;
}
- }
+ }
var consider_lib = g.map_acn[ cn_id ].owning_lib();
if (!consider_lib) continue;
owning_libs[ typeof consider_lib == 'object' ? consider_lib.id() : consider_lib ] = true;
- }
- }
- if (g.callnumbers) {
- for (var i in g.callnumbers) {
+ }
+ }
+ if (g.callnumbers) {
+ for (var i in g.callnumbers) {
var consider_lib = g.callnumbers[i].owning_lib;
if (!consider_lib) continue;
owning_libs[ typeof consider_lib == 'object' ? consider_lib.id() : consider_lib ] = true;
- }
- }
+ }
+ }
/***************************************************************************************************/
/* now find the first ancestor they all have in common, get the acpl's for it and higher ancestors */
- JSAN.use('util.fm_utils');
+ JSAN.use('util.fm_utils');
var libs = []; for (var i in owning_libs) libs.push(i);
if (libs.length > 0) {
var ancestor = util.fm_utils.find_common_aou_ancestor( libs );
libs = []; for (var i in circ_libs) libs.push(i);
if (libs.length > 0) {
- var ancestor = util.fm_utils.find_common_aou_ancestor( libs );
- if (typeof ancestor == 'object' && ancestor != null) ancestor = ancestor.id();
+ var ancestor = util.fm_utils.find_common_aou_ancestor( libs );
+ if (typeof ancestor == 'object' && ancestor != null) ancestor = ancestor.id();
- if (ancestor) {
- var ancestors = util.fm_utils.find_common_aou_ancestors( libs );
- var acpl_list = g.get_acpl_list_for_lib(ancestor, ancestors);
+ if (ancestor) {
+ var ancestors = util.fm_utils.find_common_aou_ancestors( libs );
+ var acpl_list = g.get_acpl_list_for_lib(ancestor, ancestors);
if (acpl_list) for (var i = 0; i < acpl_list.length; i++) {
if (acpl_list[i] != null) {
my_acpls[ typeof acpl_list[i] == 'object' ? acpl_list[i].id() : acpl_list[i] ] = true;
return 0;
}
);
-
- } catch(E) {
- g.error.standard_unexpected_error_alert('get_acpl_list',E);
- return [];
- }
+
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('get_acpl_list',E);
+ return [];
+ }
}
function init_panes0() {
g.special_exception = {};
g.special_exception[$('catStrings').getString('staff.cat.copy_editor.field.owning_library.label')] = function(label,value) {
- JSAN.use('util.widgets');
- if (value>0) { /* an existing call number */
- g.network.simple_request(
- 'FM_ACN_RETRIEVE.authoritative',
- [ value ],
- function(req) {
- var cn = '??? id = ' + value;
- try {
- cn = req.getResultObject();
- } catch(E) {
- g.error.sdump('D_ERROR','callnumber retrieve: ' + E);
- }
- util.widgets.set_text(label,g.data.hash.aou[ cn.owning_lib() ].shortname() + ' : ' + cn.label());
- }
- );
- } else { /* a yet to be created call number */
- if (g.callnumbers) {
- util.widgets.set_text(label,g.data.hash.aou[ g.callnumbers[value].owning_lib ].shortname() + ' : ' + g.callnumbers[value].label);
- }
- }
- };
+ JSAN.use('util.widgets');
+ if (value>0) { /* an existing call number */
+ g.network.simple_request(
+ 'FM_ACN_RETRIEVE.authoritative',
+ [ value ],
+ function(req) {
+ var cn = '??? id = ' + value;
+ try {
+ cn = req.getResultObject();
+ } catch(E) {
+ g.error.sdump('D_ERROR','callnumber retrieve: ' + E);
+ }
+ util.widgets.set_text(label,g.data.hash.aou[ cn.owning_lib() ].shortname() + ' : ' + cn.label());
+ }
+ );
+ } else { /* a yet to be created call number */
+ if (g.callnumbers) {
+ util.widgets.set_text(label,g.data.hash.aou[ g.callnumbers[value].owning_lib ].shortname() + ' : ' + g.callnumbers[value].label);
+ }
+ }
+ };
g.special_exception[$('catStrings').getString('staff.cat.copy_editor.field.creator.label')] = function(label,value) {
- if (!Number(value)) return;
- g.network.simple_request(
- 'FM_AU_RETRIEVE_VIA_ID',
- [ ses(), value ],
- function(req) {
- var p = '??? id = ' + value;
- try {
- p = req.getResultObject();
- p = p.usrname();
-
- } catch(E) {
- g.error.sdump('D_ERROR','patron retrieve: ' + E);
- }
- JSAN.use('util.widgets');
- util.widgets.set_text(label,p);
- }
- );
- };
+ if (!Number(value)) return;
+ g.network.simple_request(
+ 'FM_AU_RETRIEVE_VIA_ID',
+ [ ses(), value ],
+ function(req) {
+ var p = '??? id = ' + value;
+ try {
+ p = req.getResultObject();
+ p = p.usrname();
+
+ } catch(E) {
+ g.error.sdump('D_ERROR','patron retrieve: ' + E);
+ }
+ JSAN.use('util.widgets');
+ util.widgets.set_text(label,p);
+ }
+ );
+ };
g.special_exception[$('catStrings').getString('staff.cat.copy_editor.field.last_editor.label')] = function(label,value) {
- if (!Number(value)) return;
- g.network.simple_request(
- 'FM_AU_RETRIEVE_VIA_ID',
- [ ses(), value ],
- function(req) {
- var p = '??? id = ' + value;
- try {
- p = req.getResultObject();
- p = p.usrname();
-
- } catch(E) {
- g.error.sdump('D_ERROR','patron retrieve: ' + E);
- }
- util.widgets.set_text(label,p);
- }
- );
- };
+ if (!Number(value)) return;
+ g.network.simple_request(
+ 'FM_AU_RETRIEVE_VIA_ID',
+ [ ses(), value ],
+ function(req) {
+ var p = '??? id = ' + value;
+ try {
+ p = req.getResultObject();
+ p = p.usrname();
+
+ } catch(E) {
+ g.error.sdump('D_ERROR','patron retrieve: ' + E);
+ }
+ util.widgets.set_text(label,p);
+ }
+ );
+ };
}
/******************************************************************************************************/
function init_panes() {
g.panes_and_field_names = {
- 'left_pane' :
+ 'left_pane' :
[
- [
- $('catStrings').getString('staff.cat.copy_editor.field.barcode.label'),
- {
- render: 'fm.barcode();',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.creation_date.label'),
- {
- render: 'util.date.formatted_date( fm.create_date(), "%F");',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.creator.label'),
- {
- render: 'fm.creator();',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.last_edit_date.label'),
- {
- render: 'util.date.formatted_date( fm.edit_date(), "%F");',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.last_editor.label'),
- {
- render: 'fm.editor();',
- }
- ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.barcode.label'),
+ {
+ render: 'fm.barcode();',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.creation_date.label'),
+ {
+ render: 'util.date.formatted_date( fm.create_date(), "%F");',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.creator.label'),
+ {
+ render: 'fm.creator();',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.last_edit_date.label'),
+ {
+ render: 'util.date.formatted_date( fm.edit_date(), "%F");',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.last_editor.label'),
+ {
+ render: 'fm.editor();',
+ }
+ ],
],
'right_pane' :
[
- [
- $('catStrings').getString('staff.cat.copy_editor.field.location.label'),
- {
- render: 'typeof fm.location() == "object" ? fm.location().name() : g.data.lookup("acpl",fm.location()).name()',
- input: 'c = function(v){ g.apply("location",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.get_acpl_list(), function(obj) { return [ g.data.hash.aou[ obj.owning_lib() ].shortname() + " : " + obj.name(), obj.id() ]; }).sort()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
-
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.circulation_library.label'),
- {
- render: 'typeof fm.circ_lib() == "object" ? fm.circ_lib().shortname() : g.data.hash.aou[ fm.circ_lib() ].shortname()',
- //input: 'c = function(v){ g.apply("circ_lib",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( util.functional.filter_list(g.data.list.my_aou, function(obj) { return g.data.hash.aout[ obj.ou_type() ].can_have_vols(); }), function(obj) { return [ obj.shortname(), obj.id() ]; }).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- input: 'c = function(v){ g.apply("circ_lib",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.aou, function(obj) { var sname = obj.shortname(); for (i = sname.length; i < 20; i++) sname += " "; return [ obj.name() ? sname + " " + obj.name() : obj.shortname(), obj.id(), ( ! get_bool( g.data.hash.aout[ obj.ou_type() ].can_have_vols() ) ), ( g.data.hash.aout[ obj.ou_type() ].depth() * 2), ]; }), g.data.list.au[0].ws_ou()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.owning_library.label'),
- {
- render: 'fm.call_number();',
- input: g.safe_to_change_owning_lib() ? 'c = function(v){ g.apply_owning_lib(v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.aou, function(obj) { var sname = obj.shortname(); for (i = sname.length; i < 20; i++) sname += " "; return [ obj.name() ? sname + " " + obj.name() : obj.shortname(), obj.id(), ( ! get_bool( g.data.hash.aout[ obj.ou_type() ].can_have_vols() ) ), ( g.data.hash.aout[ obj.ou_type() ].depth() * 2), ]; }), g.data.list.au[0].ws_ou()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);' : undefined,
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.copy_number.label'),
- {
- render: 'fm.copy_number() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : fm.copy_number()',
- input: 'c = function(v){ g.apply("copy_number",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.location.label'),
+ {
+ render: 'typeof fm.location() == "object" ? fm.location().name() : g.data.lookup("acpl",fm.location()).name()',
+ input: 'c = function(v){ g.apply("location",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.get_acpl_list(), function(obj) { return [ g.data.hash.aou[ obj.owning_lib() ].shortname() + " : " + obj.name(), obj.id() ]; }).sort()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.circulation_library.label'),
+ {
+ render: 'typeof fm.circ_lib() == "object" ? fm.circ_lib().shortname() : g.data.hash.aou[ fm.circ_lib() ].shortname()',
+ //input: 'c = function(v){ g.apply("circ_lib",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( util.functional.filter_list(g.data.list.my_aou, function(obj) { return g.data.hash.aout[ obj.ou_type() ].can_have_vols(); }), function(obj) { return [ obj.shortname(), obj.id() ]; }).sort() ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ input: 'c = function(v){ g.apply("circ_lib",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.aou, function(obj) { var sname = obj.shortname(); for (i = sname.length; i < 20; i++) sname += " "; return [ obj.name() ? sname + " " + obj.name() : obj.shortname(), obj.id(), ( ! get_bool( g.data.hash.aout[ obj.ou_type() ].can_have_vols() ) ), ( g.data.hash.aout[ obj.ou_type() ].depth() * 2), ]; }), g.data.list.au[0].ws_ou()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.owning_library.label'),
+ {
+ render: 'fm.call_number();',
+ input: g.safe_to_change_owning_lib() ? 'c = function(v){ g.apply_owning_lib(v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( g.data.list.aou, function(obj) { var sname = obj.shortname(); for (i = sname.length; i < 20; i++) sname += " "; return [ obj.name() ? sname + " " + obj.name() : obj.shortname(), obj.id(), ( ! get_bool( g.data.hash.aout[ obj.ou_type() ].can_have_vols() ) ), ( g.data.hash.aout[ obj.ou_type() ].depth() * 2), ]; }), g.data.list.au[0].ws_ou()); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);' : undefined,
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.copy_number.label'),
+ {
+ render: 'fm.copy_number() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : fm.copy_number()',
+ input: 'c = function(v){ g.apply("copy_number",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
],
'right_pane2' :
[
- [
- $('catStrings').getString('staff.cat.copy_editor.field.circulate.label'),
- {
- render: 'fm.circulate() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.circulate() ) ? $("catStrings").getString("staff.cat.copy_editor.field.circulate.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.circulate.no_or_false") )',
- input: 'c = function(v){ g.apply("circulate",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.circulate.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.circulate.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.holdable.label'),
- {
- render: 'fm.holdable() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.holdable() ) ? $("catStrings").getString("staff.cat.copy_editor.field.holdable.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.holdable.no_or_false") )',
- input: 'c = function(v){ g.apply("holdable",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.holdable.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.holdable.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.age_based_hold_protection.label'),
- {
- render: 'fm.age_protect() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( typeof fm.age_protect() == "object" ? fm.age_protect().name() : g.data.hash.crahp[ fm.age_protect() ].name() )',
- input: 'c = function(v){ g.apply("age_protect",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.remove_age_based_hold_protection"), "<HACK:KLUDGE:NULL>" ] ].concat( util.functional.map_list( g.data.list.crahp, function(obj) { return [ obj.name(), obj.id() ]; }).sort() ) ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
-
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.loan_duration.label'),
- {
- render: 'switch(Number(fm.loan_duration())){ case 1: $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.short"); break; case 2: $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.normal"); break; case 3: $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.extended"); break; }',
- input: 'c = function(v){ g.apply("loan_duration",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.short"), "1" ], [ $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.normal"), "2" ], [ $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.extended"), "3" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
-
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.fine_level.label'),
- {
- render: 'switch(Number(fm.fine_level())){ case 1: $("catStrings").getString("staff.cat.copy_editor.field.fine_level.low"); break; case 2: $("catStrings").getString("staff.cat.copy_editor.field.fine_level.normal"); break; case 3: $("catStrings").getString("staff.cat.copy_editor.field.fine_level.high"); break; }',
- input: 'c = function(v){ g.apply("fine_level",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.fine_level.low"), "1" ], [ $("catStrings").getString("staff.cat.copy_editor.field.fine_level.normal"), "2" ], [ $("catStrings").getString("staff.cat.copy_editor.field.fine_level.high"), "3" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
-
- [
- $('catStrings').getString('staff.cat.copy_editor.field.circulate_as_type.label'),
- {
- render: 'fm.circ_as_type() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : g.data.hash.citm[ fm.circ_as_type() ].value()',
- input: 'c = function(v){ g.apply("circ_as_type",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.remove_circulate_as_type"), "<HACK:KLUDGE:NULL>" ] ].concat( util.functional.map_list( g.data.list.citm, function(n){return [ n.code() + " - " + n.value(), n.code()];} ).sort() ) ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.circulation_modifier.label'),
- {
- render: 'fm.circ_modifier() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : fm.circ_modifier()',
- input: 'c = function(v){ g.apply("circ_modifier",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null"), "<HACK:KLUDGE:NULL>" ] ].concat( util.functional.map_list( g.data.list.circ_modifier, function(obj) { return [ obj, obj ]; } ).sort() ) ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.circulate.label'),
+ {
+ render: 'fm.circulate() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.circulate() ) ? $("catStrings").getString("staff.cat.copy_editor.field.circulate.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.circulate.no_or_false") )',
+ input: 'c = function(v){ g.apply("circulate",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.circulate.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.circulate.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.holdable.label'),
+ {
+ render: 'fm.holdable() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.holdable() ) ? $("catStrings").getString("staff.cat.copy_editor.field.holdable.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.holdable.no_or_false") )',
+ input: 'c = function(v){ g.apply("holdable",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.holdable.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.holdable.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.age_based_hold_protection.label'),
+ {
+ render: 'fm.age_protect() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( typeof fm.age_protect() == "object" ? fm.age_protect().name() : g.data.hash.crahp[ fm.age_protect() ].name() )',
+ input: 'c = function(v){ g.apply("age_protect",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.remove_age_based_hold_protection"), "<HACK:KLUDGE:NULL>" ] ].concat( util.functional.map_list( g.data.list.crahp, function(obj) { return [ obj.name(), obj.id() ]; }).sort() ) ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.loan_duration.label'),
+ {
+ render: 'switch(Number(fm.loan_duration())){ case 1: $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.short"); break; case 2: $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.normal"); break; case 3: $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.extended"); break; }',
+ input: 'c = function(v){ g.apply("loan_duration",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.short"), "1" ], [ $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.normal"), "2" ], [ $("catStrings").getString("staff.cat.copy_editor.field.loan_duration.extended"), "3" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.fine_level.label'),
+ {
+ render: 'switch(Number(fm.fine_level())){ case 1: $("catStrings").getString("staff.cat.copy_editor.field.fine_level.low"); break; case 2: $("catStrings").getString("staff.cat.copy_editor.field.fine_level.normal"); break; case 3: $("catStrings").getString("staff.cat.copy_editor.field.fine_level.high"); break; }',
+ input: 'c = function(v){ g.apply("fine_level",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.fine_level.low"), "1" ], [ $("catStrings").getString("staff.cat.copy_editor.field.fine_level.normal"), "2" ], [ $("catStrings").getString("staff.cat.copy_editor.field.fine_level.high"), "3" ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
+
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.circulate_as_type.label'),
+ {
+ render: 'fm.circ_as_type() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : g.data.hash.citm[ fm.circ_as_type() ].value()',
+ input: 'c = function(v){ g.apply("circ_as_type",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.remove_circulate_as_type"), "<HACK:KLUDGE:NULL>" ] ].concat( util.functional.map_list( g.data.list.citm, function(n){return [ n.code() + " - " + n.value(), n.code()];} ).sort() ) ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.circulation_modifier.label'),
+ {
+ render: 'fm.circ_modifier() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : fm.circ_modifier()',
+ input: 'c = function(v){ g.apply("circ_modifier",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null"), "<HACK:KLUDGE:NULL>" ] ].concat( util.functional.map_list( g.data.list.circ_modifier, function(obj) { return [ obj, obj ]; } ).sort() ) ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
],
'right_pane3' :
-[ [
- $('catStrings').getString('staff.cat.copy_editor.field.alert_message.label'),
- {
- render: 'fm.alert_message() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : fm.alert_message()',
- input: 'c = function(v){ g.apply("alert_message",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("multiline",true); g.populate_alert_message_input(x); x.addEventListener("apply",function(f){ return function(ev) { f( ev.target.value ); } }(c), false);',
- }
- ],
-
- [
- $('catStrings').getString('staff.cat.copy_editor.field.deposit.label'),
- {
- render: 'fm.deposit() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.deposit() ) ? $("catStrings").getString("staff.cat.copy_editor.field.deposit.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.deposit.no_or_false") )',
- input: 'c = function(v){ g.apply("deposit",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.deposit.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.deposit.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.deposit_amount.label'),
- {
- render: 'if (fm.deposit_amount() == null) { $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null"); } else { util.money.sanitize( fm.deposit_amount() ); }',
- input: 'c = function(v){ g.apply("deposit_amount",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.price.label'),
- {
- render: 'if (fm.price() == null) { $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null"); } else { util.money.sanitize( fm.price() ); }',
- input: 'c = function(v){ g.apply("price",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
-
- [
- $('catStrings').getString('staff.cat.copy_editor.field.opac_visible.label'),
- {
- render: 'fm.opac_visible() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.opac_visible() ) ? $("catStrings").getString("staff.cat.copy_editor.field.opac_visible.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.opac_visible.no_or_false") )',
- input: 'c = function(v){ g.apply("opac_visible",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.opac_visible.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.opac_visible.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
- [
- $('catStrings').getString('staff.cat.copy_editor.field.reference.label'),
- {
- render: 'fm.ref() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.ref() ) ? $("catStrings").getString("staff.cat.copy_editor.field.reference.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.reference.no_or_false") )',
- input: 'c = function(v){ g.apply("ref",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.reference.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.reference.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
- }
- ],
+[ [
+ $('catStrings').getString('staff.cat.copy_editor.field.alert_message.label'),
+ {
+ render: 'fm.alert_message() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : fm.alert_message()',
+ input: 'c = function(v){ g.apply("alert_message",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("multiline",true); g.populate_alert_message_input(x); x.addEventListener("apply",function(f){ return function(ev) { f( ev.target.value ); } }(c), false);',
+ }
+ ],
+
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.deposit.label'),
+ {
+ render: 'fm.deposit() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.deposit() ) ? $("catStrings").getString("staff.cat.copy_editor.field.deposit.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.deposit.no_or_false") )',
+ input: 'c = function(v){ g.apply("deposit",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.deposit.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.deposit.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.deposit_amount.label'),
+ {
+ render: 'if (fm.deposit_amount() == null) { $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null"); } else { util.money.sanitize( fm.deposit_amount() ); }',
+ input: 'c = function(v){ g.apply("deposit_amount",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.price.label'),
+ {
+ render: 'if (fm.price() == null) { $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null"); } else { util.money.sanitize( fm.price() ); }',
+ input: 'c = function(v){ g.apply("price",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
+
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.opac_visible.label'),
+ {
+ render: 'fm.opac_visible() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.opac_visible() ) ? $("catStrings").getString("staff.cat.copy_editor.field.opac_visible.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.opac_visible.no_or_false") )',
+ input: 'c = function(v){ g.apply("opac_visible",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.opac_visible.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.opac_visible.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
+ [
+ $('catStrings').getString('staff.cat.copy_editor.field.reference.label'),
+ {
+ render: 'fm.ref() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.ref() ) ? $("catStrings").getString("staff.cat.copy_editor.field.reference.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.reference.no_or_false") )',
+ input: 'c = function(v){ g.apply("ref",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.reference.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.reference.no_or_false"), get_db_false() ] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
+ }
+ ],
],
'right_pane4' :
/* This loops through all our fieldnames and all the copies, tallying up counts for the different values */
g.summarize = function( copies ) {
- /******************************************************************************************************/
- /* Setup */
-
- JSAN.use('util.date'); JSAN.use('util.money');
- g.summary = {};
- g.field_names = [];
- for (var i in g.panes_and_field_names) {
- g.field_names = g.field_names.concat( g.panes_and_field_names[i] );
- }
- g.field_names = g.field_names.concat( g.editable_stat_cat_names );
- g.field_names = g.field_names.concat( g.readonly_stat_cat_names );
+ /******************************************************************************************************/
+ /* Setup */
+
+ JSAN.use('util.date'); JSAN.use('util.money');
+ g.summary = {};
+ g.field_names = [];
+ for (var i in g.panes_and_field_names) {
+ g.field_names = g.field_names.concat( g.panes_and_field_names[i] );
+ }
+ g.field_names = g.field_names.concat( g.editable_stat_cat_names );
+ g.field_names = g.field_names.concat( g.readonly_stat_cat_names );
- /******************************************************************************************************/
- /* Loop through the field names */
+ /******************************************************************************************************/
+ /* Loop through the field names */
- for (var i = 0; i < g.field_names.length; i++) {
+ for (var i = 0; i < g.field_names.length; i++) {
- var field_name = g.field_names[i][0];
- var render = g.field_names[i][1].render;
+ var field_name = g.field_names[i][0];
+ var render = g.field_names[i][1].render;
var attr = g.field_names[i][1].attr;
- g.summary[ field_name ] = {};
-
- /******************************************************************************************************/
- /* Loop through the copies */
-
- for (var j = 0; j < copies.length; j++) {
-
- var fm = copies[j];
- var cmd = render || ('fm.' + field_name + '();');
- var value = '???';
-
- /**********************************************************************************************/
- /* Try to retrieve the value for this field for this copy */
-
- try {
- value = eval( cmd );
- } catch(E) {
- g.error.sdump('D_ERROR','Attempted ' + cmd + '\n' + E + '\n');
- }
- if (typeof value == 'object' && value != null) {
- alert('FIXME: field_name = <' + field_name + '> value = <' + js2JSON(value) + '>\n');
- }
-
- /**********************************************************************************************/
- /* Tally the count */
-
- if (g.summary[ field_name ][ value ]) {
- g.summary[ field_name ][ value ]++;
- } else {
- g.summary[ field_name ][ value ] = 1;
- }
- }
- }
- g.error.sdump('D_TRACE','summary = ' + js2JSON(g.summary) + '\n');
+ g.summary[ field_name ] = {};
+
+ /******************************************************************************************************/
+ /* Loop through the copies */
+
+ for (var j = 0; j < copies.length; j++) {
+
+ var fm = copies[j];
+ var cmd = render || ('fm.' + field_name + '();');
+ var value = '???';
+
+ /**********************************************************************************************/
+ /* Try to retrieve the value for this field for this copy */
+
+ try {
+ value = eval( cmd );
+ } catch(E) {
+ g.error.sdump('D_ERROR','Attempted ' + cmd + '\n' + E + '\n');
+ }
+ if (typeof value == 'object' && value != null) {
+ alert('FIXME: field_name = <' + field_name + '> value = <' + js2JSON(value) + '>\n');
+ }
+
+ /**********************************************************************************************/
+ /* Tally the count */
+
+ if (g.summary[ field_name ][ value ]) {
+ g.summary[ field_name ][ value ]++;
+ } else {
+ g.summary[ field_name ][ value ] = 1;
+ }
+ }
+ }
+ g.error.sdump('D_TRACE','summary = ' + js2JSON(g.summary) + '\n');
}
/******************************************************************************************************/
g.render = function() {
- /******************************************************************************************************/
- /* Library setup and clear any existing interface */
+ /******************************************************************************************************/
+ /* Library setup and clear any existing interface */
- JSAN.use('util.widgets'); JSAN.use('util.date'); JSAN.use('util.money'); JSAN.use('util.functional');
+ JSAN.use('util.widgets'); JSAN.use('util.date'); JSAN.use('util.money'); JSAN.use('util.functional');
- for (var i in g.panes_and_field_names) {
- var p = document.getElementById(i);
- if (p) util.widgets.remove_children(p);
- }
+ for (var i in g.panes_and_field_names) {
+ var p = document.getElementById(i);
+ if (p) util.widgets.remove_children(p);
+ }
- /******************************************************************************************************/
- /* Populate the library filter menu for stat cats */
+ /******************************************************************************************************/
+ /* Populate the library filter menu for stat cats */
var sc_libs = {};
for (var i = 0; i < g.panes_and_field_names.right_pane4.length; i++) {
x.appendChild(menuitem);
}
- /******************************************************************************************************/
- /* Prepare the panes */
+ /******************************************************************************************************/
+ /* Prepare the panes */
- var groupbox; var caption; var vbox; var grid; var rows;
-
- /******************************************************************************************************/
- /* Loop through the field names */
+ var groupbox; var caption; var vbox; var grid; var rows;
+
+ /******************************************************************************************************/
+ /* Loop through the field names */
- for (h in g.panes_and_field_names) {
- if (!document.getElementById(h)) continue;
- for (var i = 0; i < g.panes_and_field_names[h].length; i++) {
- try {
- var f = g.panes_and_field_names[h][i]; var fn = f[0]; var attr = f[1].attr;
- groupbox = document.createElement('groupbox'); document.getElementById(h).appendChild(groupbox);
+ for (h in g.panes_and_field_names) {
+ if (!document.getElementById(h)) continue;
+ for (var i = 0; i < g.panes_and_field_names[h].length; i++) {
+ try {
+ var f = g.panes_and_field_names[h][i]; var fn = f[0]; var attr = f[1].attr;
+ groupbox = document.createElement('groupbox'); document.getElementById(h).appendChild(groupbox);
if (attr) {
for (var a in attr) {
groupbox.setAttribute(a,attr[a]);
}
}
- if (typeof g.changed[fn] != 'undefined') groupbox.setAttribute('class','copy_editor_field_changed');
- caption = document.createElement('caption'); groupbox.appendChild(caption);
- caption.setAttribute('label',fn); caption.setAttribute('id','caption_'+fn);
- vbox = document.createElement('vbox'); groupbox.appendChild(vbox);
- grid = util.widgets.make_grid( [ { 'flex' : 1 }, {}, {} ] ); vbox.appendChild(grid);
- grid.setAttribute('flex','1');
- rows = grid.lastChild;
- var row;
-
- /**************************************************************************************/
- /* Loop through each value for the field */
-
- for (var j in g.summary[fn]) {
- var value = j; var count = g.summary[fn][j];
- row = document.createElement('row'); rows.appendChild(row);
- var label1 = document.createElement('description'); row.appendChild(label1);
- if (g.special_exception[ fn ]) {
- g.special_exception[ fn ]( label1, value );
- } else {
- label1.appendChild( document.createTextNode(value) );
- }
- var label2 = document.createElement('description'); row.appendChild(label2);
- var copy_count;
- if (count == 1) {
- copy_count = $('catStrings').getString('staff.cat.copy_editor.copy_count');
- } else {
- copy_count = $('catStrings').getFormattedString('staff.cat.copy_editor.copy_count.plural', [count]);
- }
- label2.appendChild( document.createTextNode(copy_count) );
- }
- var hbox = document.createElement('hbox');
- hbox.setAttribute('id',fn);
- groupbox.appendChild(hbox);
- var hbox2 = document.createElement('hbox');
- groupbox.appendChild(hbox2);
-
- /**************************************************************************************/
- /* Render the input widget */
-
- if (f[1].input && g.edit) {
- g.render_input(hbox,f[1]);
- }
-
- } catch(E) {
- g.error.sdump('D_ERROR','copy editor: ' + E + '\n');
- }
- }
- }
+ if (typeof g.changed[fn] != 'undefined') groupbox.setAttribute('class','copy_editor_field_changed');
+ caption = document.createElement('caption'); groupbox.appendChild(caption);
+ caption.setAttribute('label',fn); caption.setAttribute('id','caption_'+fn);
+ vbox = document.createElement('vbox'); groupbox.appendChild(vbox);
+ grid = util.widgets.make_grid( [ { 'flex' : 1 }, {}, {} ] ); vbox.appendChild(grid);
+ grid.setAttribute('flex','1');
+ rows = grid.lastChild;
+ var row;
+
+ /**************************************************************************************/
+ /* Loop through each value for the field */
+
+ for (var j in g.summary[fn]) {
+ var value = j; var count = g.summary[fn][j];
+ row = document.createElement('row'); rows.appendChild(row);
+ var label1 = document.createElement('description'); row.appendChild(label1);
+ if (g.special_exception[ fn ]) {
+ g.special_exception[ fn ]( label1, value );
+ } else {
+ label1.appendChild( document.createTextNode(value) );
+ }
+ var label2 = document.createElement('description'); row.appendChild(label2);
+ var copy_count;
+ if (count == 1) {
+ copy_count = $('catStrings').getString('staff.cat.copy_editor.copy_count');
+ } else {
+ copy_count = $('catStrings').getFormattedString('staff.cat.copy_editor.copy_count.plural', [count]);
+ }
+ label2.appendChild( document.createTextNode(copy_count) );
+ }
+ var hbox = document.createElement('hbox');
+ hbox.setAttribute('id',fn);
+ groupbox.appendChild(hbox);
+ var hbox2 = document.createElement('hbox');
+ groupbox.appendChild(hbox2);
+
+ /**************************************************************************************/
+ /* Render the input widget */
+
+ if (f[1].input && g.edit) {
+ g.render_input(hbox,f[1]);
+ }
+
+ } catch(E) {
+ g.error.sdump('D_ERROR','copy editor: ' + E + '\n');
+ }
+ }
+ }
- /******************************************************************************************************/
- /* Synchronize stat cat visibility with library filter menu, and default template selection */
+ /******************************************************************************************************/
+ /* Synchronize stat cat visibility with library filter menu, and default template selection */
JSAN.use('util.file');
- var file = new util.file('copy_editor_prefs.'+g.data.server_unadorned);
- g.copy_editor_prefs = util.widgets.load_attributes(file);
+ var file = new util.file('copy_editor_prefs.'+g.data.server_unadorned);
+ g.copy_editor_prefs = util.widgets.load_attributes(file);
for (var i in g.copy_editor_prefs) {
if (i.match(/filter_/) && g.copy_editor_prefs[i].checked == '') {
try {
/******************************************************************************************************/
/* This actually draws the change button and input widget for a given field */
g.render_input = function(node,blob) {
- try {
- // node = hbox ; groupbox -> hbox, hbox
+ try {
+ // node = hbox ; groupbox -> hbox, hbox
- var groupbox = node.parentNode;
- var caption = groupbox.firstChild;
- var vbox = node.previousSibling;
- var hbox = node;
- var hbox2 = node.nextSibling;
+ var groupbox = node.parentNode;
+ var caption = groupbox.firstChild;
+ var vbox = node.previousSibling;
+ var hbox = node;
+ var hbox2 = node.nextSibling;
- var input_cmd = blob.input;
- var render_cmd = blob.render;
+ var input_cmd = blob.input;
+ var render_cmd = blob.render;
var attr = blob.attr;
- var block = false; var first = true;
-
- function on_mouseover(ev) {
- groupbox.setAttribute('style','background: white');
- }
-
- function on_mouseout(ev) {
- groupbox.setAttribute('style','');
- }
-
- vbox.addEventListener('mouseover',on_mouseover,false);
- vbox.addEventListener('mouseout',on_mouseout,false);
- groupbox.addEventListener('mouseover',on_mouseover,false);
- groupbox.addEventListener('mouseout',on_mouseout,false);
- groupbox.firstChild.addEventListener('mouseover',on_mouseover,false);
- groupbox.firstChild.addEventListener('mouseout',on_mouseout,false);
-
- function on_click(ev){
- try {
- if (block) return; block = true;
-
- function post_c(v) {
- try {
- /* FIXME - kludgy */
- var t = input_cmd.match('apply_stat_cat') ? 'stat_cat' : ( input_cmd.match('apply_owning_lib') ? 'owning_lib' : 'attribute' );
- var f;
- switch(t) {
- case 'attribute' :
- f = input_cmd.match(/apply\("(.+?)",/)[1];
- break;
- case 'stat_cat' :
- f = input_cmd.match(/apply_stat_cat\((.+?),/)[1];
- break;
- case 'owning_lib' :
- f = null;
- break;
- }
- g.changed[ hbox.id ] = { 'type' : t, 'field' : f, 'value' : v };
- block = false;
- setTimeout(
- function() {
- g.summarize( g.copies );
- g.render();
- document.getElementById(caption.id).focus();
- }, 0
- );
- } catch(E) {
- g.error.standard_unexpected_error_alert('post_c',E);
- }
- }
- var x; var c; eval( input_cmd );
- if (x) {
- util.widgets.remove_children(vbox);
- util.widgets.remove_children(hbox);
- util.widgets.remove_children(hbox2);
- hbox.appendChild(x);
- var apply = document.createElement('button');
- apply.setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.apply.label'));
- apply.setAttribute('accesskey', $('catStrings').getString('staff.cat.copy_editor.apply.accesskey'));
- hbox2.appendChild(apply);
- apply.addEventListener('command',function() { c(x.value); },false);
- var cancel = document.createElement('button');
- cancel.setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.cancel.label'));
- cancel.addEventListener('command',function() { setTimeout( function() { g.summarize( g.copies ); g.render(); document.getElementById(caption.id).focus(); }, 0); }, false);
- hbox2.appendChild(cancel);
- setTimeout( function() { x.focus(); }, 0 );
- }
- } catch(E) {
- g.error.standard_unexpected_error_alert('render_input',E);
- }
- }
- vbox.addEventListener('click',on_click, false);
- hbox.addEventListener('click',on_click, false);
- caption.addEventListener('click',on_click, false);
- caption.addEventListener('keypress',function(ev) {
- if (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* mac enter */) on_click();
- }, false);
- caption.setAttribute('style','-moz-user-focus: normal');
- caption.setAttribute('onfocus','this.setAttribute("class","outline_me")');
- caption.setAttribute('onblur','this.setAttribute("class","")');
-
- } catch(E) {
- g.error.sdump('D_ERROR',E + '\n');
- }
+ var block = false; var first = true;
+
+ function on_mouseover(ev) {
+ groupbox.setAttribute('style','background: white');
+ }
+
+ function on_mouseout(ev) {
+ groupbox.setAttribute('style','');
+ }
+
+ vbox.addEventListener('mouseover',on_mouseover,false);
+ vbox.addEventListener('mouseout',on_mouseout,false);
+ groupbox.addEventListener('mouseover',on_mouseover,false);
+ groupbox.addEventListener('mouseout',on_mouseout,false);
+ groupbox.firstChild.addEventListener('mouseover',on_mouseover,false);
+ groupbox.firstChild.addEventListener('mouseout',on_mouseout,false);
+
+ function on_click(ev){
+ try {
+ if (block) return; block = true;
+
+ function post_c(v) {
+ try {
+ /* FIXME - kludgy */
+ var t = input_cmd.match('apply_stat_cat') ? 'stat_cat' : ( input_cmd.match('apply_owning_lib') ? 'owning_lib' : 'attribute' );
+ var f;
+ switch(t) {
+ case 'attribute' :
+ f = input_cmd.match(/apply\("(.+?)",/)[1];
+ break;
+ case 'stat_cat' :
+ f = input_cmd.match(/apply_stat_cat\((.+?),/)[1];
+ break;
+ case 'owning_lib' :
+ f = null;
+ break;
+ }
+ g.changed[ hbox.id ] = { 'type' : t, 'field' : f, 'value' : v };
+ block = false;
+ setTimeout(
+ function() {
+ g.summarize( g.copies );
+ g.render();
+ document.getElementById(caption.id).focus();
+ }, 0
+ );
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('post_c',E);
+ }
+ }
+ var x; var c; eval( input_cmd );
+ if (x) {
+ util.widgets.remove_children(vbox);
+ util.widgets.remove_children(hbox);
+ util.widgets.remove_children(hbox2);
+ hbox.appendChild(x);
+ var apply = document.createElement('button');
+ apply.setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.apply.label'));
+ apply.setAttribute('accesskey', $('catStrings').getString('staff.cat.copy_editor.apply.accesskey'));
+ hbox2.appendChild(apply);
+ apply.addEventListener('command',function() { c(x.value); },false);
+ var cancel = document.createElement('button');
+ cancel.setAttribute('label', $('catStrings').getString('staff.cat.copy_editor.cancel.label'));
+ cancel.addEventListener('command',function() { setTimeout( function() { g.summarize( g.copies ); g.render(); document.getElementById(caption.id).focus(); }, 0); }, false);
+ hbox2.appendChild(cancel);
+ setTimeout( function() { x.focus(); }, 0 );
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('render_input',E);
+ }
+ }
+ vbox.addEventListener('click',on_click, false);
+ hbox.addEventListener('click',on_click, false);
+ caption.addEventListener('click',on_click, false);
+ caption.addEventListener('keypress',function(ev) {
+ if (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* mac enter */) on_click();
+ }, false);
+ caption.setAttribute('style','-moz-user-focus: normal');
+ caption.setAttribute('onfocus','this.setAttribute("class","outline_me")');
+ caption.setAttribute('onblur','this.setAttribute("class","")');
+
+ } catch(E) {
+ g.error.sdump('D_ERROR',E + '\n');
+ }
}
/******************************************************************************************************/
/* store the copies in the global xpcom stash */
g.stash_and_close = function() {
- try {
- if (g.handle_update) {
- try {
- var r = g.network.request(
- api.FM_ACP_FLESHED_BATCH_UPDATE.app,
- api.FM_ACP_FLESHED_BATCH_UPDATE.method,
- [ ses(), g.copies, true ]
- );
- if (typeof r.ilsevent != 'undefined') {
- g.error.standard_unexpected_error_alert('copy update',r);
- } else {
- alert($('catStrings').getString('staff.cat.copy_editor.handle_update.success'));
- }
- /* FIXME -- revisit the return value here */
- } catch(E) {
- alert($('catStrings').getString('staff.cat.copy_editor.handle_update.error') + ' ' + js2JSON(E));
- }
- }
- //g.data.temp_copies = js2JSON( g.copies );
- //g.data.stash('temp_copies');
- xulG.copies = g.copies;
- update_modal_xulG(xulG);
- window.close();
- } catch(E) {
- g.error.standard_unexpected_error_alert('stash and close',E);
- }
+ try {
+ if (g.handle_update) {
+ try {
+ var r = g.network.request(
+ api.FM_ACP_FLESHED_BATCH_UPDATE.app,
+ api.FM_ACP_FLESHED_BATCH_UPDATE.method,
+ [ ses(), g.copies, true ]
+ );
+ if (typeof r.ilsevent != 'undefined') {
+ g.error.standard_unexpected_error_alert('copy update',r);
+ } else {
+ alert($('catStrings').getString('staff.cat.copy_editor.handle_update.success'));
+ }
+ /* FIXME -- revisit the return value here */
+ } catch(E) {
+ alert($('catStrings').getString('staff.cat.copy_editor.handle_update.error') + ' ' + js2JSON(E));
+ }
+ }
+ //g.data.temp_copies = js2JSON( g.copies );
+ //g.data.stash('temp_copies');
+ xulG.copies = g.copies;
+ update_modal_xulG(xulG);
+ window.close();
+ } catch(E) {
+ g.error.standard_unexpected_error_alert('stash and close',E);
+ }
}
/******************************************************************************************************/
/* spawn copy notes interface */
g.copy_notes = function() {
- JSAN.use('util.window'); var win = new util.window();
- win.open(
- urls.XUL_COPY_NOTES,
- //+ '?copy_id=' + window.escape(g.copies[0].id()),
- $("catStrings").getString("staff.cat.copy_editor.copy_notes"),'chrome,resizable,modal',
- { 'copy_id' : g.copies[0].id() }
- );
+ JSAN.use('util.window'); var win = new util.window();
+ win.open(
+ urls.XUL_COPY_NOTES,
+ //+ '?copy_id=' + window.escape(g.copies[0].id()),
+ $("catStrings").getString("staff.cat.copy_editor.copy_notes"),'chrome,resizable,modal',
+ { 'copy_id' : g.copies[0].id() }
+ );
}
/******************************************************************************************************/
/******************************************************************************************************/
/* This adds a stat cat definition to the stat cat pane for rendering */
g.save_attributes = function() {
- JSAN.use('util.widgets'); JSAN.use('util.file'); var file = new util.file('copy_editor_prefs.'+g.data.server_unadorned);
+ JSAN.use('util.widgets'); JSAN.use('util.file'); var file = new util.file('copy_editor_prefs.'+g.data.server_unadorned);
var what_to_save = {};
for (var i in g.copy_editor_prefs) {
what_to_save[i] = [];
for (var j in g.copy_editor_prefs[i]) what_to_save[i].push(j);
}
- util.widgets.save_attributes(file, what_to_save );
+ util.widgets.save_attributes(file, what_to_save );
}
/******************************************************************************************************/
/* This adds a stat cat definition to the stat cat pane for rendering */
g.add_stat_cat = function(sc) {
try {
- if (typeof g.data.hash.asc == 'undefined') { g.data.hash.asc = {}; g.data.stash('hash'); }
+ if (typeof g.data.hash.asc == 'undefined') { g.data.hash.asc = {}; g.data.stash('hash'); }
- var sc_id = sc;
+ var sc_id = sc;
- if (typeof sc == 'object') {
+ if (typeof sc == 'object') {
- sc_id = sc.id();
- }
+ sc_id = sc.id();
+ }
- if (typeof g.stat_cat_seen[sc_id] != 'undefined') { return; }
+ if (typeof g.stat_cat_seen[sc_id] != 'undefined') { return; }
- g.stat_cat_seen[ sc_id ] = 1;
+ g.stat_cat_seen[ sc_id ] = 1;
- if (typeof sc != 'object') {
+ if (typeof sc != 'object') {
- sc = g.network.simple_request(
- 'FM_ASC_BATCH_RETRIEVE',
- [ ses(), [ sc_id ] ]
- )[0];
+ sc = g.network.simple_request(
+ 'FM_ASC_BATCH_RETRIEVE',
+ [ ses(), [ sc_id ] ]
+ )[0];
- }
+ }
- g.data.hash.asc[ sc.id() ] = sc; g.data.stash('hash');
+ g.data.hash.asc[ sc.id() ] = sc; g.data.stash('hash');
- var label_name = g.data.hash.aou[ sc.owner() ].shortname() + " : " + sc.name();
+ var label_name = g.data.hash.aou[ sc.owner() ].shortname() + " : " + sc.name();
- var temp_array = [
- label_name,
- {
- render: 'var l = util.functional.find_list( fm.stat_cat_entries(), function(e){ return e.stat_cat() == '
- + sc.id() + '; } ); l ? l.value() : $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null");',
- input: 'c = function(v){ g.apply_stat_cat(' + sc.id() + ',v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.remove_stat_cat_entry"), -1 ] ].concat( util.functional.map_list( g.data.hash.asc[' + sc.id()
- + '].entries(), function(obj){ return [ obj.value(), obj.id() ]; } ) ).sort() ); '
- + 'x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c),false);',
+ var temp_array = [
+ label_name,
+ {
+ render: 'var l = util.functional.find_list( fm.stat_cat_entries(), function(e){ return e.stat_cat() == '
+ + sc.id() + '; } ); l ? l.value() : $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null");',
+ input: 'c = function(v){ g.apply_stat_cat(' + sc.id() + ',v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.remove_stat_cat_entry"), -1 ] ].concat( util.functional.map_list( g.data.hash.asc[' + sc.id()
+ + '].entries(), function(obj){ return [ obj.value(), obj.id() ]; } ) ).sort() ); '
+ + 'x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c),false);',
attr: {
sc_lib: sc.owner(),
}
- }
- ];
+ }
+ ];
- g.panes_and_field_names.right_pane4.push( temp_array );
- } catch(E) {
- g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.add_stat_cat.error'), E);
+ g.panes_and_field_names.right_pane4.push( temp_array );
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.add_stat_cat.error'), E);
}
}
g.populate_stat_cats = function() {
try {
g.data.stash_retrieve();
- g.stat_cat_seen = {};
+ g.stat_cat_seen = {};
- function get(lib_id,only_these) {
+ function get(lib_id,only_these) {
g.data.stash_retrieve();
- var label = 'asc_list_for_lib_'+lib_id;
- if (typeof g.data[label] == 'undefined') {
- var robj = g.network.simple_request('FM_ASC_RETRIEVE_VIA_AOU', [ ses(), lib_id ]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- var temp_list = [];
- for (var j = 0; j < robj.length; j++) {
- var my_asc = robj[j];
+ var label = 'asc_list_for_lib_'+lib_id;
+ if (typeof g.data[label] == 'undefined') {
+ var robj = g.network.simple_request('FM_ASC_RETRIEVE_VIA_AOU', [ ses(), lib_id ]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ var temp_list = [];
+ for (var j = 0; j < robj.length; j++) {
+ var my_asc = robj[j];
if (typeof g.data.hash.asc == 'undefined') { g.data.hash.asc = {}; }
- if (typeof g.data.hash.asc[ my_asc.id() ] == 'undefined') {
- g.data.hash.asc[ my_asc.id() ] = my_asc;
- }
+ if (typeof g.data.hash.asc[ my_asc.id() ] == 'undefined') {
+ g.data.hash.asc[ my_asc.id() ] = my_asc;
+ }
var only_this_lib = my_asc.owner(); if (typeof only_this_lib == 'object') only_this_lib = only_this_lib.id();
- if (only_these.indexOf( String( only_this_lib ) ) != -1) {
- temp_list.push( my_asc );
- }
- }
- g.data[label] = temp_list; g.data.stash(label,'hash','list');
- }
- return g.data[label];
- }
-
- /* The stat cats for the pertinent library -- this is based on workstation ou */
+ if (only_these.indexOf( String( only_this_lib ) ) != -1) {
+ temp_list.push( my_asc );
+ }
+ }
+ g.data[label] = temp_list; g.data.stash(label,'hash','list');
+ }
+ return g.data[label];
+ }
+
+ /* The stat cats for the pertinent library -- this is based on workstation ou */
var label = 'asc_list_for_' + typeof g.data.ws_ou == 'object' ? g.data.ws_ou.id() : g.data.ws_ou;
g.data[ label ] = g.data.list.my_asc; g.data.stash('label');
- for (var i = 0; i < g.data.list.my_asc.length; i++) {
- g.add_stat_cat( g.data.list.my_asc[i] );
- }
+ for (var i = 0; i < g.data.list.my_asc.length; i++) {
+ g.add_stat_cat( g.data.list.my_asc[i] );
+ }
/* For the others, we want to consider the owning libs, circ libs, and any libs that have stat cats already on the copies,
however, if batch editing, we only want to show the ones they have in common. So let's compile the libs */
}
}
- /* stat cats based on stat cat entries present on these copies */
+ /* stat cats based on stat cat entries present on these copies */
var sc_libs = {};
- for (var i = 0; i < g.copies.length; i++) {
- var entries = g.copies[i].stat_cat_entries();
- if (!entries) entries = [];
- for (var j = 0; j < entries.length; j++) {
+ for (var i = 0; i < g.copies.length; i++) {
+ var entries = g.copies[i].stat_cat_entries();
+ if (!entries) entries = [];
+ for (var j = 0; j < entries.length; j++) {
var lib = entries[j].owner(); if (typeof lib == 'object') lib = lib.id();
- sc_libs[ lib ] = true;
- }
+ sc_libs[ lib ] = true;
+ }
}
add_common_ancestors(sc_libs); // CAVEAT - if a copy has no stat_cat_entries, it basically gets no vote here
/* stat cats based on Circ Lib */
sc_libs = {};
- for (var i = 0; i < g.copies.length; i++) {
+ for (var i = 0; i < g.copies.length; i++) {
var circ_lib = g.copies[i].circ_lib(); if (typeof circ_lib == 'object') circ_lib = circ_lib.id();
sc_libs[ circ_lib ] = true;
}
/* stat cats based on Owning Lib */
sc_libs = {};
- for (var i = 0; i < g.copies.length; i++) {
+ for (var i = 0; i < g.copies.length; i++) {
var cn_id = g.copies[i].call_number();
- if (cn_id > 0) {
- if (! g.map_acn[ cn_id ]) {
+ if (cn_id > 0) {
+ if (! g.map_acn[ cn_id ]) {
var req = g.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ cn_id ]);
if (typeof req.ilsevent == 'undefined') {
- g.map_acn[ cn_id ] = req;
+ g.map_acn[ cn_id ] = req;
} else {
continue;
}
- }
+ }
var owning_lib = g.map_acn[ cn_id ].owning_lib(); if (typeof owning_lib == 'object') owning_lib = owning_lib.id();
sc_libs[ owning_lib ] = true;
- }
- }
+ }
+ }
add_common_ancestors(sc_libs); // CAVEAT - if a copy is a pre-cat, it basically gets no vote here
g.panes_and_field_names.right_pane4.sort();
} catch(E) {
- alert(E);
+ alert(E);
g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_editor.populate_stat_cat.error'),E);
}
}
function $(id) { return document.getElementById(id); }
function mangle_005() {
- var now = new Date();
- var y = now.getUTCFullYear();
-
- var m = now.getUTCMonth() + 1;
- if (m < 10) m = '0' + m;
-
- var d = now.getUTCDate();
- if (d < 10) d = '0' + d;
-
- var H = now.getUTCHours();
- if (H < 10) H = '0' + H;
-
- var M = now.getUTCMinutes();
- if (M < 10) M = '0' + M;
-
- var S = now.getUTCSeconds();
- if (S < 10) S = '0' + S;
-
-
- var stamp = '' + y + m + d + H + M + S + '.0';
- createControlField('005',stamp);
+ var now = new Date();
+ var y = now.getUTCFullYear();
+
+ var m = now.getUTCMonth() + 1;
+ if (m < 10) m = '0' + m;
+
+ var d = now.getUTCDate();
+ if (d < 10) d = '0' + d;
+
+ var H = now.getUTCHours();
+ if (H < 10) H = '0' + H;
+
+ var M = now.getUTCMinutes();
+ if (M < 10) M = '0' + M;
+
+ var S = now.getUTCSeconds();
+ if (S < 10) S = '0' + S;
+
+
+ var stamp = '' + y + m + d + H + M + S + '.0';
+ createControlField('005',stamp);
}
function createControlField (tag,data) {
- // first, remove the old field, if any;
- for (var i in xml_record.controlfield.(@tag == tag)) delete xml_record.controlfield.(@tag == tag)[i];
-
- var cf = <controlfield tag="" xmlns="http://www.loc.gov/MARC21/slim">{ data }</controlfield>;
- cf.@tag = tag;
-
- // then, find the right position and insert it
- var done = 0;
- var cfields = xml_record.controlfield;
- var base = Number(tag.substring(2));
- for (var i in cfields) {
- var t = Number(cfields[i].@tag.toString().substring(2));
- if (t > base) {
- xml_record.insertChildBefore( cfields[i], cf );
- done = 1
- break;
- }
- }
-
- if (!done) xml_record.insertChildBefore( xml_record.datafield[0], cf );
-
- return cf;
+ // first, remove the old field, if any;
+ for (var i in xml_record.controlfield.(@tag == tag)) delete xml_record.controlfield.(@tag == tag)[i];
+
+ var cf = <controlfield tag="" xmlns="http://www.loc.gov/MARC21/slim">{ data }</controlfield>;
+ cf.@tag = tag;
+
+ // then, find the right position and insert it
+ var done = 0;
+ var cfields = xml_record.controlfield;
+ var base = Number(tag.substring(2));
+ for (var i in cfields) {
+ var t = Number(cfields[i].@tag.toString().substring(2));
+ if (t > base) {
+ xml_record.insertChildBefore( cfields[i], cf );
+ done = 1
+ break;
+ }
+ }
+
+ if (!done) xml_record.insertChildBefore( xml_record.datafield[0], cf );
+
+ return cf;
}
function xml_escape_unicode ( str ) {
- return str.replace(
- /([\u0080-\ufffe])/g,
- function (r,s) { return "&#x" + s.charCodeAt(0).toString(16) + ";"; }
- );
+ return str.replace(
+ /([\u0080-\ufffe])/g,
+ function (r,s) { return "&#x" + s.charCodeAt(0).toString(16) + ";"; }
+ );
}
function my_init() {
- try {
-
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
- JSAN.errorLevel = "die"; // none, warn, or die
- JSAN.addRepository('/xul/server/');
-
- // Fake xulG for standalone...
- try {
- window.xulG.record;
- } catch (e) {
- window.xulG = {};
- window.xulG.record = {};
- window.xulG.save = {};
-
- window.xulG.save.label = $('catStrings').getString('staff.cat.marcedit.save.label');
- window.xulG.save.func = function (r) { alert(r); }
-
- var cgi = new CGI();
- var _rid = cgi.param('record');
- if (_rid) {
- window.xulG.record.url = '/opac/extras/supercat/retrieve/marcxml/record/' + _rid;
- }
- }
- // End faking part...
-
- document.getElementById('save-button').setAttribute('label', window.xulG.save.label);
- document.getElementById('save-button').setAttribute('oncommand',
- 'mangle_005(); ' +
- 'var xml_string = xml_escape_unicode( xml_record.toXMLString() ); ' +
- 'save_attempt( xml_string ); ' +
- 'loadRecord(xml_record);'
- );
-
- if (window.xulG.record.url) {
- var req = new XMLHttpRequest();
- req.open('POST',window.xulG.record.url,false);
- req.send(null);
- window.xulG.record.marc = req.responseText.replace(xmlDeclaration, '');
- }
-
- xml_record = new XML( window.xulG.record.marc );
- if (xml_record..record[0]) xml_record = xml_record..record[0];
-
- // Get the tooltip xml all async like
- req = new XMLHttpRequest();
-
- // Set a default locale in case preferences fail us
- var locale = "en-US";
-
- // Try to get the locale from our preferences
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- try {
- const Cc = Components.classes;
- const Ci = Components.interfaces;
- locale = Cc["@mozilla.org/preferences-service;1"].
- getService(Ci.nsIPrefBranch).
- getCharPref("general.useragent.locale");
- }
- catch (e) { }
-
- // TODO: We should send a HEAD request to check for the existence of the desired file
- // then fall back to the default locale if preferred locale is not necessary;
- // however, for now we have a simplistic check:
- //
- // we currently have translations for only two locales; in the absence of a
- // valid locale, default to the almighty en-US
- if (locale != 'en-US' && locale != 'fr-CA') {
- locale = 'en-US';
- }
-
- // Get the locale-specific tooltips
- req.open('GET','/xul/server/locale/' + locale + '/marcedit-tooltips.xml',true);
-
- context_menus = createComplexXULElement('popupset');
- document.documentElement.appendChild( context_menus );
-
- tag_menu = createPopup({position : 'after_start', id : 'tags_popup'});
- context_menus.appendChild( tag_menu );
-
- tag_menu.appendChild(
- createMenuitem(
- { label : $('catStrings').getString('staff.cat.marcedit.add_row.label'),
- oncommand :
- 'var e = document.createEvent("KeyEvents");' +
- 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,13,0);' +
- 'current_focus.inputField.dispatchEvent(e);'
- }
- )
- );
-
- tag_menu.appendChild(
- createMenuitem(
- { label : $('catStrings').getString('staff.cat.marcedit.insert_row.label'),
- oncommand :
- 'var e = document.createEvent("KeyEvents");' +
- 'e.initKeyEvent("keypress",1,1,null,1,0,1,0,13,0);' +
- 'current_focus.inputField.dispatchEvent(e);'
- }
- )
- );
-
- tag_menu.appendChild(
- createMenuitem(
- { label : $('catStrings').getString('staff.cat.marcedit.remove_row.label'),
- oncommand :
- 'var e = document.createEvent("KeyEvents");' +
- 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,46,0);' +
- 'current_focus.inputField.dispatchEvent(e);'
- }
- )
- );
-
- tag_menu.appendChild( createComplexXULElement( 'separator' ) );
-
- tag_menu.appendChild(
- createMenuitem(
- { label : $('catStrings').getString('staff.cat.marcedit.replace_006.label'),
- oncommand :
- 'var e = document.createEvent("KeyEvents");' +
- 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,64,0);' +
- 'current_focus.inputField.dispatchEvent(e);'
- }
- )
- );
-
- tag_menu.appendChild(
- createMenuitem(
- { label : $('catStrings').getString('staff.cat.marcedit.replace_007.label'),
- oncommand :
- 'var e = document.createEvent("KeyEvents");' +
- 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,65,0);' +
- 'current_focus.inputField.dispatchEvent(e);'
- }
- )
- );
-
- tag_menu.appendChild(
- createMenuitem(
- { label : $('catStrings').getString('staff.cat.marcedit.replace_008.label'),
- oncommand :
- 'var e = document.createEvent("KeyEvents");' +
- 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,66,0);' +
- 'current_focus.inputField.dispatchEvent(e);'
- }
- )
- );
-
- tag_menu.appendChild( createComplexXULElement( 'separator' ) );
-
- p = createComplexXULElement('popupset');
- document.documentElement.appendChild( p );
-
- req.onreadystatechange = function () {
- if (req.readyState == 4) {
- bib_data = new XML( req.responseText.replace(xmlDeclaration, '') );
- genToolTips();
- }
- }
- req.send(null);
-
- loadRecord(xml_record);
+ try {
+
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
+ JSAN.errorLevel = "die"; // none, warn, or die
+ JSAN.addRepository('/xul/server/');
+
+ // Fake xulG for standalone...
+ try {
+ window.xulG.record;
+ } catch (e) {
+ window.xulG = {};
+ window.xulG.record = {};
+ window.xulG.save = {};
+
+ window.xulG.save.label = $('catStrings').getString('staff.cat.marcedit.save.label');
+ window.xulG.save.func = function (r) { alert(r); }
+
+ var cgi = new CGI();
+ var _rid = cgi.param('record');
+ if (_rid) {
+ window.xulG.record.url = '/opac/extras/supercat/retrieve/marcxml/record/' + _rid;
+ }
+ }
+ // End faking part...
+
+ document.getElementById('save-button').setAttribute('label', window.xulG.save.label);
+ document.getElementById('save-button').setAttribute('oncommand',
+ 'mangle_005(); ' +
+ 'var xml_string = xml_escape_unicode( xml_record.toXMLString() ); ' +
+ 'save_attempt( xml_string ); ' +
+ 'loadRecord(xml_record);'
+ );
+
+ if (window.xulG.record.url) {
+ var req = new XMLHttpRequest();
+ req.open('POST',window.xulG.record.url,false);
+ req.send(null);
+ window.xulG.record.marc = req.responseText.replace(xmlDeclaration, '');
+ }
+
+ xml_record = new XML( window.xulG.record.marc );
+ if (xml_record..record[0]) xml_record = xml_record..record[0];
+
+ // Get the tooltip xml all async like
+ req = new XMLHttpRequest();
+
+ // Set a default locale in case preferences fail us
+ var locale = "en-US";
+
+ // Try to get the locale from our preferences
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ try {
+ const Cc = Components.classes;
+ const Ci = Components.interfaces;
+ locale = Cc["@mozilla.org/preferences-service;1"].
+ getService(Ci.nsIPrefBranch).
+ getCharPref("general.useragent.locale");
+ }
+ catch (e) { }
+
+ // TODO: We should send a HEAD request to check for the existence of the desired file
+ // then fall back to the default locale if preferred locale is not necessary;
+ // however, for now we have a simplistic check:
+ //
+ // we currently have translations for only two locales; in the absence of a
+ // valid locale, default to the almighty en-US
+ if (locale != 'en-US' && locale != 'fr-CA') {
+ locale = 'en-US';
+ }
+
+ // Get the locale-specific tooltips
+ req.open('GET','/xul/server/locale/' + locale + '/marcedit-tooltips.xml',true);
+
+ context_menus = createComplexXULElement('popupset');
+ document.documentElement.appendChild( context_menus );
+
+ tag_menu = createPopup({position : 'after_start', id : 'tags_popup'});
+ context_menus.appendChild( tag_menu );
+
+ tag_menu.appendChild(
+ createMenuitem(
+ { label : $('catStrings').getString('staff.cat.marcedit.add_row.label'),
+ oncommand :
+ 'var e = document.createEvent("KeyEvents");' +
+ 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,13,0);' +
+ 'current_focus.inputField.dispatchEvent(e);'
+ }
+ )
+ );
+
+ tag_menu.appendChild(
+ createMenuitem(
+ { label : $('catStrings').getString('staff.cat.marcedit.insert_row.label'),
+ oncommand :
+ 'var e = document.createEvent("KeyEvents");' +
+ 'e.initKeyEvent("keypress",1,1,null,1,0,1,0,13,0);' +
+ 'current_focus.inputField.dispatchEvent(e);'
+ }
+ )
+ );
+
+ tag_menu.appendChild(
+ createMenuitem(
+ { label : $('catStrings').getString('staff.cat.marcedit.remove_row.label'),
+ oncommand :
+ 'var e = document.createEvent("KeyEvents");' +
+ 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,46,0);' +
+ 'current_focus.inputField.dispatchEvent(e);'
+ }
+ )
+ );
+
+ tag_menu.appendChild( createComplexXULElement( 'separator' ) );
+
+ tag_menu.appendChild(
+ createMenuitem(
+ { label : $('catStrings').getString('staff.cat.marcedit.replace_006.label'),
+ oncommand :
+ 'var e = document.createEvent("KeyEvents");' +
+ 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,64,0);' +
+ 'current_focus.inputField.dispatchEvent(e);'
+ }
+ )
+ );
+
+ tag_menu.appendChild(
+ createMenuitem(
+ { label : $('catStrings').getString('staff.cat.marcedit.replace_007.label'),
+ oncommand :
+ 'var e = document.createEvent("KeyEvents");' +
+ 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,65,0);' +
+ 'current_focus.inputField.dispatchEvent(e);'
+ }
+ )
+ );
+
+ tag_menu.appendChild(
+ createMenuitem(
+ { label : $('catStrings').getString('staff.cat.marcedit.replace_008.label'),
+ oncommand :
+ 'var e = document.createEvent("KeyEvents");' +
+ 'e.initKeyEvent("keypress",1,1,null,1,0,0,0,66,0);' +
+ 'current_focus.inputField.dispatchEvent(e);'
+ }
+ )
+ );
+
+ tag_menu.appendChild( createComplexXULElement( 'separator' ) );
+
+ p = createComplexXULElement('popupset');
+ document.documentElement.appendChild( p );
+
+ req.onreadystatechange = function () {
+ if (req.readyState == 4) {
+ bib_data = new XML( req.responseText.replace(xmlDeclaration, '') );
+ genToolTips();
+ }
+ }
+ req.send(null);
+
+ loadRecord(xml_record);
if (! xulG.fast_add_item) {
document.getElementById('fastItemAdd_checkbox').hidden = true;
}
document.getElementById('fastItemAdd_textboxes').hidden = document.getElementById('fastItemAdd_checkbox').hidden || !document.getElementById('fastItemAdd_checkbox').checked;
- } catch(E) {
- alert('FIXME, MARC Editor, my_init: ' + E);
- }
+ } catch(E) {
+ alert('FIXME, MARC Editor, my_init: ' + E);
+ }
}
function createComplexHTMLElement (e, attrs, objects, text) {
- var l = document.createElementNS('http://www.w3.org/1999/xhtml',e);
+ var l = document.createElementNS('http://www.w3.org/1999/xhtml',e);
- if (attrs) {
- for (var i in attrs) l.setAttribute(i,attrs[i]);
- }
+ if (attrs) {
+ for (var i in attrs) l.setAttribute(i,attrs[i]);
+ }
- if (objects) {
- for ( var i in objects ) l.appendChild( objects[i] );
- }
+ if (objects) {
+ for ( var i in objects ) l.appendChild( objects[i] );
+ }
- if (text) {
- l.appendChild( document.createTextNode(text) )
- }
+ if (text) {
+ l.appendChild( document.createTextNode(text) )
+ }
- return l;
+ return l;
}
function createComplexXULElement (e, attrs, objects) {
- var l = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul',e);
-
- if (attrs) {
- for (var i in attrs) {
- if (typeof attrs[i] == 'function') {
- l.addEventListener( i, attrs[i], true );
- } else {
- l.setAttribute(i,attrs[i]);
- }
- }
- }
-
- if (objects) {
- for ( var i in objects ) l.appendChild( objects[i] );
- }
-
- return l;
+ var l = document.createElementNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul',e);
+
+ if (attrs) {
+ for (var i in attrs) {
+ if (typeof attrs[i] == 'function') {
+ l.addEventListener( i, attrs[i], true );
+ } else {
+ l.setAttribute(i,attrs[i]);
+ }
+ }
+ }
+
+ if (objects) {
+ for ( var i in objects ) l.appendChild( objects[i] );
+ }
+
+ return l;
}
function createDescription (attrs) {
- return createComplexXULElement('description', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('description', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createTooltip (attrs) {
- return createComplexXULElement('tooltip', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('tooltip', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createLabel (attrs) {
- return createComplexXULElement('label', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('label', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createVbox (attrs) {
- return createComplexXULElement('vbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('vbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createHbox (attrs) {
- return createComplexXULElement('hbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('hbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createRow (attrs) {
- return createComplexXULElement('row', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('row', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createTextbox (attrs) {
- return createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createMenu (attrs) {
- return createComplexXULElement('menu', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('menu', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createMenuPopup (attrs) {
- return createComplexXULElement('menupopup', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('menupopup', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createPopup (attrs) {
- return createComplexXULElement('popup', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('popup', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createMenuitem (attrs) {
- return createComplexXULElement('menuitem', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('menuitem', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createCheckbox (attrs) {
- return createComplexXULElement('checkbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
+ return createComplexXULElement('checkbox', attrs, Array.prototype.slice.apply(arguments, [1]) );
}
function createMARCTextbox (element,attrs) {
- var box = createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [2]) );
- box.onkeypress = function (event) {
- var root_node;
- var node = element;
- while(node = node.parent()) {
- root_node = node;
- }
-
- var row = event.target;
- while (row.tagName != 'row') row = row.parentNode;
-
- if (element.nodeKind() == 'attribute') element[0]=box.value;
- else element.setChildren( box.value );
-
- if (element.localName() != 'controlfield') {
- if ((event.charCode == 100 || event.charCode == 105) && event.ctrlKey) { // ctrl+d or ctrl+i
-
- var index_sf, target, move_data;
- if (element.localName() == 'subfield') {
- index_sf = element;
- target = event.target.parentNode;
-
- var start = event.target.selectionStart;
- var end = event.target.selectionEnd - event.target.selectionStart ?
- event.target.selectionEnd :
- event.target.value.length;
-
- move_data = event.target.value.substring(start,end);
- event.target.value = event.target.value.substring(0,start) + event.target.value.substring(end);
- event.target.setAttribute('size', event.target.value.length + 2);
-
- element.setChildren( event.target.value );
-
- } else if (element.localName() == 'code') {
- index_sf = element.parent();
- target = event.target.parentNode;
- } else if (element.localName() == 'tag' || element.localName() == 'ind1' || element.localName() == 'ind2') {
- index_sf = element.parent().children()[element.parent().children().length() - 1];
- target = event.target.parentNode.lastChild.lastChild;
- }
-
- var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{ move_data }</subfield>;
-
- index_sf.parent().insertChildAfter( index_sf, sf );
-
- var new_sf = marcSubfield(sf);
-
- if (target === target.parentNode.lastChild) {
- target.parentNode.appendChild( new_sf );
- } else {
- target.parentNode.insertBefore( new_sf, target.nextSibling );
- }
-
- new_sf.firstChild.nextSibling.focus();
-
- event.preventDefault();
- return false;
-
- } else if (event.keyCode == 13 || event.keyCode == 77) {
- if (event.ctrlKey) { // ctrl+enter
-
- var index;
- if (element.localName() == 'subfield') index = element.parent();
- if (element.localName() == 'code') index = element.parent().parent();
- if (element.localName() == 'tag') index = element.parent();
- if (element.localName() == 'ind1') index = element.parent();
- if (element.localName() == 'ind2') index = element.parent();
-
- var df = <datafield tag="" ind1="" ind2="" xmlns="http://www.loc.gov/MARC21/slim"><subfield code="" /></datafield>;
-
- if (event.shiftKey) { // ctrl+shift+enter
- index.parent().insertChildBefore( index, df );
- } else {
- index.parent().insertChildAfter( index, df );
- }
-
- var new_df = marcDatafield(df);
-
- if (row.parentNode.lastChild === row) {
- row.parentNode.appendChild( new_df );
- } else {
- if (event.shiftKey) { // ctrl+shift+enter
- row.parentNode.insertBefore( new_df, row );
- } else {
- row.parentNode.insertBefore( new_df, row.nextSibling );
- }
- }
-
- new_df.firstChild.focus();
-
- event.preventDefault();
- return false;
-
- } else if (event.shiftKey) {
- if (row.previousSibling.className.match('marcDatafieldRow'))
- row.previousSibling.firstChild.focus();
- } else {
- row.nextSibling.firstChild.focus();
- }
-
- } else if (event.keyCode == 38 || event.keyCode == 40) { // up-arrow or down-arrow
- if (event.ctrlKey) { // CTRL key: copy the field
- var index;
- if (element.localName() == 'subfield') index = element.parent();
- if (element.localName() == 'code') index = element.parent().parent();
- if (element.localName() == 'tag') index = element.parent();
- if (element.localName() == 'ind1') index = element.parent();
- if (element.localName() == 'ind2') index = element.parent();
-
- var copyField = index.copy();
-
- if (event.keyCode == 38) { // ctrl+up-arrow
- index.parent().insertChildBefore( index, copyField );
- } else {
- index.parent().insertChildAfter( index, copyField );
- }
-
- var new_df = marcDatafield(copyField);
-
- if (row.parentNode.lastChild === row) {
- row.parentNode.appendChild( new_df );
- } else {
- if (event.keyCode == 38) { // ctrl+up-arrow
- row.parentNode.insertBefore( new_df, row );
- } else { // ctrl+down-arrow
- row.parentNode.insertBefore( new_df, row.nextSibling );
- }
- }
-
- new_df.firstChild.focus();
-
- event.preventDefault();
-
- return false;
- }
-
- } else if (event.keyCode == 46 && event.ctrlKey) { // ctrl+del
-
- var index;
- if (element.localName() == 'subfield') index = element.parent();
- if (element.localName() == 'code') index = element.parent().parent();
- if (element.localName() == 'tag') index = element.parent();
- if (element.localName() == 'ind1') index = element.parent();
- if (element.localName() == 'ind2') index = element.parent();
-
- for (var i in index.parent().children()) {
- if (index === index.parent().children()[i]) {
- delete index.parent().children()[i];
- break;
- }
- }
-
- row.previousSibling.firstChild.focus();
- row.parentNode.removeChild(row);
-
- event.preventDefault();
- return false;
-
- } else if (event.keyCode == 46 && event.shiftKey) { // shift+del
-
- var index;
- if (element.localName() == 'subfield') index = element;
- if (element.localName() == 'code') index = element.parent();
-
- if (index) {
- for (var i in index.parent().children()) {
- if (index === index.parent().children()[i]) {
- delete index.parent().children()[i];
- break;
- }
- }
-
- if (event.target.parentNode === event.target.parentNode.parentNode.lastChild) {
- event.target.parentNode.previousSibling.lastChild.focus();
- } else {
- event.target.parentNode.nextSibling.firstChild.nextSibling.focus();
- }
-
- event.target.parentNode.parentNode.removeChild(event.target.parentNode);
-
- event.preventDefault();
- return false;
- }
- } else if (event.keyCode == 64 && event.ctrlKey) { // ctrl + F6
- createControlField('006',' ');
- loadRecord(xml_record);
- } else if (event.keyCode == 65 && event.ctrlKey) { // ctrl + F7
- createControlField('007',' ');
- loadRecord(xml_record);
- } else if (event.keyCode == 66 && event.ctrlKey) { // ctrl + F8
- createControlField('008',' ');
- loadRecord(xml_record);
- }
- return true;
- }
- };
-
- box.addEventListener(
- 'keypress',
- function () {
- if (element.nodeKind() == 'attribute') element[0]=box.value;
- else element.setChildren( box.value );
- return true;
- },
- false
- );
-
- box.addEventListener(
- 'change',
- function () {
- if (element.nodeKind() == 'attribute') element[0]=box.value;
- else element.setChildren( box.value );
- return true;
- },
- false
- );
-
- box.addEventListener(
- 'keypress',
- function () {
- if (element.nodeKind() == 'attribute') element[0]=box.value;
- else element.setChildren( box.value );
- return true;
- },
- true
- );
-
- box.addEventListener(
- 'keyup',
- function () {
- if (element.localName() == 'controlfield')
- eval('fillFixedFields(xml_record);');
- },
- true
- );
-
- return box;
+ var box = createComplexXULElement('textbox', attrs, Array.prototype.slice.apply(arguments, [2]) );
+ box.onkeypress = function (event) {
+ var root_node;
+ var node = element;
+ while(node = node.parent()) {
+ root_node = node;
+ }
+
+ var row = event.target;
+ while (row.tagName != 'row') row = row.parentNode;
+
+ if (element.nodeKind() == 'attribute') element[0]=box.value;
+ else element.setChildren( box.value );
+
+ if (element.localName() != 'controlfield') {
+ if ((event.charCode == 100 || event.charCode == 105) && event.ctrlKey) { // ctrl+d or ctrl+i
+
+ var index_sf, target, move_data;
+ if (element.localName() == 'subfield') {
+ index_sf = element;
+ target = event.target.parentNode;
+
+ var start = event.target.selectionStart;
+ var end = event.target.selectionEnd - event.target.selectionStart ?
+ event.target.selectionEnd :
+ event.target.value.length;
+
+ move_data = event.target.value.substring(start,end);
+ event.target.value = event.target.value.substring(0,start) + event.target.value.substring(end);
+ event.target.setAttribute('size', event.target.value.length + 2);
+
+ element.setChildren( event.target.value );
+
+ } else if (element.localName() == 'code') {
+ index_sf = element.parent();
+ target = event.target.parentNode;
+ } else if (element.localName() == 'tag' || element.localName() == 'ind1' || element.localName() == 'ind2') {
+ index_sf = element.parent().children()[element.parent().children().length() - 1];
+ target = event.target.parentNode.lastChild.lastChild;
+ }
+
+ var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{ move_data }</subfield>;
+
+ index_sf.parent().insertChildAfter( index_sf, sf );
+
+ var new_sf = marcSubfield(sf);
+
+ if (target === target.parentNode.lastChild) {
+ target.parentNode.appendChild( new_sf );
+ } else {
+ target.parentNode.insertBefore( new_sf, target.nextSibling );
+ }
+
+ new_sf.firstChild.nextSibling.focus();
+
+ event.preventDefault();
+ return false;
+
+ } else if (event.keyCode == 13 || event.keyCode == 77) {
+ if (event.ctrlKey) { // ctrl+enter
+
+ var index;
+ if (element.localName() == 'subfield') index = element.parent();
+ if (element.localName() == 'code') index = element.parent().parent();
+ if (element.localName() == 'tag') index = element.parent();
+ if (element.localName() == 'ind1') index = element.parent();
+ if (element.localName() == 'ind2') index = element.parent();
+
+ var df = <datafield tag="" ind1="" ind2="" xmlns="http://www.loc.gov/MARC21/slim"><subfield code="" /></datafield>;
+
+ if (event.shiftKey) { // ctrl+shift+enter
+ index.parent().insertChildBefore( index, df );
+ } else {
+ index.parent().insertChildAfter( index, df );
+ }
+
+ var new_df = marcDatafield(df);
+
+ if (row.parentNode.lastChild === row) {
+ row.parentNode.appendChild( new_df );
+ } else {
+ if (event.shiftKey) { // ctrl+shift+enter
+ row.parentNode.insertBefore( new_df, row );
+ } else {
+ row.parentNode.insertBefore( new_df, row.nextSibling );
+ }
+ }
+
+ new_df.firstChild.focus();
+
+ event.preventDefault();
+ return false;
+
+ } else if (event.shiftKey) {
+ if (row.previousSibling.className.match('marcDatafieldRow'))
+ row.previousSibling.firstChild.focus();
+ } else {
+ row.nextSibling.firstChild.focus();
+ }
+
+ } else if (event.keyCode == 38 || event.keyCode == 40) { // up-arrow or down-arrow
+ if (event.ctrlKey) { // CTRL key: copy the field
+ var index;
+ if (element.localName() == 'subfield') index = element.parent();
+ if (element.localName() == 'code') index = element.parent().parent();
+ if (element.localName() == 'tag') index = element.parent();
+ if (element.localName() == 'ind1') index = element.parent();
+ if (element.localName() == 'ind2') index = element.parent();
+
+ var copyField = index.copy();
+
+ if (event.keyCode == 38) { // ctrl+up-arrow
+ index.parent().insertChildBefore( index, copyField );
+ } else {
+ index.parent().insertChildAfter( index, copyField );
+ }
+
+ var new_df = marcDatafield(copyField);
+
+ if (row.parentNode.lastChild === row) {
+ row.parentNode.appendChild( new_df );
+ } else {
+ if (event.keyCode == 38) { // ctrl+up-arrow
+ row.parentNode.insertBefore( new_df, row );
+ } else { // ctrl+down-arrow
+ row.parentNode.insertBefore( new_df, row.nextSibling );
+ }
+ }
+
+ new_df.firstChild.focus();
+
+ event.preventDefault();
+
+ return false;
+ }
+
+ } else if (event.keyCode == 46 && event.ctrlKey) { // ctrl+del
+
+ var index;
+ if (element.localName() == 'subfield') index = element.parent();
+ if (element.localName() == 'code') index = element.parent().parent();
+ if (element.localName() == 'tag') index = element.parent();
+ if (element.localName() == 'ind1') index = element.parent();
+ if (element.localName() == 'ind2') index = element.parent();
+
+ for (var i in index.parent().children()) {
+ if (index === index.parent().children()[i]) {
+ delete index.parent().children()[i];
+ break;
+ }
+ }
+
+ row.previousSibling.firstChild.focus();
+ row.parentNode.removeChild(row);
+
+ event.preventDefault();
+ return false;
+
+ } else if (event.keyCode == 46 && event.shiftKey) { // shift+del
+
+ var index;
+ if (element.localName() == 'subfield') index = element;
+ if (element.localName() == 'code') index = element.parent();
+
+ if (index) {
+ for (var i in index.parent().children()) {
+ if (index === index.parent().children()[i]) {
+ delete index.parent().children()[i];
+ break;
+ }
+ }
+
+ if (event.target.parentNode === event.target.parentNode.parentNode.lastChild) {
+ event.target.parentNode.previousSibling.lastChild.focus();
+ } else {
+ event.target.parentNode.nextSibling.firstChild.nextSibling.focus();
+ }
+
+ event.target.parentNode.parentNode.removeChild(event.target.parentNode);
+
+ event.preventDefault();
+ return false;
+ }
+ } else if (event.keyCode == 64 && event.ctrlKey) { // ctrl + F6
+ createControlField('006',' ');
+ loadRecord(xml_record);
+ } else if (event.keyCode == 65 && event.ctrlKey) { // ctrl + F7
+ createControlField('007',' ');
+ loadRecord(xml_record);
+ } else if (event.keyCode == 66 && event.ctrlKey) { // ctrl + F8
+ createControlField('008',' ');
+ loadRecord(xml_record);
+ }
+ return true;
+ }
+ };
+
+ box.addEventListener(
+ 'keypress',
+ function () {
+ if (element.nodeKind() == 'attribute') element[0]=box.value;
+ else element.setChildren( box.value );
+ return true;
+ },
+ false
+ );
+
+ box.addEventListener(
+ 'change',
+ function () {
+ if (element.nodeKind() == 'attribute') element[0]=box.value;
+ else element.setChildren( box.value );
+ return true;
+ },
+ false
+ );
+
+ box.addEventListener(
+ 'keypress',
+ function () {
+ if (element.nodeKind() == 'attribute') element[0]=box.value;
+ else element.setChildren( box.value );
+ return true;
+ },
+ true
+ );
+
+ box.addEventListener(
+ 'keyup',
+ function () {
+ if (element.localName() == 'controlfield')
+ eval('fillFixedFields(xml_record);');
+ },
+ true
+ );
+
+ return box;
}
var rec_type = {
- BKS : { Type : /[at]{1}/, BLvl : /[acdm]{1}/ },
- SER : { Type : /[a]{1}/, BLvl : /[bs]{1}/ },
- VIS : { Type : /[gkro]{1}/, BLvl : /[abcdms]{1}/ },
- MIX : { Type : /[p]{1}/, BLvl : /[cd]{1}/ },
- MAP : { Type : /[ef]{1}/, BLvl : /[abcdms]{1}/ },
- SCO : { Type : /[cd]{1}/, BLvl : /[abcdms]{1}/ },
- REC : { Type : /[ij]{1}/, BLvl : /[abcdms]{1}/ },
- COM : { Type : /[m]{1}/, BLvl : /[abcdms]{1}/ }
+ BKS : { Type : /[at]{1}/, BLvl : /[acdm]{1}/ },
+ SER : { Type : /[a]{1}/, BLvl : /[bs]{1}/ },
+ VIS : { Type : /[gkro]{1}/, BLvl : /[abcdms]{1}/ },
+ MIX : { Type : /[p]{1}/, BLvl : /[cd]{1}/ },
+ MAP : { Type : /[ef]{1}/, BLvl : /[abcdms]{1}/ },
+ SCO : { Type : /[cd]{1}/, BLvl : /[abcdms]{1}/ },
+ REC : { Type : /[ij]{1}/, BLvl : /[abcdms]{1}/ },
+ COM : { Type : /[m]{1}/, BLvl : /[abcdms]{1}/ }
};
var ff_pos = {
- TrAr : {
- _8 : {
- SCO : {start : 33, len : 1, def : ' ' },
- REC : {start : 33, len : 1, def : 'n' }
- },
- _6 : {
- SCO : {start : 16, len : 1, def : ' ' },
- REC : {start : 16, len : 1, def : 'n' }
- }
- },
- TMat : {
- _8 : {
- VIS : {start : 33, len : 1, def : ' ' }
- },
- _6 : {
- VIS : {start : 16, len : 1, def : ' ' }
- }
- },
- Time : {
- _8 : {
- VIS : {start : 18, len : 3, def : ' ' }
- },
- _6 : {
- VIS : {start : 1, len : 3, def : ' ' }
- }
- },
- Tech : {
- _8 : {
- VIS : {start : 34, len : 1, def : 'n' }
- },
- _6 : {
- VIS : {start : 17, len : 1, def : 'n' }
- }
- },
- SrTp : {
- _8 : {
- SER : {start : 21, len : 1, def : ' ' }
- },
- _6 : {
- SER : {start : 4, len : 1, def : ' ' }
- }
- },
- Srce : {
- _8 : {
- BKS : {start : 39, len : 1, def : 'd' },
- SER : {start : 39, len : 1, def : 'd' },
- VIS : {start : 39, len : 1, def : 'd' },
- MIX : {start : 39, len : 1, def : 'd' },
- MAP : {start : 39, len : 1, def : 'd' },
- SCO : {start : 39, len : 1, def : 'd' },
- REC : {start : 39, len : 1, def : 'd' },
- COM : {start : 39, len : 1, def : 'd' }
- }
- },
- SpFm : {
- _8 : {
- MAP : {start : 33, len : 2, def : ' ' }
- },
- _6 : {
- MAP : {start : 16, len : 2, def : ' ' }
- }
- },
- Relf : {
- _8 : {
- MAP : {start : 18, len : 4, def : ' ' }
- },
- _6 : {
- MAP : {start : 1, len : 4, def : ' ' }
- }
- },
- Regl : {
- _8 : {
- SER : {start : 19, len : 1, def : ' ' }
- },
- _6 : {
- SER : {start : 2, len : 1, def : ' ' }
- }
- },
- Proj : {
- _8 : {
- MAP : {start : 22, len : 2, def : ' ' }
- },
- _6 : {
- MAP : {start : 5, len : 2, def : ' ' }
- }
- },
- Part : {
- _8 : {
- SCO : {start : 21, len : 1, def : ' ' },
- REC : {start : 21, len : 1, def : 'n' }
- },
- _6 : {
- SCO : {start : 4, len : 1, def : ' ' },
- REC : {start : 4, len : 1, def : 'n' }
- }
- },
- Orig : {
- _8 : {
- SER : {start : 22, len : 1, def : ' ' }
- },
- _6 : {
- SER : {start : 5, len : 1, def : ' ' }
- }
- },
- LTxt : {
- _8 : {
- SCO : {start : 30, len : 2, def : ' ' },
- REC : {start : 30, len : 2, def : ' ' }
- },
- _6 : {
- SCO : {start : 13, len : 2, def : ' ' },
- REC : {start : 13, len : 2, def : ' ' }
- }
- },
- Freq : {
- _8 : {
- SER : {start : 18, len : 1, def : ' ' }
- },
- _6 : {
- SER : {start : 1, len : 1, def : ' ' }
- }
- },
- FMus : {
- _8 : {
- SCO : {start : 20, len : 1, def : ' ' },
- REC : {start : 20, len : 1, def : 'n' }
- },
- _6 : {
- SCO : {start : 3, len : 1, def : ' ' },
- REC : {start : 3, len : 1, def : 'n' }
- }
- },
- File : {
- _8 : {
- COM : {start : 26, len : 1, def : 'u' }
- },
- _6 : {
- COM : {start : 9, len : 1, def : 'u' }
- }
- },
- EntW : {
- _8 : {
- SER : {start : 24, len : 1, def : ' ' }
- },
- _6 : {
- SER : {start : 7, len : 1, def : ' ' }
- }
- },
- AccM : {
- _8 : {
- SCO : {start : 24, len : 6, def : ' ' },
- REC : {start : 24, len : 6, def : ' ' }
- },
- _6 : {
- SCO : {start : 7, len : 6, def : ' ' },
- REC : {start : 7, len : 6, def : ' ' }
- }
- },
- Comp : {
- _8 : {
- SCO : {start : 18, len : 2, def : ' ' },
- REC : {start : 18, len : 2, def : ' ' }
- },
- _6 : {
- SCO : {start : 1, len : 2, def : ' ' },
- REC : {start : 1, len : 2, def : ' ' }
- }
- },
- CrTp : {
- _8 : {
- MAP : {start : 25, len : 1, def : ' ' }
- },
- _6 : {
- MAP : {start : 8, len : 1, def : ' ' }
- }
- },
- Ctry : {
- _8 : {
- BKS : {start : 15, len : 3, def : ' ' },
- SER : {start : 15, len : 3, def : ' ' },
- VIS : {start : 15, len : 3, def : ' ' },
- MIX : {start : 15, len : 3, def : ' ' },
- MAP : {start : 15, len : 3, def : ' ' },
- SCO : {start : 15, len : 3, def : ' ' },
- REC : {start : 15, len : 3, def : ' ' },
- COM : {start : 15, len : 3, def : ' ' }
- }
- },
- Lang : {
- _8 : {
- BKS : {start : 35, len : 3, def : ' ' },
- SER : {start : 35, len : 3, def : ' ' },
- VIS : {start : 35, len : 3, def : ' ' },
- MIX : {start : 35, len : 3, def : ' ' },
- MAP : {start : 35, len : 3, def : ' ' },
- SCO : {start : 35, len : 3, def : ' ' },
- REC : {start : 35, len : 3, def : ' ' },
- COM : {start : 35, len : 3, def : ' ' }
- }
- },
- MRec : {
- _8 : {
- BKS : {start : 38, len : 1, def : ' ' },
- SER : {start : 38, len : 1, def : ' ' },
- VIS : {start : 38, len : 1, def : ' ' },
- MIX : {start : 38, len : 1, def : ' ' },
- MAP : {start : 38, len : 1, def : ' ' },
- SCO : {start : 38, len : 1, def : ' ' },
- REC : {start : 38, len : 1, def : ' ' },
- COM : {start : 38, len : 1, def : ' ' }
- }
- },
- DtSt : {
- _8 : {
- BKS : {start : 6, len : 1, def : ' ' },
- SER : {start : 6, len : 1, def : 'c' },
- VIS : {start : 6, len : 1, def : ' ' },
- MIX : {start : 6, len : 1, def : ' ' },
- MAP : {start : 6, len : 1, def : ' ' },
- SCO : {start : 6, len : 1, def : ' ' },
- REC : {start : 6, len : 1, def : ' ' },
- COM : {start : 6, len : 1, def : ' ' }
- }
- },
- Type : {
- ldr : {
- BKS : {start : 6, len : 1, def : 'a' },
- SER : {start : 6, len : 1, def : 'a' },
- VIS : {start : 6, len : 1, def : 'g' },
- MIX : {start : 6, len : 1, def : 'p' },
- MAP : {start : 6, len : 1, def : 'e' },
- SCO : {start : 6, len : 1, def : 'c' },
- REC : {start : 6, len : 1, def : 'i' },
- COM : {start : 6, len : 1, def : 'm' }
- }
- },
- Ctrl : {
- ldr : {
- BKS : {start : 8, len : 1, def : ' ' },
- SER : {start : 8, len : 1, def : ' ' },
- VIS : {start : 8, len : 1, def : ' ' },
- MIX : {start : 8, len : 1, def : ' ' },
- MAP : {start : 8, len : 1, def : ' ' },
- SCO : {start : 8, len : 1, def : ' ' },
- REC : {start : 8, len : 1, def : ' ' },
- COM : {start : 8, len : 1, def : ' ' }
- }
- },
- BLvl : {
- ldr : {
- BKS : {start : 7, len : 1, def : 'm' },
- SER : {start : 7, len : 1, def : 's' },
- VIS : {start : 7, len : 1, def : 'm' },
- MIX : {start : 7, len : 1, def : 'c' },
- MAP : {start : 7, len : 1, def : 'm' },
- SCO : {start : 7, len : 1, def : 'm' },
- REC : {start : 7, len : 1, def : 'm' },
- COM : {start : 7, len : 1, def : 'm' }
- }
- },
- Desc : {
- ldr : {
- BKS : {start : 18, len : 1, def : ' ' },
- SER : {start : 18, len : 1, def : ' ' },
- VIS : {start : 18, len : 1, def : ' ' },
- MIX : {start : 18, len : 1, def : ' ' },
- MAP : {start : 18, len : 1, def : ' ' },
- SCO : {start : 18, len : 1, def : ' ' },
- REC : {start : 18, len : 1, def : ' ' },
- COM : {start : 18, len : 1, def : ' ' }
- }
- },
- ELvl : {
- ldr : {
- BKS : {start : 17, len : 1, def : ' ' },
- SER : {start : 17, len : 1, def : ' ' },
- VIS : {start : 17, len : 1, def : ' ' },
- MIX : {start : 17, len : 1, def : ' ' },
- MAP : {start : 17, len : 1, def : ' ' },
- SCO : {start : 17, len : 1, def : ' ' },
- REC : {start : 17, len : 1, def : ' ' },
- COM : {start : 17, len : 1, def : ' ' }
- }
- },
- Indx : {
- _8 : {
- BKS : {start : 31, len : 1, def : '0' },
- MAP : {start : 31, len : 1, def : '0' }
- },
- _6 : {
- BKS : {start : 14, len : 1, def : '0' },
- MAP : {start : 14, len : 1, def : '0' }
- }
- },
- Date1 : {
- _8 : {
- BKS : {start : 7, len : 4, def : ' ' },
- SER : {start : 7, len : 4, def : ' ' },
- VIS : {start : 7, len : 4, def : ' ' },
- MIX : {start : 7, len : 4, def : ' ' },
- MAP : {start : 7, len : 4, def : ' ' },
- SCO : {start : 7, len : 4, def : ' ' },
- REC : {start : 7, len : 4, def : ' ' },
- COM : {start : 7, len : 4, def : ' ' }
- }
- },
- Date2 : {
- _8 : {
- BKS : {start : 11, len : 4, def : ' ' },
- SER : {start : 11, len : 4, def : '9' },
- VIS : {start : 11, len : 4, def : ' ' },
- MIX : {start : 11, len : 4, def : ' ' },
- MAP : {start : 11, len : 4, def : ' ' },
- SCO : {start : 11, len : 4, def : ' ' },
- REC : {start : 11, len : 4, def : ' ' },
- COM : {start : 11, len : 4, def : ' ' }
- }
- },
- LitF : {
- _8 : {
- BKS : {start : 33, len : 1, def : '0' }
- },
- _6 : {
- BKS : {start : 16, len : 1, def : '0' }
- }
- },
- Biog : {
- _8 : {
- BKS : {start : 34, len : 1, def : ' ' }
- },
- _6 : {
- BKS : {start : 17, len : 1, def : ' ' }
- }
- },
- Ills : {
- _8 : {
- BKS : {start : 18, len : 4, def : ' ' }
- },
- _6 : {
- BKS : {start : 1, len : 4, def : ' ' }
- }
- },
- Fest : {
- _8 : {
- BKS : {start : 30, len : 1, def : '0' }
- },
- _6 : {
- BKS : {start : 13, len : 1, def : '0' }
- }
- },
- Conf : {
- _8 : {
- BKS : {start : 29, len : 1, def : '0' },
- SER : {start : 29, len : 1, def : '0' }
- },
- _6 : {
- BKS : {start : 12, len : 1, def : '0' },
- SER : {start : 12, len : 1, def : '0' }
- }
- },
- Cont : {
- _8 : {
- BKS : {start : 24, len : 4, def : ' ' },
- SER : {start : 25, len : 3, def : ' ' }
- },
- _6 : {
- BKS : {start : 7, len : 4, def : ' ' },
- SER : {start : 8, len : 3, def : ' ' }
- }
- },
- GPub : {
- _8 : {
- BKS : {start : 28, len : 1, def : ' ' },
- SER : {start : 28, len : 1, def : ' ' },
- VIS : {start : 28, len : 1, def : ' ' },
- MAP : {start : 28, len : 1, def : ' ' },
- COM : {start : 28, len : 1, def : ' ' }
- },
- _6 : {
- BKS : {start : 11, len : 1, def : ' ' },
- SER : {start : 11, len : 1, def : ' ' },
- VIS : {start : 11, len : 1, def : ' ' },
- MAP : {start : 11, len : 1, def : ' ' },
- COM : {start : 11, len : 1, def : ' ' }
- }
- },
- Audn : {
- _8 : {
- BKS : {start : 22, len : 1, def : ' ' },
- SER : {start : 22, len : 1, def : ' ' },
- VIS : {start : 22, len : 1, def : ' ' },
- SCO : {start : 22, len : 1, def : ' ' },
- REC : {start : 22, len : 1, def : ' ' },
- COM : {start : 22, len : 1, def : ' ' }
- },
- _6 : {
- BKS : {start : 5, len : 1, def : ' ' },
- SER : {start : 5, len : 1, def : ' ' },
- VIS : {start : 5, len : 1, def : ' ' },
- SCO : {start : 5, len : 1, def : ' ' },
- REC : {start : 5, len : 1, def : ' ' },
- COM : {start : 5, len : 1, def : ' ' }
- }
- },
- Form : {
- _8 : {
- BKS : {start : 23, len : 1, def : ' ' },
- SER : {start : 23, len : 1, def : ' ' },
- VIS : {start : 29, len : 1, def : ' ' },
- MIX : {start : 23, len : 1, def : ' ' },
- MAP : {start : 29, len : 1, def : ' ' },
- SCO : {start : 23, len : 1, def : ' ' },
- REC : {start : 23, len : 1, def : ' ' }
- },
- _6 : {
- BKS : {start : 6, len : 1, def : ' ' },
- SER : {start : 6, len : 1, def : ' ' },
- VIS : {start : 12, len : 1, def : ' ' },
- MIX : {start : 6, len : 1, def : ' ' },
- MAP : {start : 12, len : 1, def : ' ' },
- SCO : {start : 6, len : 1, def : ' ' },
- REC : {start : 6, len : 1, def : ' ' }
- }
- },
- 'S/L' : {
- _8 : {
- SER : {start : 34, len : 1, def : '0' }
- },
- _6 : {
- SER : {start : 17, len : 1, def : '0' }
- }
- },
- 'Alph' : {
- _8 : {
- SER : {start : 33, len : 1, def : ' ' }
- },
- _6 : {
- SER : {start : 16, len : 1, def : ' ' }
- }
- }
+ TrAr : {
+ _8 : {
+ SCO : {start : 33, len : 1, def : ' ' },
+ REC : {start : 33, len : 1, def : 'n' }
+ },
+ _6 : {
+ SCO : {start : 16, len : 1, def : ' ' },
+ REC : {start : 16, len : 1, def : 'n' }
+ }
+ },
+ TMat : {
+ _8 : {
+ VIS : {start : 33, len : 1, def : ' ' }
+ },
+ _6 : {
+ VIS : {start : 16, len : 1, def : ' ' }
+ }
+ },
+ Time : {
+ _8 : {
+ VIS : {start : 18, len : 3, def : ' ' }
+ },
+ _6 : {
+ VIS : {start : 1, len : 3, def : ' ' }
+ }
+ },
+ Tech : {
+ _8 : {
+ VIS : {start : 34, len : 1, def : 'n' }
+ },
+ _6 : {
+ VIS : {start : 17, len : 1, def : 'n' }
+ }
+ },
+ SrTp : {
+ _8 : {
+ SER : {start : 21, len : 1, def : ' ' }
+ },
+ _6 : {
+ SER : {start : 4, len : 1, def : ' ' }
+ }
+ },
+ Srce : {
+ _8 : {
+ BKS : {start : 39, len : 1, def : 'd' },
+ SER : {start : 39, len : 1, def : 'd' },
+ VIS : {start : 39, len : 1, def : 'd' },
+ MIX : {start : 39, len : 1, def : 'd' },
+ MAP : {start : 39, len : 1, def : 'd' },
+ SCO : {start : 39, len : 1, def : 'd' },
+ REC : {start : 39, len : 1, def : 'd' },
+ COM : {start : 39, len : 1, def : 'd' }
+ }
+ },
+ SpFm : {
+ _8 : {
+ MAP : {start : 33, len : 2, def : ' ' }
+ },
+ _6 : {
+ MAP : {start : 16, len : 2, def : ' ' }
+ }
+ },
+ Relf : {
+ _8 : {
+ MAP : {start : 18, len : 4, def : ' ' }
+ },
+ _6 : {
+ MAP : {start : 1, len : 4, def : ' ' }
+ }
+ },
+ Regl : {
+ _8 : {
+ SER : {start : 19, len : 1, def : ' ' }
+ },
+ _6 : {
+ SER : {start : 2, len : 1, def : ' ' }
+ }
+ },
+ Proj : {
+ _8 : {
+ MAP : {start : 22, len : 2, def : ' ' }
+ },
+ _6 : {
+ MAP : {start : 5, len : 2, def : ' ' }
+ }
+ },
+ Part : {
+ _8 : {
+ SCO : {start : 21, len : 1, def : ' ' },
+ REC : {start : 21, len : 1, def : 'n' }
+ },
+ _6 : {
+ SCO : {start : 4, len : 1, def : ' ' },
+ REC : {start : 4, len : 1, def : 'n' }
+ }
+ },
+ Orig : {
+ _8 : {
+ SER : {start : 22, len : 1, def : ' ' }
+ },
+ _6 : {
+ SER : {start : 5, len : 1, def : ' ' }
+ }
+ },
+ LTxt : {
+ _8 : {
+ SCO : {start : 30, len : 2, def : ' ' },
+ REC : {start : 30, len : 2, def : ' ' }
+ },
+ _6 : {
+ SCO : {start : 13, len : 2, def : ' ' },
+ REC : {start : 13, len : 2, def : ' ' }
+ }
+ },
+ Freq : {
+ _8 : {
+ SER : {start : 18, len : 1, def : ' ' }
+ },
+ _6 : {
+ SER : {start : 1, len : 1, def : ' ' }
+ }
+ },
+ FMus : {
+ _8 : {
+ SCO : {start : 20, len : 1, def : ' ' },
+ REC : {start : 20, len : 1, def : 'n' }
+ },
+ _6 : {
+ SCO : {start : 3, len : 1, def : ' ' },
+ REC : {start : 3, len : 1, def : 'n' }
+ }
+ },
+ File : {
+ _8 : {
+ COM : {start : 26, len : 1, def : 'u' }
+ },
+ _6 : {
+ COM : {start : 9, len : 1, def : 'u' }
+ }
+ },
+ EntW : {
+ _8 : {
+ SER : {start : 24, len : 1, def : ' ' }
+ },
+ _6 : {
+ SER : {start : 7, len : 1, def : ' ' }
+ }
+ },
+ AccM : {
+ _8 : {
+ SCO : {start : 24, len : 6, def : ' ' },
+ REC : {start : 24, len : 6, def : ' ' }
+ },
+ _6 : {
+ SCO : {start : 7, len : 6, def : ' ' },
+ REC : {start : 7, len : 6, def : ' ' }
+ }
+ },
+ Comp : {
+ _8 : {
+ SCO : {start : 18, len : 2, def : ' ' },
+ REC : {start : 18, len : 2, def : ' ' }
+ },
+ _6 : {
+ SCO : {start : 1, len : 2, def : ' ' },
+ REC : {start : 1, len : 2, def : ' ' }
+ }
+ },
+ CrTp : {
+ _8 : {
+ MAP : {start : 25, len : 1, def : ' ' }
+ },
+ _6 : {
+ MAP : {start : 8, len : 1, def : ' ' }
+ }
+ },
+ Ctry : {
+ _8 : {
+ BKS : {start : 15, len : 3, def : ' ' },
+ SER : {start : 15, len : 3, def : ' ' },
+ VIS : {start : 15, len : 3, def : ' ' },
+ MIX : {start : 15, len : 3, def : ' ' },
+ MAP : {start : 15, len : 3, def : ' ' },
+ SCO : {start : 15, len : 3, def : ' ' },
+ REC : {start : 15, len : 3, def : ' ' },
+ COM : {start : 15, len : 3, def : ' ' }
+ }
+ },
+ Lang : {
+ _8 : {
+ BKS : {start : 35, len : 3, def : ' ' },
+ SER : {start : 35, len : 3, def : ' ' },
+ VIS : {start : 35, len : 3, def : ' ' },
+ MIX : {start : 35, len : 3, def : ' ' },
+ MAP : {start : 35, len : 3, def : ' ' },
+ SCO : {start : 35, len : 3, def : ' ' },
+ REC : {start : 35, len : 3, def : ' ' },
+ COM : {start : 35, len : 3, def : ' ' }
+ }
+ },
+ MRec : {
+ _8 : {
+ BKS : {start : 38, len : 1, def : ' ' },
+ SER : {start : 38, len : 1, def : ' ' },
+ VIS : {start : 38, len : 1, def : ' ' },
+ MIX : {start : 38, len : 1, def : ' ' },
+ MAP : {start : 38, len : 1, def : ' ' },
+ SCO : {start : 38, len : 1, def : ' ' },
+ REC : {start : 38, len : 1, def : ' ' },
+ COM : {start : 38, len : 1, def : ' ' }
+ }
+ },
+ DtSt : {
+ _8 : {
+ BKS : {start : 6, len : 1, def : ' ' },
+ SER : {start : 6, len : 1, def : 'c' },
+ VIS : {start : 6, len : 1, def : ' ' },
+ MIX : {start : 6, len : 1, def : ' ' },
+ MAP : {start : 6, len : 1, def : ' ' },
+ SCO : {start : 6, len : 1, def : ' ' },
+ REC : {start : 6, len : 1, def : ' ' },
+ COM : {start : 6, len : 1, def : ' ' }
+ }
+ },
+ Type : {
+ ldr : {
+ BKS : {start : 6, len : 1, def : 'a' },
+ SER : {start : 6, len : 1, def : 'a' },
+ VIS : {start : 6, len : 1, def : 'g' },
+ MIX : {start : 6, len : 1, def : 'p' },
+ MAP : {start : 6, len : 1, def : 'e' },
+ SCO : {start : 6, len : 1, def : 'c' },
+ REC : {start : 6, len : 1, def : 'i' },
+ COM : {start : 6, len : 1, def : 'm' }
+ }
+ },
+ Ctrl : {
+ ldr : {
+ BKS : {start : 8, len : 1, def : ' ' },
+ SER : {start : 8, len : 1, def : ' ' },
+ VIS : {start : 8, len : 1, def : ' ' },
+ MIX : {start : 8, len : 1, def : ' ' },
+ MAP : {start : 8, len : 1, def : ' ' },
+ SCO : {start : 8, len : 1, def : ' ' },
+ REC : {start : 8, len : 1, def : ' ' },
+ COM : {start : 8, len : 1, def : ' ' }
+ }
+ },
+ BLvl : {
+ ldr : {
+ BKS : {start : 7, len : 1, def : 'm' },
+ SER : {start : 7, len : 1, def : 's' },
+ VIS : {start : 7, len : 1, def : 'm' },
+ MIX : {start : 7, len : 1, def : 'c' },
+ MAP : {start : 7, len : 1, def : 'm' },
+ SCO : {start : 7, len : 1, def : 'm' },
+ REC : {start : 7, len : 1, def : 'm' },
+ COM : {start : 7, len : 1, def : 'm' }
+ }
+ },
+ Desc : {
+ ldr : {
+ BKS : {start : 18, len : 1, def : ' ' },
+ SER : {start : 18, len : 1, def : ' ' },
+ VIS : {start : 18, len : 1, def : ' ' },
+ MIX : {start : 18, len : 1, def : ' ' },
+ MAP : {start : 18, len : 1, def : ' ' },
+ SCO : {start : 18, len : 1, def : ' ' },
+ REC : {start : 18, len : 1, def : ' ' },
+ COM : {start : 18, len : 1, def : ' ' }
+ }
+ },
+ ELvl : {
+ ldr : {
+ BKS : {start : 17, len : 1, def : ' ' },
+ SER : {start : 17, len : 1, def : ' ' },
+ VIS : {start : 17, len : 1, def : ' ' },
+ MIX : {start : 17, len : 1, def : ' ' },
+ MAP : {start : 17, len : 1, def : ' ' },
+ SCO : {start : 17, len : 1, def : ' ' },
+ REC : {start : 17, len : 1, def : ' ' },
+ COM : {start : 17, len : 1, def : ' ' }
+ }
+ },
+ Indx : {
+ _8 : {
+ BKS : {start : 31, len : 1, def : '0' },
+ MAP : {start : 31, len : 1, def : '0' }
+ },
+ _6 : {
+ BKS : {start : 14, len : 1, def : '0' },
+ MAP : {start : 14, len : 1, def : '0' }
+ }
+ },
+ Date1 : {
+ _8 : {
+ BKS : {start : 7, len : 4, def : ' ' },
+ SER : {start : 7, len : 4, def : ' ' },
+ VIS : {start : 7, len : 4, def : ' ' },
+ MIX : {start : 7, len : 4, def : ' ' },
+ MAP : {start : 7, len : 4, def : ' ' },
+ SCO : {start : 7, len : 4, def : ' ' },
+ REC : {start : 7, len : 4, def : ' ' },
+ COM : {start : 7, len : 4, def : ' ' }
+ }
+ },
+ Date2 : {
+ _8 : {
+ BKS : {start : 11, len : 4, def : ' ' },
+ SER : {start : 11, len : 4, def : '9' },
+ VIS : {start : 11, len : 4, def : ' ' },
+ MIX : {start : 11, len : 4, def : ' ' },
+ MAP : {start : 11, len : 4, def : ' ' },
+ SCO : {start : 11, len : 4, def : ' ' },
+ REC : {start : 11, len : 4, def : ' ' },
+ COM : {start : 11, len : 4, def : ' ' }
+ }
+ },
+ LitF : {
+ _8 : {
+ BKS : {start : 33, len : 1, def : '0' }
+ },
+ _6 : {
+ BKS : {start : 16, len : 1, def : '0' }
+ }
+ },
+ Biog : {
+ _8 : {
+ BKS : {start : 34, len : 1, def : ' ' }
+ },
+ _6 : {
+ BKS : {start : 17, len : 1, def : ' ' }
+ }
+ },
+ Ills : {
+ _8 : {
+ BKS : {start : 18, len : 4, def : ' ' }
+ },
+ _6 : {
+ BKS : {start : 1, len : 4, def : ' ' }
+ }
+ },
+ Fest : {
+ _8 : {
+ BKS : {start : 30, len : 1, def : '0' }
+ },
+ _6 : {
+ BKS : {start : 13, len : 1, def : '0' }
+ }
+ },
+ Conf : {
+ _8 : {
+ BKS : {start : 29, len : 1, def : '0' },
+ SER : {start : 29, len : 1, def : '0' }
+ },
+ _6 : {
+ BKS : {start : 12, len : 1, def : '0' },
+ SER : {start : 12, len : 1, def : '0' }
+ }
+ },
+ Cont : {
+ _8 : {
+ BKS : {start : 24, len : 4, def : ' ' },
+ SER : {start : 25, len : 3, def : ' ' }
+ },
+ _6 : {
+ BKS : {start : 7, len : 4, def : ' ' },
+ SER : {start : 8, len : 3, def : ' ' }
+ }
+ },
+ GPub : {
+ _8 : {
+ BKS : {start : 28, len : 1, def : ' ' },
+ SER : {start : 28, len : 1, def : ' ' },
+ VIS : {start : 28, len : 1, def : ' ' },
+ MAP : {start : 28, len : 1, def : ' ' },
+ COM : {start : 28, len : 1, def : ' ' }
+ },
+ _6 : {
+ BKS : {start : 11, len : 1, def : ' ' },
+ SER : {start : 11, len : 1, def : ' ' },
+ VIS : {start : 11, len : 1, def : ' ' },
+ MAP : {start : 11, len : 1, def : ' ' },
+ COM : {start : 11, len : 1, def : ' ' }
+ }
+ },
+ Audn : {
+ _8 : {
+ BKS : {start : 22, len : 1, def : ' ' },
+ SER : {start : 22, len : 1, def : ' ' },
+ VIS : {start : 22, len : 1, def : ' ' },
+ SCO : {start : 22, len : 1, def : ' ' },
+ REC : {start : 22, len : 1, def : ' ' },
+ COM : {start : 22, len : 1, def : ' ' }
+ },
+ _6 : {
+ BKS : {start : 5, len : 1, def : ' ' },
+ SER : {start : 5, len : 1, def : ' ' },
+ VIS : {start : 5, len : 1, def : ' ' },
+ SCO : {start : 5, len : 1, def : ' ' },
+ REC : {start : 5, len : 1, def : ' ' },
+ COM : {start : 5, len : 1, def : ' ' }
+ }
+ },
+ Form : {
+ _8 : {
+ BKS : {start : 23, len : 1, def : ' ' },
+ SER : {start : 23, len : 1, def : ' ' },
+ VIS : {start : 29, len : 1, def : ' ' },
+ MIX : {start : 23, len : 1, def : ' ' },
+ MAP : {start : 29, len : 1, def : ' ' },
+ SCO : {start : 23, len : 1, def : ' ' },
+ REC : {start : 23, len : 1, def : ' ' }
+ },
+ _6 : {
+ BKS : {start : 6, len : 1, def : ' ' },
+ SER : {start : 6, len : 1, def : ' ' },
+ VIS : {start : 12, len : 1, def : ' ' },
+ MIX : {start : 6, len : 1, def : ' ' },
+ MAP : {start : 12, len : 1, def : ' ' },
+ SCO : {start : 6, len : 1, def : ' ' },
+ REC : {start : 6, len : 1, def : ' ' }
+ }
+ },
+ 'S/L' : {
+ _8 : {
+ SER : {start : 34, len : 1, def : '0' }
+ },
+ _6 : {
+ SER : {start : 17, len : 1, def : '0' }
+ }
+ },
+ 'Alph' : {
+ _8 : {
+ SER : {start : 33, len : 1, def : ' ' }
+ },
+ _6 : {
+ SER : {start : 16, len : 1, def : ' ' }
+ }
+ }
};
function recordType (rec) {
- try {
- var _l = rec.leader.toString();
-
- var _t = _l.substr(ff_pos.Type.ldr.BKS.start, ff_pos.Type.ldr.BKS.len);
- var _b = _l.substr(ff_pos.BLvl.ldr.BKS.start, ff_pos.BLvl.ldr.BKS.len);
-
- for (var t in rec_type) {
- if (_t.match(rec_type[t].Type) && _b.match(rec_type[t].BLvl)) {
- document.getElementById('recordTypeLabel').value = t;
- _record_type = t;
- return t;
- }
- }
-
- // in case we don't have a valid record type ...
- _record_type = 'BKS';
- return _record_type;
-
- } catch(E) {
- alert('FIXME, MARC Editor, recordType: ' + E);
- }
+ try {
+ var _l = rec.leader.toString();
+
+ var _t = _l.substr(ff_pos.Type.ldr.BKS.start, ff_pos.Type.ldr.BKS.len);
+ var _b = _l.substr(ff_pos.BLvl.ldr.BKS.start, ff_pos.BLvl.ldr.BKS.len);
+
+ for (var t in rec_type) {
+ if (_t.match(rec_type[t].Type) && _b.match(rec_type[t].BLvl)) {
+ document.getElementById('recordTypeLabel').value = t;
+ _record_type = t;
+ return t;
+ }
+ }
+
+ // in case we don't have a valid record type ...
+ _record_type = 'BKS';
+ return _record_type;
+
+ } catch(E) {
+ alert('FIXME, MARC Editor, recordType: ' + E);
+ }
}
function toggleFFE () {
- var grid = document.getElementById('leaderGrid');
- if (grid.hidden) {
- grid.hidden = false;
- } else {
- grid.hidden = true;
- }
- return true;
+ var grid = document.getElementById('leaderGrid');
+ if (grid.hidden) {
+ grid.hidden = false;
+ } else {
+ grid.hidden = true;
+ }
+ return true;
}
function changeFFEditor (type) {
- var grid = document.getElementById('leaderGrid');
- grid.setAttribute('type',type);
+ var grid = document.getElementById('leaderGrid');
+ grid.setAttribute('type',type);
}
function fillFixedFields (rec) {
- try {
- var grid = document.getElementById('leaderGrid');
-
- var rtype = _record_type;
-
- var _l = rec.leader.toString();
- var _6 = rec.controlfield.(@tag=='006').toString();
- var _7 = rec.controlfield.(@tag=='007').toString();
- var _8 = rec.controlfield.(@tag=='008').toString();
-
- var list = [];
- var pre_list = grid.getElementsByTagName('label');
- for (var i in pre_list) {
- if ( pre_list[i].getAttribute && pre_list[i].getAttribute('set').indexOf(grid.getAttribute('type')) > -1 ) {
- list.push( pre_list[i] );
- }
- }
-
- for (var i in list) {
- var name = list[i].getAttribute('name');
-
- if (!ff_pos[name])
- continue;
-
- var value = '';
- if ( ff_pos[name].ldr && ff_pos[name].ldr[rtype] )
- value = _l.substr(ff_pos[name].ldr[rtype].start, ff_pos[name].ldr[rtype].len);
-
- if ( ff_pos[name]._8 && ff_pos[name]._8[rtype] )
- value = _8.substr(ff_pos[name]._8[rtype].start, ff_pos[name]._8[rtype].len);
-
- if ( !value && ff_pos[name]._6 && ff_pos[name]._6[rtype] )
- value = _6.substr(ff_pos[name]._6[rtype].start, ff_pos[name]._6[rtype].len);
-
- if ( ff_pos[name]._7 && ff_pos[name]._7[rtype] )
- value = _7.substr(ff_pos[name]._7[rtype].start, ff_pos[name]._7[rtype].len);
-
- if (!value) {
- var d;
- var p;
- if (ff_pos[name].ldr && ff_pos[name].ldr[rtype]) {
- d = ff_pos[name].ldr[rtype].def;
- p = 'ldr';
- }
-
- if (ff_pos[name]._8 && ff_pos[name]._8[rtype]) {
- d = ff_pos[name]._8[rtype].def;
- p = '_8';
- }
-
- if (!value && ff_pos[name]._6 && ff_pos[name]._6[rtype]) {
- d = ff_pos[name]._6[rtype].def;
- p = '_6';
- }
-
- if (ff_pos[name]._7 && ff_pos[name]._7[rtype]) {
- d = ff_pos[name]._7[rtype].def;
- p = '_7';
- }
-
- if (!value) {
- for (var j = 0; j < ff_pos[name][p][rtype].len; j++) {
- value += d;
- }
- }
- }
-
- list[i].nextSibling.value = value;
- }
-
- return true;
- } catch(E) {
- alert('FIXME, MARC Editor, fillFixedFields: ' + E);
- }
+ try {
+ var grid = document.getElementById('leaderGrid');
+
+ var rtype = _record_type;
+
+ var _l = rec.leader.toString();
+ var _6 = rec.controlfield.(@tag=='006').toString();
+ var _7 = rec.controlfield.(@tag=='007').toString();
+ var _8 = rec.controlfield.(@tag=='008').toString();
+
+ var list = [];
+ var pre_list = grid.getElementsByTagName('label');
+ for (var i in pre_list) {
+ if ( pre_list[i].getAttribute && pre_list[i].getAttribute('set').indexOf(grid.getAttribute('type')) > -1 ) {
+ list.push( pre_list[i] );
+ }
+ }
+
+ for (var i in list) {
+ var name = list[i].getAttribute('name');
+
+ if (!ff_pos[name])
+ continue;
+
+ var value = '';
+ if ( ff_pos[name].ldr && ff_pos[name].ldr[rtype] )
+ value = _l.substr(ff_pos[name].ldr[rtype].start, ff_pos[name].ldr[rtype].len);
+
+ if ( ff_pos[name]._8 && ff_pos[name]._8[rtype] )
+ value = _8.substr(ff_pos[name]._8[rtype].start, ff_pos[name]._8[rtype].len);
+
+ if ( !value && ff_pos[name]._6 && ff_pos[name]._6[rtype] )
+ value = _6.substr(ff_pos[name]._6[rtype].start, ff_pos[name]._6[rtype].len);
+
+ if ( ff_pos[name]._7 && ff_pos[name]._7[rtype] )
+ value = _7.substr(ff_pos[name]._7[rtype].start, ff_pos[name]._7[rtype].len);
+
+ if (!value) {
+ var d;
+ var p;
+ if (ff_pos[name].ldr && ff_pos[name].ldr[rtype]) {
+ d = ff_pos[name].ldr[rtype].def;
+ p = 'ldr';
+ }
+
+ if (ff_pos[name]._8 && ff_pos[name]._8[rtype]) {
+ d = ff_pos[name]._8[rtype].def;
+ p = '_8';
+ }
+
+ if (!value && ff_pos[name]._6 && ff_pos[name]._6[rtype]) {
+ d = ff_pos[name]._6[rtype].def;
+ p = '_6';
+ }
+
+ if (ff_pos[name]._7 && ff_pos[name]._7[rtype]) {
+ d = ff_pos[name]._7[rtype].def;
+ p = '_7';
+ }
+
+ if (!value) {
+ for (var j = 0; j < ff_pos[name][p][rtype].len; j++) {
+ value += d;
+ }
+ }
+ }
+
+ list[i].nextSibling.value = value;
+ }
+
+ return true;
+ } catch(E) {
+ alert('FIXME, MARC Editor, fillFixedFields: ' + E);
+ }
}
function updateFixedFields (element) {
- var grid = document.getElementById('leaderGrid');
- var recGrid = document.getElementById('recGrid');
-
- var rtype = _record_type;
- var new_value = element.value;
-
- var parts = {
- ldr : _record.leader,
- _6 : _record.controlfield.(@tag=='006'),
- _7 : _record.controlfield.(@tag=='007'),
- _8 : _record.controlfield.(@tag=='008')
- };
-
- var name = element.getAttribute('name');
- for (var i in ff_pos[name]) {
-
- if (!ff_pos[name][i][rtype]) continue;
- if (!parts[i]) {
- // we're missing the required field. Add it now.
-
- var newfield;
- if (i == '_6') newfield = '006';
- else if (i == '_7') newfield = '007';
- else if (i == '_8') newfield = '008';
- else continue;
-
- createControlField(newfield,' ');
- parts[i] = _record.controlfield.(@tag==newfield);
- }
+ var grid = document.getElementById('leaderGrid');
+ var recGrid = document.getElementById('recGrid');
+
+ var rtype = _record_type;
+ var new_value = element.value;
+
+ var parts = {
+ ldr : _record.leader,
+ _6 : _record.controlfield.(@tag=='006'),
+ _7 : _record.controlfield.(@tag=='007'),
+ _8 : _record.controlfield.(@tag=='008')
+ };
+
+ var name = element.getAttribute('name');
+ for (var i in ff_pos[name]) {
+
+ if (!ff_pos[name][i][rtype]) continue;
+ if (!parts[i]) {
+ // we're missing the required field. Add it now.
+
+ var newfield;
+ if (i == '_6') newfield = '006';
+ else if (i == '_7') newfield = '007';
+ else if (i == '_8') newfield = '008';
+ else continue;
+
+ createControlField(newfield,' ');
+ parts[i] = _record.controlfield.(@tag==newfield);
+ }
- var before = parts[i].substr(0, ff_pos[name][i][rtype].start);
- var after = parts[i].substr(ff_pos[name][i][rtype].start + ff_pos[name][i][rtype].len);
+ var before = parts[i].substr(0, ff_pos[name][i][rtype].start);
+ var after = parts[i].substr(ff_pos[name][i][rtype].start + ff_pos[name][i][rtype].len);
- for (var j = 0; new_value.length < ff_pos[name][i][rtype].len; j++) {
- new_value += ff_pos[name][i][rtype].def;
- }
+ for (var j = 0; new_value.length < ff_pos[name][i][rtype].len; j++) {
+ new_value += ff_pos[name][i][rtype].def;
+ }
- parts[i].setChildren( before + new_value + after );
- recGrid.getElementsByAttribute('tag',i)[0].lastChild.value = parts[i].toString();
- }
+ parts[i].setChildren( before + new_value + after );
+ recGrid.getElementsByAttribute('tag',i)[0].lastChild.value = parts[i].toString();
+ }
- return true;
+ return true;
}
function marcLeader (leader) {
- var row = createRow(
- { class : 'marcLeaderRow',
- tag : 'ldr' },
- createLabel(
- { value : 'LDR',
- class : 'marcTag',
- tooltiptext : $('catStrings').getString('staff.cat.marcedit.marcTag.LDR.label') } ),
- createLabel(
- { value : '',
- class : 'marcInd1' } ),
- createLabel(
- { value : '',
- class : 'marcInd2' } ),
- createLabel(
- { value : leader.text(),
- class : 'marcLeader' } )
- );
-
- return row;
+ var row = createRow(
+ { class : 'marcLeaderRow',
+ tag : 'ldr' },
+ createLabel(
+ { value : 'LDR',
+ class : 'marcTag',
+ tooltiptext : $('catStrings').getString('staff.cat.marcedit.marcTag.LDR.label') } ),
+ createLabel(
+ { value : '',
+ class : 'marcInd1' } ),
+ createLabel(
+ { value : '',
+ class : 'marcInd2' } ),
+ createLabel(
+ { value : leader.text(),
+ class : 'marcLeader' } )
+ );
+
+ return row;
}
function marcControlfield (field) {
- tagname = field.@tag.toString().substr(2);
- var row;
- if (tagname == '1' || tagname == '3' || tagname == '6' || tagname == '7' || tagname == '8') {
- row = createRow(
- { class : 'marcControlfieldRow',
- tag : '_' + tagname },
- createLabel(
- { value : field.@tag,
- class : 'marcTag',
- context : 'tags_popup',
- onmouseover : 'getTooltip(this, "tag");',
- tooltipid : 'tag' + field.@tag } ),
- createLabel(
- { value : field.@ind1,
- class : 'marcInd1',
- onmouseover : 'getTooltip(this, "ind1");',
- tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
- createLabel(
- { value : field.@ind2,
- class : 'marcInd2',
- onmouseover : 'getTooltip(this, "ind2");',
- tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
- createMARCTextbox(
- field,
- { value : field.text(),
- class : 'plain marcEditableControlfield',
- name : 'CONTROL' + tagname,
- context : 'clipboard',
- size : 50,
- maxlength : 50 } )
- );
- } else {
- row = createRow(
- { class : 'marcControlfieldRow',
- tag : '_' + tagname },
- createLabel(
- { value : field.@tag,
- class : 'marcTag',
- onmouseover : 'getTooltip(this, "tag");',
- tooltipid : 'tag' + field.@tag } ),
- createLabel(
- { value : field.@ind1,
- class : 'marcInd1',
- onmouseover : 'getTooltip(this, "ind1");',
- tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
- createLabel(
- { value : field.@ind2,
- class : 'marcInd2',
- onmouseover : 'getTooltip(this, "ind2");',
- tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
- createLabel(
- { value : field.text(),
- class : 'marcControlfield' } )
- );
- }
-
- return row;
+ tagname = field.@tag.toString().substr(2);
+ var row;
+ if (tagname == '1' || tagname == '3' || tagname == '6' || tagname == '7' || tagname == '8') {
+ row = createRow(
+ { class : 'marcControlfieldRow',
+ tag : '_' + tagname },
+ createLabel(
+ { value : field.@tag,
+ class : 'marcTag',
+ context : 'tags_popup',
+ onmouseover : 'getTooltip(this, "tag");',
+ tooltipid : 'tag' + field.@tag } ),
+ createLabel(
+ { value : field.@ind1,
+ class : 'marcInd1',
+ onmouseover : 'getTooltip(this, "ind1");',
+ tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
+ createLabel(
+ { value : field.@ind2,
+ class : 'marcInd2',
+ onmouseover : 'getTooltip(this, "ind2");',
+ tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
+ createMARCTextbox(
+ field,
+ { value : field.text(),
+ class : 'plain marcEditableControlfield',
+ name : 'CONTROL' + tagname,
+ context : 'clipboard',
+ size : 50,
+ maxlength : 50 } )
+ );
+ } else {
+ row = createRow(
+ { class : 'marcControlfieldRow',
+ tag : '_' + tagname },
+ createLabel(
+ { value : field.@tag,
+ class : 'marcTag',
+ onmouseover : 'getTooltip(this, "tag");',
+ tooltipid : 'tag' + field.@tag } ),
+ createLabel(
+ { value : field.@ind1,
+ class : 'marcInd1',
+ onmouseover : 'getTooltip(this, "ind1");',
+ tooltipid : 'tag' + field.@tag + 'ind1val' + field.@ind1 } ),
+ createLabel(
+ { value : field.@ind2,
+ class : 'marcInd2',
+ onmouseover : 'getTooltip(this, "ind2");',
+ tooltipid : 'tag' + field.@tag + 'ind2val' + field.@ind2 } ),
+ createLabel(
+ { value : field.text(),
+ class : 'marcControlfield' } )
+ );
+ }
+
+ return row;
}
function stackSubfields(checkbox) {
- var list = document.getElementsByAttribute('name','sf_box');
-
- var o = 'vertical';
- if (!checkbox.checked) o = 'horizontal';
-
- for (var i = 0; i < list.length; i++) {
- if (list[i]) list[i].setAttribute('orient',o);
- }
+ var list = document.getElementsByAttribute('name','sf_box');
+
+ var o = 'vertical';
+ if (!checkbox.checked) o = 'horizontal';
+
+ for (var i = 0; i < list.length; i++) {
+ if (list[i]) list[i].setAttribute('orient',o);
+ }
}
function fastItemAdd_toggle(checkbox) {
}
function marcDatafield (field) {
- var row = createRow(
- { class : 'marcDatafieldRow' },
- createMARCTextbox(
- field.@tag,
- { value : field.@tag,
- class : 'plain marcTag',
- name : 'marcTag',
- context : 'tags_popup',
- oninput : 'if (this.value.length == 3) { this.nextSibling.focus(); }',
- size : 3,
- maxlength : 3,
- onmouseover : 'current_focus = this; getTooltip(this, "tag");' } ),
- createMARCTextbox(
- field.@ind1,
- { value : field.@ind1,
- class : 'plain marcInd1',
- name : 'marcInd1',
- oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
- size : 1,
- maxlength : 1,
- onmouseover : 'current_focus = this; getContextMenu(this, "ind1"); getTooltip(this, "ind1");',
- oncontextmenu : 'getContextMenu(this, "ind1");' } ),
- createMARCTextbox(
- field.@ind2,
- { value : field.@ind2,
- class : 'plain marcInd2',
- name : 'marcInd2',
- oninput : 'if (this.value.length == 1) { this.nextSibling.firstChild.firstChild.focus(); }',
- size : 1,
- maxlength : 1,
- onmouseover : 'current_focus = this; getContextMenu(this, "ind2"); getTooltip(this, "ind2");',
- oncontextmenu : 'getContextMenu(this, "ind2");' } ),
- createHbox({ name : 'sf_box' })
- );
-
- if (!current_focus && field.@tag == '') current_focus = row.childNodes[0];
- if (!current_focus && field.@ind1 == '') current_focus = row.childNodes[1];
- if (!current_focus && field.@ind2 == '') current_focus = row.childNodes[2];
-
- var sf_box = row.lastChild;
- if (document.getElementById('stackSubfields').checked)
- sf_box.setAttribute('orient','vertical');
-
- sf_box.addEventListener(
- 'click',
- function (e) {
- if (sf_box === e.target) {
- sf_box.lastChild.lastChild.focus();
- } else if (e.target.parentNode === sf_box) {
- e.target.lastChild.focus();
- }
- },
- false
- );
-
-
- for (var i in field.subfield) {
- var sf = field.subfield[i];
- sf_box.appendChild(
- marcSubfield(sf)
- );
-
- if (sf.@code == '' && (!current_focus || current_focus.className.match(/Ind/)))
- current_focus = sf_box.lastChild.childNodes[1];
- }
-
- return row;
+ var row = createRow(
+ { class : 'marcDatafieldRow' },
+ createMARCTextbox(
+ field.@tag,
+ { value : field.@tag,
+ class : 'plain marcTag',
+ name : 'marcTag',
+ context : 'tags_popup',
+ oninput : 'if (this.value.length == 3) { this.nextSibling.focus(); }',
+ size : 3,
+ maxlength : 3,
+ onmouseover : 'current_focus = this; getTooltip(this, "tag");' } ),
+ createMARCTextbox(
+ field.@ind1,
+ { value : field.@ind1,
+ class : 'plain marcInd1',
+ name : 'marcInd1',
+ oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
+ size : 1,
+ maxlength : 1,
+ onmouseover : 'current_focus = this; getContextMenu(this, "ind1"); getTooltip(this, "ind1");',
+ oncontextmenu : 'getContextMenu(this, "ind1");' } ),
+ createMARCTextbox(
+ field.@ind2,
+ { value : field.@ind2,
+ class : 'plain marcInd2',
+ name : 'marcInd2',
+ oninput : 'if (this.value.length == 1) { this.nextSibling.firstChild.firstChild.focus(); }',
+ size : 1,
+ maxlength : 1,
+ onmouseover : 'current_focus = this; getContextMenu(this, "ind2"); getTooltip(this, "ind2");',
+ oncontextmenu : 'getContextMenu(this, "ind2");' } ),
+ createHbox({ name : 'sf_box' })
+ );
+
+ if (!current_focus && field.@tag == '') current_focus = row.childNodes[0];
+ if (!current_focus && field.@ind1 == '') current_focus = row.childNodes[1];
+ if (!current_focus && field.@ind2 == '') current_focus = row.childNodes[2];
+
+ var sf_box = row.lastChild;
+ if (document.getElementById('stackSubfields').checked)
+ sf_box.setAttribute('orient','vertical');
+
+ sf_box.addEventListener(
+ 'click',
+ function (e) {
+ if (sf_box === e.target) {
+ sf_box.lastChild.lastChild.focus();
+ } else if (e.target.parentNode === sf_box) {
+ e.target.lastChild.focus();
+ }
+ },
+ false
+ );
+
+
+ for (var i in field.subfield) {
+ var sf = field.subfield[i];
+ sf_box.appendChild(
+ marcSubfield(sf)
+ );
+
+ if (sf.@code == '' && (!current_focus || current_focus.className.match(/Ind/)))
+ current_focus = sf_box.lastChild.childNodes[1];
+ }
+
+ return row;
}
-function marcSubfield (sf) {
- return createHbox(
- { class : 'marcSubfieldBox' },
- createLabel(
- { value : "\u2021",
- class : 'plain marcSubfieldDelimiter',
- onmouseover : 'getTooltip(this.nextSibling, "subfield");',
- oncontextmenu : 'getContextMenu(this.nextSibling, "subfield");',
- //onclick : 'this.nextSibling.focus();',
- onfocus : 'this.nextSibling.focus();',
- size : 2 } ),
- createMARCTextbox(
- sf.@code,
- { value : sf.@code,
- class : 'plain marcSubfieldCode',
- name : 'marcSubfieldCode',
- onmouseover : 'current_focus = this; getContextMenu(this, "subfield"); getTooltip(this, "subfield");',
- oncontextmenu : 'getContextMenu(this, "subfield");',
- oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
- size : 2,
- maxlength : 1 } ),
- createMARCTextbox(
- sf,
- { value : sf.text(),
- name : sf.parent().@tag + ':' + sf.@code,
- class : 'plain marcSubfield',
- onmouseover : 'getTooltip(this, "subfield");',
- contextmenu : function (event) { getAuthorityContextMenu(event.target, sf) },
- size : new String(sf.text()).length + 2,
- oninput : "this.setAttribute('size', this.value.length + 2);"
- } )
- );
+function marcSubfield (sf) {
+ return createHbox(
+ { class : 'marcSubfieldBox' },
+ createLabel(
+ { value : "\u2021",
+ class : 'plain marcSubfieldDelimiter',
+ onmouseover : 'getTooltip(this.nextSibling, "subfield");',
+ oncontextmenu : 'getContextMenu(this.nextSibling, "subfield");',
+ //onclick : 'this.nextSibling.focus();',
+ onfocus : 'this.nextSibling.focus();',
+ size : 2 } ),
+ createMARCTextbox(
+ sf.@code,
+ { value : sf.@code,
+ class : 'plain marcSubfieldCode',
+ name : 'marcSubfieldCode',
+ onmouseover : 'current_focus = this; getContextMenu(this, "subfield"); getTooltip(this, "subfield");',
+ oncontextmenu : 'getContextMenu(this, "subfield");',
+ oninput : 'if (this.value.length == 1) { this.nextSibling.focus(); }',
+ size : 2,
+ maxlength : 1 } ),
+ createMARCTextbox(
+ sf,
+ { value : sf.text(),
+ name : sf.parent().@tag + ':' + sf.@code,
+ class : 'plain marcSubfield',
+ onmouseover : 'getTooltip(this, "subfield");',
+ contextmenu : function (event) { getAuthorityContextMenu(event.target, sf) },
+ size : new String(sf.text()).length + 2,
+ oninput : "this.setAttribute('size', this.value.length + 2);"
+ } )
+ );
}
function loadRecord(rec) {
- try {
- _record = rec;
- var grid_rows = document.getElementById('recGrid').lastChild;
+ try {
+ _record = rec;
+ var grid_rows = document.getElementById('recGrid').lastChild;
- while (grid_rows.firstChild) grid_rows.removeChild(grid_rows.firstChild);
+ while (grid_rows.firstChild) grid_rows.removeChild(grid_rows.firstChild);
- grid_rows.appendChild( marcLeader( rec.leader ) );
+ grid_rows.appendChild( marcLeader( rec.leader ) );
- for (var i in rec.controlfield) {
- grid_rows.appendChild( marcControlfield( rec.controlfield[i] ) );
- }
+ for (var i in rec.controlfield) {
+ grid_rows.appendChild( marcControlfield( rec.controlfield[i] ) );
+ }
- for (var i in rec.datafield) {
- grid_rows.appendChild( marcDatafield( rec.datafield[i] ) );
- }
+ for (var i in rec.datafield) {
+ grid_rows.appendChild( marcDatafield( rec.datafield[i] ) );
+ }
- grid_rows.getElementsByAttribute('class','marcDatafieldRow')[0].firstChild.focus();
- changeFFEditor(recordType(rec));
- fillFixedFields(rec);
- } catch(E) {
- alert('FIXME, MARC Editor, loadRecord: ' + E);
- }
+ grid_rows.getElementsByAttribute('class','marcDatafieldRow')[0].firstChild.focus();
+ changeFFEditor(recordType(rec));
+ fillFixedFields(rec);
+ } catch(E) {
+ alert('FIXME, MARC Editor, loadRecord: ' + E);
+ }
}
function genToolTips () {
- for (var i in bib_data.field) {
- var f = bib_data.field[i];
-
- tag_menu.appendChild(
- createMenuitem(
- { label : f.@tag,
- oncommand :
- 'current_focus.value = "' + f.@tag + '";' +
- 'var e = document.createEvent("MutationEvents");' +
- 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
- 'current_focus.inputField.dispatchEvent(e);',
- disabled : f.@tag < '010' ? "true" : "false",
- tooltiptext : f.description }
- )
- );
-
- var i1_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i1' });
- context_menus.appendChild( i1_popup );
-
- var i2_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i2' });
- context_menus.appendChild( i2_popup );
-
- var sf_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'sf' });
- context_menus.appendChild( sf_popup );
-
- tooltip_hash['tag' + f.@tag] = f.description;
- for (var j in f.indicator) {
- var ind = f.indicator[j];
- tooltip_hash['tag' + f.@tag + 'ind' + ind.@position + 'val' + ind.@value] = ind.description;
-
- if (ind.@position == 1) {
- i1_popup.appendChild(
- createMenuitem(
- { label : ind.@value,
- oncommand :
- 'current_focus.value = "' + ind.@value + '";' +
- 'var e = document.createEvent("MutationEvents");' +
- 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
- 'current_focus.inputField.dispatchEvent(e);',
- tooltiptext : ind.description }
- )
- );
- }
-
- if (ind.@position == 2) {
- i2_popup.appendChild(
- createMenuitem(
- { label : ind.@value,
- oncommand :
- 'current_focus.value = "' + ind.@value + '";' +
- 'var e = document.createEvent("MutationEvents");' +
- 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
- 'current_focus.inputField.dispatchEvent(e);',
- tooltiptext : ind.description }
- )
- );
- }
- }
-
- for (var j in f.subfield) {
- var sf = f.subfield[j];
- tooltip_hash['tag' + f.@tag + 'sf' + sf.@code] = sf.description;
-
- sf_popup.appendChild(
- createMenuitem(
- { label : sf.@code,
- oncommand :
- 'current_focus.value = "' + sf.@code + '";' +
- 'var e = document.createEvent("MutationEvents");' +
- 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
- 'current_focus.inputField.dispatchEvent(e);',
- tooltiptext : sf.description
- }
- )
- );
- }
- }
+ for (var i in bib_data.field) {
+ var f = bib_data.field[i];
+
+ tag_menu.appendChild(
+ createMenuitem(
+ { label : f.@tag,
+ oncommand :
+ 'current_focus.value = "' + f.@tag + '";' +
+ 'var e = document.createEvent("MutationEvents");' +
+ 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
+ 'current_focus.inputField.dispatchEvent(e);',
+ disabled : f.@tag < '010' ? "true" : "false",
+ tooltiptext : f.description }
+ )
+ );
+
+ var i1_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i1' });
+ context_menus.appendChild( i1_popup );
+
+ var i2_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'i2' });
+ context_menus.appendChild( i2_popup );
+
+ var sf_popup = createPopup({position : 'after_start', id : 't' + f.@tag + 'sf' });
+ context_menus.appendChild( sf_popup );
+
+ tooltip_hash['tag' + f.@tag] = f.description;
+ for (var j in f.indicator) {
+ var ind = f.indicator[j];
+ tooltip_hash['tag' + f.@tag + 'ind' + ind.@position + 'val' + ind.@value] = ind.description;
+
+ if (ind.@position == 1) {
+ i1_popup.appendChild(
+ createMenuitem(
+ { label : ind.@value,
+ oncommand :
+ 'current_focus.value = "' + ind.@value + '";' +
+ 'var e = document.createEvent("MutationEvents");' +
+ 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
+ 'current_focus.inputField.dispatchEvent(e);',
+ tooltiptext : ind.description }
+ )
+ );
+ }
+
+ if (ind.@position == 2) {
+ i2_popup.appendChild(
+ createMenuitem(
+ { label : ind.@value,
+ oncommand :
+ 'current_focus.value = "' + ind.@value + '";' +
+ 'var e = document.createEvent("MutationEvents");' +
+ 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
+ 'current_focus.inputField.dispatchEvent(e);',
+ tooltiptext : ind.description }
+ )
+ );
+ }
+ }
+
+ for (var j in f.subfield) {
+ var sf = f.subfield[j];
+ tooltip_hash['tag' + f.@tag + 'sf' + sf.@code] = sf.description;
+
+ sf_popup.appendChild(
+ createMenuitem(
+ { label : sf.@code,
+ oncommand :
+ 'current_focus.value = "' + sf.@code + '";' +
+ 'var e = document.createEvent("MutationEvents");' +
+ 'e.initMutationEvent("change",1,1,null,0,0,0,0);' +
+ 'current_focus.inputField.dispatchEvent(e);',
+ tooltiptext : sf.description
+ }
+ )
+ );
+ }
+ }
}
function getTooltip (target, type) {
- var tt = '';
- if (type == 'subfield')
- tt = 'tag' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf' + target.parentNode.childNodes[1].value;
-
- if (type == 'ind1')
- tt = 'tag' + target.parentNode.firstChild.value + 'ind1val' + target.value;
-
- if (type == 'ind2')
- tt = 'tag' + target.parentNode.firstChild.value + 'ind2val' + target.value;
-
- if (type == 'tag')
- tt = 'tag' + target.parentNode.firstChild.value;
-
- if (!document.getElementById( tt )) {
- p.appendChild(
- createTooltip(
- { id : tt,
- flex : "1",
- orient : 'vertical',
- onpopupshown : 'this.width = this.firstChild.boxObject.width + 10; this.height = this.firstChild.boxObject.height + 10;',
- class : 'tooltip' },
- createDescription({}, document.createTextNode( tooltip_hash[tt] ) )
- )
- );
- }
-
- target.tooltip = tt;
- return true;
+ var tt = '';
+ if (type == 'subfield')
+ tt = 'tag' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf' + target.parentNode.childNodes[1].value;
+
+ if (type == 'ind1')
+ tt = 'tag' + target.parentNode.firstChild.value + 'ind1val' + target.value;
+
+ if (type == 'ind2')
+ tt = 'tag' + target.parentNode.firstChild.value + 'ind2val' + target.value;
+
+ if (type == 'tag')
+ tt = 'tag' + target.parentNode.firstChild.value;
+
+ if (!document.getElementById( tt )) {
+ p.appendChild(
+ createTooltip(
+ { id : tt,
+ flex : "1",
+ orient : 'vertical',
+ onpopupshown : 'this.width = this.firstChild.boxObject.width + 10; this.height = this.firstChild.boxObject.height + 10;',
+ class : 'tooltip' },
+ createDescription({}, document.createTextNode( tooltip_hash[tt] ) )
+ )
+ );
+ }
+
+ target.tooltip = tt;
+ return true;
}
function getContextMenu (target, type) {
- var tt = '';
- if (type == 'subfield')
- tt = 't' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf';
+ var tt = '';
+ if (type == 'subfield')
+ tt = 't' + target.parentNode.parentNode.parentNode.firstChild.value + 'sf';
- if (type == 'ind1')
- tt = 't' + target.parentNode.firstChild.value + 'i1';
+ if (type == 'ind1')
+ tt = 't' + target.parentNode.firstChild.value + 'i1';
- if (type == 'ind2')
- tt = 't' + target.parentNode.firstChild.value + 'i2';
+ if (type == 'ind2')
+ tt = 't' + target.parentNode.firstChild.value + 'i2';
- target.setAttribute('context', tt);
- return true;
+ target.setAttribute('context', tt);
+ return true;
}
var authority_tag_map = {
- 100 : ['[100,400,500,700]',100],
- 400 : ['[100,400,500,700]',100],
- 700 : ['[100,400,500,700]',100],
- 800 : ['[100,400,500,700]',100],
- 110 : ['[110,410,510,710]',110],
- 410 : ['[110,410,510,710]',110],
- 710 : ['[110,410,510,710]',110],
- 810 : ['[110,410,510,710]',110],
- 111 : ['[111,411,511,711]',111],
- 411 : ['[111,411,511,711]',111],
- 711 : ['[111,411,511,711]',111],
- 811 : ['[111,411,511,711]',111],
- 240 : ['[130,430,530,730]',130],
- 440 : ['[130,430,530,730]',130],
- 130 : ['[130,430,530,730]',130],
- 730 : ['[130,430,530,730]',130],
- 830 : ['[130,430,530,730]',130],
- 600 : ['[100,400,480,481,482,485,500,580,581,582,585,700,780,781,782,785]',100],
- 650 : ['[150,450,480,481,482,485,550,580,581,582,585,750,780,781,782,785]',150],
- 651 : ['[151,451,480,481,482,485,551,580,581,582,585,751,780,781,782,785]',151],
- 655 : ['[155,455,480,481,482,485,555,580,581,582,585,755,780,781,782,785]',155]
+ 100 : ['[100,400,500,700]',100],
+ 400 : ['[100,400,500,700]',100],
+ 700 : ['[100,400,500,700]',100],
+ 800 : ['[100,400,500,700]',100],
+ 110 : ['[110,410,510,710]',110],
+ 410 : ['[110,410,510,710]',110],
+ 710 : ['[110,410,510,710]',110],
+ 810 : ['[110,410,510,710]',110],
+ 111 : ['[111,411,511,711]',111],
+ 411 : ['[111,411,511,711]',111],
+ 711 : ['[111,411,511,711]',111],
+ 811 : ['[111,411,511,711]',111],
+ 240 : ['[130,430,530,730]',130],
+ 440 : ['[130,430,530,730]',130],
+ 130 : ['[130,430,530,730]',130],
+ 730 : ['[130,430,530,730]',130],
+ 830 : ['[130,430,530,730]',130],
+ 600 : ['[100,400,480,481,482,485,500,580,581,582,585,700,780,781,782,785]',100],
+ 650 : ['[150,450,480,481,482,485,550,580,581,582,585,750,780,781,782,785]',150],
+ 651 : ['[151,451,480,481,482,485,551,580,581,582,585,751,780,781,782,785]',151],
+ 655 : ['[155,455,480,481,482,485,555,580,581,582,585,755,780,781,782,785]',155]
};
function getAuthorityContextMenu (target, sf) {
- var menu_id = sf.parent().@tag + ':' + sf.@code + '-authority-context-' + sf;
+ var menu_id = sf.parent().@tag + ':' + sf.@code + '-authority-context-' + sf;
- var old = document.getElementById( menu_id );
- if (old) old.parentNode.removeChild(old);
+ var old = document.getElementById( menu_id );
+ if (old) old.parentNode.removeChild(old);
- var sf_popup = createPopup({ id : menu_id, flex : 1 });
- context_menus.appendChild( sf_popup );
+ var sf_popup = createPopup({ id : menu_id, flex : 1 });
+ context_menus.appendChild( sf_popup );
- if (!authority_tag_map[sf.parent().@tag]) {
- sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.not_authority_field.label') } ) );
- target.setAttribute('context', 'clipboard');
- return false;
- }
-
- var auth_data = searchAuthority( sf, authority_tag_map[sf.parent().@tag][0], sf.@code, 50);
-
- var res = new XML( auth_data.responseText );
+ if (!authority_tag_map[sf.parent().@tag]) {
+ sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.not_authority_field.label') } ) );
+ target.setAttribute('context', 'clipboard');
+ return false;
+ }
- var rec_list = [];
+ var auth_data = searchAuthority( sf, authority_tag_map[sf.parent().@tag][0], sf.@code, 50);
- var recs = res.gw::payload.gw::array.gw::string;
- for (var i in recs) {
- var x = recs[i];
- var xml = new XML(x.toString());
- var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
+ var res = new XML( auth_data.responseText );
- if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
+ var rec_list = [];
- var main_text = '';
- for (var i in main) {
- if (main_text) main_text += ' / ';
- main_text += main[i];
- }
+ var recs = res.gw::payload.gw::array.gw::string;
+ for (var i in recs) {
+ var x = recs[i];
+ var xml = new XML(x.toString());
+ var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
- rec_list.push( [ main_text, xml ] );
- }
-
- for (var i in rec_list.sort( function (a, b) { if(a[0] > b[0]) return 1; return -1; } )) {
+ if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
- var main_text = rec_list[i][0];
- var xml = rec_list[i][1];
- var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
+ var main_text = '';
+ for (var i in main) {
+ if (main_text) main_text += ' / ';
+ main_text += main[i];
+ }
- if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
+ rec_list.push( [ main_text, xml ] );
+ }
+
+ for (var i in rec_list.sort( function (a, b) { if(a[0] > b[0]) return 1; return -1; } )) {
- var grid = document.getElementsByAttribute('name','authority-marc-template')[0].cloneNode(true);
- grid.setAttribute('name','-none-');
- grid.setAttribute('style','overflow:scroll');
+ var main_text = rec_list[i][0];
+ var xml = rec_list[i][1];
+ var main = xml.datafield.(@tag.toString().match(/^1/)).subfield;
+ if (! (main[0].parent().@tag == authority_tag_map[sf.parent().@tag][1]) ) continue;
- var submenu = createMenu( { label : main_text } );
+ var grid = document.getElementsByAttribute('name','authority-marc-template')[0].cloneNode(true);
+ grid.setAttribute('name','-none-');
+ grid.setAttribute('style','overflow:scroll');
- var popup = createMenuPopup({ flex : "1" });
- submenu.appendChild(popup);
- var fields = xml.datafield;
- for (var j in fields) {
+ var submenu = createMenu( { label : main_text } );
- var row = createRow(
- {},
- createLabel( { value : fields[j].@tag } ),
- createLabel( { value : fields[j].@ind1 } ),
- createLabel( { value : fields[j].@ind2 } )
- );
+ var popup = createMenuPopup({ flex : "1" });
+ submenu.appendChild(popup);
- var sf_box = createHbox();
+ var fields = xml.datafield;
+ for (var j in fields) {
- var subfields = fields[j].subfield;
- for (var k in subfields) {
- sf_box.appendChild(
- createCheckbox(
- { label : '\u2021' + subfields[k].@code + ' ' + subfields[k],
- subfield : subfields[k].@code,
- tag : subfields[k].parent().@tag,
- value : subfields[k]
- }
- )
- );
- row.appendChild(sf_box);
- }
+ var row = createRow(
+ {},
+ createLabel( { value : fields[j].@tag } ),
+ createLabel( { value : fields[j].@ind1 } ),
+ createLabel( { value : fields[j].@ind2 } )
+ );
- grid.lastChild.appendChild(row);
- }
+ var sf_box = createHbox();
- grid.hidden = false;
- popup.appendChild( grid );
+ var subfields = fields[j].subfield;
+ for (var k in subfields) {
+ sf_box.appendChild(
+ createCheckbox(
+ { label : '\u2021' + subfields[k].@code + ' ' + subfields[k],
+ subfield : subfields[k].@code,
+ tag : subfields[k].parent().@tag,
+ value : subfields[k]
+ }
+ )
+ );
+ row.appendChild(sf_box);
+ }
- popup.appendChild(
- createMenuitem(
- { label : $('catStrings').getString('staff.cat.marcedit.apply_selected.label'),
- command : function (event) {
- applyAuthority(event.target.previousSibling, target, sf);
- return true;
- }
- }
- )
- );
+ grid.lastChild.appendChild(row);
+ }
- sf_popup.appendChild( submenu );
- }
+ grid.hidden = false;
+ popup.appendChild( grid );
+
+ popup.appendChild(
+ createMenuitem(
+ { label : $('catStrings').getString('staff.cat.marcedit.apply_selected.label'),
+ command : function (event) {
+ applyAuthority(event.target.previousSibling, target, sf);
+ return true;
+ }
+ }
+ )
+ );
+
+ sf_popup.appendChild( submenu );
+ }
- if (sf_popup.childNodes.length == 0)
- sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.no_authority_match.label') } ) );
+ if (sf_popup.childNodes.length == 0)
+ sf_popup.appendChild(createLabel( { value : $('catStrings').getString('staff.cat.marcedit.no_authority_match.label') } ) );
- target.setAttribute('context', menu_id);
- return true;
+ target.setAttribute('context', menu_id);
+ return true;
}
function applyAuthority ( target, ui_sf, e4x_sf ) {
- var new_vals = target.getElementsByAttribute('checked','true');
- var field = e4x_sf.parent();
+ var new_vals = target.getElementsByAttribute('checked','true');
+ var field = e4x_sf.parent();
- for (var i = 0; i < new_vals.length; i++) {
+ for (var i = 0; i < new_vals.length; i++) {
- var sf_list = field.subfield;
- for (var j in sf_list) {
+ var sf_list = field.subfield;
+ for (var j in sf_list) {
- if (sf_list[j].@code == new_vals[i].getAttribute('subfield')) {
- sf_list[j] = new_vals[i].getAttribute('value');
- new_vals[i].setAttribute('subfield','');
- break;
- }
- }
- }
+ if (sf_list[j].@code == new_vals[i].getAttribute('subfield')) {
+ sf_list[j] = new_vals[i].getAttribute('value');
+ new_vals[i].setAttribute('subfield','');
+ break;
+ }
+ }
+ }
- for (var i = 0; i < new_vals.length; i++) {
- if (!new_vals[i].getAttribute('subfield')) continue;
+ for (var i = 0; i < new_vals.length; i++) {
+ if (!new_vals[i].getAttribute('subfield')) continue;
- var val = new_vals[i].getAttribute('value');
+ var val = new_vals[i].getAttribute('value');
- var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{val}</subfield>;
- sf.@code = new_vals[i].getAttribute('subfield');
+ var sf = <subfield code="" xmlns="http://www.loc.gov/MARC21/slim">{val}</subfield>;
+ sf.@code = new_vals[i].getAttribute('subfield');
- field.insertChildAfter(field.subfield[field.subfield.length() - 1], sf);
- }
+ field.insertChildAfter(field.subfield[field.subfield.length() - 1], sf);
+ }
- var row = marcDatafield( field );
+ var row = marcDatafield( field );
- var node = ui_sf;
- while (node.nodeName != 'row') {
- node = node.parentNode;
- }
+ var node = ui_sf;
+ while (node.nodeName != 'row') {
+ node = node.parentNode;
+ }
- node.parentNode.replaceChild( row, node );
- return true;
+ node.parentNode.replaceChild( row, node );
+ return true;
}
var control_map = {
- 100 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' },
- 'q' : { 100 : 'q' }
- },
- 110 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' }
- },
- 111 : {
- 'a' : { 111 : 'a' },
- 'd' : { 111 : 'd' }
- },
- 130 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 240 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 400 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' }
- },
- 410 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' }
- },
- 411 : {
- 'a' : { 111 : 'a' },
- 'd' : { 111 : 'd' }
- },
- 440 : {
- 'a' : { 130 : 'a' },
- 'n' : { 130 : 'n' },
- 'p' : { 130 : 'p' }
- },
- 700 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' },
- 'q' : { 100 : 'q' },
- 't' : { 100 : 't' }
- },
- 710 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' }
- },
- 711 : {
- 'a' : { 111 : 'a' },
- 'd' : { 111 : 'd' }
- },
- 730 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 800 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' }
- },
- 810 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' }
- },
- 811 : {
- 'a' : { 111 : 'a' },
- 'd' : { 111 : 'd' }
- },
- 830 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 600 : {
- 'a' : { 100 : 'a' },
- 'd' : { 100 : 'd' },
- 'q' : { 100 : 'q' },
- 't' : { 100 : 't' },
- 'v' : { 180 : 'v',
- 100 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 100 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 100 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 100 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 610 : {
- 'a' : { 110 : 'a' },
- 'd' : { 110 : 'd' },
- 't' : { 110 : 't' },
- 'v' : { 180 : 'v',
- 110 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 110 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 110 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 110 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 611 : {
- 'a' : { 111 : 'a' },
- 'd' : { 111 : 'd' },
- 't' : { 111 : 't' },
- 'v' : { 180 : 'v',
- 111 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 111 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 111 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 111 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 630 : {
- 'a' : { 130 : 'a' },
- 'd' : { 130 : 'd' }
- },
- 650 : {
- 'a' : { 150 : 'a' },
- 'b' : { 150 : 'b' },
- 'v' : { 180 : 'v',
- 150 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 150 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 150 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 150 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 651 : {
- 'a' : { 151 : 'a' },
- 'v' : { 180 : 'v',
- 151 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 151 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 151 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 151 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- },
- 655 : {
- 'a' : { 155 : 'a' },
- 'v' : { 180 : 'v',
- 155 : 'v',
- 181 : 'v',
- 182 : 'v',
- 185 : 'v'
- },
- 'x' : { 180 : 'x',
- 155 : 'x',
- 181 : 'x',
- 182 : 'x',
- 185 : 'x'
- },
- 'y' : { 180 : 'y',
- 155 : 'y',
- 181 : 'y',
- 182 : 'y',
- 185 : 'y'
- },
- 'z' : { 180 : 'z',
- 155 : 'z',
- 181 : 'z',
- 182 : 'z',
- 185 : 'z'
- }
- }
+ 100 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' },
+ 'q' : { 100 : 'q' }
+ },
+ 110 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' }
+ },
+ 111 : {
+ 'a' : { 111 : 'a' },
+ 'd' : { 111 : 'd' }
+ },
+ 130 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 240 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 400 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' }
+ },
+ 410 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' }
+ },
+ 411 : {
+ 'a' : { 111 : 'a' },
+ 'd' : { 111 : 'd' }
+ },
+ 440 : {
+ 'a' : { 130 : 'a' },
+ 'n' : { 130 : 'n' },
+ 'p' : { 130 : 'p' }
+ },
+ 700 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' },
+ 'q' : { 100 : 'q' },
+ 't' : { 100 : 't' }
+ },
+ 710 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' }
+ },
+ 711 : {
+ 'a' : { 111 : 'a' },
+ 'd' : { 111 : 'd' }
+ },
+ 730 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 800 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' }
+ },
+ 810 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' }
+ },
+ 811 : {
+ 'a' : { 111 : 'a' },
+ 'd' : { 111 : 'd' }
+ },
+ 830 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 600 : {
+ 'a' : { 100 : 'a' },
+ 'd' : { 100 : 'd' },
+ 'q' : { 100 : 'q' },
+ 't' : { 100 : 't' },
+ 'v' : { 180 : 'v',
+ 100 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 100 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 100 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 100 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 610 : {
+ 'a' : { 110 : 'a' },
+ 'd' : { 110 : 'd' },
+ 't' : { 110 : 't' },
+ 'v' : { 180 : 'v',
+ 110 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 110 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 110 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 110 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 611 : {
+ 'a' : { 111 : 'a' },
+ 'd' : { 111 : 'd' },
+ 't' : { 111 : 't' },
+ 'v' : { 180 : 'v',
+ 111 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 111 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 111 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 111 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 630 : {
+ 'a' : { 130 : 'a' },
+ 'd' : { 130 : 'd' }
+ },
+ 650 : {
+ 'a' : { 150 : 'a' },
+ 'b' : { 150 : 'b' },
+ 'v' : { 180 : 'v',
+ 150 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 150 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 150 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 150 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 651 : {
+ 'a' : { 151 : 'a' },
+ 'v' : { 180 : 'v',
+ 151 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 151 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 151 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 151 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ },
+ 655 : {
+ 'a' : { 155 : 'a' },
+ 'v' : { 180 : 'v',
+ 155 : 'v',
+ 181 : 'v',
+ 182 : 'v',
+ 185 : 'v'
+ },
+ 'x' : { 180 : 'x',
+ 155 : 'x',
+ 181 : 'x',
+ 182 : 'x',
+ 185 : 'x'
+ },
+ 'y' : { 180 : 'y',
+ 155 : 'y',
+ 181 : 'y',
+ 182 : 'y',
+ 185 : 'y'
+ },
+ 'z' : { 180 : 'z',
+ 155 : 'z',
+ 181 : 'z',
+ 182 : 'z',
+ 185 : 'z'
+ }
+ }
};
function validateAuthority (button) {
- var grid = document.getElementById('recGrid');
- var label = button.getAttribute('label');
+ var grid = document.getElementById('recGrid');
+ var label = button.getAttribute('label');
- //loop over rows
- var rows = grid.lastChild.childNodes;
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i];
- var tag = row.firstChild;
+ //loop over rows
+ var rows = grid.lastChild.childNodes;
+ for (var i = 0; i < rows.length; i++) {
+ var row = rows[i];
+ var tag = row.firstChild;
- if (!control_map[tag.value]) continue
- button.setAttribute('label', label + ' - ' + tag.value);
+ if (!control_map[tag.value]) continue
+ button.setAttribute('label', label + ' - ' + tag.value);
- var ind1 = tag.nextSibling;
- var ind2 = ind1.nextSibling;
- var subfields = ind2.nextSibling.childNodes;
+ var ind1 = tag.nextSibling;
+ var ind2 = ind1.nextSibling;
+ var subfields = ind2.nextSibling.childNodes;
var tags = {};
- for (var j = 0; j < subfields.length; j++) {
- var sf = subfields[j];
+ for (var j = 0; j < subfields.length; j++) {
+ var sf = subfields[j];
var sf_code = sf.childNodes[1].value;
var sf_value = sf.childNodes[2].value;
- if (!control_map[tag.value][sf_code]) continue;
+ if (!control_map[tag.value][sf_code]) continue;
- var found = 0;
- for (var a_tag in control_map[tag.value][sf_code]) {
+ var found = 0;
+ for (var a_tag in control_map[tag.value][sf_code]) {
if (!tags[a_tag]) tags[a_tag] = [];
tags[a_tag].push({ term : sf_value, subfield : sf_code });
- }
+ }
- }
+ }
for (var val_tag in tags) {
- var auth_data = validateBibField( [val_tag], tags[val_tag]);
- var res = new XML( auth_data.responseText );
- found = parseInt(res.gw::payload.gw::string.toString());
+ var auth_data = validateBibField( [val_tag], tags[val_tag]);
+ var res = new XML( auth_data.responseText );
+ found = parseInt(res.gw::payload.gw::string.toString());
if (found) break;
}
- // XXX If adt, etc should be validated separately from vxz, etc then move this up into the above for loop
- for (var j = 0; j < subfields.length; j++) {
- var sf = subfields[j];
- if (!found) {
- sf.childNodes[2].inputField.style.color = 'red';
- } else {
- sf.childNodes[2].inputField.style.color = 'black';
- }
+ // XXX If adt, etc should be validated separately from vxz, etc then move this up into the above for loop
+ for (var j = 0; j < subfields.length; j++) {
+ var sf = subfields[j];
+ if (!found) {
+ sf.childNodes[2].inputField.style.color = 'red';
+ } else {
+ sf.childNodes[2].inputField.style.color = 'black';
+ }
}
- }
+ }
- button.setAttribute('label', label);
+ button.setAttribute('label', label);
- return true;
+ return true;
}
function validateBibField (tags, searches) {
- var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.validate.tag";
- url += '¶m="tags"¶m=' + js2JSON(tags);
- url += '¶m="searches"¶m=' + js2JSON(searches);
+ var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.validate.tag";
+ url += '¶m="tags"¶m=' + js2JSON(tags);
+ url += '¶m="searches"¶m=' + js2JSON(searches);
- var req = new XMLHttpRequest();
- req.open('GET',url,false);
- req.send(null);
+ var req = new XMLHttpRequest();
+ req.open('GET',url,false);
+ req.send(null);
- return req;
+ return req;
}
function searchAuthority (term, tag, sf, limit) {
- var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.fts";
- url += '¶m="term"¶m="' + term + '"';
- url += '¶m="limit"¶m=' + limit;
- url += '¶m="tag"¶m=' + tag;
- url += '¶m="subfield"¶m="' + sf + '"';
+ var url = "/gateway?input_format=json&format=xml&service=open-ils.search&method=open-ils.search.authority.fts";
+ url += '¶m="term"¶m="' + term + '"';
+ url += '¶m="limit"¶m=' + limit;
+ url += '¶m="tag"¶m=' + tag;
+ url += '¶m="subfield"¶m="' + sf + '"';
- var req = new XMLHttpRequest();
- req.open('GET',url,false);
- req.send(null);
+ var req = new XMLHttpRequest();
+ req.open('GET',url,false);
+ req.send(null);
- return req;
+ return req;
}
if (typeof cat == 'undefined') cat = {};
cat.record_buckets = 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'});
+ 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'});
var x = document.getElementById("record_buckets_tabbox");
if (x) {
x.addEventListener(
};
cat.record_buckets.pick_file = function (defaultFileName) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var nsIFilePicker = Components.interfaces.nsIFilePicker;
- var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance( nsIFilePicker );
+ var nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance( nsIFilePicker );
- fp.init( window, $("catStrings").getString('staff.cat.record_buckets.save_file_as'), nsIFilePicker.modeSave );
- if (defaultFileName)
- fp.defaultString = defaultFileName;
+ fp.init( window, $("catStrings").getString('staff.cat.record_buckets.save_file_as'), nsIFilePicker.modeSave );
+ if (defaultFileName)
+ fp.defaultString = defaultFileName;
- fp.appendFilters( nsIFilePicker.filterAll );
+ fp.appendFilters( nsIFilePicker.filterAll );
- var result = fp.show();
- if ( (result == nsIFilePicker.returnOK || result == nsIFilePicker.returnReplace) && fp.file ) {
- return fp.file;
- } else {
- return null;
- }
+ var result = fp.show();
+ if ( (result == nsIFilePicker.returnOK || result == nsIFilePicker.returnReplace) && fp.file ) {
+ return fp.file;
+ } else {
+ return null;
+ }
};
cat.record_buckets.export_records = function(obj, output_type) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.list2.select_all();
- obj.data.stash_retrieve();
- JSAN.use('util.functional');
-
- var record_ids = util.functional.map_list(
- obj.list2.dump_retrieve_ids(),
- function (o) { return JSON2js(o).docid }
- );
-
- var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
- .createInstance(Components.interfaces.nsIWebBrowserPersist);
-
- var proto_uri = 'https://' + window.location.hostname + '/exporter?format=' + output_type + '&ses=' + ses();
-
- dump('Record Export URI is ' + proto_uri + '&id=' + record_ids.join('&id=') + '\n');
-
- var uri = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService)
- .newURI( proto_uri + '&id=' + record_ids.join('&id='), null, null );
-
- var file = cat.record_buckets.pick_file('bucket.' + output_type);
-
- if (file) {
- persist.saveURI(uri,null,null,null,null,file);
- } else {
- alert( $("catStrings").getString('staff.cat.record_buckets.export_records.alert') );
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.export_records.std_unexpected_error'), E);
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.list2.select_all();
+ obj.data.stash_retrieve();
+ JSAN.use('util.functional');
+
+ var record_ids = util.functional.map_list(
+ obj.list2.dump_retrieve_ids(),
+ function (o) { return JSON2js(o).docid }
+ );
+
+ var persist = Components.classes["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
+ .createInstance(Components.interfaces.nsIWebBrowserPersist);
+
+ var proto_uri = 'https://' + window.location.hostname + '/exporter?format=' + output_type + '&ses=' + ses();
+
+ dump('Record Export URI is ' + proto_uri + '&id=' + record_ids.join('&id=') + '\n');
+
+ var uri = Components.classes["@mozilla.org/network/io-service;1"]
+ .getService(Components.interfaces.nsIIOService)
+ .newURI( proto_uri + '&id=' + record_ids.join('&id='), null, null );
+
+ var file = cat.record_buckets.pick_file('bucket.' + output_type);
+
+ if (file) {
+ persist.saveURI(uri,null,null,null,null,file);
+ } else {
+ alert( $("catStrings").getString('staff.cat.record_buckets.export_records.alert') );
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.export_records.std_unexpected_error'), E);
+ }
};
cat.record_buckets.prototype = {
- 'selection_list0' : [],
- 'selection_list1' : [],
- 'selection_list2' : [],
- 'bucket_id_name_map' : {},
-
- 'render_pending_records' : function() {
- var obj = this;
- obj.list1.clear();
- for (var i = 0; i < obj.record_ids.length; i++) {
- var item = obj.prep_record_for_list( obj.record_ids[i] );
- if (item) obj.list1.append( item );
- }
- },
-
- 'init' : function( params ) {
-
- var obj = this;
-
- obj.record_ids = params['record_ids'] || [];
-
- JSAN.use('circ.util');
- var columns = circ.util.columns(
- {
- 'title' : { 'hidden' : false },
- 'author' : { 'hidden' : false },
- 'edition' : { 'hidden' : false },
- 'publisher' : { 'hidden' : false },
- 'pubdate' : { 'hidden' : false },
- 'isbn' : { 'hidden' : false },
- 'tcn' : { 'hidden' : false }
- }
- );
-
- JSAN.use('util.list');
+ 'selection_list0' : [],
+ 'selection_list1' : [],
+ 'selection_list2' : [],
+ 'bucket_id_name_map' : {},
+
+ 'render_pending_records' : function() {
+ var obj = this;
+ obj.list1.clear();
+ for (var i = 0; i < obj.record_ids.length; i++) {
+ var item = obj.prep_record_for_list( obj.record_ids[i] );
+ if (item) obj.list1.append( item );
+ }
+ },
+
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ obj.record_ids = params['record_ids'] || [];
+
+ JSAN.use('circ.util');
+ var columns = circ.util.columns(
+ {
+ 'title' : { 'hidden' : false },
+ 'author' : { 'hidden' : false },
+ 'edition' : { 'hidden' : false },
+ 'publisher' : { 'hidden' : false },
+ 'pubdate' : { 'hidden' : false },
+ 'isbn' : { 'hidden' : false },
+ 'tcn' : { 'hidden' : false }
+ }
+ );
+
+ JSAN.use('util.list');
function retrieve_row(params) {
var row = params.row;
try {
- obj.network.simple_request( 'MODS_SLIM_RECORD_RETRIEVE.authoritative', [ row.my.docid ],
+ obj.network.simple_request( 'MODS_SLIM_RECORD_RETRIEVE.authoritative', [ row.my.docid ],
function(req) {
try {
var record = req.getResultObject();
return row;
}
- obj.list0 = new util.list('record_query_list');
- obj.list0.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ obj.list0 = new util.list('record_query_list');
+ obj.list0.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
'retrieve_row' : retrieve_row,
- 'on_select' : function(ev) {
- try {
- JSAN.use('util.functional');
- var sel = obj.list0.retrieve_selection();
- obj.controller.view.sel_clip1.setAttribute('disabled', sel.length < 1 ? "true" : "false");
- obj.selection_list0 = util.functional.map_list(
- sel,
- function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
- );
- obj.error.sdump('D_TRACE','circ/record_buckets: selection list 0 = ' + js2JSON(obj.selection_list1) );
- if (obj.selection_list0.length == 0) {
- obj.controller.view.cmd_add_sel_query_to_pending.setAttribute('disabled','true');
- } else {
- obj.controller.view.cmd_add_sel_query_to_pending.setAttribute('disabled','false');
- }
- } catch(E) {
- alert('FIXME: ' + E);
- }
- }
-
- }
- );
-
- obj.list1 = new util.list('pending_records_list');
- obj.list1.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'on_select' : function(ev) {
+ try {
+ JSAN.use('util.functional');
+ var sel = obj.list0.retrieve_selection();
+ obj.controller.view.sel_clip1.setAttribute('disabled', sel.length < 1 ? "true" : "false");
+ obj.selection_list0 = util.functional.map_list(
+ sel,
+ function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
+ );
+ obj.error.sdump('D_TRACE','circ/record_buckets: selection list 0 = ' + js2JSON(obj.selection_list1) );
+ if (obj.selection_list0.length == 0) {
+ obj.controller.view.cmd_add_sel_query_to_pending.setAttribute('disabled','true');
+ } else {
+ obj.controller.view.cmd_add_sel_query_to_pending.setAttribute('disabled','false');
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ }
+
+ }
+ );
+
+ obj.list1 = new util.list('pending_records_list');
+ obj.list1.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
'retrieve_row' : retrieve_row,
- 'on_select' : function(ev) {
- try {
- JSAN.use('util.functional');
- var sel = obj.list1.retrieve_selection();
- obj.controller.view.sel_clip1.setAttribute('disabled', sel.length < 1 ? "true" : "false");
- obj.selection_list1 = util.functional.map_list(
- sel,
- function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
- );
- obj.error.sdump('D_TRACE','circ/record_buckets: selection list 1 = ' + js2JSON(obj.selection_list1) );
- if (obj.selection_list1.length == 0) {
- obj.controller.view.cmd_add_sel_pending_to_record_bucket.setAttribute('disabled','true');
- } else {
- obj.controller.view.cmd_add_sel_pending_to_record_bucket.setAttribute('disabled','false');
- }
- } catch(E) {
- alert('FIXME: ' + E);
- }
- }
-
- }
- );
-
- obj.render_pending_records();
-
- obj.list2 = new util.list('records_in_bucket_list');
- obj.list2.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'on_select' : function(ev) {
+ try {
+ JSAN.use('util.functional');
+ var sel = obj.list1.retrieve_selection();
+ obj.controller.view.sel_clip1.setAttribute('disabled', sel.length < 1 ? "true" : "false");
+ obj.selection_list1 = util.functional.map_list(
+ sel,
+ function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
+ );
+ obj.error.sdump('D_TRACE','circ/record_buckets: selection list 1 = ' + js2JSON(obj.selection_list1) );
+ if (obj.selection_list1.length == 0) {
+ obj.controller.view.cmd_add_sel_pending_to_record_bucket.setAttribute('disabled','true');
+ } else {
+ obj.controller.view.cmd_add_sel_pending_to_record_bucket.setAttribute('disabled','false');
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ }
+
+ }
+ );
+
+ obj.render_pending_records();
+
+ obj.list2 = new util.list('records_in_bucket_list');
+ obj.list2.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
'retrieve_row' : retrieve_row,
- 'on_select' : function(ev) {
- try {
- JSAN.use('util.functional');
- var sel = obj.list2.retrieve_selection();
- obj.controller.view.sel_clip2.setAttribute('disabled', sel.length < 1 ? "true" : "false");
- obj.selection_list2 = util.functional.map_list(
- sel,
- function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
- );
- obj.error.sdump('D_TRACE','circ/record_buckets: selection list 2 = ' + js2JSON(obj.selection_list2) );
- if (obj.selection_list2.length == 0) {
- obj.controller.view.cmd_record_buckets_delete_item.setAttribute('disabled','true');
- obj.controller.view.cmd_record_buckets_to_pending_buckets.setAttribute('disabled','true');
- } else {
- obj.controller.view.cmd_record_buckets_delete_item.setAttribute('disabled','false');
- obj.controller.view.cmd_record_buckets_to_pending_buckets.setAttribute('disabled','false');
- }
- } catch(E) {
- alert('FIXME: ' + E);
- }
- }
- }
- );
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'save_columns2' : [
- ['command'],
- function() { obj.list2.save_columns(); }
- ],
- 'save_columns1' : [
- ['command'],
- function() { obj.list1.save_columns(); }
- ],
- 'save_columns0' : [
- ['command'],
- function() { obj.list0.save_columns(); }
- ],
- 'sel_clip2' : [
- ['command'],
- function() { obj.list2.clipboard(); }
- ],
- 'sel_clip1' : [
- ['command'],
- function() { obj.list1.clipboard(); }
- ],
- 'sel_clip0' : [
- ['command'],
- function() { obj.list0.clipboard(); }
- ],
+ 'on_select' : function(ev) {
+ try {
+ JSAN.use('util.functional');
+ var sel = obj.list2.retrieve_selection();
+ obj.controller.view.sel_clip2.setAttribute('disabled', sel.length < 1 ? "true" : "false");
+ obj.selection_list2 = util.functional.map_list(
+ sel,
+ function(o) { return JSON2js(o.getAttribute('retrieve_id')); }
+ );
+ obj.error.sdump('D_TRACE','circ/record_buckets: selection list 2 = ' + js2JSON(obj.selection_list2) );
+ if (obj.selection_list2.length == 0) {
+ obj.controller.view.cmd_record_buckets_delete_item.setAttribute('disabled','true');
+ obj.controller.view.cmd_record_buckets_to_pending_buckets.setAttribute('disabled','true');
+ } else {
+ obj.controller.view.cmd_record_buckets_delete_item.setAttribute('disabled','false');
+ obj.controller.view.cmd_record_buckets_to_pending_buckets.setAttribute('disabled','false');
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ }
+ }
+ );
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'save_columns2' : [
+ ['command'],
+ function() { obj.list2.save_columns(); }
+ ],
+ 'save_columns1' : [
+ ['command'],
+ function() { obj.list1.save_columns(); }
+ ],
+ 'save_columns0' : [
+ ['command'],
+ function() { obj.list0.save_columns(); }
+ ],
+ 'sel_clip2' : [
+ ['command'],
+ function() { obj.list2.clipboard(); }
+ ],
+ 'sel_clip1' : [
+ ['command'],
+ function() { obj.list1.clipboard(); }
+ ],
+ 'sel_clip0' : [
+ ['command'],
+ function() { obj.list0.clipboard(); }
+ ],
'record_query_input' : [
['render'],
function(ev) {
['command'],
function() { obj.submit(); }
],
- 'record_buckets_menulist_placeholder' : [
- ['render'],
- function(e) {
- return function() {
- JSAN.use('util.widgets'); JSAN.use('util.functional');
- var buckets = obj.network.simple_request(
- 'BUCKET_RETRIEVE_VIA_USER',
- [ ses(), obj.data.list.au[0].id() ]
- );
- if (typeof buckets.ilsevent != 'undefined') {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.buckets.std_unexpected_error'), buckets);
- return;
- }
- var items = [
- [$("catStrings").getString('staff.cat.record_buckets.menulist_placeholder.item1'),''],
- [$("catStrings").getString('staff.cat.record_buckets.menulist_placeholder.item2'),-1]
- ].concat(
- util.functional.map_list(
- util.functional.filter_list(
- buckets.biblio,
- function(o) {
- return o.btype() == 'staff_client';
- }
- ),
- function(o) {
- obj.bucket_id_name_map[ o.id() ] = o.name();
- return [ o.name(), o.id() ];
- }
- ).sort(
- function( a, b ) {
- if (a[0] < b[0]) return -1;
- if (a[0] > b[0]) return 1;
- return 0;
- }
- )
- );
- obj.error.sdump('D_TRACE','items = ' + js2JSON(items));
- util.widgets.remove_children( e );
- var ml = util.widgets.make_menulist(
- items
- );
- e.appendChild( ml );
- ml.setAttribute('id','bucket_menulist');
- ml.setAttribute('accesskey','');
-
- function change_bucket(ev) {
- var bucket_id = ev.target.value;
- if (bucket_id < 0 ) {
- bucket_id = window.prompt($("catStrings").getString('staff.cat.record_buckets.change_bucket.bucket_id'));
- ev.target.value = bucket_id;
- ev.target.setAttribute('value',bucket_id);
- }
- if (!bucket_id) return;
- var x = document.getElementById('info_box');
- if (x) x.setAttribute('hidden','true');
+ 'record_buckets_menulist_placeholder' : [
+ ['render'],
+ function(e) {
+ return function() {
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+ var buckets = obj.network.simple_request(
+ 'BUCKET_RETRIEVE_VIA_USER',
+ [ ses(), obj.data.list.au[0].id() ]
+ );
+ if (typeof buckets.ilsevent != 'undefined') {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.buckets.std_unexpected_error'), buckets);
+ return;
+ }
+ var items = [
+ [$("catStrings").getString('staff.cat.record_buckets.menulist_placeholder.item1'),''],
+ [$("catStrings").getString('staff.cat.record_buckets.menulist_placeholder.item2'),-1]
+ ].concat(
+ util.functional.map_list(
+ util.functional.filter_list(
+ buckets.biblio,
+ function(o) {
+ return o.btype() == 'staff_client';
+ }
+ ),
+ function(o) {
+ obj.bucket_id_name_map[ o.id() ] = o.name();
+ return [ o.name(), o.id() ];
+ }
+ ).sort(
+ function( a, b ) {
+ if (a[0] < b[0]) return -1;
+ if (a[0] > b[0]) return 1;
+ return 0;
+ }
+ )
+ );
+ obj.error.sdump('D_TRACE','items = ' + js2JSON(items));
+ util.widgets.remove_children( e );
+ var ml = util.widgets.make_menulist(
+ items
+ );
+ e.appendChild( ml );
+ ml.setAttribute('id','bucket_menulist');
+ ml.setAttribute('accesskey','');
+
+ function change_bucket(ev) {
+ var bucket_id = ev.target.value;
+ if (bucket_id < 0 ) {
+ bucket_id = window.prompt($("catStrings").getString('staff.cat.record_buckets.change_bucket.bucket_id'));
+ ev.target.value = bucket_id;
+ ev.target.setAttribute('value',bucket_id);
+ }
+ if (!bucket_id) return;
+ var x = document.getElementById('info_box');
+ if (x) x.setAttribute('hidden','true');
x = document.getElementById('bucket_item_count');
if (x) x.setAttribute('label','');
obj.controller.view.cmd_record_buckets_delete_bucket.setAttribute('disabled','true');
obj.controller.view.cmd_delete_records.setAttribute('disabled','true');
obj.controller.view.cmd_sel_opac.setAttribute('disabled','true');
obj.controller.view.record_buckets_list_actions.disabled = true;
- var bucket = obj.network.simple_request(
- 'BUCKET_FLESH',
- [ ses(), 'biblio', bucket_id ]
- );
- if (typeof bucket.ilsevent != 'undefined') {
- if (bucket.ilsevent == 1506 /* CONTAINER_NOT_FOUND */) {
- alert(catStrings.getFormattedString('staff.cat.record_buckets.menulist.change_bucket.undefined',[bucket_id]));
- } else {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.change_bucket.error'),bucket);
- }
- return;
- }
- try {
+ var bucket = obj.network.simple_request(
+ 'BUCKET_FLESH',
+ [ ses(), 'biblio', bucket_id ]
+ );
+ if (typeof bucket.ilsevent != 'undefined') {
+ if (bucket.ilsevent == 1506 /* CONTAINER_NOT_FOUND */) {
+ alert(catStrings.getFormattedString('staff.cat.record_buckets.menulist.change_bucket.undefined',[bucket_id]));
+ } else {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.change_bucket.error'),bucket);
+ }
+ return;
+ }
+ try {
obj.controller.view.cmd_record_buckets_delete_bucket.setAttribute('disabled','false');
obj.controller.view.cmd_record_buckets_refresh.setAttribute('disabled','false');
obj.controller.view.record_buckets_export_records.disabled = false;
obj.controller.view.cmd_sel_opac.setAttribute('disabled','false');
obj.controller.view.record_buckets_list_actions.disabled = false;
- var x = document.getElementById('info_box');
- x.setAttribute('hidden','false');
- x = document.getElementById('bucket_number');
- x.setAttribute('value',bucket.id());
- x = document.getElementById('bucket_name');
- x.setAttribute('value',bucket.name());
- x = document.getElementById('bucket_owner');
- var s = bucket.owner(); JSAN.use('patron.util');
- if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s);
- x.setAttribute('value',s.family_name() + ' (' + s.card().barcode() + ") @ " + obj.data.hash.aou[ s.home_ou() ].shortname());
- } catch(E) {
- alert(E);
- }
- var items = bucket.items() || [];
- obj.list2.clear();
+ var x = document.getElementById('info_box');
+ x.setAttribute('hidden','false');
+ x = document.getElementById('bucket_number');
+ x.setAttribute('value',bucket.id());
+ x = document.getElementById('bucket_name');
+ x.setAttribute('value',bucket.name());
+ x = document.getElementById('bucket_owner');
+ var s = bucket.owner(); JSAN.use('patron.util');
+ if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s);
+ x.setAttribute('value',s.family_name() + ' (' + s.card().barcode() + ") @ " + obj.data.hash.aou[ s.home_ou() ].shortname());
+ } catch(E) {
+ alert(E);
+ }
+ var items = bucket.items() || [];
+ obj.list2.clear();
var x = document.getElementById('bucket_item_count');
if (x && catStrings) x.setAttribute('value',catStrings.getFormattedString('cat.total_bucket_items_in_bucket',[items.length]));
- for (var i = 0; i < items.length; i++) {
- var item = obj.prep_record_for_list(
- items[i].target_biblio_record_entry(),
- items[i].id()
- );
- if (item) obj.list2.append( item );
- }
- }
-
- ml.addEventListener( 'change_bucket', change_bucket , false);
- ml.addEventListener( 'command', function() {
- JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
- }, false);
- obj.controller.view.bucket_menulist = ml;
- JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
- };
- },
- ],
+ for (var i = 0; i < items.length; i++) {
+ var item = obj.prep_record_for_list(
+ items[i].target_biblio_record_entry(),
+ items[i].id()
+ );
+ if (item) obj.list2.append( item );
+ }
+ }
+
+ ml.addEventListener( 'change_bucket', change_bucket , false);
+ ml.addEventListener( 'command', function() {
+ JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
+ }, false);
+ obj.controller.view.bucket_menulist = ml;
+ JSAN.use('util.widgets'); util.widgets.dispatch('change_bucket',ml);
+ };
+ },
+ ],
'cmd_record_buckets_refresh' : [
['command'],
}
],
- 'cmd_add_all_query_to_pending' : [
- ['command'],
- function() {
- obj.list0.select_all();
- for (var i = 0; i < obj.selection_list0.length; i++) {
- var docid = obj.selection_list0[i].docid;
- try {
- var item = obj.prep_record_for_list( docid );
- if (!item) continue;
- obj.list1.append( item );
+ 'cmd_add_all_query_to_pending' : [
+ ['command'],
+ function() {
+ obj.list0.select_all();
+ for (var i = 0; i < obj.selection_list0.length; i++) {
+ var docid = obj.selection_list0[i].docid;
+ try {
+ var item = obj.prep_record_for_list( docid );
+ if (!item) continue;
+ obj.list1.append( item );
+ obj.record_ids.push( docid );
+ } catch(E) {
+ alert( js2JSON(E) );
+ }
+ }
+ }
+ ],
+
+ 'cmd_add_sel_query_to_pending' : [
+ ['command'],
+ function() {
+ for (var i = 0; i < obj.selection_list0.length; i++) {
+ var docid = obj.selection_list0[i].docid;
+ try {
+ var item = obj.prep_record_for_list( docid );
+ if (!item) continue;
+ obj.list1.append( item );
obj.record_ids.push( docid );
- } catch(E) {
- alert( js2JSON(E) );
- }
- }
- }
- ],
-
- 'cmd_add_sel_query_to_pending' : [
- ['command'],
- function() {
- for (var i = 0; i < obj.selection_list0.length; i++) {
- var docid = obj.selection_list0[i].docid;
- try {
- var item = obj.prep_record_for_list( docid );
- if (!item) continue;
- obj.list1.append( item );
+ } catch(E) {
+ alert( js2JSON(E) );
+ }
+ }
+ }
+ ],
+
+
+ 'cmd_add_all_pending_to_record_bucket' : [
+ ['command'],
+ function() {
+ var bucket_id = obj.controller.view.bucket_menulist.value;
+ if (!bucket_id) return;
+ for (var i = 0; i < obj.record_ids.length; i++) {
+ var bucket_item = new cbrebi();
+ bucket_item.isnew('1');
+ bucket_item.bucket(bucket_id);
+ bucket_item.target_biblio_record_entry( obj.record_ids[i] );
+ try {
+ var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
+ [ ses(), 'biblio', bucket_item ]);
+
+ if (typeof robj == 'object') throw robj;
+
+ var item = obj.prep_record_for_list( obj.record_ids[i], robj );
+ if (!item) continue;
+
+ obj.list2.append( item );
+ } catch(E) {
+ alert( js2JSON(E) );
+ }
+ }
+ }
+ ],
+ 'cmd_add_sel_pending_to_record_bucket' : [
+ ['command'],
+ function() {
+ var bucket_id = obj.controller.view.bucket_menulist.value;
+ if (!bucket_id) return;
+ for (var i = 0; i < obj.selection_list1.length; i++) {
+ var docid = obj.selection_list1[i].docid;
+ var bucket_item = new cbrebi();
+ bucket_item.isnew('1');
+ bucket_item.bucket(bucket_id);
+ bucket_item.target_biblio_record_entry( docid );
+ try {
+ var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
+ [ ses(), 'biblio', bucket_item ]);
+
+ if (typeof robj == 'object') throw robj;
+
+ var item = obj.prep_record_for_list( docid, robj );
+ if (!item) continue;
+
+ obj.list2.append( item );
+ } catch(E) {
+ alert( js2JSON(E) );
+ }
+ }
+
+ }
+ ],
+ 'cmd_record_buckets_to_pending_buckets' : [
+ ['command'],
+ function() {
+ for (var i = 0; i < obj.selection_list2.length; i++) {
+ var docid = obj.selection_list2[i].docid;
+ var item = obj.prep_record_for_list( docid );
+ if (item) {
+ obj.list1.append( item );
obj.record_ids.push( docid );
- } catch(E) {
- alert( js2JSON(E) );
- }
- }
- }
- ],
-
-
- 'cmd_add_all_pending_to_record_bucket' : [
- ['command'],
- function() {
- var bucket_id = obj.controller.view.bucket_menulist.value;
- if (!bucket_id) return;
- for (var i = 0; i < obj.record_ids.length; i++) {
- var bucket_item = new cbrebi();
- bucket_item.isnew('1');
- bucket_item.bucket(bucket_id);
- bucket_item.target_biblio_record_entry( obj.record_ids[i] );
- try {
- var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
- [ ses(), 'biblio', bucket_item ]);
-
- if (typeof robj == 'object') throw robj;
-
- var item = obj.prep_record_for_list( obj.record_ids[i], robj );
- if (!item) continue;
-
- obj.list2.append( item );
- } catch(E) {
- alert( js2JSON(E) );
- }
- }
- }
- ],
- 'cmd_add_sel_pending_to_record_bucket' : [
- ['command'],
- function() {
- var bucket_id = obj.controller.view.bucket_menulist.value;
- if (!bucket_id) return;
- for (var i = 0; i < obj.selection_list1.length; i++) {
- var docid = obj.selection_list1[i].docid;
- var bucket_item = new cbrebi();
- bucket_item.isnew('1');
- bucket_item.bucket(bucket_id);
- bucket_item.target_biblio_record_entry( docid );
- try {
- var robj = obj.network.simple_request('BUCKET_ITEM_CREATE',
- [ ses(), 'biblio', bucket_item ]);
-
- if (typeof robj == 'object') throw robj;
-
- var item = obj.prep_record_for_list( docid, robj );
- if (!item) continue;
-
- obj.list2.append( item );
- } catch(E) {
- alert( js2JSON(E) );
- }
- }
-
- }
- ],
- 'cmd_record_buckets_to_pending_buckets' : [
- ['command'],
- function() {
- for (var i = 0; i < obj.selection_list2.length; i++) {
- var docid = obj.selection_list2[i].docid;
- var item = obj.prep_record_for_list( docid );
- if (item) {
- obj.list1.append( item );
- obj.record_ids.push( docid );
- }
- }
- }
- ],
-
- 'cmd_record_buckets_delete_item' : [
- ['command'],
- function() {
- for (var i = 0; i < obj.selection_list2.length; i++) {
- try {
- var bucket_item_id = obj.selection_list2[i].bucket_item_id;
- var robj = obj.network.simple_request('BUCKET_ITEM_DELETE',
- [ ses(), 'biblio', bucket_item_id ]);
- if (typeof robj == 'object') throw robj;
- } catch(E) {
- alert(js2JSON(E));
- }
+ }
+ }
+ }
+ ],
+
+ 'cmd_record_buckets_delete_item' : [
+ ['command'],
+ function() {
+ for (var i = 0; i < obj.selection_list2.length; i++) {
+ try {
+ var bucket_item_id = obj.selection_list2[i].bucket_item_id;
+ var robj = obj.network.simple_request('BUCKET_ITEM_DELETE',
+ [ ses(), 'biblio', bucket_item_id ]);
+ if (typeof robj == 'object') throw robj;
+ } catch(E) {
+ alert(js2JSON(E));
+ }
}
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
- }
- ],
- 'cmd_record_buckets_delete_bucket' : [
- ['command'],
- function() {
- try {
- var bucket = obj.controller.view.bucket_menulist.value;
- var name = obj.bucket_id_name_map[ bucket ];
- var conf = window.confirm($("catStrings").getFormattedString('staff.cat.record_buckets.delete_bucket_named', [name]));
- if (!conf) return;
- obj.list2.clear();
- var robj = obj.network.simple_request('BUCKET_DELETE',[ses(),'biblio',bucket]);
- if (typeof robj == 'object') throw robj;
- var x = document.getElementById('info_box');
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+ }
+ ],
+ 'cmd_record_buckets_delete_bucket' : [
+ ['command'],
+ function() {
+ try {
+ var bucket = obj.controller.view.bucket_menulist.value;
+ var name = obj.bucket_id_name_map[ bucket ];
+ var conf = window.confirm($("catStrings").getFormattedString('staff.cat.record_buckets.delete_bucket_named', [name]));
+ if (!conf) return;
+ obj.list2.clear();
+ var robj = obj.network.simple_request('BUCKET_DELETE',[ses(),'biblio',bucket]);
+ if (typeof robj == 'object') throw robj;
+ var x = document.getElementById('info_box');
x.setAttribute('hidden','true');
obj.controller.view.cmd_record_buckets_delete_bucket.setAttribute('disabled','true');
obj.controller.view.cmd_record_buckets_refresh.setAttribute('disabled','true');
obj.controller.view.cmd_delete_records.setAttribute('disabled','true');
obj.controller.view.cmd_sel_opac.setAttribute('disabled','true');
obj.controller.view.record_buckets_list_actions.disabled = true;
- obj.controller.render('record_buckets_menulist_placeholder');
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
-
- } catch(E) {
- alert('FIXME: ' + E);
- }
- }
- ],
- 'cmd_record_buckets_new_bucket' : [
- ['command'],
- function() {
- try {
- var name = prompt(
- $("catStrings").getString('staff.cat.record_buckets.new_bucket.bucket_prompt'),
- '',
- $("catStrings").getString('staff.cat.record_buckets.new_bucket.bucket_prompt_title')
- );
-
- if (name) {
- var bucket = new cbreb();
- bucket.btype('staff_client');
- bucket.owner( obj.data.list.au[0].id() );
- bucket.name( name );
-
- var robj = obj.network.simple_request('BUCKET_CREATE',[ses(),'biblio',bucket]);
-
- if (typeof robj == 'object') {
- if (robj.ilsevent == 1710 /* CONTAINER_EXISTS */) {
- alert($("catStrings").getString('staff.cat.record_buckets.new_bucket.same_name_alert'));
- return;
- }
- throw robj;
- }
-
- obj.controller.render('record_buckets_menulist_placeholder');
- obj.controller.view.bucket_menulist.value = robj;
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
- }
- } catch(E) {
- alert( js2JSON(E) );
- }
- }
- ],
-
- 'cmd_record_query_csv_to_clipboard' : [ ['command'], function() { obj.list0.dump_csv_to_clipboard(); } ],
- 'cmd_pending_buckets_csv_to_clipboard' : [ ['command'], function() { obj.list1.dump_csv_to_clipboard(); } ],
- 'cmd_record_buckets_csv_to_clipboard' : [ ['command'], function() { obj.list2.dump_csv_to_clipboard(); } ],
+ obj.controller.render('record_buckets_menulist_placeholder');
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ }
+ ],
+ 'cmd_record_buckets_new_bucket' : [
+ ['command'],
+ function() {
+ try {
+ var name = prompt(
+ $("catStrings").getString('staff.cat.record_buckets.new_bucket.bucket_prompt'),
+ '',
+ $("catStrings").getString('staff.cat.record_buckets.new_bucket.bucket_prompt_title')
+ );
+
+ if (name) {
+ var bucket = new cbreb();
+ bucket.btype('staff_client');
+ bucket.owner( obj.data.list.au[0].id() );
+ bucket.name( name );
+
+ var robj = obj.network.simple_request('BUCKET_CREATE',[ses(),'biblio',bucket]);
+
+ if (typeof robj == 'object') {
+ if (robj.ilsevent == 1710 /* CONTAINER_EXISTS */) {
+ alert($("catStrings").getString('staff.cat.record_buckets.new_bucket.same_name_alert'));
+ return;
+ }
+ throw robj;
+ }
+
+ obj.controller.render('record_buckets_menulist_placeholder');
+ obj.controller.view.bucket_menulist.value = robj;
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+ }
+ } catch(E) {
+ alert( js2JSON(E) );
+ }
+ }
+ ],
+
+ 'cmd_record_query_csv_to_clipboard' : [ ['command'], function() { obj.list0.dump_csv_to_clipboard(); } ],
+ 'cmd_pending_buckets_csv_to_clipboard' : [ ['command'], function() { obj.list1.dump_csv_to_clipboard(); } ],
+ 'cmd_record_buckets_csv_to_clipboard' : [ ['command'], function() { obj.list2.dump_csv_to_clipboard(); } ],
'cmd_record_query_csv_to_printer' : [ ['command'], function() { obj.list0.dump_csv_to_printer(); } ],
'cmd_pending_buckets_csv_to_printer' : [ ['command'], function() { obj.list1.dump_csv_to_printer(); } ],
'cmd_record_buckets_csv_to_printer' : [ ['command'], function() { obj.list2.dump_csv_to_printer(); } ],
'cmd_pending_buckets_csv_to_file' : [ ['command'], function() { obj.list1.dump_csv_to_file( { 'defaultFileName' : 'pending_records.txt' } ); } ],
'cmd_record_buckets_csv_to_file' : [ ['command'], function() { obj.list2.dump_csv_to_file( { 'defaultFileName' : 'bucket_records.txt' } ); } ],
- 'cmd_export_records_usmarc' : [
- ['command'],
- function () { return cat.record_buckets.export_records(obj, 'usmarc') }
- ],
-
- 'cmd_export_records_unimarc' : [
- ['command'],
- function () { return cat.record_buckets.export_records(obj, 'unimarc') }
- ],
-
- 'cmd_export_records_xml' : [
- ['command'],
- function () { return cat.record_buckets.export_records(obj, 'xml') }
- ],
-
- 'cmd_export_records_bre' : [
- ['command'],
- function () { return cat.record_buckets.export_records(obj, 'bre') }
- ],
-
- 'cmd_merge_records' : [
- ['command'],
- function() {
- try {
- obj.list2.select_all();
- obj.data.stash_retrieve();
- JSAN.use('util.functional');
-
- var record_ids = util.functional.map_list(
- obj.list2.dump_retrieve_ids(),
- function (o) {
- return JSON2js(o).docid; // docid
- }
- );
-
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- var top_xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" >';
- top_xml += '<description>' + $("catStrings").getString('staff.cat.record_buckets.merge_records.merge_lead') + '</description>';
- top_xml += '<hbox>';
- top_xml += '<button id="lead" disabled="true" label="'
- + $("catStrings").getString('staff.cat.record_buckets.merge_records.button.label') + '" name="fancy_submit"/>';
- top_xml += '<button label="' + $("catStrings").getString('staff.cat.record_buckets.merge_records.cancel_button.label') +'" accesskey="'
- + $("catStrings").getString('staff.cat.record_buckets.merge_records.cancel_button.accesskey') +'" name="fancy_cancel"/></hbox></vbox>';
-
- var xml = '<form xmlns="http://www.w3.org/1999/xhtml">';
- xml += '<table><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td><input value="' + $("catStrings").getString('staff.cat.record_buckets.merge_records.lead')
- xml += '" id="record_' + record_ids[i] + '" type="radio" name="lead"';
- xml += ' onclick="' + "try { var x = $('lead'); x.setAttribute('value',";
- xml += record_ids[i] + '); x.disabled = false; } catch(E) { alert(E); }">';
- xml += '</input>' + $("catStrings").getFormattedString('staff.cat.record_buckets.merge_records.lead_record_number',[record_ids[i]]) + '</td>';
- }
- xml += '</tr><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td nowrap="nowrap"><iframe src="' + urls.XUL_BIB_BRIEF;
- xml += '?docid=' + record_ids[i] + '"/></td>';
- }
- xml += '</tr><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td nowrap="nowrap"><iframe style="min-height: 1000px; min-width: 300px;" flex="1" src="' + urls.XUL_MARC_VIEW + '?docid=' + record_ids[i] + ' "/></td>';
- }
- xml += '</tr></table></form>';
- //obj.data.temp_merge_top = top_xml; obj.data.stash('temp_merge_top');
- //obj.data.temp_merge_mid = xml; obj.data.stash('temp_merge_mid');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_merge_mid'
- //+ '&top_xml_in_stash=temp_merge_top'
- //+ '&title=' + window.escape('Record Merging'),
- 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
- {
- 'top_xml' : top_xml, 'xml' : xml, 'title' : $("catStrings").getString('staff.cat.record_buckets.merge_records.fancy_prompt_title')
- }
- );
- //obj.data.stash_retrieve();
-
- if (typeof fancy_prompt_data.fancy_status == 'undefined' || fancy_prompt_data.fancy_status == 'incomplete') {
- alert($("catStrings").getString('staff.cat.record_buckets.merge_records.fancy_prompt.alert'));
- return;
- }
- var robj = obj.network.simple_request('MERGE_RECORDS',
- [
- ses(),
- fancy_prompt_data.lead,
- util.functional.filter_list( record_ids,
- function(o) {
- return o != fancy_prompt_data.lead;
- }
- )
- ]
- );
- if (typeof robj.ilsevent != 'undefined') {
- throw(robj);
- }
-
- obj.render_pending_records(); // FIXME -- need a generic refresh for lists
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.merge_records.catch.std_unex_error'),E);
- }
-
- }
- ],
-
- 'cmd_delete_records' : [
- ['command'],
- function() {
- try {
- obj.list2.select_all();
- obj.data.stash_retrieve();
- JSAN.use('util.functional');
-
- var record_ids = util.functional.map_list(
- obj.list2.dump_retrieve_ids(),
- function (o) {
- return JSON2js(o).docid; // docid
- }
- );
-
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- var top_xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" >';
- top_xml += '<description>' + $("catStrings").getString('staff.cat.record_buckets.delete_records.xml1') + '</description>';
- top_xml += '<hbox>';
- top_xml += '<button id="lead" disabled="false" label="'
- + $("catStrings").getString('staff.cat.record_buckets.delete_records.button.label')
- + '" name="fancy_submit"/>';
- top_xml += '<button label="'
- + $("catStrings").getString('staff.cat.record_buckets.delete_records.cancel_button.label') +'" accesskey="'
- + $("catStrings").getString('staff.cat.record_buckets.delete_records.cancel_button.accesskey') +'" name="fancy_cancel"/></hbox></vbox>';
-
- var xml = '<form xmlns="http://www.w3.org/1999/xhtml">';
- xml += '<table><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td>' + $("catStrings").getFormattedString('staff.cat.record_buckets.delete_records.xml2', [record_ids[i]]) + '</td>';
- }
- xml += '</tr><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td nowrap="nowrap"><iframe src="' + urls.XUL_BIB_BRIEF;
- xml += '?docid=' + record_ids[i] + '"/></td>';
- }
- xml += '</tr><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td nowrap="nowrap"><iframe style="min-height: 1000px; min-width: 300px;" flex="1" src="' + urls.XUL_MARC_VIEW + '?docid=' + record_ids[i] + ' "/></td>';
- }
- xml += '</tr></table></form>';
- //obj.data.temp_merge_top = top_xml; obj.data.stash('temp_merge_top');
- //obj.data.temp_merge_mid = xml; obj.data.stash('temp_merge_mid');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_merge_mid'
- //+ '&top_xml_in_stash=temp_merge_top'
- //+ '&title=' + window.escape('Record Purging'),
- 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
- {
- 'top_xml' : top_xml, 'xml' : xml, 'title' : $("catStrings").getString('staff.cat.record_buckets.delete_records.fancy_prompt_title')
- }
- );
- //obj.data.stash_retrieve();
- if (typeof fancy_prompt_data.fancy_status == 'undefined' || fancy_prompt_data.fancy_status != 'complete') {
- alert($("catStrings").getString('staff.cat.record_buckets.delete_records.fancy_prompt.alert'));
- return;
- }
- var s = '';
- for (var i = 0; i < record_ids.length; i++) {
- var robj = obj.network.simple_request('FM_BRE_DELETE',[ses(),record_ids[i]]);
- if (typeof robj.ilsevent != 'undefined') {
- if (!s) s = $("catStrings").getString('staff.cat.record_buckets.delete_records.s1');
- s += $("catStrings").getFormattedString('staff.cat.record_buckets.delete_records.s2', [record_ids[i], robj.textcode, robj.desc]);
- }
- }
- if (s) { alert(s); }
-
- obj.render_pending_records(); // FIXME -- need a generic refresh for lists
- setTimeout(
- function() {
- JSAN.use('util.widgets');
- util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
- }, 0
- );
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.delete_records.catch.std_unex_err',E));
- }
-
- }
- ],
-
- 'cmd_broken' : [
- ['command'],
- function() { alert($("catStrings").getString('staff.cat.record_buckets.cmd_broken.alert')); }
- ],
- 'cmd_sel_opac' : [
- ['command'],
- function() {
- try {
- obj.list2.select_all();
- JSAN.use('util.functional');
- var docids = util.functional.map_list(
- obj.list2.dump_retrieve_ids(),
- function (o) {
- return JSON2js(o).docid; // docid
- }
- );
+ 'cmd_export_records_usmarc' : [
+ ['command'],
+ function () { return cat.record_buckets.export_records(obj, 'usmarc') }
+ ],
+
+ 'cmd_export_records_unimarc' : [
+ ['command'],
+ function () { return cat.record_buckets.export_records(obj, 'unimarc') }
+ ],
+
+ 'cmd_export_records_xml' : [
+ ['command'],
+ function () { return cat.record_buckets.export_records(obj, 'xml') }
+ ],
+
+ 'cmd_export_records_bre' : [
+ ['command'],
+ function () { return cat.record_buckets.export_records(obj, 'bre') }
+ ],
+
+ 'cmd_merge_records' : [
+ ['command'],
+ function() {
+ try {
+ obj.list2.select_all();
+ obj.data.stash_retrieve();
+ JSAN.use('util.functional');
+
+ var record_ids = util.functional.map_list(
+ obj.list2.dump_retrieve_ids(),
+ function (o) {
+ return JSON2js(o).docid; // docid
+ }
+ );
+
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ var top_xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" >';
+ top_xml += '<description>' + $("catStrings").getString('staff.cat.record_buckets.merge_records.merge_lead') + '</description>';
+ top_xml += '<hbox>';
+ top_xml += '<button id="lead" disabled="true" label="'
+ + $("catStrings").getString('staff.cat.record_buckets.merge_records.button.label') + '" name="fancy_submit"/>';
+ top_xml += '<button label="' + $("catStrings").getString('staff.cat.record_buckets.merge_records.cancel_button.label') +'" accesskey="'
+ + $("catStrings").getString('staff.cat.record_buckets.merge_records.cancel_button.accesskey') +'" name="fancy_cancel"/></hbox></vbox>';
+
+ var xml = '<form xmlns="http://www.w3.org/1999/xhtml">';
+ xml += '<table><tr valign="top">';
+ for (var i = 0; i < record_ids.length; i++) {
+ xml += '<td><input value="' + $("catStrings").getString('staff.cat.record_buckets.merge_records.lead')
+ xml += '" id="record_' + record_ids[i] + '" type="radio" name="lead"';
+ xml += ' onclick="' + "try { var x = $('lead'); x.setAttribute('value',";
+ xml += record_ids[i] + '); x.disabled = false; } catch(E) { alert(E); }">';
+ xml += '</input>' + $("catStrings").getFormattedString('staff.cat.record_buckets.merge_records.lead_record_number',[record_ids[i]]) + '</td>';
+ }
+ xml += '</tr><tr valign="top">';
+ for (var i = 0; i < record_ids.length; i++) {
+ xml += '<td nowrap="nowrap"><iframe src="' + urls.XUL_BIB_BRIEF;
+ xml += '?docid=' + record_ids[i] + '"/></td>';
+ }
+ xml += '</tr><tr valign="top">';
+ for (var i = 0; i < record_ids.length; i++) {
+ xml += '<td nowrap="nowrap"><iframe style="min-height: 1000px; min-width: 300px;" flex="1" src="' + urls.XUL_MARC_VIEW + '?docid=' + record_ids[i] + ' "/></td>';
+ }
+ xml += '</tr></table></form>';
+ //obj.data.temp_merge_top = top_xml; obj.data.stash('temp_merge_top');
+ //obj.data.temp_merge_mid = xml; obj.data.stash('temp_merge_mid');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_merge_mid'
+ //+ '&top_xml_in_stash=temp_merge_top'
+ //+ '&title=' + window.escape('Record Merging'),
+ 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
+ {
+ 'top_xml' : top_xml, 'xml' : xml, 'title' : $("catStrings").getString('staff.cat.record_buckets.merge_records.fancy_prompt_title')
+ }
+ );
+ //obj.data.stash_retrieve();
+
+ if (typeof fancy_prompt_data.fancy_status == 'undefined' || fancy_prompt_data.fancy_status == 'incomplete') {
+ alert($("catStrings").getString('staff.cat.record_buckets.merge_records.fancy_prompt.alert'));
+ return;
+ }
+ var robj = obj.network.simple_request('MERGE_RECORDS',
+ [
+ ses(),
+ fancy_prompt_data.lead,
+ util.functional.filter_list( record_ids,
+ function(o) {
+ return o != fancy_prompt_data.lead;
+ }
+ )
+ ]
+ );
+ if (typeof robj.ilsevent != 'undefined') {
+ throw(robj);
+ }
+
+ obj.render_pending_records(); // FIXME -- need a generic refresh for lists
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.merge_records.catch.std_unex_error'),E);
+ }
+
+ }
+ ],
+
+ 'cmd_delete_records' : [
+ ['command'],
+ function() {
+ try {
+ obj.list2.select_all();
+ obj.data.stash_retrieve();
+ JSAN.use('util.functional');
+
+ var record_ids = util.functional.map_list(
+ obj.list2.dump_retrieve_ids(),
+ function (o) {
+ return JSON2js(o).docid; // docid
+ }
+ );
+
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ var top_xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" >';
+ top_xml += '<description>' + $("catStrings").getString('staff.cat.record_buckets.delete_records.xml1') + '</description>';
+ top_xml += '<hbox>';
+ top_xml += '<button id="lead" disabled="false" label="'
+ + $("catStrings").getString('staff.cat.record_buckets.delete_records.button.label')
+ + '" name="fancy_submit"/>';
+ top_xml += '<button label="'
+ + $("catStrings").getString('staff.cat.record_buckets.delete_records.cancel_button.label') +'" accesskey="'
+ + $("catStrings").getString('staff.cat.record_buckets.delete_records.cancel_button.accesskey') +'" name="fancy_cancel"/></hbox></vbox>';
+
+ var xml = '<form xmlns="http://www.w3.org/1999/xhtml">';
+ xml += '<table><tr valign="top">';
+ for (var i = 0; i < record_ids.length; i++) {
+ xml += '<td>' + $("catStrings").getFormattedString('staff.cat.record_buckets.delete_records.xml2', [record_ids[i]]) + '</td>';
+ }
+ xml += '</tr><tr valign="top">';
+ for (var i = 0; i < record_ids.length; i++) {
+ xml += '<td nowrap="nowrap"><iframe src="' + urls.XUL_BIB_BRIEF;
+ xml += '?docid=' + record_ids[i] + '"/></td>';
+ }
+ xml += '</tr><tr valign="top">';
+ for (var i = 0; i < record_ids.length; i++) {
+ xml += '<td nowrap="nowrap"><iframe style="min-height: 1000px; min-width: 300px;" flex="1" src="' + urls.XUL_MARC_VIEW + '?docid=' + record_ids[i] + ' "/></td>';
+ }
+ xml += '</tr></table></form>';
+ //obj.data.temp_merge_top = top_xml; obj.data.stash('temp_merge_top');
+ //obj.data.temp_merge_mid = xml; obj.data.stash('temp_merge_mid');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_merge_mid'
+ //+ '&top_xml_in_stash=temp_merge_top'
+ //+ '&title=' + window.escape('Record Purging'),
+ 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
+ {
+ 'top_xml' : top_xml, 'xml' : xml, 'title' : $("catStrings").getString('staff.cat.record_buckets.delete_records.fancy_prompt_title')
+ }
+ );
+ //obj.data.stash_retrieve();
+ if (typeof fancy_prompt_data.fancy_status == 'undefined' || fancy_prompt_data.fancy_status != 'complete') {
+ alert($("catStrings").getString('staff.cat.record_buckets.delete_records.fancy_prompt.alert'));
+ return;
+ }
+ var s = '';
+ for (var i = 0; i < record_ids.length; i++) {
+ var robj = obj.network.simple_request('FM_BRE_DELETE',[ses(),record_ids[i]]);
+ if (typeof robj.ilsevent != 'undefined') {
+ if (!s) s = $("catStrings").getString('staff.cat.record_buckets.delete_records.s1');
+ s += $("catStrings").getFormattedString('staff.cat.record_buckets.delete_records.s2', [record_ids[i], robj.textcode, robj.desc]);
+ }
+ }
+ if (s) { alert(s); }
+
+ obj.render_pending_records(); // FIXME -- need a generic refresh for lists
+ setTimeout(
+ function() {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('change_bucket',obj.controller.view.bucket_menulist);
+ }, 0
+ );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.delete_records.catch.std_unex_err',E));
+ }
+
+ }
+ ],
+
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert($("catStrings").getString('staff.cat.record_buckets.cmd_broken.alert')); }
+ ],
+ 'cmd_sel_opac' : [
+ ['command'],
+ function() {
+ try {
+ obj.list2.select_all();
+ JSAN.use('util.functional');
+ var docids = util.functional.map_list(
+ obj.list2.dump_retrieve_ids(),
+ function (o) {
+ return JSON2js(o).docid; // docid
+ }
+ );
var seen = {};
- for (var i = 0; i < docids.length; i++) {
- var doc_id = docids[i];
+ for (var i = 0; i < docids.length; i++) {
+ var doc_id = docids[i];
if (seen[doc_id]) continue; seen[doc_id] = true;
- var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id;
- var content_params = {
- 'session' : ses(),
- 'authtime' : ses('authtime'),
- 'opac_url' : opac_url
- };
- xulG.new_tab(
- xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
- {'tab_name':$("catStrings").getString('staff.cat.record_buckets.cmd_sel_opac.tab_name')},
- content_params
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.cmd_sel_opac.catch.std_unex_err'),E);
- }
- }
- ],
+ var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id;
+ var content_params = {
+ 'session' : ses(),
+ 'authtime' : ses('authtime'),
+ 'opac_url' : opac_url
+ };
+ xulG.new_tab(
+ xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name':$("catStrings").getString('staff.cat.record_buckets.cmd_sel_opac.tab_name')},
+ content_params
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.record_buckets.cmd_sel_opac.catch.std_unex_err'),E);
+ }
+ }
+ ],
'record_buckets_export_records' : [ ['render'], function(){} ],
'record_buckets_list_actions' : [ ['render'], function(){} ]
- }
- }
- );
- this.controller.render();
+ }
+ }
+ );
+ this.controller.render();
- if (typeof xulG == 'undefined') {
- obj.controller.view.cmd_sel_opac.disabled = true;
- obj.controller.view.cmd_sel_opac.setAttribute('disabled',true);
- }
- },
+ if (typeof xulG == 'undefined') {
+ obj.controller.view.cmd_sel_opac.disabled = true;
+ obj.controller.view.cmd_sel_opac.setAttribute('disabled',true);
+ }
+ },
'submit' : function() {
try {
}
},
- 'prep_record_for_list' : function(docid,bucket_item_id) {
- var obj = this;
- try {
+ 'prep_record_for_list' : function(docid,bucket_item_id) {
+ var obj = this;
+ try {
var item = {
'retrieve_id' : js2JSON( { 'docid' : docid, 'bucket_item_id' : bucket_item_id } ),
'row' : {
}
};
return item;
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.record_buckets.prep_record_for_list.std_unex_err', [docid]),E);
- return null;
- }
- }
-
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.record_buckets.prep_record_for_list.std_unex_err', [docid]),E);
+ return null;
+ }
+ }
+
};
dump('exiting cat.record_buckets.js\n');
- function my_init() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.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 spine_labels.xul');
+ function my_init() {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.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 spine_labels.xul');
- JSAN.use('util.network'); g.network = new util.network();
+ JSAN.use('util.network'); g.network = new util.network();
- g.cgi = new CGI();
+ g.cgi = new CGI();
- g.barcodes = [];
- if (g.cgi.param('barcodes')) {
- g.barcodes = g.barcodes.concat( JSON2js(g.cgi.param('barcodes')) );
- }
- JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
- if (g.data.temp_barcodes_for_labels) {
- g.barcodes = g.barcodes.concat( g.data.temp_barcodes_for_labels );
- g.data.temp_barcodes_for_labels = null; g.data.stash('temp_barcodes_for_labels');
- }
+ g.barcodes = [];
+ if (g.cgi.param('barcodes')) {
+ g.barcodes = g.barcodes.concat( JSON2js(g.cgi.param('barcodes')) );
+ }
+ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
+ if (g.data.temp_barcodes_for_labels) {
+ g.barcodes = g.barcodes.concat( g.data.temp_barcodes_for_labels );
+ g.data.temp_barcodes_for_labels = null; g.data.stash('temp_barcodes_for_labels');
+ }
- JSAN.use('circ.util');
- g.cols = circ.util.columns( {} );
- g.col_map = {};
- for (var i = 0; i < g.cols.length; i++) {
- g.col_map[ g.cols[i].id ] = { 'regex' : new RegExp('%' + g.cols[i].id + '%',"g"), 'render' : g.cols[i].render };
- }
+ JSAN.use('circ.util');
+ g.cols = circ.util.columns( {} );
+ g.col_map = {};
+ for (var i = 0; i < g.cols.length; i++) {
+ g.col_map[ g.cols[i].id ] = { 'regex' : new RegExp('%' + g.cols[i].id + '%',"g"), 'render' : g.cols[i].render };
+ }
- g.volumes = {};
+ g.volumes = {};
- for (var i = 0; i < g.barcodes.length; i++) {
- var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative', [ g.barcodes[i] ] );
- if (typeof copy.ilsevent != 'undefined') throw(copy);
- if (!g.volumes[ copy.call_number() ]) {
- var volume = g.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ copy.call_number() ] );
- if (typeof volume.ilsevent != 'undefined') throw(volume);
- var record = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative', [ volume.record() ]);
- volume.record( record );
- g.volumes[ volume.id() ] = volume;
- }
- if (g.volumes[ copy.call_number() ].copies()) {
- var copies = g.volumes[ copy.call_number() ].copies();
- copies.push( copy );
- g.volumes[ copy.call_number() ].copies( copies );
- } else {
- g.volumes[ copy.call_number() ].copies( [ copy ] );
- }
- }
+ for (var i = 0; i < g.barcodes.length; i++) {
+ var copy = g.network.simple_request( 'FM_ACP_RETRIEVE_VIA_BARCODE.authoritative', [ g.barcodes[i] ] );
+ if (typeof copy.ilsevent != 'undefined') throw(copy);
+ if (!g.volumes[ copy.call_number() ]) {
+ var volume = g.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ copy.call_number() ] );
+ if (typeof volume.ilsevent != 'undefined') throw(volume);
+ var record = g.network.simple_request('MODS_SLIM_RECORD_RETRIEVE.authoritative', [ volume.record() ]);
+ volume.record( record );
+ g.volumes[ volume.id() ] = volume;
+ }
+ if (g.volumes[ copy.call_number() ].copies()) {
+ var copies = g.volumes[ copy.call_number() ].copies();
+ copies.push( copy );
+ g.volumes[ copy.call_number() ].copies( copies );
+ } else {
+ g.volumes[ copy.call_number() ].copies( [ copy ] );
+ }
+ }
- generate();
+ generate();
- if (typeof xulG != 'undefined') $('close').hidden = true;
+ if (typeof xulG != 'undefined') $('close').hidden = true;
- } catch(E) {
- try {
- g.error.standard_unexpected_error_alert('/xul/server/cat/spine_labels.xul',E);
- } catch(F) {
- alert('FIXME: ' + js2JSON(E));
- }
- }
- }
+ } catch(E) {
+ try {
+ g.error.standard_unexpected_error_alert('/xul/server/cat/spine_labels.xul',E);
+ } catch(F) {
+ alert('FIXME: ' + js2JSON(E));
+ }
+ }
+ }
- function show_macros() {
- JSAN.use('util.functional');
- alert( util.functional.map_list( g.cols, function(o) { return '%' + o.id + '%'; } ).join(" ") );
- }
+ function show_macros() {
+ JSAN.use('util.functional');
+ alert( util.functional.map_list( g.cols, function(o) { return '%' + o.id + '%'; } ).join(" ") );
+ }
- function $(id) { return document.getElementById(id); }
+ function $(id) { return document.getElementById(id); }
- function generate() {
- try {
- var idx = 0;
- JSAN.use('util.text'); JSAN.use('util.money');
- JSAN.use('util.widgets'); util.widgets.remove_children('panel'); var pn = $('panel'); $('preview').disabled = false;
- var lw = Number($('lw').value) || 8; /* spine label width */
- var ll = Number($('ll').value) || 9; /* spine label length */
- var plw = Number($('plw').value) || 28; /* pocket label width */
- var pll = Number($('pll').value) || 9; /* pocket label length */
- for (var i in g.volumes) {
- var vb = document.createElement('vbox'); pn.appendChild(vb); vb.setAttribute('name','template'); vb.setAttribute('acn_id',g.volumes[i].id());
- var ds = document.createElement('description'); vb.appendChild(ds);
- ds.appendChild( document.createTextNode( g.volumes[i].label() ) );
- var ds2 = document.createElement('description'); vb.appendChild(ds2);
- ds2.appendChild( document.createTextNode( g.volumes[i].copies().length + (
- g.volumes[i].copies().length == 1 ? $("catStrings").getString('staff.cat.spine_labels.copy') : $("catStrings").getString('staff.cat.spine_labels.copies')) ) );
- ds2.setAttribute('style','color: green');
- var hb = document.createElement('hbox'); vb.appendChild(hb);
+ function generate() {
+ try {
+ var idx = 0;
+ JSAN.use('util.text'); JSAN.use('util.money');
+ JSAN.use('util.widgets'); util.widgets.remove_children('panel'); var pn = $('panel'); $('preview').disabled = false;
+ var lw = Number($('lw').value) || 8; /* spine label width */
+ var ll = Number($('ll').value) || 9; /* spine label length */
+ var plw = Number($('plw').value) || 28; /* pocket label width */
+ var pll = Number($('pll').value) || 9; /* pocket label length */
+ for (var i in g.volumes) {
+ var vb = document.createElement('vbox'); pn.appendChild(vb); vb.setAttribute('name','template'); vb.setAttribute('acn_id',g.volumes[i].id());
+ var ds = document.createElement('description'); vb.appendChild(ds);
+ ds.appendChild( document.createTextNode( g.volumes[i].label() ) );
+ var ds2 = document.createElement('description'); vb.appendChild(ds2);
+ ds2.appendChild( document.createTextNode( g.volumes[i].copies().length + (
+ g.volumes[i].copies().length == 1 ? $("catStrings").getString('staff.cat.spine_labels.copy') : $("catStrings").getString('staff.cat.spine_labels.copies')) ) );
+ ds2.setAttribute('style','color: green');
+ var hb = document.createElement('hbox'); vb.appendChild(hb);
- var gb = document.createElement('groupbox'); hb.appendChild(gb);
- /* take the call number and split it on whitespace */
- var names = String(g.volumes[i].label()).split(/\s+/);
- var j = 0;
- while (j < ll || j < pll) {
- var hb2 = document.createElement('hbox'); gb.appendChild(hb2);
-
- /* spine */
- if (j < ll) {
- var tb = document.createElement('textbox'); hb2.appendChild(tb);
- tb.value = '';
- tb.setAttribute('class','plain'); tb.setAttribute('style','font-family: monospace');
- tb.setAttribute('size',lw+1); tb.setAttribute('maxlength',lw);
- tb.setAttribute('name','spine');
- var name = names.shift(); if (name) {
- name = String( name );
- /* if the name is greater than the label width... */
- if (name.length > lw) {
- /* then try to split it on periods */
- var sname = name.split(/\./);
- if (sname.length > 1) {
- /* if we can, then put the periods back in on each splitted element */
- if (name.match(/^\./)) sname[0] = '.' + sname[0];
- for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k];
- /* and put all but the first one back into the names array */
- names = sname.slice(1).concat( names );
- /* if the name fragment is still greater than the label width... */
- if (sname[0].length > lw) {
- /* then just truncate and throw the rest back into the names array */
- tb.value = sname[0].substr(0,lw);
- names = [ sname[0].substr(lw) ].concat( names );
- } else {
- /* otherwise we're set */
- tb.value = sname[0];
- }
- } else {
- /* if we can't split on periods, then just truncate and throw the rest back into the names array */
- tb.value = name.substr(0,lw);
- names = [ name.substr(lw) ].concat( names );
- }
- } else {
- /* otherwise we're set */
- tb.value = name;
- }
- }
- }
+ var gb = document.createElement('groupbox'); hb.appendChild(gb);
+ /* take the call number and split it on whitespace */
+ var names = String(g.volumes[i].label()).split(/\s+/);
+ var j = 0;
+ while (j < ll || j < pll) {
+ var hb2 = document.createElement('hbox'); gb.appendChild(hb2);
+
+ /* spine */
+ if (j < ll) {
+ var tb = document.createElement('textbox'); hb2.appendChild(tb);
+ tb.value = '';
+ tb.setAttribute('class','plain'); tb.setAttribute('style','font-family: monospace');
+ tb.setAttribute('size',lw+1); tb.setAttribute('maxlength',lw);
+ tb.setAttribute('name','spine');
+ var name = names.shift(); if (name) {
+ name = String( name );
+ /* if the name is greater than the label width... */
+ if (name.length > lw) {
+ /* then try to split it on periods */
+ var sname = name.split(/\./);
+ if (sname.length > 1) {
+ /* if we can, then put the periods back in on each splitted element */
+ if (name.match(/^\./)) sname[0] = '.' + sname[0];
+ for (var k = 1; k < sname.length; k++) sname[k] = '.' + sname[k];
+ /* and put all but the first one back into the names array */
+ names = sname.slice(1).concat( names );
+ /* if the name fragment is still greater than the label width... */
+ if (sname[0].length > lw) {
+ /* then just truncate and throw the rest back into the names array */
+ tb.value = sname[0].substr(0,lw);
+ names = [ sname[0].substr(lw) ].concat( names );
+ } else {
+ /* otherwise we're set */
+ tb.value = sname[0];
+ }
+ } else {
+ /* if we can't split on periods, then just truncate and throw the rest back into the names array */
+ tb.value = name.substr(0,lw);
+ names = [ name.substr(lw) ].concat( names );
+ }
+ } else {
+ /* otherwise we're set */
+ tb.value = name;
+ }
+ }
+ }
- /* pocket */
- if ($('pl').checked && j < pll) {
- var tb2 = document.createElement('textbox'); hb2.appendChild(tb2);
- tb2.value = '';
- tb2.setAttribute('class','plain'); tb2.setAttribute('style','font-family: monospace');
- tb2.setAttribute('size',plw+1); tb2.setAttribute('maxlength',plw);
- tb2.setAttribute('name','pocket');
- if ($('title').checked && $('title_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) {
- if (g.volumes[i].record().title()) {
- tb2.value = util.text.wrap_on_space( g.volumes[i].record().title(), plw )[0];
- } else {
- tb2.value = '';
- }
- }
- if ($('title_r').checked && $('title_r_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) {
- if (g.volumes[i].record().title()) {
- tb2.value = ( ($('title_r_indent').checked ? ' ' : '') + util.text.wrap_on_space( g.volumes[i].record().title(), plw )[1]).substr(0,plw);
- } else {
- tb2.value = '';
- }
- }
- if ($('author').checked && $('author_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) {
- if (g.volumes[i].record().author()) {
- tb2.value = g.volumes[i].record().author().substr(0,plw);
- } else {
- tb2.value = '';
- }
- }
- if ($('call_number').checked && $('call_number_line').value == j + 1) {
- tb2.value = g.volumes[i].label().substr(0,plw);
- }
- if ($('owning_lib_shortname').checked && $('owning_lib_shortname_line').value == j + 1) {
- var lib = g.volumes[i].owning_lib();
- if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
- tb2.value = lib.shortname().substr(0,plw);
- }
- if ($('owning_lib').checked && $('owning_lib_line').value == j + 1) {
- var lib = g.volumes[i].owning_lib();
- if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
- tb2.value = lib.name().substr(0,plw);
- }
- if ($('shelving_location').checked && $('shelving_location_line').value == j + 1) {
- tb2.value = '%location%';
- }
- if ($('barcode').checked && $('barcode_line').value == j + 1) {
- tb2.value = '%barcode%';
- }
- if ($('custom1').checked && $('custom1_line').value == j + 1) {
- tb2.value = $('custom1_tb').value;
- }
- if ($('custom2').checked && $('custom2_line').value == j + 1) {
- tb2.value = $('custom2_tb').value;
- }
- if ($('custom3').checked && $('custom3_line').value == j + 1) {
- tb2.value = $('custom3_tb').value;
- }
- if ($('custom4').checked && $('custom4_line').value == j + 1) {
- tb2.value = $('custom4_tb').value;
- }
- }
+ /* pocket */
+ if ($('pl').checked && j < pll) {
+ var tb2 = document.createElement('textbox'); hb2.appendChild(tb2);
+ tb2.value = '';
+ tb2.setAttribute('class','plain'); tb2.setAttribute('style','font-family: monospace');
+ tb2.setAttribute('size',plw+1); tb2.setAttribute('maxlength',plw);
+ tb2.setAttribute('name','pocket');
+ if ($('title').checked && $('title_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) {
+ if (g.volumes[i].record().title()) {
+ tb2.value = util.text.wrap_on_space( g.volumes[i].record().title(), plw )[0];
+ } else {
+ tb2.value = '';
+ }
+ }
+ if ($('title_r').checked && $('title_r_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) {
+ if (g.volumes[i].record().title()) {
+ tb2.value = ( ($('title_r_indent').checked ? ' ' : '') + util.text.wrap_on_space( g.volumes[i].record().title(), plw )[1]).substr(0,plw);
+ } else {
+ tb2.value = '';
+ }
+ }
+ if ($('author').checked && $('author_line').value == j + 1 && instanceOf(g.volumes[i].record(),mvr)) {
+ if (g.volumes[i].record().author()) {
+ tb2.value = g.volumes[i].record().author().substr(0,plw);
+ } else {
+ tb2.value = '';
+ }
+ }
+ if ($('call_number').checked && $('call_number_line').value == j + 1) {
+ tb2.value = g.volumes[i].label().substr(0,plw);
+ }
+ if ($('owning_lib_shortname').checked && $('owning_lib_shortname_line').value == j + 1) {
+ var lib = g.volumes[i].owning_lib();
+ if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
+ tb2.value = lib.shortname().substr(0,plw);
+ }
+ if ($('owning_lib').checked && $('owning_lib_line').value == j + 1) {
+ var lib = g.volumes[i].owning_lib();
+ if (!instanceOf(lib,aou)) lib = g.data.hash.aou[ lib ];
+ tb2.value = lib.name().substr(0,plw);
+ }
+ if ($('shelving_location').checked && $('shelving_location_line').value == j + 1) {
+ tb2.value = '%location%';
+ }
+ if ($('barcode').checked && $('barcode_line').value == j + 1) {
+ tb2.value = '%barcode%';
+ }
+ if ($('custom1').checked && $('custom1_line').value == j + 1) {
+ tb2.value = $('custom1_tb').value;
+ }
+ if ($('custom2').checked && $('custom2_line').value == j + 1) {
+ tb2.value = $('custom2_tb').value;
+ }
+ if ($('custom3').checked && $('custom3_line').value == j + 1) {
+ tb2.value = $('custom3_tb').value;
+ }
+ if ($('custom4').checked && $('custom4_line').value == j + 1) {
+ tb2.value = $('custom4_tb').value;
+ }
+ }
- j++;
- }
+ j++;
+ }
- idx++;
- }
- } catch(E) {
- g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.generate.std_unexpeceted_err'),E);
- }
- }
+ idx++;
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.generate.std_unexpeceted_err'),E);
+ }
+ }
- function expand_macros(text,copy,volume,record) {
- var my = { 'acp' : copy, 'acn' : volume, 'mvr' : record };
- var obj = { 'data' : g.data };
- for (var i in g.col_map) {
- var re = g.col_map[i].regex;
- if (text.match(re)) {
- try {
- text = text.replace(re, (typeof g.col_map[i].render == 'function' ? g.col_map[i].render(my) : eval( g.col_map[i].render ) ) );
- } catch(E) {
- g.error.sdump('D_ERROR','spine_labels.js, expand_macros() = ' + E);
- }
- }
- }
- return text;
- }
+ function expand_macros(text,copy,volume,record) {
+ var my = { 'acp' : copy, 'acn' : volume, 'mvr' : record };
+ var obj = { 'data' : g.data };
+ for (var i in g.col_map) {
+ var re = g.col_map[i].regex;
+ if (text.match(re)) {
+ try {
+ text = text.replace(re, (typeof g.col_map[i].render == 'function' ? g.col_map[i].render(my) : eval( g.col_map[i].render ) ) );
+ } catch(E) {
+ g.error.sdump('D_ERROR','spine_labels.js, expand_macros() = ' + E);
+ }
+ }
+ }
+ return text;
+ }
- function preview(idx) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- var pt = Number( $('pt').value ) || 10; /* font size */
- var lm = Number($('lm').value); if (lm == NaN) lm = 11; /* left margin */
- var mm = Number($('mm').value); if (mm == NaN) mm = 2; /* middle margin */
- var lw = Number($('lw').value) || 8; var ll = Number($('ll').value) || 9; /* spine label width and length */
- var plw = Number($('plw').value) || 28; var pll = Number($('pll').value) || 9; /* pocket label width and length */
- var html = "<html><head>";
+ function preview(idx) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ var pt = Number( $('pt').value ) || 10; /* font size */
+ var lm = Number($('lm').value); if (lm == NaN) lm = 11; /* left margin */
+ var mm = Number($('mm').value); if (mm == NaN) mm = 2; /* middle margin */
+ var lw = Number($('lw').value) || 8; var ll = Number($('ll').value) || 9; /* spine label width and length */
+ var plw = Number($('plw').value) || 28; var pll = Number($('pll').value) || 9; /* pocket label width and length */
+ var html = "<html><head>";
html += "<link type='text/css' rel='stylesheet' href='/xul/server/skin/print.css'></link>"
html += "<link type='text/css' rel='stylesheet' href='data:text/css,pre{font-size:" + pt + "pt;}'></link>";
html += "<title>Spine Labels</title></head><body>\n";
- var nl = document.getElementsByAttribute('name','template');
- for (var i = 0; i < nl.length; i++) {
- if (typeof idx == 'undefined' || idx == null) { } else {
- if (idx != i) continue;
- }
- var volume = g.volumes[ nl[i].getAttribute('acn_id') ];
+ var nl = document.getElementsByAttribute('name','template');
+ for (var i = 0; i < nl.length; i++) {
+ if (typeof idx == 'undefined' || idx == null) { } else {
+ if (idx != i) continue;
+ }
+ var volume = g.volumes[ nl[i].getAttribute('acn_id') ];
- for (var j = 0; j < volume.copies().length; j++) {
- var copy = volume.copies()[j];
+ for (var j = 0; j < volume.copies().length; j++) {
+ var copy = volume.copies()[j];
if (i == 0) {
- html += '<pre class="first_pre">\n';
+ html += '<pre class="first_pre">\n';
} else {
- html += '<pre class="not_first_pre">\n';
+ html += '<pre class="not_first_pre">\n';
+ }
+ var gb = nl[i].getElementsByTagName('groupbox')[0];
+ var nl2 = gb.getElementsByAttribute('name','spine');
+ for (var k = 0; k < nl2.length; k++) {
+ for (var m = 0; m < lm; m++) html += ' ';
+ html += util.text.preserve_string_in_html(expand_macros( nl2[k].value, copy, volume, volume.record() ).substr(0,lw));
+ if ($('pl').checked) {
+ var sib = nl2[k].nextSibling;
+ if (sib) {
+ for (var m = 0; m < lw - nl2[k].value.length; m++) html += ' ';
+ for (var m = 0; m < mm; m++) html += ' ';
+ html += util.text.preserve_string_in_html(expand_macros( sib.value, copy, volume, volume.record() ).substr(0,plw));
+ }
+ }
+ html += '\n';
+ }
+ html += '</pre>\n';
+ }
+ }
+ html += '</body></html>';
+ JSAN.use('util.window'); var win = new util.window();
+ var loc = ( urls.XUL_REMOTE_BROWSER );
+ //+ '?url=' + window.escape('about:blank') + '&show_print_button=1&alternate_print=1&no_xulG=1&title=' + window.escape('Spine Labels');
+ var w = win.open( loc, 'spine_preview', 'chrome,resizable,width=750,height=550');
+ w.xulG = {
+ 'url' : 'about:blank',
+ 'show_print_button' : 1,
+ 'alternate_print' : 1,
+ 'no_xulG' : 1,
+ 'title' : $("catStrings").getString('staff.cat.spine_labels.preview.title'),
+ 'on_url_load' : function(b) {
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ if (typeof w.xulG.written == 'undefined') {
+ w.xulG.written = true;
+ w.g.browser.get_content().document.write(html);
+ w.g.browser.get_content().document.close();
+ }
+ } catch(E) {
+ alert(E);
}
- var gb = nl[i].getElementsByTagName('groupbox')[0];
- var nl2 = gb.getElementsByAttribute('name','spine');
- for (var k = 0; k < nl2.length; k++) {
- for (var m = 0; m < lm; m++) html += ' ';
- html += util.text.preserve_string_in_html(expand_macros( nl2[k].value, copy, volume, volume.record() ).substr(0,lw));
- if ($('pl').checked) {
- var sib = nl2[k].nextSibling;
- if (sib) {
- for (var m = 0; m < lw - nl2[k].value.length; m++) html += ' ';
- for (var m = 0; m < mm; m++) html += ' ';
- html += util.text.preserve_string_in_html(expand_macros( sib.value, copy, volume, volume.record() ).substr(0,plw));
- }
- }
- html += '\n';
- }
- html += '</pre>\n';
- }
- }
- html += '</body></html>';
- JSAN.use('util.window'); var win = new util.window();
- var loc = ( urls.XUL_REMOTE_BROWSER );
- //+ '?url=' + window.escape('about:blank') + '&show_print_button=1&alternate_print=1&no_xulG=1&title=' + window.escape('Spine Labels');
- var w = win.open( loc, 'spine_preview', 'chrome,resizable,width=750,height=550');
- w.xulG = {
- 'url' : 'about:blank',
- 'show_print_button' : 1,
- 'alternate_print' : 1,
- 'no_xulG' : 1,
- 'title' : $("catStrings").getString('staff.cat.spine_labels.preview.title'),
- 'on_url_load' : function(b) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- if (typeof w.xulG.written == 'undefined') {
- w.xulG.written = true;
- w.g.browser.get_content().document.write(html);
- w.g.browser.get_content().document.close();
- }
- } catch(E) {
- alert(E);
- }
- }
- };
- } catch(E) {
- g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.preview.std_unexpected_err'),E);
- }
- }
+ }
+ };
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.spine_labels.preview.std_unexpected_err'),E);
+ }
+ }
if (typeof cat == 'undefined') var cat = {};
cat.util = {};
-cat.util.EXPORT_OK = [
- 'spawn_copy_editor', 'add_copies_to_bucket', 'show_in_opac', 'spawn_spine_editor', 'transfer_copies',
- 'mark_item_missing', 'mark_item_damaged', 'replace_barcode', 'fast_item_add'
+cat.util.EXPORT_OK = [
+ 'spawn_copy_editor', 'add_copies_to_bucket', 'show_in_opac', 'spawn_spine_editor', 'transfer_copies',
+ 'mark_item_missing', 'mark_item_damaged', 'replace_barcode', 'fast_item_add'
];
-cat.util.EXPORT_TAGS = { ':all' : cat.util.EXPORT_OK };
+cat.util.EXPORT_TAGS = { ':all' : cat.util.EXPORT_OK };
cat.util.replace_barcode = function(old_bc) {
- try {
- JSAN.use('util.network');
- var network = new util.network();
+ try {
+ JSAN.use('util.network');
+ var network = new util.network();
- if (!old_bc) old_bc = window.prompt($("catStrings").getString('staff.cat.util.replace_barcode.old_bc_window_prompt.prompt'),
- '',
- $("catStrings").getString('staff.cat.util.replace_barcode.old_bc_window_prompt.title'));
- if (!old_bc) return;
+ if (!old_bc) old_bc = window.prompt($("catStrings").getString('staff.cat.util.replace_barcode.old_bc_window_prompt.prompt'),
+ '',
+ $("catStrings").getString('staff.cat.util.replace_barcode.old_bc_window_prompt.title'));
+ if (!old_bc) return;
- var copy;
+ var copy;
try {
- copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
- if (typeof copy.ilsevent != 'undefined') throw(copy);
- if (!copy) throw(copy);
- } catch(E) {
- alert($("catStrings").getFormattedString('staff.cat.util.replace_barcode.error_alert', [old_bc]) + '\n');
- return old_bc;
- }
-
- // Why did I want to do this twice? Because this copy is more fleshed?
- try {
- copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
- if (typeof copy.ilsevent != 'undefined') throw(copy);
- if (!copy) throw(copy);
- } catch(E) {
- try {
- alert($("catStrings").getFormattedString('staff.cat.util.replace_barcode.error_alert', [old_bc]) +
- '\n' + (typeof E.ilsevent == 'undefined' ? '' : E.textcode + ' : ' + E.desc));
- } catch(F) {
- alert(E + '\n' + F);
- }
- return old_bc;
- }
-
- var new_bc = window.prompt($("catStrings").getString('staff.cat.util.replace_barcode.new_bc_window_prompt.prompt'),
- '',
- $("catStrings").getString('staff.cat.util.replace_barcode.new_bc_window_prompt.title'));
- new_bc = String( new_bc ).replace(/\s/g,'');
- /* Casting a possibly null input value to a String turns it into "null" */
- if (!new_bc || new_bc == 'null') {
- alert($("catStrings").getString('staff.cat.util.replace_barcode.new_bc.failed'));
- return old_bc;
- }
-
- var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ new_bc ]);
- if (typeof test.ilsevent == 'undefined') {
- alert('Rename aborted. Another copy has barcode "' + new_bc + '".');
- return old_bc;
- } else {
- if (test.ilsevent != 1502 /* ASSET_COPY_NOT_FOUND */) {
- obj.error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.replace_barcode.testing_error', [new_bc]), test);
- return old_bc;
- }
- }
-
- copy.barcode(new_bc); copy.ischanged('1');
- var r = network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE', [ ses(), [ copy ] ]);
- if (typeof r.ilsevent != 'undefined') {
- if (r.ilsevent != 0) {
- if (r.ilsevent == 5000 /* PERM_FAILURE */) {
- alert($("catStrings").getString('staff.cat.util.replace_barcode.insufficient_permission_for_rename'));
- return old_bc;
- } else {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.util.replace_barcode.item_rename_error'),r);
- return old_bc;
- }
- }
- }
-
- return new_bc;
- } catch(E) {
- JSAN.use('util.error'); var error = new util.error();
- error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.util.replace_barcode.rename_error'),E);
- return old_bc;
- }
+ copy = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ old_bc ]);
+ if (typeof copy.ilsevent != 'undefined') throw(copy);
+ if (!copy) throw(copy);
+ } catch(E) {
+ alert($("catStrings").getFormattedString('staff.cat.util.replace_barcode.error_alert', [old_bc]) + '\n');
+ return old_bc;
+ }
+
+ // Why did I want to do this twice? Because this copy is more fleshed?
+ try {
+ copy = network.simple_request('FM_ACP_RETRIEVE',[ copy.id() ]);
+ if (typeof copy.ilsevent != 'undefined') throw(copy);
+ if (!copy) throw(copy);
+ } catch(E) {
+ try {
+ alert($("catStrings").getFormattedString('staff.cat.util.replace_barcode.error_alert', [old_bc]) +
+ '\n' + (typeof E.ilsevent == 'undefined' ? '' : E.textcode + ' : ' + E.desc));
+ } catch(F) {
+ alert(E + '\n' + F);
+ }
+ return old_bc;
+ }
+
+ var new_bc = window.prompt($("catStrings").getString('staff.cat.util.replace_barcode.new_bc_window_prompt.prompt'),
+ '',
+ $("catStrings").getString('staff.cat.util.replace_barcode.new_bc_window_prompt.title'));
+ new_bc = String( new_bc ).replace(/\s/g,'');
+ /* Casting a possibly null input value to a String turns it into "null" */
+ if (!new_bc || new_bc == 'null') {
+ alert($("catStrings").getString('staff.cat.util.replace_barcode.new_bc.failed'));
+ return old_bc;
+ }
+
+ var test = network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ new_bc ]);
+ if (typeof test.ilsevent == 'undefined') {
+ alert('Rename aborted. Another copy has barcode "' + new_bc + '".');
+ return old_bc;
+ } else {
+ if (test.ilsevent != 1502 /* ASSET_COPY_NOT_FOUND */) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.replace_barcode.testing_error', [new_bc]), test);
+ return old_bc;
+ }
+ }
+
+ copy.barcode(new_bc); copy.ischanged('1');
+ var r = network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE', [ ses(), [ copy ] ]);
+ if (typeof r.ilsevent != 'undefined') {
+ if (r.ilsevent != 0) {
+ if (r.ilsevent == 5000 /* PERM_FAILURE */) {
+ alert($("catStrings").getString('staff.cat.util.replace_barcode.insufficient_permission_for_rename'));
+ return old_bc;
+ } else {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.util.replace_barcode.item_rename_error'),r);
+ return old_bc;
+ }
+ }
+ }
+
+ return new_bc;
+ } catch(E) {
+ JSAN.use('util.error'); var error = new util.error();
+ error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.util.replace_barcode.rename_error'),E);
+ return old_bc;
+ }
}
cat.util.transfer_copies = function(params) {
- JSAN.use('util.error'); var error = new util.error();
- JSAN.use('OpenILS.data'); var data = new OpenILS.data();
- JSAN.use('util.network'); var network = new util.network();
- try {
- data.stash_retrieve();
- if (!data.marked_volume) {
- alert($("catStrings").getString('staff.cat.util.transfer_copies.unmarked_volume_alert'));
- return;
- }
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
- if (!params.message) {
- params.message = $("catStrings").getFormattedString('staff.cat.util.transfer_copies.params_message', [data.hash.aou[ params.owning_lib ].shortname(), params.volume_label]);
- //params.message = 'Transfer items from their original volumes to ';
- //params.message += data.hash.aou[ params.owning_lib ].shortname() + "'s volume labelled ";
- //params.message += '"' + params.volume_label + '" on the following record (and change their circ libs to match)?';
- }
-
- xml += '<description>' + params.message.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') + '</description>';
- xml += '<hbox><button label="' + $("catStrings").getString('staff.cat.util.transfer_copies.transfer.label')+ '" name="fancy_submit"/>';
- xml += '<button label="' + $("catStrings").getString('staff.cat.util.transfer_copies.cancel.label');
- xml += '" accesskey="'+ $("catStrings").getString('staff.cat.util.transfer_copies.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
- xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + params.docid + '"/>';
- xml += '</vbox>';
- //data.temp_transfer = xml; data.stash('temp_transfer');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_transfer'
- //+ '&title=' + window.escape('Item Transfer'),
- 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
- { 'xml' : xml, 'title' : $("catStrings").getString('staff.cat.util.transfer_copies.window_title') }
- );
- if (fancy_prompt_data.fancy_status == 'incomplete') { alert($("catStrings").getString('staff.cat.util.transfer_copies.aborted_transfer')); return; }
-
- JSAN.use('util.functional');
-
- var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative', [ params.copy_ids ]);
-
- for (var i = 0; i < copies.length; i++) {
- copies[i].call_number( data.marked_volume );
- copies[i].circ_lib( params.owning_lib );
- copies[i].ischanged( 1 );
- }
-
- var robj = network.simple_request(
- 'FM_ACP_FLESHED_BATCH_UPDATE',
- [ ses(), copies, true ],
- null,
- {
- 'title' : $("catStrings").getString('staff.cat.util.transfer_copies.override_transfer_failure'),
- 'overridable_events' : [
- 1208 /* TITLE_LAST_COPY */,
- 1227 /* COPY_DELETE_WARNING */,
- ]
- }
- );
-
- if (typeof robj.ilsevent != 'undefined') {
- throw(robj);
- } else {
- alert($("catStrings").getString('staff.cat.util.transfer_copies.successful_transfer'));
- }
-
- } catch(E) {
- error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.util.transfer_copies.transfer_error'),E);
- }
+ JSAN.use('util.error'); var error = new util.error();
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data();
+ JSAN.use('util.network'); var network = new util.network();
+ try {
+ data.stash_retrieve();
+ if (!data.marked_volume) {
+ alert($("catStrings").getString('staff.cat.util.transfer_copies.unmarked_volume_alert'));
+ return;
+ }
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
+ if (!params.message) {
+ params.message = $("catStrings").getFormattedString('staff.cat.util.transfer_copies.params_message', [data.hash.aou[ params.owning_lib ].shortname(), params.volume_label]);
+ //params.message = 'Transfer items from their original volumes to ';
+ //params.message += data.hash.aou[ params.owning_lib ].shortname() + "'s volume labelled ";
+ //params.message += '"' + params.volume_label + '" on the following record (and change their circ libs to match)?';
+ }
+
+ xml += '<description>' + params.message.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>') + '</description>';
+ xml += '<hbox><button label="' + $("catStrings").getString('staff.cat.util.transfer_copies.transfer.label')+ '" name="fancy_submit"/>';
+ xml += '<button label="' + $("catStrings").getString('staff.cat.util.transfer_copies.cancel.label');
+ xml += '" accesskey="'+ $("catStrings").getString('staff.cat.util.transfer_copies.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
+ xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + params.docid + '"/>';
+ xml += '</vbox>';
+ //data.temp_transfer = xml; data.stash('temp_transfer');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_transfer'
+ //+ '&title=' + window.escape('Item Transfer'),
+ 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
+ { 'xml' : xml, 'title' : $("catStrings").getString('staff.cat.util.transfer_copies.window_title') }
+ );
+ if (fancy_prompt_data.fancy_status == 'incomplete') { alert($("catStrings").getString('staff.cat.util.transfer_copies.aborted_transfer')); return; }
+
+ JSAN.use('util.functional');
+
+ var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative', [ params.copy_ids ]);
+
+ for (var i = 0; i < copies.length; i++) {
+ copies[i].call_number( data.marked_volume );
+ copies[i].circ_lib( params.owning_lib );
+ copies[i].ischanged( 1 );
+ }
+
+ var robj = network.simple_request(
+ 'FM_ACP_FLESHED_BATCH_UPDATE',
+ [ ses(), copies, true ],
+ null,
+ {
+ 'title' : $("catStrings").getString('staff.cat.util.transfer_copies.override_transfer_failure'),
+ 'overridable_events' : [
+ 1208 /* TITLE_LAST_COPY */,
+ 1227 /* COPY_DELETE_WARNING */,
+ ]
+ }
+ );
+
+ if (typeof robj.ilsevent != 'undefined') {
+ throw(robj);
+ } else {
+ alert($("catStrings").getString('staff.cat.util.transfer_copies.successful_transfer'));
+ }
+
+ } catch(E) {
+ error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.util.transfer_copies.transfer_error'),E);
+ }
}
cat.util.spawn_spine_editor = function(selection_list) {
- JSAN.use('util.error'); var error = new util.error();
- try {
- JSAN.use('util.functional');
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
- data.temp_barcodes_for_labels = util.functional.map_list( selection_list, function(o){return o.barcode;}) ;
- data.stash('temp_barcodes_for_labels');
- xulG.new_tab(
- xulG.url_prefix( urls.XUL_SPINE_LABEL ),
- { 'tab_name' : $("catStrings").getString('staff.cat.util.spine_editor.tab_name') },
- {}
- );
- } catch(E) {
- error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.util.spine_editor.spine_editor_error'),E);
- }
+ JSAN.use('util.error'); var error = new util.error();
+ try {
+ JSAN.use('util.functional');
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+ data.temp_barcodes_for_labels = util.functional.map_list( selection_list, function(o){return o.barcode;}) ;
+ data.stash('temp_barcodes_for_labels');
+ xulG.new_tab(
+ xulG.url_prefix( urls.XUL_SPINE_LABEL ),
+ { 'tab_name' : $("catStrings").getString('staff.cat.util.spine_editor.tab_name') },
+ {}
+ );
+ } catch(E) {
+ error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.util.spine_editor.spine_editor_error'),E);
+ }
}
cat.util.show_in_opac = function(selection_list) {
- JSAN.use('util.error'); var error = new util.error();
- var doc_id; var seen = {};
- try {
- for (var i = 0; i < selection_list.length; i++) {
- doc_id = selection_list[i].doc_id;
- if (!doc_id) {
- alert($("catStrings").getFormattedString('staff.cat.util.show_in_opac.unknown_barcode', [selection_list[i].barcode]));
- continue;
- }
+ JSAN.use('util.error'); var error = new util.error();
+ var doc_id; var seen = {};
+ try {
+ for (var i = 0; i < selection_list.length; i++) {
+ doc_id = selection_list[i].doc_id;
+ if (!doc_id) {
+ alert($("catStrings").getFormattedString('staff.cat.util.show_in_opac.unknown_barcode', [selection_list[i].barcode]));
+ continue;
+ }
if (doc_id == -1 ) {
continue; /* pre-cat */
}
- if (typeof seen[doc_id] != 'undefined') {
- continue;
- }
- seen[doc_id] = true;
- var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id;
- var content_params = {
- 'session' : ses(),
- 'authtime' : ses('authtime'),
- 'opac_url' : opac_url,
- };
- xulG.new_tab(
- xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
- {'tab_name':'Retrieving title...'},
- content_params
- );
- }
- } catch(E) {
- error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.show_in_opac.catalog_error_for_doc_id', [doc_id]),E);
- }
+ if (typeof seen[doc_id] != 'undefined') {
+ continue;
+ }
+ seen[doc_id] = true;
+ var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id;
+ var content_params = {
+ 'session' : ses(),
+ 'authtime' : ses('authtime'),
+ 'opac_url' : opac_url,
+ };
+ xulG.new_tab(
+ xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name':'Retrieving title...'},
+ content_params
+ );
+ }
+ } catch(E) {
+ error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.show_in_opac.catalog_error_for_doc_id', [doc_id]),E);
+ }
}
cat.util.add_copies_to_bucket = function(selection_list) {
- JSAN.use('util.functional');
- JSAN.use('util.window'); var win = new util.window();
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- data.cb_temp_copy_ids = js2JSON(
- util.functional.map_list(
- selection_list,
- function (o) {
- if (typeof o.copy_id != 'undefined' && o.copy_id != null) {
- return o.copy_id;
- } else {
- return o;
- }
- }
- )
- );
- data.stash('cb_temp_copy_ids');
- win.open(
- xulG.url_prefix(urls.XUL_COPY_BUCKETS_QUICK),
- 'sel_bucket_win' + win.window_name_increment(),
- 'chrome,resizable,center'
- );
+ JSAN.use('util.functional');
+ JSAN.use('util.window'); var win = new util.window();
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ data.cb_temp_copy_ids = js2JSON(
+ util.functional.map_list(
+ selection_list,
+ function (o) {
+ if (typeof o.copy_id != 'undefined' && o.copy_id != null) {
+ return o.copy_id;
+ } else {
+ return o;
+ }
+ }
+ )
+ );
+ data.stash('cb_temp_copy_ids');
+ win.open(
+ xulG.url_prefix(urls.XUL_COPY_BUCKETS_QUICK),
+ 'sel_bucket_win' + win.window_name_increment(),
+ 'chrome,resizable,center'
+ );
}
cat.util.spawn_copy_editor = function(params) {
- try {
+ try {
if (!params.copy_ids && !params.copies) return;
- if (params.copy_ids && params.copy_ids.length == 0) return;
- if (params.copies && params.copies.length == 0) return;
+ if (params.copy_ids && params.copy_ids.length == 0) return;
+ if (params.copies && params.copies.length == 0) return;
if (params.copy_ids) params.copy_ids = js2JSON(params.copy_ids); // legacy
if (!params.caller_handles_update) params.handle_update = 1; // legacy
- var obj = {};
- JSAN.use('util.network'); obj.network = new util.network();
- JSAN.use('util.error'); obj.error = new util.error();
-
- var title = '';
- if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
- title = $("catStrings").getString('staff.cat.util.copy_editor.batch_edit');
- else if(params.copies && params.copies.length > 1 && params.edit == 1)
- title = $("catStrings").getString('staff.cat.util.copy_editor.batch_view');
- else if(params.copy_ids && params.copy_ids.length == 1)
- title = $("catStrings").getString('staff.cat.util.copy_editor.edit');
- else
- title = $("catStrings").getString('staff.cat.util.copy_editor.view');
-
- JSAN.use('util.window'); var win = new util.window();
- var my_xulG = win.open(
- (urls.XUL_COPY_EDITOR),
- title,
- 'chrome,modal,resizable',
+ var obj = {};
+ JSAN.use('util.network'); obj.network = new util.network();
+ JSAN.use('util.error'); obj.error = new util.error();
+
+ var title = '';
+ if (params.copy_ids && params.copy_ids.length > 1 && params.edit == 1)
+ title = $("catStrings").getString('staff.cat.util.copy_editor.batch_edit');
+ else if(params.copies && params.copies.length > 1 && params.edit == 1)
+ title = $("catStrings").getString('staff.cat.util.copy_editor.batch_view');
+ else if(params.copy_ids && params.copy_ids.length == 1)
+ title = $("catStrings").getString('staff.cat.util.copy_editor.edit');
+ else
+ title = $("catStrings").getString('staff.cat.util.copy_editor.view');
+
+ JSAN.use('util.window'); var win = new util.window();
+ var my_xulG = win.open(
+ (urls.XUL_COPY_EDITOR),
+ title,
+ 'chrome,modal,resizable',
params
- );
- if (!my_xulG.copies && params.edit) {
+ );
+ if (!my_xulG.copies && params.edit) {
alert(typeof params.no_copies_modified_msg != 'undefined' ? params.no_copies_modified_msg : $("catStrings").getString('staff.cat.util.copy_editor.not_modified'));
} else {
return my_xulG.copies;
}
return [];
- } catch(E) {
- JSAN.use('util.error'); var error = new util.error();
- error.standard_unexpected_error_alert('error in cat.util.spawn_copy_editor',E);
- }
+ } catch(E) {
+ JSAN.use('util.error'); var error = new util.error();
+ error.standard_unexpected_error_alert('error in cat.util.spawn_copy_editor',E);
+ }
}
cat.util.mark_item_damaged = function(copy_ids) {
- var error;
- try {
- JSAN.use('util.error'); error = new util.error();
- JSAN.use('util.functional');
- JSAN.use('util.network'); var network = new util.network();
- var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative', [ copy_ids ]);
- if (typeof copies.ilsevent != 'undefined') throw(copies);
- var magic_status = false;
- for (var i = 0; i < copies.length; i++) {
- var status = copies[i].status(); if (typeof status == 'object') status = status.id();
- if (typeof my_constants.magical_statuses[ status ] != 'undefined')
- if (my_constants.magical_statuses[ status ].block_mark_item_damaged) magic_status = true;
- }
- if (magic_status) {
-
- error.yns_alert($("catStrings").getString('staff.cat.util.mark_item_damaged.af_message'),
- $("catStrings").getString('staff.cat.util.mark_item_damaged.af_title'),
- $("catStrings").getString('staff.cat.util.mark_item_damaged.af_ok_label'), null, null,
- $("catStrings").getString('staff.cat.util.mark_item_damaged.af_confirm_action'));
-
- } else {
-
- var r = error.yns_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.md_message', [util.functional.map_list( copies, function(o) { return o.barcode(); } ).join(", ")]),
- $("catStrings").getString('staff.cat.util.mark_item_damaged.md_title'),
- $("catStrings").getString('staff.cat.util.mark_item_damaged.md_ok_label'),
- $("catStrings").getString('staff.cat.util.mark_item_damaged.md_cancel_label'), null,
- $("catStrings").getString('staff.cat.util.mark_item_damaged.md_confirm_action'));
-
- if (r == 0) {
- var count = 0;
- for (var i = 0; i < copies.length; i++) {
- try {
+ var error;
+ try {
+ JSAN.use('util.error'); error = new util.error();
+ JSAN.use('util.functional');
+ JSAN.use('util.network'); var network = new util.network();
+ var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative', [ copy_ids ]);
+ if (typeof copies.ilsevent != 'undefined') throw(copies);
+ var magic_status = false;
+ for (var i = 0; i < copies.length; i++) {
+ var status = copies[i].status(); if (typeof status == 'object') status = status.id();
+ if (typeof my_constants.magical_statuses[ status ] != 'undefined')
+ if (my_constants.magical_statuses[ status ].block_mark_item_damaged) magic_status = true;
+ }
+ if (magic_status) {
+
+ error.yns_alert($("catStrings").getString('staff.cat.util.mark_item_damaged.af_message'),
+ $("catStrings").getString('staff.cat.util.mark_item_damaged.af_title'),
+ $("catStrings").getString('staff.cat.util.mark_item_damaged.af_ok_label'), null, null,
+ $("catStrings").getString('staff.cat.util.mark_item_damaged.af_confirm_action'));
+
+ } else {
+
+ var r = error.yns_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.md_message', [util.functional.map_list( copies, function(o) { return o.barcode(); } ).join(", ")]),
+ $("catStrings").getString('staff.cat.util.mark_item_damaged.md_title'),
+ $("catStrings").getString('staff.cat.util.mark_item_damaged.md_ok_label'),
+ $("catStrings").getString('staff.cat.util.mark_item_damaged.md_cancel_label'), null,
+ $("catStrings").getString('staff.cat.util.mark_item_damaged.md_confirm_action'));
+
+ if (r == 0) {
+ var count = 0;
+ for (var i = 0; i < copies.length; i++) {
+ try {
var my_circ = network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),copies[i].id(),1]);
if (typeof my_circ.ilsevent == 'undefined') {
}
}
- var robj = network.simple_request('MARK_ITEM_DAMAGED',[ses(),copies[i].id()]);
- if (typeof robj.ilsevent != 'undefined') {
+ var robj = network.simple_request('MARK_ITEM_DAMAGED',[ses(),copies[i].id()]);
+ if (typeof robj.ilsevent != 'undefined') {
switch(robj.textcode) {
case 'DAMAGE_CHARGE' :
JSAN.use('util.money');
$("catStrings").getString('staff.cat.util.mark_item_damaged.charge_patron_prompt.confirm_action'));
robj = network.simple_request('MARK_ITEM_DAMAGED',[ ses(), copies[i].id(), {'apply_fines' : r1 == 0 ? 'apply' : 'noapply'} ]);
- if (typeof robj.ilsevent != 'undefined') { throw(robj); }
+ if (typeof robj.ilsevent != 'undefined') { throw(robj); }
break;
default: throw(robj);
}
}
- count++;
- } catch(E) {
- error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.marking_error', [copies[i].barcode()]),E);
- }
- }
- alert(count == 1 ? $("catStrings").getString('staff.cat.util.mark_item_damaged.one_item_damaged') :
- $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.multiple_item_damaged', [count]));
- }
- }
-
- } catch(E) {
- if (error) error.standard_unexpected_error_alert('cat.util.mark_item_damaged',E); else alert('FIXME: ' + E);
- }
+ count++;
+ } catch(E) {
+ error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.marking_error', [copies[i].barcode()]),E);
+ }
+ }
+ alert(count == 1 ? $("catStrings").getString('staff.cat.util.mark_item_damaged.one_item_damaged') :
+ $("catStrings").getFormattedString('staff.cat.util.mark_item_damaged.multiple_item_damaged', [count]));
+ }
+ }
+
+ } catch(E) {
+ if (error) error.standard_unexpected_error_alert('cat.util.mark_item_damaged',E); else alert('FIXME: ' + E);
+ }
}
cat.util.mark_item_missing = function(copy_ids) {
- var error;
- try {
- JSAN.use('util.error'); error = new util.error();
- JSAN.use('util.functional');
- JSAN.use('util.network'); var network = new util.network();
- var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative', [ copy_ids ]);
- if (typeof copies.ilsevent != 'undefined') throw(copies);
- var magic_status = false;
- for (var i = 0; i < copies.length; i++) {
- var status = copies[i].status(); if (typeof status == 'object') status = status.id();
- if (typeof my_constants.magical_statuses[ status ] != 'undefined')
- if (my_constants.magical_statuses[ status ].block_mark_item_action) magic_status = true;
- }
- if (magic_status) {
-
- error.yns_alert($("catStrings").getString('staff.cat.util.mark_item_missing.af_message'),
- $("catStrings").getString('staff.cat.util.mark_item_missing.af_title'),
- $("catStrings").getString('staff.cat.util.mark_item_missing.af_ok_label'), null, null,
- $("catStrings").getString('staff.cat.util.mark_item_missing.af_confirm_action'));
-
- } else {
-
- var r = error.yns_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_missing.ms_message', [util.functional.map_list( copies, function(o) { return o.barcode(); } ).join(", ")]),
- $("catStrings").getString('staff.cat.util.mark_item_missing.ms_title'),
- $("catStrings").getString('staff.cat.util.mark_item_missing.ms_ok_label'),
- $("catStrings").getString('staff.cat.util.mark_item_missing.ms_cancel_label'), null,
- $("catStrings").getString('staff.cat.util.mark_item_missing.ms_confirm_action'));
-
- if (r == 0) {
- var count = 0;
- for (var i = 0; i < copies.length; i++) {
- try {
- var robj = network.simple_request('MARK_ITEM_MISSING',[ses(),copies[i].id()]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- count++;
- } catch(E) {
- error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_missing.marking_error', [copies[i].barcode()]),E);
- }
- }
- alert(count == 1 ? $("catStrings").getString('staff.cat.util.mark_item_missing.one_item_missing') :
- $("catStrings").getFormattedString('staff.cat.util.mark_item_missing.multiple_item_missing', [count]));
- }
- }
-
- } catch(E) {
- if (error) error.standard_unexpected_error_alert('cat.util.mark_item_missing',E); else alert('FIXME: ' + E);
- }
+ var error;
+ try {
+ JSAN.use('util.error'); error = new util.error();
+ JSAN.use('util.functional');
+ JSAN.use('util.network'); var network = new util.network();
+ var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative', [ copy_ids ]);
+ if (typeof copies.ilsevent != 'undefined') throw(copies);
+ var magic_status = false;
+ for (var i = 0; i < copies.length; i++) {
+ var status = copies[i].status(); if (typeof status == 'object') status = status.id();
+ if (typeof my_constants.magical_statuses[ status ] != 'undefined')
+ if (my_constants.magical_statuses[ status ].block_mark_item_action) magic_status = true;
+ }
+ if (magic_status) {
+
+ error.yns_alert($("catStrings").getString('staff.cat.util.mark_item_missing.af_message'),
+ $("catStrings").getString('staff.cat.util.mark_item_missing.af_title'),
+ $("catStrings").getString('staff.cat.util.mark_item_missing.af_ok_label'), null, null,
+ $("catStrings").getString('staff.cat.util.mark_item_missing.af_confirm_action'));
+
+ } else {
+
+ var r = error.yns_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_missing.ms_message', [util.functional.map_list( copies, function(o) { return o.barcode(); } ).join(", ")]),
+ $("catStrings").getString('staff.cat.util.mark_item_missing.ms_title'),
+ $("catStrings").getString('staff.cat.util.mark_item_missing.ms_ok_label'),
+ $("catStrings").getString('staff.cat.util.mark_item_missing.ms_cancel_label'), null,
+ $("catStrings").getString('staff.cat.util.mark_item_missing.ms_confirm_action'));
+
+ if (r == 0) {
+ var count = 0;
+ for (var i = 0; i < copies.length; i++) {
+ try {
+ var robj = network.simple_request('MARK_ITEM_MISSING',[ses(),copies[i].id()]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ count++;
+ } catch(E) {
+ error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.util.mark_item_missing.marking_error', [copies[i].barcode()]),E);
+ }
+ }
+ alert(count == 1 ? $("catStrings").getString('staff.cat.util.mark_item_missing.one_item_missing') :
+ $("catStrings").getFormattedString('staff.cat.util.mark_item_missing.multiple_item_missing', [count]));
+ }
+ }
+
+ } catch(E) {
+ if (error) error.standard_unexpected_error_alert('cat.util.mark_item_missing',E); else alert('FIXME: ' + E);
+ }
}
cat.util.fast_item_add = function(doc_id,cn_label,cp_barcode) {
- var error;
- try {
+ var error;
+ try {
- JSAN.use('util.error'); error = new util.error();
- JSAN.use('util.network'); var network = new util.network();
+ JSAN.use('util.error'); error = new util.error();
+ JSAN.use('util.network'); var network = new util.network();
var acn_id = network.simple_request(
'FM_ACN_FIND_OR_CREATE',
copy_obj.opac_visible(get_db_true());
copy_obj.ref(get_db_false());
- JSAN.use('util.window'); var win = new util.window();
+ JSAN.use('util.window'); var win = new util.window();
JSAN.use('cat.util');
return cat.util.spawn_copy_editor( { 'handle_update' : 1, 'edit' : 1, 'docid' : doc_id, 'copies' : [ copy_obj ] });
- } catch(E) {
- if (error) error.standard_unexpected_error_alert('cat.util.fast_item_add',E); else alert('FIXME: ' + E);
- }
+ } catch(E) {
+ if (error) error.standard_unexpected_error_alert('cat.util.fast_item_add',E); else alert('FIXME: ' + E);
+ }
}
dump('exiting cat/util.js\n');
var g = {};
function my_init() {
- try {
+ try {
- /***********************************************************************************************************/
- /* Initial setup */
+ /***********************************************************************************************************/
+ /* Initial setup */
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.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 cat/volume_copy_creator.xul');
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.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 cat/volume_copy_creator.xul');
- JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
- JSAN.use('util.widgets'); JSAN.use('util.functional');
+ JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
- JSAN.use('util.network'); g.network = new util.network();
+ JSAN.use('util.network'); g.network = new util.network();
- /***********************************************************************************************************/
- /* What record am I dealing with? Am I adding just copies or copies and volumes? */
+ /***********************************************************************************************************/
+ /* What record am I dealing with? Am I adding just copies or copies and volumes? */
- g.doc_id = xul_param('doc_id');
+ g.doc_id = xul_param('doc_id');
var sb = document.getElementById('summary_box'); while(sb.firstChild) sb.removeChild(sb.lastChild);
var summary = document.createElement('iframe'); sb.appendChild(summary);
- summary.setAttribute('src',urls.XUL_BIB_BRIEF);
- summary.setAttribute('flex','1');
- get_contentWindow(summary).xulG = { 'docid' : g.doc_id };
-
- g.copy_shortcut = xul_param('copy_shortcut',{'JSON2js_if_cgi':true});
- g.error.sdump('D_ERROR','location.href = ' + location.href + '\n\ncopy_short cut = ' + g.copy_shortcut + '\n\nou_ids = ' + xul_param('ou_ids'));
-
- var ou_ids = xul_param('ou_ids',{'JSON2js_if_cgi' : true, 'concat' : true});;
-
- /***********************************************************************************************************/
- /* For the call number drop down */
-
- var cn_blob;
- try {
- cn_blob = g.network.simple_request('BLOB_MARC_CALLNUMBERS_RETRIEVE',[g.doc_id]);
- } catch(E) {
- cn_blob = [];
- }
- if ((!g.copy_shortcut)) {
- var hbox = document.getElementById('marc_cn');
- var ml = util.widgets.make_menulist(
- util.functional.map_list(
- cn_blob,
- function(o) {
- for (var i in o) {
- return [ o[i], i ];
- }
- }
- ).sort(
- function(a,b) {
- a = a[1]; b = b[1];
- if (a == '082') return -1;
- if (b == '082') return 1;
- if (a == '092') return -1;
- if (b == '092') return 1;
- if (a < b) return -1;
- if (a > b) return 1;
- return 0;
- }
- )
- ); hbox.appendChild(ml);
- ml.setAttribute('editable','true');
- ml.setAttribute('width', '200');
- var btn = document.createElement('button');
- btn.setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.my_init.btn.label'));
- btn.setAttribute('accesskey','A');
- btn.setAttribute('image','/xul/server/skin/media/images/down_arrow.gif');
- hbox.appendChild(btn);
- btn.addEventListener(
- 'command',
- function() {
- var nl = document.getElementsByTagName('textbox');
- for (var i = 0; i < nl.length; i++) {
- if (nl[i].getAttribute('rel_vert_pos')==2
- && !nl[i].disabled) nl[i].value = ml.value;
- }
- if (g.last_focus) setTimeout( function() { g.last_focus.focus(); }, 0 );
- },
- false
- );
- }
-
- /***********************************************************************************************************/
- /* render the orgs and volumes/input */
-
- var rows = document.getElementById('rows');
-
- var node_id = 0;
- for (var i = 0; i < ou_ids.length; i++) {
- try {
- var org = g.data.hash.aou[ ou_ids[i] ];
- if ( get_bool( g.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
- var row = document.createElement('row'); rows.appendChild(row); row.setAttribute('ou_id',ou_ids[i]);
- g.render_library_label(row,ou_ids[i]);
- g.render_volume_count_entry(row,ou_ids[i]);
- }
- } catch(E) {
- g.error.sdump('D_ERROR',E);
- }
- }
-
- g.load_prefs();
-
- } catch(E) {
- var err_msg = $("commonStrings").getFormattedString('common.exception', ['cat/volume_copy_creator.js', E]);
- try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); dump(js2JSON(E)); }
- alert(err_msg);
- }
+ summary.setAttribute('src',urls.XUL_BIB_BRIEF);
+ summary.setAttribute('flex','1');
+ get_contentWindow(summary).xulG = { 'docid' : g.doc_id };
+
+ g.copy_shortcut = xul_param('copy_shortcut',{'JSON2js_if_cgi':true});
+ g.error.sdump('D_ERROR','location.href = ' + location.href + '\n\ncopy_short cut = ' + g.copy_shortcut + '\n\nou_ids = ' + xul_param('ou_ids'));
+
+ var ou_ids = xul_param('ou_ids',{'JSON2js_if_cgi' : true, 'concat' : true});;
+
+ /***********************************************************************************************************/
+ /* For the call number drop down */
+
+ var cn_blob;
+ try {
+ cn_blob = g.network.simple_request('BLOB_MARC_CALLNUMBERS_RETRIEVE',[g.doc_id]);
+ } catch(E) {
+ cn_blob = [];
+ }
+ if ((!g.copy_shortcut)) {
+ var hbox = document.getElementById('marc_cn');
+ var ml = util.widgets.make_menulist(
+ util.functional.map_list(
+ cn_blob,
+ function(o) {
+ for (var i in o) {
+ return [ o[i], i ];
+ }
+ }
+ ).sort(
+ function(a,b) {
+ a = a[1]; b = b[1];
+ if (a == '082') return -1;
+ if (b == '082') return 1;
+ if (a == '092') return -1;
+ if (b == '092') return 1;
+ if (a < b) return -1;
+ if (a > b) return 1;
+ return 0;
+ }
+ )
+ ); hbox.appendChild(ml);
+ ml.setAttribute('editable','true');
+ ml.setAttribute('width', '200');
+ var btn = document.createElement('button');
+ btn.setAttribute('label',$('catStrings').getString('staff.cat.volume_copy_creator.my_init.btn.label'));
+ btn.setAttribute('accesskey','A');
+ btn.setAttribute('image','/xul/server/skin/media/images/down_arrow.gif');
+ hbox.appendChild(btn);
+ btn.addEventListener(
+ 'command',
+ function() {
+ var nl = document.getElementsByTagName('textbox');
+ for (var i = 0; i < nl.length; i++) {
+ if (nl[i].getAttribute('rel_vert_pos')==2
+ && !nl[i].disabled) nl[i].value = ml.value;
+ }
+ if (g.last_focus) setTimeout( function() { g.last_focus.focus(); }, 0 );
+ },
+ false
+ );
+ }
+
+ /***********************************************************************************************************/
+ /* render the orgs and volumes/input */
+
+ var rows = document.getElementById('rows');
+
+ var node_id = 0;
+ for (var i = 0; i < ou_ids.length; i++) {
+ try {
+ var org = g.data.hash.aou[ ou_ids[i] ];
+ if ( get_bool( g.data.hash.aout[ org.ou_type() ].can_have_vols() ) ) {
+ var row = document.createElement('row'); rows.appendChild(row); row.setAttribute('ou_id',ou_ids[i]);
+ g.render_library_label(row,ou_ids[i]);
+ g.render_volume_count_entry(row,ou_ids[i]);
+ }
+ } catch(E) {
+ g.error.sdump('D_ERROR',E);
+ }
+ }
+
+ g.load_prefs();
+
+ } catch(E) {
+ var err_msg = $("commonStrings").getFormattedString('common.exception', ['cat/volume_copy_creator.js', E]);
+ try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); dump(js2JSON(E)); }
+ alert(err_msg);
+ }
}
g.render_library_label = function(row,ou_id) {
- var label = document.createElement('label'); row.appendChild(label);
- label.setAttribute('ou_id',ou_id);
- label.setAttribute('value',g.data.hash.aou[ ou_id ].shortname());
+ var label = document.createElement('label'); row.appendChild(label);
+ label.setAttribute('ou_id',ou_id);
+ label.setAttribute('value',g.data.hash.aou[ ou_id ].shortname());
}
g.render_volume_count_entry = function(row,ou_id) {
- var hb = document.createElement('vbox'); row.appendChild(hb);
- var tb = document.createElement('textbox'); hb.appendChild(tb);
- tb.setAttribute('ou_id',ou_id); tb.setAttribute('size','3'); tb.setAttribute('cols','3');
- tb.setAttribute('rel_vert_pos','1');
- if ( (!g.copy_shortcut) && (!g.last_focus) ) { tb.focus(); g.last_focus = tb; }
- var node;
- function render_copy_count_entry(ev) {
- if (ev.target.disabled) return;
- if (! isNaN( Number( ev.target.value) ) ) {
- if ( Number( ev.target.value ) > g_max_copies_that_can_be_added_at_a_time_per_volume ) {
- g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_volume_count_entry.message', [g_max_copies_that_can_be_added_at_a_time_per_volume]),
- $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.title'),
- $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.ok_label'),null,null,'');
- return;
- }
- if (node) { row.removeChild(node); node = null; }
- //ev.target.disabled = true;
- node = g.render_callnumber_copy_count_entry(row,ou_id,ev.target.value);
- }
- }
- util.widgets.apply_vertical_tab_on_enter_handler(
- tb,
- function() { render_copy_count_entry({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); }
- );
- tb.addEventListener( 'change', render_copy_count_entry, false);
- tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
- setTimeout(
- function() {
- try {
- if (g.copy_shortcut) {
- JSAN.use('util.functional');
- tb.value = util.functional.map_object_to_list(
- g.copy_shortcut[ou_id],
- function(o,i) {
- return g.copy_shortcut[ou_id][i];
- }
- ).length
- render_copy_count_entry({'target':tb});
- tb.disabled = true;
- }
- } catch(E) {
- alert(E);
- }
- }, 0
- );
+ var hb = document.createElement('vbox'); row.appendChild(hb);
+ var tb = document.createElement('textbox'); hb.appendChild(tb);
+ tb.setAttribute('ou_id',ou_id); tb.setAttribute('size','3'); tb.setAttribute('cols','3');
+ tb.setAttribute('rel_vert_pos','1');
+ if ( (!g.copy_shortcut) && (!g.last_focus) ) { tb.focus(); g.last_focus = tb; }
+ var node;
+ function render_copy_count_entry(ev) {
+ if (ev.target.disabled) return;
+ if (! isNaN( Number( ev.target.value) ) ) {
+ if ( Number( ev.target.value ) > g_max_copies_that_can_be_added_at_a_time_per_volume ) {
+ g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_volume_count_entry.message', [g_max_copies_that_can_be_added_at_a_time_per_volume]),
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.title'),
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.ok_label'),null,null,'');
+ return;
+ }
+ if (node) { row.removeChild(node); node = null; }
+ //ev.target.disabled = true;
+ node = g.render_callnumber_copy_count_entry(row,ou_id,ev.target.value);
+ }
+ }
+ util.widgets.apply_vertical_tab_on_enter_handler(
+ tb,
+ function() { render_copy_count_entry({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); }
+ );
+ tb.addEventListener( 'change', render_copy_count_entry, false);
+ tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
+ setTimeout(
+ function() {
+ try {
+ if (g.copy_shortcut) {
+ JSAN.use('util.functional');
+ tb.value = util.functional.map_object_to_list(
+ g.copy_shortcut[ou_id],
+ function(o,i) {
+ return g.copy_shortcut[ou_id][i];
+ }
+ ).length
+ render_copy_count_entry({'target':tb});
+ tb.disabled = true;
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }, 0
+ );
}
g.render_callnumber_copy_count_entry = function(row,ou_id,count) {
- var grid = util.widgets.make_grid( [ {}, {} ] ); row.appendChild(grid);
- grid.setAttribute('flex','1');
- grid.setAttribute('ou_id',ou_id);
- var rows = grid.lastChild;
- var r = document.createElement('row'); rows.appendChild( r );
- var x = document.createElement('label'); r.appendChild(x);
- x.setAttribute('value', $("catStrings").getString('staff.cat.volume_copy_creator.render_callnumber_copy_count_entry.call_nums')); x.setAttribute('style','font-weight: bold');
- x = document.createElement('label'); r.appendChild(x);
- x.setAttribute('value',$("catStrings").getString('staff.cat.volume_copy_creator.render_callnumber_copy_count_entry.num_of_copies')); x.setAttribute('style','font-weight: bold');
- x.setAttribute('size','3'); x.setAttribute('cols','3');
-
-
- function handle_change(tb1,tb2,hb3) {
- if (tb1.value == '') return;
- if (isNaN( Number( tb2.value ) )) return;
- if ( Number( tb2.value ) > g_max_copies_that_can_be_added_at_a_time_per_volume ) {
- g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_volume_count_entry.message', [g_max_copies_that_can_be_added_at_a_time_per_volume]),
- $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.title'),
- $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.ok_label'),null,null,'');
+ var grid = util.widgets.make_grid( [ {}, {} ] ); row.appendChild(grid);
+ grid.setAttribute('flex','1');
+ grid.setAttribute('ou_id',ou_id);
+ var rows = grid.lastChild;
+ var r = document.createElement('row'); rows.appendChild( r );
+ var x = document.createElement('label'); r.appendChild(x);
+ x.setAttribute('value', $("catStrings").getString('staff.cat.volume_copy_creator.render_callnumber_copy_count_entry.call_nums')); x.setAttribute('style','font-weight: bold');
+ x = document.createElement('label'); r.appendChild(x);
+ x.setAttribute('value',$("catStrings").getString('staff.cat.volume_copy_creator.render_callnumber_copy_count_entry.num_of_copies')); x.setAttribute('style','font-weight: bold');
+ x.setAttribute('size','3'); x.setAttribute('cols','3');
+
+
+ function handle_change(tb1,tb2,hb3) {
+ if (tb1.value == '') return;
+ if (isNaN( Number( tb2.value ) )) return;
+ if ( Number( tb2.value ) > g_max_copies_that_can_be_added_at_a_time_per_volume ) {
+ g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_volume_count_entry.message', [g_max_copies_that_can_be_added_at_a_time_per_volume]),
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.title'),
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_volume_count_entry.ok_label'),null,null,'');
return;
- }
-
- //if (tb1.disabled || tb2.disabled) return;
-
- //tb1.disabled = true;
- //tb2.disabled = true;
-
- util.widgets.remove_children(hb3);
-
- g.render_barcode_entry(hb3,tb1.value,Number(tb2.value),ou_id);
- document.getElementById("Create").disabled = false;
- }
-
- function handle_change_tb1(ev) {
- var _tb1 = ev.target;
- var _hb1 = _tb1.parentNode;
- var _hb2 = _hb1.nextSibling;
- var _tb2 = _hb2.firstChild;
- var _hb3 = _hb2.nextSibling;
- handle_change(_tb1,_tb2,_hb3);
- }
-
- function handle_change_tb2(ev) {
- var _tb2 = ev.target;
- var _hb2 = _tb2.parentNode;
- var _hb1 = _hb2.previousSibling;
- var _tb1 = _hb1.firstChild;
- var _hb3 = _hb2.nextSibling;
- handle_change(_tb1,_tb2,_hb3);
- }
-
- for (var i = 0; i < count; i++) {
- var r = document.createElement('row'); rows.appendChild(r);
- var hb1 = document.createElement('vbox'); r.appendChild(hb1);
- var hb2 = document.createElement('vbox'); r.appendChild(hb2);
- var hb3 = document.createElement('vbox'); r.appendChild(hb3);
- var tb1 = document.createElement('textbox'); hb1.appendChild(tb1);
- tb1.setAttribute('rel_vert_pos','2');
- tb1.setAttribute('ou_id',ou_id);
- util.widgets.apply_vertical_tab_on_enter_handler(
- tb1,
- function() { handle_change_tb1({'target':tb1}); setTimeout(function(){util.widgets.vertical_tab(tb1);},0); }
- );
- var tb2 = document.createElement('textbox'); hb2.appendChild(tb2);
- tb2.setAttribute('size','3'); tb2.setAttribute('cols','3');
- tb2.setAttribute('rel_vert_pos','3');
- tb2.setAttribute('ou_id',ou_id);
- util.widgets.apply_vertical_tab_on_enter_handler(
- tb2,
- function() { handle_change_tb2({'target':tb2}); setTimeout(function(){util.widgets.vertical_tab(tb2);},0); }
- );
-
- tb1.addEventListener( 'change', handle_change_tb1, false);
- tb1.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
- tb2.addEventListener( 'change', handle_change_tb2, false);
- tb2.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
- if ( !g.last_focus ) { tb2.focus(); g.last_focus = tb2; }
-
- setTimeout(
- function(idx,tb){
- return function() {
- try {
- JSAN.use('util.functional');
- if (g.copy_shortcut) {
- var label = util.functional.map_object_to_list(
- g.copy_shortcut[ou_id],
- function(o,i) {
- return i;
- }
- )[idx];
- tb.value = label; handle_change_tb1({'target':tb});
- tb.disabled = true;
- }
- } catch(E) {
- alert(E);
- }
- }
- }(i,tb1),0
- );
- }
-
- return grid;
+ }
+
+ //if (tb1.disabled || tb2.disabled) return;
+
+ //tb1.disabled = true;
+ //tb2.disabled = true;
+
+ util.widgets.remove_children(hb3);
+
+ g.render_barcode_entry(hb3,tb1.value,Number(tb2.value),ou_id);
+ document.getElementById("Create").disabled = false;
+ }
+
+ function handle_change_tb1(ev) {
+ var _tb1 = ev.target;
+ var _hb1 = _tb1.parentNode;
+ var _hb2 = _hb1.nextSibling;
+ var _tb2 = _hb2.firstChild;
+ var _hb3 = _hb2.nextSibling;
+ handle_change(_tb1,_tb2,_hb3);
+ }
+
+ function handle_change_tb2(ev) {
+ var _tb2 = ev.target;
+ var _hb2 = _tb2.parentNode;
+ var _hb1 = _hb2.previousSibling;
+ var _tb1 = _hb1.firstChild;
+ var _hb3 = _hb2.nextSibling;
+ handle_change(_tb1,_tb2,_hb3);
+ }
+
+ for (var i = 0; i < count; i++) {
+ var r = document.createElement('row'); rows.appendChild(r);
+ var hb1 = document.createElement('vbox'); r.appendChild(hb1);
+ var hb2 = document.createElement('vbox'); r.appendChild(hb2);
+ var hb3 = document.createElement('vbox'); r.appendChild(hb3);
+ var tb1 = document.createElement('textbox'); hb1.appendChild(tb1);
+ tb1.setAttribute('rel_vert_pos','2');
+ tb1.setAttribute('ou_id',ou_id);
+ util.widgets.apply_vertical_tab_on_enter_handler(
+ tb1,
+ function() { handle_change_tb1({'target':tb1}); setTimeout(function(){util.widgets.vertical_tab(tb1);},0); }
+ );
+ var tb2 = document.createElement('textbox'); hb2.appendChild(tb2);
+ tb2.setAttribute('size','3'); tb2.setAttribute('cols','3');
+ tb2.setAttribute('rel_vert_pos','3');
+ tb2.setAttribute('ou_id',ou_id);
+ util.widgets.apply_vertical_tab_on_enter_handler(
+ tb2,
+ function() { handle_change_tb2({'target':tb2}); setTimeout(function(){util.widgets.vertical_tab(tb2);},0); }
+ );
+
+ tb1.addEventListener( 'change', handle_change_tb1, false);
+ tb1.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
+ tb2.addEventListener( 'change', handle_change_tb2, false);
+ tb2.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
+ if ( !g.last_focus ) { tb2.focus(); g.last_focus = tb2; }
+
+ setTimeout(
+ function(idx,tb){
+ return function() {
+ try {
+ JSAN.use('util.functional');
+ if (g.copy_shortcut) {
+ var label = util.functional.map_object_to_list(
+ g.copy_shortcut[ou_id],
+ function(o,i) {
+ return i;
+ }
+ )[idx];
+ tb.value = label; handle_change_tb1({'target':tb});
+ tb.disabled = true;
+ }
+ } catch(E) {
+ alert(E);
+ }
+ }
+ }(i,tb1),0
+ );
+ }
+
+ return grid;
}
g.render_barcode_entry = function(node,callnumber,count,ou_id) {
- try {
- function ready_to_create(ev) {
- document.getElementById("Create").disabled = false;
- }
-
- JSAN.use('util.barcode');
-
- for (var i = 0; i < count; i++) {
- var tb = document.createElement('textbox'); node.appendChild(tb);
- tb.setAttribute('ou_id',ou_id);
- tb.setAttribute('callnumber',callnumber);
- tb.setAttribute('rel_vert_pos','4');
- util.widgets.apply_vertical_tab_on_enter_handler(
- tb,
- function() { ready_to_create({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); }
- );
- //tb.addEventListener('change',ready_to_create,false);
- tb.addEventListener('change', function(ev) {
- var barcode = String( ev.target.value ).replace(/\s/g,'');
- if (barcode != ev.target.value) ev.target.value = barcode;
- if ($('check_barcodes').checked && ! util.barcode.check(barcode) ) {
- g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_barcode_entry.alert_message', [barcode]),
- $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_title'),
- $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_ok_button'),null,null,
- $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_confirm'));
- setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0);
- }
- }, false);
- tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
- }
- } catch(E) {
- g.error.sdump('D_ERROR','g.render_barcode_entry: ' + E);
- }
+ try {
+ function ready_to_create(ev) {
+ document.getElementById("Create").disabled = false;
+ }
+
+ JSAN.use('util.barcode');
+
+ for (var i = 0; i < count; i++) {
+ var tb = document.createElement('textbox'); node.appendChild(tb);
+ tb.setAttribute('ou_id',ou_id);
+ tb.setAttribute('callnumber',callnumber);
+ tb.setAttribute('rel_vert_pos','4');
+ util.widgets.apply_vertical_tab_on_enter_handler(
+ tb,
+ function() { ready_to_create({'target':tb}); setTimeout(function(){util.widgets.vertical_tab(tb);},0); }
+ );
+ //tb.addEventListener('change',ready_to_create,false);
+ tb.addEventListener('change', function(ev) {
+ var barcode = String( ev.target.value ).replace(/\s/g,'');
+ if (barcode != ev.target.value) ev.target.value = barcode;
+ if ($('check_barcodes').checked && ! util.barcode.check(barcode) ) {
+ g.error.yns_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.render_barcode_entry.alert_message', [barcode]),
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_title'),
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_ok_button'),null,null,
+ $("catStrings").getString('staff.cat.volume_copy_creator.render_barcode_entry.alert_confirm'));
+ setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0);
+ }
+ }, false);
+ tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );
+ }
+ } catch(E) {
+ g.error.sdump('D_ERROR','g.render_barcode_entry: ' + E);
+ }
}
g.new_node_id = -1;
g.stash_and_close = function() {
- try {
-
- var nl = document.getElementsByTagName('textbox');
-
- var volumes_hash = {};
-
- var barcodes = [];
-
- for (var i = 0; i < nl.length; i++) {
- if ( nl[i].getAttribute('rel_vert_pos') == 4 ) barcodes.push( nl[i] );
- if ( nl[i].getAttribute('rel_vert_pos') == 2 ) {
- var ou_id = nl[i].getAttribute('ou_id');
- var callnumber = nl[i].value;
- if (typeof volumes_hash[ou_id] == 'undefined') { volumes_hash[ou_id] = {} }
- if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { volumes_hash[ou_id][callnumber] = [] }
- }
- };
-
- for (var i = 0; i < barcodes.length; i++) {
- var ou_id = barcodes[i].getAttribute('ou_id');
- var callnumber = barcodes[i].getAttribute('callnumber');
- var barcode = barcodes[i].value;
-
- if (typeof volumes_hash[ou_id] == 'undefined') { volumes_hash[ou_id] = {} }
- if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { volumes_hash[ou_id][callnumber] = [] }
-
- if (barcode != '') volumes_hash[ou_id][callnumber].push( barcode );
- }
-
- var volumes = [];
- var copies = [];
- var volume_labels = {};
-
- for (var ou_id in volumes_hash) {
- for (var cn in volumes_hash[ou_id]) {
-
- var acn_id = g.network.simple_request(
- 'FM_ACN_FIND_OR_CREATE',
- [ ses(), cn, g.doc_id, ou_id ]
- );
-
- if (typeof acn_id.ilsevent != 'undefined') {
- g.error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.stash_and_close.problem_with_volume', [cn]), acn_id);
- continue;
- }
-
- volume_labels[ acn_id ] = { 'label' : cn, 'owning_lib' : ou_id };
-
- for (var i = 0; i < volumes_hash[ou_id][cn].length; i++) {
- var copy = new acp();
- copy.id( g.new_node_id-- );
- copy.isnew('1');
- copy.barcode( volumes_hash[ou_id][cn][i] );
- copy.call_number( acn_id );
- copy.circ_lib(ou_id);
- /* FIXME -- use constants */
- copy.deposit(0);
- copy.price(0);
- copy.deposit_amount(0);
- copy.fine_level(2);
- copy.loan_duration(2);
- copy.location(1);
- copy.status(0);
- copy.circulate(get_db_true());
- copy.holdable(get_db_true());
- copy.opac_visible(get_db_true());
- copy.ref(get_db_false());
- copies.push( copy );
- }
- }
- }
-
- JSAN.use('util.window'); var win = new util.window();
- if (copies.length > 0) {
- JSAN.use('cat.util');
+ try {
+
+ var nl = document.getElementsByTagName('textbox');
+
+ var volumes_hash = {};
+
+ var barcodes = [];
+
+ for (var i = 0; i < nl.length; i++) {
+ if ( nl[i].getAttribute('rel_vert_pos') == 4 ) barcodes.push( nl[i] );
+ if ( nl[i].getAttribute('rel_vert_pos') == 2 ) {
+ var ou_id = nl[i].getAttribute('ou_id');
+ var callnumber = nl[i].value;
+ if (typeof volumes_hash[ou_id] == 'undefined') { volumes_hash[ou_id] = {} }
+ if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { volumes_hash[ou_id][callnumber] = [] }
+ }
+ };
+
+ for (var i = 0; i < barcodes.length; i++) {
+ var ou_id = barcodes[i].getAttribute('ou_id');
+ var callnumber = barcodes[i].getAttribute('callnumber');
+ var barcode = barcodes[i].value;
+
+ if (typeof volumes_hash[ou_id] == 'undefined') { volumes_hash[ou_id] = {} }
+ if (typeof volumes_hash[ou_id][callnumber] == 'undefined') { volumes_hash[ou_id][callnumber] = [] }
+
+ if (barcode != '') volumes_hash[ou_id][callnumber].push( barcode );
+ }
+
+ var volumes = [];
+ var copies = [];
+ var volume_labels = {};
+
+ for (var ou_id in volumes_hash) {
+ for (var cn in volumes_hash[ou_id]) {
+
+ var acn_id = g.network.simple_request(
+ 'FM_ACN_FIND_OR_CREATE',
+ [ ses(), cn, g.doc_id, ou_id ]
+ );
+
+ if (typeof acn_id.ilsevent != 'undefined') {
+ g.error.standard_unexpected_error_alert($("catStrings").getFormattedString('staff.cat.volume_copy_creator.stash_and_close.problem_with_volume', [cn]), acn_id);
+ continue;
+ }
+
+ volume_labels[ acn_id ] = { 'label' : cn, 'owning_lib' : ou_id };
+
+ for (var i = 0; i < volumes_hash[ou_id][cn].length; i++) {
+ var copy = new acp();
+ copy.id( g.new_node_id-- );
+ copy.isnew('1');
+ copy.barcode( volumes_hash[ou_id][cn][i] );
+ copy.call_number( acn_id );
+ copy.circ_lib(ou_id);
+ /* FIXME -- use constants */
+ copy.deposit(0);
+ copy.price(0);
+ copy.deposit_amount(0);
+ copy.fine_level(2);
+ copy.loan_duration(2);
+ copy.location(1);
+ copy.status(0);
+ copy.circulate(get_db_true());
+ copy.holdable(get_db_true());
+ copy.opac_visible(get_db_true());
+ copy.ref(get_db_false());
+ copies.push( copy );
+ }
+ }
+ }
+
+ JSAN.use('util.window'); var win = new util.window();
+ if (copies.length > 0) {
+ JSAN.use('cat.util');
copies = cat.util.spawn_copy_editor( { 'edit' : 1, 'docid' : g.doc_id, 'copies' : copies });
try {
//case 1706 /* ITEM_BARCODE_EXISTS */ :
} catch(E) {
g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.stash_and_close.tree_err2'),E);
}
- }
+ }
- if (typeof window.refresh == 'function') window.refresh();
+ if (typeof window.refresh == 'function') window.refresh();
- window.close();
+ window.close();
- } catch(E) {
- g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.stash_and_close.tree_err3'),E);
- }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.stash_and_close.tree_err3'),E);
+ }
}
g.load_prefs = function() {
- try {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('volume_copy_creator.prefs');
- if (file._file.exists()) {
- var prefs = file.get_object(); file.close();
- if (prefs.check_barcodes) {
- if ( prefs.check_barcodes == 'false' ) {
- $('check_barcodes').checked = false;
- } else {
- $('check_barcodes').checked = prefs.check_barcodes;
- }
- } else {
- $('check_barcodes').checked = false;
- }
- if (prefs.print_labels) {
- if ( prefs.print_labels == 'false' ) {
- $('print_labels').checked = false;
- } else {
- $('print_labels').checked = prefs.print_labels;
- }
- } else {
- $('print_labels').checked = false;
- }
-
- }
- } catch(E) {
- g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.load_prefs.err_retrieving_prefs'),E);
-
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('volume_copy_creator.prefs');
+ if (file._file.exists()) {
+ var prefs = file.get_object(); file.close();
+ if (prefs.check_barcodes) {
+ if ( prefs.check_barcodes == 'false' ) {
+ $('check_barcodes').checked = false;
+ } else {
+ $('check_barcodes').checked = prefs.check_barcodes;
+ }
+ } else {
+ $('check_barcodes').checked = false;
+ }
+ if (prefs.print_labels) {
+ if ( prefs.print_labels == 'false' ) {
+ $('print_labels').checked = false;
+ } else {
+ $('print_labels').checked = prefs.print_labels;
+ }
+ } else {
+ $('print_labels').checked = false;
+ }
+
+ }
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.load_prefs.err_retrieving_prefs'),E);
+
+ }
}
g.save_prefs = function () {
- try {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('volume_copy_creator.prefs');
- file.set_object(
- {
- 'check_barcodes' : $('check_barcodes').checked,
- 'print_labels' : $('print_labels').checked,
- }
- );
- file.close();
- } catch(E) {
- g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.save_prefs.err_storing_prefs'),E);
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('volume_copy_creator.prefs');
+ file.set_object(
+ {
+ 'check_barcodes' : $('check_barcodes').checked,
+ 'print_labels' : $('print_labels').checked,
+ }
+ );
+ file.close();
+ } catch(E) {
+ g.error.standard_unexpected_error_alert($(catStrings).getString('staff.cat.volume_copy_creator.save_prefs.err_storing_prefs'),E);
+ }
}
if (typeof cat == 'undefined') cat = {};
cat.z3950 = function (params) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- } catch(E) {
- dump('cat.z3950: ' + E + '\n');
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ } catch(E) {
+ dump('cat.z3950: ' + E + '\n');
+ }
}
cat.z3950.prototype = {
- 'creds_version' : 2,
+ 'creds_version' : 2,
'number_of_result_sets' : 0,
'limit' : 10,
- 'init' : function( params ) {
+ 'init' : function( params ) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.widgets');
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.widgets');
- var obj = this;
+ var obj = this;
JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
- obj.load_creds();
+ obj.load_creds();
- JSAN.use('circ.util');
- var columns = circ.util.columns(
- {
- 'tcn' : { 'hidden' : false },
- 'isbn' : { 'hidden' : false },
- 'title' : { 'hidden' : false, 'flex' : '1' },
- 'author' : { 'hidden' : false },
- 'edition' : { 'hidden' : false },
- 'pubdate' : { 'hidden' : false },
- 'publisher' : { 'hidden' : false },
- 'service' : { 'hidden' : false }
- }
+ JSAN.use('circ.util');
+ var columns = circ.util.columns(
+ {
+ 'tcn' : { 'hidden' : false },
+ 'isbn' : { 'hidden' : false },
+ 'title' : { 'hidden' : false, 'flex' : '1' },
+ 'author' : { 'hidden' : false },
+ 'edition' : { 'hidden' : false },
+ 'pubdate' : { 'hidden' : false },
+ 'publisher' : { 'hidden' : false },
+ 'service' : { 'hidden' : false }
+ }
);
- JSAN.use('util.list'); obj.list = new util.list('results');
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
- 'on_select' : function(ev) {
- try {
- JSAN.use('util.functional');
- var sel = obj.list.retrieve_selection();
- document.getElementById('sel_clip').setAttribute('disabled', sel.length < 1);
- var list = util.functional.map_list(
- sel,
- function(o) { return o.getAttribute('retrieve_id'); }
- );
- obj.error.sdump('D_TRACE','cat/z3950: selection list = ' + js2JSON(list) );
- obj.controller.view.marc_import.disabled = false;
- obj.controller.view.marc_import.setAttribute('retrieve_id',list[0]);
- obj.data.init({'via':'stash'});
- if (obj.data.marked_record) {
- obj.controller.view.marc_import_overlay.disabled = false;
+ JSAN.use('util.list'); obj.list = new util.list('results');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'on_select' : function(ev) {
+ try {
+ JSAN.use('util.functional');
+ var sel = obj.list.retrieve_selection();
+ document.getElementById('sel_clip').setAttribute('disabled', sel.length < 1);
+ var list = util.functional.map_list(
+ sel,
+ function(o) { return o.getAttribute('retrieve_id'); }
+ );
+ obj.error.sdump('D_TRACE','cat/z3950: selection list = ' + js2JSON(list) );
+ obj.controller.view.marc_import.disabled = false;
+ obj.controller.view.marc_import.setAttribute('retrieve_id',list[0]);
+ obj.data.init({'via':'stash'});
+ if (obj.data.marked_record) {
+ obj.controller.view.marc_import_overlay.disabled = false;
} else {
- obj.controller.view.marc_import_overlay.disabled = true;
+ obj.controller.view.marc_import_overlay.disabled = true;
}
- obj.controller.view.marc_import_overlay.setAttribute('retrieve_id',list[0]);
- obj.controller.view.marc_view_btn.disabled = false;
- obj.controller.view.marc_view_btn.setAttribute('retrieve_id',list[0]);
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_list_init.list_construction_error'),E);
- }
- },
- }
- );
+ obj.controller.view.marc_import_overlay.setAttribute('retrieve_id',list[0]);
+ obj.controller.view.marc_view_btn.disabled = false;
+ obj.controller.view.marc_view_btn.setAttribute('retrieve_id',list[0]);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_list_init.list_construction_error'),E);
+ }
+ },
+ }
+ );
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
- 'sel_clip' : [ ['command'], function() { obj.list.clipboard(); } ],
- 'cmd_z3950_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
+ 'sel_clip' : [ ['command'], function() { obj.list.clipboard(); } ],
+ 'cmd_z3950_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
'cmd_z3950_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
'cmd_z3950_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'z3950_results.txt' } ); } ],
- 'cmd_broken' : [
- ['command'],
- function() { alert('Not Yet Implemented'); }
- ],
- 'result_message' : [['render'],function(e){return function(){};}],
- 'clear' : [
- ['command'],
- function() {
- obj.clear();
- }
- ],
- 'save_creds' : [
- ['command'],
- function() {
- obj.save_creds();
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert('Not Yet Implemented'); }
+ ],
+ 'result_message' : [['render'],function(e){return function(){};}],
+ 'clear' : [
+ ['command'],
+ function() {
+ obj.clear();
+ }
+ ],
+ 'save_creds' : [
+ ['command'],
+ function() {
+ obj.save_creds();
setTimeout( function() { obj.focus(); }, 0 );
- }
- ],
+ }
+ ],
'marc_view_btn' : [
['render'],
function(e) {
e.setAttribute('accesskey', $("catStrings").getString('staff.cat.z3950.marc_view.accesskey'));
}
],
- 'marc_view' : [
- ['command'],
- function(ev) {
- try {
- var n = obj.controller.view.marc_view_btn;
- if (n.getAttribute('toggle') == '1') {
- document.getElementById('deck').selectedIndex = 0;
- n.setAttribute('toggle','0');
- n.setAttribute('label', $("catStrings").getString('staff.cat.z3950.marc_view.label'));
- n.setAttribute('accesskey', $("catStrings").getString('staff.cat.z3950.marc_view.accesskey'));
- document.getElementById('results').focus();
- } else {
- document.getElementById('deck').selectedIndex = 1;
- n.setAttribute('toggle','1');
- n.setAttribute('label', $("catStrings").getString('staff.cat.z3950.results_view.label'));
- n.setAttribute('accesskey', $("catStrings").getString('staff.cat.z3950.results_view.accesskey'));
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- var f = get_contentWindow(document.getElementById('marc_frame'));
+ 'marc_view' : [
+ ['command'],
+ function(ev) {
+ try {
+ var n = obj.controller.view.marc_view_btn;
+ if (n.getAttribute('toggle') == '1') {
+ document.getElementById('deck').selectedIndex = 0;
+ n.setAttribute('toggle','0');
+ n.setAttribute('label', $("catStrings").getString('staff.cat.z3950.marc_view.label'));
+ n.setAttribute('accesskey', $("catStrings").getString('staff.cat.z3950.marc_view.accesskey'));
+ document.getElementById('results').focus();
+ } else {
+ document.getElementById('deck').selectedIndex = 1;
+ n.setAttribute('toggle','1');
+ n.setAttribute('label', $("catStrings").getString('staff.cat.z3950.results_view.label'));
+ n.setAttribute('accesskey', $("catStrings").getString('staff.cat.z3950.results_view.accesskey'));
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ var f = get_contentWindow(document.getElementById('marc_frame'));
var retrieve_id = n.getAttribute('retrieve_id');
var result_idx = retrieve_id.split('-')[0];
var record_idx = retrieve_id.split('-')[1];
- f.xulG = { 'marcxml' : obj.result_set[result_idx].records[ record_idx ].marcxml };
- f.my_init();
- f.document.body.firstChild.focus();
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.marc_view_error'),E);
- }
- },
- ],
- 'marc_import' : [
- ['command'],
- function() {
+ f.xulG = { 'marcxml' : obj.result_set[result_idx].records[ record_idx ].marcxml };
+ f.my_init();
+ f.document.body.firstChild.focus();
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.marc_view_error'),E);
+ }
+ },
+ ],
+ 'marc_import' : [
+ ['command'],
+ function() {
try {
var retrieve_id = obj.controller.view.marc_import.getAttribute('retrieve_id');
var result_idx = retrieve_id.split('-')[0];
obj.result_set[ result_idx ].records[ record_idx ].service /* FIXME: we want biblio_source here */
);
} catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.marc_import_error'),E);
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.marc_import_error'),E);
}
- },
- ],
- 'marc_import_overlay' : [
- ['command'],
- function() {
- try {
+ },
+ ],
+ 'marc_import_overlay' : [
+ ['command'],
+ function() {
+ try {
var retrieve_id = obj.controller.view.marc_import_overlay.getAttribute('retrieve_id');
var result_idx = retrieve_id.split('-')[0];
var record_idx = retrieve_id.split('-')[1];
obj.result_set[ result_idx ].records[ record_idx ].marcxml,
obj.result_set[ result_idx ].records[ record_idx ].service /* FIXME: we want biblio_source here */
);
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.marc_import_overlay_error'),E);
- }
- },
- ],
- 'search' : [
- ['command'],
- function() {
- obj.initial_search();
- },
- ],
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.marc_import_overlay_error'),E);
+ }
+ },
+ ],
+ 'search' : [
+ ['command'],
+ function() {
+ obj.initial_search();
+ },
+ ],
'raw_search' : [
['command'],
function() {
if (raw) obj.initial_raw_search(raw);
}
],
- 'page_next' : [
- ['command'],
- function() {
- obj.page_next();
- },
- ],
+ 'page_next' : [
+ ['command'],
+ function() {
+ obj.page_next();
+ },
+ ],
'toggle_form_btn' : [
['render'],
function(e) {
function() {
var x = document.getElementById('top_pane');
document.getElementById('splitter_grippy2').doCommand();
- var n = obj.controller.view.toggle_form_btn;
+ var n = obj.controller.view.toggle_form_btn;
if (x.collapsed) {
n.setAttribute('image',"/xul/server/skin/media/images/down_arrow.gif");
n.setAttribute('label',$("catStrings").getString('staff.cat.z3950.unhide_top_pane.label'));
}
}
],
- 'service_rows' : [
- ['render'],
- function(e) {
- return function() {
- try {
+ 'service_rows' : [
+ ['render'],
+ function(e) {
+ return function() {
+ try {
- function handle_switch(node) {
+ function handle_switch(node) {
try {
$('search').setAttribute('disabled','true'); $('raw_search').setAttribute('disabled','true');
obj.active_services = [];
}
}
} catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.search_fields_error'),E);
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.search_fields_error'),E);
}
- }
+ }
document.getElementById('native-evergreen-catalog_service').addEventListener('command',handle_switch,false);
- var robj = obj.network.simple_request(
- 'RETRIEVE_Z3950_SERVICES',
- [ ses() ]
- );
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- obj.services = robj;
+ var robj = obj.network.simple_request(
+ 'RETRIEVE_Z3950_SERVICES',
+ [ ses() ]
+ );
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ obj.services = robj;
var x = document.getElementById('service_rows');
var services = new Array();
for (var i in obj.services) {
}
//obj.services[ 'native-evergreen-catalog' ] = { 'attrs' : { 'author' : {}, 'title' : {} } };
setTimeout(
- function() {
+ function() {
if (obj.creds.hosts[ obj.data.server_unadorned ]) {
for (var i = 0; i < obj.creds.hosts[ obj.data.server_unadorned ].default_services.length; i++) {
var x = document.getElementById(obj.creds.hosts[ obj.data.server_unadorned ].default_services[i]+'_service');
if (x) x.checked = true;
}
handle_switch();
- },0
- );
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.z39_service_error'),E);
- }
- }
- }
- ],
- }
- }
- );
+ },0
+ );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.obj_controller_init.z39_service_error'),E);
+ }
+ }
+ }
+ ],
+ }
+ }
+ );
- obj.controller.render();
+ obj.controller.render();
setTimeout( function() { obj.focus(); }, 0 );
function() {
obj.data.init({'via':'stash'});
if (obj.data.marked_record) {
- var sel = obj.list.retrieve_selection();
+ var sel = obj.list.retrieve_selection();
if (sel.length > 0) { obj.controller.view.marc_import_overlay.disabled = false; }
if ($("overlay_tcn_indicator")) {
if (obj.data.marked_record_mvr) {
}, 2000
);
- } catch(E) {
- this.error.sdump('D_ERROR','cat.z3950.init: ' + E + '\n');
- }
- },
+ } catch(E) {
+ this.error.sdump('D_ERROR','cat.z3950.init: ' + E + '\n');
+ }
+ },
- 'focus' : function() {
- var obj = this;
+ 'focus' : function() {
+ var obj = this;
var focus_me; var or_focus_me;
for (var i = 0; i < obj.active_services.length; i++) {
if (obj.creds.hosts[ obj.data.server_unadorned ] && obj.creds.hosts[ obj.data.server_unadorned ].services[ obj.active_services[i] ]) {
- var x = obj.creds.hosts[ obj.data.server_unadorned ].services[ obj.active_services[i] ].default_attr;
+ var x = obj.creds.hosts[ obj.data.server_unadorned ].services[ obj.active_services[i] ].default_attr;
if (x) { focus_me = x; break; }
}
if (obj.services[ obj.active_services[i] ]) for (var i in obj.services[ obj.active_services[i] ].attr) { or_focus_me = i; }
}
if (! focus_me) focus_me = or_focus_me;
- var xx = document.getElementById(focus_me+'_input'); if (xx) xx.focus();
- },
+ var xx = document.getElementById(focus_me+'_input'); if (xx) xx.focus();
+ },
- 'clear' : function() {
- var obj = this;
- var nl = document.getElementsByAttribute('mytype','search_class');
- for (var i = 0; i < nl.length; i++) { nl[i].value = ''; nl[i].setAttribute('value',''); }
- obj.focus();
- },
+ 'clear' : function() {
+ var obj = this;
+ var nl = document.getElementsByAttribute('mytype','search_class');
+ for (var i = 0; i < nl.length; i++) { nl[i].value = ''; nl[i].setAttribute('value',''); }
+ obj.focus();
+ },
- 'search_params' : {},
+ 'search_params' : {},
- 'initial_search' : function() {
- try {
- var obj = this;
+ 'initial_search' : function() {
+ try {
+ var obj = this;
obj.result_set = []; obj.number_of_result_sets = 0;
- JSAN.use('util.widgets');
- util.widgets.remove_children( obj.controller.view.result_message );
- var x = document.createElement('description'); obj.controller.view.result_message.appendChild(x);
+ JSAN.use('util.widgets');
+ util.widgets.remove_children( obj.controller.view.result_message );
+ var x = document.createElement('description'); obj.controller.view.result_message.appendChild(x);
if (obj.active_services.length < 1) {
- x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.no_search_selection')));
+ x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.no_search_selection')));
return;
}
- x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.searching')));
- obj.search_params = {}; obj.list.clear();
- obj.controller.view.page_next.disabled = true;
- obj.controller.view.cmd_z3950_csv_to_file.setAttribute('disabled','true');
- obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','true');
- obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','true');
+ x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.searching')));
+ obj.search_params = {}; obj.list.clear();
+ obj.controller.view.page_next.disabled = true;
+ obj.controller.view.cmd_z3950_csv_to_file.setAttribute('disabled','true');
+ obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','true');
+ obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','true');
- obj.search_params.service_array = [];
- obj.search_params.username_array = [];
- obj.search_params.password_array = [];
+ obj.search_params.service_array = [];
+ obj.search_params.username_array = [];
+ obj.search_params.password_array = [];
for (var i = 0; i < obj.active_services.length; i++) {
obj.search_params.service_array.push( obj.active_services[i] );
obj.search_params.username_array.push( document.getElementById( obj.active_services[i]+'_username' ).value );
obj.search_params.password_array.push( document.getElementById( obj.active_services[i]+'_password' ).value );
}
- obj.search_params.limit = Math.ceil( obj.limit / obj.active_services.length );
- obj.search_params.offset = 0;
+ obj.search_params.limit = Math.ceil( obj.limit / obj.active_services.length );
+ obj.search_params.offset = 0;
- obj.search_params.search = {};
- var nl = document.getElementsByAttribute('mytype','search_class');
- var count = 0;
- for (var i = 0; i < nl.length; i++) {
- if (nl[i].disabled) continue;
- if (nl[i].value == '') continue;
- count++;
- obj.search_params.search[ nl[i].getAttribute('search_class') ] = nl[i].value;
- }
- if (count>0) {
- obj.search();
- } else {
- util.widgets.remove_children( obj.controller.view.result_message );
- }
- } catch(E) {
- this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.initial_search.failed_search'),E);
- }
- },
+ obj.search_params.search = {};
+ var nl = document.getElementsByAttribute('mytype','search_class');
+ var count = 0;
+ for (var i = 0; i < nl.length; i++) {
+ if (nl[i].disabled) continue;
+ if (nl[i].value == '') continue;
+ count++;
+ obj.search_params.search[ nl[i].getAttribute('search_class') ] = nl[i].value;
+ }
+ if (count>0) {
+ obj.search();
+ } else {
+ util.widgets.remove_children( obj.controller.view.result_message );
+ }
+ } catch(E) {
+ this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.initial_search.failed_search'),E);
+ }
+ },
'initial_raw_search' : function(raw) {
try {
util.widgets.remove_children( obj.controller.view.result_message );
var x = document.createElement('description'); obj.controller.view.result_message.appendChild(x);
if (obj.active_services.length < 1) {
- x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.no_search_selection')));
+ x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.no_search_selection')));
return;
}
if (obj.active_services.length > 1) {
- x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.too_many_selections')));
+ x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.too_many_selections')));
return;
}
if (obj.active_services[0] == 'native-evergreen-catalog') {
- x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.raw_search_unsupported_for_native_catalog')));
+ x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.raw_search_unsupported_for_native_catalog')));
return;
}
- x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.searching')));
- obj.search_params = {}; obj.list.clear();
- obj.controller.view.page_next.disabled = true;
- obj.controller.view.cmd_z3950_csv_to_file.setAttribute('disabled','true');
- obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','true');
- obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','true');
+ x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.initial_search.searching')));
+ obj.search_params = {}; obj.list.clear();
+ obj.controller.view.page_next.disabled = true;
+ obj.controller.view.cmd_z3950_csv_to_file.setAttribute('disabled','true');
+ obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','true');
+ obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','true');
- obj.search_params.service_array = [];
- obj.search_params.username_array = [];
- obj.search_params.password_array = [];
+ obj.search_params.service_array = [];
+ obj.search_params.username_array = [];
+ obj.search_params.password_array = [];
for (var i = 0; i < obj.active_services.length; i++) {
obj.search_params.service_array.push( obj.active_services[i] );
obj.search_params.username_array.push( document.getElementById( obj.active_services[i]+'_username' ).value );
obj.search_params.password_array.push( document.getElementById( obj.active_services[i]+'_password' ).value );
}
- obj.search_params.limit = Math.ceil( obj.limit / obj.active_services.length );
- obj.search_params.offset = 0;
+ obj.search_params.limit = Math.ceil( obj.limit / obj.active_services.length );
+ obj.search_params.offset = 0;
obj.search_params.query = raw;
obj.search();
} catch(E) {
- this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.initial_search.failed_search'),E);
+ this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.initial_search.failed_search'),E);
}
},
- 'page_next' : function() {
- try {
- var obj = this;
- JSAN.use('util.widgets');
- util.widgets.remove_children( obj.controller.view.result_message );
- var x = document.createElement('description'); obj.controller.view.result_message.appendChild(x);
- x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.page_next.more_results')));
- obj.search_params.offset += obj.search_params.limit;
- obj.search();
- } catch(E) {
- this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.page_next.subsequent_search_error'),E);
- }
- },
+ 'page_next' : function() {
+ try {
+ var obj = this;
+ JSAN.use('util.widgets');
+ util.widgets.remove_children( obj.controller.view.result_message );
+ var x = document.createElement('description'); obj.controller.view.result_message.appendChild(x);
+ x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.page_next.more_results')));
+ obj.search_params.offset += obj.search_params.limit;
+ obj.search();
+ } catch(E) {
+ this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.page_next.subsequent_search_error'),E);
+ }
+ },
- 'search' : function() {
- try {
- var obj = this;
- var method;
- if (typeof obj.search_params.query == 'undefined') {
- method = 'FM_BLOB_RETRIEVE_VIA_Z3950_SEARCH';
+ 'search' : function() {
+ try {
+ var obj = this;
+ var method;
+ if (typeof obj.search_params.query == 'undefined') {
+ method = 'FM_BLOB_RETRIEVE_VIA_Z3950_SEARCH';
obj.search_params.service = obj.search_params.service_array;
obj.search_params.username = obj.search_params.username_array;
obj.search_params.password = obj.search_params.password_array;
- } else {
- method = 'FM_BLOB_RETRIEVE_VIA_Z3950_RAW_SEARCH';
+ } else {
+ method = 'FM_BLOB_RETRIEVE_VIA_Z3950_RAW_SEARCH';
obj.search_params.service = obj.search_params.service_array[0];
obj.search_params.username = obj.search_params.username_array[0];
obj.search_params.password = obj.search_params.password_array[0];
- }
- obj.network.simple_request(
- method,
- [ ses(), obj.search_params ],
- function(req) {
- obj.handle_results(req.getResultObject())
- }
- );
- document.getElementById('deck').selectedIndex = 0;
- } catch(E) {
- this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.search.search_error'),E);
- }
- },
+ }
+ obj.network.simple_request(
+ method,
+ [ ses(), obj.search_params ],
+ function(req) {
+ obj.handle_results(req.getResultObject())
+ }
+ );
+ document.getElementById('deck').selectedIndex = 0;
+ } catch(E) {
+ this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.search.search_error'),E);
+ }
+ },
- 'handle_results' : function(results) {
- var obj = this;
- try {
- JSAN.use('util.widgets');
- util.widgets.remove_children( obj.controller.view.result_message ); var x;
- if (results == null) {
- x = document.createElement('description'); obj.controller.view.result_message.appendChild(x);
- x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.handle_results.null_server_error')));
- return;
- }
- if (typeof results.ilsevent != 'undefined') {
- x = document.createElement('description'); obj.controller.view.result_message.appendChild(x);
- x.appendChild( document.createTextNode($("catStrings").getFormattedString('staff.cat.z3950.handle_results.server_error', [results.textcode, results.desc])));
- return;
- }
+ 'handle_results' : function(results) {
+ var obj = this;
+ try {
+ JSAN.use('util.widgets');
+ util.widgets.remove_children( obj.controller.view.result_message ); var x;
+ if (results == null) {
+ x = document.createElement('description'); obj.controller.view.result_message.appendChild(x);
+ x.appendChild( document.createTextNode($("catStrings").getString('staff.cat.z3950.handle_results.null_server_error')));
+ return;
+ }
+ if (typeof results.ilsevent != 'undefined') {
+ x = document.createElement('description'); obj.controller.view.result_message.appendChild(x);
+ x.appendChild( document.createTextNode($("catStrings").getFormattedString('staff.cat.z3950.handle_results.server_error', [results.textcode, results.desc])));
+ return;
+ }
obj.controller.view.cmd_z3950_csv_to_file.setAttribute('disabled','false');
obj.controller.view.cmd_z3950_csv_to_clipboard.setAttribute('disabled','false');
obj.controller.view.cmd_z3950_csv_to_printer.setAttribute('disabled','false');
);
}
- } catch(E) {
- this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.handle_results.search_result_error'),E);
- }
- },
+ } catch(E) {
+ this.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.handle_results.search_result_error'),E);
+ }
+ },
- 'replace_tab_with_opac' : function(doc_id) {
- var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id;
- var content_params = {
- 'session' : ses(),
- 'authtime' : ses('authtime'),
- 'opac_url' : opac_url,
- };
- xulG.set_tab(
- xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
- {'tab_name': $("catStrings").getString('staff.cat.z3950.replace_tab_with_opac.tab_name')},
- content_params
- );
- },
+ 'replace_tab_with_opac' : function(doc_id) {
+ var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id;
+ var content_params = {
+ 'session' : ses(),
+ 'authtime' : ses('authtime'),
+ 'opac_url' : opac_url,
+ };
+ xulG.set_tab(
+ xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name': $("catStrings").getString('staff.cat.z3950.replace_tab_with_opac.tab_name')},
+ content_params
+ );
+ },
- 'spawn_marc_editor' : function(my_marcxml,biblio_source) {
- var obj = this;
- xulG.new_tab(
- xulG.url_prefix(urls.XUL_MARC_EDIT),
- { 'tab_name' : 'MARC Editor' },
- {
- 'record' : { 'marc' : my_marcxml },
+ 'spawn_marc_editor' : function(my_marcxml,biblio_source) {
+ var obj = this;
+ xulG.new_tab(
+ xulG.url_prefix(urls.XUL_MARC_EDIT),
+ { 'tab_name' : 'MARC Editor' },
+ {
+ 'record' : { 'marc' : my_marcxml },
'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
try {
JSAN.use('cat.util'); return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
alert(E);
}
},
- 'save' : {
- 'label' : 'Import Record',
- 'func' : function (new_marcxml) {
- try {
- var r = obj.network.simple_request('MARC_XML_RECORD_IMPORT', [ ses(), new_marcxml, biblio_source ]);
- if (typeof r.ilsevent != 'undefined') {
- switch(Number(r.ilsevent)) {
- case 1704 /* TCN_EXISTS */ :
- var msg = $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.same_tcn', [r.payload.tcn]);
- var title = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.title');
- var btn1 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn1_overlay');
- var btn2 = typeof r.payload.new_tcn == 'undefined' ? null : $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.btn2_import', [r.payload.new_tcn]);
- if (btn2) {
- obj.data.init({'via':'stash'});
- var robj = obj.network.simple_request(
- 'PERM_CHECK',[
- ses(),
- obj.data.list.au[0].id(),
- obj.data.list.au[0].ws_ou(),
- [ 'ALLOW_ALT_TCN' ]
- ]
- );
- if (typeof robj.ilsevent != 'undefined') {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.permission_error'),E);
- }
- if (robj.length != 0) btn2 = null;
- }
- var btn3 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn3_cancel_import');
- var p = obj.error.yns_alert(msg,title,btn1,btn2,btn3,$("catStrings").getString('staff.cat.z3950.spawn_marc_editor.confirm_action'));
- obj.error.sdump('D_ERROR','option ' + p + 'chosen');
- switch(p) {
- case 0:
- var r3 = obj.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), r.payload.dup_record, new_marcxml, biblio_source ]);
- if (typeof r3.ilsevent != 'undefined') {
- throw(r3);
- } else {
- alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_overlay'));
+ 'save' : {
+ 'label' : 'Import Record',
+ 'func' : function (new_marcxml) {
+ try {
+ var r = obj.network.simple_request('MARC_XML_RECORD_IMPORT', [ ses(), new_marcxml, biblio_source ]);
+ if (typeof r.ilsevent != 'undefined') {
+ switch(Number(r.ilsevent)) {
+ case 1704 /* TCN_EXISTS */ :
+ var msg = $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.same_tcn', [r.payload.tcn]);
+ var title = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.title');
+ var btn1 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn1_overlay');
+ var btn2 = typeof r.payload.new_tcn == 'undefined' ? null : $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor.btn2_import', [r.payload.new_tcn]);
+ if (btn2) {
+ obj.data.init({'via':'stash'});
+ var robj = obj.network.simple_request(
+ 'PERM_CHECK',[
+ ses(),
+ obj.data.list.au[0].id(),
+ obj.data.list.au[0].ws_ou(),
+ [ 'ALLOW_ALT_TCN' ]
+ ]
+ );
+ if (typeof robj.ilsevent != 'undefined') {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.permission_error'),E);
+ }
+ if (robj.length != 0) btn2 = null;
+ }
+ var btn3 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor.btn3_cancel_import');
+ var p = obj.error.yns_alert(msg,title,btn1,btn2,btn3,$("catStrings").getString('staff.cat.z3950.spawn_marc_editor.confirm_action'));
+ obj.error.sdump('D_ERROR','option ' + p + 'chosen');
+ switch(p) {
+ case 0:
+ var r3 = obj.network.simple_request('MARC_XML_RECORD_UPDATE', [ ses(), r.payload.dup_record, new_marcxml, biblio_source ]);
+ if (typeof r3.ilsevent != 'undefined') {
+ throw(r3);
+ } else {
+ alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_overlay'));
return {
'id' : r3.id(),
'on_complete' : function() {
}
}
};
- }
- break;
- case 1:
- var r2 = obj.network.request(
- api.MARC_XML_RECORD_IMPORT.app,
- api.MARC_XML_RECORD_IMPORT.method + '.override',
- [ ses(), new_marcxml, biblio_source ]
- );
- if (typeof r2.ilsevent != 'undefined') {
- throw(r2);
- } else {
- alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import_with_new_tcn'));
+ }
+ break;
+ case 1:
+ var r2 = obj.network.request(
+ api.MARC_XML_RECORD_IMPORT.app,
+ api.MARC_XML_RECORD_IMPORT.method + '.override',
+ [ ses(), new_marcxml, biblio_source ]
+ );
+ if (typeof r2.ilsevent != 'undefined') {
+ throw(r2);
+ } else {
+ alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import_with_new_tcn'));
return {
'id' : r2.id(),
'on_complete' : function() {
}
}
};
- }
- break;
- case 2:
- default:
- alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_cancelled'));
- break;
- }
- break;
- default:
- throw(r);
- break;
- }
- } else {
- alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import'));
- return {
+ }
+ break;
+ case 2:
+ default:
+ alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_cancelled'));
+ break;
+ }
+ break;
+ default:
+ throw(r);
+ break;
+ }
+ } else {
+ alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.successful_import'));
+ return {
'id' : r.id(),
'on_complete' : function() {
try {
}
}
};
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_error'),E);
- }
- }
- }
- }
- );
- },
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor.import_error'),E);
+ }
+ }
+ }
+ }
+ );
+ },
- 'confirm_overlay' : function(record_ids) {
- var obj = this; // JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- var top_xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" >';
- top_xml += '<description>'+$("catStrings").getString('staff.cat.z3950.confirm_overlay.description')+'</description>';
- top_xml += '<hbox><button id="lead" disabled="false" label="'+$("catStrings").getString('staff.cat.z3950.confirm_overlay.lead.label')+'" name="fancy_submit"';
- top_xml += ' accesskey="'+$("catStrings").getString('staff.cat.z3950.confirm_overlay.lead.accesskey')+'"/>';
- top_xml += ' <button label="'+$("catStrings").getString('staff.cat.z3950.confirm_overlay.cancel.label')+'" accesskey="'+
- $("catStrings").getString('staff.cat.z3950.confirm_overlay.cancel.accesskey')+'" name="fancy_cancel"/></hbox></vbox>';
+ 'confirm_overlay' : function(record_ids) {
+ var obj = this; // JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ var top_xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" >';
+ top_xml += '<description>'+$("catStrings").getString('staff.cat.z3950.confirm_overlay.description')+'</description>';
+ top_xml += '<hbox><button id="lead" disabled="false" label="'+$("catStrings").getString('staff.cat.z3950.confirm_overlay.lead.label')+'" name="fancy_submit"';
+ top_xml += ' accesskey="'+$("catStrings").getString('staff.cat.z3950.confirm_overlay.lead.accesskey')+'"/>';
+ top_xml += ' <button label="'+$("catStrings").getString('staff.cat.z3950.confirm_overlay.cancel.label')+'" accesskey="'+
+ $("catStrings").getString('staff.cat.z3950.confirm_overlay.cancel.accesskey')+'" name="fancy_cancel"/></hbox></vbox>';
- var xml = '<form xmlns="http://www.w3.org/1999/xhtml">';
- xml += '<table width="100%"><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
- xml += '<td nowrap="nowrap"><iframe src="' + urls.XUL_BIB_BRIEF;
- xml += '?docid=' + record_ids[i] + '"/></td>';
- }
- xml += '</tr><tr valign="top">';
- for (var i = 0; i < record_ids.length; i++) {
+ var xml = '<form xmlns="http://www.w3.org/1999/xhtml">';
+ xml += '<table width="100%"><tr valign="top">';
+ for (var i = 0; i < record_ids.length; i++) {
+ xml += '<td nowrap="nowrap"><iframe src="' + urls.XUL_BIB_BRIEF;
+ xml += '?docid=' + record_ids[i] + '"/></td>';
+ }
+ xml += '</tr><tr valign="top">';
+ for (var i = 0; i < record_ids.length; i++) {
xml += '<td nowrap="nowrap"><iframe style="min-height: 1000px; min-width: 300px;" flex="1" src="' + urls.XUL_MARC_VIEW + '?docid=' + record_ids[i] + ' "/></td>';
- }
- xml += '</tr></table></form>';
- // data.temp_merge_top = top_xml; data.stash('temp_merge_top');
- // data.temp_merge_mid = xml; data.stash('temp_merge_mid');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- // + '?xml_in_stash=temp_merge_mid'
- // + '&top_xml_in_stash=temp_merge_top'
- // + '&title=' + window.escape('Record Overlay'),
- 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
- { 'top_xml' : top_xml, 'xml' : xml, 'title' : $("catStrings").getString('staff.cat.z3950.confirm_overlay.title') }
- );
- //data.stash_retrieve();
- if (fancy_prompt_data.fancy_status == 'incomplete') { alert($("catStrings").getString('staff.cat.z3950.confirm_overlay.aborted')); return false; }
- return true;
- },
+ }
+ xml += '</tr></table></form>';
+ // data.temp_merge_top = top_xml; data.stash('temp_merge_top');
+ // data.temp_merge_mid = xml; data.stash('temp_merge_mid');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ // + '?xml_in_stash=temp_merge_mid'
+ // + '&top_xml_in_stash=temp_merge_top'
+ // + '&title=' + window.escape('Record Overlay'),
+ 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
+ { 'top_xml' : top_xml, 'xml' : xml, 'title' : $("catStrings").getString('staff.cat.z3950.confirm_overlay.title') }
+ );
+ //data.stash_retrieve();
+ if (fancy_prompt_data.fancy_status == 'incomplete') { alert($("catStrings").getString('staff.cat.z3950.confirm_overlay.aborted')); return false; }
+ return true;
+ },
- 'spawn_marc_editor_for_overlay' : function(my_marcxml,biblio_source) {
- var obj = this;
- obj.data.init({'via':'stash'});
- if (!obj.data.marked_record) {
- alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.try_again'));
- return;
- }
+ 'spawn_marc_editor_for_overlay' : function(my_marcxml,biblio_source) {
+ var obj = this;
+ obj.data.init({'via':'stash'});
+ if (!obj.data.marked_record) {
+ alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.try_again'));
+ return;
+ }
- xulG.new_tab(
- xulG.url_prefix(urls.XUL_MARC_EDIT),
- { 'tab_name' : $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.tab_name') },
- {
- 'record' : { 'marc' : my_marcxml },
+ xulG.new_tab(
+ xulG.url_prefix(urls.XUL_MARC_EDIT),
+ { 'tab_name' : $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.tab_name') },
+ {
+ 'record' : { 'marc' : my_marcxml },
'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
try {
JSAN.use('cat.util'); cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
alert(E);
}
},
- 'save' : {
- 'label' : $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.overlay_record_label'),
- 'func' : function (new_marcxml) {
- try {
- if (! obj.confirm_overlay( [ obj.data.marked_record ] ) ) { return; }
- var r = obj.network.simple_request('MARC_XML_RECORD_REPLACE', [ ses(), obj.data.marked_record, new_marcxml, biblio_source ]);
- if (typeof r.ilsevent != 'undefined') {
- switch(Number(r.ilsevent)) {
- case 1704 /* TCN_EXISTS */ :
- var msg = $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor_for_overlay.same_tcn', [r.payload.tcn]);
- var title = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.import_collision');
- var btn1 = typeof r.payload.new_tcn == 'undefined' ? null : $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor_for_overlay.btn1_overlay', [r.payload.new_tcn]);
- if (btn1) {
- var robj = obj.network.simple_request(
- 'PERM_CHECK',[
- ses(),
- obj.data.list.au[0].id(),
- obj.data.list.au[0].ws_ou(),
- [ 'ALLOW_ALT_TCN' ]
- ]
- );
- if (typeof robj.ilsevent != 'undefined') {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.permission_error'),E);
- }
- if (robj.length != 0) btn1 = null;
- }
- var btn2 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.btn2_cancel');
- var p = obj.error.yns_alert(msg,title,btn1,btn2,null, $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.confirm_action'));
- obj.error.sdump('D_ERROR','option ' + p + 'chosen');
- switch(p) {
- case 0:
- var r2 = obj.network.request(
- api.MARC_XML_RECORD_REPLACE.app,
- api.MARC_XML_RECORD_REPLACE.method + '.override',
- [ ses(), obj.data.marked_record, new_marcxml, biblio_source ]
- );
- if (typeof r2.ilsevent != 'undefined') {
- throw(r2);
- } else {
- alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.successful_overlay_with_new_TCN'));
- return {
+ 'save' : {
+ 'label' : $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.overlay_record_label'),
+ 'func' : function (new_marcxml) {
+ try {
+ if (! obj.confirm_overlay( [ obj.data.marked_record ] ) ) { return; }
+ var r = obj.network.simple_request('MARC_XML_RECORD_REPLACE', [ ses(), obj.data.marked_record, new_marcxml, biblio_source ]);
+ if (typeof r.ilsevent != 'undefined') {
+ switch(Number(r.ilsevent)) {
+ case 1704 /* TCN_EXISTS */ :
+ var msg = $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor_for_overlay.same_tcn', [r.payload.tcn]);
+ var title = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.import_collision');
+ var btn1 = typeof r.payload.new_tcn == 'undefined' ? null : $("catStrings").getFormattedString('staff.cat.z3950.spawn_marc_editor_for_overlay.btn1_overlay', [r.payload.new_tcn]);
+ if (btn1) {
+ var robj = obj.network.simple_request(
+ 'PERM_CHECK',[
+ ses(),
+ obj.data.list.au[0].id(),
+ obj.data.list.au[0].ws_ou(),
+ [ 'ALLOW_ALT_TCN' ]
+ ]
+ );
+ if (typeof robj.ilsevent != 'undefined') {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.permission_error'),E);
+ }
+ if (robj.length != 0) btn1 = null;
+ }
+ var btn2 = $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.btn2_cancel');
+ var p = obj.error.yns_alert(msg,title,btn1,btn2,null, $("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.confirm_action'));
+ obj.error.sdump('D_ERROR','option ' + p + 'chosen');
+ switch(p) {
+ case 0:
+ var r2 = obj.network.request(
+ api.MARC_XML_RECORD_REPLACE.app,
+ api.MARC_XML_RECORD_REPLACE.method + '.override',
+ [ ses(), obj.data.marked_record, new_marcxml, biblio_source ]
+ );
+ if (typeof r2.ilsevent != 'undefined') {
+ throw(r2);
+ } else {
+ alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.successful_overlay_with_new_TCN'));
+ return {
'id' : r2.id(),
'on_complete' : function() {
try {
}
}
};
- }
- break;
- case 1:
- default:
- alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.cancelled_overlay'));
- break;
- }
- break;
- default:
- throw(r);
- break;
- }
- } else {
- alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.success_overlay'));
+ }
+ break;
+ case 1:
+ default:
+ alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.cancelled_overlay'));
+ break;
+ }
+ break;
+ default:
+ throw(r);
+ break;
+ }
+ } else {
+ alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.success_overlay'));
return {
'id' : r.id(),
'on_complete' : function() {
}
}
};
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.overlay_error'),E);
- }
- }
- }
- }
- );
- },
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.spawn_marc_editor_for_overlay.overlay_error'),E);
+ }
+ }
+ }
+ }
+ );
+ },
- 'load_creds' : function() {
- var obj = this;
- try {
- obj.creds = { 'version' : g.save_version, 'services' : {}, 'hosts' : {} };
- /*
- {
- 'version' : xx,
- 'default_service' : xx,
- 'services' : {
+ 'load_creds' : function() {
+ var obj = this;
+ try {
+ obj.creds = { 'version' : g.save_version, 'services' : {}, 'hosts' : {} };
+ /*
+ {
+ 'version' : xx,
+ 'default_service' : xx,
+ 'services' : {
- 'xx' : {
- 'username' : xx,
- 'password' : xx,
- 'default_attr' : xx,
- },
+ 'xx' : {
+ 'username' : xx,
+ 'password' : xx,
+ 'default_attr' : xx,
+ },
- 'xx' : {
- 'username' : xx,
- 'password' : xx,
- 'default_attr' : xx,
- },
- },
+ 'xx' : {
+ 'username' : xx,
+ 'password' : xx,
+ 'default_attr' : xx,
+ },
+ },
// new in version 2
'hosts' : {
'xxxx' : {
},
}
}
- }
- */
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('z3950_store');
- if (file._file.exists()) {
- var creds = file.get_object(); file.close();
- if (typeof creds.version != 'undefined') {
- if (creds.version >= obj.creds_version) { /* so apparently, this guy is assuming that future versions will be backwards compatible */
+ }
+ */
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('z3950_store');
+ if (file._file.exists()) {
+ var creds = file.get_object(); file.close();
+ if (typeof creds.version != 'undefined') {
+ if (creds.version >= obj.creds_version) { /* so apparently, this guy is assuming that future versions will be backwards compatible */
if (typeof creds.hosts == 'undefined') creds.hosts = {};
- obj.creds = creds;
- }
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.load_creds.z3950_cred_error'),E);
- }
- },
+ obj.creds = creds;
+ }
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.load_creds.z3950_cred_error'),E);
+ }
+ },
- 'save_creds' : function () {
- try {
- var obj = this;
+ 'save_creds' : function () {
+ try {
+ var obj = this;
if (typeof obj.creds.hosts == 'undefined') obj.creds.hosts = {};
if (typeof obj.creds.hosts[ obj.data.server_unadorned ] == 'undefined') obj.creds.hosts[ obj.data.server_unadorned ] = { 'services' : {} };
obj.creds.hosts[ obj.data.server_unadorned ].default_services = obj.active_services;
for (var i = 0; i < obj.creds.hosts[ obj.data.server_unadorned ].default_services.length; i++) {
- var service = obj.creds.hosts[ obj.data.server_unadorned ].default_services[i];
- if (typeof obj.creds.hosts[ obj.data.server_unadorned ].services[ service ] == 'undefined') {
+ var service = obj.creds.hosts[ obj.data.server_unadorned ].default_services[i];
+ if (typeof obj.creds.hosts[ obj.data.server_unadorned ].services[ service ] == 'undefined') {
obj.creds.hosts[ obj.data.server_unadorned ].services[ service ] = {}
- }
- obj.creds.hosts[ obj.data.server_unadorned ].services[service].username = document.getElementById(service + '_username').value;
- obj.creds.hosts[ obj.data.server_unadorned ].services[service].password = document.getElementById(service + '_password').value;
- if (obj.default_attr) {
- obj.creds.hosts[ obj.data.server_unadorned ].services[service].default_attr = obj.default_attr;
- }
+ }
+ obj.creds.hosts[ obj.data.server_unadorned ].services[service].username = document.getElementById(service + '_username').value;
+ obj.creds.hosts[ obj.data.server_unadorned ].services[service].password = document.getElementById(service + '_password').value;
+ if (obj.default_attr) {
+ obj.creds.hosts[ obj.data.server_unadorned ].services[service].default_attr = obj.default_attr;
+ }
}
- obj.creds.version = obj.creds_version;
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('z3950_store');
- file.set_object(obj.creds);
- file.close();
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.save_creds.z3950_cred_error'),E);
- }
- },
+ obj.creds.version = obj.creds_version;
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('z3950_store');
+ file.set_object(obj.creds);
+ file.close();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("catStrings").getString('staff.cat.z3950.save_creds.z3950_cred_error'),E);
+ }
+ },
- 'handle_enter' : function(ev) {
- var obj = this;
- if (ev.target.tagName != 'textbox') return;
- if (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* enter on a mac */) setTimeout( function() { obj.initial_search(); }, 0);
- },
+ 'handle_enter' : function(ev) {
+ var obj = this;
+ if (ev.target.tagName != 'textbox') return;
+ if (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* enter on a mac */) setTimeout( function() { obj.initial_search(); }, 0);
+ },
}
dump('exiting cat.z3950.js\n');
JSAN.errorLevel = "die"; // none, warn, or die
JSAN.addRepository('..');
- JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+ JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
JSAN.use('util.error'); error = new util.error();
if (typeof circ == 'undefined') circ = {};
circ.checkin = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- JSAN.use('util.barcode');
- JSAN.use('util.date');
- this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
- this.data = this.OpenILS.data;
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('util.barcode');
+ JSAN.use('util.date');
+ this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
+ this.data = this.OpenILS.data;
}
circ.checkin.prototype = {
- 'selection_list' : [],
-
- 'init' : function( params ) {
-
- var obj = this;
-
- JSAN.use('circ.util'); JSAN.use('patron.util');
- var columns = circ.util.columns(
- {
- 'barcode' : { 'hidden' : false },
- 'title' : { 'hidden' : false },
- 'location' : { 'hidden' : false },
- 'call_number' : { 'hidden' : false },
- 'status' : { 'hidden' : false },
- 'route_to' : { 'hidden' : false },
- 'alert_message' : { 'hidden' : false },
- 'checkin_time' : { 'hidden' : false }
- },
- {
- 'except_these' : [ 'uses', 'checkin_time_full' ]
- }
- ).concat(
+ 'selection_list' : [],
+
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ JSAN.use('circ.util'); JSAN.use('patron.util');
+ var columns = circ.util.columns(
+ {
+ 'barcode' : { 'hidden' : false },
+ 'title' : { 'hidden' : false },
+ 'location' : { 'hidden' : false },
+ 'call_number' : { 'hidden' : false },
+ 'status' : { 'hidden' : false },
+ 'route_to' : { 'hidden' : false },
+ 'alert_message' : { 'hidden' : false },
+ 'checkin_time' : { 'hidden' : false }
+ },
+ {
+ 'except_these' : [ 'uses', 'checkin_time_full' ]
+ }
+ ).concat(
patron.util.columns( { 'family_name' : { 'hidden' : 'false' } } )
).concat(
).sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
- JSAN.use('util.list'); obj.list = new util.list('checkin_list');
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ JSAN.use('util.list'); obj.list = new util.list('checkin_list');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
'retrieve_row' : obj.gen_list_retrieve_row_func(),
- '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_edit.setAttribute('disabled','true');
- obj.controller.view.sel_backdate.setAttribute('disabled','true');
- obj.controller.view.sel_opac.setAttribute('disabled','true');
- obj.controller.view.sel_patron.setAttribute('disabled','true');
- obj.controller.view.sel_last_patron.setAttribute('disabled','true');
- obj.controller.view.sel_copy_details.setAttribute('disabled','true');
- obj.controller.view.sel_bucket.setAttribute('disabled','true');
- obj.controller.view.sel_spine.setAttribute('disabled','true');
- obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
- obj.controller.view.sel_clip.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
- } else {
- obj.controller.view.sel_edit.setAttribute('disabled','false');
- obj.controller.view.sel_backdate.setAttribute('disabled','false');
- obj.controller.view.sel_opac.setAttribute('disabled','false');
- obj.controller.view.sel_patron.setAttribute('disabled','false');
- obj.controller.view.sel_last_patron.setAttribute('disabled','false');
- obj.controller.view.sel_copy_details.setAttribute('disabled','false');
- obj.controller.view.sel_bucket.setAttribute('disabled','false');
- obj.controller.view.sel_spine.setAttribute('disabled','false');
- obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
- obj.controller.view.sel_clip.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
- }
- } catch(E) {
- alert('FIXME: ' + E);
- }
- }
- }
- );
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
- 'sel_clip' : [
- ['command'],
- function() {
+ '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_edit.setAttribute('disabled','true');
+ obj.controller.view.sel_backdate.setAttribute('disabled','true');
+ obj.controller.view.sel_opac.setAttribute('disabled','true');
+ obj.controller.view.sel_patron.setAttribute('disabled','true');
+ obj.controller.view.sel_last_patron.setAttribute('disabled','true');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','true');
+ obj.controller.view.sel_bucket.setAttribute('disabled','true');
+ obj.controller.view.sel_spine.setAttribute('disabled','true');
+ obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
+ obj.controller.view.sel_clip.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
+ } else {
+ obj.controller.view.sel_edit.setAttribute('disabled','false');
+ obj.controller.view.sel_backdate.setAttribute('disabled','false');
+ obj.controller.view.sel_opac.setAttribute('disabled','false');
+ obj.controller.view.sel_patron.setAttribute('disabled','false');
+ obj.controller.view.sel_last_patron.setAttribute('disabled','false');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','false');
+ obj.controller.view.sel_bucket.setAttribute('disabled','false');
+ obj.controller.view.sel_spine.setAttribute('disabled','false');
+ obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
+ obj.controller.view.sel_clip.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ }
+ }
+ );
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
+ 'sel_clip' : [
+ ['command'],
+ function() {
obj.list.clipboard();
obj.controller.view.checkin_barcode_entry_textbox.focus();
}
- ],
- 'sel_edit' : [
- ['command'],
- function() {
- try {
- obj.spawn_copy_editor();
- } catch(E) {
- alert(E);
- }
- }
- ],
- 'sel_spine' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.spawn_spine_editor(obj.selection_list);
- }
- ],
- 'sel_opac' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.show_in_opac(obj.selection_list);
- }
- ],
- 'sel_transit_abort' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- circ.util.abort_transits(obj.selection_list);
- }
- ],
- 'sel_patron' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- circ.util.show_last_few_circs(obj.selection_list);
- }
- ],
- 'sel_last_patron' : [
- ['command'],
- function() {
- var patrons = {};
- for (var i = 0; i < obj.selection_list.length; i++) {
- var circs = obj.network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),obj.selection_list[i].copy_id,1]);
- if (circs.length > 0) {
- patrons[circs[0].usr()] = 1;
- } else {
- alert(document.getElementById('circStrings').getFormattedString('staff.circ.item_no_circs', [obj.selection_list[i].barcode]));
- }
- }
- for (var i in patrons) {
- xulG.new_patron_tab({},{'id' : i});
- }
- }
- ],
- 'sel_copy_details' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- for (var i = 0; i < obj.selection_list.length; i++) {
- circ.util.show_copy_details( obj.selection_list[i].copy_id );
- }
- }
- ],
- 'sel_backdate' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
+ ],
+ 'sel_edit' : [
+ ['command'],
+ function() {
+ try {
+ obj.spawn_copy_editor();
+ } catch(E) {
+ alert(E);
+ }
+ }
+ ],
+ 'sel_spine' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.spawn_spine_editor(obj.selection_list);
+ }
+ ],
+ 'sel_opac' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.show_in_opac(obj.selection_list);
+ }
+ ],
+ 'sel_transit_abort' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ circ.util.abort_transits(obj.selection_list);
+ }
+ ],
+ 'sel_patron' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ circ.util.show_last_few_circs(obj.selection_list);
+ }
+ ],
+ 'sel_last_patron' : [
+ ['command'],
+ function() {
+ var patrons = {};
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ var circs = obj.network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),obj.selection_list[i].copy_id,1]);
+ if (circs.length > 0) {
+ patrons[circs[0].usr()] = 1;
+ } else {
+ alert(document.getElementById('circStrings').getFormattedString('staff.circ.item_no_circs', [obj.selection_list[i].barcode]));
+ }
+ }
+ for (var i in patrons) {
+ xulG.new_patron_tab({},{'id' : i});
+ }
+ }
+ ],
+ 'sel_copy_details' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ circ.util.show_copy_details( obj.selection_list[i].copy_id );
+ }
+ }
+ ],
+ 'sel_backdate' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
var circ_ids = [];
- for (var i = 0; i < obj.selection_list.length; i++) {
+ for (var i = 0; i < obj.selection_list.length; i++) {
var circ_id = obj.selection_list[i].circ_id;
var copy_id = obj.selection_list[i].copy_id;
if (!circ_id) {
}
if (!circ_id) continue;
circ_ids.push( circ_id );
- }
+ }
circ.util.backdate_post_checkin( circ_ids );
- }
- ],
- 'sel_mark_items_damaged' : [
- ['command'],
- function() {
- var funcs = [];
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_damaged( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_bucket' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.add_copies_to_bucket(obj.selection_list);
- }
- ],
- 'checkin_barcode_entry_textbox' : [
- ['keypress'],
- function(ev) {
- if (ev.keyCode && ev.keyCode == 13) {
- obj.checkin();
- }
- }
- ],
- 'checkin_effective_date_label' : [
- ['render'],
- function(e) {
- return function() {
- obj.controller.view.checkin_effective_datepicker.value =
- util.date.formatted_date(new Date(),'%F');
- };
- }
- ],
- 'checkin_effective_datepicker' : [
- ['change'],
- function(ev) {
- if (ev.target.nodeName == 'datepicker') {
- try {
- if ( ev.target.dateValue > new Date() ) throw(document.getElementById('circStrings').getString('staff.circ.future_date'));
- var x = document.getElementById('background');
- if (x) {
- if ( ev.target.value == util.date.formatted_date(new Date(),'%F') ) {
+ }
+ ],
+ 'sel_mark_items_damaged' : [
+ ['command'],
+ function() {
+ var funcs = [];
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_damaged( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_bucket' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.add_copies_to_bucket(obj.selection_list);
+ }
+ ],
+ 'checkin_barcode_entry_textbox' : [
+ ['keypress'],
+ function(ev) {
+ if (ev.keyCode && ev.keyCode == 13) {
+ obj.checkin();
+ }
+ }
+ ],
+ 'checkin_effective_date_label' : [
+ ['render'],
+ function(e) {
+ return function() {
+ obj.controller.view.checkin_effective_datepicker.value =
+ util.date.formatted_date(new Date(),'%F');
+ };
+ }
+ ],
+ 'checkin_effective_datepicker' : [
+ ['change'],
+ function(ev) {
+ if (ev.target.nodeName == 'datepicker') {
+ try {
+ if ( ev.target.dateValue > new Date() ) throw(document.getElementById('circStrings').getString('staff.circ.future_date'));
+ var x = document.getElementById('background');
+ if (x) {
+ if ( ev.target.value == util.date.formatted_date(new Date(),'%F') ) {
//addCSSClass(x,'checkin_screen_normal');
removeCSSClass(x,'checkin_screen_backdating');
removeCSSClass(document.getElementById('background'),'checkin_screen_do_not_alert_on_precat');
removeCSSClass(document.getElementById('background'),'checkin_screen_suppress_holds_and_transits');
removeCSSClass(document.getElementById('background'),'checkin_screen_amnesty_mode');
removeCSSClass(document.getElementById('background'),'checkin_screen_checkin_auto_print_slips');
- document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getString('staff.circ.process_item'));
- } else {
+ document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getString('staff.circ.process_item'));
+ } else {
addCSSClass(x,'checkin_screen_backdating');
//removeCSSClass(x,'checkin_screen_normal');
- document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getFormattedString('staff.circ.backdated_checkin', [ev.target.value]));
- }
- }
- } catch(E) {
- var x = document.getElementById('background');
- if (x) {
+ document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getFormattedString('staff.circ.backdated_checkin', [ev.target.value]));
+ }
+ }
+ } catch(E) {
+ var x = document.getElementById('background');
+ if (x) {
//addCSSClass(x,'checkin_screen_normal');
removeCSSClass(x,'checkin_screen_backdating');
removeCSSClass(document.getElementById('background'),'checkin_screen_do_not_alert_on_precat');
removeCSSClass(document.getElementById('background'),'checkin_screen_checkin_auto_print_slips');
document.getElementById('background-text').setAttribute('value',document.getElementById('circStrings').getString('staff.circ.process_item'));
}
- dump('checkin:effective_date: ' + E + '\n');
+ dump('checkin:effective_date: ' + E + '\n');
ev.target.disabled = true;
- //alert(document.getElementById('circStrings').getFormattedString('staff.circ.backdate.exception', [E]));
+ //alert(document.getElementById('circStrings').getFormattedString('staff.circ.backdate.exception', [E]));
ev.target.value = util.date.formatted_date(new Date(),'%F');
ev.target.disabled = false;
- JSAN.use('util.sound'); var sound = new util.sound(); sound.bad();
+ JSAN.use('util.sound'); var sound = new util.sound(); sound.bad();
- }
- }
- }
- ],
- 'cmd_broken' : [
- ['command'],
- function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
- ],
- 'cmd_checkin_submit_barcode' : [
- ['command'],
- function() {
- obj.checkin();
- }
- ],
- 'cmd_checkin_print' : [
- ['command'],
- function() {
- var p = {
- 'template' : 'checkin'
- };
- obj.list.print(p);
- }
- ],
- 'cmd_csv_to_clipboard' : [ ['command'], function() {
+ }
+ }
+ }
+ ],
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
+ ],
+ 'cmd_checkin_submit_barcode' : [
+ ['command'],
+ function() {
+ obj.checkin();
+ }
+ ],
+ 'cmd_checkin_print' : [
+ ['command'],
+ function() {
+ var p = {
+ 'template' : 'checkin'
+ };
+ obj.list.print(p);
+ }
+ ],
+ 'cmd_csv_to_clipboard' : [ ['command'], function() {
obj.list.dump_csv_to_clipboard();
obj.controller.view.checkin_barcode_entry_textbox.focus();
} ],
- 'cmd_csv_to_printer' : [ ['command'], function() {
+ 'cmd_csv_to_printer' : [ ['command'], function() {
obj.list.dump_csv_to_printer();
obj.controller.view.checkin_barcode_entry_textbox.focus();
} ],
- 'cmd_csv_to_file' : [ ['command'], function() {
+ 'cmd_csv_to_file' : [ ['command'], function() {
obj.list.dump_csv_to_file( { 'defaultFileName' : 'checked_in.txt' } );
obj.controller.view.checkin_barcode_entry_textbox.focus();
} ],
document.getElementById('checkin_barcode_entry_textbox').focus();
return true;
} ]
- }
- }
- );
- this.controller.render();
- this.controller.view.checkin_barcode_entry_textbox.focus();
+ }
+ }
+ );
+ this.controller.render();
+ this.controller.view.checkin_barcode_entry_textbox.focus();
- },
+ },
'gen_list_retrieve_row_func' : function() {
var obj = this;
};
},
- 'test_barcode' : function(bc) {
- var obj = this;
- var x = document.getElementById('strict_barcode');
- if (x && x.checked != true) return true;
- var good = util.barcode.check(bc);
- if (good) {
- return true;
- } else {
- if ( 1 == obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
- document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
- document.getElementById('circStrings').getString('staff.circ.cancel'),
- document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm'),
- '/xul/server/skin/media/images/bad_barcode.png'
- ) ) {
- return true;
- } else {
- return false;
- }
- }
- },
-
- 'checkin' : function() {
- var obj = this;
- try {
- var barcode = obj.controller.view.checkin_barcode_entry_textbox.value;
- if (!barcode) return;
- if (barcode) {
- if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
- }
- var backdate = obj.controller.view.checkin_effective_datepicker.value;
- var auto_print = document.getElementById('checkin_auto_print_slips');
- if (auto_print) auto_print = auto_print.getAttribute('checked') == 'true';
- JSAN.use('circ.util');
+ 'test_barcode' : function(bc) {
+ var obj = this;
+ var x = document.getElementById('strict_barcode');
+ if (x && x.checked != true) return true;
+ var good = util.barcode.check(bc);
+ if (good) {
+ return true;
+ } else {
+ if ( 1 == obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
+ document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
+ document.getElementById('circStrings').getString('staff.circ.cancel'),
+ document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm'),
+ '/xul/server/skin/media/images/bad_barcode.png'
+ ) ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ },
+
+ 'checkin' : function() {
+ var obj = this;
+ try {
+ var barcode = obj.controller.view.checkin_barcode_entry_textbox.value;
+ if (!barcode) return;
+ if (barcode) {
+ if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
+ }
+ var backdate = obj.controller.view.checkin_effective_datepicker.value;
+ var auto_print = document.getElementById('checkin_auto_print_slips');
+ if (auto_print) auto_print = auto_print.getAttribute('checked') == 'true';
+ JSAN.use('circ.util');
var params = {
'barcode' : barcode,
'disable_textbox' : function() {
obj.checkin2(checkin,backdate);
}
};
- var suppress_holds_and_transits = document.getElementById('suppress_holds_and_transits');
- if (suppress_holds_and_transits) suppress_holds_and_transits = suppress_holds_and_transits.getAttribute('checked') == 'true';
+ var suppress_holds_and_transits = document.getElementById('suppress_holds_and_transits');
+ if (suppress_holds_and_transits) suppress_holds_and_transits = suppress_holds_and_transits.getAttribute('checked') == 'true';
if (suppress_holds_and_transits) params.noop = 1;
- var amnesty_mode = document.getElementById('amnesty_mode');
- if (amnesty_mode) amnesty_mode = amnesty_mode.getAttribute('checked') == 'true';
+ var amnesty_mode = document.getElementById('amnesty_mode');
+ if (amnesty_mode) amnesty_mode = amnesty_mode.getAttribute('checked') == 'true';
if (amnesty_mode) params.void_overdues = 1;
- circ.util.checkin_via_barcode(
- ses(),
+ circ.util.checkin_via_barcode(
+ ses(),
params,
backdate,
auto_print
- );
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.exception', [E]), E);
- if (typeof obj.on_failure == 'function') {
- obj.on_failure(E);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
- obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.util.checkin.exception.external') + '\n');
- window.xulG.on_failure(E);
- } else {
- obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.util.checkin.exception.no_external') + '\n');
- }
- }
-
- },
-
- 'checkin2' : function(checkin,backdate) {
- var obj = this;
- try {
- if (!checkin) return obj.on_failure(); /* circ.util.checkin handles errors and returns null currently */
- if (checkin.ilsevent == 7010 /* COPY_ALERT_MESSAGE */
- || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */
- || checkin.ilsevent == -1 /* offline */
- || checkin.ilsevent == 1502 /* ASSET_COPY_NOT_FOUND */
- || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */
- || checkin.ilsevent == 7009 /* CIRC_CLAIMS_RETURNED */
- || checkin.ilsevent == 7011 /* COPY_STATUS_LOST */
- || checkin.ilsevent == 7012 /* COPY_STATUS_MISSING */) return obj.on_failure();
- var retrieve_id = js2JSON( { 'circ_id' : checkin.circ ? checkin.circ.id() : null , 'copy_id' : checkin.copy.id(), 'barcode' : checkin.copy.barcode(), 'doc_id' : (typeof checkin.record != 'undefined' ? ( typeof checkin.record.ilsevent == 'undefined' ? checkin.record.doc_id() : null ) : null ) } );
- if (checkin.circ && checkin.circ.checkin_time() == 'now') checkin.circ.checkin_time(backdate);
- if (document.getElementById('trim_list')) {
- var x = document.getElementById('trim_list');
- if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
- }
- obj.list.append(
- {
- 'retrieve_id' : retrieve_id,
- 'row' : {
- 'my' : {
- 'circ' : checkin.circ,
- 'mbts' : checkin.circ ? checkin.circ.billable_transaction().summary() : null,
- 'mvr' : checkin.record,
- 'acp' : checkin.copy,
- 'au' : checkin.patron,
- 'status' : checkin.status,
- 'route_to' : checkin.route_to,
- 'message' : checkin.message
- }
- },
- 'to_top' : true
- }
- );
- obj.list.node.view.selection.select(0);
-
- JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good();
-
- if (typeof obj.on_checkin == 'function') {
- obj.on_checkin(checkin);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_checkin == 'function') {
- obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin.exception.external') + '\n');
- window.xulG.on_checkin(checkin);
- } else {
- obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin.exception.no_external') + '\n');
- }
-
- return true;
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin2.exception', [E]));
- if (typeof obj.on_failure == 'function') {
- obj.on_failure(E);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
- obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin2.exception.external') + '\n');
- window.xulG.on_failure(E);
- } else {
- obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin2.exception.no_external') + '\n');
- }
- }
-
- },
-
- 'on_checkin' : function() {
- this.controller.view.checkin_barcode_entry_textbox.disabled = false;
- this.controller.view.checkin_barcode_entry_textbox.select();
- this.controller.view.checkin_barcode_entry_textbox.value = '';
- this.controller.view.checkin_barcode_entry_textbox.focus();
- },
-
- 'on_failure' : function() {
- this.controller.view.checkin_barcode_entry_textbox.disabled = false;
- this.controller.view.checkin_barcode_entry_textbox.select();
- this.controller.view.checkin_barcode_entry_textbox.focus();
- },
-
- 'spawn_copy_editor' : function() {
-
- var obj = this;
-
- JSAN.use('util.functional');
-
- var list = obj.selection_list;
-
- list = util.functional.map_list(
- list,
- function (o) {
- return o.copy_id;
- }
- );
-
- JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
-
- }
+ );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.exception', [E]), E);
+ if (typeof obj.on_failure == 'function') {
+ obj.on_failure(E);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
+ obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.util.checkin.exception.external') + '\n');
+ window.xulG.on_failure(E);
+ } else {
+ obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.util.checkin.exception.no_external') + '\n');
+ }
+ }
+
+ },
+
+ 'checkin2' : function(checkin,backdate) {
+ var obj = this;
+ try {
+ if (!checkin) return obj.on_failure(); /* circ.util.checkin handles errors and returns null currently */
+ if (checkin.ilsevent == 7010 /* COPY_ALERT_MESSAGE */
+ || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */
+ || checkin.ilsevent == -1 /* offline */
+ || checkin.ilsevent == 1502 /* ASSET_COPY_NOT_FOUND */
+ || checkin.ilsevent == 1203 /* COPY_BAD_STATUS */
+ || checkin.ilsevent == 7009 /* CIRC_CLAIMS_RETURNED */
+ || checkin.ilsevent == 7011 /* COPY_STATUS_LOST */
+ || checkin.ilsevent == 7012 /* COPY_STATUS_MISSING */) return obj.on_failure();
+ var retrieve_id = js2JSON( { 'circ_id' : checkin.circ ? checkin.circ.id() : null , 'copy_id' : checkin.copy.id(), 'barcode' : checkin.copy.barcode(), 'doc_id' : (typeof checkin.record != 'undefined' ? ( typeof checkin.record.ilsevent == 'undefined' ? checkin.record.doc_id() : null ) : null ) } );
+ if (checkin.circ && checkin.circ.checkin_time() == 'now') checkin.circ.checkin_time(backdate);
+ if (document.getElementById('trim_list')) {
+ var x = document.getElementById('trim_list');
+ if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
+ }
+ obj.list.append(
+ {
+ 'retrieve_id' : retrieve_id,
+ 'row' : {
+ 'my' : {
+ 'circ' : checkin.circ,
+ 'mbts' : checkin.circ ? checkin.circ.billable_transaction().summary() : null,
+ 'mvr' : checkin.record,
+ 'acp' : checkin.copy,
+ 'au' : checkin.patron,
+ 'status' : checkin.status,
+ 'route_to' : checkin.route_to,
+ 'message' : checkin.message
+ }
+ },
+ 'to_top' : true
+ }
+ );
+ obj.list.node.view.selection.select(0);
+
+ JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good();
+
+ if (typeof obj.on_checkin == 'function') {
+ obj.on_checkin(checkin);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_checkin == 'function') {
+ obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin.exception.external') + '\n');
+ window.xulG.on_checkin(checkin);
+ } else {
+ obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin.exception.no_external') + '\n');
+ }
+
+ return true;
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin2.exception', [E]));
+ if (typeof obj.on_failure == 'function') {
+ obj.on_failure(E);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
+ obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin2.exception.external') + '\n');
+ window.xulG.on_failure(E);
+ } else {
+ obj.error.sdump('D_CIRC', document.getElementById('circStrings').getString('staff.circ.checkin2.exception.no_external') + '\n');
+ }
+ }
+
+ },
+
+ 'on_checkin' : function() {
+ this.controller.view.checkin_barcode_entry_textbox.disabled = false;
+ this.controller.view.checkin_barcode_entry_textbox.select();
+ this.controller.view.checkin_barcode_entry_textbox.value = '';
+ this.controller.view.checkin_barcode_entry_textbox.focus();
+ },
+
+ 'on_failure' : function() {
+ this.controller.view.checkin_barcode_entry_textbox.disabled = false;
+ this.controller.view.checkin_barcode_entry_textbox.select();
+ this.controller.view.checkin_barcode_entry_textbox.focus();
+ },
+
+ 'spawn_copy_editor' : function() {
+
+ var obj = this;
+
+ JSAN.use('util.functional');
+
+ var list = obj.selection_list;
+
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.copy_id;
+ }
+ );
+
+ JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
+
+ }
}
if (typeof circ == 'undefined') { circ = {}; }
circ.checkout = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
- JSAN.use('util.barcode');
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
+ JSAN.use('util.barcode');
};
circ.checkout.prototype = {
- 'init' : function( params ) {
-
- var obj = this;
-
- obj.patron_id = params.patron_id;
-
- JSAN.use('circ.util');
- var columns = circ.util.columns(
- {
- 'barcode' : { 'hidden' : false },
- 'title' : { 'hidden' : false },
- 'due_date' : { 'hidden' : false }
- }
- );
-
- JSAN.use('util.list'); obj.list = new util.list('checkout_list');
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
- 'on_select' : function() {
- var sel = obj.list.retrieve_selection();
- document.getElementById('clip_button').disabled = sel.length < 1;
- }
- }
- );
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
- 'sel_clip' : [
- ['command'],
- function() { obj.list.clipboard(); }
- ],
- 'checkout_menu_placeholder' : [
- ['render'],
- function(e) {
- return function() {
- JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
- var items = [ [ document.getElementById('circStrings').getString('staff.circ.checkout.barcode') , 'barcode' ] ].concat(
- util.functional.map_list(
- util.functional.filter_list(
- obj.data.list.my_cnct,
- function(o) {
- return util.fm_utils.compare_aou_a_is_b_or_ancestor(o.owning_lib(), obj.data.list.au[0].ws_ou());
- }
- ).sort(
-
- function(a,b) {
- try {
- return util.fm_utils.sort_func_aou_by_depth_and_then_string(
- [ a.owning_lib(), a.name() ],
- [ b.owning_lib(), b.name() ]
- );
- } catch(E) {
- alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkout.sorting.exception', [E]));
- return 0;
- }
- }
-
- ),
- function(o) {
- return [ obj.data.hash.aou[ o.owning_lib() ].shortname() + ' : ' + o.name(), o.id() ];
- }
- )
- );
- g.error.sdump('D_TRACE','items = ' + js2JSON(items));
- util.widgets.remove_children( e );
- var ml = util.widgets.make_menulist(items);
- e.appendChild( ml );
- ml.setAttribute('id','checkout_menulist');
- ml.setAttribute('accesskey','');
- ml.addEventListener(
- 'command',
- function(ev) {
- var tb = obj.controller.view.checkout_barcode_entry_textbox;
- var db = document.getElementById('duedate_hbox');
- if (ev.target.value == 'barcode') {
- db.hidden = false;
- tb.disabled = false;
- tb.value = '';
- tb.focus();
- } else {
- db.hidden = true;
- tb.disabled = true;
- tb.value = document.getElementById('circStrings').getString('staff.circ.non_cataloged');
- }
- }, false
- );
- obj.controller.view.checkout_menu = ml;
- };
- }
- ],
- 'checkout_barcode_entry_textbox' : [
- ['keypress'],
- function(ev) {
- if (ev.keyCode && ev.keyCode == 13) {
- obj.checkout( { barcode: ev.target.value } );
- }
- }
- ],
- 'checkout_duedate_datepicker' : [
- ['change'],
- function(ev) {
- try {
- if (obj.check_date(ev.target)) {
- ev.target.parentNode.setAttribute('style','');
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ obj.patron_id = params.patron_id;
+
+ JSAN.use('circ.util');
+ var columns = circ.util.columns(
+ {
+ 'barcode' : { 'hidden' : false },
+ 'title' : { 'hidden' : false },
+ 'due_date' : { 'hidden' : false }
+ }
+ );
+
+ JSAN.use('util.list'); obj.list = new util.list('checkout_list');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'on_select' : function() {
+ var sel = obj.list.retrieve_selection();
+ document.getElementById('clip_button').disabled = sel.length < 1;
+ }
+ }
+ );
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
+ 'sel_clip' : [
+ ['command'],
+ function() { obj.list.clipboard(); }
+ ],
+ 'checkout_menu_placeholder' : [
+ ['render'],
+ function(e) {
+ return function() {
+ JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
+ var items = [ [ document.getElementById('circStrings').getString('staff.circ.checkout.barcode') , 'barcode' ] ].concat(
+ util.functional.map_list(
+ util.functional.filter_list(
+ obj.data.list.my_cnct,
+ function(o) {
+ return util.fm_utils.compare_aou_a_is_b_or_ancestor(o.owning_lib(), obj.data.list.au[0].ws_ou());
+ }
+ ).sort(
+
+ function(a,b) {
+ try {
+ return util.fm_utils.sort_func_aou_by_depth_and_then_string(
+ [ a.owning_lib(), a.name() ],
+ [ b.owning_lib(), b.name() ]
+ );
+ } catch(E) {
+ alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkout.sorting.exception', [E]));
+ return 0;
+ }
+ }
+
+ ),
+ function(o) {
+ return [ obj.data.hash.aou[ o.owning_lib() ].shortname() + ' : ' + o.name(), o.id() ];
+ }
+ )
+ );
+ g.error.sdump('D_TRACE','items = ' + js2JSON(items));
+ util.widgets.remove_children( e );
+ var ml = util.widgets.make_menulist(items);
+ e.appendChild( ml );
+ ml.setAttribute('id','checkout_menulist');
+ ml.setAttribute('accesskey','');
+ ml.addEventListener(
+ 'command',
+ function(ev) {
+ var tb = obj.controller.view.checkout_barcode_entry_textbox;
+ var db = document.getElementById('duedate_hbox');
+ if (ev.target.value == 'barcode') {
+ db.hidden = false;
+ tb.disabled = false;
+ tb.value = '';
+ tb.focus();
+ } else {
+ db.hidden = true;
+ tb.disabled = true;
+ tb.value = document.getElementById('circStrings').getString('staff.circ.non_cataloged');
+ }
+ }, false
+ );
+ obj.controller.view.checkout_menu = ml;
+ };
+ }
+ ],
+ 'checkout_barcode_entry_textbox' : [
+ ['keypress'],
+ function(ev) {
+ if (ev.keyCode && ev.keyCode == 13) {
+ obj.checkout( { barcode: ev.target.value } );
+ }
+ }
+ ],
+ 'checkout_duedate_datepicker' : [
+ ['change'],
+ function(ev) {
+ try {
+ if (obj.check_date(ev.target)) {
+ ev.target.parentNode.setAttribute('style','');
} else {
ev.target.parentNode.setAttribute('style','background-color: red');
}
- } catch(E) {
+ } catch(E) {
alert('Error in checkout.js, checkout_duedate_datepicker @change: ' + E);
- }
- }
- ],
- 'cmd_broken' : [
- ['command'],
- function() { alert(document.getElementById('circStrings').getString('staff.circ.checkout.unimplemented')); }
- ],
- 'cmd_checkout_submit' : [
- ['command'],
- function() {
- var params = {}; var count = 1;
-
- if (obj.controller.view.checkout_menu.value == 'barcode' ||
- obj.controller.view.checkout_menu.value === '') {
- params.barcode = obj.controller.view.checkout_barcode_entry_textbox.value;
- } else {
- params.noncat = 1;
- params.noncat_type = obj.controller.view.checkout_menu.value;
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- var r = window.prompt(
- document.getElementById('circStrings').getFormattedString('staff.circ.checkout.cmd_checkout_submit.msg', [obj.data.hash.cnct[params.noncat_type].name()]),
- '1',
- document.getElementById('circStrings').getString('staff.circ.checkout.cmd_checkout_submit.title')
- );
- if (r) {
- count = Number(r);
- if (count > 0) {
- if (count > 99) {
- obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.checkout.cmd_checkout_submit.too_many.msg', [count, obj.data.hash.cnct[params.noncat_type].name()]),
- document.getElementById('circStrings').getString('staff.circ.checkout.cmd_checkout_submit.too_many.title'),
- document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm')
- );
- return;
- } else if (count > 20) {
- r = obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.checkout.cmd_checkout_submit.confirm.msg', [count, obj.data.hash.cnct[params.noncat_type].name()]),
- document.getElementById('circStrings').getString('staff.circ.checkout.cmd_checkout_submit.confirm.title'),
- document.getElementById('circStrings').getString('staff.circ.checkout.yes.btn'),
- document.getElementById('circStrings').getString('staff.circ.checkout.no.btn'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm')
- );
- if (r !== 0) { return; }
- }
- } else {
- r = obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.checkout.cmd_checkout_submit.non_numeric.msg', [r]),
- document.getElementById('circStrings').getString('staff.circ.checkout.cmd_checkout_submit.non_numeric.title'),
- document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm')
- );
- return;
- }
- } else {
- return;
- }
- }
- for (var i = 0; i < count; i++) {
- obj.checkout( params );
- }
- }
- ],
- 'cmd_checkout_print' : [
- ['command'],
- function() {
- try {
- obj.print();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('cmd_checkout_print',E);
- }
-
- }
- ],
- 'cmd_checkout_export' : [
- ['command'],
- function() {
- try {
- obj.export_list();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('cmd_checkout_export',E);
- }
- }
- ],
-
-
- 'cmd_checkout_reprint' : [
- ['command'],
- function() {
- JSAN.use('util.print'); var print = new util.print();
- print.reprint_last();
- }
- ],
- 'cmd_checkout_done' : [
- ['command'],
- function() {
- try {
+ }
+ }
+ ],
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert(document.getElementById('circStrings').getString('staff.circ.checkout.unimplemented')); }
+ ],
+ 'cmd_checkout_submit' : [
+ ['command'],
+ function() {
+ var params = {}; var count = 1;
+
+ if (obj.controller.view.checkout_menu.value == 'barcode' ||
+ obj.controller.view.checkout_menu.value === '') {
+ params.barcode = obj.controller.view.checkout_barcode_entry_textbox.value;
+ } else {
+ params.noncat = 1;
+ params.noncat_type = obj.controller.view.checkout_menu.value;
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ var r = window.prompt(
+ document.getElementById('circStrings').getFormattedString('staff.circ.checkout.cmd_checkout_submit.msg', [obj.data.hash.cnct[params.noncat_type].name()]),
+ '1',
+ document.getElementById('circStrings').getString('staff.circ.checkout.cmd_checkout_submit.title')
+ );
+ if (r) {
+ count = Number(r);
+ if (count > 0) {
+ if (count > 99) {
+ obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.checkout.cmd_checkout_submit.too_many.msg', [count, obj.data.hash.cnct[params.noncat_type].name()]),
+ document.getElementById('circStrings').getString('staff.circ.checkout.cmd_checkout_submit.too_many.title'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm')
+ );
+ return;
+ } else if (count > 20) {
+ r = obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.checkout.cmd_checkout_submit.confirm.msg', [count, obj.data.hash.cnct[params.noncat_type].name()]),
+ document.getElementById('circStrings').getString('staff.circ.checkout.cmd_checkout_submit.confirm.title'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.yes.btn'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.no.btn'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm')
+ );
+ if (r !== 0) { return; }
+ }
+ } else {
+ r = obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.checkout.cmd_checkout_submit.non_numeric.msg', [r]),
+ document.getElementById('circStrings').getString('staff.circ.checkout.cmd_checkout_submit.non_numeric.title'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm')
+ );
+ return;
+ }
+ } else {
+ return;
+ }
+ }
+ for (var i = 0; i < count; i++) {
+ obj.checkout( params );
+ }
+ }
+ ],
+ 'cmd_checkout_print' : [
+ ['command'],
+ function() {
+ try {
+ obj.print();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('cmd_checkout_print',E);
+ }
+
+ }
+ ],
+ 'cmd_checkout_export' : [
+ ['command'],
+ function() {
+ try {
+ obj.export_list();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('cmd_checkout_export',E);
+ }
+ }
+ ],
+
+
+ 'cmd_checkout_reprint' : [
+ ['command'],
+ function() {
+ JSAN.use('util.print'); var print = new util.print();
+ print.reprint_last();
+ }
+ ],
+ 'cmd_checkout_done' : [
+ ['command'],
+ function() {
+ try {
var no_print_prompting = obj.data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
if (no_print_prompting) {
if (no_print_prompting.indexOf( "Checkout" ) > -1) {
- obj.list.clear();
- xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
+ obj.list.clear();
+ xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
return;
}
}
- if (document.getElementById('checkout_auto').checked) {
- obj.print(true,function() {
- obj.list.clear();
- xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
- });
- } else {
- obj.print(false,function() {
- obj.list.clear();
- xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
- });
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('cmd_checkout_done',E);
- }
- }
- ]
- }
- }
- );
- this.controller.render();
- //this.controller.view.checkout_barcode_entry_textbox.focus();
-
- this.check_disable();
-
- var robj = obj.network.simple_request(
- 'FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative',
- [ ses(), obj.patron_id ]
- );
- obj.items_out_count = (robj.out + robj.overdue + robj.claims_returned + robj.long_overdue );
-
- },
-
- 'check_disable' : function() {
- var obj = this;
- try {
- if (typeof xulG.check_stop_checkouts == 'function') {
- var disable = xulG.check_stop_checkouts();
- if (disable) {
- document.getElementById('checkout_submit_barcode_button').disabled = true;
- document.getElementById('checkout_done').disabled = true;
- obj.controller.view.checkout_menu.disabled = true;
- obj.controller.view.checkout_barcode_entry_textbox.disabled = true;
- } else {
- document.getElementById('checkout_submit_barcode_button').disabled = false;
- document.getElementById('checkout_done').disabled = false;
- obj.controller.view.checkout_menu.disabled = false;
- obj.controller.view.checkout_barcode_entry_textbox.disabled = false;
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.checkout.disable.error'),E);
- }
- },
-
- 'print' : function(silent,f) {
- var obj = this;
- try {
- obj.patron = obj.network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ses(),obj.patron_id]);
+ if (document.getElementById('checkout_auto').checked) {
+ obj.print(true,function() {
+ obj.list.clear();
+ xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
+ });
+ } else {
+ obj.print(false,function() {
+ obj.list.clear();
+ xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
+ });
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('cmd_checkout_done',E);
+ }
+ }
+ ]
+ }
+ }
+ );
+ this.controller.render();
+ //this.controller.view.checkout_barcode_entry_textbox.focus();
+
+ this.check_disable();
+
+ var robj = obj.network.simple_request(
+ 'FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative',
+ [ ses(), obj.patron_id ]
+ );
+ obj.items_out_count = (robj.out + robj.overdue + robj.claims_returned + robj.long_overdue );
+
+ },
+
+ 'check_disable' : function() {
+ var obj = this;
+ try {
+ if (typeof xulG.check_stop_checkouts == 'function') {
+ var disable = xulG.check_stop_checkouts();
+ if (disable) {
+ document.getElementById('checkout_submit_barcode_button').disabled = true;
+ document.getElementById('checkout_done').disabled = true;
+ obj.controller.view.checkout_menu.disabled = true;
+ obj.controller.view.checkout_barcode_entry_textbox.disabled = true;
+ } else {
+ document.getElementById('checkout_submit_barcode_button').disabled = false;
+ document.getElementById('checkout_done').disabled = false;
+ obj.controller.view.checkout_menu.disabled = false;
+ obj.controller.view.checkout_barcode_entry_textbox.disabled = false;
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.checkout.disable.error'),E);
+ }
+ },
+
+ 'print' : function(silent,f) {
+ var obj = this;
+ try {
+ obj.patron = obj.network.simple_request('FM_AU_FLESHED_RETRIEVE_VIA_ID',[ses(),obj.patron_id]);
var params = {
'patron' : obj.patron,
'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
);
}
};
- if (silent) { params.no_prompt = true; }
- obj.list.print(params);
- } catch(E) {
- obj.error.standard_unexpected_error_alert('print',E);
- }
- },
-
- 'export_list' : function(silent,f) {
- var obj = this;
- try {
- obj.list.dump_csv_to_clipboard();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('export',E);
- }
- },
-
- 'check_date' : function(node) {
+ if (silent) { params.no_prompt = true; }
+ obj.list.print(params);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('print',E);
+ }
+ },
+
+ 'export_list' : function(silent,f) {
+ var obj = this;
+ try {
+ obj.list.dump_csv_to_clipboard();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('export',E);
+ }
+ },
+
+ 'check_date' : function(node) {
var obj = this;
- JSAN.use('util.date');
- try {
+ JSAN.use('util.date');
+ try {
obj.controller.view.checkout_barcode_entry_textbox.setAttribute('disabled','false');
obj.controller.view.checkout_barcode_entry_textbox.disabled = false;
obj.controller.view.cmd_checkout_submit.setAttribute('disabled','false');
obj.controller.view.cmd_checkout_submit.disabled = false;
- if (util.date.check_past('YYYY-MM-DD',node.value) ) {
- obj.controller.view.checkout_barcode_entry_textbox.setAttribute('disabled','true');
- obj.controller.view.cmd_checkout_submit.setAttribute('disabled','true');
+ if (util.date.check_past('YYYY-MM-DD',node.value) ) {
+ obj.controller.view.checkout_barcode_entry_textbox.setAttribute('disabled','true');
+ obj.controller.view.cmd_checkout_submit.setAttribute('disabled','true');
return false;
- }
- return true;
- } catch(E) {
- throw(E);
- }
- },
-
- '_checkout_pending_hash' : {},
-
- '_checkout' : function(params,permit) {
- var obj = this;
- try {
-
- /**********************************************************************************************************************/
- /* This handles the return value of the checkout/renewal */
- function _checkout_callback(req,x) {
- try {
-
- if (params.barcode) {
- delete obj._checkout_pending_hash[ params.barcode ];
- }
-
- var checkout = req.getResultObject();
-
- if (checkout.ilsevent === '0') {
-
- if (!checkout.payload) { checkout.payload = {}; }
-
- if (!checkout.payload.circ) {
- checkout.payload.circ = new aoc();
- /*********************************************************************************************/
- /* Non Cat */
- if (checkout.payload.noncat_circ) {
- checkout.payload.circ.circ_lib( checkout.payload.noncat_circ.circ_lib() );
- checkout.payload.circ.circ_staff( checkout.payload.noncat_circ.staff() );
- checkout.payload.circ.usr( checkout.payload.noncat_circ.patron() );
-
- JSAN.use('util.date');
- var c = checkout.payload.noncat_circ.circ_time();
- var d = c == "now" ? new Date() : util.date.db_date2Date( c );
- var t =obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ];
- var cd = t.circ_duration() || "14 days";
- var i = util.date.interval_to_seconds( cd ) * 1000;
- d.setTime( Date.parse(d) + i );
- checkout.payload.circ.due_date( util.date.formatted_date(d,'%F') );
-
- }
- }
-
- if (!checkout.payload.record) {
- checkout.payload.record = new mvr();
- /*********************************************************************************************/
- /* Non Cat */
- if (checkout.payload.noncat_circ) {
- checkout.payload.record.title(
- obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ].name()
- );
- }
- }
-
- if (!checkout.payload.copy) {
- checkout.payload.copy = new acp();
- checkout.payload.copy.barcode( '' );
- }
-
- /*********************************************************************************************/
- /* Override mvr title/author with dummy title/author for Pre cat */
- if (checkout.payload.copy.dummy_title()) {
- checkout.payload.record.title( checkout.payload.copy.dummy_title() );
- }
- if (checkout.payload.copy.dummy_author()) {
- checkout.payload.record.author( checkout.payload.copy.dummy_author() );
- }
-
- obj.list.append(
- {
- 'row' : {
- 'my' : {
- 'circ' : checkout.payload.circ,
- 'mvr' : checkout.payload.record,
- 'acp' : checkout.payload.copy
- }
- },
- 'to_top' : true
- //I could override map_row_to_column here
- }
- );
+ }
+ return true;
+ } catch(E) {
+ throw(E);
+ }
+ },
+
+ '_checkout_pending_hash' : {},
+
+ '_checkout' : function(params,permit) {
+ var obj = this;
+ try {
+
+ /**********************************************************************************************************************/
+ /* This handles the return value of the checkout/renewal */
+ function _checkout_callback(req,x) {
+ try {
+
+ if (params.barcode) {
+ delete obj._checkout_pending_hash[ params.barcode ];
+ }
+
+ var checkout = req.getResultObject();
+
+ if (checkout.ilsevent === '0') {
+
+ if (!checkout.payload) { checkout.payload = {}; }
+
+ if (!checkout.payload.circ) {
+ checkout.payload.circ = new aoc();
+ /*********************************************************************************************/
+ /* Non Cat */
+ if (checkout.payload.noncat_circ) {
+ checkout.payload.circ.circ_lib( checkout.payload.noncat_circ.circ_lib() );
+ checkout.payload.circ.circ_staff( checkout.payload.noncat_circ.staff() );
+ checkout.payload.circ.usr( checkout.payload.noncat_circ.patron() );
+
+ JSAN.use('util.date');
+ var c = checkout.payload.noncat_circ.circ_time();
+ var d = c == "now" ? new Date() : util.date.db_date2Date( c );
+ var t =obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ];
+ var cd = t.circ_duration() || "14 days";
+ var i = util.date.interval_to_seconds( cd ) * 1000;
+ d.setTime( Date.parse(d) + i );
+ checkout.payload.circ.due_date( util.date.formatted_date(d,'%F') );
+
+ }
+ }
+
+ if (!checkout.payload.record) {
+ checkout.payload.record = new mvr();
+ /*********************************************************************************************/
+ /* Non Cat */
+ if (checkout.payload.noncat_circ) {
+ checkout.payload.record.title(
+ obj.data.hash.cnct[ checkout.payload.noncat_circ.item_type() ].name()
+ );
+ }
+ }
+
+ if (!checkout.payload.copy) {
+ checkout.payload.copy = new acp();
+ checkout.payload.copy.barcode( '' );
+ }
+
+ /*********************************************************************************************/
+ /* Override mvr title/author with dummy title/author for Pre cat */
+ if (checkout.payload.copy.dummy_title()) {
+ checkout.payload.record.title( checkout.payload.copy.dummy_title() );
+ }
+ if (checkout.payload.copy.dummy_author()) {
+ checkout.payload.record.author( checkout.payload.copy.dummy_author() );
+ }
+
+ obj.list.append(
+ {
+ 'row' : {
+ 'my' : {
+ 'circ' : checkout.payload.circ,
+ 'mvr' : checkout.payload.record,
+ 'acp' : checkout.payload.copy
+ }
+ },
+ 'to_top' : true
+ //I could override map_row_to_column here
+ }
+ );
obj.error.work_log(
document.getElementById('circStrings').getFormattedString(
'staff.circ.work_log_checkout.message',
'acp_barcode' : checkout.payload.copy.barcode()
}
);
- document.getElementById('msg_area').removeChild(x);
- /*
- if (typeof obj.on_checkout == 'function') {
- obj.on_checkout(checkout.payload);
- }
- */
- if (typeof window.xulG == 'object' && typeof window.xulG.on_list_change == 'function') {
- window.xulG.on_list_change(checkout.payload);
- } else {
- obj.error.sdump('D_CIRC','circ.checkout: No external .on_checkout()\n');
- }
-
- } else {
+ document.getElementById('msg_area').removeChild(x);
+ /*
+ if (typeof obj.on_checkout == 'function') {
+ obj.on_checkout(checkout.payload);
+ }
+ */
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_list_change == 'function') {
+ window.xulG.on_list_change(checkout.payload);
+ } else {
+ obj.error.sdump('D_CIRC','circ.checkout: No external .on_checkout()\n');
+ }
+
+ } else {
// Should get here with failed renewals
switch(Number(checkout.ilsevent)) {
case null /* custom event */ :
case 7009 /* CIRC_CLAIMS_RETURNED */ :
case 7010 /* COPY_ALERT_MESSAGE */ :
case 7013 /* PATRON_EXCEEDS_FINES */ :
- x.setAttribute('style','color: red');
- x.setAttribute('value', document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed', [params.barcode]));
- if (typeof params.noncat == 'undefined') { obj.items_out_count--; }
+ x.setAttribute('style','color: red');
+ x.setAttribute('value', document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed', [params.barcode]));
+ if (typeof params.noncat == 'undefined') { obj.items_out_count--; }
break;
default: throw(checkout);
}
- }
-
- } catch(E) {
- x.setAttribute('style','color: red');
- x.setAttribute('value', document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed', [params.barcode]));
- if (typeof params.noncat == 'undefined') { obj.items_out_count--; }
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed.alert', ['#3']),E);
- }
- }
-
- /**********************************************************************************************************************/
- /* This used to do the actual checkout/renewal */
-
- var x = document.createElement('label');
- x.setAttribute('style','color: green');
- if (params.barcode) {
- x.setAttribute('value',document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.pending', [params.barcode]));
- } else {
- x.setAttribute('value',document.getElementById('circStrings').getString('staff.circ.checkout.non_cataloged.pending'));
- }
- document.getElementById('msg_area').appendChild(x);
+ }
+
+ } catch(E) {
+ x.setAttribute('style','color: red');
+ x.setAttribute('value', document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed', [params.barcode]));
+ if (typeof params.noncat == 'undefined') { obj.items_out_count--; }
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed.alert', ['#3']),E);
+ }
+ }
+
+ /**********************************************************************************************************************/
+ /* This used to do the actual checkout/renewal */
+
+ var x = document.createElement('label');
+ x.setAttribute('style','color: green');
+ if (params.barcode) {
+ x.setAttribute('value',document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.pending', [params.barcode]));
+ } else {
+ x.setAttribute('value',document.getElementById('circStrings').getString('staff.circ.checkout.non_cataloged.pending'));
+ }
+ document.getElementById('msg_area').appendChild(x);
/*
- obj.network.request(
- api.CHECKOUT.app,
- api.CHECKOUT.method,
- [ ses(), params, obj.items_out_count ],
- function(req) {
- _checkout_callback(req,x);
- }
- );
+ obj.network.request(
+ api.CHECKOUT.app,
+ api.CHECKOUT.method,
+ [ ses(), params, obj.items_out_count ],
+ function(req) {
+ _checkout_callback(req,x);
+ }
+ );
*/
-
- if (typeof params.noncat == 'undefined') { obj.items_out_count++; }
+
+ if (typeof params.noncat == 'undefined') { obj.items_out_count++; }
/* new */
_checkout_callback({ 'getResultObject' : function() { return permit; } },x);
- } catch(E) {
- x.setAttribute('style','color: red');
- x.setAttribute('value', document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed', [params.barcode]));
- if (typeof params.noncat == 'undefined') { obj.items_out_count--; }
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed.alert', ['#2']),E);
- }
- },
-
-
- 'test_barcode' : function(bc) {
- var obj = this;
- var x = document.getElementById('strict_barcode');
- if (x && x.checked !== true) { return true; }
- var good = util.barcode.check(bc);
- if (good) {
- return true;
- } else {
- if ( 1 == obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
- document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
- document.getElementById('circStrings').getString('staff.circ.cancel'),
- document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm'),
- '/xul/server/skin/media/images/bad_barcode.png'
- )
- ) {
- return true;
- } else {
- return false;
- }
- }
- },
-
- 'checkout' : function(params) {
- var obj = this;
+ } catch(E) {
+ x.setAttribute('style','color: red');
+ x.setAttribute('value', document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed', [params.barcode]));
+ if (typeof params.noncat == 'undefined') { obj.items_out_count--; }
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkout.barcode.failed.alert', ['#2']),E);
+ }
+ },
+
+
+ 'test_barcode' : function(bc) {
+ var obj = this;
+ var x = document.getElementById('strict_barcode');
+ if (x && x.checked !== true) { return true; }
+ var good = util.barcode.check(bc);
+ if (good) {
+ return true;
+ } else {
+ if ( 1 == obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
+ document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
+ document.getElementById('circStrings').getString('staff.circ.cancel'),
+ document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm'),
+ '/xul/server/skin/media/images/bad_barcode.png'
+ )
+ ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ },
+
+ 'checkout' : function(params) {
+ var obj = this;
if (document.getElementById('checkout_duedate_checkbox').checked) {
if (! obj.check_date(obj.controller.view.checkout_duedate_datepicker)) return;
params.due_date = util.date.formatted_date(tp_date,'%{iso8601}');
}
- if (typeof obj.on_checkout == 'function') { obj.on_checkout(params); }
+ if (typeof obj.on_checkout == 'function') { obj.on_checkout(params); }
- if (! (params.barcode||params.noncat)) { return; }
+ if (! (params.barcode||params.noncat)) { return; }
- if (params.barcode) {
+ if (params.barcode) {
- if ( obj.test_barcode(params.barcode) ) { /* good */ } else { /* bad */ return; }
+ if ( obj.test_barcode(params.barcode) ) { /* good */ } else { /* bad */ return; }
- if (typeof obj._checkout_pending_hash[ params.barcode ] != 'undefined') {
+ if (typeof obj._checkout_pending_hash[ params.barcode ] != 'undefined') {
- obj.error.sdump('D_CIRC','Redundant barcode scan == ' + params.barcode);
- return; // redundant barcode scan
+ obj.error.sdump('D_CIRC','Redundant barcode scan == ' + params.barcode);
+ return; // redundant barcode scan
- } else {
+ } else {
- obj._checkout_pending_hash[ params.barcode ] = true;
+ obj._checkout_pending_hash[ params.barcode ] = true;
- }
- }
+ }
+ }
- /**********************************************************************************************************************/
- /* This used to be the Permissibility test before checkout */
- try {
+ /**********************************************************************************************************************/
+ /* This used to be the Permissibility test before checkout */
+ try {
- params.patron = obj.patron_id;
+ params.patron = obj.patron_id;
- var permit = obj.network.simple_request(
- //api.CHECKOUT_PERMIT.app,
- 'CHECKOUT_FULL',
- [ ses(), params, obj.items_out_count ],
- null,
- {
- 'title' : document.getElementById('circStrings').getString('staff.circ.checkout.override.confirm'),
- 'overridable_events' : [
+ var permit = obj.network.simple_request(
+ //api.CHECKOUT_PERMIT.app,
+ 'CHECKOUT_FULL',
+ [ ses(), params, obj.items_out_count ],
+ null,
+ {
+ 'title' : document.getElementById('circStrings').getString('staff.circ.checkout.override.confirm'),
+ 'overridable_events' : [
null /* custom event */,
- 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
- 1213 /* PATRON_BARRED */,
- 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
+ 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
+ 1213 /* PATRON_BARRED */,
+ 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
1232 /* ITEM_DEPOSIT_REQUIRED */,
1233 /* ITEM_RENTAL_FEE_REQUIRED */,
- 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
- 7003 /* COPY_CIRC_NOT_ALLOWED */,
- 7004 /* COPY_NOT_AVAILABLE */,
- 7006 /* COPY_IS_REFERENCE */,
- 7010 /* COPY_ALERT_MESSAGE */,
- 7016 /* ITEM_ON_HOLDS_SHELF */,
- 7013 /* PATRON_EXCEEDS_FINES */
- ],
- 'text' : {
+ 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
+ 7003 /* COPY_CIRC_NOT_ALLOWED */,
+ 7004 /* COPY_NOT_AVAILABLE */,
+ 7006 /* COPY_IS_REFERENCE */,
+ 7010 /* COPY_ALERT_MESSAGE */,
+ 7016 /* ITEM_ON_HOLDS_SHELF */,
+ 7013 /* PATRON_EXCEEDS_FINES */
+ ],
+ 'text' : {
'1232' : function(r) {
return document.getElementById('circStrings').getString('staff.circ.checkout.override.item_deposit_required.warning');
},
'1233' : function(r) {
return document.getElementById('circStrings').getString('staff.circ.checkout.override.item_rental_fee_required.warning');
},
- '7004' : function(r) {
- return r.payload.status().name();
- },
- '7010' : function(r) {
- return r.payload;
- }
- }
- }
- );
-
- if (!permit) { throw(permit); }
-
- function test_event(list,ev) {
- if (typeof list.ilsevent != 'undefined' ) {
- if (list.ilsevent == ev) {
- return list;
- } else {
- return false;
- }
- } else {
- for (var i = 0; i < list.length; i++) {
- if (typeof list[i].ilsevent != 'undefined') {
- if (list[i].ilsevent == ev) { return list[i]; }
- }
- }
- return false;
- }
- }
-
- /**********************************************************************************************************************/
- /* Normal case, proceed with checkout */
- if (permit.ilsevent === '0') {
-
- JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good();
- params.permit_key = permit.payload;
- obj._checkout( params, permit );
-
- /**********************************************************************************************************************/
- /* Item not cataloged or barcode mis-scan. Prompt for pre-cat option */
- } else {
-
- if (params.barcode) { delete obj._checkout_pending_hash[ params.barcode ]; }
-
- var found_handled = false; var found_not_handled = false; var msg = '';
-
- if (test_event(permit,1202 /* ITEM_NOT_CATALOGED */)) {
-
- if ( 1 == obj.error.yns_alert(
- document.getElementById('circStrings').getString('staff.circ.checkout.not_cataloged.confirm'),
- document.getElementById('circStrings').getString('staff.circ.alert'),
- document.getElementById('circStrings').getString('staff.circ.cancel'),
- document.getElementById('circStrings').getString('staff.circ.pre_cataloged'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm'),
- '/xul/server/skin/media/images/book_question.png'
- ) ) {
-
- obj.data.dummy_title = ''; obj.data.dummy_author = ''; obj.data.stash('dummy_title','dummy_author');
- JSAN.use('util.window'); var win = new util.window();
- win.open(urls.XUL_PRE_CAT, 'dummy_fields', 'chrome,resizable,modal');
- obj.data.stash_retrieve();
-
- params.permit_key = permit.payload;
- params.dummy_title = obj.data.precat_dummy_title;
- params.dummy_author = obj.data.precat_dummy_author;
- params.dummy_isbn = obj.data.precat_dummy_isbn;
- params.circ_modifier = obj.data.precat_circ_modifier;
- params.precat = 1;
-
- if (obj.data.precat_submit == 'go') {
- //obj._checkout( params ); No real request method here anymore
- obj.checkout( params );
- } else {
- alert(document.getElementById('circStrings').getString('staff.circ.checkout.cancelled'));
- }
- }
+ '7004' : function(r) {
+ return r.payload.status().name();
+ },
+ '7010' : function(r) {
+ return r.payload;
+ }
+ }
+ }
+ );
+
+ if (!permit) { throw(permit); }
+
+ function test_event(list,ev) {
+ if (typeof list.ilsevent != 'undefined' ) {
+ if (list.ilsevent == ev) {
+ return list;
+ } else {
+ return false;
+ }
+ } else {
+ for (var i = 0; i < list.length; i++) {
+ if (typeof list[i].ilsevent != 'undefined') {
+ if (list[i].ilsevent == ev) { return list[i]; }
+ }
+ }
+ return false;
+ }
+ }
+
+ /**********************************************************************************************************************/
+ /* Normal case, proceed with checkout */
+ if (permit.ilsevent === '0') {
+
+ JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good();
+ params.permit_key = permit.payload;
+ obj._checkout( params, permit );
+
+ /**********************************************************************************************************************/
+ /* Item not cataloged or barcode mis-scan. Prompt for pre-cat option */
+ } else {
+
+ if (params.barcode) { delete obj._checkout_pending_hash[ params.barcode ]; }
+
+ var found_handled = false; var found_not_handled = false; var msg = '';
+
+ if (test_event(permit,1202 /* ITEM_NOT_CATALOGED */)) {
+
+ if ( 1 == obj.error.yns_alert(
+ document.getElementById('circStrings').getString('staff.circ.checkout.not_cataloged.confirm'),
+ document.getElementById('circStrings').getString('staff.circ.alert'),
+ document.getElementById('circStrings').getString('staff.circ.cancel'),
+ document.getElementById('circStrings').getString('staff.circ.pre_cataloged'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm'),
+ '/xul/server/skin/media/images/book_question.png'
+ ) ) {
+
+ obj.data.dummy_title = ''; obj.data.dummy_author = ''; obj.data.stash('dummy_title','dummy_author');
+ JSAN.use('util.window'); var win = new util.window();
+ win.open(urls.XUL_PRE_CAT, 'dummy_fields', 'chrome,resizable,modal');
+ obj.data.stash_retrieve();
+
+ params.permit_key = permit.payload;
+ params.dummy_title = obj.data.precat_dummy_title;
+ params.dummy_author = obj.data.precat_dummy_author;
+ params.dummy_isbn = obj.data.precat_dummy_isbn;
+ params.circ_modifier = obj.data.precat_circ_modifier;
+ params.precat = 1;
+
+ if (obj.data.precat_submit == 'go') {
+ //obj._checkout( params ); No real request method here anymore
+ obj.checkout( params );
+ } else {
+ alert(document.getElementById('circStrings').getString('staff.circ.checkout.cancelled'));
+ }
+ }
return;
- }
-
- var test_permit;
- if (typeof permit.ilsevent != 'undefined') { test_permit = [ permit ]; } else { test_permit = permit; }
-
- var stop_checkout = false;
- for (var i = 0; i < test_permit.length; i++) {
- switch(Number(test_permit[i].ilsevent)) {
- case 1216 /* PATRON_CARD_INACTIVE */ :
- case 1217 /* PATRON_INACTIVE */ :
- case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
- stop_checkout = true;
- break;
- }
- }
-
- for (var i = 0; i < test_permit.length; i++) {
- dump('found [' + test_permit[i].ilsevent + ']\n');
- switch(test_permit[i].ilsevent == null ? null : Number(test_permit[i].ilsevent)) {
- case null /* custom event */ :
- found_handled = true;
- break;
- case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ :
- found_handled = true;
- break;
- case 1213 /* PATRON_BARRED */ :
- found_handled = true;
- break;
- case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ :
- found_handled = true;
- break;
- case 1216 /* PATRON_CARD_INACTIVE */ :
- found_handled = true;
- msg += document.getElementById('circStrings').getString('staff.circ.checkout.card.inactive') + '\n';
- obj.error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
- document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- break;
- case 1217 /* PATRON_INACTIVE */ :
- found_handled = true;
- msg += document.getElementById('circStrings').getString('staff.circ.checkout.account.inactive') + '\n';
- obj.error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
- document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- break;
- case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
- found_handled = true;
- msg += document.getElementById('circStrings').getString('staff.circ.checkout.account.expired') + '\n';
- obj.error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
- document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- break;
- case 1232 /* ITEM_DEPOSIT_REQUIRED */ :
- case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ :
- case 7013 /* PATRON_EXCEEDS_FINES */ :
- found_handled = true;
- break;
- case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ :
- found_handled = true;
- break;
- case 7003 /* COPY_CIRC_NOT_ALLOWED */ :
- found_handled = true;
- break;
- case 7004 /* COPY_NOT_AVAILABLE */ :
- msg += test_permit[i].desc + '\n' + document.getElementById('circStrings').getFormattedString('staff.circ.checkout.copy_status', [test_permit[i].payload.status().name()]) + '\n';
- found_handled = true;
- break;
- case 7006 /* COPY_IS_REFERENCE */ :
- msg += test_permit[i].desc + '\n';
- found_handled = true;
- break;
- case 7009 /* CIRC_CLAIMS_RETURNED */ :
- msg += test_permit[i].desc + '\n';
- obj.error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
- document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- found_handled = true;
- break;
- case 7010 /* COPY_ALERT_MESSAGE */ :
- msg += test_permit[i].desc + '\n' + document.getElementById('circStrings').getFormattedString('staff.circ.checkout.alert_message', [test_permit[i].payload]) + '\n';
- found_handled = true;
- break;
- case 7016 /* ITEM_ON_HOLDS_SHELF */ :
- msg += test_permit[i].desc + '\n';
- found_handled = true;
- break;
- case 1202 /* ITEM_NOT_CATALOGED */ :
- found_handled = true;
- break;
- case 5000 /* PERM_FAILURE */ :
- msg += test_permit[i].desc + '\n' + document.getElementById('circStrings').getFormattedString('staff.circ.checkout.permission_denied', [test_permit[i].ilsperm]) + '\n';
- found_handled = true;
- break;
- case 1702 /* OPEN_CIRCULATION_EXISTS */ :
- msg += test_permit[i].desc + '\n';
- found_handled = true;
+ }
+
+ var test_permit;
+ if (typeof permit.ilsevent != 'undefined') { test_permit = [ permit ]; } else { test_permit = permit; }
+
+ var stop_checkout = false;
+ for (var i = 0; i < test_permit.length; i++) {
+ switch(Number(test_permit[i].ilsevent)) {
+ case 1216 /* PATRON_CARD_INACTIVE */ :
+ case 1217 /* PATRON_INACTIVE */ :
+ case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
+ stop_checkout = true;
+ break;
+ }
+ }
+
+ for (var i = 0; i < test_permit.length; i++) {
+ dump('found [' + test_permit[i].ilsevent + ']\n');
+ switch(test_permit[i].ilsevent == null ? null : Number(test_permit[i].ilsevent)) {
+ case null /* custom event */ :
+ found_handled = true;
+ break;
+ case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ :
+ found_handled = true;
+ break;
+ case 1213 /* PATRON_BARRED */ :
+ found_handled = true;
+ break;
+ case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ :
+ found_handled = true;
+ break;
+ case 1216 /* PATRON_CARD_INACTIVE */ :
+ found_handled = true;
+ msg += document.getElementById('circStrings').getString('staff.circ.checkout.card.inactive') + '\n';
+ obj.error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ break;
+ case 1217 /* PATRON_INACTIVE */ :
+ found_handled = true;
+ msg += document.getElementById('circStrings').getString('staff.circ.checkout.account.inactive') + '\n';
+ obj.error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ break;
+ case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
+ found_handled = true;
+ msg += document.getElementById('circStrings').getString('staff.circ.checkout.account.expired') + '\n';
+ obj.error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ break;
+ case 1232 /* ITEM_DEPOSIT_REQUIRED */ :
+ case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ :
+ case 7013 /* PATRON_EXCEEDS_FINES */ :
+ found_handled = true;
+ break;
+ case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ :
+ found_handled = true;
+ break;
+ case 7003 /* COPY_CIRC_NOT_ALLOWED */ :
+ found_handled = true;
+ break;
+ case 7004 /* COPY_NOT_AVAILABLE */ :
+ msg += test_permit[i].desc + '\n' + document.getElementById('circStrings').getFormattedString('staff.circ.checkout.copy_status', [test_permit[i].payload.status().name()]) + '\n';
+ found_handled = true;
+ break;
+ case 7006 /* COPY_IS_REFERENCE */ :
+ msg += test_permit[i].desc + '\n';
+ found_handled = true;
+ break;
+ case 7009 /* CIRC_CLAIMS_RETURNED */ :
+ msg += test_permit[i].desc + '\n';
+ obj.error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ found_handled = true;
+ break;
+ case 7010 /* COPY_ALERT_MESSAGE */ :
+ msg += test_permit[i].desc + '\n' + document.getElementById('circStrings').getFormattedString('staff.circ.checkout.alert_message', [test_permit[i].payload]) + '\n';
+ found_handled = true;
+ break;
+ case 7016 /* ITEM_ON_HOLDS_SHELF */ :
+ msg += test_permit[i].desc + '\n';
+ found_handled = true;
+ break;
+ case 1202 /* ITEM_NOT_CATALOGED */ :
+ found_handled = true;
+ break;
+ case 5000 /* PERM_FAILURE */ :
+ msg += test_permit[i].desc + '\n' + document.getElementById('circStrings').getFormattedString('staff.circ.checkout.permission_denied', [test_permit[i].ilsperm]) + '\n';
+ found_handled = true;
+ break;
+ case 1702 /* OPEN_CIRCULATION_EXISTS */ :
+ msg += test_permit[i].desc + '\n';
+ found_handled = true;
var foreign_circ = true;
var my_circ;
my_circ = my_circ[0];
}
- if (! stop_checkout ) {
+ if (! stop_checkout ) {
var due_date = my_circ.due_date() ? my_circ.due_date().substr(0,10) : null;
JSAN.use('util.date'); var today = util.date.formatted_date(new Date(),'%F');
}
}
}
- } else {
- obj.error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
- document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- }
- break;
- case 7014 /* COPY_IN_TRANSIT */ :
- msg += test_permit[i].desc + '\n';
- found_handled = true;
- if (! stop_checkout ) {
- var r = obj.error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
- document.getElementById('circStrings').getString('staff.circ.cancel'),
- document.getElementById('circStrings').getString('staff.circ.checkout.abort_transit_then_checkout'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- if (r == 1) {
- var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : params.barcode } ]);
- if (typeof robj.ilsevent == 'undefined') {
- obj.checkout(params);
- } else {
- switch(robj.ilsevent) {
- case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
- alert(robj.desc);
- break;
- case 5000 /* PERM_FAILURE */ :
- break;
- default:
- throw(robj);
- break;
- }
- }
- }
- } else {
- obj.error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
- document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- }
- break;
- case -1 /* NETWORK_FAILURE */ :
- msg += document.getElementById('circStrings').getString('staff.circ.checkout.network_failure') + '\n';
- found_handled = true;
- obj.error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
- document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- break;
- default:
- msg += 'FIXME: ' + js2JSON(test_permit[i]) + '\n';
- found_not_handled = true;
- break;
- }
- }
-
- if (found_not_handled) {
- obj.error.standard_unexpected_error_alert(msg,permit);
- }
-
- obj.controller.view.checkout_barcode_entry_textbox.select();
- obj.controller.view.checkout_barcode_entry_textbox.focus();
- }
-
- } catch(E) {
- if (params.barcode) { delete obj._checkout_pending_hash[ params.barcode ]; }
- if (typeof E.ilsevent != 'undefined' && E.ilsevent == -1) {
- obj.error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkout.suggest_offline'));
- } else {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),E);
- }
- if (typeof obj.on_failure == 'function') {
- obj.on_failure(E);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
- obj.error.sdump('D_CIRC','circ.checkout: Calling external .on_failure()\n');
- window.xulG.on_failure(E);
- } else {
- obj.error.sdump('D_CIRC','circ.checkout: No external .on_failure()\n');
- }
- }
-
- },
-
- 'on_checkout' : function() {
- this.controller.view.checkout_menu.selectedIndex = 0;
- this.controller.view.checkout_barcode_entry_textbox.disabled = false;
- this.controller.view.checkout_barcode_entry_textbox.value = '';
- this.controller.view.checkout_barcode_entry_textbox.focus();
- document.getElementById('duedate_hbox').hidden = false;
- },
-
- 'on_failure' : function() {
- this.controller.view.checkout_barcode_entry_textbox.select();
- this.controller.view.checkout_barcode_entry_textbox.focus();
- }
+ } else {
+ obj.error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ }
+ break;
+ case 7014 /* COPY_IN_TRANSIT */ :
+ msg += test_permit[i].desc + '\n';
+ found_handled = true;
+ if (! stop_checkout ) {
+ var r = obj.error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
+ document.getElementById('circStrings').getString('staff.circ.cancel'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.abort_transit_then_checkout'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ if (r == 1) {
+ var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'barcode' : params.barcode } ]);
+ if (typeof robj.ilsevent == 'undefined') {
+ obj.checkout(params);
+ } else {
+ switch(robj.ilsevent) {
+ case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
+ alert(robj.desc);
+ break;
+ case 5000 /* PERM_FAILURE */ :
+ break;
+ default:
+ throw(robj);
+ break;
+ }
+ }
+ }
+ } else {
+ obj.error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ }
+ break;
+ case -1 /* NETWORK_FAILURE */ :
+ msg += document.getElementById('circStrings').getString('staff.circ.checkout.network_failure') + '\n';
+ found_handled = true;
+ obj.error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),
+ document.getElementById('circStrings').getString('staff.circ.checkout.ok.btn'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ break;
+ default:
+ msg += 'FIXME: ' + js2JSON(test_permit[i]) + '\n';
+ found_not_handled = true;
+ break;
+ }
+ }
+
+ if (found_not_handled) {
+ obj.error.standard_unexpected_error_alert(msg,permit);
+ }
+
+ obj.controller.view.checkout_barcode_entry_textbox.select();
+ obj.controller.view.checkout_barcode_entry_textbox.focus();
+ }
+
+ } catch(E) {
+ if (params.barcode) { delete obj._checkout_pending_hash[ params.barcode ]; }
+ if (typeof E.ilsevent != 'undefined' && E.ilsevent == -1) {
+ obj.error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkout.suggest_offline'));
+ } else {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.checkout.barcode.check_out_failed'),E);
+ }
+ if (typeof obj.on_failure == 'function') {
+ obj.on_failure(E);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
+ obj.error.sdump('D_CIRC','circ.checkout: Calling external .on_failure()\n');
+ window.xulG.on_failure(E);
+ } else {
+ obj.error.sdump('D_CIRC','circ.checkout: No external .on_failure()\n');
+ }
+ }
+
+ },
+
+ 'on_checkout' : function() {
+ this.controller.view.checkout_menu.selectedIndex = 0;
+ this.controller.view.checkout_barcode_entry_textbox.disabled = false;
+ this.controller.view.checkout_barcode_entry_textbox.value = '';
+ this.controller.view.checkout_barcode_entry_textbox.focus();
+ document.getElementById('duedate_hbox').hidden = false;
+ },
+
+ 'on_failure' : function() {
+ this.controller.view.checkout_barcode_entry_textbox.select();
+ this.controller.view.checkout_barcode_entry_textbox.focus();
+ }
};
dump('exiting circ.checkout.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.barcode');
- JSAN.use('util.date');
- JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
- JSAN.use('util.sound'); this.sound = new util.sound();
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('util.barcode');
+ JSAN.use('util.date');
+ JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
+ JSAN.use('util.sound'); this.sound = new util.sound();
};
circ.copy_status.prototype = {
- 'selection_list' : [],
- 'list_copyid_map' : {},
+ 'selection_list' : [],
+ 'list_copyid_map' : {},
'detail_map' : {},
- 'init' : function( params ) {
-
- var obj = this;
-
- 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 },
- 'alert_message' : { 'hidden' : false },
- 'due_date' : { 'hidden' : false }
- },
- {
- 'except_these' : [
- 'route_to', 'message', 'uses'
- ]
- }
- );
-
- JSAN.use('util.list'); obj.list = new util.list('copy_status_list');
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
- '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.setAttribute('disabled','true');
- obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
- obj.controller.view.sel_edit.setAttribute('disabled','true');
- obj.controller.view.sel_opac.setAttribute('disabled','true');
- obj.controller.view.sel_bucket.setAttribute('disabled','true');
- obj.controller.view.sel_copy_details.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
- obj.controller.view.sel_patron.setAttribute('disabled','true');
- obj.controller.view.sel_spine.setAttribute('disabled','true');
- obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
- obj.controller.view.sel_clip.setAttribute('disabled','true');
- obj.controller.view.sel_renew.setAttribute('disabled','true');
- obj.controller.view.cmd_add_items.setAttribute('disabled','true');
- obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
- obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
- obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
- obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
- obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
- obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
- obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
- obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
- } else {
- obj.controller.view.sel_checkin.setAttribute('disabled','false');
- obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
- obj.controller.view.sel_edit.setAttribute('disabled','false');
- obj.controller.view.sel_opac.setAttribute('disabled','false');
- obj.controller.view.sel_patron.setAttribute('disabled','false');
- obj.controller.view.sel_bucket.setAttribute('disabled','false');
- obj.controller.view.sel_copy_details.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
- obj.controller.view.sel_spine.setAttribute('disabled','false');
- obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
- obj.controller.view.sel_clip.setAttribute('disabled','false');
- obj.controller.view.sel_renew.setAttribute('disabled','false');
- obj.controller.view.cmd_add_items.setAttribute('disabled','false');
- obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
- obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
- obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
- obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
- obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
- obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
- obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
- obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
- }
- } catch(E) {
- alert('FIXME: ' + E);
- }
- }
- }
- );
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ 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 },
+ 'alert_message' : { 'hidden' : false },
+ 'due_date' : { 'hidden' : false }
+ },
+ {
+ 'except_these' : [
+ 'route_to', 'message', 'uses'
+ ]
+ }
+ );
+
+ JSAN.use('util.list'); obj.list = new util.list('copy_status_list');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ '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.setAttribute('disabled','true');
+ obj.controller.view.cmd_replace_barcode.setAttribute('disabled','true');
+ obj.controller.view.sel_edit.setAttribute('disabled','true');
+ obj.controller.view.sel_opac.setAttribute('disabled','true');
+ obj.controller.view.sel_bucket.setAttribute('disabled','true');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
+ obj.controller.view.sel_patron.setAttribute('disabled','true');
+ obj.controller.view.sel_spine.setAttribute('disabled','true');
+ obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
+ obj.controller.view.sel_clip.setAttribute('disabled','true');
+ obj.controller.view.sel_renew.setAttribute('disabled','true');
+ obj.controller.view.cmd_add_items.setAttribute('disabled','true');
+ obj.controller.view.cmd_delete_items.setAttribute('disabled','true');
+ obj.controller.view.cmd_transfer_items.setAttribute('disabled','true');
+ obj.controller.view.cmd_add_volumes.setAttribute('disabled','true');
+ obj.controller.view.cmd_edit_volumes.setAttribute('disabled','true');
+ obj.controller.view.cmd_delete_volumes.setAttribute('disabled','true');
+ obj.controller.view.cmd_mark_volume.setAttribute('disabled','true');
+ obj.controller.view.cmd_mark_library.setAttribute('disabled','true');
+ obj.controller.view.cmd_transfer_volume.setAttribute('disabled','true');
+ } else {
+ obj.controller.view.sel_checkin.setAttribute('disabled','false');
+ obj.controller.view.cmd_replace_barcode.setAttribute('disabled','false');
+ obj.controller.view.sel_edit.setAttribute('disabled','false');
+ obj.controller.view.sel_opac.setAttribute('disabled','false');
+ obj.controller.view.sel_patron.setAttribute('disabled','false');
+ obj.controller.view.sel_bucket.setAttribute('disabled','false');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
+ obj.controller.view.sel_spine.setAttribute('disabled','false');
+ obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
+ obj.controller.view.sel_clip.setAttribute('disabled','false');
+ obj.controller.view.sel_renew.setAttribute('disabled','false');
+ obj.controller.view.cmd_add_items.setAttribute('disabled','false');
+ obj.controller.view.cmd_delete_items.setAttribute('disabled','false');
+ obj.controller.view.cmd_transfer_items.setAttribute('disabled','false');
+ obj.controller.view.cmd_add_volumes.setAttribute('disabled','false');
+ obj.controller.view.cmd_edit_volumes.setAttribute('disabled','false');
+ obj.controller.view.cmd_delete_volumes.setAttribute('disabled','false');
+ obj.controller.view.cmd_mark_volume.setAttribute('disabled','false');
+ obj.controller.view.cmd_mark_library.setAttribute('disabled','false');
+ obj.controller.view.cmd_transfer_volume.setAttribute('disabled','false');
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ }
+ }
+ );
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
'list_actions' : [
['render'],
function(e) {
}
},
],
- 'sel_checkin' : [
- ['command'],
- function() {
- try {
- var funcs = [];
- JSAN.use('circ.util');
- for (var i = 0; i < obj.selection_list.length; i++) {
- var barcode = obj.selection_list[i].barcode;
- var checkin = circ.util.checkin_via_barcode( ses(), { 'barcode' : barcode } );
- funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
- }
- for (var i = 0; i < funcs.length; i++) { funcs[i](); }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.sel_checkin.error'),E);
- }
- }
- ],
- 'cmd_replace_barcode' : [
- ['command'],
- function() {
- try {
- var funcs = [];
- JSAN.use('cat.util');
- for (var i = 0; i < obj.selection_list.length; i++) {
- try {
- var barcode = obj.selection_list[i].barcode;
- var new_bc = cat.util.replace_barcode( barcode );
- funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(new_bc) );
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.cmd_replace_barcode.error', [barcode]), E);
- }
- }
- for (var i = 0; i < funcs.length; i++) { funcs[i](); }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.cmd_replace_barcodes.error'), E);
- }
- }
- ],
- 'sel_edit' : [
- ['command'],
- function() {
- try {
- var funcs = [];
- obj.spawn_copy_editor();
- for (var i = 0; i < obj.selection_list.length; i++) {
- var barcode = obj.selection_list[i].barcode;
- funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
- }
- for (var i = 0; i < funcs.length; i++) { funcs[i](); }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.sel_edit.error'), E);
- }
- }
- ],
- 'sel_spine' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.spawn_spine_editor(obj.selection_list);
- }
- ],
- 'sel_opac' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.show_in_opac(obj.selection_list);
- }
- ],
- 'sel_transit_abort' : [
- ['command'],
- function() {
- var funcs = [];
- JSAN.use('circ.util');
- circ.util.abort_transits(obj.selection_list);
- for (var i = 0; i < obj.selection_list.length; i++) {
- var barcode = obj.selection_list[i].barcode;
- funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
- }
- for (var i = 0; i < funcs.length; i++) { funcs[i](); }
- }
- ],
- 'sel_patron' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- circ.util.show_last_few_circs(obj.selection_list);
- }
- ],
- 'sel_copy_details' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- for (var i = 0; i < obj.selection_list.length; i++) {
- circ.util.show_copy_details( obj.selection_list[i].copy_id );
- }
- }
- ],
- 'sel_renew' : [
- ['command'],
- function() {
- var funcs = [];
- JSAN.use('circ.util');
- for (var i = 0; i < obj.selection_list.length; i++) {
- var test = obj.selection_list[i].renewable;
- var barcode = obj.selection_list[i].barcode;
- if (test == 't') {
- circ.util.renew_via_barcode( { 'barcode' : barcode } );
- funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
- } else {
- alert(document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.sel_renew.not_circulating', [barcode]));
- }
- }
- for (var i = 0; i < funcs.length; i++) { funcs[i](); }
- }
- ],
-
- 'sel_mark_items_damaged' : [
- ['command'],
- function() {
- var funcs = [];
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_damaged( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
- for (var i = 0; i < obj.selection_list.length; i++) {
- var barcode = obj.selection_list[i].barcode;
- funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
- }
- for (var i = 0; i < funcs.length; i++) { funcs[i](); }
- }
- ],
- 'sel_mark_items_missing' : [
- ['command'],
- function() {
- var funcs = [];
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_missing( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
- for (var i = 0; i < obj.selection_list.length; i++) {
- var barcode = obj.selection_list[i].barcode;
- funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
- }
- for (var i = 0; i < funcs.length; i++) { funcs[i](); }
- }
- ],
- 'sel_bucket' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.add_copies_to_bucket(obj.selection_list);
- }
- ],
- 'copy_status_barcode_entry_textbox' : [
- ['keypress'],
- function(ev) {
- if (ev.keyCode && ev.keyCode == 13) {
- obj.copy_status();
- }
- }
- ],
- 'cmd_broken' : [
- ['command'],
- function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
- ],
- 'cmd_copy_status_submit_barcode' : [
- ['command'],
- function() {
- obj.copy_status();
- }
- ],
- 'cmd_copy_status_upload_file' : [
- ['command'],
- function() {
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- JSAN.use('util.file');
- var f = new util.file('');
+ 'sel_checkin' : [
+ ['command'],
+ function() {
+ try {
+ var funcs = [];
+ JSAN.use('circ.util');
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ var barcode = obj.selection_list[i].barcode;
+ var checkin = circ.util.checkin_via_barcode( ses(), { 'barcode' : barcode } );
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
+ }
+ for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.sel_checkin.error'),E);
+ }
+ }
+ ],
+ 'cmd_replace_barcode' : [
+ ['command'],
+ function() {
+ try {
+ var funcs = [];
+ JSAN.use('cat.util');
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ try {
+ var barcode = obj.selection_list[i].barcode;
+ var new_bc = cat.util.replace_barcode( barcode );
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(new_bc) );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.cmd_replace_barcode.error', [barcode]), E);
+ }
+ }
+ for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.cmd_replace_barcodes.error'), E);
+ }
+ }
+ ],
+ 'sel_edit' : [
+ ['command'],
+ function() {
+ try {
+ var funcs = [];
+ obj.spawn_copy_editor();
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ var barcode = obj.selection_list[i].barcode;
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
+ }
+ for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.sel_edit.error'), E);
+ }
+ }
+ ],
+ 'sel_spine' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.spawn_spine_editor(obj.selection_list);
+ }
+ ],
+ 'sel_opac' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.show_in_opac(obj.selection_list);
+ }
+ ],
+ 'sel_transit_abort' : [
+ ['command'],
+ function() {
+ var funcs = [];
+ JSAN.use('circ.util');
+ circ.util.abort_transits(obj.selection_list);
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ var barcode = obj.selection_list[i].barcode;
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
+ }
+ for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ }
+ ],
+ 'sel_patron' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ circ.util.show_last_few_circs(obj.selection_list);
+ }
+ ],
+ 'sel_copy_details' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ circ.util.show_copy_details( obj.selection_list[i].copy_id );
+ }
+ }
+ ],
+ 'sel_renew' : [
+ ['command'],
+ function() {
+ var funcs = [];
+ JSAN.use('circ.util');
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ var test = obj.selection_list[i].renewable;
+ var barcode = obj.selection_list[i].barcode;
+ if (test == 't') {
+ circ.util.renew_via_barcode( { 'barcode' : barcode } );
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
+ } else {
+ alert(document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.sel_renew.not_circulating', [barcode]));
+ }
+ }
+ for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ }
+ ],
+
+ 'sel_mark_items_damaged' : [
+ ['command'],
+ function() {
+ var funcs = [];
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_damaged( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ var barcode = obj.selection_list[i].barcode;
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
+ }
+ for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ }
+ ],
+ 'sel_mark_items_missing' : [
+ ['command'],
+ function() {
+ var funcs = [];
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_missing( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ var barcode = obj.selection_list[i].barcode;
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
+ }
+ for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ }
+ ],
+ 'sel_bucket' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.add_copies_to_bucket(obj.selection_list);
+ }
+ ],
+ 'copy_status_barcode_entry_textbox' : [
+ ['keypress'],
+ function(ev) {
+ if (ev.keyCode && ev.keyCode == 13) {
+ obj.copy_status();
+ }
+ }
+ ],
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
+ ],
+ 'cmd_copy_status_submit_barcode' : [
+ ['command'],
+ function() {
+ obj.copy_status();
+ }
+ ],
+ 'cmd_copy_status_upload_file' : [
+ ['command'],
+ function() {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ JSAN.use('util.file');
+ var f = new util.file('');
var content = f.import_file( { 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.upload_file.title'), 'not_json' : true } );
if (!content) { return; }
- var barcodes = content.split(/[,\s]+/);
- if (barcodes.length > 0) {
- JSAN.use('util.exec'); var exec = new util.exec();
- var funcs = [];
- for (var i = 0; i < barcodes.length; i++) {
- funcs.push(
- function(b){
- return function() {
- obj.copy_status(b);
- };
- }(barcodes[i])
- );
- }
- funcs.push( function() { alert(document.getElementById('circStrings').getString('staff.circ.copy_status.upload_file.complete')); } );
- exec.chain( funcs );
- } else {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.upload_file.no_barcodes'));
- }
-
- }
- ],
- 'cmd_copy_status_print' : [
- ['command'],
- function() {
- try {
+ var barcodes = content.split(/[,\s]+/);
+ if (barcodes.length > 0) {
+ JSAN.use('util.exec'); var exec = new util.exec();
+ var funcs = [];
+ for (var i = 0; i < barcodes.length; i++) {
+ funcs.push(
+ function(b){
+ return function() {
+ obj.copy_status(b);
+ };
+ }(barcodes[i])
+ );
+ }
+ funcs.push( function() { alert(document.getElementById('circStrings').getString('staff.circ.copy_status.upload_file.complete')); } );
+ exec.chain( funcs );
+ } else {
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.upload_file.no_barcodes'));
+ }
+
+ }
+ ],
+ 'cmd_copy_status_print' : [
+ ['command'],
+ function() {
+ try {
var p = {
'template' : 'item_status'
};
- obj.list.print(p);
- } catch(E) {
- obj.error.standard_unexpected_error_alert('print',E);
- }
- }
- ],
- 'cmd_add_items' : [
- ['command'],
- function() {
- try {
-
- JSAN.use('util.functional');
- var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
- if (list.length == 0) { return; }
-
- var copy_shortcut = {}; var map_acn = {};
-
- for (var i = 0; i < list.length; i++) {
- var volume_id = list[i];
- if (volume_id == -1) {
- continue; /* ignore magic pre-cat volume */
- }
- if (! map_acn[volume_id]) {
- map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
- }
- var record_id = map_acn[ volume_id ].record();
- var ou_id = map_acn[ volume_id ].owning_lib();
- var label = map_acn[ volume_id ].label();
- if (!copy_shortcut[record_id]) {
- copy_shortcut[record_id] = {};
- }
- if (!copy_shortcut[record_id][ou_id]) {
- copy_shortcut[record_id][ou_id] = {};
- }
- copy_shortcut[record_id][ou_id][ label ] = volume_id;
-
- }
-
- for (var r in copy_shortcut) {
-
- /* quick fix */ /* what was this fixing? */
- list = []; for (var i in copy_shortcut[r]) { list.push( i ); }
-
- var edit = 0;
- try {
- edit = obj.network.request(
- api.PERM_MULTI_ORG_CHECK.app,
- api.PERM_MULTI_ORG_CHECK.method,
- [
- ses(),
- obj.data.list.au[0].id(),
- list,
- [ 'CREATE_COPY' ]
- ]
- ).length == 0 ? 1 : 0;
- } catch(E) {
- obj.error.sdump('D_ERROR','batch permission check: ' + E);
- }
-
- if (edit==0) {
- return; // no read-only view for this interface
- }
-
- var title = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.add_items.title', [r]);
-
- JSAN.use('util.window'); var win = new util.window();
- var w = win.open(
- window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
- //+'?doc_id=' + window.escape(r)
- //+'&ou_ids=' + window.escape( js2JSON(list) )
- //+'©_shortcut=' + window.escape( js2JSON(copy_shortcut[r]) ),
- title,
- 'chrome,resizable',
- { 'doc_id' : r, 'ou_ids' : list, 'copy_shortcut' : copy_shortcut[r] }
- );
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert('copy status -> add copies',E);
- }
- }
-
- ],
- 'cmd_delete_items' : [
- ['command'],
- function() {
- try {
+ obj.list.print(p);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('print',E);
+ }
+ }
+ ],
+ 'cmd_add_items' : [
+ ['command'],
+ function() {
+ try {
+
+ JSAN.use('util.functional');
+ var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
+ if (list.length == 0) { return; }
+
+ var copy_shortcut = {}; var map_acn = {};
+
+ for (var i = 0; i < list.length; i++) {
+ var volume_id = list[i];
+ if (volume_id == -1) {
+ continue; /* ignore magic pre-cat volume */
+ }
+ if (! map_acn[volume_id]) {
+ map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
+ }
+ var record_id = map_acn[ volume_id ].record();
+ var ou_id = map_acn[ volume_id ].owning_lib();
+ var label = map_acn[ volume_id ].label();
+ if (!copy_shortcut[record_id]) {
+ copy_shortcut[record_id] = {};
+ }
+ if (!copy_shortcut[record_id][ou_id]) {
+ copy_shortcut[record_id][ou_id] = {};
+ }
+ copy_shortcut[record_id][ou_id][ label ] = volume_id;
+
+ }
+
+ for (var r in copy_shortcut) {
+
+ /* quick fix */ /* what was this fixing? */
+ list = []; for (var i in copy_shortcut[r]) { list.push( i ); }
+
+ var edit = 0;
+ try {
+ edit = obj.network.request(
+ api.PERM_MULTI_ORG_CHECK.app,
+ api.PERM_MULTI_ORG_CHECK.method,
+ [
+ ses(),
+ obj.data.list.au[0].id(),
+ list,
+ [ 'CREATE_COPY' ]
+ ]
+ ).length == 0 ? 1 : 0;
+ } catch(E) {
+ obj.error.sdump('D_ERROR','batch permission check: ' + E);
+ }
+
+ if (edit==0) {
+ return; // no read-only view for this interface
+ }
+
+ var title = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.add_items.title', [r]);
+
+ JSAN.use('util.window'); var win = new util.window();
+ var w = win.open(
+ window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
+ //+'?doc_id=' + window.escape(r)
+ //+'&ou_ids=' + window.escape( js2JSON(list) )
+ //+'©_shortcut=' + window.escape( js2JSON(copy_shortcut[r]) ),
+ title,
+ 'chrome,resizable',
+ { 'doc_id' : r, 'ou_ids' : list, 'copy_shortcut' : copy_shortcut[r] }
+ );
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('copy status -> add copies',E);
+ }
+ }
+
+ ],
+ 'cmd_delete_items' : [
+ ['command'],
+ function() {
+ try {
JSAN.use('util.functional');
- var list = util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } );
+ var list = util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } );
var copies = util.functional.map_list(
list,
copies[i].isdeleted(1);
}
- if (! window.confirm(document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.del_items.confirm', [util.functional.map_list( copies, function(o) { return o.barcode(); }).join(", ")]))) {
- return;
- }
+ if (! window.confirm(document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.del_items.confirm', [util.functional.map_list( copies, function(o) { return o.barcode(); }).join(", ")]))) {
+ return;
+ }
var robj = obj.network.simple_request('FM_ACP_FLESHED_BATCH_UPDATE',[ ses(), copies, true]);
- var robj = obj.network.simple_request(
- 'FM_ACP_FLESHED_BATCH_UPDATE',
- [ ses(), copies, true ],
- null,
- {
- 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.del_items.title'),
- 'overridable_events' : [
- 1208 /* TITLE_LAST_COPY */,
- 1227 /* COPY_DELETE_WARNING */
- ]
- }
- );
-
+ var robj = obj.network.simple_request(
+ 'FM_ACP_FLESHED_BATCH_UPDATE',
+ [ ses(), copies, true ],
+ null,
+ {
+ 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.del_items.title'),
+ 'overridable_events' : [
+ 1208 /* TITLE_LAST_COPY */,
+ 1227 /* COPY_DELETE_WARNING */
+ ]
+ }
+ );
+
if (typeof robj.ilsevent != 'undefined') {
- switch(Number(robj.ilsevent)) {
- case 1208 /* TITLE_LAST_COPY */:
- case 1227 /* COPY_DELETE_WARNING */:
- break;
- default:
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.del_items.success.error'), robj);
- break;
- }
- } else { alert(document.getElementById('circStrings').getString('staff.circ.copy_status.del_items.success')); }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert('copy status -> delete items',E);
- }
- }
- ],
- 'cmd_transfer_items' : [
- ['command'],
- function() {
- try {
- obj.data.stash_retrieve();
- if (!obj.data.marked_volume) {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_items.mark_destination'));
- return;
- }
-
- JSAN.use('util.functional');
-
- var list = util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } );
-
- var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
-
- JSAN.use('cat.util'); cat.util.transfer_copies( {
- 'copy_ids' : list,
- 'docid' : volume.record(),
- 'volume_label' : volume.label(),
- 'owning_lib' : volume.owning_lib()
- } );
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_items.problem'), E);
- }
- }
-
- ],
- 'cmd_add_volumes' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
- var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
- if (list.length == 0) { return; }
-
- var aou_hash = {}; var map_acn = {};
-
- for (var i = 0; i < list.length; i++) {
- var volume_id = list[i];
- if (volume_id == -1) {
- continue; /* ignore magic pre-cat volume */
- }
- if (! map_acn[volume_id]) {
- map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
- }
- var record_id = map_acn[ volume_id ].record();
- var ou_id = map_acn[ volume_id ].owning_lib();
- var label = map_acn[ volume_id ].label();
- if (!aou_hash[record_id]) aou_hash[record_id] = {};
- aou_hash[record_id][ou_id] = 1;
-
- }
-
- for (var r in aou_hash) {
-
- list = []; for (var org in aou_hash[r]) list.push(org);
-
- var edit = 0;
- try {
- edit = obj.network.request(
- api.PERM_MULTI_ORG_CHECK.app,
- api.PERM_MULTI_ORG_CHECK.method,
- [
- ses(),
- obj.data.list.au[0].id(),
- list,
- [ 'CREATE_VOLUME', 'CREATE_COPY' ]
- ]
- ).length == 0 ? 1 : 0;
- } catch(E) {
- obj.error.sdump('D_ERROR','batch permission check: ' + E);
- }
-
- if (edit==0) {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
- return; // no read-only view for this interface
- }
-
- var title = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [r]);
-
- JSAN.use('util.window'); var win = new util.window();
- var w = win.open(
- window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
- //+'?doc_id=' + window.escape(r)
- //+'&ou_ids=' + window.escape( js2JSON(list) ),
- title,
- 'chrome,resizable',
- { 'doc_id' : r, 'ou_ids' : list }
- );
-
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert('copy status -> add volumes',E);
- }
- }
-
- ],
- 'cmd_edit_volumes' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
- var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
- if (list.length == 0) { return; }
-
- var volume_hash = {}; var map_acn = {};
-
- for (var i = 0; i < list.length; i++) {
- var volume_id = list[i];
- if (volume_id == -1) {
- continue; /* ignore magic pre-cat volume */
- }
- if (! map_acn[volume_id]) {
- map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
- map_acn[ volume_id ].copies( [] );
- }
- var record_id = map_acn[ volume_id ].record();
- if (!volume_hash[record_id]) {
- volume_hash[record_id] = {};
- }
- volume_hash[record_id][volume_id] = 1;
- }
-
- for (var rec in volume_hash) {
-
- list = [];
- for (var v in volume_hash[rec]) {
- list.push( map_acn[v] );
- }
-
- var edit = 0;
- try {
- edit = obj.network.request(
- api.PERM_MULTI_ORG_CHECK.app,
- api.PERM_MULTI_ORG_CHECK.method,
- [
- ses(),
- obj.data.list.au[0].id(),
- util.functional.map_list(
- list,
- function (o) {
- return o.owning_lib();
- }
- ),
- [ 'UPDATE_VOLUME' ]
- ]
- ).length == 0 ? 1 : 0;
- } catch(E) {
- obj.error.sdump('D_ERROR','batch permission check: ' + E);
- }
-
- if (edit==0) {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.edit_volumes.perm_failure'));
- return; // no read-only view for this interface
- }
-
- var title;
- if (list.length == 1) {
- title = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.edit_volume.title', [rec]);
- } else {
- title = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.edit_volumes.title', [rec]);
- }
-
- JSAN.use('util.window'); var win = new util.window();
- //obj.data.volumes_temp = js2JSON( list );
- //obj.data.stash('volumes_temp');
- var my_xulG = win.open(
- window.xulG.url_prefix(urls.XUL_VOLUME_EDITOR),
- title,
- 'chrome,modal,resizable',
- { 'volumes' : JSON2js(js2JSON(list)) }
- );
-
- /* FIXME -- need to unique the temp space, and not rely on modalness of window */
- //obj.data.stash_retrieve();
- //var volumes = JSON2js( obj.data.volumes_temp );
+ switch(Number(robj.ilsevent)) {
+ case 1208 /* TITLE_LAST_COPY */:
+ case 1227 /* COPY_DELETE_WARNING */:
+ break;
+ default:
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.del_items.success.error'), robj);
+ break;
+ }
+ } else { alert(document.getElementById('circStrings').getString('staff.circ.copy_status.del_items.success')); }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('copy status -> delete items',E);
+ }
+ }
+ ],
+ 'cmd_transfer_items' : [
+ ['command'],
+ function() {
+ try {
+ obj.data.stash_retrieve();
+ if (!obj.data.marked_volume) {
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_items.mark_destination'));
+ return;
+ }
+
+ JSAN.use('util.functional');
+
+ var list = util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } );
+
+ var volume = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ obj.data.marked_volume ]);
+
+ JSAN.use('cat.util'); cat.util.transfer_copies( {
+ 'copy_ids' : list,
+ 'docid' : volume.record(),
+ 'volume_label' : volume.label(),
+ 'owning_lib' : volume.owning_lib()
+ } );
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_items.problem'), E);
+ }
+ }
+
+ ],
+ 'cmd_add_volumes' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
+ if (list.length == 0) { return; }
+
+ var aou_hash = {}; var map_acn = {};
+
+ for (var i = 0; i < list.length; i++) {
+ var volume_id = list[i];
+ if (volume_id == -1) {
+ continue; /* ignore magic pre-cat volume */
+ }
+ if (! map_acn[volume_id]) {
+ map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
+ }
+ var record_id = map_acn[ volume_id ].record();
+ var ou_id = map_acn[ volume_id ].owning_lib();
+ var label = map_acn[ volume_id ].label();
+ if (!aou_hash[record_id]) aou_hash[record_id] = {};
+ aou_hash[record_id][ou_id] = 1;
+
+ }
+
+ for (var r in aou_hash) {
+
+ list = []; for (var org in aou_hash[r]) list.push(org);
+
+ var edit = 0;
+ try {
+ edit = obj.network.request(
+ api.PERM_MULTI_ORG_CHECK.app,
+ api.PERM_MULTI_ORG_CHECK.method,
+ [
+ ses(),
+ obj.data.list.au[0].id(),
+ list,
+ [ 'CREATE_VOLUME', 'CREATE_COPY' ]
+ ]
+ ).length == 0 ? 1 : 0;
+ } catch(E) {
+ obj.error.sdump('D_ERROR','batch permission check: ' + E);
+ }
+
+ if (edit==0) {
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.add_volumes.perm_failure'));
+ return; // no read-only view for this interface
+ }
+
+ var title = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.add_volumes.title', [r]);
+
+ JSAN.use('util.window'); var win = new util.window();
+ var w = win.open(
+ window.xulG.url_prefix(urls.XUL_VOLUME_COPY_CREATOR),
+ //+'?doc_id=' + window.escape(r)
+ //+'&ou_ids=' + window.escape( js2JSON(list) ),
+ title,
+ 'chrome,resizable',
+ { 'doc_id' : r, 'ou_ids' : list }
+ );
+
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('copy status -> add volumes',E);
+ }
+ }
+
+ ],
+ 'cmd_edit_volumes' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
+ if (list.length == 0) { return; }
+
+ var volume_hash = {}; var map_acn = {};
+
+ for (var i = 0; i < list.length; i++) {
+ var volume_id = list[i];
+ if (volume_id == -1) {
+ continue; /* ignore magic pre-cat volume */
+ }
+ if (! map_acn[volume_id]) {
+ map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
+ map_acn[ volume_id ].copies( [] );
+ }
+ var record_id = map_acn[ volume_id ].record();
+ if (!volume_hash[record_id]) {
+ volume_hash[record_id] = {};
+ }
+ volume_hash[record_id][volume_id] = 1;
+ }
+
+ for (var rec in volume_hash) {
+
+ list = [];
+ for (var v in volume_hash[rec]) {
+ list.push( map_acn[v] );
+ }
+
+ var edit = 0;
+ try {
+ edit = obj.network.request(
+ api.PERM_MULTI_ORG_CHECK.app,
+ api.PERM_MULTI_ORG_CHECK.method,
+ [
+ ses(),
+ obj.data.list.au[0].id(),
+ util.functional.map_list(
+ list,
+ function (o) {
+ return o.owning_lib();
+ }
+ ),
+ [ 'UPDATE_VOLUME' ]
+ ]
+ ).length == 0 ? 1 : 0;
+ } catch(E) {
+ obj.error.sdump('D_ERROR','batch permission check: ' + E);
+ }
+
+ if (edit==0) {
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.edit_volumes.perm_failure'));
+ return; // no read-only view for this interface
+ }
+
+ var title;
+ if (list.length == 1) {
+ title = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.edit_volume.title', [rec]);
+ } else {
+ title = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.edit_volumes.title', [rec]);
+ }
+
+ JSAN.use('util.window'); var win = new util.window();
+ //obj.data.volumes_temp = js2JSON( list );
+ //obj.data.stash('volumes_temp');
+ var my_xulG = win.open(
+ window.xulG.url_prefix(urls.XUL_VOLUME_EDITOR),
+ title,
+ 'chrome,modal,resizable',
+ { 'volumes' : JSON2js(js2JSON(list)) }
+ );
+
+ /* FIXME -- need to unique the temp space, and not rely on modalness of window */
+ //obj.data.stash_retrieve();
+ //var volumes = JSON2js( obj.data.volumes_temp );
if (typeof my_xulG.update_these_volumes == 'undefined') { return; }
- var volumes = my_xulG.volumes;
- if (!volumes) { return; }
-
- volumes = util.functional.filter_list(
- volumes,
- function (o) {
- return o.ischanged() == '1';
- }
- );
-
- volumes = util.functional.map_list(
- volumes,
- function (o) {
- o.record( rec ); // staff client 2 did not do this. Does it matter?
- return o;
- }
- );
-
- if (volumes.length == 0) { return; }
-
- try {
- var r = obj.network.request(
- api.FM_ACN_TREE_UPDATE.app,
- api.FM_ACN_TREE_UPDATE.method,
- [ ses(), volumes, false ]
- );
+ var volumes = my_xulG.volumes;
+ if (!volumes) { return; }
+
+ volumes = util.functional.filter_list(
+ volumes,
+ function (o) {
+ return o.ischanged() == '1';
+ }
+ );
+
+ volumes = util.functional.map_list(
+ volumes,
+ function (o) {
+ o.record( rec ); // staff client 2 did not do this. Does it matter?
+ return o;
+ }
+ );
+
+ if (volumes.length == 0) { return; }
+
+ try {
+ var r = obj.network.request(
+ api.FM_ACN_TREE_UPDATE.app,
+ api.FM_ACN_TREE_UPDATE.method,
+ [ ses(), volumes, false ]
+ );
if (typeof r.ilsevent != 'undefined') {
switch(Number(r.ilsevent)) {
case 1705 /* VOLUME_LABEL_EXISTS */ :
default: throw(r);
}
} else {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.edit_volumes.success'));
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.edit_volumes.success'));
}
- } catch(E) {
- obj.error.standard_unexpected_error_alert('volume update error: ',E);
- }
-
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('Copy Status -> Volume Edit',E);
- }
- }
-
- ],
- 'cmd_delete_volumes' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
- var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
- if (list.length == 0) { return; }
-
- var map_acn = {};
-
- for (var i = 0; i < list.length; i++) {
- var volume_id = list[i];
- if (volume_id == -1) {
- continue; /* ignore magic pre-cat volume */
- }
- if (! map_acn[volume_id]) {
- map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
- }
- }
-
- list = [];
- for (var v in map_acn) {
- list.push( map_acn[v] );
- }
-
- var confirm_prompt;
- if (list.length == 1) {
- confirm_prompt = document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.singular');
- } else {
- confirm_prompt = document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.plural');
- }
-
- var r = obj.error.yns_alert(
- confirm_prompt,
- document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.title'),
- document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete'),
- document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.cancel'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm')
- );
-
- if (r == 0) {
- for (var i = 0; i < list.length; i++) {
- list[i].isdeleted('1');
- }
- var robj = obj.network.simple_request(
- 'FM_ACN_TREE_UPDATE',
- [ ses(), list, true ],
- null,
- {
- 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.override'),
- 'overridable_events' : [
- ]
- }
- );
- if (robj == null) throw(robj);
- if (typeof robj.ilsevent != 'undefined') {
- if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies'));
- return;
- }
- if (robj.ilsevent != 0) { throw(robj); }
- }
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.success'));
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('copy status -> delete volumes',E);
- }
-
- }
-
- ],
- 'cmd_mark_volume' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
- var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
-
- if (list.length == 1) {
- obj.data.marked_volume = list[0];
- obj.data.stash('marked_volume');
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.mark_volume.status'));
- } else {
- obj.error.yns_alert(
- document.getElementById('circStrings').getString('staff.circ.copy_status.mark_volume.prompt'),
- document.getElementById('circStrings').getString('staff.circ.copy_status.mark_volume.title'),
- document.getElementById('circStrings').getString('staff.circ.copy_status.ok'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm')
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('copy status -> mark volume',E);
- }
- }
- ],
- 'cmd_mark_library' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
- var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
-
- if (list.length == 1) {
- var v = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[list[0]]);
- var owning_lib = v.owning_lib();
- if (typeof owning_lib == 'object') {
- owning_lib = owning_lib.id();
- }
-
- obj.data.marked_library = { 'lib' : owning_lib, 'docid' : v.record() };
- obj.data.stash('marked_library');
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.mark_library'));
- } else {
- obj.error.yns_alert(
- document.getElementById('circStrings').getString('staff.circ.copy_status.mark_library.limit_one'),
- document.getElementById('circStrings').getString('staff.circ.copy_status.mark_library.limit_one.title'),
- document.getElementById('circStrings').getString('staff.circ.copy_status.ok'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm')
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('copy status -> mark library',E);
- }
- }
- ],
- 'cmd_transfer_volume' : [
- ['command'],
- function() {
- try {
- obj.data.stash_retrieve();
- if (!obj.data.marked_library) {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.none'));
- return;
- }
-
- JSAN.use('util.functional');
-
- var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
- if (list.length == 0) { return; }
-
- var map_acn = {};
-
- for (var i = 0; i < list.length; i++) {
- var volume_id = list[i];
- if (volume_id == -1) {
- continue; /* ignore magic pre-cat volume */
- }
- if (! map_acn[volume_id]) {
- map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
- }
- }
-
- list = [];
- for (v in map_acn) {
- list.push(map_acn[v]);
- }
-
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
- xml += '<description>';
-
- var vols = util.functional.map_list(list,
- function (o) {
- return o.label();
- }
- ).join(", ");
-
- var volume_list = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.transfer_volume.confirm',
- [vols, obj.data.hash.aou[ obj.data.marked_library.lib ].shortname()]);
-
- xml += volume_list;
- xml += '</description>';
- xml += '<hbox><button label="';
- xml += document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.transfer.label');
- xml += '" name="fancy_submit"/>';
- xml += '<button label="';
- xml += document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.cancel.label');
- xml += '" accesskey="';
- xml += document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.cancel.accesskey');
- xml += '" name="fancy_cancel"/></hbox>';
- xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
- xml += '</vbox>';
- JSAN.use('OpenILS.data');
- //var data = new OpenILS.data(); data.init({'via':'stash'});
- //data.temp_transfer = xml; data.stash('temp_transfer');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_transfer'
- //+ '&title=' + window.escape('Volume Transfer'),
- 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
- { 'xml' : xml, 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.title') }
- );
-
- if (fancy_prompt_data.fancy_status == 'incomplete') {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.aborted'));
- return;
- }
-
- var robj = obj.network.simple_request(
- 'FM_ACN_TRANSFER',
- [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : util.functional.map_list( list, function(o) { return o.id(); }) } ],
- null,
- {
- 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.override_failure'),
- 'overridable_events' : [
- 1208 /* TITLE_LAST_COPY */,
- 1219 /* COPY_REMOTE_CIRC_LIB */
- ]
- }
- );
-
- if (typeof robj.ilsevent != 'undefined') {
- if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.cannot_have_vols'));
- } else {
- throw(robj);
- }
- } else {
- alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.success'));
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.error'),E);
- }
- }
-
- ]
- }
- }
- );
- this.controller.render();
- this.controller.view.copy_status_barcode_entry_textbox.focus();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('volume update error: ',E);
+ }
+
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Copy Status -> Volume Edit',E);
+ }
+ }
+
+ ],
+ 'cmd_delete_volumes' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
+ if (list.length == 0) { return; }
+
+ var map_acn = {};
+
+ for (var i = 0; i < list.length; i++) {
+ var volume_id = list[i];
+ if (volume_id == -1) {
+ continue; /* ignore magic pre-cat volume */
+ }
+ if (! map_acn[volume_id]) {
+ map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
+ }
+ }
+
+ list = [];
+ for (var v in map_acn) {
+ list.push( map_acn[v] );
+ }
+
+ var confirm_prompt;
+ if (list.length == 1) {
+ confirm_prompt = document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.singular');
+ } else {
+ confirm_prompt = document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.plural');
+ }
+
+ var r = obj.error.yns_alert(
+ confirm_prompt,
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.title'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.cancel'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm')
+ );
+
+ if (r == 0) {
+ for (var i = 0; i < list.length; i++) {
+ list[i].isdeleted('1');
+ }
+ var robj = obj.network.simple_request(
+ 'FM_ACN_TREE_UPDATE',
+ [ ses(), list, true ],
+ null,
+ {
+ 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.override'),
+ 'overridable_events' : [
+ ]
+ }
+ );
+ if (robj == null) throw(robj);
+ if (typeof robj.ilsevent != 'undefined') {
+ if (robj.ilsevent == 1206 /* VOLUME_NOT_EMPTY */) {
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.delete_copies'));
+ return;
+ }
+ if (robj.ilsevent != 0) { throw(robj); }
+ }
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.delete_volumes.success'));
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('copy status -> delete volumes',E);
+ }
+
+ }
+
+ ],
+ 'cmd_mark_volume' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
+
+ if (list.length == 1) {
+ obj.data.marked_volume = list[0];
+ obj.data.stash('marked_volume');
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.mark_volume.status'));
+ } else {
+ obj.error.yns_alert(
+ document.getElementById('circStrings').getString('staff.circ.copy_status.mark_volume.prompt'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.mark_volume.title'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.ok'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm')
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('copy status -> mark volume',E);
+ }
+ }
+ ],
+ 'cmd_mark_library' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
+
+ if (list.length == 1) {
+ var v = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[list[0]]);
+ var owning_lib = v.owning_lib();
+ if (typeof owning_lib == 'object') {
+ owning_lib = owning_lib.id();
+ }
+
+ obj.data.marked_library = { 'lib' : owning_lib, 'docid' : v.record() };
+ obj.data.stash('marked_library');
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.mark_library'));
+ } else {
+ obj.error.yns_alert(
+ document.getElementById('circStrings').getString('staff.circ.copy_status.mark_library.limit_one'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.mark_library.limit_one.title'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.ok'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm')
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('copy status -> mark library',E);
+ }
+ }
+ ],
+ 'cmd_transfer_volume' : [
+ ['command'],
+ function() {
+ try {
+ obj.data.stash_retrieve();
+ if (!obj.data.marked_library) {
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.none'));
+ return;
+ }
+
+ JSAN.use('util.functional');
+
+ var list = util.functional.map_list( obj.selection_list, function(o) { return o.acn_id; } );
+ if (list.length == 0) { return; }
+
+ var map_acn = {};
+
+ for (var i = 0; i < list.length; i++) {
+ var volume_id = list[i];
+ if (volume_id == -1) {
+ continue; /* ignore magic pre-cat volume */
+ }
+ if (! map_acn[volume_id]) {
+ map_acn[ volume_id ] = obj.network.simple_request('FM_ACN_RETRIEVE.authoritative',[ volume_id ]);
+ }
+ }
+
+ list = [];
+ for (v in map_acn) {
+ list.push(map_acn[v]);
+ }
+
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: auto">';
+ xml += '<description>';
+
+ var vols = util.functional.map_list(list,
+ function (o) {
+ return o.label();
+ }
+ ).join(", ");
+
+ var volume_list = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.transfer_volume.confirm',
+ [vols, obj.data.hash.aou[ obj.data.marked_library.lib ].shortname()]);
+
+ xml += volume_list;
+ xml += '</description>';
+ xml += '<hbox><button label="';
+ xml += document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.transfer.label');
+ xml += '" name="fancy_submit"/>';
+ xml += '<button label="';
+ xml += document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.cancel.label');
+ xml += '" accesskey="';
+ xml += document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.cancel.accesskey');
+ xml += '" name="fancy_cancel"/></hbox>';
+ xml += '<iframe style="overflow: scroll" flex="1" src="' + urls.XUL_BIB_BRIEF + '?docid=' + obj.data.marked_library.docid + '"/>';
+ xml += '</vbox>';
+ JSAN.use('OpenILS.data');
+ //var data = new OpenILS.data(); data.init({'via':'stash'});
+ //data.temp_transfer = xml; data.stash('temp_transfer');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_transfer'
+ //+ '&title=' + window.escape('Volume Transfer'),
+ 'fancy_prompt', 'chrome,resizable,modal,width=500,height=300',
+ { 'xml' : xml, 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.title') }
+ );
+
+ if (fancy_prompt_data.fancy_status == 'incomplete') {
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.aborted'));
+ return;
+ }
+
+ var robj = obj.network.simple_request(
+ 'FM_ACN_TRANSFER',
+ [ ses(), { 'docid' : obj.data.marked_library.docid, 'lib' : obj.data.marked_library.lib, 'volumes' : util.functional.map_list( list, function(o) { return o.id(); }) } ],
+ null,
+ {
+ 'title' : document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.override_failure'),
+ 'overridable_events' : [
+ 1208 /* TITLE_LAST_COPY */,
+ 1219 /* COPY_REMOTE_CIRC_LIB */
+ ]
+ }
+ );
+
+ if (typeof robj.ilsevent != 'undefined') {
+ if (robj.ilsevent == 1221 /* ORG_CANNOT_HAVE_VOLS */) {
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.cannot_have_vols'));
+ } else {
+ throw(robj);
+ }
+ } else {
+ alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.success'));
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.copy_status.transfer_volume.error'),E);
+ }
+ }
+
+ ]
+ }
+ }
+ );
+ this.controller.render();
+ this.controller.view.copy_status_barcode_entry_textbox.focus();
JSAN.use('util.browser');
obj.browser = new util.browser();
}
);
- },
-
- 'test_barcode' : function(bc) {
- var obj = this;
- var good = util.barcode.check(bc);
- var x = document.getElementById('strict_barcode');
- if (x && x.checked != true) { return true; }
- if (good) {
- return true;
- } else {
- if ( 1 == obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
- document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
- document.getElementById('circStrings').getString('staff.circ.cancel'),
- document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm'),
- '/xul/server/skin/media/images/bad_barcode.png'
- ) ) {
- return true;
- } else {
- return false;
- }
- }
- },
-
- 'copy_status' : function(barcode,refresh) {
- var obj = this;
- try {
- try { document.getElementById('last_scanned').setAttribute('value',''); } catch(E) {}
- if (!barcode) {
- barcode = obj.controller.view.copy_status_barcode_entry_textbox.value;
- }
- if (!barcode) { return; }
- if (barcode) {
- if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
- }
- JSAN.use('circ.util');
- function handle_req(req) {
- try {
- var details = req.getResultObject();
- if (details == null) {
- throw(document.getElementById('circStrings').getString('staff.circ.copy_status.status.null_result'));
- } else if (details.ilsevent) {
- switch(Number(details.ilsevent)) {
- case -1:
- obj.error.standard_network_error_alert();
- obj.controller.view.copy_status_barcode_entry_textbox.select();
- obj.controller.view.copy_status_barcode_entry_textbox.focus();
- return;
- break;
- case 1502 /* ASSET_COPY_NOT_FOUND */ :
- try { document.getElementById('last_scanned').setAttribute('value', document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [barcode])); } catch(E) {}
- obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [barcode]),
- document.getElementById('circStrings').getString('staff.circ.copy_status.status.not_cataloged'),
- document.getElementById('circStrings').getString('staff.circ.copy_status.ok'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- obj.controller.view.copy_status_barcode_entry_textbox.select();
- obj.controller.view.copy_status_barcode_entry_textbox.focus();
- return;
- break;
- default:
- throw(details);
- break;
- }
- }
- var msg = details.copy.barcode() + ' -- ';
- if (details.copy.call_number() == -1) {
- msg += document.getElementById('circStrings').getString('staff.circ.copy_status.status.pre_cat') + ' ';
- }
- if (details.hold) {
- msg += document.getElementById('circStrings').getString('staff.circ.copy_status.status.hold') + ' ';
- }
- if (details.transit) {
- msg += document.getElementById('circStrings').getString('staff.circ.copy_status.status.transit') + ' ';
- }
- if (details.circ && ! details.circ.checkin_time()) {
- msg += document.getElementById('circStrings').getString('staff.circ.copy_status.status.circ') + ' ';
- }
- try { document.getElementById('last_scanned').setAttribute('value',msg); } catch(E) {}
- if (document.getElementById('trim_list')) {
- var x = document.getElementById('trim_list');
- if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
- }
- var params = {
- 'retrieve_id' : js2JSON(
- {
- 'renewable' : details.circ ? 't' : 'f',
- 'copy_id' : details.copy.id(),
- 'acn_id' : details.volume ? details.volume.id() : -1,
- 'barcode' : barcode,
- 'doc_id' : details.mvr ? details.mvr.doc_id() : null
- }
- ),
- 'row' : {
- 'my' : {
- 'mvr' : details.mvr,
- 'acp' : details.copy,
- 'acn' : details.volume,
- 'atc' : details.transit,
- 'circ' : details.circ,
- 'ahr' : details.hold
- }
- },
- 'to_top' : true
- };
- if (!refresh) {
- var nparams = obj.list.append(params);
- if (!document.getElementById('trim_list').checked) {
- if (typeof obj.list_copyid_map[details.copy.id()] == 'undefined') obj.list_copyid_map[details.copy.id()] =[];
- obj.list_copyid_map[details.copy.id()].push(nparams);
- }
- } else {
- if (!document.getElementById('trim_list').checked) {
+ },
+
+ 'test_barcode' : function(bc) {
+ var obj = this;
+ var good = util.barcode.check(bc);
+ var x = document.getElementById('strict_barcode');
+ if (x && x.checked != true) { return true; }
+ if (good) {
+ return true;
+ } else {
+ if ( 1 == obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
+ document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
+ document.getElementById('circStrings').getString('staff.circ.cancel'),
+ document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm'),
+ '/xul/server/skin/media/images/bad_barcode.png'
+ ) ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ },
+
+ 'copy_status' : function(barcode,refresh) {
+ var obj = this;
+ try {
+ try { document.getElementById('last_scanned').setAttribute('value',''); } catch(E) {}
+ if (!barcode) {
+ barcode = obj.controller.view.copy_status_barcode_entry_textbox.value;
+ }
+ if (!barcode) { return; }
+ if (barcode) {
+ if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
+ }
+ JSAN.use('circ.util');
+ function handle_req(req) {
+ try {
+ var details = req.getResultObject();
+ if (details == null) {
+ throw(document.getElementById('circStrings').getString('staff.circ.copy_status.status.null_result'));
+ } else if (details.ilsevent) {
+ switch(Number(details.ilsevent)) {
+ case -1:
+ obj.error.standard_network_error_alert();
+ obj.controller.view.copy_status_barcode_entry_textbox.select();
+ obj.controller.view.copy_status_barcode_entry_textbox.focus();
+ return;
+ break;
+ case 1502 /* ASSET_COPY_NOT_FOUND */ :
+ try { document.getElementById('last_scanned').setAttribute('value', document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [barcode])); } catch(E) {}
+ obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [barcode]),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.status.not_cataloged'),
+ document.getElementById('circStrings').getString('staff.circ.copy_status.ok'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ obj.controller.view.copy_status_barcode_entry_textbox.select();
+ obj.controller.view.copy_status_barcode_entry_textbox.focus();
+ return;
+ break;
+ default:
+ throw(details);
+ break;
+ }
+ }
+ var msg = details.copy.barcode() + ' -- ';
+ if (details.copy.call_number() == -1) {
+ msg += document.getElementById('circStrings').getString('staff.circ.copy_status.status.pre_cat') + ' ';
+ }
+ if (details.hold) {
+ msg += document.getElementById('circStrings').getString('staff.circ.copy_status.status.hold') + ' ';
+ }
+ if (details.transit) {
+ msg += document.getElementById('circStrings').getString('staff.circ.copy_status.status.transit') + ' ';
+ }
+ if (details.circ && ! details.circ.checkin_time()) {
+ msg += document.getElementById('circStrings').getString('staff.circ.copy_status.status.circ') + ' ';
+ }
+ try { document.getElementById('last_scanned').setAttribute('value',msg); } catch(E) {}
+ if (document.getElementById('trim_list')) {
+ var x = document.getElementById('trim_list');
+ if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
+ }
+ var params = {
+ 'retrieve_id' : js2JSON(
+ {
+ 'renewable' : details.circ ? 't' : 'f',
+ 'copy_id' : details.copy.id(),
+ 'acn_id' : details.volume ? details.volume.id() : -1,
+ 'barcode' : barcode,
+ 'doc_id' : details.mvr ? details.mvr.doc_id() : null
+ }
+ ),
+ 'row' : {
+ 'my' : {
+ 'mvr' : details.mvr,
+ 'acp' : details.copy,
+ 'acn' : details.volume,
+ 'atc' : details.transit,
+ 'circ' : details.circ,
+ 'ahr' : details.hold
+ }
+ },
+ 'to_top' : true
+ };
+ if (!refresh) {
+ var nparams = obj.list.append(params);
+ if (!document.getElementById('trim_list').checked) {
+ if (typeof obj.list_copyid_map[details.copy.id()] == 'undefined') obj.list_copyid_map[details.copy.id()] =[];
+ obj.list_copyid_map[details.copy.id()].push(nparams);
+ }
+ } else {
+ if (!document.getElementById('trim_list').checked) {
if (typeof obj.list_copyid_map[details.copy.id()] != 'undefined') {
for (var i = 0; i < obj.list_copyid_map[details.copy.id()].length; i++) {
if (typeof obj.list_copyid_map[details.copy.id()][i] == 'undefined') {
}
}
} else {
- obj.list.append(params);
+ obj.list.append(params);
}
- } else {
- obj.list.append(params);
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('barcode = ' + barcode,E);
- }
- }
- var result = obj.network.simple_request('FM_ACP_DETAILS_VIA_BARCODE.authoritative', [ ses(), barcode ]);
- handle_req({'getResultObject':function(){return result;}}); // used to be async
+ } else {
+ obj.list.append(params);
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('barcode = ' + barcode,E);
+ }
+ }
+ var result = obj.network.simple_request('FM_ACP_DETAILS_VIA_BARCODE.authoritative', [ ses(), barcode ]);
+ handle_req({'getResultObject':function(){return result;}}); // used to be async
if (result.copy && document.getElementById('deck').selectedIndex == 1) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var f = obj.browser.get_content();
alert('hrmm');
}
}
- obj.controller.view.copy_status_barcode_entry_textbox.value = '';
- obj.controller.view.copy_status_barcode_entry_textbox.focus();
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert('barcode = ' + barcode,E);
- obj.controller.view.copy_status_barcode_entry_textbox.select();
- obj.controller.view.copy_status_barcode_entry_textbox.focus();
- }
+ obj.controller.view.copy_status_barcode_entry_textbox.value = '';
+ obj.controller.view.copy_status_barcode_entry_textbox.focus();
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('barcode = ' + barcode,E);
+ obj.controller.view.copy_status_barcode_entry_textbox.select();
+ obj.controller.view.copy_status_barcode_entry_textbox.focus();
+ }
- },
-
- 'spawn_copy_editor' : function() {
+ },
+
+ 'spawn_copy_editor' : function() {
- var obj = this;
+ var obj = this;
- JSAN.use('util.functional');
+ JSAN.use('util.functional');
- var list = obj.selection_list;
+ var list = obj.selection_list;
- list = util.functional.map_list(
- list,
- function (o) {
- return o.copy_id;
- }
- );
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.copy_id;
+ }
+ );
- JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
+ JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
- },
+ },
}
if (typeof circ == 'undefined') circ = {};
circ.in_house_use = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- JSAN.use('util.barcode');
- JSAN.use('util.date');
- JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('util.barcode');
+ JSAN.use('util.date');
+ JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
}
circ.in_house_use.prototype = {
- 'init' : function( params ) {
+ 'init' : function( params ) {
- var obj = this;
+ var obj = this;
- JSAN.use('circ.util');
- var columns = circ.util.columns(
- {
- 'barcode' : { 'hidden' : false },
- 'title' : { 'hidden' : false },
- 'status' : { 'hidden' : false },
- 'location' : { 'hidden' : false },
- 'call_number' : { 'hidden' : false },
- 'uses' : { 'hidden' : false }
- }
- );
+ JSAN.use('circ.util');
+ var columns = circ.util.columns(
+ {
+ 'barcode' : { 'hidden' : false },
+ 'title' : { 'hidden' : false },
+ 'status' : { 'hidden' : false },
+ 'location' : { 'hidden' : false },
+ 'call_number' : { 'hidden' : false },
+ 'uses' : { 'hidden' : false }
+ }
+ );
- JSAN.use('util.list'); obj.list = new util.list('in_house_use_list');
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
- 'on_select' : function() {
- var sel = obj.list.retrieve_selection();
- obj.controller.view.sel_clip.setAttribute('disabled', sel.length < 1);
- }
- }
- );
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
- 'sel_clip' : [
- ['command'],
- function() {
- obj.list.clipboard();
- obj.controller.view.in_house_use_barcode_entry_textbox.focus();
- }
- ],
- 'in_house_use_menu_placeholder' : [
- ['render'],
- function(e) {
- return function() {
- JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
- var items = [ [ document.getElementById('circStrings').getString('staff.circ.in_house_use.barcode') , 'barcode' ] ].concat(
- util.functional.map_list(
- util.functional.filter_list(
- obj.data.list.my_cnct,
- function(o) {
- return util.fm_utils.compare_aou_a_is_b_or_ancestor(o.owning_lib(), obj.data.list.au[0].ws_ou());
- }
- ).sort(
+ JSAN.use('util.list'); obj.list = new util.list('in_house_use_list');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'on_select' : function() {
+ var sel = obj.list.retrieve_selection();
+ obj.controller.view.sel_clip.setAttribute('disabled', sel.length < 1);
+ }
+ }
+ );
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
+ 'sel_clip' : [
+ ['command'],
+ function() {
+ obj.list.clipboard();
+ obj.controller.view.in_house_use_barcode_entry_textbox.focus();
+ }
+ ],
+ 'in_house_use_menu_placeholder' : [
+ ['render'],
+ function(e) {
+ return function() {
+ JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
+ var items = [ [ document.getElementById('circStrings').getString('staff.circ.in_house_use.barcode') , 'barcode' ] ].concat(
+ util.functional.map_list(
+ util.functional.filter_list(
+ obj.data.list.my_cnct,
+ function(o) {
+ return util.fm_utils.compare_aou_a_is_b_or_ancestor(o.owning_lib(), obj.data.list.au[0].ws_ou());
+ }
+ ).sort(
- function(a,b) {
- try {
- return util.fm_utils.sort_func_aou_by_depth_and_then_string(
- [ a.owning_lib(), a.name() ],
- [ b.owning_lib(), b.name() ]
- );
- } catch(E) {
- alert(document.getElementById('circStrings').getString('staff.circ.in_house_use.noncat_sort_error') + ' ' + E);
- return 0;
- }
- }
+ function(a,b) {
+ try {
+ return util.fm_utils.sort_func_aou_by_depth_and_then_string(
+ [ a.owning_lib(), a.name() ],
+ [ b.owning_lib(), b.name() ]
+ );
+ } catch(E) {
+ alert(document.getElementById('circStrings').getString('staff.circ.in_house_use.noncat_sort_error') + ' ' + E);
+ return 0;
+ }
+ }
- ),
- function(o) {
- return [ obj.data.hash.aou[ o.owning_lib() ].shortname() + ' : ' + o.name(), o.id() ];
- }
- )
- );
- g.error.sdump('D_TRACE', document.getElementById('circStrings').getString('staff.circ.in_house_use.items_dump') + js2JSON(items));
- util.widgets.remove_children( e );
- var ml = util.widgets.make_menulist(
- items
- );
- e.appendChild( ml );
- ml.setAttribute('id','in_house_use_menulist');
- ml.setAttribute('accesskey','');
- ml.addEventListener(
- 'command',
- function(ev) {
- var tb = obj.controller.view.in_house_use_barcode_entry_textbox;
- if (ev.target.value == 'barcode') {
- tb.disabled = false;
- tb.value = '';
- tb.focus();
- } else {
- tb.disabled = true;
- tb.value = document.getElementById('circStrings').getString('staff.circ.in_house_use.noncataloged');
- }
- }, false
- );
- obj.controller.view.in_house_use_menu = ml;
- };
- },
- ],
- 'in_house_use_barcode_entry_textbox' : [
- ['keypress'],
- function(ev) {
- if (ev.keyCode && ev.keyCode == 13) {
- obj.in_house_use();
- }
- }
- ],
- 'in_house_use_multiplier_label' : [
- ['render'],
- function(e) {
- return function() {
- obj.controller.view.in_house_use_multiplier_textbox.select();
- obj.controller.view.in_house_use_multiplier_textbox.value = 1;
- };
- }
- ],
- 'in_house_use_multiplier_textbox' : [
- ['change'],
- function(ev) {
- if (ev.target.nodeName == 'textbox') {
- try {
- var value = Number(ev.target.value);
- if (value > 0) {
- if (value > 99) ev.target.value = 99;
- } else {
- ev.target.value = 1;
- }
- } catch(E) {
- dump('in_house_use:multiplier: ' + E + '\n');
- ev.target.value = 1;
- }
- }
- }
- ],
- 'cmd_broken' : [
- ['command'],
- function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
- ],
- 'cmd_in_house_use_submit_barcode' : [
- ['command'],
- function() {
- obj.in_house_use();
- }
- ],
- 'cmd_in_house_use_print' : [
- ['command'],
- function() {
- var p = {
- 'template' : 'in_house_use'
- };
- obj.list.print(p);
- }
- ],
- 'cmd_csv_to_clipboard' : [ ['command'], function() {
+ ),
+ function(o) {
+ return [ obj.data.hash.aou[ o.owning_lib() ].shortname() + ' : ' + o.name(), o.id() ];
+ }
+ )
+ );
+ g.error.sdump('D_TRACE', document.getElementById('circStrings').getString('staff.circ.in_house_use.items_dump') + js2JSON(items));
+ util.widgets.remove_children( e );
+ var ml = util.widgets.make_menulist(
+ items
+ );
+ e.appendChild( ml );
+ ml.setAttribute('id','in_house_use_menulist');
+ ml.setAttribute('accesskey','');
+ ml.addEventListener(
+ 'command',
+ function(ev) {
+ var tb = obj.controller.view.in_house_use_barcode_entry_textbox;
+ if (ev.target.value == 'barcode') {
+ tb.disabled = false;
+ tb.value = '';
+ tb.focus();
+ } else {
+ tb.disabled = true;
+ tb.value = document.getElementById('circStrings').getString('staff.circ.in_house_use.noncataloged');
+ }
+ }, false
+ );
+ obj.controller.view.in_house_use_menu = ml;
+ };
+ },
+ ],
+ 'in_house_use_barcode_entry_textbox' : [
+ ['keypress'],
+ function(ev) {
+ if (ev.keyCode && ev.keyCode == 13) {
+ obj.in_house_use();
+ }
+ }
+ ],
+ 'in_house_use_multiplier_label' : [
+ ['render'],
+ function(e) {
+ return function() {
+ obj.controller.view.in_house_use_multiplier_textbox.select();
+ obj.controller.view.in_house_use_multiplier_textbox.value = 1;
+ };
+ }
+ ],
+ 'in_house_use_multiplier_textbox' : [
+ ['change'],
+ function(ev) {
+ if (ev.target.nodeName == 'textbox') {
+ try {
+ var value = Number(ev.target.value);
+ if (value > 0) {
+ if (value > 99) ev.target.value = 99;
+ } else {
+ ev.target.value = 1;
+ }
+ } catch(E) {
+ dump('in_house_use:multiplier: ' + E + '\n');
+ ev.target.value = 1;
+ }
+ }
+ }
+ ],
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
+ ],
+ 'cmd_in_house_use_submit_barcode' : [
+ ['command'],
+ function() {
+ obj.in_house_use();
+ }
+ ],
+ 'cmd_in_house_use_print' : [
+ ['command'],
+ function() {
+ var p = {
+ 'template' : 'in_house_use'
+ };
+ obj.list.print(p);
+ }
+ ],
+ 'cmd_csv_to_clipboard' : [ ['command'], function() {
obj.list.dump_csv_to_clipboard();
obj.controller.view.in_house_use_barcode_entry_textbox.focus();
} ],
- 'cmd_csv_to_printer' : [ ['command'], function() {
+ 'cmd_csv_to_printer' : [ ['command'], function() {
obj.list.dump_csv_to_printer();
obj.controller.view.in_house_use_barcode_entry_textbox.focus();
} ],
- 'cmd_csv_to_file' : [ ['command'], function() {
+ 'cmd_csv_to_file' : [ ['command'], function() {
obj.list.dump_csv_to_file( { 'defaultFileName' : 'checked_in.txt' } );
obj.controller.view.in_house_use_barcode_entry_textbox.focus();
} ]
- }
- }
- );
- this.controller.render();
- this.controller.view.in_house_use_barcode_entry_textbox.focus();
+ }
+ }
+ );
+ this.controller.render();
+ this.controller.view.in_house_use_barcode_entry_textbox.focus();
- },
+ },
- 'test_barcode' : function(bc) {
- var obj = this;
- var good = util.barcode.check(bc);
- var x = document.getElementById('strict_barcode');
- if (x && x.checked != true) return true;
- if (good) {
- return true;
- } else {
- if ( 1 == obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
- document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
- document.getElementById('circStrings').getString('staff.circ.cancel'),
- document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm'),
- '/xul/server/skin/media/images/bad_barcode.png'
- ) ) {
- return true;
- } else {
- return false;
- }
- }
- },
+ 'test_barcode' : function(bc) {
+ var obj = this;
+ var good = util.barcode.check(bc);
+ var x = document.getElementById('strict_barcode');
+ if (x && x.checked != true) return true;
+ if (good) {
+ return true;
+ } else {
+ if ( 1 == obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
+ document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
+ document.getElementById('circStrings').getString('staff.circ.cancel'),
+ document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm'),
+ '/xul/server/skin/media/images/bad_barcode.png'
+ ) ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ },
- 'in_house_use' : function() {
- var obj = this;
- try {
- var barcode;
- if (obj.controller.view.in_house_use_menu.value == '' || obj.controller.view.in_house_use_menu.value == 'barcode') {
- barcode = obj.controller.view.in_house_use_barcode_entry_textbox.value;
- if (barcode) {
- if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
- }
- } else {
- barcode = ( obj.controller.view.in_house_use_menu.value );
- //barcode = obj.data.hash.cnct[ obj.controller.view.in_house_use_menu.value ].name()
- }
- var multiplier = Number( obj.controller.view.in_house_use_multiplier_textbox.value );
+ 'in_house_use' : function() {
+ var obj = this;
+ try {
+ var barcode;
+ if (obj.controller.view.in_house_use_menu.value == '' || obj.controller.view.in_house_use_menu.value == 'barcode') {
+ barcode = obj.controller.view.in_house_use_barcode_entry_textbox.value;
+ if (barcode) {
+ if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
+ }
+ } else {
+ barcode = ( obj.controller.view.in_house_use_menu.value );
+ //barcode = obj.data.hash.cnct[ obj.controller.view.in_house_use_menu.value ].name()
+ }
+ var multiplier = Number( obj.controller.view.in_house_use_multiplier_textbox.value );
- if (barcode == '') {
- obj.controller.view.in_house_use_barcode_entry_textbox.focus();
- return;
- }
+ if (barcode == '') {
+ obj.controller.view.in_house_use_barcode_entry_textbox.focus();
+ return;
+ }
- if (multiplier == 0 || multiplier > 99) {
- obj.controller.view.in_house_use_multiplier_textbox.focus();
- obj.controller.view.in_house_use_multiplier_textbox.select();
- return;
- }
+ if (multiplier == 0 || multiplier > 99) {
+ obj.controller.view.in_house_use_multiplier_textbox.focus();
+ obj.controller.view.in_house_use_multiplier_textbox.select();
+ return;
+ }
- if (multiplier > 20) {
- var r = obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.in_house_use.confirm_multiple', [barcode, multiplier]),
- document.getElementById('circStrings').getString('staff.circ.in_house_use.confirm_multiple.title'),
- document.getElementById('circStrings').getString('staff.circ.in_house_use.yes'),
- document.getElementById('circStrings').getString('staff.circ.in_house_use.no'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- if (r != 0) {
- obj.controller.view.in_house_use_multiplier_textbox.focus();
- obj.controller.view.in_house_use_multiplier_textbox.select();
- return;
- }
- }
+ if (multiplier > 20) {
+ var r = obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.in_house_use.confirm_multiple', [barcode, multiplier]),
+ document.getElementById('circStrings').getString('staff.circ.in_house_use.confirm_multiple.title'),
+ document.getElementById('circStrings').getString('staff.circ.in_house_use.yes'),
+ document.getElementById('circStrings').getString('staff.circ.in_house_use.no'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ if (r != 0) {
+ obj.controller.view.in_house_use_multiplier_textbox.focus();
+ obj.controller.view.in_house_use_multiplier_textbox.select();
+ return;
+ }
+ }
- JSAN.use('circ.util');
+ JSAN.use('circ.util');
- if (obj.controller.view.in_house_use_menu.value == 'barcode') {
+ if (obj.controller.view.in_house_use_menu.value == 'barcode') {
- var copy = obj.network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ barcode ]);
- if (copy.ilsevent) {
- switch(Number(copy.ilsevent)) {
- case -1 :
- obj.error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.in_house_use.failed.verbose'));
- break;
- case 1502 /* ASSET_COPY_NOT_FOUND */ :
- obj.error.yns_alert(
- copy.textcode,
- document.getElementById('circStrings').getString('staff.circ.in_house_use.failed'),
- document.getElementById('circStrings').getString('staff.circ.in_house_use.ok'),
- null,
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- break;
- default:
- throw(copy);
- }
- return;
- }
-
- var mods = obj.network.simple_request('MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.authoritative',[ copy.id() ]);
- var result = obj.network.simple_request('FM_AIHU_CREATE',
- [ ses(), { 'copyid' : copy.id(), 'location' : obj.data.list.au[0].ws_ou(), 'count' : multiplier } ]
- );
+ var copy = obj.network.simple_request('FM_ACP_RETRIEVE_VIA_BARCODE',[ barcode ]);
+ if (copy.ilsevent) {
+ switch(Number(copy.ilsevent)) {
+ case -1 :
+ obj.error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.in_house_use.failed.verbose'));
+ break;
+ case 1502 /* ASSET_COPY_NOT_FOUND */ :
+ obj.error.yns_alert(
+ copy.textcode,
+ document.getElementById('circStrings').getString('staff.circ.in_house_use.failed'),
+ document.getElementById('circStrings').getString('staff.circ.in_house_use.ok'),
+ null,
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ break;
+ default:
+ throw(copy);
+ }
+ return;
+ }
+
+ var mods = obj.network.simple_request('MODS_SLIM_RECORD_RETRIEVE_VIA_COPY.authoritative',[ copy.id() ]);
+ var result = obj.network.simple_request('FM_AIHU_CREATE',
+ [ ses(), { 'copyid' : copy.id(), 'location' : obj.data.list.au[0].ws_ou(), 'count' : multiplier } ]
+ );
- } else {
- var result = obj.network.simple_request('FM_ANCIHU_CREATE',
- [ ses(), { 'non_cat_type' : obj.controller.view.in_house_use_menu.value, 'location' : obj.data.list.au[0].ws_ou(), 'count' : multiplier } ]
- );
- mods = new mvr(); mods.title( obj.data.hash.cnct[ obj.controller.view.in_house_use_menu.value ].name());
- copy = new acp(); copy.barcode( '' );
- }
+ } else {
+ var result = obj.network.simple_request('FM_ANCIHU_CREATE',
+ [ ses(), { 'non_cat_type' : obj.controller.view.in_house_use_menu.value, 'location' : obj.data.list.au[0].ws_ou(), 'count' : multiplier } ]
+ );
+ mods = new mvr(); mods.title( obj.data.hash.cnct[ obj.controller.view.in_house_use_menu.value ].name());
+ copy = new acp(); copy.barcode( '' );
+ }
- if (document.getElementById('trim_list')) {
- var x = document.getElementById('trim_list');
- if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
- }
- obj.list.append(
- {
- 'row' : {
- 'my' : {
- 'mvr' : mods,
- 'acp' : copy,
- 'uses' : result.length
- }
- },
- 'to_top' : true
- //I could override map_row_to_column here
- }
- );
+ if (document.getElementById('trim_list')) {
+ var x = document.getElementById('trim_list');
+ if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
+ }
+ obj.list.append(
+ {
+ 'row' : {
+ 'my' : {
+ 'mvr' : mods,
+ 'acp' : copy,
+ 'uses' : result.length
+ }
+ },
+ 'to_top' : true
+ //I could override map_row_to_column here
+ }
+ );
- if (typeof obj.on_in_house_use == 'function') {
- obj.on_in_house_use(result);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_in_house_use == 'function') {
- obj.error.sdump('D_CIRC', + document.getElementById('circStrings').getString('staff.circ.in_house_use.external') + '\n');
- window.xulG.on_in_house_use(result);
- } else {
- obj.error.sdump('D_CIRC', + document.getElementById('circStrings').getString('staff.circ.in_house_use.no_external') + '\n');
- }
+ if (typeof obj.on_in_house_use == 'function') {
+ obj.on_in_house_use(result);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_in_house_use == 'function') {
+ obj.error.sdump('D_CIRC', + document.getElementById('circStrings').getString('staff.circ.in_house_use.external') + '\n');
+ window.xulG.on_in_house_use(result);
+ } else {
+ obj.error.sdump('D_CIRC', + document.getElementById('circStrings').getString('staff.circ.in_house_use.no_external') + '\n');
+ }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.in_house_use.failed'), E);
- if (typeof obj.on_failure == 'function') {
- obj.on_failure(E);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
- obj.error.sdump('D_CIRC', + document.getElementById('circStrings').getString('staff.circ.in_house_use.on_failure.external') + '\n');
- window.xulG.on_failure(E);
- } else {
- obj.error.sdump('D_CIRC', + document.getElementById('circStrings').getString('staff.circ.in_house_use.on_failure.external') + '\n');
- }
- }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.in_house_use.failed'), E);
+ if (typeof obj.on_failure == 'function') {
+ obj.on_failure(E);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
+ obj.error.sdump('D_CIRC', + document.getElementById('circStrings').getString('staff.circ.in_house_use.on_failure.external') + '\n');
+ window.xulG.on_failure(E);
+ } else {
+ obj.error.sdump('D_CIRC', + document.getElementById('circStrings').getString('staff.circ.in_house_use.on_failure.external') + '\n');
+ }
+ }
- },
+ },
- 'on_in_house_use' : function() {
- this.controller.view.in_house_use_multiplier_textbox.select();
- this.controller.view.in_house_use_multiplier_textbox.value = '1';
- this.controller.view.in_house_use_barcode_entry_textbox.value = '';
- this.controller.view.in_house_use_barcode_entry_textbox.focus();
- },
+ 'on_in_house_use' : function() {
+ this.controller.view.in_house_use_multiplier_textbox.select();
+ this.controller.view.in_house_use_multiplier_textbox.value = '1';
+ this.controller.view.in_house_use_barcode_entry_textbox.value = '';
+ this.controller.view.in_house_use_barcode_entry_textbox.focus();
+ },
- 'on_failure' : function() {
- this.controller.view.in_house_use_barcode_entry_textbox.select();
- this.controller.view.in_house_use_barcode_entry_textbox.focus();
- }
+ 'on_failure' : function() {
+ this.controller.view.in_house_use_barcode_entry_textbox.select();
+ this.controller.view.in_house_use_barcode_entry_textbox.focus();
+ }
}
dump('exiting circ.in_house_use.js\n');
if (typeof circ == 'undefined') circ = {};
circ.print_list_template_editor = function (params) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.error'); this.error = new util.error();
- } catch(E) {
- dump('print_list: ' + E + '\n');
- }
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.error'); this.error = new util.error();
+ } catch(E) {
+ dump('print_list: ' + E + '\n');
+ }
}
circ.print_list_template_editor.prototype = {
- 'init' : function( params ) {
+ 'init' : function( params ) {
- try {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var obj = this;
+ var obj = this;
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
- this.test_patron = new au();
- this.test_patron.family_name('Doe');
- this.test_patron.first_given_name('John');
- this.test_card = new ac();
- this.test_card.barcode('123456789');
- this.test_patron.card( this.test_card );
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+ this.test_patron = new au();
+ this.test_patron.family_name('Doe');
+ this.test_patron.first_given_name('John');
+ this.test_card = new ac();
+ this.test_card.barcode('123456789');
+ this.test_patron.card( this.test_card );
- this.test_data = {
- 'payment' : {
- 'original_balance' : '16.36',
- 'payment_type' : 'Cash',
- 'payment_received' : '0.00',
- 'payment_applied' : '0.00',
- 'voided_balance' : '0.50',
- 'change_given' : '0.00',
- 'credit_given' : '0.00',
- 'note' : "We refunded this because...",
- 'new_balance' : '16.36'
- }
- }
+ this.test_data = {
+ 'payment' : {
+ 'original_balance' : '16.36',
+ 'payment_type' : 'Cash',
+ 'payment_received' : '0.00',
+ 'payment_applied' : '0.00',
+ 'voided_balance' : '0.50',
+ 'change_given' : '0.00',
+ 'credit_given' : '0.00',
+ 'note' : "We refunded this because...",
+ 'new_balance' : '16.36'
+ }
+ }
- this.test_list = {
-
- 'items' : [
- {"uses":"undefined","alert_message":"","author":"Annixter, Jane.","barcode":"3635300990263","call_number":"F","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:37:15-0400","circ_as_type":"","circ_id":"19907","circ_lib":"URRLS-SC","circ_modifier":"","circulate":"Yes","acp_id":"34","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"13","due_date":"2006-08-23","edition":"","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"URRLS-SC","price":"10.00","pubdate":"1961","publisher":"Longmans","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000015 ","title":"Peace comes to Castle Oak ","xact_finish":""},
- {"uses":"undefined","alert_message":"","author":"Josephson, Matthew","barcode":"33207002163014","call_number":"NONFIC 330.922 JOSEPHSO","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:37:23-0400","circ_as_type":"","circ_id":"19908","circ_lib":"ARL-ATH","circ_modifier":"","circulate":"Yes","acp_id":"1658","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"250","due_date":"2006-09-06","edition":"","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"ARL-ATH","price":"10.95","pubdate":"[c1934]","publisher":"Harcourt, Brace and company","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000311 ","title":"The robber barons : the great American capitalists, 1861-1901","xact_finish":""},
- {"uses":"undefined","alert_message":"","author":"Payne, Emmy","barcode":"33034001434539","call_number":"EJ PAYNE","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:36:54-0400","circ_as_type":"","circ_id":"19904","circ_lib":"SHRL-RM","circ_modifier":"","circulate":"Yes","acp_id":"6165596","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"1220497","due_date":"2006-09-06","edition":"Reinforced ed.","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"075872926X (BWI bdg.)","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"SHRL-RM","price":"0.00","pubdate":"1944","publisher":"Houghton Mifflin","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000377 ","title":"Katy no-pocket ","xact_finish":""},
- {"uses":"undefined","alert_message":"","author":"Ames, Leslie","barcode":"31039000791757","call_number":"AF AME","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:37:07-0400","circ_as_type":"","circ_id":"19906","circ_lib":"ORLS-TEL","circ_modifier":"","circulate":"Yes","acp_id":"28","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"8","due_date":"2006-09-06","edition":"","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"ORLS-TEL","price":"5.95","pubdate":"","publisher":"Lenox Hill","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000009 ","title":"King's Castle ","xact_finish":""},
- {"uses":"undefined","alert_message":"","author":"Payne, Emmy","barcode":"33034001434539","call_number":"EJ PAYNE","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:36:54-0400","circ_as_type":"","circ_id":"19903","circ_lib":"SHRL-RM","circ_modifier":"","circulate":"Yes","acp_id":"6165596","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"1220497","due_date":"2006-09-06","edition":"Reinforced ed.","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"075872926X (BWI bdg.)","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"SHRL-RM","price":"0.00","pubdate":"1944","publisher":"Houghton Mifflin","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000377 ","title":"Katy no-pocket ","xact_finish":""}],
- 'holds' : [{"author":"Wells, H. G. ","available_time":"2006-08-03","available_timestamp":"2006-08-03T15:14:53-0400","capture_time":"2006-08-03","capture_timestamp":"2006-08-03T15:14:53-0400","current_copy":"33207003884402","edition":"","email_notify":"No","expire_time":"","fulfillment_time":"","id":"57","holdable_formats":"","isbn":"0192828266 :","notify_time":"","notify_count":"0","patron_name":"23500000023053 Stompro, Josh","phone_notify":"218-233-3757","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-02T16:15:11-0400","pubdate":"1995","publisher":"Oxford University Press","request_time":"2006-05-20","request_timestamp":"2006-05-20","requestor":"1000000","selection_depth":"0","status":"Ready for pickup","tcn":"PIN03002240 ","target":"131469","title":"The war of the worlds","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1000567"},
- {"author":"Kramer, Kathryn.","available_time":"2006-08-03","available_timestamp":"2006-08-03T15:32:58-0400","capture_time":"2006-08-03","capture_timestamp":"2006-08-03T15:32:58-0400","current_copy":"33207004030757","edition":"1st ed.","email_notify":"No","expire_time":"","fulfillment_time":"","id":"470","holdable_formats":"","isbn":"0375400834","notify_time":"2006-08-24T15:12:30-0400","notify_count":"1","patron_name":"21034000217210 Jenkins, George","phone_notify":"229-985-3464","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-03T12:15:03-0400","pubdate":"1998","publisher":"Knopf","request_time":"2006-07-28","request_timestamp":"2006-07-28","requestor":"3","selection_depth":"0","status":"Ready for pickup","tcn":"PIN03053147 ","target":"313678","title":"Sweet water ","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1001151"},
- {"author":"Silva, Daniel","available_time":"2006-08-03","available_timestamp":"2006-08-03T15:39:35-0400","capture_time":"2006-08-03","capture_timestamp":"2006-08-03T15:39:35-0400","current_copy":"33207004323517","edition":"1st ed.","email_notify":"No","expire_time":"","fulfillment_time":"","id":"448","holdable_formats":"","isbn":"0375500898 (alk. paper)","notify_time":"","notify_count":"0","patron_name":"21099000002755 Broome, Sandra","phone_notify":"706-236-4632","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-02T17:16:39-0400","pubdate":"c1999","publisher":"Random House","request_time":"2006-07-27","request_timestamp":"2006-07-27","requestor":"1000001","selection_depth":"0","status":"Ready for pickup","tcn":"ocm40444117 ","target":"77772","title":"The marching season : a novel","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1000846"},
- {"author":"Seuss","available_time":"2006-08-13","available_timestamp":"2006-08-13T20:55:02-0400","capture_time":"2006-08-13","capture_timestamp":"2006-08-13T20:55:02-0400","current_copy":"20070805","edition":"","email_notify":"No","expire_time":"","fulfillment_time":"","id":"1697","holdable_formats":"","isbn":"039480001X :","notify_time":"","notify_count":"0","patron_name":"4545 Tripper, Jack","phone_notify":"444-333-2222","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-13T20:45:09-0400","pubdate":"1992, c1957","publisher":"Seedlings Braille Books for Children","request_time":"2006-08-13","request_timestamp":"2006-08-13","requestor":"1000000","selection_depth":"0","status":"Ready for pickup","tcn":"ocm47673093 ","target":"1534993","title":"The cat in the hat","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1002261"},
- {"author":"Potter, Sally.","available_time":"2006-08-09","available_timestamp":"2006-08-09T18:06:10-0400","capture_time":"2006-08-09","capture_timestamp":"2006-08-09T18:06:10-0400","current_copy":"31001000843129","edition":"","email_notify":"No","expire_time":"","fulfillment_time":"","id":"1004","holdable_formats":"","isbn":"0783262663","notify_time":"2006-08-10T15:24:46-0400","notify_count":"12","patron_name":"2222233333 Erickson, Bill","phone_notify":"999-999-9999","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-09T12:15:27-0400","pubdate":"c2001","publisher":"Universal Studios","request_time":"2006-08-08","request_timestamp":"2006-08-08","requestor":"3","selection_depth":"0","status":"Ready for pickup","tcn":"ocm48683123 ","target":"1572303","title":"The man who cried","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"3"}],
- 'bills' : [{"balance_owed":"-5.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","id":"9","last_billing_ts":"2006-05-08 18:53","last_billing_note":"test","last_billing_type":"Miscellaneous charges","last_payment_ts":"2006-05-08 18:53","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"0.00","total_paid":"5.00","xact_type":"grocery","usr":"Id = 1000502"},
- {"balance_owed":"-5.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","id":"11","last_billing_ts":"2006-05-08 19:11","last_billing_note":"test","last_billing_type":"Miscellaneous","last_payment_ts":"2006-05-08 19:12","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"0.00","total_paid":"5.00","xact_type":"grocery","usr":"Id = 1000502"},
- {"balance_owed":"-50.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","id":"18","last_billing_ts":"2006-05-08 20:20","last_billing_note":"","last_billing_type":"Miscellaneous","last_payment_ts":"2006-05-08 21:27","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"0.00","total_paid":"50.00","xact_type":"grocery","usr":"Id = 1000502"},
- {"balance_owed":"1.00","xact_finish":"2006-06-14","xact_start":"2006-06-14","id":"451","last_billing_ts":"2006-06-14 16:49","last_billing_note":"SYSTEM GENERATED","last_billing_type":"Lost Materials","last_payment_ts":"2006-06-14 16:49","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"6.00","total_paid":"5.00","xact_type":"circulation","usr":"Id = 1000502"},
- {"balance_owed":"-1.00","xact_finish":"2006-06-17","xact_start":"2006-06-17","id":"3689","last_billing_ts":"2006-06-17 04:01","last_billing_note":"","last_billing_type":"Miscellaneous","last_payment_ts":"2006-06-17 18:51","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"10.00","total_paid":"11.00","xact_type":"grocery","usr":"Id = 1000502"},
- {"balance_owed":".66","xact_finish":"","xact_start":"2006-06-27","id":"5589","last_billing_ts":"2006-08-22 00:00","last_billing_note":"Overdue Fine","last_billing_type":"Overdue materials","last_payment_ts":"2006-09-04 17:31","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"5.60","total_paid":"4.94","xact_type":"circulation","usr":"Id = 1000502"},
- {"balance_owed":".70","xact_finish":"","xact_start":"2006-06-27","id":"5593","last_billing_ts":"2006-08-22 00:00","last_billing_note":"Overdue Fine","last_billing_type":"Overdue materials","last_payment_ts":"2006-08-16 11:01","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"5.50","total_paid":"4.80","xact_type":"circulation","usr":"Id = 1000502"},
- {"balance_owed":"5.00","xact_finish":"","xact_start":"2006-08-16","id":"14834","last_billing_ts":"2006-08-16 12:25","last_billing_note":"","last_billing_type":"Damaged material","last_payment_ts":"","last_payment_note":"","last_payment_type":"","total_owed":"5.00","total_paid":"0.00","xact_type":"grocery","usr":"Id = 1000502"},
- {"balance_owed":"10.00","xact_finish":"","xact_start":"2006-08-16","id":"14858","last_billing_ts":"2006-08-16 12:34","last_billing_note":"","last_billing_type":"Damaged material","last_payment_ts":"","last_payment_note":"","last_payment_type":"","total_owed":"10.00","total_paid":"0.00","xact_type":"grocery","usr":"Id = 1000502"}],
- 'payment' : [{"bill_id":5559,"payment":"-0.04","last_billing_type":"Overdue materials","last_billing_note":"Overdue Fine","title":"Hali Bote Azikaban de tao fan","barcode":"a16"},{"bill_id":5589,"payment":"0.04","last_billing_type":"Overdue materials","last_billing_note":"Overdue Fine","title":"Hali Bote Azikaban de tao fan","barcode":"a47"}],
- 'patrons' : [],
- 'transits' : [{"transit_item_author":"Arvetis, Chris.","transit_item_barcode":"3947801748348","transit_item_callnumber":"JE ARV","transit_item_title":"Why do birds sing?","transit_target_copy":"2385751","transit_dest_lib":"PIED-WIN","transit_id":"25","transit_source":"ARL-ATH","transit_source_send_time":"2006-05-24T16:37:09-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Pine, Tillie S.","transit_item_barcode":"3635300990762","transit_item_callnumber":"F","transit_item_title":"Water all around ","transit_target_copy":"1","transit_dest_lib":"URRLS-SC","transit_id":"26","transit_source":"ARL-ATH","transit_source_send_time":"2006-05-27T22:49:40-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"","transit_item_barcode":"31057000861941","transit_item_callnumber":"CD J 781.5246 CASPE","transit_item_title":"Casper's spookiest songs and sounds 10 spooky songs plus creepy sound effects","transit_target_copy":"7923932","transit_dest_lib":"WGRL-LS","transit_id":"98","transit_source":"ARL-ATH","transit_source_send_time":"2006-06-29T16:34:38-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Davidson, MaryJanice.","transit_item_barcode":"31027005649112","transit_item_callnumber":"AC DAV","transit_item_title":"Undead and unreturnable ","transit_target_copy":"7924995","transit_dest_lib":"HCLS-LG","transit_id":"100","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-07T16:02:32-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Evanovich, Janet.","transit_item_barcode":"31001001097295","transit_item_callnumber":"813/.54","transit_item_title":"Two for the dough","transit_target_copy":"8000335","transit_dest_lib":"ARL-BOG","transit_id":"102","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-11T12:12:11-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Edwards, Anne","transit_item_barcode":"39021423853564","transit_item_callnumber":"780.92 STREISAND","transit_item_title":"Streisand a biography","transit_target_copy":"949781","transit_dest_lib":"ECGR-BKM","transit_id":"110","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-14T10:00:01-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Riese, Randall.","transit_item_barcode":"31025900460205","transit_item_callnumber":"921 STREISAND 1993","transit_item_title":"Her name is Barbra an intimate portrait of the real Barbra Streisand","transit_target_copy":"2210566","transit_dest_lib":"HALL-BPL","transit_id":"112","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-14T10:01:39-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Rowling, J. K.","transit_item_barcode":"a45","transit_item_callnumber":"JROWLING2","transit_item_title":"Hali Bote Azikaban de tao fan","transit_target_copy":"8000297","transit_dest_lib":"WGRL-LS","transit_id":"118","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-19T13:52:38-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Some Author","transit_item_barcode":"321","transit_item_callnumber":"UNCATALOGED","transit_item_title":"Big Book","transit_target_copy":"8000387","transit_dest_lib":"ROCK-NG","transit_id":"119","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-19T13:58:21-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Thomas, Joyce Carol.","transit_item_barcode":"31036000522216","transit_item_callnumber":"E THOMAS","transit_item_title":"The gospel Cinderella","transit_target_copy":"7422951","transit_dest_lib":"NCLS-COVTN","transit_id":"200","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:20:00-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Robinson, Barbara","transit_item_barcode":"31036000545159","transit_item_callnumber":"J ROBINSON","transit_item_title":"The best Halloween ever","transit_target_copy":"7487432","transit_dest_lib":"NCLS-COVTN","transit_id":"206","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:25:44-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Robinson, Barbara","transit_item_barcode":"31036000545142","transit_item_callnumber":"J ROBINSON","transit_item_title":"The best Halloween ever","transit_target_copy":"7487431","transit_dest_lib":"NCLS-COVTN","transit_id":"207","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:25:49-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Grafton, Sue.","transit_item_barcode":"31036000527900","transit_item_callnumber":"F GRAFTON","transit_item_title":"\"H\" is for homicide","transit_target_copy":"7273824","transit_dest_lib":"NCLS-COVTN","transit_id":"208","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:25:58-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Beaumont, Karen.","transit_item_barcode":"31036000521853","transit_item_callnumber":"E BEAUMONT","transit_item_title":"I like myself!","transit_target_copy":"7387328","transit_dest_lib":"NCLS-COVTN","transit_id":"211","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:26:08-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Sandler, Martin W.","transit_item_barcode":"31036000522612","transit_item_callnumber":"J 388.42 SANDLER","transit_item_title":"Straphanging in the USA trolleys and subways in American life","transit_target_copy":"7360328","transit_dest_lib":"NCLS-COVTN","transit_id":"212","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:35:17-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
- {"transit_item_author":"Bohjalian, Christopher A.","transit_item_barcode":"31036000538303","transit_item_callnumber":"F BOHJALIAN","transit_item_title":"Before you know kindness : a novel","transit_target_copy":"7544549","transit_dest_lib":"NCLS-COVTN","transit_id":"218","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-26T10:23:20-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},],
- 'offline_checkout' : [],
- 'offline_checkin' : [],
- 'offline_renew' : [],
- 'offline_inhouse_use' : []
- }
+ this.test_list = {
+
+ 'items' : [
+ {"uses":"undefined","alert_message":"","author":"Annixter, Jane.","barcode":"3635300990263","call_number":"F","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:37:15-0400","circ_as_type":"","circ_id":"19907","circ_lib":"URRLS-SC","circ_modifier":"","circulate":"Yes","acp_id":"34","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"13","due_date":"2006-08-23","edition":"","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"URRLS-SC","price":"10.00","pubdate":"1961","publisher":"Longmans","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000015 ","title":"Peace comes to Castle Oak ","xact_finish":""},
+ {"uses":"undefined","alert_message":"","author":"Josephson, Matthew","barcode":"33207002163014","call_number":"NONFIC 330.922 JOSEPHSO","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:37:23-0400","circ_as_type":"","circ_id":"19908","circ_lib":"ARL-ATH","circ_modifier":"","circulate":"Yes","acp_id":"1658","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"250","due_date":"2006-09-06","edition":"","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"ARL-ATH","price":"10.95","pubdate":"[c1934]","publisher":"Harcourt, Brace and company","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000311 ","title":"The robber barons : the great American capitalists, 1861-1901","xact_finish":""},
+ {"uses":"undefined","alert_message":"","author":"Payne, Emmy","barcode":"33034001434539","call_number":"EJ PAYNE","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:36:54-0400","circ_as_type":"","circ_id":"19904","circ_lib":"SHRL-RM","circ_modifier":"","circulate":"Yes","acp_id":"6165596","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"1220497","due_date":"2006-09-06","edition":"Reinforced ed.","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"075872926X (BWI bdg.)","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"SHRL-RM","price":"0.00","pubdate":"1944","publisher":"Houghton Mifflin","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000377 ","title":"Katy no-pocket ","xact_finish":""},
+ {"uses":"undefined","alert_message":"","author":"Ames, Leslie","barcode":"31039000791757","call_number":"AF AME","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:37:07-0400","circ_as_type":"","circ_id":"19906","circ_lib":"ORLS-TEL","circ_modifier":"","circulate":"Yes","acp_id":"28","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"8","due_date":"2006-09-06","edition":"","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"ORLS-TEL","price":"5.95","pubdate":"","publisher":"Lenox Hill","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000009 ","title":"King's Castle ","xact_finish":""},
+ {"uses":"undefined","alert_message":"","author":"Payne, Emmy","barcode":"33034001434539","call_number":"EJ PAYNE","checkin_time":" ","checkin_time_full":"","xact_start":"2006-08-23","xact_start_full":"2006-08-23T14:36:54-0400","circ_as_type":"","circ_id":"19903","circ_lib":"SHRL-RM","circ_modifier":"","circulate":"Yes","acp_id":"6165596","copy_number":"1","create_date":"2006-04-28","edit_date":"2006-08-23","deleted":"No","deposit_amount":"0.00","deposit":"No","mvr_doc_id":"1220497","due_date":"2006-09-06","edition":"Reinforced ed.","fine_level":"Low","stop_fines":"","stop_fines_time":"","holdable":"Yes","isbn":"075872926X (BWI bdg.)","loan_duration":"Short","location":"Adult","message":" ","opac_visible":"Yes","owning_lib":"SHRL-RM","price":"0.00","pubdate":"1944","publisher":"Houghton Mifflin","ref":"No","renewal_remaining":"0","route_to":" ","status":"Checked out","tcn":"PIN01000377 ","title":"Katy no-pocket ","xact_finish":""}],
+ 'holds' : [{"author":"Wells, H. G. ","available_time":"2006-08-03","available_timestamp":"2006-08-03T15:14:53-0400","capture_time":"2006-08-03","capture_timestamp":"2006-08-03T15:14:53-0400","current_copy":"33207003884402","edition":"","email_notify":"No","expire_time":"","fulfillment_time":"","id":"57","holdable_formats":"","isbn":"0192828266 :","notify_time":"","notify_count":"0","patron_name":"23500000023053 Stompro, Josh","phone_notify":"218-233-3757","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-02T16:15:11-0400","pubdate":"1995","publisher":"Oxford University Press","request_time":"2006-05-20","request_timestamp":"2006-05-20","requestor":"1000000","selection_depth":"0","status":"Ready for pickup","tcn":"PIN03002240 ","target":"131469","title":"The war of the worlds","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1000567"},
+ {"author":"Kramer, Kathryn.","available_time":"2006-08-03","available_timestamp":"2006-08-03T15:32:58-0400","capture_time":"2006-08-03","capture_timestamp":"2006-08-03T15:32:58-0400","current_copy":"33207004030757","edition":"1st ed.","email_notify":"No","expire_time":"","fulfillment_time":"","id":"470","holdable_formats":"","isbn":"0375400834","notify_time":"2006-08-24T15:12:30-0400","notify_count":"1","patron_name":"21034000217210 Jenkins, George","phone_notify":"229-985-3464","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-03T12:15:03-0400","pubdate":"1998","publisher":"Knopf","request_time":"2006-07-28","request_timestamp":"2006-07-28","requestor":"3","selection_depth":"0","status":"Ready for pickup","tcn":"PIN03053147 ","target":"313678","title":"Sweet water ","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1001151"},
+ {"author":"Silva, Daniel","available_time":"2006-08-03","available_timestamp":"2006-08-03T15:39:35-0400","capture_time":"2006-08-03","capture_timestamp":"2006-08-03T15:39:35-0400","current_copy":"33207004323517","edition":"1st ed.","email_notify":"No","expire_time":"","fulfillment_time":"","id":"448","holdable_formats":"","isbn":"0375500898 (alk. paper)","notify_time":"","notify_count":"0","patron_name":"21099000002755 Broome, Sandra","phone_notify":"706-236-4632","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-02T17:16:39-0400","pubdate":"c1999","publisher":"Random House","request_time":"2006-07-27","request_timestamp":"2006-07-27","requestor":"1000001","selection_depth":"0","status":"Ready for pickup","tcn":"ocm40444117 ","target":"77772","title":"The marching season : a novel","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1000846"},
+ {"author":"Seuss","available_time":"2006-08-13","available_timestamp":"2006-08-13T20:55:02-0400","capture_time":"2006-08-13","capture_timestamp":"2006-08-13T20:55:02-0400","current_copy":"20070805","edition":"","email_notify":"No","expire_time":"","fulfillment_time":"","id":"1697","holdable_formats":"","isbn":"039480001X :","notify_time":"","notify_count":"0","patron_name":"4545 Tripper, Jack","phone_notify":"444-333-2222","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-13T20:45:09-0400","pubdate":"1992, c1957","publisher":"Seedlings Braille Books for Children","request_time":"2006-08-13","request_timestamp":"2006-08-13","requestor":"1000000","selection_depth":"0","status":"Ready for pickup","tcn":"ocm47673093 ","target":"1534993","title":"The cat in the hat","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"1002261"},
+ {"author":"Potter, Sally.","available_time":"2006-08-09","available_timestamp":"2006-08-09T18:06:10-0400","capture_time":"2006-08-09","capture_timestamp":"2006-08-09T18:06:10-0400","current_copy":"31001000843129","edition":"","email_notify":"No","expire_time":"","fulfillment_time":"","id":"1004","holdable_formats":"","isbn":"0783262663","notify_time":"2006-08-10T15:24:46-0400","notify_count":"12","patron_name":"2222233333 Erickson, Bill","phone_notify":"999-999-9999","pickup_lib_shortname":"ARL-ATH","pickup_lib":"Athens-Clarke County Library","prev_check_time":"2006-08-09T12:15:27-0400","pubdate":"c2001","publisher":"Universal Studios","request_time":"2006-08-08","request_timestamp":"2006-08-08","requestor":"3","selection_depth":"0","status":"Ready for pickup","tcn":"ocm48683123 ","target":"1572303","title":"The man who cried","transit_dest_recv_time":"","transit_dest_lib":"","transit_source":"","transit_source_send_time":"","hold_type":"T","usr":"3"}],
+ 'bills' : [{"balance_owed":"-5.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","id":"9","last_billing_ts":"2006-05-08 18:53","last_billing_note":"test","last_billing_type":"Miscellaneous charges","last_payment_ts":"2006-05-08 18:53","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"0.00","total_paid":"5.00","xact_type":"grocery","usr":"Id = 1000502"},
+ {"balance_owed":"-5.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","id":"11","last_billing_ts":"2006-05-08 19:11","last_billing_note":"test","last_billing_type":"Miscellaneous","last_payment_ts":"2006-05-08 19:12","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"0.00","total_paid":"5.00","xact_type":"grocery","usr":"Id = 1000502"},
+ {"balance_owed":"-50.00","xact_finish":"2006-05-08","xact_start":"2006-05-08","id":"18","last_billing_ts":"2006-05-08 20:20","last_billing_note":"","last_billing_type":"Miscellaneous","last_payment_ts":"2006-05-08 21:27","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"0.00","total_paid":"50.00","xact_type":"grocery","usr":"Id = 1000502"},
+ {"balance_owed":"1.00","xact_finish":"2006-06-14","xact_start":"2006-06-14","id":"451","last_billing_ts":"2006-06-14 16:49","last_billing_note":"SYSTEM GENERATED","last_billing_type":"Lost Materials","last_payment_ts":"2006-06-14 16:49","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"6.00","total_paid":"5.00","xact_type":"circulation","usr":"Id = 1000502"},
+ {"balance_owed":"-1.00","xact_finish":"2006-06-17","xact_start":"2006-06-17","id":"3689","last_billing_ts":"2006-06-17 04:01","last_billing_note":"","last_billing_type":"Miscellaneous","last_payment_ts":"2006-06-17 18:51","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"10.00","total_paid":"11.00","xact_type":"grocery","usr":"Id = 1000502"},
+ {"balance_owed":".66","xact_finish":"","xact_start":"2006-06-27","id":"5589","last_billing_ts":"2006-08-22 00:00","last_billing_note":"Overdue Fine","last_billing_type":"Overdue materials","last_payment_ts":"2006-09-04 17:31","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"5.60","total_paid":"4.94","xact_type":"circulation","usr":"Id = 1000502"},
+ {"balance_owed":".70","xact_finish":"","xact_start":"2006-06-27","id":"5593","last_billing_ts":"2006-08-22 00:00","last_billing_note":"Overdue Fine","last_billing_type":"Overdue materials","last_payment_ts":"2006-08-16 11:01","last_payment_note":"","last_payment_type":"cash_payment","total_owed":"5.50","total_paid":"4.80","xact_type":"circulation","usr":"Id = 1000502"},
+ {"balance_owed":"5.00","xact_finish":"","xact_start":"2006-08-16","id":"14834","last_billing_ts":"2006-08-16 12:25","last_billing_note":"","last_billing_type":"Damaged material","last_payment_ts":"","last_payment_note":"","last_payment_type":"","total_owed":"5.00","total_paid":"0.00","xact_type":"grocery","usr":"Id = 1000502"},
+ {"balance_owed":"10.00","xact_finish":"","xact_start":"2006-08-16","id":"14858","last_billing_ts":"2006-08-16 12:34","last_billing_note":"","last_billing_type":"Damaged material","last_payment_ts":"","last_payment_note":"","last_payment_type":"","total_owed":"10.00","total_paid":"0.00","xact_type":"grocery","usr":"Id = 1000502"}],
+ 'payment' : [{"bill_id":5559,"payment":"-0.04","last_billing_type":"Overdue materials","last_billing_note":"Overdue Fine","title":"Hali Bote Azikaban de tao fan","barcode":"a16"},{"bill_id":5589,"payment":"0.04","last_billing_type":"Overdue materials","last_billing_note":"Overdue Fine","title":"Hali Bote Azikaban de tao fan","barcode":"a47"}],
+ 'patrons' : [],
+ 'transits' : [{"transit_item_author":"Arvetis, Chris.","transit_item_barcode":"3947801748348","transit_item_callnumber":"JE ARV","transit_item_title":"Why do birds sing?","transit_target_copy":"2385751","transit_dest_lib":"PIED-WIN","transit_id":"25","transit_source":"ARL-ATH","transit_source_send_time":"2006-05-24T16:37:09-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Pine, Tillie S.","transit_item_barcode":"3635300990762","transit_item_callnumber":"F","transit_item_title":"Water all around ","transit_target_copy":"1","transit_dest_lib":"URRLS-SC","transit_id":"26","transit_source":"ARL-ATH","transit_source_send_time":"2006-05-27T22:49:40-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"","transit_item_barcode":"31057000861941","transit_item_callnumber":"CD J 781.5246 CASPE","transit_item_title":"Casper's spookiest songs and sounds 10 spooky songs plus creepy sound effects","transit_target_copy":"7923932","transit_dest_lib":"WGRL-LS","transit_id":"98","transit_source":"ARL-ATH","transit_source_send_time":"2006-06-29T16:34:38-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Davidson, MaryJanice.","transit_item_barcode":"31027005649112","transit_item_callnumber":"AC DAV","transit_item_title":"Undead and unreturnable ","transit_target_copy":"7924995","transit_dest_lib":"HCLS-LG","transit_id":"100","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-07T16:02:32-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Evanovich, Janet.","transit_item_barcode":"31001001097295","transit_item_callnumber":"813/.54","transit_item_title":"Two for the dough","transit_target_copy":"8000335","transit_dest_lib":"ARL-BOG","transit_id":"102","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-11T12:12:11-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Edwards, Anne","transit_item_barcode":"39021423853564","transit_item_callnumber":"780.92 STREISAND","transit_item_title":"Streisand a biography","transit_target_copy":"949781","transit_dest_lib":"ECGR-BKM","transit_id":"110","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-14T10:00:01-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Riese, Randall.","transit_item_barcode":"31025900460205","transit_item_callnumber":"921 STREISAND 1993","transit_item_title":"Her name is Barbra an intimate portrait of the real Barbra Streisand","transit_target_copy":"2210566","transit_dest_lib":"HALL-BPL","transit_id":"112","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-14T10:01:39-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Rowling, J. K.","transit_item_barcode":"a45","transit_item_callnumber":"JROWLING2","transit_item_title":"Hali Bote Azikaban de tao fan","transit_target_copy":"8000297","transit_dest_lib":"WGRL-LS","transit_id":"118","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-19T13:52:38-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Some Author","transit_item_barcode":"321","transit_item_callnumber":"UNCATALOGED","transit_item_title":"Big Book","transit_target_copy":"8000387","transit_dest_lib":"ROCK-NG","transit_id":"119","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-19T13:58:21-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Thomas, Joyce Carol.","transit_item_barcode":"31036000522216","transit_item_callnumber":"E THOMAS","transit_item_title":"The gospel Cinderella","transit_target_copy":"7422951","transit_dest_lib":"NCLS-COVTN","transit_id":"200","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:20:00-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Robinson, Barbara","transit_item_barcode":"31036000545159","transit_item_callnumber":"J ROBINSON","transit_item_title":"The best Halloween ever","transit_target_copy":"7487432","transit_dest_lib":"NCLS-COVTN","transit_id":"206","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:25:44-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Robinson, Barbara","transit_item_barcode":"31036000545142","transit_item_callnumber":"J ROBINSON","transit_item_title":"The best Halloween ever","transit_target_copy":"7487431","transit_dest_lib":"NCLS-COVTN","transit_id":"207","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:25:49-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Grafton, Sue.","transit_item_barcode":"31036000527900","transit_item_callnumber":"F GRAFTON","transit_item_title":"\"H\" is for homicide","transit_target_copy":"7273824","transit_dest_lib":"NCLS-COVTN","transit_id":"208","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:25:58-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Beaumont, Karen.","transit_item_barcode":"31036000521853","transit_item_callnumber":"E BEAUMONT","transit_item_title":"I like myself!","transit_target_copy":"7387328","transit_dest_lib":"NCLS-COVTN","transit_id":"211","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:26:08-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Sandler, Martin W.","transit_item_barcode":"31036000522612","transit_item_callnumber":"J 388.42 SANDLER","transit_item_title":"Straphanging in the USA trolleys and subways in American life","transit_target_copy":"7360328","transit_dest_lib":"NCLS-COVTN","transit_id":"212","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-25T15:35:17-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},
+ {"transit_item_author":"Bohjalian, Christopher A.","transit_item_barcode":"31036000538303","transit_item_callnumber":"F BOHJALIAN","transit_item_title":"Before you know kindness : a novel","transit_target_copy":"7544549","transit_dest_lib":"NCLS-COVTN","transit_id":"218","transit_source":"ARL-ATH","transit_source_send_time":"2006-07-26T10:23:20-0400","capture_time":" ","capture_timestamp":" ","expire_time":" ","patron_name":"undefined undefined, undefined","request_time":" ","request_timestamp":" ","hold_type":" "},],
+ 'offline_checkout' : [],
+ 'offline_checkin' : [],
+ 'offline_renew' : [],
+ 'offline_inhouse_use' : []
+ }
- obj.controller_init();
- obj.controller.render(); obj.controller.view.template_name_menu.focus();
+ obj.controller_init();
+ obj.controller.render(); obj.controller.view.template_name_menu.focus();
- obj.post_init();
+ obj.post_init();
- } catch(E) {
- alert('init: ' + E);
- this.error.sdump('D_ERROR','print_list.init: ' + E + '\n');
- }
- },
+ } catch(E) {
+ alert('init: ' + E);
+ this.error.sdump('D_ERROR','print_list.init: ' + E + '\n');
+ }
+ },
- 'post_init' : function() {
- var obj = this;
- setTimeout(
- function() {
- var tmp = obj.data.print_list_templates[ obj.controller.view.template_name_menu.value ];
- obj.controller.view.template_type_menu.value = tmp.type;
- obj.controller.view.header.value = tmp.header;
- obj.controller.view.line_item.value = tmp.line_item;
- obj.controller.view.footer.value = tmp.footer;
- obj.preview();
- }, 0
- );
- },
+ 'post_init' : function() {
+ var obj = this;
+ setTimeout(
+ function() {
+ var tmp = obj.data.print_list_templates[ obj.controller.view.template_name_menu.value ];
+ obj.controller.view.template_type_menu.value = tmp.type;
+ obj.controller.view.header.value = tmp.header;
+ obj.controller.view.line_item.value = tmp.line_item;
+ obj.controller.view.footer.value = tmp.footer;
+ obj.preview();
+ }, 0
+ );
+ },
- 'controller_init' : function() {
- try {
- var obj = this;
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'sample' : [ ['command'], function() { } ],
- 'header' : [ ['change'], function() { obj.preview(); } ],
- 'line_item' : [ ['change'], function() { obj.preview(); } ],
- 'footer' : [ ['change'], function() { obj.preview(); } ],
- 'preview' : [
- ['command'],
- function() {
- obj.preview();
- }
- ],
- 'save' : [
- ['command'],
- function() {
- obj.save_template( obj.controller.view.template_name_menu.value );
- }
- ],
- 'export' : [
- ['command'],
- function() {
- obj.export_templates();
- }
- ],
- 'import' : [
- ['command'],
- function() {
- obj.import_templates();
- }
- ],
- 'default' : [
- ['command'],
- function() {
- obj.data.print_list_defaults();
- obj.post_init();
- }
- ],
- 'macros' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
- var template_type = obj.controller.view.template_type_menu.value;
- var macros = [];
- switch(template_type) {
- case 'items':
- JSAN.use('circ.util');
- macros = util.functional.map_list(
- circ.util.columns( {} ),
- function(o) {
- return '%' + o.id + '%';
- }
- );
- break;
- case 'holds':
- JSAN.use('circ.util');
- macros = util.functional.map_list(
- circ.util.hold_columns( {} ),
- function(o) {
- return '%' + o.id + '%';
- }
- );
- break;
- case 'transits':
- JSAN.use('circ.util');
- macros = util.functional.map_list(
- circ.util.transit_columns( {} ),
- function(o) {
- return '%' + o.id + '%';
- }
- );
- break;
- case 'offline_checkout':
- JSAN.use('circ.util');
- macros = util.functional.map_list(
- circ.util.offline_checkout_columns( {} ),
- function(o) {
- return '%' + o.id + '%';
- }
- );
- break;
- case 'offline_checkin':
- JSAN.use('circ.util');
- macros = util.functional.map_list(
- circ.util.offline_checkin_columns( {} ),
- function(o) {
- return '%' + o.id + '%';
- }
- );
- break;
- case 'offline_renew':
- JSAN.use('circ.util');
- macros = util.functional.map_list(
- circ.util.offline_renew_columns( {} ),
- function(o) {
- return '%' + o.id + '%';
- }
- );
- break;
+ 'controller_init' : function() {
+ try {
+ var obj = this;
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'sample' : [ ['command'], function() { } ],
+ 'header' : [ ['change'], function() { obj.preview(); } ],
+ 'line_item' : [ ['change'], function() { obj.preview(); } ],
+ 'footer' : [ ['change'], function() { obj.preview(); } ],
+ 'preview' : [
+ ['command'],
+ function() {
+ obj.preview();
+ }
+ ],
+ 'save' : [
+ ['command'],
+ function() {
+ obj.save_template( obj.controller.view.template_name_menu.value );
+ }
+ ],
+ 'export' : [
+ ['command'],
+ function() {
+ obj.export_templates();
+ }
+ ],
+ 'import' : [
+ ['command'],
+ function() {
+ obj.import_templates();
+ }
+ ],
+ 'default' : [
+ ['command'],
+ function() {
+ obj.data.print_list_defaults();
+ obj.post_init();
+ }
+ ],
+ 'macros' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
+ var template_type = obj.controller.view.template_type_menu.value;
+ var macros = [];
+ switch(template_type) {
+ case 'items':
+ JSAN.use('circ.util');
+ macros = util.functional.map_list(
+ circ.util.columns( {} ),
+ function(o) {
+ return '%' + o.id + '%';
+ }
+ );
+ break;
+ case 'holds':
+ JSAN.use('circ.util');
+ macros = util.functional.map_list(
+ circ.util.hold_columns( {} ),
+ function(o) {
+ return '%' + o.id + '%';
+ }
+ );
+ break;
+ case 'transits':
+ JSAN.use('circ.util');
+ macros = util.functional.map_list(
+ circ.util.transit_columns( {} ),
+ function(o) {
+ return '%' + o.id + '%';
+ }
+ );
+ break;
+ case 'offline_checkout':
+ JSAN.use('circ.util');
+ macros = util.functional.map_list(
+ circ.util.offline_checkout_columns( {} ),
+ function(o) {
+ return '%' + o.id + '%';
+ }
+ );
+ break;
+ case 'offline_checkin':
+ JSAN.use('circ.util');
+ macros = util.functional.map_list(
+ circ.util.offline_checkin_columns( {} ),
+ function(o) {
+ return '%' + o.id + '%';
+ }
+ );
+ break;
+ case 'offline_renew':
+ JSAN.use('circ.util');
+ macros = util.functional.map_list(
+ circ.util.offline_renew_columns( {} ),
+ function(o) {
+ return '%' + o.id + '%';
+ }
+ );
+ break;
case 'offline_inhouse_use':
- JSAN.use('circ.util');
- macros = util.functional.map_list(
- circ.util.offline_inhouse_use_columns( {} ),
- function(o) {
- return '%' + o.id + '%';
- }
- );
- break;
- case 'bills':
- JSAN.use('patron.util');
- macros = util.functional.map_list(
- patron.util.mbts_columns( {} ),
- function(o) {
- return '%' + o.id + '%';
- }
- );
- break;
- case 'patrons':
- JSAN.use('patron.util');
- macros = util.functional.map_list(
- patron.util.columns( {} ),
- function(o) {
- return '%' + o.id + '%';
- }
- );
- break;
- case 'payment' :
- macros = [ '%original_balance%', '%payment_received%', '%payment_applied%', '%payment_type%', '%voided_balance%', '%change_given%', '%new_balance%', '%note%', '%bill_id%', '%payment%', '%title%' ];
- break;
- }
- var macro_string = macros.join(', ');
- JSAN.use('util.window');
- var win = new util.window();
- win.open('data:text/html,'
- + window.escape(
- '<html style="width: 600; height: 400;">'
- + '<head><title>'
- + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.title')
- + '</title></head>'
- + '<body onload="document.getElementById(\'btn\').focus()">'
- + '<h1>'
- + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.heading')
- + '</h1>'
- + '<p>%SHORTNAME%, %TODAY%, %STAFF_FIRSTNAME%, %STAFF_LASTNAME%, '
- + '%PATRON_FIRSTNAME%, %LIBRARY%</p>'
- + '<h1>'
- + document.getElementById('circStrings').getFormattedString('staff.circ.print_list_template.window.template_type', [template_type])
- + '</h1>'
- + '<p>'
- + macro_string
- + '</p>'
- + '<button id="btn" onclick="window.close()">'
- + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.close')
- + '</button>'
- + '</body></html>'
- ), 'title', 'chrome,resizable');
- } catch(E) {
- alert(E);
- }
- }
- ],
- 'template_name_menu_placeholder' : [
- ['render'],
- function(e) {
- return function() {
- JSAN.use('util.widgets'); JSAN.use('util.functional');
- util.widgets.remove_children(e);
- var ml = util.widgets.make_menulist(
- util.functional.map_object_to_list(
- obj.data.print_list_templates,
- function(o,i) { return [i,i]; }
- )
- );
- ml.setAttribute('id','template_name_menu');
- //ml.setAttribute('editable','true');
- ml.setAttribute('flex','1');
- e.appendChild(ml);
- obj.controller.view.template_name_menu = ml;
- ml.addEventListener(
- 'command',
- function(ev) {
- var tmp = obj.data.print_list_templates[ ev.target.value ];
- obj.controller.view.template_type_menu.value = tmp.type;
- obj.controller.view.header.value = tmp.header;
- obj.controller.view.line_item.value = tmp.line_item;
- obj.controller.view.footer.value = tmp.footer;
- obj.preview();
- },
- false
- );
- }
- }
- ],
- 'template_type_menu_placeholder' : [
- ['render'],
- function(e) {
- return function() {
- JSAN.use('util.widgets'); JSAN.use('util.functional');
- util.widgets.remove_children(e);
- var ml = util.widgets.make_menulist(
- util.functional.map_list(
- obj.data.print_list_types,
- function(o) { return [o,o]; }
- )
- );
- ml.setAttribute('id','template_types_menu');
- ml.setAttribute('disabled','true');
- e.appendChild(ml);
- obj.controller.view.template_type_menu = ml;
- }
- }
- ]
+ JSAN.use('circ.util');
+ macros = util.functional.map_list(
+ circ.util.offline_inhouse_use_columns( {} ),
+ function(o) {
+ return '%' + o.id + '%';
+ }
+ );
+ break;
+ case 'bills':
+ JSAN.use('patron.util');
+ macros = util.functional.map_list(
+ patron.util.mbts_columns( {} ),
+ function(o) {
+ return '%' + o.id + '%';
+ }
+ );
+ break;
+ case 'patrons':
+ JSAN.use('patron.util');
+ macros = util.functional.map_list(
+ patron.util.columns( {} ),
+ function(o) {
+ return '%' + o.id + '%';
+ }
+ );
+ break;
+ case 'payment' :
+ macros = [ '%original_balance%', '%payment_received%', '%payment_applied%', '%payment_type%', '%voided_balance%', '%change_given%', '%new_balance%', '%note%', '%bill_id%', '%payment%', '%title%' ];
+ break;
+ }
+ var macro_string = macros.join(', ');
+ JSAN.use('util.window');
+ var win = new util.window();
+ win.open('data:text/html,'
+ + window.escape(
+ '<html style="width: 600; height: 400;">'
+ + '<head><title>'
+ + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.title')
+ + '</title></head>'
+ + '<body onload="document.getElementById(\'btn\').focus()">'
+ + '<h1>'
+ + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.heading')
+ + '</h1>'
+ + '<p>%SHORTNAME%, %TODAY%, %STAFF_FIRSTNAME%, %STAFF_LASTNAME%, '
+ + '%PATRON_FIRSTNAME%, %LIBRARY%</p>'
+ + '<h1>'
+ + document.getElementById('circStrings').getFormattedString('staff.circ.print_list_template.window.template_type', [template_type])
+ + '</h1>'
+ + '<p>'
+ + macro_string
+ + '</p>'
+ + '<button id="btn" onclick="window.close()">'
+ + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.close')
+ + '</button>'
+ + '</body></html>'
+ ), 'title', 'chrome,resizable');
+ } catch(E) {
+ alert(E);
+ }
+ }
+ ],
+ 'template_name_menu_placeholder' : [
+ ['render'],
+ function(e) {
+ return function() {
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+ util.widgets.remove_children(e);
+ var ml = util.widgets.make_menulist(
+ util.functional.map_object_to_list(
+ obj.data.print_list_templates,
+ function(o,i) { return [i,i]; }
+ )
+ );
+ ml.setAttribute('id','template_name_menu');
+ //ml.setAttribute('editable','true');
+ ml.setAttribute('flex','1');
+ e.appendChild(ml);
+ obj.controller.view.template_name_menu = ml;
+ ml.addEventListener(
+ 'command',
+ function(ev) {
+ var tmp = obj.data.print_list_templates[ ev.target.value ];
+ obj.controller.view.template_type_menu.value = tmp.type;
+ obj.controller.view.header.value = tmp.header;
+ obj.controller.view.line_item.value = tmp.line_item;
+ obj.controller.view.footer.value = tmp.footer;
+ obj.preview();
+ },
+ false
+ );
+ }
+ }
+ ],
+ 'template_type_menu_placeholder' : [
+ ['render'],
+ function(e) {
+ return function() {
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+ util.widgets.remove_children(e);
+ var ml = util.widgets.make_menulist(
+ util.functional.map_list(
+ obj.data.print_list_types,
+ function(o) { return [o,o]; }
+ )
+ );
+ ml.setAttribute('id','template_types_menu');
+ ml.setAttribute('disabled','true');
+ e.appendChild(ml);
+ obj.controller.view.template_type_menu = ml;
+ }
+ }
+ ]
- }
- }
- );
- } catch(E) {
- alert('controller_init: ' + E );
- }
- },
+ }
+ }
+ );
+ } catch(E) {
+ alert('controller_init: ' + E );
+ }
+ },
- 'preview' : function () {
- try {
- var list = this.test_list[ this.controller.view.template_type_menu.value ];
- if (typeof list == 'undefined') list = [];
- var data = this.test_data[ this.controller.view.template_type_menu.value ];
- if (typeof data == 'undefined') data = {};
+ 'preview' : function () {
+ try {
+ var list = this.test_list[ this.controller.view.template_type_menu.value ];
+ if (typeof list == 'undefined') list = [];
+ var data = this.test_data[ this.controller.view.template_type_menu.value ];
+ if (typeof data == 'undefined') data = {};
- var params = {
- 'patron' : this.test_patron,
- 'lib' : this.data.hash.aou[ this.data.list.au[0].ws_ou() ],
- 'staff' : this.data.list.au[0],
- 'header' : this.controller.view.header.value,
- 'line_item' : this.controller.view.line_item.value,
- 'footer' : this.controller.view.footer.value,
- 'type' : this.controller.view.template_type_menu.value,
- 'list' : list,
- 'data' : data,
- 'sample_frame' : this.controller.view.sample
- };
- JSAN.use('util.print'); var print = new util.print();
- print.tree_list( params );
- } catch(E) {
- this.error.sdump('D_ERROR', document.getElementById('circStrings').getString('staff.circ.print_list_template.preview') + ' ' + E);
- alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.preview') + ' ' + E);
- }
- },
+ var params = {
+ 'patron' : this.test_patron,
+ 'lib' : this.data.hash.aou[ this.data.list.au[0].ws_ou() ],
+ 'staff' : this.data.list.au[0],
+ 'header' : this.controller.view.header.value,
+ 'line_item' : this.controller.view.line_item.value,
+ 'footer' : this.controller.view.footer.value,
+ 'type' : this.controller.view.template_type_menu.value,
+ 'list' : list,
+ 'data' : data,
+ 'sample_frame' : this.controller.view.sample
+ };
+ JSAN.use('util.print'); var print = new util.print();
+ print.tree_list( params );
+ } catch(E) {
+ this.error.sdump('D_ERROR', document.getElementById('circStrings').getString('staff.circ.print_list_template.preview') + ' ' + E);
+ alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.preview') + ' ' + E);
+ }
+ },
- 'save_template' : function(name) {
- var obj = this;
- obj.data.print_list_templates[name].header = obj.controller.view.header.value;
- obj.data.print_list_templates[name].line_item = obj.controller.view.line_item.value;
- obj.data.print_list_templates[name].footer = obj.controller.view.footer.value;
- obj.data.print_list_templates[name].type = obj.controller.view.template_type_menu.value;
- obj.data.stash( 'print_list_templates' );
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.file'); var file = new util.file('print_list_templates');
- file.set_object(obj.data.print_list_templates); file.close();
- alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.save') + '\n' + js2JSON(obj.data.print_list_templates[name]));
- },
+ 'save_template' : function(name) {
+ var obj = this;
+ obj.data.print_list_templates[name].header = obj.controller.view.header.value;
+ obj.data.print_list_templates[name].line_item = obj.controller.view.line_item.value;
+ obj.data.print_list_templates[name].footer = obj.controller.view.footer.value;
+ obj.data.print_list_templates[name].type = obj.controller.view.template_type_menu.value;
+ obj.data.stash( 'print_list_templates' );
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.file'); var file = new util.file('print_list_templates');
+ file.set_object(obj.data.print_list_templates); file.close();
+ alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.save') + '\n' + js2JSON(obj.data.print_list_templates[name]));
+ },
- 'export_templates' : function() {
- try {
- var obj = this;
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.file'); var f = new util.file('');
+ 'export_templates' : function() {
+ try {
+ var obj = this;
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.file'); var f = new util.file('');
f.export_file( { 'title' : document.getElementById('circStrings').getString('staff.circ.print_list_template.save_as'), 'data' : obj.data.print_list_templates } );
- } catch(E) {
- this.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.export.error'),E);
- }
- },
+ } catch(E) {
+ this.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.export.error'),E);
+ }
+ },
- 'import_templates' : function() {
- try {
- var obj = this;
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- JSAN.use('util.file'); var f = new util.file('');
+ 'import_templates' : function() {
+ try {
+ var obj = this;
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ JSAN.use('util.file'); var f = new util.file('');
var temp = f.import_file( { 'title' : document.getElementById('circStrings').getString('staff.circ.print_list_template.import') } );
if (!temp) { return; }
var s = '';
} else {
alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.reload'));
}
-
- } catch(E) {
- this.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.import.error'),E);
- }
- }
+
+ } catch(E) {
+ this.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.print_list_template.import.error'),E);
+ }
+ }
}
if (typeof circ == 'undefined') circ = {};
circ.renew = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- JSAN.use('util.barcode');
- JSAN.use('util.date');
- this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
- this.data = this.OpenILS.data;
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('util.barcode');
+ JSAN.use('util.date');
+ this.OpenILS = {}; JSAN.use('OpenILS.data'); this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
+ this.data = this.OpenILS.data;
}
circ.renew.prototype = {
- 'selection_list' : [],
-
- 'init' : function( params ) {
-
- var obj = this;
-
- JSAN.use('circ.util'); JSAN.use('patron.util');
- var columns = circ.util.columns(
- {
- 'barcode' : { 'hidden' : false },
- 'title' : { 'hidden' : false },
- 'location' : { 'hidden' : false },
- 'call_number' : { 'hidden' : false },
- 'status' : { 'hidden' : false },
- 'alert_message' : { 'hidden' : false },
- 'due_date' : { 'hidden' : false },
- 'due_time' : { 'hidden' : false },
- 'renewal_remaining' : { 'hidden' : false }
- },
- {
- 'except_these' : [ 'uses', 'checkin_time_full' ]
- }
- ).concat(
+ 'selection_list' : [],
+
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ JSAN.use('circ.util'); JSAN.use('patron.util');
+ var columns = circ.util.columns(
+ {
+ 'barcode' : { 'hidden' : false },
+ 'title' : { 'hidden' : false },
+ 'location' : { 'hidden' : false },
+ 'call_number' : { 'hidden' : false },
+ 'status' : { 'hidden' : false },
+ 'alert_message' : { 'hidden' : false },
+ 'due_date' : { 'hidden' : false },
+ 'due_time' : { 'hidden' : false },
+ 'renewal_remaining' : { 'hidden' : false }
+ },
+ {
+ 'except_these' : [ 'uses', 'checkin_time_full' ]
+ }
+ ).concat(
patron.util.columns( { 'family_name' : { 'hidden' : 'false' } } )
).concat(
).sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
- JSAN.use('util.list'); obj.list = new util.list('renew_list');
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
- '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_edit.setAttribute('disabled','true');
- obj.controller.view.sel_opac.setAttribute('disabled','true');
- obj.controller.view.sel_patron.setAttribute('disabled','true');
- obj.controller.view.sel_last_patron.setAttribute('disabled','true');
- obj.controller.view.sel_copy_details.setAttribute('disabled','true');
- obj.controller.view.sel_bucket.setAttribute('disabled','true');
- obj.controller.view.sel_spine.setAttribute('disabled','true');
- obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
- obj.controller.view.sel_clip.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
- } else {
- obj.controller.view.sel_edit.setAttribute('disabled','false');
- obj.controller.view.sel_opac.setAttribute('disabled','false');
- obj.controller.view.sel_patron.setAttribute('disabled','false');
- obj.controller.view.sel_last_patron.setAttribute('disabled','false');
- obj.controller.view.sel_copy_details.setAttribute('disabled','false');
- obj.controller.view.sel_bucket.setAttribute('disabled','false');
- obj.controller.view.sel_spine.setAttribute('disabled','false');
- obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
- obj.controller.view.sel_clip.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
- }
- } catch(E) {
- alert('FIXME: ' + E);
- }
- }
- }
- );
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
- 'sel_clip' : [
- ['command'],
- function() {
+ JSAN.use('util.list'); obj.list = new util.list('renew_list');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ '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_edit.setAttribute('disabled','true');
+ obj.controller.view.sel_opac.setAttribute('disabled','true');
+ obj.controller.view.sel_patron.setAttribute('disabled','true');
+ obj.controller.view.sel_last_patron.setAttribute('disabled','true');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','true');
+ obj.controller.view.sel_bucket.setAttribute('disabled','true');
+ obj.controller.view.sel_spine.setAttribute('disabled','true');
+ obj.controller.view.sel_transit_abort.setAttribute('disabled','true');
+ obj.controller.view.sel_clip.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
+ } else {
+ obj.controller.view.sel_edit.setAttribute('disabled','false');
+ obj.controller.view.sel_opac.setAttribute('disabled','false');
+ obj.controller.view.sel_patron.setAttribute('disabled','false');
+ obj.controller.view.sel_last_patron.setAttribute('disabled','false');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','false');
+ obj.controller.view.sel_bucket.setAttribute('disabled','false');
+ obj.controller.view.sel_spine.setAttribute('disabled','false');
+ obj.controller.view.sel_transit_abort.setAttribute('disabled','false');
+ obj.controller.view.sel_clip.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
+ }
+ } catch(E) {
+ alert('FIXME: ' + E);
+ }
+ }
+ }
+ );
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
+ 'sel_clip' : [
+ ['command'],
+ function() {
obj.list.clipboard();
obj.controller.view.renew_barcode_entry_textbox.focus();
}
- ],
- 'sel_edit' : [
- ['command'],
- function() {
- try {
- obj.spawn_copy_editor();
- } catch(E) {
- alert(E);
- }
- }
- ],
- 'sel_spine' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.spawn_spine_editor(obj.selection_list);
- }
- ],
- 'sel_opac' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.show_in_opac(obj.selection_list);
- }
- ],
- 'sel_transit_abort' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- circ.util.abort_transits(obj.selection_list);
- }
- ],
- 'sel_patron' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- circ.util.show_last_few_circs(obj.selection_list);
- }
- ],
- 'sel_last_patron' : [
- ['command'],
- function() {
- var patrons = {};
- for (var i = 0; i < obj.selection_list.length; i++) {
- var circs = obj.network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),obj.selection_list[i].copy_id,1]);
- if (circs.length > 0) {
- patrons[circs[0].usr()] = 1;
- } else {
- alert(document.getElementById('circStrings').getFormattedString('staff.circ.item_no_circs', [obj.selection_list[i].barcode]));
- }
- }
- for (var i in patrons) {
- xulG.new_patron_tab({},{'id' : i});
- }
- }
- ],
- 'sel_copy_details' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- for (var i = 0; i < obj.selection_list.length; i++) {
- circ.util.show_copy_details( obj.selection_list[i].copy_id );
- }
- }
- ],
- 'sel_mark_items_damaged' : [
- ['command'],
- function() {
- var funcs = [];
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_damaged( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_bucket' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.add_copies_to_bucket(obj.selection_list);
- }
- ],
- 'renew_barcode_entry_textbox' : [
- ['keypress'],
- function(ev) {
- if (ev.keyCode && ev.keyCode == 13) {
- obj.renew();
- }
- }
- ],
- 'cmd_broken' : [
- ['command'],
- function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
- ],
- 'cmd_renew_submit_barcode' : [
- ['command'],
- function() {
- obj.renew();
- }
- ],
- 'cmd_renew_print' : [
- ['command'],
- function() {
- var p = {
- 'template' : 'renew'
- };
- obj.list.print(p);
- }
- ],
- 'cmd_csv_to_clipboard' : [ ['command'], function() {
+ ],
+ 'sel_edit' : [
+ ['command'],
+ function() {
+ try {
+ obj.spawn_copy_editor();
+ } catch(E) {
+ alert(E);
+ }
+ }
+ ],
+ 'sel_spine' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.spawn_spine_editor(obj.selection_list);
+ }
+ ],
+ 'sel_opac' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.show_in_opac(obj.selection_list);
+ }
+ ],
+ 'sel_transit_abort' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ circ.util.abort_transits(obj.selection_list);
+ }
+ ],
+ 'sel_patron' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ circ.util.show_last_few_circs(obj.selection_list);
+ }
+ ],
+ 'sel_last_patron' : [
+ ['command'],
+ function() {
+ var patrons = {};
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ var circs = obj.network.simple_request('FM_CIRC_RETRIEVE_VIA_COPY',[ses(),obj.selection_list[i].copy_id,1]);
+ if (circs.length > 0) {
+ patrons[circs[0].usr()] = 1;
+ } else {
+ alert(document.getElementById('circStrings').getFormattedString('staff.circ.item_no_circs', [obj.selection_list[i].barcode]));
+ }
+ }
+ for (var i in patrons) {
+ xulG.new_patron_tab({},{'id' : i});
+ }
+ }
+ ],
+ 'sel_copy_details' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ for (var i = 0; i < obj.selection_list.length; i++) {
+ circ.util.show_copy_details( obj.selection_list[i].copy_id );
+ }
+ }
+ ],
+ 'sel_mark_items_damaged' : [
+ ['command'],
+ function() {
+ var funcs = [];
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_damaged( util.functional.map_list( obj.selection_list, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_bucket' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.add_copies_to_bucket(obj.selection_list);
+ }
+ ],
+ 'renew_barcode_entry_textbox' : [
+ ['keypress'],
+ function(ev) {
+ if (ev.keyCode && ev.keyCode == 13) {
+ obj.renew();
+ }
+ }
+ ],
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert(document.getElementById('circStrings').getString('staff.circ.unimplemented')); }
+ ],
+ 'cmd_renew_submit_barcode' : [
+ ['command'],
+ function() {
+ obj.renew();
+ }
+ ],
+ 'cmd_renew_print' : [
+ ['command'],
+ function() {
+ var p = {
+ 'template' : 'renew'
+ };
+ obj.list.print(p);
+ }
+ ],
+ 'cmd_csv_to_clipboard' : [ ['command'], function() {
obj.list.dump_csv_to_clipboard();
obj.controller.view.renew_barcode_entry_textbox.focus();
} ],
- 'cmd_csv_to_printer' : [ ['command'], function() {
+ 'cmd_csv_to_printer' : [ ['command'], function() {
obj.list.dump_csv_to_printer();
obj.controller.view.renew_barcode_entry_textbox.focus();
} ],
- 'cmd_csv_to_file' : [ ['command'], function() {
+ 'cmd_csv_to_file' : [ ['command'], function() {
obj.list.dump_csv_to_file( { 'defaultFileName' : 'checked_in.txt' } );
obj.controller.view.renew_barcode_entry_textbox.focus();
} ]
- }
- }
- );
- this.controller.render();
- this.controller.view.renew_barcode_entry_textbox.focus();
-
- },
-
- 'test_barcode' : function(bc) {
- var obj = this;
- var x = document.getElementById('strict_barcode');
- if (x && x.checked != true) return true;
- var good = util.barcode.check(bc);
- if (good) {
- return true;
- } else {
- if ( 1 == obj.error.yns_alert(
- document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
- document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
- document.getElementById('circStrings').getString('staff.circ.cancel'),
- document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm'),
- '/xul/server/skin/media/images/bad_barcode.png'
- ) ) {
- return true;
- } else {
- return false;
- }
- }
- },
-
- 'renew' : function() {
- var obj = this;
- try {
- var barcode = obj.controller.view.renew_barcode_entry_textbox.value;
- if (!barcode) return;
- if (barcode) {
- if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
- }
- var auto_print = document.getElementById('renew_auto');
- if (auto_print) auto_print = auto_print.checked;
- JSAN.use('circ.util');
- var renew = circ.util.renew_via_barcode(
+ }
+ }
+ );
+ this.controller.render();
+ this.controller.view.renew_barcode_entry_textbox.focus();
+
+ },
+
+ 'test_barcode' : function(bc) {
+ var obj = this;
+ var x = document.getElementById('strict_barcode');
+ if (x && x.checked != true) return true;
+ var good = util.barcode.check(bc);
+ if (good) {
+ return true;
+ } else {
+ if ( 1 == obj.error.yns_alert(
+ document.getElementById('circStrings').getFormattedString('staff.circ.check_digit.bad', [bc]),
+ document.getElementById('circStrings').getString('staff.circ.barcode.bad'),
+ document.getElementById('circStrings').getString('staff.circ.cancel'),
+ document.getElementById('circStrings').getString('staff.circ.barcode.accept'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm'),
+ '/xul/server/skin/media/images/bad_barcode.png'
+ ) ) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ },
+
+ 'renew' : function() {
+ var obj = this;
+ try {
+ var barcode = obj.controller.view.renew_barcode_entry_textbox.value;
+ if (!barcode) return;
+ if (barcode) {
+ if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
+ }
+ var auto_print = document.getElementById('renew_auto');
+ if (auto_print) auto_print = auto_print.checked;
+ JSAN.use('circ.util');
+ var renew = circ.util.renew_via_barcode(
{ 'barcode' : barcode, 'return_patron' : true },
function( r ) {
obj.renew_followup( r, barcode );
}
- );
- } catch(E) {
- obj.error.standard_unexpected_error_alert('Error in circ/renew.js, renew():', E);
- if (typeof obj.on_failure == 'function') {
- obj.on_failure(E);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
- window.xulG.on_failure(E);
- }
- }
- },
-
- 'renew_followup' : function(r,bc) {
- var obj = this;
- try {
- if (!r) return obj.on_failure(); /* circ.util.renew handles errors and returns null currently */
+ );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Error in circ/renew.js, renew():', E);
+ if (typeof obj.on_failure == 'function') {
+ obj.on_failure(E);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
+ window.xulG.on_failure(E);
+ }
+ }
+ },
+
+ 'renew_followup' : function(r,bc) {
+ var obj = this;
+ try {
+ if (!r) return obj.on_failure(); /* circ.util.renew handles errors and returns null currently */
if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) {
// SUCCESS
var x = document.getElementById('no_change_label');
x.hidden = false;
x.setAttribute('value',msg);
}
- obj.controller.view.renew_barcode_entry_textbox.focus();
- obj.controller.view.renew_barcode_entry_textbox.select();
+ obj.controller.view.renew_barcode_entry_textbox.focus();
+ obj.controller.view.renew_barcode_entry_textbox.select();
return;
}
var renew = r[0].payload;
- var retrieve_id = js2JSON( { 'copy_id' : renew.copy.id(), 'barcode' : renew.copy.barcode(), 'doc_id' : (renew.record == null ? null : renew.record.doc_id() ) } );
- if (document.getElementById('trim_list')) {
- var x = document.getElementById('trim_list');
- if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
- }
+ var retrieve_id = js2JSON( { 'copy_id' : renew.copy.id(), 'barcode' : renew.copy.barcode(), 'doc_id' : (renew.record == null ? null : renew.record.doc_id() ) } );
+ if (document.getElementById('trim_list')) {
+ var x = document.getElementById('trim_list');
+ if (x.checked) { obj.list.trim_list = 20; } else { obj.list.trim_list = null; }
+ }
var params = {
'retrieve_id' : retrieve_id,
},
'to_top' : true
};
- obj.list.append( params );
+ obj.list.append( params );
if (params.row.my.mbts && ( document.getElementById('no_change_label') || document.getElementById('fine_tally') ) ) {
JSAN.use('util.money');
}
}
- obj.list.node.view.selection.select(0);
+ obj.list.node.view.selection.select(0);
- JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good();
+ JSAN.use('util.sound'); var sound = new util.sound(); sound.circ_good();
- if (typeof obj.on_renew == 'function') {
- obj.on_renew(renew);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_renew == 'function') {
- window.xulG.on_renew(renew);
- }
+ if (typeof obj.on_renew == 'function') {
+ obj.on_renew(renew);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_renew == 'function') {
+ window.xulG.on_renew(renew);
+ }
- return true;
+ return true;
- } catch(E) {
- obj.error.standard_unexpected_error_alert('Error in circ/renew.js, renew_followup():', E);
- if (typeof obj.on_failure == 'function') {
- obj.on_failure(E);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
- window.xulG.on_failure(E);
- }
- }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Error in circ/renew.js, renew_followup():', E);
+ if (typeof obj.on_failure == 'function') {
+ obj.on_failure(E);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_failure == 'function') {
+ window.xulG.on_failure(E);
+ }
+ }
- },
+ },
- 'on_renew' : function() {
+ 'on_renew' : function() {
try {
this.controller.view.renew_barcode_entry_textbox.disabled = false;
this.controller.view.renew_barcode_entry_textbox.select();
} catch(E) {
alert('Error in renew.js, on_renew(): ' + E);
}
- },
+ },
- 'on_failure' : function() {
+ 'on_failure' : function() {
try {
this.controller.view.renew_barcode_entry_textbox.disabled = false;
this.controller.view.renew_barcode_entry_textbox.select();
} catch(E) {
alert('Error in renew.js, on_failure(): ' + E);
}
- },
-
- 'spawn_copy_editor' : function() {
+ },
+
+ 'spawn_copy_editor' : function() {
- var obj = this;
+ var obj = this;
- JSAN.use('util.functional');
+ JSAN.use('util.functional');
- var list = obj.selection_list;
+ var list = obj.selection_list;
- list = util.functional.map_list(
- list,
- function (o) {
- return o.copy_id;
- }
- );
+ list = util.functional.map_list(
+ list,
+ function (o) {
+ return o.copy_id;
+ }
+ );
- JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
+ JSAN.use('cat.util'); cat.util.spawn_copy_editor( { 'copy_ids' : list, 'edit' : 1 } );
- }
+ }
}
if (typeof circ == 'undefined') { var circ = {}; }
circ.util = {};
-circ.util.EXPORT_OK = [
- 'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns',
- 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_columns',
- 'show_last_few_circs', 'abort_transits', 'transit_columns', 'work_log_columns', 'renew_via_barcode', 'backdate_post_checkin'
+circ.util.EXPORT_OK = [
+ 'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns',
+ 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_columns',
+ 'show_last_few_circs', 'abort_transits', 'transit_columns', 'work_log_columns', 'renew_via_barcode', 'backdate_post_checkin'
];
-circ.util.EXPORT_TAGS = { ':all' : circ.util.EXPORT_OK };
+circ.util.EXPORT_TAGS = { ':all' : circ.util.EXPORT_OK };
circ.util.abort_transits = function(selection_list) {
- var obj = {};
- JSAN.use('util.error'); obj.error = new util.error();
- JSAN.use('util.network'); obj.network = new util.network();
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
- JSAN.use('util.functional');
- var copies = util.functional.map_list( selection_list, function(o){return o.copy_id;}).join(', ');
- var msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.abort_transits.confirm', [copies]);
- var r = obj.error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.utils.abort_transits.title'),
- document.getElementById('circStrings').getString('staff.circ.utils.yes'),
- document.getElementById('circStrings').getString('staff.circ.utils.no'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm')
- );
- if (r == 0) {
- try {
- for (var i = 0; i < selection_list.length; i++) {
- var copy_id = selection_list[i].copy_id;
- var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'copyid' : copy_id } ]);
- if (typeof robj.ilsevent != 'undefined') {
- switch(Number(robj.ilsevent)) {
- case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
- alert(document.getElementById('circString').getFormattedString('staff.circ.utils.abort_transits.not_allowed', [copy_id]) + '\n' + robj.desc);
- break;
- case 1504 /* ACTION_TRANSIT_COPY_NOT_FOUND */ :
- alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.not_found'));
- break;
- case 5000 /* PERM_FAILURE */ :
- break;
- default:
- throw(robj);
- break;
- }
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.unexpected_error'),E);
- }
- }
+ var obj = {};
+ JSAN.use('util.error'); obj.error = new util.error();
+ JSAN.use('util.network'); obj.network = new util.network();
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+ JSAN.use('util.functional');
+ var copies = util.functional.map_list( selection_list, function(o){return o.copy_id;}).join(', ');
+ var msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.abort_transits.confirm', [copies]);
+ var r = obj.error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.utils.abort_transits.title'),
+ document.getElementById('circStrings').getString('staff.circ.utils.yes'),
+ document.getElementById('circStrings').getString('staff.circ.utils.no'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm')
+ );
+ if (r == 0) {
+ try {
+ for (var i = 0; i < selection_list.length; i++) {
+ var copy_id = selection_list[i].copy_id;
+ var robj = obj.network.simple_request('FM_ATC_VOID',[ ses(), { 'copyid' : copy_id } ]);
+ if (typeof robj.ilsevent != 'undefined') {
+ switch(Number(robj.ilsevent)) {
+ case 1225 /* TRANSIT_ABORT_NOT_ALLOWED */ :
+ alert(document.getElementById('circString').getFormattedString('staff.circ.utils.abort_transits.not_allowed', [copy_id]) + '\n' + robj.desc);
+ break;
+ case 1504 /* ACTION_TRANSIT_COPY_NOT_FOUND */ :
+ alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.not_found'));
+ break;
+ case 5000 /* PERM_FAILURE */ :
+ break;
+ default:
+ throw(robj);
+ break;
+ }
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circString').getString('staff.circ.utils.abort_transits.unexpected_error'),E);
+ }
+ }
};
circ.util.show_copy_details = function(copy_id) {
- var obj = {};
- JSAN.use('util.error'); obj.error = new util.error();
- JSAN.use('util.window'); obj.win = new util.window();
- JSAN.use('util.network'); obj.network = new util.network();
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
-
- if (typeof copy_id == 'object' && copy_id != null) copy_id = copy_id.id();
-
- try {
- var url = xulG.url_prefix( urls.XUL_COPY_DETAILS ); // + '?copy_id=' + copy_id;
- var my_xulG = obj.win.open( url, 'show_copy_details', 'chrome,resizable,modal', { 'copy_id' : copy_id } );
-
- if (typeof my_xulG.retrieve_these_patrons == 'undefined') return;
- var patrons = my_xulG.retrieve_these_patrons;
- for (var j = 0; j < patrons.length; j++) {
- if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
- try {
- window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure'), E);
- }
- }
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E);
- }
+ var obj = {};
+ JSAN.use('util.error'); obj.error = new util.error();
+ JSAN.use('util.window'); obj.win = new util.window();
+ JSAN.use('util.network'); obj.network = new util.network();
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+
+ if (typeof copy_id == 'object' && copy_id != null) copy_id = copy_id.id();
+
+ try {
+ var url = xulG.url_prefix( urls.XUL_COPY_DETAILS ); // + '?copy_id=' + copy_id;
+ var my_xulG = obj.win.open( url, 'show_copy_details', 'chrome,resizable,modal', { 'copy_id' : copy_id } );
+
+ if (typeof my_xulG.retrieve_these_patrons == 'undefined') return;
+ var patrons = my_xulG.retrieve_these_patrons;
+ for (var j = 0; j < patrons.length; j++) {
+ if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
+ try {
+ window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure'), E);
+ }
+ }
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_copy.failure'),E);
+ }
};
circ.util.backdate_post_checkin = function(circ_ids) {
- var obj = {};
- JSAN.use('util.error'); obj.error = new util.error();
- JSAN.use('util.window'); obj.win = new util.window();
- JSAN.use('util.network'); obj.network = new util.network();
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+ var obj = {};
+ JSAN.use('util.error'); obj.error = new util.error();
+ JSAN.use('util.window'); obj.win = new util.window();
+ JSAN.use('util.network'); obj.network = new util.network();
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
JSAN.use('util.sound'); obj.sound = new util.sound();
var circStrings = document.getElementById('circStrings');
}
);
- try {
- var url = xulG.url_prefix( urls.XUL_BACKDATE );
- var my_xulG = obj.win.open( url, 'backdate_post_checkin', 'chrome,resizable,modal', { 'circ_ids' : circ_ids } );
+ try {
+ var url = xulG.url_prefix( urls.XUL_BACKDATE );
+ var my_xulG = obj.win.open( url, 'backdate_post_checkin', 'chrome,resizable,modal', { 'circ_ids' : circ_ids } );
return my_xulG;
- } catch(E) {
- obj.error.standard_unexpected_error_alert(circStrings.getString('staff.circ.utils.retrieve_copy.failure'),E);
- }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(circStrings.getString('staff.circ.utils.retrieve_copy.failure'),E);
+ }
};
circ.util.show_last_few_circs = function(selection_list) {
- var obj = {};
- JSAN.use('util.error'); obj.error = new util.error();
- JSAN.use('util.window'); obj.win = new util.window();
- JSAN.use('util.network'); obj.network = new util.network();
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
-
- for (var i = 0; i < selection_list.length; i++) {
- try {
- if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
- var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
- var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id } );
-
- if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
- var patrons = my_xulG.retrieve_these_patrons;
- for (var j = 0; j < patrons.length; j++) {
- if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
- try {
- window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure') ,E);
- }
- }
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_circs.failure') ,E);
- }
- }
+ var obj = {};
+ JSAN.use('util.error'); obj.error = new util.error();
+ JSAN.use('util.window'); obj.win = new util.window();
+ JSAN.use('util.network'); obj.network = new util.network();
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+
+ for (var i = 0; i < selection_list.length; i++) {
+ try {
+ if (typeof selection_list[i].copy_id == 'undefined' || selection_list[i].copy_id == null) continue;
+ var url = xulG.url_prefix( urls.XUL_CIRC_SUMMARY ); // + '?copy_id=' + selection_list[i].copy_id + '&count=' + count;
+ var my_xulG = obj.win.open( url, 'show_last_few_circs', 'chrome,resizable,modal', { 'copy_id' : selection_list[i].copy_id } );
+
+ if (typeof my_xulG.retrieve_these_patrons == 'undefined') continue;
+ var patrons = my_xulG.retrieve_these_patrons;
+ for (var j = 0; j < patrons.length; j++) {
+ if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
+ try {
+ window.xulG.new_patron_tab( {}, { 'id' : patrons[j] } );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_patron.failure') ,E);
+ }
+ }
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.retrieve_circs.failure') ,E);
+ }
+ }
};
circ.util.offline_checkout_columns = function(modify,params) {
- var c = [
- {
- 'id' : 'timestamp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.timestamp; }
- },
- {
- 'id' : 'checkout_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.checkout_time; }
- },
- {
- 'id' : 'type',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.type; }
- },
- {
- 'id' : 'noncat',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.noncat; }
- },
- {
- 'id' : 'noncat_type',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat_type'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.noncat_type; }
- },
- {
- 'id' : 'noncat_count',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
- 'sort_type' : 'number',
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.noncat_count; }
- },
- {
- 'id' : 'patron_barcode',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.patron_barcode; }
- },
- {
- 'id' : 'barcode',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
- 'flex' : 2,
- 'primary' : true,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.barcode; }
- },
- {
- 'id' : 'due_date',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.due_date; }
- },
- {
- 'id' : 'due_time',
- 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.due_time; }
- }
-
- ];
- if (modify) for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ var c = [
+ {
+ 'id' : 'timestamp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.timestamp; }
+ },
+ {
+ 'id' : 'checkout_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.checkout_time; }
+ },
+ {
+ 'id' : 'type',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.type; }
+ },
+ {
+ 'id' : 'noncat',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.noncat; }
+ },
+ {
+ 'id' : 'noncat_type',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.noncat_type'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.noncat_type; }
+ },
+ {
+ 'id' : 'noncat_count',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
+ 'sort_type' : 'number',
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.noncat_count; }
+ },
+ {
+ 'id' : 'patron_barcode',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.patron_barcode; }
+ },
+ {
+ 'id' : 'barcode',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
+ 'flex' : 2,
+ 'primary' : true,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.barcode; }
+ },
+ {
+ 'id' : 'due_date',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.due_date; }
+ },
+ {
+ 'id' : 'due_time',
+ 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.due_time; }
+ }
+
+ ];
+ if (modify) for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
};
circ.util.offline_checkin_columns = function(modify,params) {
- var c = [
- {
- 'id' : 'timestamp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.timestamp; }
- },
- {
- 'id' : 'backdate',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.backdate'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.backdate; }
- },
- {
- 'id' : 'type',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.type; }
- },
- {
- 'id' : 'barcode',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
- 'flex' : 2,
- 'primary' : true,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.barcode; }
- }
- ];
- if (modify) for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ var c = [
+ {
+ 'id' : 'timestamp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.timestamp; }
+ },
+ {
+ 'id' : 'backdate',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.backdate'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.backdate; }
+ },
+ {
+ 'id' : 'type',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.type; }
+ },
+ {
+ 'id' : 'barcode',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
+ 'flex' : 2,
+ 'primary' : true,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.barcode; }
+ }
+ ];
+ if (modify) for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
};
circ.util.offline_renew_columns = function(modify,params) {
- var c = [
- {
- 'id' : 'timestamp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.timestamp; }
- },
- {
- 'id' : 'checkout_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.checkout_time; }
- },
- {
- 'id' : 'type',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.type; }
- },
- {
- 'id' : 'patron_barcode',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.patron_barcode; }
- },
- {
- 'id' : 'barcode',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
- 'flex' : 2,
- 'primary' : true,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.barcode; }
- },
- {
- 'id' : 'due_date',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.due_date; }
- },
- {
- 'id' : 'due_time',
- 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.due_time; }
- }
- ];
- if (modify) for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ var c = [
+ {
+ 'id' : 'timestamp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.timestamp; }
+ },
+ {
+ 'id' : 'checkout_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.checkout_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.checkout_time; }
+ },
+ {
+ 'id' : 'type',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.type; }
+ },
+ {
+ 'id' : 'patron_barcode',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.patron_barcode; }
+ },
+ {
+ 'id' : 'barcode',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
+ 'flex' : 2,
+ 'primary' : true,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.barcode; }
+ },
+ {
+ 'id' : 'due_date',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.due_date'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.due_date; }
+ },
+ {
+ 'id' : 'due_time',
+ 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.due_time; }
+ }
+ ];
+ if (modify) for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
};
circ.util.offline_inhouse_use_columns = function(modify,params) {
- var c = [
- {
- 'id' : 'timestamp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.timestamp; }
- },
- {
- 'id' : 'use_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.use_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.use_time; }
- },
- {
- 'id' : 'type',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.type; }
- },
- {
- 'id' : 'count',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
- 'sort_type' : 'number',
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.count; }
- },
- {
- 'id' : 'barcode',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
- 'flex' : 2,
- 'primary' : true,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.barcode; }
- }
- ];
- if (modify) for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ var c = [
+ {
+ 'id' : 'timestamp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.timestamp'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.timestamp; }
+ },
+ {
+ 'id' : 'use_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.use_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.use_time; }
+ },
+ {
+ 'id' : 'type',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.type'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.type; }
+ },
+ {
+ 'id' : 'count',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.count'),
+ 'sort_type' : 'number',
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.count; }
+ },
+ {
+ 'id' : 'barcode',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.item_barcode'),
+ 'flex' : 2,
+ 'primary' : true,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.barcode; }
+ }
+ ];
+ if (modify) for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
};
circ.util.columns = function(modify,params) {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- JSAN.use('util.network'); var network = new util.network();
- JSAN.use('util.money');
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ JSAN.use('util.network'); var network = new util.network();
+ JSAN.use('util.money');
- var c = [
- {
- 'id' : 'acp_id',
+ var c = [
+ {
+ 'id' : 'acp_id',
'fm_class' : 'acp',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.id(); },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'circ_id',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_id'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.id(); },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'circ_id',
'fm_class' : 'circ',
- 'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'mvr_doc_id',
+ 'label' : document.getElementById('commonStrings').getString('staff.circ_label_id'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'mvr_doc_id',
'fm_class' : 'mvr',
- 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.doc_id(); },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'service',
- 'label' : 'Service',
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.service; }
- },
- {
- 'id' : 'barcode',
+ 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_doc_id'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.mvr.doc_id(); },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'service',
+ 'label' : 'Service',
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.service; }
+ },
+ {
+ 'id' : 'barcode',
'fm_class' : 'acp',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.barcode(); },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'call_number',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_barcode'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.barcode(); },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'call_number',
'fm_class' : 'acp',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.acp && my.acp.call_number() == -1) {
- return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
- } else if (my.acp && my.acp.call_number() == -2) {
- return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
- } else {
- if (!my.acn) {
- var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ my.acp.call_number() ]);
- if (x.ilsevent) {
- return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
- } else {
- my.acn = x; return x.label();
- }
- } else {
- return my.acn.label();
- }
- }
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'owning_lib',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_call_number'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.acp && my.acp.call_number() == -1) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
+ } else if (my.acp && my.acp.call_number() == -2) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
+ } else {
+ if (!my.acn) {
+ var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ my.acp.call_number() ]);
+ if (x.ilsevent) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged');
+ } else {
+ my.acn = x; return x.label();
+ }
+ } else {
+ return my.acn.label();
+ }
+ }
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'owning_lib',
'fm_class' : 'acn',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.owning_lib'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (Number(my.acn.owning_lib())>=0) {
- return data.hash.aou[ my.acn.owning_lib() ].shortname();
- } else {
- return my.acn.owning_lib().shortname();
- }
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'copy_number',
- 'fm_class' : 'acp',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
- 'flex' : 1,
- 'sort_type' : 'number',
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.copy_number(); },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'location',
- 'fm_class' : 'acp',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (Number(my.acp.location())>=0) {
- return data.lookup("acpl", my.acp.location() ).name();
- } else {
- return my.acp.location().name();
- }
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'loan_duration',
- 'fm_class' : 'acp',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- switch(Number(my.acp.loan_duration())) {
- case 1:
- return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
- break;
- case 2:
- return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
- break;
- case 3:
- return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
- break;
- };
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'circ_lib',
- 'fm_class' : 'acp',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (Number(my.acp.circ_lib())>=0) {
- return data.hash.aou[ my.acp.circ_lib() ].shortname();
- } else {
- return my.acp.circ_lib().shortname();
- }
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'fine_level',
- 'fm_class' : 'acp',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- switch(Number(my.acp.fine_level())) {
- case 1:
- return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
- break;
- case 2:
- return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
- break;
- case 3:
- return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
- break;
- };
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'circulate',
- 'fm_class' : 'acp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (get_bool( my.acp.circulate() )) {
- return document.getElementById('circStrings').getString('staff.circ.utils.yes');
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.no');
- }
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'deleted',
- 'fm_class' : 'acp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (get_bool( my.acp.deleted() )) {
- return document.getElementById('circStrings').getString('staff.circ.utils.yes');
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.no');
- }
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'holdable',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.owning_lib'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (Number(my.acn.owning_lib())>=0) {
+ return data.hash.aou[ my.acn.owning_lib() ].shortname();
+ } else {
+ return my.acn.owning_lib().shortname();
+ }
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'copy_number',
'fm_class' : 'acp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (get_bool( my.acp.holdable() )) {
- return document.getElementById('circStrings').getString('staff.circ.utils.yes');
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.no');
- }
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'id' : 'opac_visible',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_copy_number'),
+ 'flex' : 1,
+ 'sort_type' : 'number',
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.copy_number(); },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'location',
'fm_class' : 'acp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (get_bool( my.acp.opac_visible() )) {
- return document.getElementById('circStrings').getString('staff.circ.utils.yes');
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.no');
- }
- },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_location'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (Number(my.acp.location())>=0) {
+ return data.lookup("acpl", my.acp.location() ).name();
+ } else {
+ return my.acp.location().name();
+ }
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'loan_duration',
'fm_class' : 'acp',
- 'id' : 'ref',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.reference'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (get_bool( my.acp.ref() )) {
- return document.getElementById('circStrings').getString('staff.circ.utils.yes');
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.no');
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_loan_duration'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ switch(Number(my.acp.loan_duration())) {
+ case 1:
+ return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.short');
+ break;
+ case 2:
+ return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.normal');
+ break;
+ case 3:
+ return document.getElementById('circStrings').getString('staff.circ.utils.loan_duration.long');
+ break;
+ };
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'circ_lib',
'fm_class' : 'acp',
- 'id' : 'deposit',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deposit'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (get_bool( my.acp.deposit() )) {
- return document.getElementById('circStrings').getString('staff.circ.utils.yes');
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.no');
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_lib'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (Number(my.acp.circ_lib())>=0) {
+ return data.hash.aou[ my.acp.circ_lib() ].shortname();
+ } else {
+ return my.acp.circ_lib().shortname();
+ }
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'fine_level',
'fm_class' : 'acp',
- 'id' : 'deposit_amount',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.acp.price() == null) {
- return document.getElementById('circStrings').getString('staff.circ.utils.unset');
- } else {
- return util.money.sanitize(my.acp.deposit_amount());
- }
- },
- 'sort_type' : 'money'
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_fine_level'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ switch(Number(my.acp.fine_level())) {
+ case 1:
+ return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.low');
+ break;
+ case 2:
+ return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.normal');
+ break;
+ case 3:
+ return document.getElementById('circStrings').getString('staff.circ.utils.fine_level.high');
+ break;
+ };
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'circulate',
'fm_class' : 'acp',
- 'id' : 'price',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.acp.price() == null) {
- return document.getElementById('circStrings').getString('staff.circ.utils.unset');
- } else {
- return util.money.sanitize(my.acp.price());
- }
- },
- 'sort_type' : 'money'
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.circulate'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (get_bool( my.acp.circulate() )) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.yes');
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.no');
+ }
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'deleted',
+ 'fm_class' : 'acp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deleted'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (get_bool( my.acp.deleted() )) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.yes');
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.no');
+ }
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'holdable',
+ 'fm_class' : 'acp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.holdable'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (get_bool( my.acp.holdable() )) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.yes');
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.no');
+ }
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'id' : 'opac_visible',
+ 'fm_class' : 'acp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.opac_visible'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (get_bool( my.acp.opac_visible() )) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.yes');
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.no');
+ }
+ },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'acp',
+ 'id' : 'ref',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.reference'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (get_bool( my.acp.ref() )) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.yes');
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.no');
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'acp',
+ 'id' : 'deposit',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.deposit'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (get_bool( my.acp.deposit() )) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.yes');
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.no');
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'acp',
+ 'id' : 'deposit_amount',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_deposit_amount'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.acp.price() == null) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.unset');
+ } else {
+ return util.money.sanitize(my.acp.deposit_amount());
+ }
+ },
+ 'sort_type' : 'money'
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'acp',
- 'id' : 'circ_as_type',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.circ_as_type(); }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'price',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_price'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.acp.price() == null) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.unset');
+ } else {
+ return util.money.sanitize(my.acp.price());
+ }
+ },
+ 'sort_type' : 'money'
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'acp',
+ 'id' : 'circ_as_type',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_as_type'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.circ_as_type(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'acp',
- 'id' : 'circ_modifier',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.circ_modifier(); }
- },
- {
- 'id' : 'status_changed_time',
+ 'id' : 'circ_modifier',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_circ_modifier'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.circ_modifier(); }
+ },
+ {
+ 'id' : 'status_changed_time',
'fm_class' : 'acp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.status_changed_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.status_changed_time(); },
- 'persist' : 'hidden width ordinal'
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.status_changed_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.status_changed_time(); },
+ 'persist' : 'hidden width ordinal'
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'circ',
- 'id' : 'checkout_lib',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_lib'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return data.hash.aou[ my.circ.circ_lib() ].shortname();
- } else {
- if (my.acp.circulations()) {
- return data.hash.aou[ my.acp.circulations()[0].circ_lib() ].shortname();
- } else {
- return "";
- }
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'checkout_lib',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_lib'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return data.hash.aou[ my.circ.circ_lib() ].shortname();
+ } else {
+ if (my.acp.circulations()) {
+ return data.hash.aou[ my.acp.circulations()[0].circ_lib() ].shortname();
+ } else {
+ return "";
+ }
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'circ',
- 'id' : 'xact_start_full',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_timestamp'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return my.circ.xact_start();
- } else {
- if (my.acp.circulations()) {
- return my.acp.circulations()[0].xact_start();
- }
- else {
- return "";
- }
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'xact_start_full',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkout_timestamp'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return my.circ.xact_start();
+ } else {
+ if (my.acp.circulations()) {
+ return my.acp.circulations()[0].xact_start();
+ }
+ else {
+ return "";
+ }
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'circ',
- 'id' : 'checkin_time_full',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_timestamp'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return my.circ.checkin_time();
- } else {
- if (my.acp.circulations()) {
- return my.acp.circulations()[0].checkin_time();
- } else {
- return "";
- }
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'checkin_time_full',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_timestamp'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return my.circ.checkin_time();
+ } else {
+ if (my.acp.circulations()) {
+ return my.acp.circulations()[0].checkin_time();
+ } else {
+ return "";
+ }
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'circ',
- 'id' : 'xact_start',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return my.circ.xact_start().substr(0,10);
- } else {
- if (my.acp.circulations()) {
- return my.acp.circulations()[0].xact_start().substr(0,10);
- } else {
- return "";
- }
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'xact_start',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return my.circ.xact_start().substr(0,10);
+ } else {
+ if (my.acp.circulations()) {
+ return my.acp.circulations()[0].xact_start().substr(0,10);
+ } else {
+ return "";
+ }
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'circ',
- 'id' : 'checkin_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return my.circ.checkin_time().substr(0,10);
- } else {
- if (my.acp.circulations()) {
- return my.acp.circulations()[0].checkin_time().substr(0,10);
- } else {
- return "";
- }
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'checkin_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return my.circ.checkin_time().substr(0,10);
+ } else {
+ if (my.acp.circulations()) {
+ return my.acp.circulations()[0].checkin_time().substr(0,10);
+ } else {
+ return "";
+ }
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'circ',
- 'id' : 'xact_finish',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.circ ? my.circ.xact_finish() : ( my.acp.circulations() ? my.acp.circulations()[0].xact_finish() : ""); },
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'xact_finish',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.circ ? my.circ.xact_finish() : ( my.acp.circulations() ? my.acp.circulations()[0].xact_finish() : ""); },
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'circ',
- 'id' : 'due_date',
- 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return my.circ.due_date().substr(0,10);
- } else {
- if (my.acp.circulations()) {
- return my.acp.circulations()[0].due_date().substr(0,10);
- } else {
- return "";
- }
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'due_date',
+ 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return my.circ.due_date().substr(0,10);
+ } else {
+ if (my.acp.circulations()) {
+ return my.acp.circulations()[0].due_date().substr(0,10);
+ } else {
+ return "";
+ }
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'circ',
- 'id' : 'due_time',
- 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return my.circ.due_date().substr(11,8);
- } else {
- if (my.acp.circulations()) {
- return my.acp.circulations()[0].due_date().substr(11,8);
- } else {
- return "";
- }
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'due_time',
+ 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return my.circ.due_date().substr(11,8);
+ } else {
+ if (my.acp.circulations()) {
+ return my.acp.circulations()[0].due_date().substr(11,8);
+ } else {
+ return "";
+ }
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'acp',
- 'id' : 'create_date',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.create_date().substr(0,10); }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'create_date',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.create_date().substr(0,10); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'acp',
- 'id' : 'edit_date',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.edit_date().substr(0,10); }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'edit_date',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.edit_date().substr(0,10); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'mvr',
- 'id' : 'title',
- 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
- 'flex' : 2,
- 'sort_type' : 'title',
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- try { return my.mvr.title(); }
- catch(E) { return my.acp.dummy_title(); }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'title',
+ 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
+ 'flex' : 2,
+ 'sort_type' : 'title',
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ try { return my.mvr.title(); }
+ catch(E) { return my.acp.dummy_title(); }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'mvr',
- 'id' : 'author',
- 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- try { return my.mvr.author(); }
- catch(E) { return my.acp.dummy_author(); }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'author',
+ 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ try { return my.mvr.author(); }
+ catch(E) { return my.acp.dummy_author(); }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'mvr',
- 'id' : 'edition',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.edition(); }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'edition',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.mvr.edition(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'mvr',
- 'id' : 'isbn',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
+ 'id' : 'isbn',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
try { return my.mvr.isbn(); }
catch(E) { return my.acp.dummy_isbn(); }
}
- },
- {
- 'persist' : 'hidden width ordinal',
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'mvr',
- 'id' : 'pubdate',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.pubdate(); }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'pubdate',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.mvr.pubdate(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'mvr',
- 'id' : 'publisher',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.publisher(); }
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'publisher',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.mvr.publisher(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'mvr',
- 'id' : 'tcn',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.tcn(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'fm_class' : 'circ',
- 'id' : 'renewal_remaining',
- 'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return my.circ.renewal_remaining();
- } else {
- if (my.acp.circulations()) {
- return my.acp.circulations()[0].renewal_remaining();
- } else {
- return "";
- }
- }
- },
- 'sort_type' : 'number'
- },
- {
- 'persist' : 'hidden width ordinal',
- 'fm_class' : 'circ',
- 'id' : 'stop_fines',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return my.circ.stop_fines();
- } else {
- if (my.acp.circulations()) {
- return my.acp.circulations()[0].stop_fines();
- } else {
- return "";
- }
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'fm_class' : 'circ',
- 'id' : 'stop_fines_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.circ) {
- return my.circ.stop_fines_time();
- } else {
- if (my.acp.circulations()) {
- return my.acp.circulations()[0].stop_fines_time();
- } else {
- return "";
- }
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'fm_class' : 'acp',
- 'id' : 'status',
- 'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (Number(my.acp.status())>=0) {
- return data.hash.ccs[ my.acp.status() ].name();
- } else {
- return my.acp.status().name();
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'route_to',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.route_to.toString(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'message',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.message.toString(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'uses',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.uses; },
- 'sort_type' : 'number'
- },
- {
- 'persist' : 'hidden width ordinal',
+ 'id' : 'tcn',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.mvr.tcn(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'circ',
+ 'id' : 'renewal_remaining',
+ 'label' : document.getElementById('commonStrings').getString('staff.circ_label_renewal_remaining'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return my.circ.renewal_remaining();
+ } else {
+ if (my.acp.circulations()) {
+ return my.acp.circulations()[0].renewal_remaining();
+ } else {
+ return "";
+ }
+ }
+ },
+ 'sort_type' : 'number'
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'circ',
+ 'id' : 'stop_fines',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return my.circ.stop_fines();
+ } else {
+ if (my.acp.circulations()) {
+ return my.acp.circulations()[0].stop_fines();
+ } else {
+ return "";
+ }
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'circ',
+ 'id' : 'stop_fines_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.circ) {
+ return my.circ.stop_fines_time();
+ } else {
+ if (my.acp.circulations()) {
+ return my.acp.circulations()[0].stop_fines_time();
+ } else {
+ return "";
+ }
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
'fm_class' : 'acp',
- 'id' : 'alert_message',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.alert_message(); }
- },
+ 'id' : 'status',
+ 'label' : document.getElementById('commonStrings').getString('staff.acp_label_status'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (Number(my.acp.status())>=0) {
+ return data.hash.ccs[ my.acp.status() ].name();
+ } else {
+ return my.acp.status().name();
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'route_to',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.route_to'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.route_to.toString(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'message',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.message'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.message.toString(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'uses',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.uses'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.uses; },
+ 'sort_type' : 'number'
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'acp',
+ 'id' : 'alert_message',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.alert_message'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.alert_message(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'circ',
+ 'id' : 'checkin_workstation',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_workstation'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.circ ? ( typeof my.circ.checkin_workstation() == 'object' ? my.circ.checkin_workstation().name() : my.circ.checkin_workstation() ) : ( my.acp.circulations() ? ( typeof my.acp.circulations()[0].checkin_workstation() == 'object' ? my.acp.circulations().checkin_workstation().name() : my.acp.circulations().checkin_workstation() ) : ""); },
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'circ',
+ 'id' : 'checkin_scan_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.circ ? my.circ.checkin_scan_time().substr(0,10) : ( my.acp.circulations() ? my.acp.circulations()[0].checkin_scan_time().substr(0,10) : ""); },
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'circ',
+ 'id' : 'checkin_scan_timestamp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_timestamp'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.circ ? my.circ.checkin_scan_time() : ( my.acp.circulations() ? my.acp.circulations()[0].checkin_scan_time() : ""); },
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'bre',
+ 'id' : 'creator',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.creator'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.bre ? (typeof my.bre.creator() == 'object' ? my.bre.creator().usrname() : '#' + my.bre.creator() ) : ''; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'bre',
+ 'id' : 'editor',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.editor'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.bre ? (typeof my.bre.editor() == 'object' ? my.bre.editor().usrname() : '#' + my.bre.editor() ) : ''; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'bre',
+ 'id' : 'create_date',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.bre ? my.bre.create_date() : ''; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'bre',
+ 'id' : 'edit_date',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.bre ? my.bre.edit_date() : ''; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'bre',
+ 'id' : 'tcn_value',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.bre ? my.bre.tcn_value() : ''; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'fm_class' : 'bre',
+ 'id' : 'tcn_source',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn_source'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.bre ? my.bre.tcn_source() : ''; }
+ }
+
+ ];
+ for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+};
+
+circ.util.work_log_columns = function(modify,params) {
+
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+
+ var c = [
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'message',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.message'),
+ 'flex' : 3,
+ 'primary' : true,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.message; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'when',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.when'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return String( my.when ); }
+ }
+
+ ];
+ for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+};
+
+circ.util.transit_columns = function(modify,params) {
+
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+
+ var c = [
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_item_barcode',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acp.barcode(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_item_title',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ try { return my.mvr.title(); }
+ catch(E) { return my.acp.dummy_title(); }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_item_author',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ try { return my.mvr.author(); }
+ catch(E) { return my.acp.dummy_author(); }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_item_callnumber',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acn.label(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_id',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.atc.id(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_source',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) {
+ if (typeof my.atc.source() == "object") {
+ return my.atc.source().shortname();
+ } else {
+ return data.hash.aou[ my.atc.source() ].shortname();
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_source_send_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.atc.source_send_time(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_dest_lib',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) {
+ if (typeof my.atc.dest() == "object") {
+ return my.atc.dest().shortname();
+ } else {
+ return data.hash.aou[ my.atc.dest() ].shortname();
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_dest_recv_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) { return my.atc.dest_recv_time(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_target_copy',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.atc.target_copy(); }
+ },
+ ];
+ for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+};
+
+circ.util.hold_columns = function(modify,params) {
+
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+
+ var c = [
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'request_lib',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (Number(my.ahr.request_lib())>=0) {
+ return data.hash.aou[ my.ahr.request_lib() ].name();
+ } else {
+ return my.ahr.request_lib().name();
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'request_lib_shortname',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (Number(my.ahr.request_lib())>=0) {
+ return data.hash.aou[ my.ahr.request_lib() ].shortname();
+ } else {
+ return my.ahr.request_lib().shortname();
+ }
+ }
+ },
+
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'request_timestamp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.request_time().toString(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'request_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'available_timestamp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
+ return my.ahr.transit().dest_recv_time().toString();
+ }
+ if (!my.ahr.transit() && my.ahr.capture_time()) {
+ return my.ahr.capture_time().toString();
+ }
+ return "";
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'available_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) {
+ if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
+ return my.ahr.transit().dest_recv_time().toString().substr(0,10);
+ }
+ if (!my.ahr.transit() && my.ahr.capture_time()) {
+ return my.ahr.capture_time().toString().substr(0,10);
+ }
+ return "";
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'capture_timestamp',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'capture_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'status',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : false,
+ 'editable' : false, 'render' : function(my) {
+ switch (Number(my.status)) {
+ case 1:
+ return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
+ break;
+ case 2:
+ return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
+ break;
+ case 3:
+ return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
+ break;
+ case 4:
+ return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
+ break;
+ case 5:
+ return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.5');
+ break;
+ default:
+ return my.status;
+ break;
+ };
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'hold_type',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.hold_type(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'frozen',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (!get_bool( my.ahr.frozen() )) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.yes');
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.no');
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'thaw_date',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.ahr.thaw_date() == null) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
+ } else {
+ return my.ahr.thaw_date().substr(0,10);
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'pickup_lib',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (Number(my.ahr.pickup_lib())>=0) {
+ return data.hash.aou[ my.ahr.pickup_lib() ].name();
+ } else {
+ return my.ahr.pickup_lib().name();
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'pickup_lib_shortname',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
+ 'flex' : 0,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (Number(my.ahr.pickup_lib())>=0) {
+ return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
+ } else {
+ return my.ahr.pickup_lib().shortname();
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'current_copy',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (my.acp) {
+ return my.acp.barcode();
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'current_copy_location',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (!my.acp) { return ""; } else { if (Number(my.acp.location())>=0) return data.lookup("acpl", my.acp.location() ).name(); else return my.acp.location().name(); }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'email_notify',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) {
+ if (get_bool(my.ahr.email_notify())) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.yes');
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.no');
+ }
+ }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'expire_time',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.expire_time(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'expire_date',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.expire_time() ? my.ahr.expire_time().toString().substr(0,10) : ''; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'fulfillment_time',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.fulfillment_time(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'holdable_formats',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.holdable_formats(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'ahr_id',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.id(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'phone_notify',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.phone_notify(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'prev_check_time',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.prev_check_time(); }
+ },
{
'persist' : 'hidden width ordinal',
- 'fm_class' : 'circ',
- 'id' : 'checkin_workstation',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_workstation'),
+ 'id' : 'requestor',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
'flex' : 1,
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.circ ? ( typeof my.circ.checkin_workstation() == 'object' ? my.circ.checkin_workstation().name() : my.circ.checkin_workstation() ) : ( my.acp.circulations() ? ( typeof my.acp.circulations()[0].checkin_workstation() == 'object' ? my.acp.circulations().checkin_workstation().name() : my.acp.circulations().checkin_workstation() ) : ""); },
+ 'editable' : false, 'render' : function(my) { return my.ahr.requestor(); }
},
{
'persist' : 'hidden width ordinal',
- 'fm_class' : 'circ',
- 'id' : 'checkin_scan_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_time'),
+ 'id' : 'selection_depth',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
'flex' : 1,
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.circ ? my.circ.checkin_scan_time().substr(0,10) : ( my.acp.circulations() ? my.acp.circulations()[0].checkin_scan_time().substr(0,10) : ""); },
+ 'editable' : false, 'render' : function(my) { return my.ahr.selection_depth(); }
},
{
'persist' : 'hidden width ordinal',
- 'fm_class' : 'circ',
- 'id' : 'checkin_scan_timestamp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_timestamp'),
+ 'id' : 'target',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
'flex' : 1,
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.circ ? my.circ.checkin_scan_time() : ( my.acp.circulations() ? my.acp.circulations()[0].checkin_scan_time() : ""); },
+ 'editable' : false, 'render' : function(my) { return my.ahr.target(); }
},
{
'persist' : 'hidden width ordinal',
- 'fm_class' : 'bre',
- 'id' : 'creator',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.creator'),
+ 'id' : 'usr',
+ 'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
'flex' : 1,
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.bre ? (typeof my.bre.creator() == 'object' ? my.bre.creator().usrname() : '#' + my.bre.creator() ) : ''; }
+ 'editable' : false, 'render' : function(my) { return my.ahr.usr(); }
},
{
'persist' : 'hidden width ordinal',
- 'fm_class' : 'bre',
- 'id' : 'editor',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.editor'),
+ 'id' : 'title',
+ 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
'flex' : 1,
+ 'sort_type' : 'title',
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.bre ? (typeof my.bre.editor() == 'object' ? my.bre.editor().usrname() : '#' + my.bre.editor() ) : ''; }
+ 'editable' : false, 'render' : function(my) {
+ if (my.mvr) {
+ return my.mvr.title();
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
+ }
+ }
},
{
'persist' : 'hidden width ordinal',
- 'fm_class' : 'bre',
- 'id' : 'create_date',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
+ 'id' : 'author',
+ 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
'flex' : 1,
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.bre ? my.bre.create_date() : ''; }
+ 'editable' : false, 'render' : function(my) {
+ if (my.mvr) {
+ return my.mvr.author();
+ } else {
+ return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
+ }
+ }
},
{
'persist' : 'hidden width ordinal',
- 'fm_class' : 'bre',
- 'id' : 'edit_date',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
+ 'id' : 'edition',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
'flex' : 1,
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.bre ? my.bre.edit_date() : ''; }
+ 'editable' : false, 'render' : function(my) { return my.mvr.edition(); }
},
{
'persist' : 'hidden width ordinal',
- 'fm_class' : 'bre',
- 'id' : 'tcn_value',
+ 'id' : 'isbn',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.mvr.isbn(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'pubdate',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.mvr.pubdate(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'publisher',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.mvr.publisher(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'tcn',
'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
'flex' : 1,
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.bre ? my.bre.tcn_value() : ''; }
+ 'editable' : false, 'render' : function(my) { return my.mvr.tcn(); }
},
{
'persist' : 'hidden width ordinal',
- 'fm_class' : 'bre',
- 'id' : 'tcn_source',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn_source'),
+ 'id' : 'notify_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
'flex' : 1,
'primary' : false,
'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.bre ? my.bre.tcn_source() : ''; }
- }
-
- ];
- for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
-};
-
-circ.util.work_log_columns = function(modify,params) {
-
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
-
- var c = [
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'message',
- 'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.message'),
- 'flex' : 3,
- 'primary' : true,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.message; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'when',
- 'label' : document.getElementById('circStrings').getString('staff.circ.work_log_column.when'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return String( my.when ); }
- }
-
- ];
- for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
-};
-
-circ.util.transit_columns = function(modify,params) {
-
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
-
- var c = [
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_item_barcode',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.barcode'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acp.barcode(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_item_title',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.title'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- try { return my.mvr.title(); }
- catch(E) { return my.acp.dummy_title(); }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_item_author',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.author'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- try { return my.mvr.author(); }
- catch(E) { return my.acp.dummy_author(); }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_item_callnumber',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acn.label(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_id',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_id'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.atc.id(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_source',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) {
- if (typeof my.atc.source() == "object") {
- return my.atc.source().shortname();
- } else {
- return data.hash.aou[ my.atc.source() ].shortname();
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_source_send_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.atc.source_send_time(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_dest_lib',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) {
- if (typeof my.atc.dest() == "object") {
- return my.atc.dest().shortname();
- } else {
- return data.hash.aou[ my.atc.dest() ].shortname();
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_dest_recv_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) { return my.atc.dest_recv_time(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_target_copy',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_target_copy'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.atc.target_copy(); }
- },
- ];
- for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
-};
-
-circ.util.hold_columns = function(modify,params) {
-
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
-
- var c = [
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'request_lib',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (Number(my.ahr.request_lib())>=0) {
- return data.hash.aou[ my.ahr.request_lib() ].name();
- } else {
- return my.ahr.request_lib().name();
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'request_lib_shortname',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_lib_shortname'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (Number(my.ahr.request_lib())>=0) {
- return data.hash.aou[ my.ahr.request_lib() ].shortname();
- } else {
- return my.ahr.request_lib().shortname();
- }
- }
- },
-
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'request_timestamp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_timestamp'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.request_time().toString(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'request_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'available_timestamp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_timestamp'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
- return my.ahr.transit().dest_recv_time().toString();
- }
- if (!my.ahr.transit() && my.ahr.capture_time()) {
- return my.ahr.capture_time().toString();
- }
- return "";
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'available_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) {
- if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) {
- return my.ahr.transit().dest_recv_time().toString().substr(0,10);
- }
- if (!my.ahr.transit() && my.ahr.capture_time()) {
- return my.ahr.capture_time().toString().substr(0,10);
- }
- return "";
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'capture_timestamp',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_timestamp'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'capture_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'status',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_status_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : false,
- 'editable' : false, 'render' : function(my) {
- switch (Number(my.status)) {
- case 1:
- return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.1');
- break;
- case 2:
- return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.2');
- break;
- case 3:
- return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.3');
- break;
- case 4:
- return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.4');
- break;
- case 5:
- return document.getElementById('circStrings').getString('staff.circ.utils.hold_status.5');
- break;
- default:
- return my.status;
- break;
- };
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'hold_type',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_hold_type_label'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.hold_type(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'frozen',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.active'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (!get_bool( my.ahr.frozen() )) {
- return document.getElementById('circStrings').getString('staff.circ.utils.yes');
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.no');
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'thaw_date',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.ahr.thaw_date() == null) {
- return document.getElementById('circStrings').getString('staff.circ.utils.thaw_date.none');
- } else {
- return my.ahr.thaw_date().substr(0,10);
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'pickup_lib',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pickup_lib'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (Number(my.ahr.pickup_lib())>=0) {
- return data.hash.aou[ my.ahr.pickup_lib() ].name();
- } else {
- return my.ahr.pickup_lib().name();
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'pickup_lib_shortname',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_pickup_lib_label'),
- 'flex' : 0,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (Number(my.ahr.pickup_lib())>=0) {
- return data.hash.aou[ my.ahr.pickup_lib() ].shortname();
- } else {
- return my.ahr.pickup_lib().shortname();
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'current_copy',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.acp) {
- return my.acp.barcode();
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.current_copy.none');
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'current_copy_location',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_current_copy_location_label'),
- 'flex' : 1,
- 'primary' : false,
+ 'editable' : false, 'render' : function(my) { return my.ahr.notify_time(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'notify_count',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.notify_count(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_source',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
+ 'flex' : 1,
+ 'primary' : false,
'hidden' : true,
'editable' : false, 'render' : function(my) {
- if (!my.acp) { return ""; } else { if (Number(my.acp.location())>=0) return data.lookup("acpl", my.acp.location() ).name(); else return my.acp.location().name(); }
+ if (my.ahr.transit()) {
+ return data.hash.aou[ my.ahr.transit().source() ].shortname();
+ } else {
+ return "";
+ }
}
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'email_notify',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_email_notify_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (get_bool(my.ahr.email_notify())) {
- return document.getElementById('circStrings').getString('staff.circ.utils.yes');
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.no');
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'expire_time',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_time_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.expire_time(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'expire_date',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.expire_time() ? my.ahr.expire_time().toString().substr(0,10) : ''; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'fulfillment_time',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.fulfillment_time(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'holdable_formats',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_holdable_formats_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.holdable_formats(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'ahr_id',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_id_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.id(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'phone_notify',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_phone_notify_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.phone_notify(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'prev_check_time',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.prev_check_time(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'requestor',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_requestor_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.requestor(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'selection_depth',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_selection_depth_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.selection_depth(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'target',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_target_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.target(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'usr',
- 'label' : document.getElementById('commonStrings').getString('staff.ahr_usr_label'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.usr(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'title',
- 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_title'),
- 'flex' : 1,
- 'sort_type' : 'title',
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.mvr) {
- return my.mvr.title();
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.title.none');
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'author',
- 'label' : document.getElementById('commonStrings').getString('staff.mvr_label_author'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.mvr) {
- return my.mvr.author();
- } else {
- return document.getElementById('circStrings').getString('staff.circ.utils.author.none');
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'edition',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edition'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.edition(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'isbn',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.isbn'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.isbn(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'pubdate',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.pubdate'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.pubdate(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'publisher',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.publisher'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.publisher(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'tcn',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.tcn'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.mvr.tcn(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'notify_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.notify_time(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'notify_count',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_count'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.notify_count(); }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_source',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) {
- if (my.ahr.transit()) {
- return data.hash.aou[ my.ahr.transit().source() ].shortname();
- } else {
- return "";
- }
- }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_source_send_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_dest_lib',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'transit_dest_recv_time',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'patron_barcode',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'patron_family_name',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'patron_first_given_name',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'callnumber',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.acn.label(); }
- },
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_source_send_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_dest_lib',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'transit_dest_recv_time',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'patron_barcode',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.offline.patron_barcode'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'patron_family_name',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_family_name'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'patron_first_given_name',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.patron_first_given_name'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'callnumber',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.callnumber'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.acn.label(); }
+ },
{
- 'persist' : 'hidden width ordinal',
- 'id' : 'total_holds',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.total_holds'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.total_holds; }
- },
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'total_holds',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.total_holds'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.total_holds; }
+ },
{
- 'persist' : 'hidden width ordinal',
- 'id' : 'queue_position',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.queue_position'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.queue_position; }
- },
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'queue_position',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.queue_position'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.queue_position; }
+ },
{
- 'persist' : 'hidden width ordinal',
- 'id' : 'potential_copies',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.potential_copies'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.potential_copies; }
- },
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'potential_copies',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.potential_copies'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.potential_copies; }
+ },
{
- 'persist' : 'hidden width ordinal',
- 'id' : 'estimated_wait',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.estimated_wait'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.estimated_wait; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'hold_note',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_note'),
- 'flex' : 1,
- 'primary' : false,
- 'hidden' : true,
- 'editable' : false, 'render' : function(my) { return my.ahrn_count; }
- },
- {
- 'persist' : 'hidden width ordinal',
- 'id' : 'staff_hold',
- 'label' : document.getElementById('circStrings').getString('staff.circ.utils.staff_hold'),
- 'flex' : 1,
- 'primary' : false,
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'estimated_wait',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.estimated_wait'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.estimated_wait; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'hold_note',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_note'),
+ 'flex' : 1,
+ 'primary' : false,
+ 'hidden' : true,
+ 'editable' : false, 'render' : function(my) { return my.ahrn_count; }
+ },
+ {
+ 'persist' : 'hidden width ordinal',
+ 'id' : 'staff_hold',
+ 'label' : document.getElementById('circStrings').getString('staff.circ.utils.staff_hold'),
+ 'flex' : 1,
+ 'primary' : false,
'hidden' : true,
'editable' : false,
'render' : function(my) {
}
}
];
- for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
};
/*
circ.util.std_map_row_to_column = function(error_value) {
- return function(row,col) {
- // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
- // col contains one of the objects listed above in columns
-
- // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
- var obj = {};
- JSAN.use('util.error'); obj.error = new util.error();
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
- JSAN.use('util.network'); obj.network = new util.network();
- JSAN.use('util.money');
-
- var my = row.my;
- var value;
- try {
- value = eval( col.render );
- } catch(E) {
- obj.error.sdump('D_WARN','map_row_to_column: ' + E);
- if (error_value) value = error_value; else value = ' ';
- }
- return value;
- }
+ return function(row,col) {
+ // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
+ // col contains one of the objects listed above in columns
+
+ // mimicking some of the obj in circ.checkin and circ.checkout where map_row_to_column is usually defined
+ var obj = {};
+ JSAN.use('util.error'); obj.error = new util.error();
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+ JSAN.use('util.network'); obj.network = new util.network();
+ JSAN.use('util.money');
+
+ var my = row.my;
+ var value;
+ try {
+ value = eval( col.render );
+ } catch(E) {
+ obj.error.sdump('D_WARN','map_row_to_column: ' + E);
+ if (error_value) value = error_value; else value = ' ';
+ }
+ return value;
+ }
};
*/
circ.util.std_map_row_to_columns = function(error_value) {
- return function(row,cols) {
- // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
- // cols contains all of the objects listed above in columns
-
- var obj = {};
- JSAN.use('util.error'); obj.error = new util.error();
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
- JSAN.use('util.network'); obj.network = new util.network();
- JSAN.use('util.money');
-
- var my = row.my;
- var values = [];
- var cmd = '';
- try {
- for (var i = 0; i < cols.length; i++) {
- switch (typeof cols[i].render) {
- case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
- case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
- default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
- }
- }
- if (cmd) eval( cmd );
- } catch(E) {
- obj.error.sdump('D_WARN','map_row_to_column: ' + E);
- if (error_value) { value = error_value; } else { value = ' ' };
- }
- return values;
- }
+ return function(row,cols) {
+ // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } }
+ // cols contains all of the objects listed above in columns
+
+ var obj = {};
+ JSAN.use('util.error'); obj.error = new util.error();
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'});
+ JSAN.use('util.network'); obj.network = new util.network();
+ JSAN.use('util.money');
+
+ var my = row.my;
+ var values = [];
+ var cmd = '';
+ try {
+ for (var i = 0; i < cols.length; i++) {
+ switch (typeof cols[i].render) {
+ case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
+ case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
+ default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
+ }
+ }
+ if (cmd) eval( cmd );
+ } catch(E) {
+ obj.error.sdump('D_WARN','map_row_to_column: ' + E);
+ if (error_value) { value = error_value; } else { value = ' ' };
+ }
+ return values;
+ }
};
circ.util.checkin_via_barcode = function(session,params,backdate,auto_print,async) {
- try {
- JSAN.use('util.error'); var error = new util.error();
- JSAN.use('util.network'); var network = new util.network();
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- JSAN.use('util.date'); JSAN.use('util.functional');
+ try {
+ JSAN.use('util.error'); var error = new util.error();
+ JSAN.use('util.network'); var network = new util.network();
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ JSAN.use('util.date'); JSAN.use('util.functional');
- if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
+ if (backdate && (backdate == util.date.formatted_date(new Date(),'%Y-%m-%d')) ) backdate = null;
- //var params = { 'barcode' : barcode };
- if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
+ //var params = { 'barcode' : barcode };
+ if (backdate) params.backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
- if (typeof params.disable_textbox == 'function') {
- try { params.disable_textbox(); }
- catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
- }
+ if (typeof params.disable_textbox == 'function') {
+ try { params.disable_textbox(); }
+ catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
+ }
function checkin_callback(req) {
JSAN.use('util.error'); var error = new util.error();
if (typeof params.checkin_result == 'function') {
try { params.checkin_result(r); } catch(E) { error.sdump('D_ERROR','params.checkin_result() = ' + E); };
}
- if (typeof async == 'function') async(check);
- return check;
+ if (typeof async == 'function') async(check);
+ return check;
} catch(E) {
error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['1']), E);
if (typeof params.enable_textbox == 'function') {
}
}
- var check = network.request(
- api.CHECKIN_VIA_BARCODE.app,
- api.CHECKIN_VIA_BARCODE.method,
- [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
- async ? checkin_callback : null,
- {
- 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
- 'overridable_events' : [
+ var check = network.request(
+ api.CHECKIN_VIA_BARCODE.app,
+ api.CHECKIN_VIA_BARCODE.method,
+ [ session, util.functional.filter_object( params, function(i,o) { return typeof o != 'function'; } ) ],
+ async ? checkin_callback : null,
+ {
+ 'title' : document.getElementById('circStrings').getString('staff.circ.utils.checkin.override'),
+ 'overridable_events' : [
null /* custom event */,
- 1203 /* COPY_BAD_STATUS */,
- 1213 /* PATRON_BARRED */,
- 1217 /* PATRON_INACTIVE */,
- 1224 /* PATRON_ACCOUNT_EXPIRED */,
- 1234 /* ITEM_DEPOSIT_PAID */,
- 7009 /* CIRC_CLAIMS_RETURNED */,
- 7010 /* COPY_ALERT_MESSAGE */,
- 7011 /* COPY_STATUS_LOST */,
- 7012 /* COPY_STATUS_MISSING */,
- 7013 /* PATRON_EXCEEDS_FINES */,
- ],
- 'text' : {
- '1203' : function(r) {
- return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
- },
- '1234' : function(r) {
- return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
- },
- '7010' : function(r) {
- return r.payload;
- }
- }
- }
- );
- if (! async ) {
- return checkin_callback( { 'getResultObject' : function() { return check; } } );
- }
-
-
- } catch(E) {
- JSAN.use('util.error'); var error = new util.error();
- error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
- if (typeof params.enable_textbox == 'function') {
- try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
- }
- return null;
- }
+ 1203 /* COPY_BAD_STATUS */,
+ 1213 /* PATRON_BARRED */,
+ 1217 /* PATRON_INACTIVE */,
+ 1224 /* PATRON_ACCOUNT_EXPIRED */,
+ 1234 /* ITEM_DEPOSIT_PAID */,
+ 7009 /* CIRC_CLAIMS_RETURNED */,
+ 7010 /* COPY_ALERT_MESSAGE */,
+ 7011 /* COPY_STATUS_LOST */,
+ 7012 /* COPY_STATUS_MISSING */,
+ 7013 /* PATRON_EXCEEDS_FINES */,
+ ],
+ 'text' : {
+ '1203' : function(r) {
+ return typeof r.payload.status() == 'object' ? r.payload.status().name() : data.hash.ccs[ r.payload.status() ].name();
+ },
+ '1234' : function(r) {
+ return document.getElementById('circStrings').getString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
+ },
+ '7010' : function(r) {
+ return r.payload;
+ }
+ }
+ }
+ );
+ if (! async ) {
+ return checkin_callback( { 'getResultObject' : function() { return check; } } );
+ }
+
+
+ } catch(E) {
+ JSAN.use('util.error'); var error = new util.error();
+ error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['2']), E);
+ if (typeof params.enable_textbox == 'function') {
+ try { params.enable_textbox(); } catch(E) { error.sdump('D_ERROR','params.disable_textbox() = ' + E); };
+ }
+ return null;
+ }
};
circ.util.checkin_via_barcode2 = function(session,params,backdate,auto_print,check) {
- try {
- JSAN.use('util.error'); var error = new util.error();
- JSAN.use('util.network'); var network = new util.network();
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- JSAN.use('util.date');
+ try {
+ JSAN.use('util.error'); var error = new util.error();
+ JSAN.use('util.network'); var network = new util.network();
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ JSAN.use('util.date');
- error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
+ error.sdump('D_DEBUG','check = ' + error.pretty_print( js2JSON( check ) ) );
- check.message = check.textcode;
+ check.message = check.textcode;
- if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
- if (check.payload && check.payload.record) { check.record = check.payload.record; }
- if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
- if (check.payload && check.payload.patron) { check.patron = check.payload.patron; }
+ if (check.payload && check.payload.copy) { check.copy = check.payload.copy; }
+ if (check.payload && check.payload.record) { check.record = check.payload.record; }
+ if (check.payload && check.payload.circ) { check.circ = check.payload.circ; }
+ if (check.payload && check.payload.patron) { check.patron = check.payload.patron; }
- if (!check.route_to) { check.route_to = ' '; }
+ if (!check.route_to) { check.route_to = ' '; }
- if (document.getElementById('no_change_label')) {
- document.getElementById('no_change_label').setAttribute('value','');
- document.getElementById('no_change_label').setAttribute('hidden','true');
- }
+ if (document.getElementById('no_change_label')) {
+ document.getElementById('no_change_label').setAttribute('value','');
+ document.getElementById('no_change_label').setAttribute('hidden','true');
+ }
- var msg = '';
+ var msg = '';
var print_list = [];
var print_data = {
'error' : '',
'slip_date_msg' : ''
};
- if (check.payload && check.payload.cancelled_hold_transit) {
- print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
+ if (check.payload && check.payload.cancelled_hold_transit) {
+ print_data.cancelled = document.getElementById('circStrings').getString('staff.circ.utils.transit_hold_cancelled');
msg += print_data.cancelled;
- msg += '\n\n';
- }
-
- /* SUCCESS / NO_CHANGE / ITEM_NOT_CATALOGED */
- if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
- try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
- catch(E) {
- print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
- print_data.error_msg += '\nFIXME: ' + E + '\n';
+ msg += '\n\n';
+ }
+
+ /* SUCCESS / NO_CHANGE / ITEM_NOT_CATALOGED */
+ if (check.ilsevent == 0 || check.ilsevent == 3 || check.ilsevent == 1202) {
+ try { check.route_to = data.lookup('acpl', check.copy.location() ).name(); }
+ catch(E) {
+ print_data.error_msg = document.getElementById('commonStrings').getString('common.error');
+ print_data.error_msg += '\nFIXME: ' + E + '\n';
msg += print_data.error_msg;
- }
- if (check.ilsevent == 3 /* NO_CHANGE */) {
- //msg = 'This item is already checked in.\n';
- if (document.getElementById('no_change_label')) {
- var m = document.getElementById('no_change_label').getAttribute('value');
- document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + ' ');
- document.getElementById('no_change_label').setAttribute('hidden','false');
- }
- }
- if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
- var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
- var err_msg = document.getElementById('commonStrings').getString('common.error');
- err_msg += '\nFIXME --';
- err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
- err_msg += '\n';
+ }
+ if (check.ilsevent == 3 /* NO_CHANGE */) {
+ //msg = 'This item is already checked in.\n';
+ if (document.getElementById('no_change_label')) {
+ var m = document.getElementById('no_change_label').getAttribute('value');
+ document.getElementById('no_change_label').setAttribute('value', m + document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_checked_in', [params.barcode]) + ' ');
+ document.getElementById('no_change_label').setAttribute('hidden','false');
+ }
+ }
+ if (check.ilsevent == 1202 /* ITEM_NOT_CATALOGED */ && check.copy.status() != 11) {
+ var copy_status = (data.hash.ccs[ check.copy.status() ] ? data.hash.ccs[ check.copy.status() ].name() : check.copy.status().name() );
+ var err_msg = document.getElementById('commonStrings').getString('common.error');
+ err_msg += '\nFIXME --';
+ err_msg += document.getElementById('circStrings').getFormattedString('staff.circ.utils.item_not_cataloged', [copy_status]);
+ err_msg += '\n';
msg += err_msg;
print_data.error_msg += err_msg;
- }
- switch(Number(check.copy.status())) {
- case 0: /* AVAILABLE */
- case 7: /* RESHELVING */
- if (msg) {
- print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
+ }
+ switch(Number(check.copy.status())) {
+ case 0: /* AVAILABLE */
+ case 7: /* RESHELVING */
+ if (msg) {
+ print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
print_data.route_to = check.route_to;
msg += print_data.route_to_msg;
- msg += '\n';
- }
- break;
- case 8: /* ON HOLDS SHELF */
+ msg += '\n';
+ }
+ break;
+ case 8: /* ON HOLDS SHELF */
check.route_to = document.getElementById('circStrings').getString('staff.circ.route_to.hold_shelf');
- if (check.payload.hold) {
- if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
- var err_msg = document.getElementById('commonStrings').getString('common.error');
- err_msg += '\nFIXME: ';
- err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
- err_msg += '\n';
+ if (check.payload.hold) {
+ if (check.payload.hold.pickup_lib() != data.list.au[0].ws_ou()) {
+ var err_msg = document.getElementById('commonStrings').getString('common.error');
+ err_msg += '\nFIXME: ';
+ err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_error');
+ err_msg += '\n';
msg += err_msg;
print_data.error_msg += err_msg;
- } else {
- print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
+ } else {
+ print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
print_data.route_to = check.route_to;
var behind_the_desk_support = String( data.hash.aous['circ.holds.behind_desk_pickup_supported'] ) == 'true';
if (behind_the_desk_support) {
}
}
msg += print_data.route_to_msg;
- msg += '\n';
- }
- } else {
- var err_msg = document.getElementById('commonStrings').getString('common.error');
- err_msg += '\nFIXME: ';
- err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
- err_msg += '\n';
+ msg += '\n';
+ }
+ } else {
+ var err_msg = document.getElementById('commonStrings').getString('common.error');
+ err_msg += '\nFIXME: ';
+ err_msg += document.getElementById('circStrings').getString('staff.circ.utils.route_item_status_error');
+ err_msg += '\n';
msg += err_msg;
print_data.error_msg += err_msg;
- }
- JSAN.use('util.date');
- if (check.payload.hold) {
- JSAN.use('patron.util');
- msg += '\n';
- print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
+ }
+ JSAN.use('util.date');
+ if (check.payload.hold) {
+ JSAN.use('patron.util');
+ msg += '\n';
+ print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
print_data.item_barcode = check.payload.copy.barcode();
msg += print_data.item_barcode_msg;
- msg += '\n';
- var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
- print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
+ msg += '\n';
+ var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
+ print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
print_data.item_title = payload_title;
msg += print_data.item_title_msg;
- msg += '\n';
- var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
+ msg += '\n';
+ var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
print_data.user = au_obj;
- msg += '\n';
+ msg += '\n';
if (au_obj.alias()) {
- print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias', [au_obj.alias()]);
+ print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias', [au_obj.alias()]);
print_data.hold_for_alias = au_obj.alias();
msg += print_data.hold_for_msg;
} else {
- print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name() ? au_obj.family_name() : '', au_obj.first_given_name() ? au_obj.first_given_name() : '', au_obj.second_given_name() ? au_obj.second_given_name() : '']);
+ print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron', [au_obj.family_name() ? au_obj.family_name() : '', au_obj.first_given_name() ? au_obj.first_given_name() : '', au_obj.second_given_name() ? au_obj.second_given_name() : '']);
msg += print_data.hold_for_msg;
print_data.hold_for_family_name = au_obj.family_name() ? au_obj.family_name() : '';
print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
}
- msg += '\n';
- print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
+ msg += '\n';
+ print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
print_data.user_barcode = au_obj.card().barcode();
msg += print_data.user_barcode_msg;
- msg += '\n';
- if (check.payload.hold.phone_notify()) {
- print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
+ msg += '\n';
+ if (check.payload.hold.phone_notify()) {
+ print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
print_data.notify_by_phone = check.payload.hold.phone_notify();
msg += print_data.notify_by_phone_msg;
- msg += '\n';
- }
- if (get_bool(check.payload.hold.email_notify())) {
- var payload_email = au_obj.email() ? au_obj.email() : '';
- print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
+ msg += '\n';
+ }
+ if (get_bool(check.payload.hold.email_notify())) {
+ var payload_email = au_obj.email() ? au_obj.email() : '';
+ print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
print_data.notify_by_email = payload_email;
msg += print_data.notify_by_email_msg;
- msg += '\n';
- }
- msg += '\n';
+ msg += '\n';
+ }
+ msg += '\n';
var notes = check.payload.hold.notes();
print_data.notes_raw = notes;
for (var i = 0; i < notes.length; i++) {
);
}
}
- msg += '\n';
- msg += '\n';
+ msg += '\n';
+ msg += '\n';
print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
- print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
+ print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
msg += print_data.request_date_msg;
- msg += '\n';
- }
- var rv = 0;
+ msg += '\n';
+ }
+ var rv = 0;
var no_print_prompting = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
if (no_print_prompting) {
if (no_print_prompting.indexOf( "Hold Slip" ) > -1) {
}
}
print_data.slip_date = util.date.formatted_date(new Date(),'%F');
- print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
+ print_data.slip_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.slip_date', [print_data.slip_date]);
msg += print_data.slip_date_msg;
- msg += '\n';
+ msg += '\n';
print_data.payload = check.payload;
- if (!auto_print) {
- rv = error.yns_alert_formatted(
- msg,
- document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
- document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
- document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
- '/xul/server/skin/media/images/turtle.gif'
- );
- }
- if (rv == 0) {
- try {
- JSAN.use('util.print'); var print = new util.print();
+ if (!auto_print) {
+ rv = error.yns_alert_formatted(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.utils.hold_slip'),
+ document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.yes'),
+ document.getElementById('circStrings').getString('staff.circ.utils.hold_slip.print.no'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
+ '/xul/server/skin/media/images/turtle.gif'
+ );
+ }
+ if (rv == 0) {
+ try {
+ JSAN.use('util.print'); var print = new util.print();
var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
if (old_template) {
msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
};
print.tree_list( params );
}
- } catch(E) {
- var err_msg = document.getElementById('commonStrings').getString('common.error');
- err_msg += '\nFIXME: ' + E + '\n';
- dump(err_msg);
- alert(err_msg);
- }
- }
- msg = '';
- if (document.getElementById('no_change_label')) {
- var m = document.getElementById('no_change_label').getAttribute('value');
- m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
- document.getElementById('no_change_label').setAttribute('value', m);
- document.getElementById('no_change_label').setAttribute('hidden','false');
- }
- break;
- case 6: /* IN TRANSIT */
- check.route_to = 'TRANSIT SHELF??';
+ } catch(E) {
+ var err_msg = document.getElementById('commonStrings').getString('common.error');
+ err_msg += '\nFIXME: ' + E + '\n';
+ dump(err_msg);
+ alert(err_msg);
+ }
+ }
+ msg = '';
+ if (document.getElementById('no_change_label')) {
+ var m = document.getElementById('no_change_label').getAttribute('value');
+ m += document.getElementById('circStrings').getFormattedString('staff.circ.utils.capture', [params.barcode]);
+ document.getElementById('no_change_label').setAttribute('value', m);
+ document.getElementById('no_change_label').setAttribute('hidden','false');
+ }
+ break;
+ case 6: /* IN TRANSIT */
+ check.route_to = 'TRANSIT SHELF??';
print_data.route_to;
- var err_msg = document.getElementById('commonStrings').getString('common.error');
- err_msg += "\nFIXME -- I didn't think we could get here.\n";
+ var err_msg = document.getElementById('commonStrings').getString('common.error');
+ err_msg += "\nFIXME -- I didn't think we could get here.\n";
print_data.error_msg += err_msg;
msg += err_msg;
- break;
- case 11: /* CATALOGING */
- check.route_to = 'CATALOGING';
+ break;
+ case 11: /* CATALOGING */
+ check.route_to = 'CATALOGING';
print_data.route_to;
- if (document.getElementById('do_not_alert_on_precat')) {
- var x = document.getElementById('do_not_alert_on_precat');
- if (x.getAttribute('checked') != 'true') {
- print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
+ if (document.getElementById('do_not_alert_on_precat')) {
+ var x = document.getElementById('do_not_alert_on_precat');
+ if (x.getAttribute('checked') != 'true') {
+ print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
msg += print_data.route_to_msg;
- }
- } else {
- print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
+ }
+ } else {
+ print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
msg += print_data.route_to_msg;
- }
- if (document.getElementById('no_change_label')) {
- var m = document.getElementById('no_change_label').getAttribute('value');
- var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
- document.getElementById('no_change_label').setAttribute('value', m + needs_cat + ' ');
- document.getElementById('no_change_label').setAttribute('hidden','false');
- }
- break;
- default:
- msg += document.getElementById('commonStrings').getString('common.error');
- var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
- msg += '\n';
- var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
+ }
+ if (document.getElementById('no_change_label')) {
+ var m = document.getElementById('no_change_label').getAttribute('value');
+ var needs_cat = document.getElementById('circStrings').getFormattedString('staff.circ.utils.needs_cataloging', [params.barcode]);
+ document.getElementById('no_change_label').setAttribute('value', m + needs_cat + ' ');
+ document.getElementById('no_change_label').setAttribute('hidden','false');
+ }
+ break;
+ default:
+ msg += document.getElementById('commonStrings').getString('common.error');
+ var copy_status = data.hash.ccs[check.copy.status()] ? data.hash.ccs[check.copy.status()].name() : check.copy.status().name();
+ msg += '\n';
+ var error_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.copy_status.error', [copy_status]);
print_data.error_msg += error_msg;
msg += error_msg;
- msg += '\n';
- print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
+ msg += '\n';
+ print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.msg', [check.route_to]);
msg += print_data.route_to_msg;
- break;
- }
- if (msg) {
- error.yns_alert(
- msg,
- document.getElementById('circStrings').getString('staff.circ.alert'),
- null,
- document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- }
- } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
-
- var lib = data.hash.aou[ check.org ];
- check.route_to = lib.shortname();
+ break;
+ }
+ if (msg) {
+ error.yns_alert(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.alert'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ }
+ } else /* ROUTE_ITEM */ if (check.ilsevent == 7000) {
+
+ var lib = data.hash.aou[ check.org ];
+ check.route_to = lib.shortname();
print_data.route_to = check.route_to;
print_data.route_to_org = lib;
- print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
+ print_data.route_to_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.route_to.destination', [check.route_to]);
print_data.route_to_org_fullname = lib.name();
msg += print_data.route_to_msg;
- msg += '\n\n';
- msg += lib.name();
- msg += '\n';
- try {
- if (lib.holds_address() ) {
- var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
- if (typeof a.ilsevent != 'undefined') throw(a);
- if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
- if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
- print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
+ msg += '\n\n';
+ msg += lib.name();
+ msg += '\n';
+ try {
+ if (lib.holds_address() ) {
+ var a = network.simple_request('FM_AOA_RETRIEVE',[ lib.holds_address() ]);
+ if (typeof a.ilsevent != 'undefined') throw(a);
+ if (a.street1()) { msg += a.street1() + '\n'; print_data.street1 = a.street1(); }
+ if (a.street2()) { msg += a.street2() + '\n'; print_data.street2 = a.street2(); }
+ print_data.city_state_zip = (a.city() ? a.city() + ', ' : '') + (a.state() ? a.state() + ' ' : '') + (a.post_code() ? a.post_code() : '');
print_data.city = a.city();
print_data.state = a.state();
print_data.county = a.county();
print_data.country = a.country();
print_data.post_code = a.post_code();
msg += print_data.city_state_zip + '\n';
- } else {
- print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
+ } else {
+ print_data.street1 = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address');
print_data.no_address = true;
msg += print_data.street1;
- msg += '\n';
- }
- } catch(E) {
- var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
+ msg += '\n';
+ }
+ } catch(E) {
+ var err_msg = document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error');
print_data.error_msg += err_msg + '\n';
- msg += err_msg + '\n';
- error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
- }
- msg += '\n';
- print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
+ msg += err_msg + '\n';
+ error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.utils.route_to.no_address.error'), E);
+ }
+ msg += '\n';
+ print_data.item_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [check.payload.copy.barcode()]);
print_data.item_barcode = check.payload.copy.barcode();
msg += print_data.item_barcode_msg;
- msg += '\n';
- var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
- print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
+ msg += '\n';
+ var payload_title = (check.payload.record ? check.payload.record.title() : check.payload.copy.dummy_title() );
+ print_data.item_title_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.title', [payload_title]);
print_data.item_title = payload_title;
msg += print_data.item_title_msg;
- msg += '\n';
- var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
- print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
+ msg += '\n';
+ var payload_author = (check.payload.record ? check.payload.record.author() :check.payload.copy.dummy_author());
+ print_data.item_author_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.author', [payload_author]);
print_data.item_author = payload_author;
msg += print_data.item_author_msg;
- msg += '\n';
- JSAN.use('util.date');
- if (check.payload.hold) {
- JSAN.use('patron.util');
- var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
+ msg += '\n';
+ JSAN.use('util.date');
+ if (check.payload.hold) {
+ JSAN.use('patron.util');
+ var au_obj = patron.util.retrieve_fleshed_au_via_id( session, check.payload.hold.usr() );
print_data.user = au_obj;
- msg += '\n';
+ msg += '\n';
if (au_obj.alias()) {
print_data.hold_for_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.patron_alias', [au_obj.alias()]);
print_data.hold_for_alias = au_obj.alias();
print_data.hold_for_first_given_name = au_obj.first_given_name() ? au_obj.first_given_name() : '';
print_data.hold_for_second_given_name = au_obj.second_given_name() ? au_obj.second_given_name() : '';
}
- msg += '\n';
+ msg += '\n';
print_data.user_barcode_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.barcode', [au_obj.card().barcode()]);
print_data.user_barcode = au_obj.card().barcode();
msg += print_data.user_barcode_msg;
- msg += '\n';
- if (check.payload.hold.phone_notify()) {
+ msg += '\n';
+ if (check.payload.hold.phone_notify()) {
print_data.notify_by_phone_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.phone_notify', [check.payload.hold.phone_notify()]);
print_data.notify_by_phone = check.payload.hold.phone_notify();
msg += print_data.notify_by_phone_msg;
- msg += '\n';
- }
- if (get_bool(check.payload.hold.email_notify())) {
- var payload_email = au_obj.email() ? au_obj.email() : '';
+ msg += '\n';
+ }
+ if (get_bool(check.payload.hold.email_notify())) {
+ var payload_email = au_obj.email() ? au_obj.email() : '';
print_data.notify_by_email_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.email_notify', [payload_email]);
print_data.notify_by_email = payload_email;
msg += print_data.notify_by_email_msg;
- msg += '\n';
- }
- msg += '\n';
+ msg += '\n';
+ }
+ msg += '\n';
var notes = check.payload.hold.notes();
print_data.notes_raw = notes;
for (var i = 0; i < notes.length; i++) {
print_data.request_date = util.date.formatted_date(check.payload.hold.request_time(),'%F');
print_data.request_date_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.hold.request_date', [print_data.request_date]);
msg += print_data.request_date_msg;
- msg += '\n';
- }
- var rv = 0;
+ msg += '\n';
+ }
+ var rv = 0;
var no_print_prompting = data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
if (no_print_prompting) {
if (no_print_prompting.indexOf( check.payload.hold ? "Hold/Transit Slip" : "Transit Slip" ) > -1) {
msg += print_data.slip_date_msg;
print_data.payload = check.payload;
- if (!auto_print) {
- rv = error.yns_alert_formatted(
- msg,
- document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
- document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
- document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
- '/xul/server/skin/media/images/turtle.gif'
- );
- }
- if (rv == 0) {
- try {
- JSAN.use('util.print'); var print = new util.print();
+ if (!auto_print) {
+ rv = error.yns_alert_formatted(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.utils.transit_slip'),
+ document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.yes'),
+ document.getElementById('circStrings').getString('staff.circ.utils.transit_slip.print.no'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
+ '/xul/server/skin/media/images/turtle.gif'
+ );
+ }
+ if (rv == 0) {
+ try {
+ JSAN.use('util.print'); var print = new util.print();
var old_template = String( data.hash.aous['ui.circ.old_harcoded_slip_template'] ) == 'true';
if (old_template) {
msg = msg.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\n/g,'<br/>');
};
print.tree_list( params );
}
- } catch(E) {
- var err_msg = document.getElementById('commonStrings').getString('common.error');
- err_msg += '\nFIXME: ' + E + '\n';
- dump(err_msg);
- alert(err_msg);
- }
- }
- if (document.getElementById('no_change_label')) {
- var m = document.getElementById('no_change_label').getAttribute('value');
- var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
- document.getElementById('no_change_label').setAttribute('value', m + trans_msg + ' ');
- document.getElementById('no_change_label').setAttribute('hidden','false');
- }
-
- } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
-
- check.route_to = 'CATALOGING';
- var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
- error.yns_alert(
- mis_scan_msg,
- document.getElementById('circStrings').getString('staff.circ.alert'),
- null,
- document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg')
- );
- if (document.getElementById('no_change_label')) {
- var m = document.getElementById('no_change_label').getAttribute('value');
- document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + ' ');
- document.getElementById('no_change_label').setAttribute('hidden','false');
- }
-
- } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
-
- var rv = 0;
- msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
- rv = error.yns_alert_formatted(
- msg,
- document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
- document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
- document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
- null,
- document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
- '/xul/server/skin/media/images/stop_sign.png'
- );
- params.capture = rv == 0 ? 'nocapture' : 'capture';
-
- return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
-
- } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
- error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
- } else {
+ } catch(E) {
+ var err_msg = document.getElementById('commonStrings').getString('common.error');
+ err_msg += '\nFIXME: ' + E + '\n';
+ dump(err_msg);
+ alert(err_msg);
+ }
+ }
+ if (document.getElementById('no_change_label')) {
+ var m = document.getElementById('no_change_label').getAttribute('value');
+ var trans_msg = document.getElementById('circStrings').getFormattedString('staff.circ.utils.payload.in_transit', [params.barcode]);
+ document.getElementById('no_change_label').setAttribute('value', m + trans_msg + ' ');
+ document.getElementById('no_change_label').setAttribute('hidden','false');
+ }
+
+ } else /* ASSET_COPY_NOT_FOUND */ if (check.ilsevent == 1502) {
+
+ check.route_to = 'CATALOGING';
+ var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
+ error.yns_alert(
+ mis_scan_msg,
+ document.getElementById('circStrings').getString('staff.circ.alert'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.utils.msg.ok'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg')
+ );
+ if (document.getElementById('no_change_label')) {
+ var m = document.getElementById('no_change_label').getAttribute('value');
+ document.getElementById('no_change_label').setAttribute('value',m + mis_scan_msg + ' ');
+ document.getElementById('no_change_label').setAttribute('hidden','false');
+ }
+
+ } else /* HOLD_CAPTURE_DELAYED */ if (check.ilsevent == 7019) {
+
+ var rv = 0;
+ msg += document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.description');
+ rv = error.yns_alert_formatted(
+ msg,
+ document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.titlebar'),
+ document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_nocapture'),
+ document.getElementById('circStrings').getString('staff.circ.utils.hold_capture_delayed.prompt_for_capture'),
+ null,
+ document.getElementById('circStrings').getString('staff.circ.confirm.msg'),
+ '/xul/server/skin/media/images/stop_sign.png'
+ );
+ params.capture = rv == 0 ? 'nocapture' : 'capture';
+
+ return circ.util.checkin_via_barcode(session,params,backdate,auto_print,false);
+
+ } else /* NETWORK TIMEOUT */ if (check.ilsevent == -1) {
+ error.standard_network_error_alert(document.getElementById('circStrings').getString('staff.circ.checkin.suggest_offline'));
+ } else {
if (check.ilsevent == null) { return null; /* handled */ }
- switch (Number(check.ilsevent)) {
- case 1203 /* COPY_BAD_STATUS */ :
- case 1213 /* PATRON_BARRED */ :
- case 1217 /* PATRON_INACTIVE */ :
- case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
- case 1234 /* ITEM_DEPOSIT_PAID */ :
- case 7009 /* CIRC_CLAIMS_RETURNED */ :
- case 7010 /* COPY_ALERT_MESSAGE */ :
- case 7011 /* COPY_STATUS_LOST */ :
- case 7012 /* COPY_STATUS_MISSING */ :
- case 7013 /* PATRON_EXCEEDS_FINES */ :
- return null; /* handled */
- break;
- }
-
- throw(check);
-
- }
-
- return check;
- } catch(E) {
- JSAN.use('util.error'); var error = new util.error();
- error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
- return null;
- }
+ switch (Number(check.ilsevent)) {
+ case 1203 /* COPY_BAD_STATUS */ :
+ case 1213 /* PATRON_BARRED */ :
+ case 1217 /* PATRON_INACTIVE */ :
+ case 1224 /* PATRON_ACCOUNT_EXPIRED */ :
+ case 1234 /* ITEM_DEPOSIT_PAID */ :
+ case 7009 /* CIRC_CLAIMS_RETURNED */ :
+ case 7010 /* COPY_ALERT_MESSAGE */ :
+ case 7011 /* COPY_STATUS_LOST */ :
+ case 7012 /* COPY_STATUS_MISSING */ :
+ case 7013 /* PATRON_EXCEEDS_FINES */ :
+ return null; /* handled */
+ break;
+ }
+
+ throw(check);
+
+ }
+
+ return check;
+ } catch(E) {
+ JSAN.use('util.error'); var error = new util.error();
+ error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.error', ['3']), E);
+ return null;
+ }
};
circ.util.renew_via_barcode = function ( params, async ) {
- try {
- var obj = {};
- JSAN.use('util.network'); obj.network = new util.network();
- JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
-
- function renew_callback(req) {
- try {
- JSAN.use('util.error'); var error = new util.error();
- var renew = req.getResultObject();
- if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
- for (var j = 0; j < renew.length; j++) {
- switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
- case 0 /* SUCCESS */ : break;
- case null /* custom event */ : break;
- case 5000 /* PERM_FAILURE */: break;
- case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
- case 1213 /* PATRON_BARRED */ : break;
- case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
- case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
+ try {
+ var obj = {};
+ JSAN.use('util.network'); obj.network = new util.network();
+ JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.stash_retrieve();
+
+ function renew_callback(req) {
+ try {
+ JSAN.use('util.error'); var error = new util.error();
+ var renew = req.getResultObject();
+ if (typeof renew.ilsevent != 'undefined') renew = [ renew ];
+ for (var j = 0; j < renew.length; j++) {
+ switch(renew[j].ilsevent == null ? null : Number(renew[j].ilsevent)) {
+ case 0 /* SUCCESS */ : break;
+ case null /* custom event */ : break;
+ case 5000 /* PERM_FAILURE */: break;
+ case 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */ : break;
+ case 1213 /* PATRON_BARRED */ : break;
+ case 1215 /* CIRC_EXCEEDS_COPY_RANGE */ : break;
+ case 1224 /* PATRON_ACCOUNT_EXPIRED */ : break;
case 1232 /* ITEM_DEPOSIT_REQUIRED */ : break;
case 1233 /* ITEM_RENTAL_FEE_REQUIRED */ : break;
- case 1234 /* ITEM_DEPOSIT_PAID */ : break;
- case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
+ case 1234 /* ITEM_DEPOSIT_PAID */ : break;
+ case 1500 /* ACTION_CIRCULATION_NOT_FOUND */ : break;
case 1502 /* ASSET_COPY_NOT_FOUND */ :
var mis_scan_msg = document.getElementById('circStrings').getFormattedString('staff.circ.copy_status.status.copy_not_found', [params.barcode]);
error.yns_alert(
document.getElementById('no_change_label').setAttribute('hidden','false');
}
break;
- case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
- case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
- case 7004 /* COPY_NOT_AVAILABLE */ : break;
- case 7006 /* COPY_IS_REFERENCE */ : break;
- case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
- case 7008 /* MAX_RENEWALS_REACHED */ : break;
- case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
- case 7010 /* COPY_ALERT_MESSAGE */ : break;
- case 7013 /* PATRON_EXCEEDS_FINES */ : break;
- default:
- throw(renew);
- break;
- }
- }
- if (typeof async == 'function') async(renew);
- return renew;
- } catch(E) {
- JSAN.use('util.error'); var error = new util.error();
- error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
- return null;
- }
- }
-
- var renew = obj.network.simple_request(
- 'CHECKOUT_RENEW',
- [ ses(), params ],
- async ? renew_callback : null,
- {
- 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
- 'overridable_events' : [
+ case 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */ : break;
+ case 7003 /* COPY_CIRC_NOT_ALLOWED */ : break;
+ case 7004 /* COPY_NOT_AVAILABLE */ : break;
+ case 7006 /* COPY_IS_REFERENCE */ : break;
+ case 7007 /* COPY_NEEDED_FOR_HOLD */ : break;
+ case 7008 /* MAX_RENEWALS_REACHED */ : break;
+ case 7009 /* CIRC_CLAIMS_RETURNED */ : break;
+ case 7010 /* COPY_ALERT_MESSAGE */ : break;
+ case 7013 /* PATRON_EXCEEDS_FINES */ : break;
+ default:
+ throw(renew);
+ break;
+ }
+ }
+ if (typeof async == 'function') async(renew);
+ return renew;
+ } catch(E) {
+ JSAN.use('util.error'); var error = new util.error();
+ error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
+ return null;
+ }
+ }
+
+ var renew = obj.network.simple_request(
+ 'CHECKOUT_RENEW',
+ [ ses(), params ],
+ async ? renew_callback : null,
+ {
+ 'title' : document.getElementById('circStrings').getString('staff.circ.checkin.renew_failed.override'),
+ 'overridable_events' : [
null /* custom event */,
- 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
- 1213 /* PATRON_BARRED */,
- 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
+ 1212 /* PATRON_EXCEEDS_OVERDUE_COUNT */,
+ 1213 /* PATRON_BARRED */,
+ 1215 /* CIRC_EXCEEDS_COPY_RANGE */,
1232 /* ITEM_DEPOSIT_REQUIRED */,
1233 /* ITEM_RENTAL_FEE_REQUIRED */,
- 1234 /* ITEM_DEPOSIT_PAID */,
- 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
- 7003 /* COPY_CIRC_NOT_ALLOWED */,
- 7004 /* COPY_NOT_AVAILABLE */,
- 7006 /* COPY_IS_REFERENCE */,
- 7007 /* COPY_NEEDED_FOR_HOLD */,
- 7008 /* MAX_RENEWALS_REACHED */,
- 7009 /* CIRC_CLAIMS_RETURNED */,
- 7010 /* COPY_ALERT_MESSAGE */,
- 7013 /* PATRON_EXCEEDS_FINES */,
- ],
- 'text' : {
- '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
- '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
- '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
+ 1234 /* ITEM_DEPOSIT_PAID */,
+ 7002 /* PATRON_EXCEEDS_CHECKOUT_COUNT */,
+ 7003 /* COPY_CIRC_NOT_ALLOWED */,
+ 7004 /* COPY_NOT_AVAILABLE */,
+ 7006 /* COPY_IS_REFERENCE */,
+ 7007 /* COPY_NEEDED_FOR_HOLD */,
+ 7008 /* MAX_RENEWALS_REACHED */,
+ 7009 /* CIRC_CLAIMS_RETURNED */,
+ 7010 /* COPY_ALERT_MESSAGE */,
+ 7013 /* PATRON_EXCEEDS_FINES */,
+ ],
+ 'text' : {
+ '1212' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
+ '1213' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
+ '1215' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
'1232' : function(r) {
return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_deposit_required.warning.barcode', [params.barcode]);
},
'1233' : function(r) {
return document.getElementById('circStrings').getFormattedString('staff.circ.renew.override.item_rental_fee_required.warning.barcode', [params.barcode]);
},
- '1234' : function(r) {
- return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
- },
- '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
- '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
- '7004' : function(r) {
- return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.status', [params.barcode, typeof r.payload.status() == 'object' ? r.payload.status().name() : obj.data.hash.ccs[ r.payload.status() ].name()]);
- },
- '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
- '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
- '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
- '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
- '7010' : function(r) {
- return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [params.barcode, r.payload]);
- },
- '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); }
- }
- }
- );
- if (! async ) {
- return renew_callback( { 'getResultObject' : function() { return renew; } } );
- }
-
- } catch(E) {
- JSAN.use('util.error'); var error = new util.error();
- error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
- return null;
- }
+ '1234' : function(r) {
+ return document.getElementById('circStrings').getFormattedString('staff.circ.utils.checkin.override.item_deposit_paid.warning');
+ },
+ '7002' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
+ '7003' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
+ '7004' : function(r) {
+ return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.status', [params.barcode, typeof r.payload.status() == 'object' ? r.payload.status().name() : obj.data.hash.ccs[ r.payload.status() ].name()]);
+ },
+ '7006' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
+ '7007' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
+ '7008' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
+ '7009' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); },
+ '7010' : function(r) {
+ return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode.msg', [params.barcode, r.payload]);
+ },
+ '7013' : function(r) { return document.getElementById('circStrings').getFormattedString('staff.circ.renew.barcode', [params.barcode]); }
+ }
+ }
+ );
+ if (! async ) {
+ return renew_callback( { 'getResultObject' : function() { return renew; } } );
+ }
+
+ } catch(E) {
+ JSAN.use('util.error'); var error = new util.error();
+ error.standard_unexpected_error_alert(document.getElementById('circStrings').getFormattedString('staff.circ.checkin.renew_failed.error', [params.barcode]), E);
+ return null;
+ }
};
dump('exiting circ/util.js\n');
JSAN.errorLevel = "die"; // none, warn, or die
JSAN.addRepository('..');
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
XML_HTTP_SERVER = data.server_unadorned;
JSAN.use('util.network'); var net = new util.network();
if (typeof patron == 'undefined') patron = {};
patron.bills = function (params) {
- var obj = this;
- try { JSAN.use('util.error'); obj.error = new util.error(); } catch(E) { alert(E); }
- try { JSAN.use('util.network'); obj.network = new util.network(); } catch(E) { alert(E); }
- try {
- obj.OpenILS = {}; JSAN.use('OpenILS.data'); obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
- obj.data = obj.OpenILS.data;
- obj.data.voided_billings = []; obj.data.stash('voided_billings');
- } catch(E) {
- alert(E);
- }
+ var obj = this;
+ try { JSAN.use('util.error'); obj.error = new util.error(); } catch(E) { alert(E); }
+ try { JSAN.use('util.network'); obj.network = new util.network(); } catch(E) { alert(E); }
+ try {
+ obj.OpenILS = {}; JSAN.use('OpenILS.data'); obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
+ obj.data = obj.OpenILS.data;
+ obj.data.voided_billings = []; obj.data.stash('voided_billings');
+ } catch(E) {
+ alert(E);
+ }
}
patron.bills.prototype = {
- 'bill_map' : {},
+ 'bill_map' : {},
- 'current_payments' : [],
+ 'current_payments' : [],
- 'SHOW_ME_THE_BILLS' : 'FM_MOBTS_HAVING_BALANCE.authoritative',
+ 'SHOW_ME_THE_BILLS' : 'FM_MOBTS_HAVING_BALANCE.authoritative',
- 'refresh' : function(dont_show_me_the_money) {
- var obj = this;
- try {
+ 'refresh' : function(dont_show_me_the_money) {
+ var obj = this;
+ try {
if (document.getElementById('circulating_hint')) {
document.getElementById('circulating_hint').hidden = true;
}
- obj.bills = obj.network.simple_request(
- obj.SHOW_ME_THE_BILLS,
- [ ses(), obj.patron_id ]
- );
+ obj.bills = obj.network.simple_request(
+ obj.SHOW_ME_THE_BILLS,
+ [ ses(), obj.patron_id ]
+ );
if (typeof obj.bills.ilsevent != 'undefined' || typeof obj.bills == 'null') { throw(obj.bills); }
- for (var i = 0; i < obj.bills.length; i++) {
- if (instanceOf(obj.bills[i],mobts)) {
- obj.bills[i] = { 'transaction' : obj.bills[i] }
- } else if (instanceOf(obj.bills[i],mbts)) {
- obj.bills[i] = { 'transaction' : obj.bills[i] }
- } else {
- var robj = obj.network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),obj.bills[i]]);
- //alert('refresh robj = ' + js2JSON(robj));
- obj.bills[i] = { 'transaction' : robj }
- }
- }
-
- if (!dont_show_me_the_money) {
- //alert('dont_show_me_the_money = ' + dont_show_me_the_money);
- if (window.xulG && typeof window.xulG.on_money_change == 'function') {
- try { window.xulG.on_money_change(obj.bills); } catch(E) { this.error.sdump('D_ERROR',E); }
- }
- }
-
- var tbs = document.getElementsByTagName('textbox');
- for (var i = 0; i < tbs.length; i++) {
- tbs[i].value = ''; tbs[i].setAttribute('value','');
- }
- obj.init();
- obj.controller.view.bill_payment_amount.focus();
- obj.distribute_payment(obj.controller.view.bill_payment_amount);
- obj.tally_selected();
- obj.tally_voided();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> refresh',E);
- }
- },
-
- 'init' : function( params ) {
-
- var obj = this;
-
- try {
- obj.init_controller( params );
-
- obj.retrieve();
-
- var total_owed = 0;
-
- JSAN.use('util.money');
-
- obj.current_payments = []; obj.list.clear();
- //FIXME//.bills virtual field
- for (var i = 0; i < obj.bills.length; i++) {
- var rparams = obj.list.append(
- { 'row' :
- { 'my' :
- { 'mobts' : obj.bills[i].transaction, 'circ' : obj.bills[i].circ, 'mvr' : obj.bills[i].record }
- },
- 'attributes' : { 'allowevents' : true }
- }
- );
- var rnode = rparams.my_node;
- obj.bill_map[ obj.bills[i].transaction.id() ] = obj.bills[i];
- var cb = rnode.getElementsByTagName('checkbox')[0];
- var tb = rnode.getElementsByTagName('textbox')[0];
- var bo = obj.bills[i].transaction.balance_owed();
- total_owed += util.money.dollars_float_to_cents_integer( bo );
- var id = obj.bills[i].transaction.id();
- obj.current_payments.push( { 'mobts_id' : id, 'balance_owed' : bo, 'checkbox' : cb, 'textbox' : tb } );
- }
- obj.controller.view.bill_total_owed.value = util.money.cents_as_dollars( total_owed );
- obj.controller.view.bill_total_owed.setAttribute('value',obj.controller.view.bill_total_owed.value);
- obj.distribute_payment(obj.controller.view.bill_payment_amount);
- obj.controller.view.bill_payment_amount.select();
- obj.tally_selected();
- obj.tally_voided();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> init',E);
- }
- },
-
- 'init_controller' : function( params ) {
-
- var obj = this;
-
- try {
- if (obj._controller_inited) return;
-
- obj.patron_id = obj.patron_id || params['patron_id'];
-
- JSAN.use('util.list'); obj.list = new util.list('bill_list');
-
- obj.list.init(
- {
- 'columns' : [
- /*
- {
- 'id' : 'xact_dates', 'label' : document.getElementById('commonStrings').getString('staff.bills_xact_dates_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'render' : 'obj.xact_dates_box(my.mobts)'
- },
- */
- {
- 'id' : 'notes', 'label' : document.getElementById('commonStrings').getString('staff.bills_information'), 'flex' : 2,
- 'primary' : false, 'hidden' : false, 'render' : 'obj.info_box(my)'
- },
- {
- 'id' : 'money', 'label' : $('patronStrings').getString('staff.patron.bills.init_controller.money_summary_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'render' : 'obj.money_box(my.mobts)'
- },
- {
- 'id' : 'current_pay', 'label' : document.getElementById('commonStrings').getString('staff.bills_current_payment_label'), 'flex' : 0,
- 'render' : 'obj.payment_box()'
- }
- ],
- 'map_row_to_column' : obj.gen_map_row_to_column()
- }
- );
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'cmd_broken' : [
- ['command'],
- function() { alert($("commonStrings").getString('common.unimplemented')); }
- ],
- 'cmd_bill_wizard' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.window');
- var win = new util.window();
- var my_xulG = win.open(
- urls.XUL_PATRON_BILL_WIZARD,
- //+ '?patron_id=' + window.escape(obj.patron_id),
- 'billwizard',
- 'chrome,resizable,modal',
- { 'patron_id' : obj.patron_id }
- );
- obj.refresh();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> cmd_bill_wizard',E);
- }
- }
- ],
- 'cmd_bill_history' : [
- ['command'],
- function() {
- try {
+ for (var i = 0; i < obj.bills.length; i++) {
+ if (instanceOf(obj.bills[i],mobts)) {
+ obj.bills[i] = { 'transaction' : obj.bills[i] }
+ } else if (instanceOf(obj.bills[i],mbts)) {
+ obj.bills[i] = { 'transaction' : obj.bills[i] }
+ } else {
+ var robj = obj.network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),obj.bills[i]]);
+ //alert('refresh robj = ' + js2JSON(robj));
+ obj.bills[i] = { 'transaction' : robj }
+ }
+ }
+
+ if (!dont_show_me_the_money) {
+ //alert('dont_show_me_the_money = ' + dont_show_me_the_money);
+ if (window.xulG && typeof window.xulG.on_money_change == 'function') {
+ try { window.xulG.on_money_change(obj.bills); } catch(E) { this.error.sdump('D_ERROR',E); }
+ }
+ }
+
+ var tbs = document.getElementsByTagName('textbox');
+ for (var i = 0; i < tbs.length; i++) {
+ tbs[i].value = ''; tbs[i].setAttribute('value','');
+ }
+ obj.init();
+ obj.controller.view.bill_payment_amount.focus();
+ obj.distribute_payment(obj.controller.view.bill_payment_amount);
+ obj.tally_selected();
+ obj.tally_voided();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> refresh',E);
+ }
+ },
+
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ try {
+ obj.init_controller( params );
+
+ obj.retrieve();
+
+ var total_owed = 0;
+
+ JSAN.use('util.money');
+
+ obj.current_payments = []; obj.list.clear();
+ //FIXME//.bills virtual field
+ for (var i = 0; i < obj.bills.length; i++) {
+ var rparams = obj.list.append(
+ { 'row' :
+ { 'my' :
+ { 'mobts' : obj.bills[i].transaction, 'circ' : obj.bills[i].circ, 'mvr' : obj.bills[i].record }
+ },
+ 'attributes' : { 'allowevents' : true }
+ }
+ );
+ var rnode = rparams.my_node;
+ obj.bill_map[ obj.bills[i].transaction.id() ] = obj.bills[i];
+ var cb = rnode.getElementsByTagName('checkbox')[0];
+ var tb = rnode.getElementsByTagName('textbox')[0];
+ var bo = obj.bills[i].transaction.balance_owed();
+ total_owed += util.money.dollars_float_to_cents_integer( bo );
+ var id = obj.bills[i].transaction.id();
+ obj.current_payments.push( { 'mobts_id' : id, 'balance_owed' : bo, 'checkbox' : cb, 'textbox' : tb } );
+ }
+ obj.controller.view.bill_total_owed.value = util.money.cents_as_dollars( total_owed );
+ obj.controller.view.bill_total_owed.setAttribute('value',obj.controller.view.bill_total_owed.value);
+ obj.distribute_payment(obj.controller.view.bill_payment_amount);
+ obj.controller.view.bill_payment_amount.select();
+ obj.tally_selected();
+ obj.tally_voided();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> init',E);
+ }
+ },
+
+ 'init_controller' : function( params ) {
+
+ var obj = this;
+
+ try {
+ if (obj._controller_inited) return;
+
+ obj.patron_id = obj.patron_id || params['patron_id'];
+
+ JSAN.use('util.list'); obj.list = new util.list('bill_list');
+
+ obj.list.init(
+ {
+ 'columns' : [
+ /*
+ {
+ 'id' : 'xact_dates', 'label' : document.getElementById('commonStrings').getString('staff.bills_xact_dates_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'render' : 'obj.xact_dates_box(my.mobts)'
+ },
+ */
+ {
+ 'id' : 'notes', 'label' : document.getElementById('commonStrings').getString('staff.bills_information'), 'flex' : 2,
+ 'primary' : false, 'hidden' : false, 'render' : 'obj.info_box(my)'
+ },
+ {
+ 'id' : 'money', 'label' : $('patronStrings').getString('staff.patron.bills.init_controller.money_summary_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'render' : 'obj.money_box(my.mobts)'
+ },
+ {
+ 'id' : 'current_pay', 'label' : document.getElementById('commonStrings').getString('staff.bills_current_payment_label'), 'flex' : 0,
+ 'render' : 'obj.payment_box()'
+ }
+ ],
+ 'map_row_to_column' : obj.gen_map_row_to_column()
+ }
+ );
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert($("commonStrings").getString('common.unimplemented')); }
+ ],
+ 'cmd_bill_wizard' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.window');
+ var win = new util.window();
+ var my_xulG = win.open(
+ urls.XUL_PATRON_BILL_WIZARD,
+ //+ '?patron_id=' + window.escape(obj.patron_id),
+ 'billwizard',
+ 'chrome,resizable,modal',
+ { 'patron_id' : obj.patron_id }
+ );
+ obj.refresh();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> cmd_bill_wizard',E);
+ }
+ }
+ ],
+ 'cmd_bill_history' : [
+ ['command'],
+ function() {
+ try {
xulG.display_window.g.patron.right_deck.reset_iframe(
- urls.XUL_PATRON_BILL_HISTORY,
- {},
- {
- 'patron_id' : obj.patron_id,
- 'refresh' : function() { obj.refresh(); }
- }
- );
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> cmd_bill_history',E);
- }
- }
- ],
- 'cmd_alternate_view' : [
- ['command'],
- function() {
- try {
+ urls.XUL_PATRON_BILL_HISTORY,
+ {},
+ {
+ 'patron_id' : obj.patron_id,
+ 'refresh' : function() { obj.refresh(); }
+ }
+ );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> cmd_bill_history',E);
+ }
+ }
+ ],
+ 'cmd_alternate_view' : [
+ ['command'],
+ function() {
+ try {
xulG.display_window.g.patron.right_deck.reset_iframe(
- urls.XUL_PATRON_BILL_ALTERNATE_VIEW,
+ urls.XUL_PATRON_BILL_ALTERNATE_VIEW,
{},
- {
- 'current' : 1,
- 'patron_id' : obj.patron_id,
- 'refresh' : function() { obj.refresh(); }
- }
- );
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> cmd_alternate_view',E);
- }
- }
- ],
+ {
+ 'current' : 1,
+ 'patron_id' : obj.patron_id,
+ 'refresh' : function() { obj.refresh(); }
+ }
+ );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> cmd_alternate_view',E);
+ }
+ }
+ ],
'cmd_print_bills' : [
['command'],
function() {
- try {
- obj.print_bills();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> cmd_print_bills',E);
- }
+ try {
+ obj.print_bills();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> cmd_print_bills',E);
+ }
}
],
- 'cmd_change_to_credit' : [
- ['command'],
- function() {
- try {
- obj.change_to_credit();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> cmd_change_to_credit',E);
- }
- }
- ],
- 'cmd_bill_apply_payment' : [
- ['command'],
- function() {
- try {
- obj.apply_payment();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> cmd_bill_apply_payment',E);
- }
- }
- ],
- 'cmd_check_all' : [
- ['command'],
- function() {
- for (var i = 0; i < obj.current_payments.length; i++) {
- obj.current_payments[i].checkbox.setAttribute('checked',true); //checked = true;
- }
- obj.distribute_payment(obj.controller.view.bill_payment_amount);
- obj.tally_selected();
- }
- ],
- 'cmd_uncheck_all' : [
- ['command'],
- function() {
- for (var i = 0; i < obj.current_payments.length; i++) {
- obj.current_payments[i].checkbox.setAttribute('checked',false); //checked = false;
- }
- obj.distribute_payment(obj.controller.view.bill_payment_amount);
- obj.tally_selected();
- }
- ],
- 'voided_balance' : [
- ['render'],
- function(e) { return function() {}; }
- ],
- 'selected_balance' : [
- ['render'],
- function(e) { return function() {}; }
- ],
- 'unselected_balance' : [
- ['render'],
- function(e) { return function() {}; }
- ],
- 'bill_total_owed' : [
- ['render'],
- function(e) { return function() {}; }
- ],
- 'payment_type' : [
- ['render'],
- function(e) { return function() {}; }
- ],
- 'bill_payment_amount' : [
- ['change','keypress'],
- function(ev) {
- try {
- if (ev.type == 'keypress') {
- if (! (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* mac enter */) ) {
- return;
- }
- }
- if (ev.type == 'change' && obj.controller.view.payment_type.value == 'credit_payment') {
- JSAN.use('util.money');
- JSAN.use('patron.util'); var au_obj = patron.util.retrieve_au_via_id(ses(),obj.patron_id);
- var proposed = util.money.dollars_float_to_cents_integer(ev.target.value);
- var available = util.money.dollars_float_to_cents_integer(au_obj.credit_forward_balance());
- if (proposed > available) {
- alert($("patronStrings").getFormattedString('staff.patron.bills.bill_payment_amount.credit_amount', [au_obj.credit_forward_balance()]));
- ev.target.value = util.money.cents_as_dollars( available );
- ev.target.setAttribute('value',ev.target.value);
- }
- }
- obj.distribute_payment(ev.target);
- ev.target.select();
- obj.tally_selected();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> bill_payment_amount',E);
- }
- }
- ],
- 'bill_payment_applied' : [
- ['render'],
- function(e) { return function() {}; }
- ],
- 'bill_change_amount' : [
- ['change'],
- function(ev) {
- try {
- JSAN.use('util.money');
- var tb = ev.target;
- var proposed_change = util.money.dollars_float_to_cents_integer( tb.value );
- var proposed_credit = 0;
- obj.update_payment_applied();
- var real_change = util.money.dollars_float_to_cents_integer( tb.value );
- if ( proposed_change > real_change ) {
- obj.error.sdump('D_ERROR',$("patronStrings").getString('staff.patron.bills.bill_change_amount.greedy'));
- proposed_change = real_change;
- } else if ( real_change > proposed_change ) {
- proposed_credit = real_change - proposed_change;
- }
- tb.value = util.money.cents_as_dollars( proposed_change );
- tb.setAttribute('value',tb.value);
- obj.controller.view.bill_credit_amount.value = util.money.cents_as_dollars( proposed_credit );
- obj.controller.view.bill_credit_amount.setAttribute(
- 'value',
- obj.controller.view.bill_credit_amount.value
- );
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> bill_change_amount',E);
- }
- }
- ],
- 'bill_credit_amount' : [
- ['render'],
- function(e) { return function() {}; }
- ],
- 'bill_new_balance' : [
- ['render'],
- function(e) { return function() {}; }
- ]
- }
- }
- );
-
- obj.controller.render();
- obj._controller_inited = true;
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> init_controller',E);
- }
-
- },
-
- /*****************************************************************************************************************************/
-
- 'distribute_payment' : function(node) {
- try {
- var obj = this;
- JSAN.use('util.money');
- var tb = node;
- tb.value = util.money.cents_as_dollars( util.money.dollars_float_to_cents_integer( tb.value ) );
- tb.setAttribute('value', tb.value );
- var total = util.money.dollars_float_to_cents_integer( tb.value );
- if (total < 0) { tb.value = '0.00'; tb.setAttribute('value','0.00'); total = 0; }
- for (var i = 0; i < obj.current_payments.length; i++) {
- var bill = obj.current_payments[i];
- if (bill.checkbox.checked || bill.checkbox.getAttribute('checked') == 'true') {
- var bo = util.money.dollars_float_to_cents_integer( bill.balance_owed );
- if ( bo > total ) {
- bill.textbox.value = util.money.cents_as_dollars( total );
- total = 0;
- } else {
- bill.textbox.value = util.money.cents_as_dollars( bo );
- total = total - bo;
- }
- } else {
- bill.textbox.value = '0.00';
- }
- bill.textbox.setAttribute('value',bill.textbox.value);
- }
- obj.update_payment_applied();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> distribute payment',E);
- }
- },
-
- /*****************************************************************************************************************************/
-
- 'tally_selected' : function() {
-
- var obj = this;
- JSAN.use('util.money');
- var selected_total = 0;
- var unselected_total = 0;
- //var s = '';
-
- for (var i = 0; i < obj.current_payments.length; i++) {
- var bill = obj.current_payments[i];
- if (bill.checkbox.checked || bill.checkbox.getAttribute('checked') == 'true') {
- var bo = util.money.dollars_float_to_cents_integer( bill.balance_owed );
- selected_total += bo;
- //s += ('tallying ' + i + ' : checked, bo = ' + bo + ' total = ' + selected_total + '\n');
- } else {
- var bo = util.money.dollars_float_to_cents_integer( bill.balance_owed );
- unselected_total += bo;
- //s += ('tallying ' + i + ' : not checked, total = ' + selected_total + '\n');
- }
- }
- obj.controller.view.selected_balance.setAttribute('value', '$' + util.money.cents_as_dollars( selected_total ) );
- obj.controller.view.unselected_balance.setAttribute('value', '$' + util.money.cents_as_dollars( unselected_total ) );
- //dump(s); alert(s);
- },
-
- /*****************************************************************************************************************************/
-
- 'tally_voided' : function() {
-
- var obj = this;
- JSAN.use('util.money');
- var voided_total = 0;
-
- obj.data.stash_retrieve();
-
- for (var i = 0; i < obj.data.voided_billings.length; i++) {
- var billing = obj.data.voided_billings[i];
- var bv = util.money.dollars_float_to_cents_integer( billing.amount() );
- voided_total += bv;
- }
- obj.controller.view.voided_balance.setAttribute('value', '$' + util.money.cents_as_dollars( voided_total ) );
- },
-
- /*****************************************************************************************************************************/
-
- 'apply_payment' : function() {
-
- var obj = this;
- try {
- var payment_blob = {};
- JSAN.use('util.window');
- var win = new util.window();
- switch(obj.controller.view.payment_type.value) {
- case 'credit_card_payment' :
- obj.OpenILS.data.temp = '';
- obj.OpenILS.data.stash('temp');
- var my_xulG = win.open(
- urls.XUL_PATRON_BILL_CC_INFO,
- 'billccinfo',
- 'chrome,resizable,modal'
- );
- obj.OpenILS.data.stash_retrieve();
- //payment_blob = my_xulG.payment_blob; //JSON2js( obj.OpenILS.data.temp );
- payment_blob = JSON2js( obj.OpenILS.data.temp );
- break;
- case 'check_payment' :
- obj.OpenILS.data.temp = '';
- obj.OpenILS.data.stash('temp');
- var my_xulG = win.open(
- urls.XUL_PATRON_BILL_CHECK_INFO,
- 'billcheckinfo',
- 'chrome,resizable,modal'
- );
- obj.OpenILS.data.stash_retrieve();
- //payment_blob = my_xulG.payment_blob; //JSON2js( obj.OpenILS.data.temp );
- payment_blob = JSON2js( obj.OpenILS.data.temp );
- break;
- }
- if ((typeof payment_blob == 'undefined') || payment_blob=='' || payment_blob.cancelled=='true') { alert('cancelled'); return; }
- payment_blob.userid = obj.patron_id;
- payment_blob.note = payment_blob.note || '';
- //payment_blob.cash_drawer = 1; // FIXME: get new Config() to work
- payment_blob.payment_type = obj.controller.view.payment_type.value;
- payment_blob.payments = [];
- payment_blob.patron_credit = obj.controller.view.bill_credit_amount.value;
- for (var i = 0; i < obj.current_payments.length; i++) {
- var tb = obj.current_payments[ i ].textbox;
- if ( !(tb.value == '0.00' || tb.value == '') ) {
- payment_blob.payments.push(
- [
- obj.current_payments[ i ].mobts_id,
- tb.value
- ]
- );
- }
- }
+ 'cmd_change_to_credit' : [
+ ['command'],
+ function() {
+ try {
+ obj.change_to_credit();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> cmd_change_to_credit',E);
+ }
+ }
+ ],
+ 'cmd_bill_apply_payment' : [
+ ['command'],
+ function() {
+ try {
+ obj.apply_payment();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> cmd_bill_apply_payment',E);
+ }
+ }
+ ],
+ 'cmd_check_all' : [
+ ['command'],
+ function() {
+ for (var i = 0; i < obj.current_payments.length; i++) {
+ obj.current_payments[i].checkbox.setAttribute('checked',true); //checked = true;
+ }
+ obj.distribute_payment(obj.controller.view.bill_payment_amount);
+ obj.tally_selected();
+ }
+ ],
+ 'cmd_uncheck_all' : [
+ ['command'],
+ function() {
+ for (var i = 0; i < obj.current_payments.length; i++) {
+ obj.current_payments[i].checkbox.setAttribute('checked',false); //checked = false;
+ }
+ obj.distribute_payment(obj.controller.view.bill_payment_amount);
+ obj.tally_selected();
+ }
+ ],
+ 'voided_balance' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ],
+ 'selected_balance' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ],
+ 'unselected_balance' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ],
+ 'bill_total_owed' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ],
+ 'payment_type' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ],
+ 'bill_payment_amount' : [
+ ['change','keypress'],
+ function(ev) {
+ try {
+ if (ev.type == 'keypress') {
+ if (! (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* mac enter */) ) {
+ return;
+ }
+ }
+ if (ev.type == 'change' && obj.controller.view.payment_type.value == 'credit_payment') {
+ JSAN.use('util.money');
+ JSAN.use('patron.util'); var au_obj = patron.util.retrieve_au_via_id(ses(),obj.patron_id);
+ var proposed = util.money.dollars_float_to_cents_integer(ev.target.value);
+ var available = util.money.dollars_float_to_cents_integer(au_obj.credit_forward_balance());
+ if (proposed > available) {
+ alert($("patronStrings").getFormattedString('staff.patron.bills.bill_payment_amount.credit_amount', [au_obj.credit_forward_balance()]));
+ ev.target.value = util.money.cents_as_dollars( available );
+ ev.target.setAttribute('value',ev.target.value);
+ }
+ }
+ obj.distribute_payment(ev.target);
+ ev.target.select();
+ obj.tally_selected();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> bill_payment_amount',E);
+ }
+ }
+ ],
+ 'bill_payment_applied' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ],
+ 'bill_change_amount' : [
+ ['change'],
+ function(ev) {
+ try {
+ JSAN.use('util.money');
+ var tb = ev.target;
+ var proposed_change = util.money.dollars_float_to_cents_integer( tb.value );
+ var proposed_credit = 0;
+ obj.update_payment_applied();
+ var real_change = util.money.dollars_float_to_cents_integer( tb.value );
+ if ( proposed_change > real_change ) {
+ obj.error.sdump('D_ERROR',$("patronStrings").getString('staff.patron.bills.bill_change_amount.greedy'));
+ proposed_change = real_change;
+ } else if ( real_change > proposed_change ) {
+ proposed_credit = real_change - proposed_change;
+ }
+ tb.value = util.money.cents_as_dollars( proposed_change );
+ tb.setAttribute('value',tb.value);
+ obj.controller.view.bill_credit_amount.value = util.money.cents_as_dollars( proposed_credit );
+ obj.controller.view.bill_credit_amount.setAttribute(
+ 'value',
+ obj.controller.view.bill_credit_amount.value
+ );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> bill_change_amount',E);
+ }
+ }
+ ],
+ 'bill_credit_amount' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ],
+ 'bill_new_balance' : [
+ ['render'],
+ function(e) { return function() {}; }
+ ]
+ }
+ }
+ );
+
+ obj.controller.render();
+ obj._controller_inited = true;
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> init_controller',E);
+ }
+
+ },
+
+ /*****************************************************************************************************************************/
+
+ 'distribute_payment' : function(node) {
+ try {
+ var obj = this;
+ JSAN.use('util.money');
+ var tb = node;
+ tb.value = util.money.cents_as_dollars( util.money.dollars_float_to_cents_integer( tb.value ) );
+ tb.setAttribute('value', tb.value );
+ var total = util.money.dollars_float_to_cents_integer( tb.value );
+ if (total < 0) { tb.value = '0.00'; tb.setAttribute('value','0.00'); total = 0; }
+ for (var i = 0; i < obj.current_payments.length; i++) {
+ var bill = obj.current_payments[i];
+ if (bill.checkbox.checked || bill.checkbox.getAttribute('checked') == 'true') {
+ var bo = util.money.dollars_float_to_cents_integer( bill.balance_owed );
+ if ( bo > total ) {
+ bill.textbox.value = util.money.cents_as_dollars( total );
+ total = 0;
+ } else {
+ bill.textbox.value = util.money.cents_as_dollars( bo );
+ total = total - bo;
+ }
+ } else {
+ bill.textbox.value = '0.00';
+ }
+ bill.textbox.setAttribute('value',bill.textbox.value);
+ }
+ obj.update_payment_applied();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> distribute payment',E);
+ }
+ },
+
+ /*****************************************************************************************************************************/
+
+ 'tally_selected' : function() {
+
+ var obj = this;
+ JSAN.use('util.money');
+ var selected_total = 0;
+ var unselected_total = 0;
+ //var s = '';
+
+ for (var i = 0; i < obj.current_payments.length; i++) {
+ var bill = obj.current_payments[i];
+ if (bill.checkbox.checked || bill.checkbox.getAttribute('checked') == 'true') {
+ var bo = util.money.dollars_float_to_cents_integer( bill.balance_owed );
+ selected_total += bo;
+ //s += ('tallying ' + i + ' : checked, bo = ' + bo + ' total = ' + selected_total + '\n');
+ } else {
+ var bo = util.money.dollars_float_to_cents_integer( bill.balance_owed );
+ unselected_total += bo;
+ //s += ('tallying ' + i + ' : not checked, total = ' + selected_total + '\n');
+ }
+ }
+ obj.controller.view.selected_balance.setAttribute('value', '$' + util.money.cents_as_dollars( selected_total ) );
+ obj.controller.view.unselected_balance.setAttribute('value', '$' + util.money.cents_as_dollars( unselected_total ) );
+ //dump(s); alert(s);
+ },
+
+ /*****************************************************************************************************************************/
+
+ 'tally_voided' : function() {
+
+ var obj = this;
+ JSAN.use('util.money');
+ var voided_total = 0;
+
+ obj.data.stash_retrieve();
+
+ for (var i = 0; i < obj.data.voided_billings.length; i++) {
+ var billing = obj.data.voided_billings[i];
+ var bv = util.money.dollars_float_to_cents_integer( billing.amount() );
+ voided_total += bv;
+ }
+ obj.controller.view.voided_balance.setAttribute('value', '$' + util.money.cents_as_dollars( voided_total ) );
+ },
+
+ /*****************************************************************************************************************************/
+
+ 'apply_payment' : function() {
+
+ var obj = this;
+ try {
+ var payment_blob = {};
+ JSAN.use('util.window');
+ var win = new util.window();
+ switch(obj.controller.view.payment_type.value) {
+ case 'credit_card_payment' :
+ obj.OpenILS.data.temp = '';
+ obj.OpenILS.data.stash('temp');
+ var my_xulG = win.open(
+ urls.XUL_PATRON_BILL_CC_INFO,
+ 'billccinfo',
+ 'chrome,resizable,modal'
+ );
+ obj.OpenILS.data.stash_retrieve();
+ //payment_blob = my_xulG.payment_blob; //JSON2js( obj.OpenILS.data.temp );
+ payment_blob = JSON2js( obj.OpenILS.data.temp );
+ break;
+ case 'check_payment' :
+ obj.OpenILS.data.temp = '';
+ obj.OpenILS.data.stash('temp');
+ var my_xulG = win.open(
+ urls.XUL_PATRON_BILL_CHECK_INFO,
+ 'billcheckinfo',
+ 'chrome,resizable,modal'
+ );
+ obj.OpenILS.data.stash_retrieve();
+ //payment_blob = my_xulG.payment_blob; //JSON2js( obj.OpenILS.data.temp );
+ payment_blob = JSON2js( obj.OpenILS.data.temp );
+ break;
+ }
+ if ((typeof payment_blob == 'undefined') || payment_blob=='' || payment_blob.cancelled=='true') { alert('cancelled'); return; }
+ payment_blob.userid = obj.patron_id;
+ payment_blob.note = payment_blob.note || '';
+ //payment_blob.cash_drawer = 1; // FIXME: get new Config() to work
+ payment_blob.payment_type = obj.controller.view.payment_type.value;
+ payment_blob.payments = [];
+ payment_blob.patron_credit = obj.controller.view.bill_credit_amount.value;
+ for (var i = 0; i < obj.current_payments.length; i++) {
+ var tb = obj.current_payments[ i ].textbox;
+ if ( !(tb.value == '0.00' || tb.value == '') ) {
+ payment_blob.payments.push(
+ [
+ obj.current_payments[ i ].mobts_id,
+ tb.value
+ ]
+ );
+ }
+ }
if ( payment_blob.payments.length == 0 && payment_blob.patron_credit == '0.00' ) {
alert($("patronStrings").getString('staff.patron.bills.apply_payment.nothing_applied'));
return;
}
- if ( obj.pay( payment_blob ) ) {
+ if ( obj.pay( payment_blob ) ) {
- obj.data.voided_billings = []; obj.data.stash('voided_billings');
- obj.refresh();
- try {
+ obj.data.voided_billings = []; obj.data.stash('voided_billings');
+ obj.refresh();
+ try {
var no_print_prompting = obj.data.hash.aous['circ.staff_client.do_not_auto_attempt_print'];
if (no_print_prompting) {
if (no_print_prompting.indexOf( "Bill Pay" ) > -1) return; // Skip print attempt
}
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.data.stash_retrieve();
- var template = 'bill_payment';
- JSAN.use('patron.util'); JSAN.use('util.functional');
- var params = {
- 'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id),
- 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
- 'staff' : obj.data.list.au[0],
- 'header' : obj.data.print_list_templates[template].header,
- 'line_item' : obj.data.print_list_templates[template].line_item,
- 'footer' : obj.data.print_list_templates[template].footer,
- 'type' : obj.data.print_list_templates[template].type,
- 'list' : util.functional.map_list(
- payment_blob.payments,
- function(o) {
- return {
- 'bill_id' : o[0],
- 'payment' : o[1],
- 'last_billing_type' : obj.bill_map[ o[0] ].transaction.last_billing_type(),
- 'last_billing_note' : obj.bill_map[ o[0] ].transaction.last_billing_note(),
- 'title' : typeof obj.bill_map[ o[0] ].title != 'undefined' ? obj.bill_map[ o[0] ].title : '',
- 'barcode' : typeof obj.bill_map[ o[0] ].barcode != 'undefined' ? obj.bill_map[ o[0] ].barcode : ''
- };
- }
- ),
- 'data' : obj.previous_summary
- };
- obj.error.sdump('D_DEBUG',js2JSON(params));
- if (document.getElementById('auto_print').checked) params.no_prompt = true;
- JSAN.use('util.print'); var print = new util.print();
- print.tree_list( params );
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bill receipt', E);
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> apply_payment',E);
- }
- },
-
- 'pay' : function(payment_blob) {
- var obj = this;
- try {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.data.stash_retrieve();
+ var template = 'bill_payment';
+ JSAN.use('patron.util'); JSAN.use('util.functional');
+ var params = {
+ 'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id),
+ 'lib' : obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ],
+ 'staff' : obj.data.list.au[0],
+ 'header' : obj.data.print_list_templates[template].header,
+ 'line_item' : obj.data.print_list_templates[template].line_item,
+ 'footer' : obj.data.print_list_templates[template].footer,
+ 'type' : obj.data.print_list_templates[template].type,
+ 'list' : util.functional.map_list(
+ payment_blob.payments,
+ function(o) {
+ return {
+ 'bill_id' : o[0],
+ 'payment' : o[1],
+ 'last_billing_type' : obj.bill_map[ o[0] ].transaction.last_billing_type(),
+ 'last_billing_note' : obj.bill_map[ o[0] ].transaction.last_billing_note(),
+ 'title' : typeof obj.bill_map[ o[0] ].title != 'undefined' ? obj.bill_map[ o[0] ].title : '',
+ 'barcode' : typeof obj.bill_map[ o[0] ].barcode != 'undefined' ? obj.bill_map[ o[0] ].barcode : ''
+ };
+ }
+ ),
+ 'data' : obj.previous_summary
+ };
+ obj.error.sdump('D_DEBUG',js2JSON(params));
+ if (document.getElementById('auto_print').checked) params.no_prompt = true;
+ JSAN.use('util.print'); var print = new util.print();
+ print.tree_list( params );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bill receipt', E);
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> apply_payment',E);
+ }
+ },
+
+ 'pay' : function(payment_blob) {
+ var obj = this;
+ try {
var x = document.getElementById('annotate_payment');
if (x && x.checked && (! payment_blob.note)) {
payment_blob.note = window.prompt($("patronStrings").getString('staff.patron.bills.pay.annotate_payment'),'', $("patronStrings").getString('staff.patron.bills.pay.annotate_payment.title'));
}
- obj.previous_summary = {
- original_balance : obj.controller.view.bill_total_owed.value,
- voided_balance : obj.controller.view.voided_balance.value,
- payment_received : obj.controller.view.bill_payment_amount.value,
- payment_applied : obj.controller.view.bill_payment_applied.value,
- change_given : obj.controller.view.bill_change_amount.value,
- credit_given : obj.controller.view.bill_credit_amount.value,
- new_balance : obj.controller.view.bill_new_balance.value,
- payment_type : obj.controller.view.payment_type.getAttribute('label'),
- note : payment_blob.note
- }
- var robj = obj.network.request(
- api.BILL_PAY.app,
- api.BILL_PAY.method,
- [ ses(), payment_blob ]
- );
- if (robj == 1) { return true; }
- if (typeof robj.ilsevent != 'undefined') {
- switch(Number(robj.ilsevent)) {
- case 0 /* SUCCESS */ : return true; break;
- case 1226 /* REFUND_EXCEEDS_DESK_PAYMENTS */ : alert($("patronStrings").getFormattedString('staff.patron.bills.pay.refund_exceeds_desk_payment', [robj.desc])); return false; break;
- default: throw(robj); break;
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.bills.pay.payment_failed'),E);
- return false;
- }
- },
-
- 'update_payment_applied' : function() {
- var obj = this;
- try {
- JSAN.use('util.money');
- var total_applied = 0;
- for (var i = 0; i < obj.current_payments.length; i++) {
- total_applied += util.money.dollars_float_to_cents_integer( obj.current_payments[ i ].textbox.value );
- }
- var total_payment = 0;
- if (obj.controller.view.bill_payment_amount.value) {
- try {
- total_payment = util.money.dollars_float_to_cents_integer( obj.controller.view.bill_payment_amount.value );
- } catch(E) {
- obj.error.sdump('D_ERROR',E + '\n');
- }
- }
- if ( total_applied > total_payment ) {
- total_payment = total_applied;
- obj.controller.view.bill_payment_amount.value = util.money.cents_as_dollars( total_applied );
- }
- obj.controller.view.bill_payment_applied.value = util.money.cents_as_dollars( total_applied );
- obj.controller.view.bill_payment_applied.setAttribute('value', obj.controller.view.bill_payment_applied.value )
- obj.controller.view.bill_credit_amount.value = '';
- if (total_payment > total_applied ) {
- obj.controller.view.bill_change_amount.value = util.money.cents_as_dollars( total_payment - total_applied);
- obj.controller.view.bill_credit_amount.value = '0.00';
- } else {
- obj.controller.view.bill_change_amount.value = '0.00';
- obj.controller.view.bill_credit_amount.value = '0.00';
- }
- var total_owed = util.money.dollars_float_to_cents_integer( obj.controller.view.bill_total_owed.value );
- obj.controller.view.bill_new_balance.value = util.money.cents_as_dollars( total_owed - total_applied );
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> update_payment_applied',E);
- }
- },
-
- 'change_to_credit' : function() {
- var obj = this;
- try {
- JSAN.use('util.money');
- var tb = obj.controller.view.bill_change_amount;
- var proposed_change = 0;
- var proposed_credit = util.money.dollars_float_to_cents_integer( tb.value );
- obj.update_payment_applied();
- var real_change = util.money.dollars_float_to_cents_integer( tb.value );
- if ( proposed_change > real_change ) {
- obj.error.sdump('D_ERROR',$("patronStrings").getString('staff.patron.bills.bill_change_amount.greedy'));
- proposed_change = real_change;
- } else if ( real_change > proposed_change ) {
- proposed_credit = real_change - proposed_change;
- }
- tb.value = util.money.cents_as_dollars( proposed_change );
- tb.setAttribute('value',tb.value);
- obj.controller.view.bill_credit_amount.value = util.money.cents_as_dollars( proposed_credit );
- obj.controller.view.bill_credit_amount.setAttribute('value',obj.controller.view.bill_credit_amount.value);
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> change_to_credit',E);
- }
- },
-
- 'retrieve' : function() {
- var obj = this;
- try {
- if (window.xulG && window.xulG.bills) {
- obj.bills = window.xulG.bills;
- } else {
- obj.bills = obj.network.simple_request(
- obj.SHOW_ME_THE_BILLS,
- [ ses(), obj.patron_id ]
- );
+ obj.previous_summary = {
+ original_balance : obj.controller.view.bill_total_owed.value,
+ voided_balance : obj.controller.view.voided_balance.value,
+ payment_received : obj.controller.view.bill_payment_amount.value,
+ payment_applied : obj.controller.view.bill_payment_applied.value,
+ change_given : obj.controller.view.bill_change_amount.value,
+ credit_given : obj.controller.view.bill_credit_amount.value,
+ new_balance : obj.controller.view.bill_new_balance.value,
+ payment_type : obj.controller.view.payment_type.getAttribute('label'),
+ note : payment_blob.note
+ }
+ var robj = obj.network.request(
+ api.BILL_PAY.app,
+ api.BILL_PAY.method,
+ [ ses(), payment_blob ]
+ );
+ if (robj == 1) { return true; }
+ if (typeof robj.ilsevent != 'undefined') {
+ switch(Number(robj.ilsevent)) {
+ case 0 /* SUCCESS */ : return true; break;
+ case 1226 /* REFUND_EXCEEDS_DESK_PAYMENTS */ : alert($("patronStrings").getFormattedString('staff.patron.bills.pay.refund_exceeds_desk_payment', [robj.desc])); return false; break;
+ default: throw(robj); break;
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.bills.pay.payment_failed'),E);
+ return false;
+ }
+ },
+
+ 'update_payment_applied' : function() {
+ var obj = this;
+ try {
+ JSAN.use('util.money');
+ var total_applied = 0;
+ for (var i = 0; i < obj.current_payments.length; i++) {
+ total_applied += util.money.dollars_float_to_cents_integer( obj.current_payments[ i ].textbox.value );
+ }
+ var total_payment = 0;
+ if (obj.controller.view.bill_payment_amount.value) {
+ try {
+ total_payment = util.money.dollars_float_to_cents_integer( obj.controller.view.bill_payment_amount.value );
+ } catch(E) {
+ obj.error.sdump('D_ERROR',E + '\n');
+ }
+ }
+ if ( total_applied > total_payment ) {
+ total_payment = total_applied;
+ obj.controller.view.bill_payment_amount.value = util.money.cents_as_dollars( total_applied );
+ }
+ obj.controller.view.bill_payment_applied.value = util.money.cents_as_dollars( total_applied );
+ obj.controller.view.bill_payment_applied.setAttribute('value', obj.controller.view.bill_payment_applied.value )
+ obj.controller.view.bill_credit_amount.value = '';
+ if (total_payment > total_applied ) {
+ obj.controller.view.bill_change_amount.value = util.money.cents_as_dollars( total_payment - total_applied);
+ obj.controller.view.bill_credit_amount.value = '0.00';
+ } else {
+ obj.controller.view.bill_change_amount.value = '0.00';
+ obj.controller.view.bill_credit_amount.value = '0.00';
+ }
+ var total_owed = util.money.dollars_float_to_cents_integer( obj.controller.view.bill_total_owed.value );
+ obj.controller.view.bill_new_balance.value = util.money.cents_as_dollars( total_owed - total_applied );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> update_payment_applied',E);
+ }
+ },
+
+ 'change_to_credit' : function() {
+ var obj = this;
+ try {
+ JSAN.use('util.money');
+ var tb = obj.controller.view.bill_change_amount;
+ var proposed_change = 0;
+ var proposed_credit = util.money.dollars_float_to_cents_integer( tb.value );
+ obj.update_payment_applied();
+ var real_change = util.money.dollars_float_to_cents_integer( tb.value );
+ if ( proposed_change > real_change ) {
+ obj.error.sdump('D_ERROR',$("patronStrings").getString('staff.patron.bills.bill_change_amount.greedy'));
+ proposed_change = real_change;
+ } else if ( real_change > proposed_change ) {
+ proposed_credit = real_change - proposed_change;
+ }
+ tb.value = util.money.cents_as_dollars( proposed_change );
+ tb.setAttribute('value',tb.value);
+ obj.controller.view.bill_credit_amount.value = util.money.cents_as_dollars( proposed_credit );
+ obj.controller.view.bill_credit_amount.setAttribute('value',obj.controller.view.bill_credit_amount.value);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> change_to_credit',E);
+ }
+ },
+
+ 'retrieve' : function() {
+ var obj = this;
+ try {
+ if (window.xulG && window.xulG.bills) {
+ obj.bills = window.xulG.bills;
+ } else {
+ obj.bills = obj.network.simple_request(
+ obj.SHOW_ME_THE_BILLS,
+ [ ses(), obj.patron_id ]
+ );
if (typeof obj.bills.ilsevent != 'undefined' || typeof obj.bills == 'null') { throw(obj.bills); }
- for (var i = 0; i < obj.bills.length; i++) {
- if (instanceOf(obj.bills[i],mobts)) {
- obj.bills[i] = { 'transaction' : obj.bills[i] }
- } else if (instanceOf(obj.bills[i],mbts)) {
- obj.bills[i] = { 'transaction' : obj.bills[i] }
- } else {
- var robj = obj.network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),obj.bills[i]]);
- //alert('robj = ' + js2JSON(robj));
- obj.bills[i] = { 'transaction' : robj }
- }
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> retrieve',E);
- }
- },
+ for (var i = 0; i < obj.bills.length; i++) {
+ if (instanceOf(obj.bills[i],mobts)) {
+ obj.bills[i] = { 'transaction' : obj.bills[i] }
+ } else if (instanceOf(obj.bills[i],mbts)) {
+ obj.bills[i] = { 'transaction' : obj.bills[i] }
+ } else {
+ var robj = obj.network.simple_request('FM_MBTS_RETRIEVE.authoritative',[ses(),obj.bills[i]]);
+ //alert('robj = ' + js2JSON(robj));
+ obj.bills[i] = { 'transaction' : robj }
+ }
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> retrieve',E);
+ }
+ },
'print_bills' : function() {
var obj = this;
'line_item' : obj.data.print_list_templates[template].line_item,
'footer' : obj.data.print_list_templates[template].footer,
'type' : obj.data.print_list_templates[template].type,
- 'list' : util.functional.map_list(
+ 'list' : util.functional.map_list(
obj.bills,
function(o) {
var id = o.transaction.id();
print.tree_list( params );
} catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> print_bills',E);
+ obj.error.standard_unexpected_error_alert('bills -> print_bills',E);
}
},
- 'xact_dates_box' : function ( mobts ) {
- var obj = this;
- try {
- var grid = document.createElement('grid');
- var cols = document.createElement('columns');
- grid.appendChild( cols );
- cols.appendChild( document.createElement('column') );
- cols.appendChild( document.createElement('column') );
- var rows = document.createElement('rows');
- grid.appendChild( rows );
- var row0 = document.createElement('row');
- rows.appendChild( row0 );
- var cb_r0_0 = document.createElement('checkbox');
- row0.appendChild( cb_r0_0 );
- cb_r0_0.setAttribute('checked',true);
- var hb_r0_1 = document.createElement('hbox');
- row0.appendChild( hb_r0_1 );
- var label_r0_1 = document.createElement('label');
- hb_r0_1.appendChild( label_r0_1 );
- label_r0_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_id_label'));
- var label_r0_2 = document.createElement('label');
- hb_r0_1.appendChild( label_r0_2 );
- label_r0_2.setAttribute('value',mobts.id());
- var row1 = document.createElement('row');
- rows.appendChild( row1 );
- var label_r1_1 = document.createElement('label');
- row1.appendChild( label_r1_1 );
- label_r1_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_xact_start_label'));
- var label_r1_2 = document.createElement('label');
- row1.appendChild( label_r1_2 );
- label_r1_2.setAttribute('value',mobts.xact_start().toString().substr(0,10));
- var row2 = document.createElement('row');
- rows.appendChild( row2 );
- var label_r2_1 = document.createElement('label');
- row2.appendChild( label_r2_1 );
- label_r2_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_xact_finish_label'));
- var label_r2_2 = document.createElement('label');
- row2.appendChild( label_r2_2 );
- try { label_r2_2.setAttribute('value',mobts.xact_finish().toString().substr(0,10));
- } catch(E) {}
-
- return grid;
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> xact_dates_box',E);
- }
- },
-
- 'money_box' : function ( mobts ) {
- var obj = this;
- try {
- JSAN.use('util.money');
- var grid = document.createElement('grid');
- var cols = document.createElement('columns');
- grid.appendChild( cols );
- cols.appendChild( document.createElement('column') );
- cols.appendChild( document.createElement('column') );
- var rows = document.createElement('rows');
- grid.appendChild( rows );
- var row1 = document.createElement('row');
- rows.appendChild( row1 );
- var label_r1_1 = document.createElement('label');
- row1.appendChild( label_r1_1 );
- label_r1_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_total_owed_label'));
- var label_r1_2 = document.createElement('label');
- row1.appendChild( label_r1_2 );
- label_r1_2.setAttribute('value','$' + util.money.sanitize(mobts.total_owed() || '0') );
- var row2 = document.createElement('row');
- rows.appendChild( row2 );
- var label_r2_1 = document.createElement('label');
- row2.appendChild( label_r2_1 );
- label_r2_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_total_paid_label'));
- var label_r2_2 = document.createElement('label');
- row2.appendChild( label_r2_2 );
- label_r2_2.setAttribute('value','$' + util.money.sanitize(mobts.total_paid() || '0') );
- var row3 = document.createElement('row');
- rows.appendChild( row3 );
- var label_r3_1 = document.createElement('label');
- row3.appendChild( label_r3_1 );
- label_r3_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_balance_owed_label'));
- label_r3_1.setAttribute('style','font-weight: bold');
- var label_r3_2 = document.createElement('label');
- row3.appendChild( label_r3_2 );
- label_r3_2.setAttribute('value','$' + util.money.sanitize(mobts.balance_owed() || '0') );
- label_r3_2.setAttribute('style','font-weight: bold');
-
- return grid;
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> money_box',E);
- }
- },
-
- 'info_box' : function ( my ) {
- var obj = this;
- try {
- var vbox = document.createElement('vbox');
-
- var hbox = document.createElement('hbox');
- vbox.appendChild( hbox ); hbox.flex = 1;
-
- var cb = document.createElement('checkbox');
- hbox.appendChild( cb );
- if ( my.mobts.balance_owed() == 0 ) {
- cb.setAttribute('disabled', 'true');
- } else {
- if (my.mobts.balance_owed() > 0) {
- cb.setAttribute('checked', true);
- }
- }
- cb.addEventListener(
- 'command',
- function() {
- setTimeout(
- function() {
- obj.distribute_payment(obj.controller.view.bill_payment_amount);
- obj.tally_selected();
- }, 0
- );
- },
- false
- );
-
-
- var grid = document.createElement('grid');
- hbox.appendChild( grid );
-
- var cols = document.createElement('columns');
- grid.appendChild( cols );
- cols.appendChild( document.createElement('column') );
- cols.appendChild( document.createElement('column') );
- var rows = document.createElement('rows');
- grid.appendChild( rows );
-
- var xact_type = document.createElement('row');
- rows.appendChild( xact_type );
-
- var xt_label = document.createElement('label');
- xact_type.appendChild( xt_label );
- var xt_value = document.createElement('description');
- xact_type.appendChild( xt_value );
-
- try {
- switch(my.mobts.xact_type()) {
- case 'circulation':
- xt_label.setAttribute( 'value', $("patronStrings").getString('staff.patron.bills.info_box.label_value.title') );
- obj.network.simple_request(
- 'FM_CIRC_RETRIEVE_VIA_ID',
- [ ses(), my.mobts.id() ],
- function (req) {
- var r_circ = req.getResultObject();
- if (instanceOf(r_circ,circ)) {
- /*
- xt_start.setAttribute('value','Checked Out: ' + r_circ.xact_start().toString().substr(0,10) );
- if (r_circ.checkin_time()) {
- xt_finish.setAttribute('value','Returned: ' + r_circ.checkin_time().toString().substr(0,10) );
- } else {
- xt_finish.setAttribute('value','Due: ' + r_circ.due_date().toString().substr(0,10) );
- }
- */
- if (! r_circ.checkin_time()) {
- xt_value.setAttribute('style','background: red; color: white');
- if (document.getElementById('circulating_hint')) {
- document.getElementById('circulating_hint').hidden = false;
- }
- }
- obj.network.simple_request(
- 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY',
- [ r_circ.target_copy() ],
- function (rreq) {
- var r_mvr = rreq.getResultObject();
- if (instanceOf(r_mvr,mvr)) {
- xt_value.appendChild( document.createTextNode( String( r_mvr.title() ).substr(0,50) ) );
- obj.bill_map[ my.mobts.id() ].title = r_mvr.title();
- }
- }
- );
- obj.network.simple_request(
- 'FM_ACP_RETRIEVE',
- [ r_circ.target_copy() ],
- function (rrreq) {
- var r_acp = rrreq.getResultObject();
- if (instanceOf(r_acp,acp)) {
- xt_value.appendChild( document.createTextNode( r_acp.dummy_title() ) );
- if (r_acp.dummy_title()) obj.bill_map[ my.mobts.id() ].title = r_acp.dummy_title();
- obj.bill_map[ my.mobts.id() ].barcode = r_acp.barcode();
- }
- }
- );
- }
- }
- );
- break;
- default:
- xt_label.setAttribute( 'value',
- my.mvr ? $("patronStrings").getString('staff.patron.bills.info_box.label_value.title') : $("patronStrings").getString('staff.patron.bills.info_box.label_value.type') );
- xt_value.appendChild( document.createTextNode( my.mvr ? my.mvr.title() : my.mobts.xact_type() ) );
- break;
- }
- } catch(E) { alert(E); }
-
- var last_billing = document.createElement('row');
- rows.appendChild( last_billing );
-
- var lb_label = document.createElement('label');
- last_billing.appendChild( lb_label );
- lb_label.setAttribute( 'value', $("patronStrings").getString('staff.patron.bills.info_box.label_value.last_billing') );
-
- var lb_value = document.createElement('label');
- last_billing.appendChild( lb_value );
- if (my.mobts.last_billing_type())
- lb_value.setAttribute( 'value', my.mobts.last_billing_type() );
- /*
- var last_payment = document.createElement('row');
- rows.appendChild( last_payment );
-
- var lp_label = document.createElement('label');
- last_payment.appendChild( lp_label );
- lp_label.setAttribute( 'value', 'Last Payment:' );
-
- var lp_value = document.createElement('label');
- last_payment.appendChild( lp_value );
- if (my.mobts.last_payment_type())
- lp_value.setAttribute( 'value', my.mobts.last_payment_type() );
- */
- var btn_box = document.createElement('hbox');
- vbox.appendChild( btn_box ); btn_box.flex = 1;
- var btn = document.createElement('button');
- btn_box.appendChild( btn );
- btn.setAttribute( 'label', $("patronStrings").getString('staff.patron.bills.info_box.label_value.full_details') );
- btn.setAttribute( 'name', 'full_details' );
- btn.setAttribute( 'mobts_id', my.mobts.id() );
- btn.addEventListener(
- 'command',
- function(ev) {
- JSAN.use('util.window'); var win = new util.window();
- var my_xulG = win.open(
- urls.XUL_PATRON_BILL_DETAILS,
- //+ '?patron_id=' + window.escape(obj.patron_id)
- //+ '&mbts_id=' + window.escape(my.mobts.id()),
- 'test' + my.mobts.id(),
- 'chrome,resizable',
- {
- 'patron_id' : obj.patron_id,
- 'mbts_id' : my.mobts.id(),
- 'refresh' : function() { obj.refresh(); },
- }
- );
- },
- false
- );
- var btn2 = document.createElement('button');
- btn_box.appendChild( btn2 );
- btn2.setAttribute( 'label', $("patronStrings").getString('staff.patron.bills.info_box.label_value.add_billing') );
- btn2.setAttribute( 'mobts_id', my.mobts.id() );
- btn2.addEventListener(
- 'command',
- function(ev) {
- JSAN.use('util.window');
- var win = new util.window();
- var my_xulG = win.open(
- urls.XUL_PATRON_BILL_WIZARD,
- //+ '?patron_id=' + window.escape(obj.patron_id)
- //+ '&xact_id=' + window.escape( my.mobts.id() ),
- 'billwizard',
- 'chrome,resizable,modal',
- {
- 'patron_id' : obj.patron_id,
- 'xact_id' : my.mobts.id(),
- }
- );
- obj.refresh();
- },
- false
- );
- if (my.mobts.balance_owed() < 0) {
- var btn3 = document.createElement('button');
- btn_box.appendChild( btn3 );
- btn3.setAttribute( 'label', $("patronStrings").getString('staff.patron.bills.info_box.label_value.refund') );
- btn3.setAttribute( 'mobts_id', my.mobts.id() );
- btn3.addEventListener(
- 'command',
- function(ev) {
- cb.setAttribute('checked',true);
- obj.distribute_payment(obj.controller.view.bill_payment_amount);
- obj.tally_selected();
- },
- false
- );
- }
-
- var btn4 = document.createElement('button');
- btn_box.appendChild( btn4 );
- btn4.setAttribute( 'label', $("patronStrings").getString('staff.patron.bills.info_box.label_value.void_all_billings') );
- btn4.setAttribute( 'mobts_id', my.mobts.id() );
- btn4.addEventListener(
- 'command',
- function(ev) {
- obj.void_all_billings( my.mobts.id() );
- },
- false
- );
-
- return vbox;
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> info_box',E);
- }
- },
-
- 'payment_box' : function() {
- try {
- var vb = document.createElement('vbox');
- var tb = document.createElement('textbox');
- tb.setAttribute('readonly','true');
- vb.appendChild(tb);
- return vb;
- } catch(E) {
- this.error.standard_unexpected_error_alert('bills -> payment_box',E);
- }
- },
-
- 'void_all_billings' : function(mobts_id) {
- try {
- var obj = this;
- JSAN.use('util.functional');
-
- var mb_list = obj.network.simple_request( 'FM_MB_RETRIEVE_VIA_MBTS_ID.authoritative', [ ses(), mobts_id ] );
- if (typeof mb_list.ilsevent != 'undefined') throw(mb_list);
-
- mb_list = util.functional.filter_list( mb_list, function(o) { return ! get_bool( o.voided() ) });
-
- if (mb_list.length == 0) { alert($("patronStrings").getString('staff.patron.bills.void_all_billings.all_voided')); return; }
-
- var sum = 0;
- for (var i = 0; i < mb_list.length; i++) sum += util.money.dollars_float_to_cents_integer( mb_list[i].amount() );
- sum = util.money.cents_as_dollars( sum );
-
- var msg = $("patronStrings").getFormattedString('staff.patron.bills.void_all_billings.void.message', [sum]);
- var r = obj.error.yns_alert(msg,
- $("patronStrings").getString('staff.patron.bills.void_all_billings.void.title'),
- $("patronStrings").getString('staff.patron.bills.void_all_billings.void.yes'),
- $("patronStrings").getString('staff.patron.bills.void_all_billings.void.no'), null,
- $("patronStrings").getString('staff.patron.bills.void_all_billings.void.confirm_message'));
- if (r == 0) {
- var robj = obj.network.simple_request('FM_MB_VOID',[ses()].concat(util.functional.map_list(mb_list,function(o){return o.id();})));
- if (robj.ilsevent) {
- switch(Number(robj.ilsevent)) {
- default:
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.bills.void_all_billings.error_voiding_bills'),robj);
- obj.refresh(); return;
- break;
- }
- }
-
- obj.data.stash_retrieve(); if (! obj.data.voided_billings ) obj.data.voided_billings = [];
- for (var i = 0; i < mb_list.length; i++) {
- obj.data.voided_billings.push( mb_list[i] );
- }
- obj.data.stash('voided_billings');
- alert($("patronStrings").getString('staff.patron.bills.void_all_billings.billings_voided'));
- obj.refresh();
- }
- } catch(E) {
- try { obj.error.standard_unexpected_error_alert('bills.js, void_all_billings():',E); } catch(F) { alert(E); }
- }
-
- },
-
- 'gen_map_row_to_column' : function() {
- var obj = this;
-
- try {
-
- return function(row,col) {
- // row contains { 'my' : { 'mobts' : ... } }
- // col contains one of the objects listed above in columns
-
- var my = row.my;
- var value;
- try {
- value = eval( col.render );
- } catch(E) {
- try{obj.error.sdump('D_ERROR','map_row_to_column: ' + E);}
- catch(P){dump('?map_row_to_column: ' + E + '\n');}
- value = '???';
- }
- //dump('map_row_to_column: value = ' + value + '\n');
- return value;
- };
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert('bills -> gen_map_row_to_column',E);
- }
- },
+ 'xact_dates_box' : function ( mobts ) {
+ var obj = this;
+ try {
+ var grid = document.createElement('grid');
+ var cols = document.createElement('columns');
+ grid.appendChild( cols );
+ cols.appendChild( document.createElement('column') );
+ cols.appendChild( document.createElement('column') );
+ var rows = document.createElement('rows');
+ grid.appendChild( rows );
+ var row0 = document.createElement('row');
+ rows.appendChild( row0 );
+ var cb_r0_0 = document.createElement('checkbox');
+ row0.appendChild( cb_r0_0 );
+ cb_r0_0.setAttribute('checked',true);
+ var hb_r0_1 = document.createElement('hbox');
+ row0.appendChild( hb_r0_1 );
+ var label_r0_1 = document.createElement('label');
+ hb_r0_1.appendChild( label_r0_1 );
+ label_r0_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_id_label'));
+ var label_r0_2 = document.createElement('label');
+ hb_r0_1.appendChild( label_r0_2 );
+ label_r0_2.setAttribute('value',mobts.id());
+ var row1 = document.createElement('row');
+ rows.appendChild( row1 );
+ var label_r1_1 = document.createElement('label');
+ row1.appendChild( label_r1_1 );
+ label_r1_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_xact_start_label'));
+ var label_r1_2 = document.createElement('label');
+ row1.appendChild( label_r1_2 );
+ label_r1_2.setAttribute('value',mobts.xact_start().toString().substr(0,10));
+ var row2 = document.createElement('row');
+ rows.appendChild( row2 );
+ var label_r2_1 = document.createElement('label');
+ row2.appendChild( label_r2_1 );
+ label_r2_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_xact_finish_label'));
+ var label_r2_2 = document.createElement('label');
+ row2.appendChild( label_r2_2 );
+ try { label_r2_2.setAttribute('value',mobts.xact_finish().toString().substr(0,10));
+ } catch(E) {}
+
+ return grid;
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> xact_dates_box',E);
+ }
+ },
+
+ 'money_box' : function ( mobts ) {
+ var obj = this;
+ try {
+ JSAN.use('util.money');
+ var grid = document.createElement('grid');
+ var cols = document.createElement('columns');
+ grid.appendChild( cols );
+ cols.appendChild( document.createElement('column') );
+ cols.appendChild( document.createElement('column') );
+ var rows = document.createElement('rows');
+ grid.appendChild( rows );
+ var row1 = document.createElement('row');
+ rows.appendChild( row1 );
+ var label_r1_1 = document.createElement('label');
+ row1.appendChild( label_r1_1 );
+ label_r1_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_total_owed_label'));
+ var label_r1_2 = document.createElement('label');
+ row1.appendChild( label_r1_2 );
+ label_r1_2.setAttribute('value','$' + util.money.sanitize(mobts.total_owed() || '0') );
+ var row2 = document.createElement('row');
+ rows.appendChild( row2 );
+ var label_r2_1 = document.createElement('label');
+ row2.appendChild( label_r2_1 );
+ label_r2_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_total_paid_label'));
+ var label_r2_2 = document.createElement('label');
+ row2.appendChild( label_r2_2 );
+ label_r2_2.setAttribute('value','$' + util.money.sanitize(mobts.total_paid() || '0') );
+ var row3 = document.createElement('row');
+ rows.appendChild( row3 );
+ var label_r3_1 = document.createElement('label');
+ row3.appendChild( label_r3_1 );
+ label_r3_1.setAttribute('value',document.getElementById('commonStrings').getString('staff.mbts_balance_owed_label'));
+ label_r3_1.setAttribute('style','font-weight: bold');
+ var label_r3_2 = document.createElement('label');
+ row3.appendChild( label_r3_2 );
+ label_r3_2.setAttribute('value','$' + util.money.sanitize(mobts.balance_owed() || '0') );
+ label_r3_2.setAttribute('style','font-weight: bold');
+
+ return grid;
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> money_box',E);
+ }
+ },
+
+ 'info_box' : function ( my ) {
+ var obj = this;
+ try {
+ var vbox = document.createElement('vbox');
+
+ var hbox = document.createElement('hbox');
+ vbox.appendChild( hbox ); hbox.flex = 1;
+
+ var cb = document.createElement('checkbox');
+ hbox.appendChild( cb );
+ if ( my.mobts.balance_owed() == 0 ) {
+ cb.setAttribute('disabled', 'true');
+ } else {
+ if (my.mobts.balance_owed() > 0) {
+ cb.setAttribute('checked', true);
+ }
+ }
+ cb.addEventListener(
+ 'command',
+ function() {
+ setTimeout(
+ function() {
+ obj.distribute_payment(obj.controller.view.bill_payment_amount);
+ obj.tally_selected();
+ }, 0
+ );
+ },
+ false
+ );
+
+
+ var grid = document.createElement('grid');
+ hbox.appendChild( grid );
+
+ var cols = document.createElement('columns');
+ grid.appendChild( cols );
+ cols.appendChild( document.createElement('column') );
+ cols.appendChild( document.createElement('column') );
+ var rows = document.createElement('rows');
+ grid.appendChild( rows );
+
+ var xact_type = document.createElement('row');
+ rows.appendChild( xact_type );
+
+ var xt_label = document.createElement('label');
+ xact_type.appendChild( xt_label );
+ var xt_value = document.createElement('description');
+ xact_type.appendChild( xt_value );
+
+ try {
+ switch(my.mobts.xact_type()) {
+ case 'circulation':
+ xt_label.setAttribute( 'value', $("patronStrings").getString('staff.patron.bills.info_box.label_value.title') );
+ obj.network.simple_request(
+ 'FM_CIRC_RETRIEVE_VIA_ID',
+ [ ses(), my.mobts.id() ],
+ function (req) {
+ var r_circ = req.getResultObject();
+ if (instanceOf(r_circ,circ)) {
+ /*
+ xt_start.setAttribute('value','Checked Out: ' + r_circ.xact_start().toString().substr(0,10) );
+ if (r_circ.checkin_time()) {
+ xt_finish.setAttribute('value','Returned: ' + r_circ.checkin_time().toString().substr(0,10) );
+ } else {
+ xt_finish.setAttribute('value','Due: ' + r_circ.due_date().toString().substr(0,10) );
+ }
+ */
+ if (! r_circ.checkin_time()) {
+ xt_value.setAttribute('style','background: red; color: white');
+ if (document.getElementById('circulating_hint')) {
+ document.getElementById('circulating_hint').hidden = false;
+ }
+ }
+ obj.network.simple_request(
+ 'MODS_SLIM_RECORD_RETRIEVE_VIA_COPY',
+ [ r_circ.target_copy() ],
+ function (rreq) {
+ var r_mvr = rreq.getResultObject();
+ if (instanceOf(r_mvr,mvr)) {
+ xt_value.appendChild( document.createTextNode( String( r_mvr.title() ).substr(0,50) ) );
+ obj.bill_map[ my.mobts.id() ].title = r_mvr.title();
+ }
+ }
+ );
+ obj.network.simple_request(
+ 'FM_ACP_RETRIEVE',
+ [ r_circ.target_copy() ],
+ function (rrreq) {
+ var r_acp = rrreq.getResultObject();
+ if (instanceOf(r_acp,acp)) {
+ xt_value.appendChild( document.createTextNode( r_acp.dummy_title() ) );
+ if (r_acp.dummy_title()) obj.bill_map[ my.mobts.id() ].title = r_acp.dummy_title();
+ obj.bill_map[ my.mobts.id() ].barcode = r_acp.barcode();
+ }
+ }
+ );
+ }
+ }
+ );
+ break;
+ default:
+ xt_label.setAttribute( 'value',
+ my.mvr ? $("patronStrings").getString('staff.patron.bills.info_box.label_value.title') : $("patronStrings").getString('staff.patron.bills.info_box.label_value.type') );
+ xt_value.appendChild( document.createTextNode( my.mvr ? my.mvr.title() : my.mobts.xact_type() ) );
+ break;
+ }
+ } catch(E) { alert(E); }
+
+ var last_billing = document.createElement('row');
+ rows.appendChild( last_billing );
+
+ var lb_label = document.createElement('label');
+ last_billing.appendChild( lb_label );
+ lb_label.setAttribute( 'value', $("patronStrings").getString('staff.patron.bills.info_box.label_value.last_billing') );
+
+ var lb_value = document.createElement('label');
+ last_billing.appendChild( lb_value );
+ if (my.mobts.last_billing_type())
+ lb_value.setAttribute( 'value', my.mobts.last_billing_type() );
+ /*
+ var last_payment = document.createElement('row');
+ rows.appendChild( last_payment );
+
+ var lp_label = document.createElement('label');
+ last_payment.appendChild( lp_label );
+ lp_label.setAttribute( 'value', 'Last Payment:' );
+
+ var lp_value = document.createElement('label');
+ last_payment.appendChild( lp_value );
+ if (my.mobts.last_payment_type())
+ lp_value.setAttribute( 'value', my.mobts.last_payment_type() );
+ */
+ var btn_box = document.createElement('hbox');
+ vbox.appendChild( btn_box ); btn_box.flex = 1;
+ var btn = document.createElement('button');
+ btn_box.appendChild( btn );
+ btn.setAttribute( 'label', $("patronStrings").getString('staff.patron.bills.info_box.label_value.full_details') );
+ btn.setAttribute( 'name', 'full_details' );
+ btn.setAttribute( 'mobts_id', my.mobts.id() );
+ btn.addEventListener(
+ 'command',
+ function(ev) {
+ JSAN.use('util.window'); var win = new util.window();
+ var my_xulG = win.open(
+ urls.XUL_PATRON_BILL_DETAILS,
+ //+ '?patron_id=' + window.escape(obj.patron_id)
+ //+ '&mbts_id=' + window.escape(my.mobts.id()),
+ 'test' + my.mobts.id(),
+ 'chrome,resizable',
+ {
+ 'patron_id' : obj.patron_id,
+ 'mbts_id' : my.mobts.id(),
+ 'refresh' : function() { obj.refresh(); },
+ }
+ );
+ },
+ false
+ );
+ var btn2 = document.createElement('button');
+ btn_box.appendChild( btn2 );
+ btn2.setAttribute( 'label', $("patronStrings").getString('staff.patron.bills.info_box.label_value.add_billing') );
+ btn2.setAttribute( 'mobts_id', my.mobts.id() );
+ btn2.addEventListener(
+ 'command',
+ function(ev) {
+ JSAN.use('util.window');
+ var win = new util.window();
+ var my_xulG = win.open(
+ urls.XUL_PATRON_BILL_WIZARD,
+ //+ '?patron_id=' + window.escape(obj.patron_id)
+ //+ '&xact_id=' + window.escape( my.mobts.id() ),
+ 'billwizard',
+ 'chrome,resizable,modal',
+ {
+ 'patron_id' : obj.patron_id,
+ 'xact_id' : my.mobts.id(),
+ }
+ );
+ obj.refresh();
+ },
+ false
+ );
+ if (my.mobts.balance_owed() < 0) {
+ var btn3 = document.createElement('button');
+ btn_box.appendChild( btn3 );
+ btn3.setAttribute( 'label', $("patronStrings").getString('staff.patron.bills.info_box.label_value.refund') );
+ btn3.setAttribute( 'mobts_id', my.mobts.id() );
+ btn3.addEventListener(
+ 'command',
+ function(ev) {
+ cb.setAttribute('checked',true);
+ obj.distribute_payment(obj.controller.view.bill_payment_amount);
+ obj.tally_selected();
+ },
+ false
+ );
+ }
+
+ var btn4 = document.createElement('button');
+ btn_box.appendChild( btn4 );
+ btn4.setAttribute( 'label', $("patronStrings").getString('staff.patron.bills.info_box.label_value.void_all_billings') );
+ btn4.setAttribute( 'mobts_id', my.mobts.id() );
+ btn4.addEventListener(
+ 'command',
+ function(ev) {
+ obj.void_all_billings( my.mobts.id() );
+ },
+ false
+ );
+
+ return vbox;
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> info_box',E);
+ }
+ },
+
+ 'payment_box' : function() {
+ try {
+ var vb = document.createElement('vbox');
+ var tb = document.createElement('textbox');
+ tb.setAttribute('readonly','true');
+ vb.appendChild(tb);
+ return vb;
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('bills -> payment_box',E);
+ }
+ },
+
+ 'void_all_billings' : function(mobts_id) {
+ try {
+ var obj = this;
+ JSAN.use('util.functional');
+
+ var mb_list = obj.network.simple_request( 'FM_MB_RETRIEVE_VIA_MBTS_ID.authoritative', [ ses(), mobts_id ] );
+ if (typeof mb_list.ilsevent != 'undefined') throw(mb_list);
+
+ mb_list = util.functional.filter_list( mb_list, function(o) { return ! get_bool( o.voided() ) });
+
+ if (mb_list.length == 0) { alert($("patronStrings").getString('staff.patron.bills.void_all_billings.all_voided')); return; }
+
+ var sum = 0;
+ for (var i = 0; i < mb_list.length; i++) sum += util.money.dollars_float_to_cents_integer( mb_list[i].amount() );
+ sum = util.money.cents_as_dollars( sum );
+
+ var msg = $("patronStrings").getFormattedString('staff.patron.bills.void_all_billings.void.message', [sum]);
+ var r = obj.error.yns_alert(msg,
+ $("patronStrings").getString('staff.patron.bills.void_all_billings.void.title'),
+ $("patronStrings").getString('staff.patron.bills.void_all_billings.void.yes'),
+ $("patronStrings").getString('staff.patron.bills.void_all_billings.void.no'), null,
+ $("patronStrings").getString('staff.patron.bills.void_all_billings.void.confirm_message'));
+ if (r == 0) {
+ var robj = obj.network.simple_request('FM_MB_VOID',[ses()].concat(util.functional.map_list(mb_list,function(o){return o.id();})));
+ if (robj.ilsevent) {
+ switch(Number(robj.ilsevent)) {
+ default:
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.bills.void_all_billings.error_voiding_bills'),robj);
+ obj.refresh(); return;
+ break;
+ }
+ }
+
+ obj.data.stash_retrieve(); if (! obj.data.voided_billings ) obj.data.voided_billings = [];
+ for (var i = 0; i < mb_list.length; i++) {
+ obj.data.voided_billings.push( mb_list[i] );
+ }
+ obj.data.stash('voided_billings');
+ alert($("patronStrings").getString('staff.patron.bills.void_all_billings.billings_voided'));
+ obj.refresh();
+ }
+ } catch(E) {
+ try { obj.error.standard_unexpected_error_alert('bills.js, void_all_billings():',E); } catch(F) { alert(E); }
+ }
+
+ },
+
+ 'gen_map_row_to_column' : function() {
+ var obj = this;
+
+ try {
+
+ return function(row,col) {
+ // row contains { 'my' : { 'mobts' : ... } }
+ // col contains one of the objects listed above in columns
+
+ var my = row.my;
+ var value;
+ try {
+ value = eval( col.render );
+ } catch(E) {
+ try{obj.error.sdump('D_ERROR','map_row_to_column: ' + E);}
+ catch(P){dump('?map_row_to_column: ' + E + '\n');}
+ value = '???';
+ }
+ //dump('map_row_to_column: value = ' + value + '\n');
+ return value;
+ };
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('bills -> gen_map_row_to_column',E);
+ }
+ },
}
if (typeof patron == 'undefined') patron = {};
patron.display = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.window'); this.window = new util.window();
- JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.window'); this.window = new util.window();
+ JSAN.use('util.network'); this.network = new util.network();
JSAN.use('util.widgets');
- this.w = window;
+ this.w = window;
}
patron.display.prototype = {
- 'retrieve_ids' : [],
- 'stop_checkouts' : false,
- 'check_stop_checkouts' : function() { return this.stop_checkouts; },
-
- 'init' : function( params ) {
-
- var obj = this;
-
- obj.barcode = params['barcode'];
- obj.id = params['id'];
-
- JSAN.use('OpenILS.data'); this.OpenILS = {};
- obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
-
- //var horizontal_interface = String( obj.OpenILS.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
- //document.getElementById('ui.circ.patron_summary.horizontal').setAttribute('orient', horizontal_interface ? 'vertical' : 'horizontal');
- //document.getElementById('pdms1').setAttribute('orient', horizontal_interface ? 'vertical' : 'horizontal');
-
- JSAN.use('util.deck');
- obj.right_deck = new util.deck('patron_right_deck');
- obj.left_deck = new util.deck('patron_left_deck');
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'cmd_broken' : [
- ['command'],
- function() { alert($("commonStrings").getString('common.unimplemented')); }
- ],
- 'cmd_patron_retrieve' : [
- ['command'],
- function(ev) {
- if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- try {
- window.xulG.new_patron_tab(
- {}, { 'id' : obj.retrieve_ids[i] }
- );
- } catch(E) {
- alert(E);
- }
- }
- }
- }
- ],
+ 'retrieve_ids' : [],
+ 'stop_checkouts' : false,
+ 'check_stop_checkouts' : function() { return this.stop_checkouts; },
+
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ obj.barcode = params['barcode'];
+ obj.id = params['id'];
+
+ JSAN.use('OpenILS.data'); this.OpenILS = {};
+ obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
+
+ //var horizontal_interface = String( obj.OpenILS.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
+ //document.getElementById('ui.circ.patron_summary.horizontal').setAttribute('orient', horizontal_interface ? 'vertical' : 'horizontal');
+ //document.getElementById('pdms1').setAttribute('orient', horizontal_interface ? 'vertical' : 'horizontal');
+
+ JSAN.use('util.deck');
+ obj.right_deck = new util.deck('patron_right_deck');
+ obj.left_deck = new util.deck('patron_left_deck');
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert($("commonStrings").getString('common.unimplemented')); }
+ ],
+ 'cmd_patron_retrieve' : [
+ ['command'],
+ function(ev) {
+ if (typeof window.xulG == 'object' && typeof window.xulG.new_tab == 'function') {
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ try {
+ window.xulG.new_patron_tab(
+ {}, { 'id' : obj.retrieve_ids[i] }
+ );
+ } catch(E) {
+ alert(E);
+ }
+ }
+ }
+ }
+ ],
'cmd_patron_merge' : [
['command'],
function(ev) {
}
}
],
- 'cmd_search_form' : [
- ['command'],
- function(ev) {
- obj.controller.view.cmd_search_form.setAttribute('disabled','true');
- obj.left_deck.node.selectedIndex = 0;
- obj.controller.view.patron_name.setAttribute('value', $("patronStrings").getString('staff.patron.display.cmd_search_form.no_patron'));
- removeCSSClass(document.documentElement,'PATRON_HAS_BILLS');
- removeCSSClass(document.documentElement,'PATRON_HAS_OVERDUES');
- removeCSSClass(document.documentElement,'PATRON_HAS_NOTES');
- removeCSSClass(document.documentElement,'PATRON_EXCEEDS_CHECKOUT_COUNT');
- removeCSSClass(document.documentElement,'PATRON_EXCEEDS_OVERDUE_COUNT');
- removeCSSClass(document.documentElement,'PATRON_EXCEEDS_FINES');
- removeCSSClass(document.documentElement,'NO_PENALTIES');
- removeCSSClass(document.documentElement,'ONE_PENALTY');
- removeCSSClass(document.documentElement,'MULTIPLE_PENALTIES');
- removeCSSClass(document.documentElement,'PATRON_HAS_ALERT');
- removeCSSClass(document.documentElement,'PATRON_BARRED');
- removeCSSClass(document.documentElement,'PATRON_INACTIVE');
- removeCSSClass(document.documentElement,'PATRON_EXPIRED');
- removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_DOB');
- removeCSSClass(document.documentElement,'PATRON_JUVENILE');
- removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_ADDRESS');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_65');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_65');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_24');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_24');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_21');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_21');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_18');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_18');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_13');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_13');
- removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_1');
- removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_2');
- removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_3');
- }
- ],
- 'cmd_patron_refresh' : [
- ['command'],
- function(ev) {
+ 'cmd_search_form' : [
+ ['command'],
+ function(ev) {
+ obj.controller.view.cmd_search_form.setAttribute('disabled','true');
+ obj.left_deck.node.selectedIndex = 0;
+ obj.controller.view.patron_name.setAttribute('value', $("patronStrings").getString('staff.patron.display.cmd_search_form.no_patron'));
+ removeCSSClass(document.documentElement,'PATRON_HAS_BILLS');
+ removeCSSClass(document.documentElement,'PATRON_HAS_OVERDUES');
+ removeCSSClass(document.documentElement,'PATRON_HAS_NOTES');
+ removeCSSClass(document.documentElement,'PATRON_EXCEEDS_CHECKOUT_COUNT');
+ removeCSSClass(document.documentElement,'PATRON_EXCEEDS_OVERDUE_COUNT');
+ removeCSSClass(document.documentElement,'PATRON_EXCEEDS_FINES');
+ removeCSSClass(document.documentElement,'NO_PENALTIES');
+ removeCSSClass(document.documentElement,'ONE_PENALTY');
+ removeCSSClass(document.documentElement,'MULTIPLE_PENALTIES');
+ removeCSSClass(document.documentElement,'PATRON_HAS_ALERT');
+ removeCSSClass(document.documentElement,'PATRON_BARRED');
+ removeCSSClass(document.documentElement,'PATRON_INACTIVE');
+ removeCSSClass(document.documentElement,'PATRON_EXPIRED');
+ removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_DOB');
+ removeCSSClass(document.documentElement,'PATRON_JUVENILE');
+ removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_ADDRESS');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_65');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_65');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_24');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_24');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_21');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_21');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_18');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_18');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_13');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_13');
+ removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_1');
+ removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_2');
+ removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_3');
+ }
+ ],
+ 'cmd_patron_refresh' : [
+ ['command'],
+ function(ev) {
try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_refresh" ) ); } catch(E) {};
- obj.network.simple_request(
- 'RECALCULATE_STANDING_PENALTIES',
- [ ses(), obj.patron.id() ]
- );
- obj.refresh_all();
- }
- ],
- 'cmd_patron_checkout' : [
- ['command'],
+ obj.network.simple_request(
+ 'RECALCULATE_STANDING_PENALTIES',
+ [ ses(), obj.patron.id() ]
+ );
+ obj.refresh_all();
+ }
+ ],
+ 'cmd_patron_checkout' : [
+ ['command'],
function(ev) {
- obj.reset_nav_styling('cmd_patron_checkout');
+ obj.reset_nav_styling('cmd_patron_checkout');
obj.spawn_checkout_interface();
}
- ],
- 'cmd_patron_items' : [
- ['command'],
- function(ev) {
+ ],
+ 'cmd_patron_items' : [
+ ['command'],
+ function(ev) {
try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_items" ) ); } catch(E) {};
- obj.reset_nav_styling('cmd_patron_items');
- var frame = obj.right_deck.set_iframe(
- urls.XUL_PATRON_ITEMS,
- //+ '?patron_id=' + window.escape( obj.patron.id() ),
- {},
- {
- 'patron_id' : obj.patron.id(),
- 'on_list_change' : function(b) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.summary_window.g.summary.controller.render('patron_checkouts');
- obj.summary_window.g.summary.controller.render('patron_standing_penalties');
- obj.summary_window.g.summary.controller.render('patron_bill');
- obj.bill_window.g.bills.refresh(true);
- },
- 'url_prefix' : xulG.url_prefix,
- 'new_tab' : xulG.new_tab,
- 'new_patron_tab' : xulG.new_patron_tab
- }
- );
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.items_window = get_contentWindow(frame);
- }
- ],
- 'cmd_patron_edit' : [
- ['command'],
- function(ev) {
+ obj.reset_nav_styling('cmd_patron_items');
+ var frame = obj.right_deck.set_iframe(
+ urls.XUL_PATRON_ITEMS,
+ //+ '?patron_id=' + window.escape( obj.patron.id() ),
+ {},
+ {
+ 'patron_id' : obj.patron.id(),
+ 'on_list_change' : function(b) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.summary_window.g.summary.controller.render('patron_checkouts');
+ obj.summary_window.g.summary.controller.render('patron_standing_penalties');
+ obj.summary_window.g.summary.controller.render('patron_bill');
+ obj.bill_window.g.bills.refresh(true);
+ },
+ 'url_prefix' : xulG.url_prefix,
+ 'new_tab' : xulG.new_tab,
+ 'new_patron_tab' : xulG.new_patron_tab
+ }
+ );
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.items_window = get_contentWindow(frame);
+ }
+ ],
+ 'cmd_patron_edit' : [
+ ['command'],
+ function(ev) {
try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_edit" ) ); } catch(E) {};
- obj.reset_nav_styling('cmd_patron_edit');
-
- function spawn_search(s) {
- obj.error.sdump('D_TRACE', $("commonStrings").getFormattedString('staff.patron.display.cmd_patron_edit.edit_search', [js2JSON(s)]) );
- obj.OpenILS.data.stash_retrieve();
- xulG.new_patron_tab( {}, { 'doit' : 1, 'query' : s } );
- }
-
- function spawn_editor(p) {
- var url = urls.XUL_PATRON_EDIT;
- //var param_count = 0;
- //for (var i in p) {
- // if (param_count++ == 0) url += '?'; else url += '&';
- // url += i + '=' + window.escape(p[i]);
- //}
- var loc = xulG.url_prefix( urls.XUL_REMOTE_BROWSER ); // + '?url=' + window.escape( url );
- xulG.new_tab(
- loc,
- {},
- {
- 'url' : url,
- 'show_print_button' : true ,
- 'tab_name' : $("patronStrings").getString('staff.patron.display.spawn_editor.editing_related_patron'),
- 'passthru_content_params' : {
- 'spawn_search' : spawn_search,
- 'spawn_editor' : spawn_editor,
- 'url_prefix' : xulG.url_prefix,
- 'new_tab' : xulG.new_tab,
- 'new_patron_tab' : xulG.new_patron_tab,
- 'params' : p
- }
- }
- );
- }
-
- obj.right_deck.set_iframe(
- urls.XUL_REMOTE_BROWSER + '?patron_edit=1',
- //+ '?url=' + window.escape(
- // urls.XUL_PATRON_EDIT
- // + '?ses=' + window.escape( ses() )
- // + '&usr=' + window.escape( obj.patron.id() )
- //),
- {}, {
- 'url' : urls.XUL_PATRON_EDIT,
- 'show_print_button' : true,
- 'passthru_content_params' : {
- 'params' : {
- 'ses' : ses(),
- 'usr' : obj.patron.id()
- },
- 'on_save' : function(p) {
- try {
- if (obj.barcode) obj.barcode = p.card().barcode();
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- //obj.summary_window.g.summary.retrieve();
- obj.refresh_all();
- } catch(E) {
- alert(E);
- }
- },
- 'spawn_search' : spawn_search,
- 'spawn_editor' : spawn_editor,
- 'url_prefix' : xulG.url_prefix,
- 'new_tab' : xulG.new_tab,
- 'new_patron_tab' : xulG.new_patron_tab
- }
- }
- );
- }
- ],
+ obj.reset_nav_styling('cmd_patron_edit');
+
+ function spawn_search(s) {
+ obj.error.sdump('D_TRACE', $("commonStrings").getFormattedString('staff.patron.display.cmd_patron_edit.edit_search', [js2JSON(s)]) );
+ obj.OpenILS.data.stash_retrieve();
+ xulG.new_patron_tab( {}, { 'doit' : 1, 'query' : s } );
+ }
+
+ function spawn_editor(p) {
+ var url = urls.XUL_PATRON_EDIT;
+ //var param_count = 0;
+ //for (var i in p) {
+ // if (param_count++ == 0) url += '?'; else url += '&';
+ // url += i + '=' + window.escape(p[i]);
+ //}
+ var loc = xulG.url_prefix( urls.XUL_REMOTE_BROWSER ); // + '?url=' + window.escape( url );
+ xulG.new_tab(
+ loc,
+ {},
+ {
+ 'url' : url,
+ 'show_print_button' : true ,
+ 'tab_name' : $("patronStrings").getString('staff.patron.display.spawn_editor.editing_related_patron'),
+ 'passthru_content_params' : {
+ 'spawn_search' : spawn_search,
+ 'spawn_editor' : spawn_editor,
+ 'url_prefix' : xulG.url_prefix,
+ 'new_tab' : xulG.new_tab,
+ 'new_patron_tab' : xulG.new_patron_tab,
+ 'params' : p
+ }
+ }
+ );
+ }
+
+ obj.right_deck.set_iframe(
+ urls.XUL_REMOTE_BROWSER + '?patron_edit=1',
+ //+ '?url=' + window.escape(
+ // urls.XUL_PATRON_EDIT
+ // + '?ses=' + window.escape( ses() )
+ // + '&usr=' + window.escape( obj.patron.id() )
+ //),
+ {}, {
+ 'url' : urls.XUL_PATRON_EDIT,
+ 'show_print_button' : true,
+ 'passthru_content_params' : {
+ 'params' : {
+ 'ses' : ses(),
+ 'usr' : obj.patron.id()
+ },
+ 'on_save' : function(p) {
+ try {
+ if (obj.barcode) obj.barcode = p.card().barcode();
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ //obj.summary_window.g.summary.retrieve();
+ obj.refresh_all();
+ } catch(E) {
+ alert(E);
+ }
+ },
+ 'spawn_search' : spawn_search,
+ 'spawn_editor' : spawn_editor,
+ 'url_prefix' : xulG.url_prefix,
+ 'new_tab' : xulG.new_tab,
+ 'new_patron_tab' : xulG.new_patron_tab
+ }
+ }
+ );
+ }
+ ],
'cmd_patron_other' : [
- ['command'],
- function(ev) {
+ ['command'],
+ function(ev) {
try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_other" ) ); } catch(E) {};
- obj.reset_nav_styling('cmd_patron_other');
+ obj.reset_nav_styling('cmd_patron_other');
try { document.getElementById('PatronNavBar_other').firstChild.showPopup(); } catch(E) {};
}
],
- 'cmd_patron_info_notes' : [
- ['command'],
- function(ev) {
- obj.right_deck.set_iframe(
+ 'cmd_patron_info_notes' : [
+ ['command'],
+ function(ev) {
+ obj.right_deck.set_iframe(
urls.XUL_PATRON_INFO_NOTES,
- {},
- {
- 'patron_id' : obj.patron.id(),
- 'url_prefix' : xulG.url_prefix,
- 'new_tab' : xulG.new_tab,
- 'new_patron_tab' : xulG.new_patron_tab
- }
- );
- }
- ],
- 'cmd_patron_info_stats' : [
- ['command'],
- function(ev) {
- obj.right_deck.set_iframe(
+ {},
+ {
+ 'patron_id' : obj.patron.id(),
+ 'url_prefix' : xulG.url_prefix,
+ 'new_tab' : xulG.new_tab,
+ 'new_patron_tab' : xulG.new_patron_tab
+ }
+ );
+ }
+ ],
+ 'cmd_patron_info_stats' : [
+ ['command'],
+ function(ev) {
+ obj.right_deck.set_iframe(
urls.XUL_PATRON_INFO_STAT_CATS,
- {},
- {
- 'patron_id' : obj.patron.id(),
- 'url_prefix' : xulG.url_prefix,
- 'new_tab' : xulG.new_tab,
- 'new_patron_tab' : xulG.new_patron_tab
- }
- );
- }
- ],
- 'cmd_patron_info_surveys' : [
- ['command'],
- function(ev) {
- obj.right_deck.set_iframe(
+ {},
+ {
+ 'patron_id' : obj.patron.id(),
+ 'url_prefix' : xulG.url_prefix,
+ 'new_tab' : xulG.new_tab,
+ 'new_patron_tab' : xulG.new_patron_tab
+ }
+ );
+ }
+ ],
+ 'cmd_patron_info_surveys' : [
+ ['command'],
+ function(ev) {
+ obj.right_deck.set_iframe(
urls.XUL_PATRON_INFO_SURVEYS,
- {},
- {
- 'patron_id' : obj.patron.id(),
- 'url_prefix' : xulG.url_prefix,
- 'new_tab' : xulG.new_tab,
- 'new_patron_tab' : xulG.new_patron_tab
- }
- );
- }
- ],
- 'cmd_patron_info_groups' : [
- ['command'],
- function(ev) {
- obj.right_deck.set_iframe(
+ {},
+ {
+ 'patron_id' : obj.patron.id(),
+ 'url_prefix' : xulG.url_prefix,
+ 'new_tab' : xulG.new_tab,
+ 'new_patron_tab' : xulG.new_patron_tab
+ }
+ );
+ }
+ ],
+ 'cmd_patron_info_groups' : [
+ ['command'],
+ function(ev) {
+ obj.right_deck.set_iframe(
urls.XUL_PATRON_INFO_GROUP,
- {},
- {
- 'patron_id' : obj.patron.id(),
- 'url_prefix' : xulG.url_prefix,
- 'new_tab' : xulG.new_tab,
- 'new_patron_tab' : xulG.new_patron_tab
- }
- );
- }
- ],
+ {},
+ {
+ 'patron_id' : obj.patron.id(),
+ 'url_prefix' : xulG.url_prefix,
+ 'new_tab' : xulG.new_tab,
+ 'new_patron_tab' : xulG.new_patron_tab
+ }
+ );
+ }
+ ],
'cmd_patron_alert' : [
['command'],
function(ev) {
}
}
],
- 'cmd_patron_exit' : [
- ['command'],
- function(ev) {
- xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
- }
- ],
- 'cmd_patron_holds' : [
- ['command'],
- function(ev) {
+ 'cmd_patron_exit' : [
+ ['command'],
+ function(ev) {
+ xulG.set_tab(urls.XUL_PATRON_BARCODE_ENTRY,{},{});
+ }
+ ],
+ 'cmd_patron_holds' : [
+ ['command'],
+ function(ev) {
try {
try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_holds" ) ); } catch(E) {};
obj.reset_nav_styling('cmd_patron_holds');
obj.right_deck.set_iframe(
- urls.XUL_PATRON_HOLDS,
+ urls.XUL_PATRON_HOLDS,
//+ '?patron_id=' + window.escape( obj.patron.id() ),
{},
{
},
'url_prefix' : xulG.url_prefix,
'new_tab' : xulG.new_tab,
- 'new_patron_tab' : xulG.new_patron_tab
+ 'new_patron_tab' : xulG.new_patron_tab
}
);
} catch(E) {
alert(E);
}
- }
- ],
- 'cmd_patron_bills' : [
- ['command'],
- function(ev) {
+ }
+ ],
+ 'cmd_patron_bills' : [
+ ['command'],
+ function(ev) {
try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_bills" ) ); } catch(E) {};
- obj.reset_nav_styling('cmd_patron_bills');
- var f = obj.right_deck.set_iframe(
- urls.XUL_PATRON_BILLS,
- //+ '?patron_id=' + window.escape( obj.patron.id() ),
- {},
- {
+ obj.reset_nav_styling('cmd_patron_bills');
+ var f = obj.right_deck.set_iframe(
+ urls.XUL_PATRON_BILLS,
+ //+ '?patron_id=' + window.escape( obj.patron.id() ),
+ {},
+ {
'display_window' : window,
- 'patron_id' : obj.patron.id(),
- 'url_prefix' : xulG.url_prefix,
- 'on_money_change' : function(b) {
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.refresh_all();
- }
- }
- );
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.bill_window = get_contentWindow(f);
- }
- ],
- 'patron_name' : [
- ['render'],
- function(e) {
- return function() {
- JSAN.use('patron.util');
- e.setAttribute('value',
+ 'patron_id' : obj.patron.id(),
+ 'url_prefix' : xulG.url_prefix,
+ 'on_money_change' : function(b) {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.refresh_all();
+ }
+ }
+ );
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.bill_window = get_contentWindow(f);
+ }
+ ],
+ 'patron_name' : [
+ ['render'],
+ function(e) {
+ return function() {
+ JSAN.use('patron.util');
+ e.setAttribute('value',
patron.util.format_name( obj.patron )
- );
+ );
patron.util.set_penalty_css(obj.patron);
- };
- }
- ],
- 'PatronNavBar' : [
- ['render'],
- function(e) {
- return function() {}
- }
- ],
+ };
+ }
+ ],
+ 'PatronNavBar' : [
+ ['render'],
+ function(e) {
+ return function() {}
+ }
+ ],
'cmd_verify_credentials' : [
['command'],
function() {
function() {
function penalty_interface() {
try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible( document.getElementById("PatronNavBar_messages" ) ); } catch(E) {};
- obj.reset_nav_styling('cmd_standing_penalties');
+ obj.reset_nav_styling('cmd_standing_penalties');
return obj.right_deck.set_iframe(
urls.XUL_STANDING_PENALTIES,
{},
penalty_interface();
}
]
- }
- }
- );
+ }
+ }
+ );
var x = document.getElementById("PatronNavBar_checkout");
x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
var x = document.getElementById("PatronNavBar_messages");
x.addEventListener( 'focus', function(xx) { return function() { try { document.getElementById("PatronNavBarScrollbox").ensureElementIsVisible(xx); } catch(E) {}; } }(x), false);
- if (obj.barcode || obj.id) {
- if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
- try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.display.init.retrieving_patron')); } catch(E) { alert(E); }
- }
-
- obj.controller.view.PatronNavBar.selectedIndex = 1;
- JSAN.use('util.widgets');
- util.widgets.enable_accesskeys_in_node_and_children(
- obj.controller.view.PatronNavBar.lastChild
- );
- util.widgets.disable_accesskeys_in_node_and_children(
- obj.controller.view.PatronNavBar.firstChild
- );
- obj.controller.view.cmd_patron_refresh.setAttribute('disabled','true');
- obj.controller.view.cmd_patron_checkout.setAttribute('disabled','true');
- obj.controller.view.cmd_patron_items.setAttribute('disabled','true');
- obj.controller.view.cmd_patron_holds.setAttribute('disabled','true');
- obj.controller.view.cmd_patron_bills.setAttribute('disabled','true');
- obj.controller.view.cmd_patron_edit.setAttribute('disabled','true');
- obj.controller.view.patron_name.setAttribute('value', $("patronStrings").getString('staff.patron.display.init.retrieving'));
- document.documentElement.setAttribute('class','');
- var frame = obj.left_deck.set_iframe(
- urls.XUL_PATRON_SUMMARY,
- {},
- {
+ if (obj.barcode || obj.id) {
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.display.init.retrieving_patron')); } catch(E) { alert(E); }
+ }
+
+ obj.controller.view.PatronNavBar.selectedIndex = 1;
+ JSAN.use('util.widgets');
+ util.widgets.enable_accesskeys_in_node_and_children(
+ obj.controller.view.PatronNavBar.lastChild
+ );
+ util.widgets.disable_accesskeys_in_node_and_children(
+ obj.controller.view.PatronNavBar.firstChild
+ );
+ obj.controller.view.cmd_patron_refresh.setAttribute('disabled','true');
+ obj.controller.view.cmd_patron_checkout.setAttribute('disabled','true');
+ obj.controller.view.cmd_patron_items.setAttribute('disabled','true');
+ obj.controller.view.cmd_patron_holds.setAttribute('disabled','true');
+ obj.controller.view.cmd_patron_bills.setAttribute('disabled','true');
+ obj.controller.view.cmd_patron_edit.setAttribute('disabled','true');
+ obj.controller.view.patron_name.setAttribute('value', $("patronStrings").getString('staff.patron.display.init.retrieving'));
+ document.documentElement.setAttribute('class','');
+ var frame = obj.left_deck.set_iframe(
+ urls.XUL_PATRON_SUMMARY,
+ {},
+ {
'display_window' : window,
- 'barcode' : obj.barcode,
- 'id' : obj.id,
+ 'barcode' : obj.barcode,
+ 'id' : obj.id,
'refresh' : function() { obj.refresh_all(); },
- 'on_finished' : obj.gen_patron_summary_finish_func(),
+ 'on_finished' : obj.gen_patron_summary_finish_func(),
'stop_sign_page' : obj.gen_patron_stop_sign_page_func(),
- 'on_error' : function(E) {
- try {
- var error;
- if (typeof E.ilsevent != 'undefined') {
- error = E.textcode;
- } else {
- error = js2JSON(E).substr(0,100);
- }
- location.href = urls.XUL_PATRON_BARCODE_ENTRY + '?error=' + window.escape(error);
- } catch(F) {
- alert(F);
- }
- }
- }
- );
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.summary_window = get_contentWindow(frame);
- } else {
- obj.render_search_form(params);
- }
- },
-
- 'reset_nav_styling' : function(btn,dont_hide_summary) {
+ 'on_error' : function(E) {
+ try {
+ var error;
+ if (typeof E.ilsevent != 'undefined') {
+ error = E.textcode;
+ } else {
+ error = js2JSON(E).substr(0,100);
+ }
+ location.href = urls.XUL_PATRON_BARCODE_ENTRY + '?error=' + window.escape(error);
+ } catch(F) {
+ alert(F);
+ }
+ }
+ }
+ );
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.summary_window = get_contentWindow(frame);
+ } else {
+ obj.render_search_form(params);
+ }
+ },
+
+ 'reset_nav_styling' : function(btn,dont_hide_summary) {
try {
this.controller.view.cmd_patron_checkout.setAttribute('style','');
this.controller.view.cmd_patron_items.setAttribute('style','');
} catch(E) {
alert(E);
}
- },
-
- 'render_search_form' : function(params) {
- var obj = this;
- if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
- try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.display.render_search_form.patron_search')); } catch(E) { alert(E); }
- }
-
- obj.controller.view.PatronNavBar.selectedIndex = 0;
- obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','true');
- obj.controller.view.cmd_patron_merge.setAttribute('disabled','true');
- obj.controller.view.cmd_search_form.setAttribute('disabled','true');
-
- var horizontal_interface = String( obj.OpenILS.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
- var loc = horizontal_interface ? urls.XUL_PATRON_HORIZONTAL_SEARCH_FORM : urls.XUL_PATRON_SEARCH_FORM;
- var my_xulG = {
- 'clear_left_deck' : function() {
- setTimeout( function() {
- obj.left_deck.clear_all_except(loc);
- obj.render_search_form(params);
- }, 0);
- },
- 'on_submit' : function(query,search_limit,search_sort) {
- obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','true');
- obj.controller.view.cmd_patron_merge.setAttribute('disabled','true');
- var list_frame = obj.right_deck.reset_iframe(
- urls.XUL_PATRON_SEARCH_RESULT, // + '?' + query,
- {},
- {
- 'query' : query,
- 'search_limit' : search_limit,
- 'search_sort' : search_sort,
- 'on_select' : function(list) {
- if (!list) return;
- if (list.length < 1) return;
- obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','false');
- if (list.length > 1) obj.controller.view.cmd_patron_merge.setAttribute('disabled','false');
- obj.controller.view.cmd_search_form.setAttribute('disabled','false');
- obj.retrieve_ids = list;
- obj.controller.view.patron_name.setAttribute('value',$("patronStrings").getString('staff.patron.display.init.retrieving'));
- document.documentElement.setAttribute('class','');
- setTimeout(
- function() {
- var frame = obj.left_deck.set_iframe(
- urls.XUL_PATRON_SUMMARY + '?id=' + window.escape(list[0]),
- {},
- {
- //'id' : list[0],
- 'on_finished' : function(patron) {
- obj.patron = patron;
- obj.controller.render();
- }
- }
- );
- netscape.security.PrivilegeManager.enablePrivilege(
- "UniversalXPConnect"
- );
- obj.summary_window = get_contentWindow(frame);
- obj.patron = obj.summary_window.g.summary.patron;
- obj.controller.render('patron_name');
- }, 0
- );
- }
- }
- );
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.search_result = get_contentWindow(list_frame);
- }
- };
-
- if (params['query']) {
- my_xulG.query = JSON2js(params['query']);
- if (params.doit) my_xulG.doit = 1;
- }
-
- var form_frame = obj.left_deck.set_iframe(
- loc,
- {},
- my_xulG
- );
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- obj.search_window = get_contentWindow(form_frame);
- obj._checkout_spawned = true;
- },
-
- '_checkout_spawned' : false,
-
- 'refresh_deck' : function(url) {
- var obj = this;
- netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- for (var i = 0; i < obj.right_deck.node.childNodes.length; i++) {
- try {
- var f = obj.right_deck.node.childNodes[i];
- var w = get_contentWindow(f);
- if (url) {
- if (w.location.href == url) w.refresh(true);
- } else {
- if (typeof w.refresh == 'function') {
- w.refresh(true);
- }
- }
-
- } catch(E) {
- obj.error.sdump('D_ERROR','refresh_deck: ' + E + '\n');
- }
- }
- },
-
- 'refresh_all' : function() {
- var obj = this;
- obj.controller.view.patron_name.setAttribute('value', $("patronStrings").getString('staff.patron.display.init.retrieving'));
- document.documentElement.setAttribute('class','');
- try { obj.summary_window.refresh(); } catch(E) { obj.error.sdump('D_ERROR', E + '\n'); }
- try { obj.refresh_deck(); } catch(E) { obj.error.sdump('D_ERROR', E + '\n'); }
- },
+ },
+
+ 'render_search_form' : function(params) {
+ var obj = this;
+ if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
+ try { window.xulG.set_tab_name($("patronStrings").getString('staff.patron.display.render_search_form.patron_search')); } catch(E) { alert(E); }
+ }
+
+ obj.controller.view.PatronNavBar.selectedIndex = 0;
+ obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','true');
+ obj.controller.view.cmd_patron_merge.setAttribute('disabled','true');
+ obj.controller.view.cmd_search_form.setAttribute('disabled','true');
+
+ var horizontal_interface = String( obj.OpenILS.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
+ var loc = horizontal_interface ? urls.XUL_PATRON_HORIZONTAL_SEARCH_FORM : urls.XUL_PATRON_SEARCH_FORM;
+ var my_xulG = {
+ 'clear_left_deck' : function() {
+ setTimeout( function() {
+ obj.left_deck.clear_all_except(loc);
+ obj.render_search_form(params);
+ }, 0);
+ },
+ 'on_submit' : function(query,search_limit,search_sort) {
+ obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','true');
+ obj.controller.view.cmd_patron_merge.setAttribute('disabled','true');
+ var list_frame = obj.right_deck.reset_iframe(
+ urls.XUL_PATRON_SEARCH_RESULT, // + '?' + query,
+ {},
+ {
+ 'query' : query,
+ 'search_limit' : search_limit,
+ 'search_sort' : search_sort,
+ 'on_select' : function(list) {
+ if (!list) return;
+ if (list.length < 1) return;
+ obj.controller.view.cmd_patron_retrieve.setAttribute('disabled','false');
+ if (list.length > 1) obj.controller.view.cmd_patron_merge.setAttribute('disabled','false');
+ obj.controller.view.cmd_search_form.setAttribute('disabled','false');
+ obj.retrieve_ids = list;
+ obj.controller.view.patron_name.setAttribute('value',$("patronStrings").getString('staff.patron.display.init.retrieving'));
+ document.documentElement.setAttribute('class','');
+ setTimeout(
+ function() {
+ var frame = obj.left_deck.set_iframe(
+ urls.XUL_PATRON_SUMMARY + '?id=' + window.escape(list[0]),
+ {},
+ {
+ //'id' : list[0],
+ 'on_finished' : function(patron) {
+ obj.patron = patron;
+ obj.controller.render();
+ }
+ }
+ );
+ netscape.security.PrivilegeManager.enablePrivilege(
+ "UniversalXPConnect"
+ );
+ obj.summary_window = get_contentWindow(frame);
+ obj.patron = obj.summary_window.g.summary.patron;
+ obj.controller.render('patron_name');
+ }, 0
+ );
+ }
+ }
+ );
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.search_result = get_contentWindow(list_frame);
+ }
+ };
+
+ if (params['query']) {
+ my_xulG.query = JSON2js(params['query']);
+ if (params.doit) my_xulG.doit = 1;
+ }
+
+ var form_frame = obj.left_deck.set_iframe(
+ loc,
+ {},
+ my_xulG
+ );
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ obj.search_window = get_contentWindow(form_frame);
+ obj._checkout_spawned = true;
+ },
+
+ '_checkout_spawned' : false,
+
+ 'refresh_deck' : function(url) {
+ var obj = this;
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ for (var i = 0; i < obj.right_deck.node.childNodes.length; i++) {
+ try {
+ var f = obj.right_deck.node.childNodes[i];
+ var w = get_contentWindow(f);
+ if (url) {
+ if (w.location.href == url) w.refresh(true);
+ } else {
+ if (typeof w.refresh == 'function') {
+ w.refresh(true);
+ }
+ }
+
+ } catch(E) {
+ obj.error.sdump('D_ERROR','refresh_deck: ' + E + '\n');
+ }
+ }
+ },
+
+ 'refresh_all' : function() {
+ var obj = this;
+ obj.controller.view.patron_name.setAttribute('value', $("patronStrings").getString('staff.patron.display.init.retrieving'));
+ document.documentElement.setAttribute('class','');
+ try { obj.summary_window.refresh(); } catch(E) { obj.error.sdump('D_ERROR', E + '\n'); }
+ try { obj.refresh_deck(); } catch(E) { obj.error.sdump('D_ERROR', E + '\n'); }
+ },
'spawn_checkout_interface' : function() {
var obj = this;
JSAN.errorLevel = "die"; // none, warn, or die
JSAN.addRepository('..');
- JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+ JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
JSAN.use('util.error'); error = new util.error();
JSAN.use('util.widgets');
JSAN.errorLevel = "die"; // none, warn, or die
JSAN.addRepository('..');
- JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+ JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
JSAN.use('util.error'); error = new util.error();
JSAN.use('util.widgets');
if (typeof patron == 'undefined') patron = {};
patron.holds = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
}
patron.holds.prototype = {
'current' : { 'limit' : 50, 'offset' : 0 }
},
- 'filter_lib' : null,
+ 'filter_lib' : null,
- 'retrieve_ids' : [],
+ 'retrieve_ids' : [],
- 'holds_map' : {},
+ 'holds_map' : {},
'flatten_copy' : function(hold) {
try { if ( hold.current_copy() && typeof hold.current_copy() == 'object') hold.current_copy( hold.current_copy().id() ); } catch(E) { alert('FIXME: Error flattening hold before hold update: ' + E); }
return hold;
},
- 'init' : function( params ) {
+ 'init' : function( params ) {
- var obj = this;
+ var obj = this;
- obj.patron_id = params['patron_id'];
- obj.patron_barcode = params['patron_barcode'];
- obj.docid = params['docid'];
- obj.shelf = params['shelf'];
- obj.tree_id = params['tree_id'];
+ obj.patron_id = params['patron_id'];
+ obj.patron_barcode = params['patron_barcode'];
+ obj.docid = params['docid'];
+ obj.shelf = params['shelf'];
+ obj.tree_id = params['tree_id'];
- JSAN.use('circ.util');
- var columns = circ.util.hold_columns(
- {
- 'title' : { 'hidden' : false, 'flex' : '3' },
- 'request_time' : { 'hidden' : false },
- 'pickup_lib_shortname' : { 'hidden' : false },
- 'hold_type' : { 'hidden' : false },
- 'current_copy' : { 'hidden' : false },
- 'capture_time' : { 'hidden' : false },
- 'notify_time' : { 'hidden' : false },
- 'notify_count' : { 'hidden' : false }
- }
- );
+ JSAN.use('circ.util');
+ var columns = circ.util.hold_columns(
+ {
+ 'title' : { 'hidden' : false, 'flex' : '3' },
+ 'request_time' : { 'hidden' : false },
+ 'pickup_lib_shortname' : { 'hidden' : false },
+ 'hold_type' : { 'hidden' : false },
+ 'current_copy' : { 'hidden' : false },
+ 'capture_time' : { 'hidden' : false },
+ 'notify_time' : { 'hidden' : false },
+ 'notify_count' : { 'hidden' : false }
+ }
+ );
- JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
- 'retrieve_row' : function(params) {
- var row = params.row;
- try {
- obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
- function(blob_req) {
- try {
- var blob = blob_req.getResultObject();
- if (typeof blob.ilsevent != 'undefined') throw(blob);
- row.my.ahr = blob.hold;
- row.my.status = blob.status;
+ JSAN.use('util.list'); obj.list = new util.list( obj.tree_id || 'holds_list');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'retrieve_row' : function(params) {
+ var row = params.row;
+ try {
+ obj.network.simple_request('FM_AHR_BLOB_RETRIEVE.authoritative', [ ses(), row.my.hold_id ],
+ function(blob_req) {
+ try {
+ var blob = blob_req.getResultObject();
+ if (typeof blob.ilsevent != 'undefined') throw(blob);
+ row.my.ahr = blob.hold;
+ row.my.status = blob.status;
row.my.ahr.status( blob.status );
- row.my.acp = blob.copy;
- row.my.acn = blob.volume;
- row.my.mvr = blob.mvr;
- row.my.patron_family_name = blob.patron_last;
- row.my.patron_first_given_name = blob.patron_first;
- row.my.patron_barcode = blob.patron_barcode;
+ row.my.acp = blob.copy;
+ row.my.acn = blob.volume;
+ row.my.mvr = blob.mvr;
+ row.my.patron_family_name = blob.patron_last;
+ row.my.patron_first_given_name = blob.patron_first;
+ row.my.patron_barcode = blob.patron_barcode;
row.my.total_holds = blob.total_holds;
row.my.queue_position = blob.queue_position;
row.my.potential_copies = blob.potential_copies;
row.my.estimated_wait = blob.estimated_wait;
row.my.ahrn_count = blob.hold.notes().length;
- var copy_id = row.my.ahr.current_copy();
- if (typeof copy_id == 'object') {
- if (copy_id == null) {
- if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
- } else {
- copy_id = copy_id.id();
- }
- } else {
- copy_id = row.my.acp.id();
- }
+ var copy_id = row.my.ahr.current_copy();
+ if (typeof copy_id == 'object') {
+ if (copy_id == null) {
+ if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
+ } else {
+ copy_id = copy_id.id();
+ }
+ } else {
+ copy_id = row.my.acp.id();
+ }
- obj.holds_map[ row.my.ahr.id() ] = blob;
- params.row_node.setAttribute('retrieve_id',
- js2JSON({
- 'copy_id':copy_id,
+ obj.holds_map[ row.my.ahr.id() ] = blob;
+ params.row_node.setAttribute('retrieve_id',
+ js2JSON({
+ 'copy_id':copy_id,
'barcode':row.my.acp ? row.my.acp.barcode() : null,
- 'id':row.my.ahr.id(),
- 'type':row.my.ahr.hold_type(),
- 'target':row.my.ahr.target(),
- 'usr':row.my.ahr.usr()
- })
- );
- if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
+ 'id':row.my.ahr.id(),
+ 'type':row.my.ahr.hold_type(),
+ 'target':row.my.ahr.target(),
+ 'usr':row.my.ahr.usr()
+ })
+ );
+ if (typeof params.on_retrieve == 'function') { params.on_retrieve(row); }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
- }
- }
- );
- } catch(E) {
- obj.error.sdump('D_ERROR','retrieve_row: ' + E );
- }
- return row;
- },
- 'on_select' : function(ev) {
- JSAN.use('util.functional');
- var sel = obj.list.retrieve_selection();
- obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
- obj.retrieve_ids = util.functional.map_list(
- sel,
- function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
- );
- if (obj.retrieve_ids.length > 0) {
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
- obj.controller.view.sel_copy_details.setAttribute('disabled','false');
- obj.controller.view.sel_patron.setAttribute('disabled','false');
- obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
- obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
- obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
- obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
- } else {
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
- obj.controller.view.sel_copy_details.setAttribute('disabled','true');
- obj.controller.view.sel_patron.setAttribute('disabled','true');
- obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
- obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
- obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
- }
- }
- }
- );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.init.hold_num_error', [row.my.hold_id]), E);
+ }
+ }
+ );
+ } catch(E) {
+ obj.error.sdump('D_ERROR','retrieve_row: ' + E );
+ }
+ return row;
+ },
+ 'on_select' : function(ev) {
+ JSAN.use('util.functional');
+ var sel = obj.list.retrieve_selection();
+ obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
+ obj.retrieve_ids = util.functional.map_list(
+ sel,
+ function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
+ );
+ if (obj.retrieve_ids.length > 0) {
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','false');
+ obj.controller.view.sel_patron.setAttribute('disabled','false');
+ obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_activate.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_suspend.setAttribute('disabled','false');
+ obj.controller.view.cmd_alt_view.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_retarget.setAttribute('disabled','false');
+ obj.controller.view.cmd_holds_cancel.setAttribute('disabled','false');
+ obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
+ } else {
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','true');
+ obj.controller.view.sel_patron.setAttribute('disabled','true');
+ obj.controller.view.cmd_retrieve_patron.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_edit_expire_time.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
+ obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_cancel.setAttribute('disabled','true');
+ obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
+ }
+ }
+ }
+ );
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
- 'sel_clip' : [
- ['command'],
- function() { obj.list.clipboard(); }
- ],
- 'cmd_broken' : [
- ['command'],
- function() { alert($("commonStrings").getString('common.unimplemented')); }
- ],
- 'sel_patron' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- circ.util.show_last_few_circs(obj.retrieve_ids);
- }
- ],
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
+ 'sel_clip' : [
+ ['command'],
+ function() { obj.list.clipboard(); }
+ ],
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert($("commonStrings").getString('common.unimplemented')); }
+ ],
+ 'sel_patron' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ circ.util.show_last_few_circs(obj.retrieve_ids);
+ }
+ ],
'alt_view_btn' : [
['render'],
function(e) {
}
},
],
- 'sel_mark_items_damaged' : [
- ['command'],
- function() {
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_mark_items_missing' : [
- ['command'],
- function() {
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_copy_details' : [
- ['command'],
- function() {
- JSAN.use('circ.util');
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- if (obj.retrieve_ids[i].copy_id) circ.util.show_copy_details( obj.retrieve_ids[i].copy_id );
- }
- }
- ],
+ 'sel_mark_items_damaged' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_mark_items_missing' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_copy_details' : [
+ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ if (obj.retrieve_ids[i].copy_id) circ.util.show_copy_details( obj.retrieve_ids[i].copy_id );
+ }
+ }
+ ],
'cmd_holds_print' : [
- ['command'],
- function() {
- try {
- JSAN.use('patron.util');
- var params = {
- 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
- 'template' : 'holds'
- };
- obj.list.print(params);
- } catch(E) {
- obj.error.standard_unexpected_error_alert('print 1',E);
- }
- }
- ],
+ ['command'],
+ function() {
+ try {
+ JSAN.use('patron.util');
+ var params = {
+ 'patron' : patron.util.retrieve_au_via_id(ses(),obj.patron_id),
+ 'template' : 'holds'
+ };
+ obj.list.print(params);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('print 1',E);
+ }
+ }
+ ],
'cmd_csv_to_clipboard' : [ ['command'], function() { obj.list.dump_csv_to_clipboard(); } ],
- 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
- 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
+ 'cmd_csv_to_printer' : [ ['command'], function() { obj.list.dump_csv_to_printer(); } ],
+ 'cmd_csv_to_file' : [ ['command'], function() { obj.list.dump_csv_to_file( { 'defaultFileName' : 'holds.txt' } ); } ],
- 'cmd_holds_edit_selection_depth' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.widgets'); JSAN.use('util.functional');
- var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
- var list = util.functional.map_list(
- util.functional.filter_list(
- obj.data.list.aout,
- function(o) {
- if (o.depth() > ws_type.depth()) return false;
- if (o.depth() < ws_type.depth()) return true;
- return (o.id() == ws_type.id());
- }
- ),
- function(o) {
- return [
- o.opac_label(),
- o.id(),
- false,
- ( o.depth() * 2),
- ];
- }
- );
- ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
- ml.setAttribute('id','selection');
- ml.setAttribute('name','fancy_data');
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
- xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
- xml += util.widgets.serialize_node(ml);
- xml += '</vbox>';
- var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
- bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
- bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
- bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
- bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
- //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_mid'
- //+ '&bottom_xml_in_stash=temp_bot'
- //+ '&title=' + window.escape('Choose a Pick Up Library'),
- 'fancy_prompt', 'chrome,resizable,modal',
- { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
- );
- if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
- var selection = fancy_prompt_data.selection;
+ 'cmd_holds_edit_selection_depth' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
+ var ws_type = obj.data.hash.aout[ obj.data.hash.aou[ obj.data.list.au[0].ws_ou() ].ou_type() ];
+ var list = util.functional.map_list(
+ util.functional.filter_list(
+ obj.data.list.aout,
+ function(o) {
+ if (o.depth() > ws_type.depth()) return false;
+ if (o.depth() < ws_type.depth()) return true;
+ return (o.id() == ws_type.id());
+ }
+ ),
+ function(o) {
+ return [
+ o.opac_label(),
+ o.id(),
+ false,
+ ( o.depth() * 2),
+ ];
+ }
+ );
+ ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
+ ml.setAttribute('id','selection');
+ ml.setAttribute('name','fancy_data');
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+ xml += '<description>' + $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_hold_range') + '</description>';
+ xml += util.widgets.serialize_node(ml);
+ xml += '</vbox>';
+ var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+ bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.label') +'"';
+ bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.done.accesskey') +'" name="fancy_submit"/>';
+ bot_xml += '<button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.label') +'"';
+ bot_xml += 'accesskey="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.cancel.accesskey') +'" name="fancy_cancel"/></hbox>';
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
+ //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_mid'
+ //+ '&bottom_xml_in_stash=temp_bot'
+ //+ '&title=' + window.escape('Choose a Pick Up Library'),
+ 'fancy_prompt', 'chrome,resizable,modal',
+ { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.choose_library') }
+ );
+ if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
+ var selection = fancy_prompt_data.selection;
- var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var msg = '';
- if(obj.retrieve_ids.length > 1) {
- msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list, obj.data.hash.aout[selection].opac_label()])
- } else {
- msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list, obj.data.hash.aout[selection].opac_label()])
- }
+ var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;}).join(', ');
+ var msg = '';
+ if(obj.retrieve_ids.length > 1) {
+ msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.plural', [hold_list, obj.data.hash.aout[selection].opac_label()])
+ } else {
+ msg = $("patronStrings").getformattedString('staff.patron.holds.holds_edit_selection_depth.modify_holds_message.singular', [hold_list, obj.data.hash.aout[selection].opac_label()])
+ }
- var r = obj.error.yns_alert(msg,
- $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
- $("commonStrings").getString('common.yes'),
- $("commonStrings").getString('common.no'),
- null,
- $("commonStrings").getString('common.check_to_confirm')
- );
- if (r == 0) {
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
- hold.selection_depth( obj.data.hash.aout[selection].depth() ); hold.ischanged('1');
+ var r = obj.error.yns_alert(msg,
+ $("patronStrings").getString('staff.patron.holds.holds_edit_selection_depth.modify_holds_title'),
+ $("commonStrings").getString('common.yes'),
+ $("commonStrings").getString('common.no'),
+ null,
+ $("commonStrings").getString('common.check_to_confirm')
+ );
+ if (r == 0) {
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
+ hold.selection_depth( obj.data.hash.aout[selection].depth() ); hold.ischanged('1');
hold = obj.flatten_copy(hold);
- var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- }
- obj.clear_and_retrieve(true);
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
- }
- }
- ],
+ var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ }
+ obj.clear_and_retrieve(true);
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
+ }
+ }
+ ],
- 'cmd_holds_edit_pickup_lib' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.widgets'); JSAN.use('util.functional');
+ 'cmd_holds_edit_pickup_lib' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.widgets'); JSAN.use('util.functional');
var deny_edit_because_of_transit = false;
for (var i = 0; i < obj.retrieve_ids.length; i++) {
return;
}
- var list = util.functional.map_list(
- obj.data.list.aou,
- function(o) {
- var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
- return [
- o.name() ? sname + ' ' + o.name() : o.shortname(),
- o.id(),
- ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
- ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
- ];
- }
- );
- ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
- ml.setAttribute('id','lib');
- ml.setAttribute('name','fancy_data');
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
- xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
- xml += util.widgets.serialize_node(ml);
- xml += '</vbox>';
- var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
- bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
- bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
- bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
- bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
- //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_mid'
- //+ '&bottom_xml_in_stash=temp_bot'
- //+ '&title=' + window.escape('Choose a Pick Up Library'),
- 'fancy_prompt', 'chrome,resizable,modal',
- { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
- );
- if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
- var pickup_lib = fancy_prompt_data.lib;
+ var list = util.functional.map_list(
+ obj.data.list.aou,
+ function(o) {
+ var sname = o.shortname(); for (i = sname.length; i < 20; i++) sname += ' ';
+ return [
+ o.name() ? sname + ' ' + o.name() : o.shortname(),
+ o.id(),
+ ( obj.data.hash.aout[ o.ou_type() ].can_have_users() == 0),
+ ( obj.data.hash.aout[ o.ou_type() ].depth() * 2),
+ ];
+ }
+ );
+ ml = util.widgets.make_menulist( list, obj.data.list.au[0].ws_ou() );
+ ml.setAttribute('id','lib');
+ ml.setAttribute('name','fancy_data');
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+ xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.new_pickup_lib.description')+'</description>';
+ xml += util.widgets.serialize_node(ml);
+ xml += '</vbox>';
+ var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+ bot_xml += '<spacer flex="1"/><button label="'+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.label') +'"';
+ bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.done.accesskey')+'" name="fancy_submit"/>';
+ bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.label')+'"';
+ bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
+ //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_mid'
+ //+ '&bottom_xml_in_stash=temp_bot'
+ //+ '&title=' + window.escape('Choose a Pick Up Library'),
+ 'fancy_prompt', 'chrome,resizable,modal',
+ { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.choose_lib') }
+ );
+ if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
+ var pickup_lib = fancy_prompt_data.lib;
- var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var msg = '';
- if(obj.retrieve_ids.length > 1) {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.plural',[hold_list, obj.data.hash.aou[pickup_lib].shortname()]);
- } else {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.singular',[hold_list, obj.data.hash.aou[pickup_lib].shortname()]);
- }
- var r = obj.error.yns_alert(msg,
- $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
- $("commonStrings").getString('common.yes'),
- $("commonStrings").getString('common.no'),
- null,
- $("commonStrings").getString('common.check_to_confirm')
- );
- if (r == 0) {
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
- hold.pickup_lib( pickup_lib ); hold.ischanged('1');
+ var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;}).join(', ');
+ var msg = '';
+ if(obj.retrieve_ids.length > 1) {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.plural',[hold_list, obj.data.hash.aou[pickup_lib].shortname()]);
+ } else {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_message.singular',[hold_list, obj.data.hash.aou[pickup_lib].shortname()]);
+ }
+ var r = obj.error.yns_alert(msg,
+ $("patronStrings").getString('staff.patron.holds.holds_edit_pickup_lib.change_pickup_lib_title'),
+ $("commonStrings").getString('common.yes'),
+ $("commonStrings").getString('common.no'),
+ null,
+ $("commonStrings").getString('common.check_to_confirm')
+ );
+ if (r == 0) {
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
+ hold.pickup_lib( pickup_lib ); hold.ischanged('1');
hold = obj.flatten_copy(hold);
- var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- }
- obj.clear_and_retrieve(true);
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
- }
- }
- ],
- 'cmd_holds_edit_phone_notify' : [
- ['command'],
- function() {
- try {
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
- xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
- xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
- xml += '</vbox>';
- var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
- bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
- bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
- bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
- bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
- //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_mid'
- //+ '&bottom_xml_in_stash=temp_bot'
- //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
- //+ '&focus=phone',
- 'fancy_prompt', 'chrome,resizable,modal',
- { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
- );
- if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
- var phone = fancy_prompt_data.phone;
+ var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ }
+ obj.clear_and_retrieve(true);
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
+ }
+ }
+ ],
+ 'cmd_holds_edit_phone_notify' : [
+ ['command'],
+ function() {
+ try {
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+ xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.new_phone_number')+'</description>';
+ xml += '<textbox id="phone" name="fancy_data" context="clipboard"/>';
+ xml += '</vbox>';
+ var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+ bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.label')+'"';
+ bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_done.accesskey')+'" name="fancy_submit"/>';
+ bot_xml += '<button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.label')+'"';
+ bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
+ //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_mid'
+ //+ '&bottom_xml_in_stash=temp_bot'
+ //+ '&title=' + window.escape('Choose a Hold Notification Phone Number')
+ //+ '&focus=phone',
+ 'fancy_prompt', 'chrome,resizable,modal',
+ { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.choose_phone_number'), 'focus' : 'phone' }
+ );
+ if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
+ var phone = fancy_prompt_data.phone;
- var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var msg = '';
- if(obj.retrieve_ids.length > 1) {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list, phone]);
- } else {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list, phone]);
- }
- var r = obj.error.yns_alert(msg,
- $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
- $("commonStrings").getString('common.yes'),
- $("commonStrings").getString('common.no'),
- null,
- $("commonStrings").getString('common.check_to_confirm')
- );
- if (r == 0) {
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
- hold.phone_notify( phone ); hold.ischanged('1');
+ var hold_list = util.functional.map_list(obj.retrieve_ids, function(o){return o.id;}).join(', ');
+ var msg = '';
+ if(obj.retrieve_ids.length > 1) {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.plural',[hold_list, phone]);
+ } else {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_phone_notify.confirm_phone_number_change.singular',[hold_list, phone]);
+ }
+ var r = obj.error.yns_alert(msg,
+ $("patronStrings").getString('staff.patron.holds.holds_edit_phone_notify.modifying_holds_title'),
+ $("commonStrings").getString('common.yes'),
+ $("commonStrings").getString('common.no'),
+ null,
+ $("commonStrings").getString('common.check_to_confirm')
+ );
+ if (r == 0) {
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
+ hold.phone_notify( phone ); hold.ischanged('1');
hold = obj.flatten_copy(hold);
- var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- }
- obj.clear_and_retrieve(true);
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
- }
- }
- ],
- 'cmd_holds_edit_email_notify' : [
- ['command'],
- function() {
- try {
- var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
- xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
- xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
- xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
- xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
- xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
- xml += '</vbox>';
- var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
- bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
- bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
- //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
- //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
- JSAN.use('util.window'); var win = new util.window();
- var fancy_prompt_data = win.open(
- urls.XUL_FANCY_PROMPT,
- //+ '?xml_in_stash=temp_mid'
- //+ '&bottom_xml_in_stash=temp_bot'
- //+ '&title=' + window.escape('Set Email Notification for Holds'),
- 'fancy_prompt', 'chrome,resizable,modal',
- { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
- );
- if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
- var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
+ var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ }
+ obj.clear_and_retrieve(true);
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
+ }
+ }
+ ],
+ 'cmd_holds_edit_email_notify' : [
+ ['command'],
+ function() {
+ try {
+ var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+ xml += '<description>'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.description')+'</description>';
+ xml += '<hbox><button value="email" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.label')+'"';
+ xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_email.accesskey')+'" name="fancy_submit"/>';
+ xml += '<button value="noemail" label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.label')+'"';
+ xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_no_email.accesskey')+'" name="fancy_submit"/></hbox>';
+ xml += '</vbox>';
+ var bot_xml = '<hbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1" style="overflow: vertical">';
+ bot_xml += '<spacer flex="1"/><button label="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.label')+'"';
+ bot_xml += ' accesskey="'+$("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.btn_cancel.accesskey')+'" name="fancy_cancel"/></hbox>';
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ //obj.data.temp_mid = xml; obj.data.stash('temp_mid');
+ //obj.data.temp_bot = bot_xml; obj.data.stash('temp_bot');
+ JSAN.use('util.window'); var win = new util.window();
+ var fancy_prompt_data = win.open(
+ urls.XUL_FANCY_PROMPT,
+ //+ '?xml_in_stash=temp_mid'
+ //+ '&bottom_xml_in_stash=temp_bot'
+ //+ '&title=' + window.escape('Set Email Notification for Holds'),
+ 'fancy_prompt', 'chrome,resizable,modal',
+ { 'xml' : xml, 'bottom_xml' : bot_xml, 'title' : $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.set_notifs') }
+ );
+ if (fancy_prompt_data.fancy_status == 'incomplete') { return; }
+ var email = fancy_prompt_data.fancy_submit == 'email' ? get_db_true() : get_db_false();
- var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var msg = '';
- if(get_bool(email)) {
- if(obj.retrieve_ids.length > 1) {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list]);
- } else {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list]);
- }
- } else {
- if(obj.retrieve_ids.length > 1) {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list]);
- } else {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list]);
- }
- }
+ var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
+ var msg = '';
+ if(get_bool(email)) {
+ if(obj.retrieve_ids.length > 1) {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.plural', [hold_list]);
+ } else {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.enable_email.singular', [hold_list]);
+ }
+ } else {
+ if(obj.retrieve_ids.length > 1) {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.plural', [hold_list]);
+ } else {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_edit_email_notify.disable_email.singular', [hold_list]);
+ }
+ }
- var r = obj.error.yns_alert(msg,
- $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
- $("commonStrings").getString('common.yes'),
- $("commonStrings").getString('common.no'),
- null,
- $("commonStrings").getString('common.check_to_confirm')
- );
- if (r == 0) {
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
- hold.email_notify( email ); hold.ischanged('1');
+ var r = obj.error.yns_alert(msg,
+ $("patronStrings").getString('staff.patron.holds.holds_edit_email_notify.mod_holds_title'),
+ $("commonStrings").getString('common.yes'),
+ $("commonStrings").getString('common.no'),
+ null,
+ $("commonStrings").getString('common.check_to_confirm')
+ );
+ if (r == 0) {
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
+ hold.email_notify( email ); hold.ischanged('1');
hold = obj.flatten_copy(hold);
- var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- }
- obj.clear_and_retrieve(true);
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
- }
- }
- ],
+ var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ }
+ obj.clear_and_retrieve(true);
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_not_modified'),E);
+ }
+ }
+ ],
'cmd_holds_suspend' : [
- ['command'],
- function() {
- try {
+ ['command'],
+ function() {
+ try {
var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var r = obj.error.yns_alert(
+ var r = obj.error.yns_alert(
obj.retrieve_ids.length > 1 ?
document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt.plural',[hold_list]) :
document.getElementById('circStrings').getFormattedString('staff.circ.holds.suspend.prompt',[hold_list]),
null,
document.getElementById('commonStrings').getString('common.confirm')
);
- if (r == 0) {
+ if (r == 0) {
var already_suspended = [];
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
if ( get_bool( hold.frozen() ) ) {
already_suspended.push( hold.id() );
continue;
}
- hold.frozen('t');
- hold.thaw_date(null);
- hold.ischanged('1');
+ hold.frozen('t');
+ hold.thaw_date(null);
+ hold.ischanged('1');
hold = obj.flatten_copy(hold);
- var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- }
+ var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ }
if (already_suspended.length == 1) {
alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended',[already_suspended[0]]) );
} else if (already_suspended.length > 1) {
alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_suspended.plural',[already_suspended.join(', ')]) );
}
- obj.clear_and_retrieve(true);
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
- }
- }
- ],
+ obj.clear_and_retrieve(true);
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_suspended'),E);
+ }
+ }
+ ],
'cmd_holds_activate' : [
- ['command'],
- function() {
- try {
+ ['command'],
+ function() {
+ try {
var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var r = obj.error.yns_alert(
+ var r = obj.error.yns_alert(
obj.retrieve_ids.length > 1 ?
document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt.plural',[hold_list]) :
document.getElementById('circStrings').getFormattedString('staff.circ.holds.activate.prompt',[hold_list]),
null,
document.getElementById('commonStrings').getString('common.confirm')
);
- if (r == 0) {
+ if (r == 0) {
var already_activated = [];
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ var hold = obj.holds_map[ obj.retrieve_ids[i].id ].hold;
if ( ! get_bool( hold.frozen() ) ) {
already_activated.push( hold.id() );
continue;
}
- hold.frozen('f');
- hold.thaw_date(null);
- hold.ischanged('1');
+ hold.frozen('f');
+ hold.thaw_date(null);
+ hold.ischanged('1');
hold = obj.flatten_copy(hold);
- var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- }
+ var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ }
if (already_activated.length == 1) {
alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated',[already_activated[0]]) );
} else if (already_activated.length > 1) {
alert( document.getElementById('circStrings').getFormattedString('staff.circ.holds.already_activated.plural',[already_activated.join(', ')]) );
}
- obj.clear_and_retrieve(true);
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
- }
- }
- ],
+ obj.clear_and_retrieve(true);
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_activated'),E);
+ }
+ }
+ ],
'cmd_holds_edit_thaw_date' : [
- ['command'],
- function() {
- try {
+ ['command'],
+ function() {
+ try {
JSAN.use('util.date');
function check_date(value) {
try {
}
var hold_ids = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_ids]);
- var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_ids]);
+ var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_ids]);
+ var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.activation_date.prompt',[hold_ids]);
var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
var value = 'YYYY-MM-DD';
var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
- var thaw_date; var invalid = true;
+ var thaw_date; var invalid = true;
while(invalid) {
thaw_date = window.prompt(msg,value,title);
if (thaw_date) {
var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
if (typeof robj.ilsevent != 'undefined') throw(robj);
}
- obj.clear_and_retrieve(true);
+ obj.clear_and_retrieve(true);
}
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
- }
- }
- ],
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
+ }
+ }
+ ],
'cmd_holds_edit_expire_time' : [
- ['command'],
- function() {
- try {
+ ['command'],
+ function() {
+ try {
JSAN.use('util.date');
function check_date(value) {
try {
}
var hold_ids = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_ids]);
- var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_ids]);
+ var msg_singular = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_ids]);
+ var msg_plural = document.getElementById('circStrings').getFormattedString('staff.circ.holds.expire_time.prompt',[hold_ids]);
var msg = obj.retrieve_ids.length > 1 ? msg_plural : msg_singular;
var value = 'YYYY-MM-DD';
var title = document.getElementById('circStrings').getString('staff.circ.holds.modifying_holds');
- var expire_time; var invalid = true;
+ var expire_time; var invalid = true;
while(invalid) {
expire_time = window.prompt(msg,value,title);
if (expire_time) {
var robj = obj.network.simple_request('FM_AHR_UPDATE',[ ses(), hold ]);
if (typeof robj.ilsevent != 'undefined') throw(robj);
}
- obj.clear_and_retrieve(true);
+ obj.clear_and_retrieve(true);
}
- } catch(E) {
- obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
- }
- }
- ],
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert(document.getElementById('circStrings').getString('staff.circ.holds.unexpected_error.not_likely_modified'),E);
+ }
+ }
+ ],
- 'cmd_holds_retarget' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
+ 'cmd_holds_retarget' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
- var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var msg = '';
- if(obj.retrieve_ids.length > 1) {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list]);
- } else {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list]);
- }
- var r = obj.error.yns_alert(msg,
- $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
- $("commonStrings").getString('common.yes'),
- $("commonStrings").getString('common.no'),
- null,
- $("commonStrings").getString('common.check_to_confirm')
- );
- if (r == 0) {
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- }
- obj.clear_and_retrieve();
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
- }
+ var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
+ var msg = '';
+ if(obj.retrieve_ids.length > 1) {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.plural',[hold_list]);
+ } else {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_retarget.reset_hold_message.singular',[hold_list]);
+ }
+ var r = obj.error.yns_alert(msg,
+ $("patronStrings").getString('staff.patron.holds.holds_retarget.reset_hold_title'),
+ $("commonStrings").getString('common.yes'),
+ $("commonStrings").getString('common.no'),
+ null,
+ $("commonStrings").getString('common.check_to_confirm')
+ );
+ if (r == 0) {
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ var robj = obj.network.simple_request('FM_AHR_RESET',[ ses(), obj.retrieve_ids[i].id]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ }
+ obj.clear_and_retrieve();
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_retarget.holds_not_reset'),E);
+ }
- }
- ],
+ }
+ ],
- 'cmd_holds_cancel' : [
- ['command'],
- function() {
- try {
- JSAN.use('util.functional');
+ 'cmd_holds_cancel' : [
+ ['command'],
+ function() {
+ try {
+ JSAN.use('util.functional');
- var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
- var msg = '';
- if(obj.retrieve_ids.length > 1 ) {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list]);
- } else {
- msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list]);
- }
+ var hold_list = util.functional.map_list( obj.retrieve_ids, function(o){return o.id;}).join(', ');
+ var msg = '';
+ if(obj.retrieve_ids.length > 1 ) {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.plural', [hold_list]);
+ } else {
+ msg = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_hold_message.singular', [hold_list]);
+ }
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
JSAN.use('util.window');
'chrome,resizable,modal',
{}
);
- /*var r = obj.error.yns_alert(msg,
- $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
- $("commonStrings").getString('common.yes'),
- $("commonStrings").getString('common.no'),
- null,
- $("commonStrings").getString('common.check_to_confirm')
- );*/
+ /*var r = obj.error.yns_alert(msg,
+ $("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_hold_title'),
+ $("commonStrings").getString('common.yes'),
+ $("commonStrings").getString('common.no'),
+ null,
+ $("commonStrings").getString('common.check_to_confirm')
+ );*/
if (my_xulG.proceed) {
var transits = [];
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
if (obj.holds_map[ obj.retrieve_ids[i].id ].hold.transit()) {
transits.push( obj.retrieve_ids[i].barcode );
}
- var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- }
+ var robj = obj.network.simple_request('FM_AHR_CANCEL',[ ses(), obj.retrieve_ids[i].id, my_xulG.cancel_reason, my_xulG.note]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ }
if (transits.length > 0) {
var msg2 = $("patronStrings").getFormattedString('staff.patron.holds.holds_cancel.cancel_for_barcodes', [transits.join(', ')]);
var r2 = obj.error.yns_alert(msg2,
$("patronStrings").getString('staff.patron.holds.holds_cancel.cancel_for_barcodes.title'),
$("commonStrings").getString('common.yes'),
$("commonStrings").getString('common.no'),
- null,
+ null,
$("commonStrings").getString('common.check_to_confirm'));
if (r2 == 0) {
try {
throw(robj);
break;
}
- }
+ }
}
} catch(E) {
obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_transits_not_cancelled'),E);
}
}
}
- obj.clear_and_retrieve();
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
- }
- }
- ],
- 'cmd_retrieve_patron' : [
- ['command'],
- function() {
- try {
- var seen = {};
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- var patron_id = obj.retrieve_ids[i].usr;
- if (seen[patron_id]) continue; seen[patron_id] = true;
- xulG.new_patron_tab(
- {},
- { 'id' : patron_id }
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('',E);
- }
- }
- ],
- 'cmd_show_catalog' : [
- ['command'],
- function() {
- try {
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- var htarget = obj.retrieve_ids[i].target;
- var htype = obj.retrieve_ids[i].type;
- var opac_url;
- switch(htype) {
- case 'M' :
- opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
- break;
- case 'T' :
- opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
- break;
- case 'V' :
- var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
- opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
- break;
- case 'C' :
- var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
- var my_acn;
- if (typeof my_acp.call_number() == 'object') {
- my_acn = my.acp.call_number();
- } else {
- my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
- [ my_acp.call_number() ]);
- }
- opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
- break;
- default:
- obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
- continue;
- break;
- }
- var content_params = {
- 'session' : ses(),
- 'authtime' : ses('authtime'),
- 'opac_url' : opac_url
- };
- xulG.new_tab(
- xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
- {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
- content_params
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('',E);
- }
- }
- ],
+ obj.clear_and_retrieve();
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.holds.holds_cancel.hold_not_cancelled'),E);
+ }
+ }
+ ],
+ 'cmd_retrieve_patron' : [
+ ['command'],
+ function() {
+ try {
+ var seen = {};
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ var patron_id = obj.retrieve_ids[i].usr;
+ if (seen[patron_id]) continue; seen[patron_id] = true;
+ xulG.new_patron_tab(
+ {},
+ { 'id' : patron_id }
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('',E);
+ }
+ }
+ ],
+ 'cmd_show_catalog' : [
+ ['command'],
+ function() {
+ try {
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ var htarget = obj.retrieve_ids[i].target;
+ var htype = obj.retrieve_ids[i].type;
+ var opac_url;
+ switch(htype) {
+ case 'M' :
+ opac_url = xulG.url_prefix( urls.opac_rresult ) + '?m=' + htarget;
+ break;
+ case 'T' :
+ opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + htarget;
+ break;
+ case 'V' :
+ var my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative', [ htarget ]);
+ opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
+ break;
+ case 'C' :
+ var my_acp = obj.network.simple_request( 'FM_ACP_RETRIEVE', [ htarget ]);
+ var my_acn;
+ if (typeof my_acp.call_number() == 'object') {
+ my_acn = my.acp.call_number();
+ } else {
+ my_acn = obj.network.simple_request( 'FM_ACN_RETRIEVE.authoritative',
+ [ my_acp.call_number() ]);
+ }
+ opac_url = xulG.url_prefix( urls.opac_rdetail) + '?r=' + my_acn.record();
+ break;
+ default:
+ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.holds.show_catalog.unknown_htype', [htype]), obj.retrieve_ids[i]);
+ continue;
+ break;
+ }
+ var content_params = {
+ 'session' : ses(),
+ 'authtime' : ses('authtime'),
+ 'opac_url' : opac_url
+ };
+ xulG.new_tab(
+ xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name': htype == 'M' ? 'Catalog' : $("patronStrings").getString('staff.patron.holds.show_catalog.retrieving_title') },
+ content_params
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('',E);
+ }
+ }
+ ],
'fetch_more' : [
['command'],
function() {
}
]
- }
- }
- );
+ }
+ }
+ );
obj.determine_hold_interface_type();
var x_fetch_more = document.getElementById('fetch_more');
obj.controller.view.cmd_holds_edit_pickup_lib.setAttribute('disabled','true');
obj.controller.view.cmd_holds_edit_phone_notify.setAttribute('disabled','true');
obj.controller.view.cmd_holds_edit_email_notify.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
- obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_edit_thaw_date.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_activate.setAttribute('disabled','true');
+ obj.controller.view.cmd_holds_suspend.setAttribute('disabled','true');
obj.controller.view.cmd_holds_edit_selection_depth.setAttribute('disabled','true');
obj.controller.view.cmd_alt_view.setAttribute('disabled','true');
obj.controller.view.cmd_holds_retarget.setAttribute('disabled','true');
}
);
- },
+ },
'determine_hold_interface_type' : function() {
- var obj = this;
+ var obj = this;
if (obj.patron_id) { /*************************************************** PATRON ******************************/
obj.hold_interface_type = 'patron';
- } else if (obj.docid) { /*************************************************** RECORD ******************************/
+ } else if (obj.docid) { /*************************************************** RECORD ******************************/
obj.hold_interface_type = 'record';
- } else if (obj.pull) { /*************************************************** PULL ******************************/
+ } else if (obj.pull) { /*************************************************** PULL ******************************/
obj.hold_interface_type = 'pull';
- } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
+ } else if (obj.shelf) { /*************************************************** HOLD SHELF ******************************/
obj.hold_interface_type = 'shelf';
- } else { /*************************************************** PULL ******************************/
+ } else { /*************************************************** PULL ******************************/
obj.hold_interface_type = 'pull';
- }
+ }
},
'clear_and_retrieve' : function() {
}
},
- 'retrieve' : function() {
- var obj = this; var holds = [];
- if (window.xulG && window.xulG.holds) {
- holds = window.xulG.holds;
- } else {
- var method; var params = [ ses() ];
+ 'retrieve' : function() {
+ var obj = this; var holds = [];
+ if (window.xulG && window.xulG.holds) {
+ holds = window.xulG.holds;
+ } else {
+ var method; var params = [ ses() ];
switch(obj.hold_interface_type) {
case 'patron' :
- method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
- params.push( obj.patron_id );
- obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
+ method = 'FM_AHR_ID_LIST_RETRIEVE_VIA_AU.authoritative';
+ params.push( obj.patron_id );
+ obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','true');
break;
case 'record' :
- method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
- params.push( obj.docid );
+ method = 'FM_AHR_RETRIEVE_ALL_VIA_BRE';
+ params.push( obj.docid );
var x_lib_filter = document.getElementById('lib_filter_checkbox');
var x_lib_type_menu = document.getElementById('lib_type_menu');
if (x_lib_filter) {
}
}
}
- obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
+ obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
break;
case 'shelf' :
- method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
+ method = 'FM_AHR_ID_LIST_ONSHELF_RETRIEVE';
params.push( obj.filter_lib || obj.data.list.au[0].ws_ou() );
- obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
+ obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
break;
case 'pull' :
default:
- method = 'FM_AHR_ID_LIST_PULL_LIST';
- params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
- //obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
+ method = 'FM_AHR_ID_LIST_PULL_LIST';
+ params.push( obj.pull_from_shelf_interface.current.limit ); params.push( obj.pull_from_shelf_interface.current.offset );
+ //obj.controller.view.cmd_retrieve_patron.setAttribute('hidden','false');
break;
- }
- var robj = obj.network.simple_request( method, params );
- if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
- if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
- holds = [];
+ }
+ var robj = obj.network.simple_request( method, params );
+ if (robj != null && typeof robj.ilsevent != 'undefined') throw(robj);
+ if (method == 'FM_AHR_RETRIEVE_ALL_VIA_BRE') {
+ holds = [];
if (robj != null) {
holds = holds.concat( robj.copy_holds );
holds = holds.concat( robj.volume_holds );
holds = holds.concat( robj.metarecord_holds );
holds = holds.sort();
}
- } else {
+ } else {
if (robj == null ) {
holds = [];
} else {
holds = robj;
}
}
- }
- //alert('method = ' + method + ' params = ' + js2JSON(params));
- }
+ }
+ //alert('method = ' + method + ' params = ' + js2JSON(params));
+ }
var x_fetch_more = document.getElementById('fetch_more');
if (holds.length == 0) {
exec.chain( rows );
} catch(E) {
- this.error.standard_unexpected_error_alert('holds.js, render():',E);
+ this.error.standard_unexpected_error_alert('holds.js, render():',E);
}
- },
+ },
- 'render_lib_menus' : function(types) {
- try {
- var obj = this;
- JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
+ 'render_lib_menus' : function(types) {
+ try {
+ var obj = this;
+ JSAN.use('util.widgets'); JSAN.use('util.functional'); JSAN.use('util.fm_utils');
var x = document.getElementById('lib_type_menu');
if (types) {
}
x.setAttribute('oncommand','g.holds.clear_and_retrieve()');
- x = document.getElementById('lib_menu_placeholder');
- util.widgets.remove_children( x );
+ x = document.getElementById('lib_menu_placeholder');
+ util.widgets.remove_children( x );
JSAN.use('util.file');
- var file = new util.file('offline_ou_list');
- if (file._file.exists()) {
- var list_data = file.get_object(); file.close();
- var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
+ var file = new util.file('offline_ou_list');
+ if (file._file.exists()) {
+ var list_data = file.get_object(); file.close();
+ var ml = util.widgets.make_menulist( list_data[0], obj.data.list.au[0].ws_ou() );
ml.setAttribute('id','lib_menu');
x.appendChild( ml );
- ml.addEventListener(
- 'command',
- function(ev) {
- obj.filter_lib = ev.target.value;
- obj.clear_and_retrieve();
- },
- false
- );
- obj.controller.view.lib_menu = ml;
- } else {
- throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
- }
+ ml.addEventListener(
+ 'command',
+ function(ev) {
+ obj.filter_lib = ev.target.value;
+ obj.clear_and_retrieve();
+ },
+ false
+ );
+ obj.controller.view.lib_menu = ml;
+ } else {
+ throw($("patronStrings").getString('staff.patron.holds.lib_menus.missing_library_list'));
+ }
- } catch(E) {
- this.error.standard_unexpected_error_alert('rendering lib menu',E);
- }
- }
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('rendering lib menu',E);
+ }
+ }
}
dump('exiting patron.holds.js\n');
if (typeof patron == 'undefined') patron = {};
patron.items = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
}
patron.items.prototype = {
- 'list_circ_map' : {},
-
- 'init' : function( params ) {
-
- var obj = this;
-
- obj.patron_id = params['patron_id'];
-
- obj.init_lists();
-
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- 'control_map' : {
- 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
- 'save_columns2' : [ [ 'command' ], function() { obj.list2.save_columns(); } ],
- 'cmd_broken' : [ ['command'], function() { alert('Not Yet Implemented'); } ],
- 'sel_clip' : [ ['command'], function() { obj.list.clipboard(); } ],
- 'sel_clip2' : [ ['command'], function() { obj.list2.clipboard(); } ],
- 'sel_patron' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.retrieve_ids); } ],
- 'sel_bucket' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.add_copies_to_bucket(util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_bucket2' : [
- ['command'],
- function() {
- JSAN.use('cat.util');
- cat.util.add_copies_to_bucket(util.functional.map_list( obj.retrieve_ids2, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_mark_items_damaged' : [
- ['command'],
- function() {
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_mark_items_missing' : [
- ['command'],
- function() {
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_mark_items_damaged2' : [
- ['command'],
- function() {
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids2, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_mark_items_missing2' : [
- ['command'],
- function() {
- JSAN.use('cat.util'); JSAN.use('util.functional');
- cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids2, function(o) { return o.copy_id; } ) );
- }
- ],
- 'sel_copy_details' : [ ['command'],
- function() {
- JSAN.use('circ.util');
- for (var i = 0; i < obj.retrieve_ids.length; i++) { circ.util.show_copy_details( obj.retrieve_ids[i].copy_id ); }
- }
- ],
- 'sel_patron2' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.retrieve_ids2); } ],
- 'sel_copy_details2' : [ ['command'],
- function() {
- JSAN.use('circ.util');
- for (var i = 0; i < obj.retrieve_ids2.length; i++) { circ.util.show_copy_details( obj.retrieve_ids2[i].copy_id ); }
- }
- ],
- 'cmd_items_print' : [ ['command'], function() { obj.items_print(1); } ],
- 'cmd_items_print2' : [ ['command'], function() { obj.items_print(2); } ],
- 'cmd_items_export' : [ ['command'], function() { obj.items_export(1); } ],
- 'cmd_items_export2' : [ ['command'], function() { obj.items_export(2); } ],
- 'cmd_items_renew' : [ ['command'], function() { obj.items_renew(1); /* obj.retrieve();*/ } ],
- 'cmd_items_renew_all' : [ ['command'], function() { obj.items_renew_all(); } ],
- 'cmd_items_renew2' : [ ['command'], function() { obj.items_renew(2); /* obj.retrieve();*/ } ],
- 'cmd_items_edit' : [ ['command'], function() { obj.items_edit(1); /*obj.retrieve();*/ } ],
- 'cmd_items_edit2' : [ ['command'], function() { obj.items_edit(2); /*obj.retrieve();*/ } ],
- 'cmd_items_mark_lost' : [ ['command'], function() { obj.items_mark_lost(1); /*obj.retrieve();*/ } ],
- 'cmd_items_mark_lost2' : [ ['command'], function() { obj.items_mark_lost(2); /*obj.retrieve();*/ } ],
- 'cmd_items_claimed_returned' : [ ['command'], function() { obj.items_claimed_returned(1); /*obj.retrieve();*/ } ],
- 'cmd_items_claimed_returned2' : [ ['command'], function() { obj.items_claimed_returned(2); /*obj.retrieve();*/ } ],
- 'cmd_items_checkin' : [ ['command'], function() { obj.items_checkin(1); /*obj.retrieve();*/ } ],
- 'cmd_items_checkin2' : [ ['command'], function() { obj.items_checkin(2); /*obj.retrieve();*/ } ],
- 'cmd_show_catalog' : [ ['command'], function() { obj.show_catalog(1); } ],
- 'cmd_show_catalog2' : [ ['command'], function() { obj.show_catalog(2); } ],
- 'cmd_add_billing' : [ ['command'], function() { obj.add_billing(1); /*obj.retrieve();*/ } ],
- 'cmd_add_billing2' : [ ['command'], function() { obj.add_billing(2); /*obj.retrieve();*/ } ],
- 'cmd_show_noncats' : [ ['command'], function() { obj.show_noncats(); } ]
- }
- }
- );
-
- obj.retrieve();
-
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_damaged2.setAttribute('disabled','true');
- obj.controller.view.sel_mark_items_missing2.setAttribute('disabled','true');
- obj.controller.view.sel_clip.setAttribute('disabled','true');
- obj.controller.view.sel_clip2.setAttribute('disabled','true');
- obj.controller.view.sel_bucket.setAttribute('disabled','true');
- obj.controller.view.sel_bucket2.setAttribute('disabled','true');
- obj.controller.view.sel_copy_details.setAttribute('disabled','true');
- obj.controller.view.sel_patron.setAttribute('disabled','true');
- obj.controller.view.sel_copy_details2.setAttribute('disabled','true');
- obj.controller.view.sel_patron2.setAttribute('disabled','true');
- obj.controller.view.cmd_items_claimed_returned.setAttribute('disabled','true');
- obj.controller.view.cmd_items_renew.setAttribute('disabled','true');
- obj.controller.view.cmd_items_checkin.setAttribute('disabled','true');
- obj.controller.view.cmd_items_edit.setAttribute('disabled','true');
- obj.controller.view.cmd_items_mark_lost.setAttribute('disabled','true');
- obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
- obj.controller.view.cmd_items_claimed_returned2.setAttribute('disabled','true');
- obj.controller.view.cmd_items_renew2.setAttribute('disabled','true');
- obj.controller.view.cmd_items_checkin2.setAttribute('disabled','true');
- obj.controller.view.cmd_items_edit2.setAttribute('disabled','true');
- obj.controller.view.cmd_items_mark_lost2.setAttribute('disabled','true');
- obj.controller.view.cmd_show_catalog2.setAttribute('disabled','true');
- },
-
- 'show_noncats' : function() {
- var obj = this; var checkout = {};
- try {
- var robj = obj.network.simple_request('FM_ANCC_RETRIEVE_VIA_USER.authoritative',[ ses(), obj.patron_id ]);
- if (typeof robj.ilsevent != 'undefined') throw(robj);
-
- for (var ii = 0; ii < robj.length; ii++) {
- try {
- var nc_circ = obj.network.simple_request('FM_ANCC_RETRIEVE_VIA_ID',[ ses(), robj[ii] ]);
- if (typeof nc_circ.ilsevent != 'undefined') throw(nc_circ);
- var fake_circ = new aoc();
- fake_circ.circ_lib( nc_circ.circ_lib() );
- fake_circ.circ_staff( nc_circ.staff() );
- fake_circ.usr( nc_circ.patron() );
- fake_circ.xact_start( nc_circ.circ_time() );
- fake_circ.renewal_remaining(0);
- fake_circ.stop_fines('Non-Cataloged');
-
- JSAN.use('util.date');
- var c = nc_circ.circ_time();
- var d = c == "now" ? new Date() : util.date.db_date2Date( c );
- var t = obj.data.hash.cnct[ nc_circ.item_type() ];
- if (!t) {
- var robj2 = obj.network.simple_request('FM_CNCT_RETRIEVE',[ nc_circ.circ_lib() ]);
- if (typeof robj2.ilsevent != 'undefined') throw(robj);
- obj.data.stash_retrieve();
- for (var j = 0; j < robj2.length; j++) {
- if (! obj.data.hash.cnct[ robj2[j].id() ] ) {
- obj.data.hash.cnct[ robj2[j].id() ] = robj2[j];
- obj.data.list.cnct.push( robj2[j] );
- }
- }
- obj.data.stash('hash','list');
- t = obj.data.hash.cnct[ nc_circ.item_type() ];
- }
- var cd = t.circ_duration() || $("patronStrings").getString('staff.patron.items.show_noncats.14_days');
- var i = util.date.interval_to_seconds( cd ) * 1000;
- d.setTime( Date.parse(d) + i );
- fake_circ.due_date( util.date.formatted_date(d,'%F') );
-
- var fake_record = new mvr();
- fake_record.title( obj.data.hash.cnct[ nc_circ.item_type() ].name());
-
- var fake_copy = new acp();
- fake_copy.barcode( '' );
- fake_copy.circ_lib( nc_circ.circ_lib() );
-
- obj.list.append( { 'row' : { 'my' : { 'circ' : fake_circ, 'mvr' : fake_record, 'acp' : fake_copy } }, 'to_bottom' : true, 'no_auto_select' : true } );
-
- } catch(F) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.show_noncats.err_showing_noncat', [robj[ii].id()]),F);
- }
- }
-
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.show_noncats.err_showing_circulations'),E);
- }
- },
-
- 'items_print' : function(which) {
- var obj = this;
- try {
- var list = (which==2 ? obj.list2 : obj.list);
+ 'list_circ_map' : {},
+
+ 'init' : function( params ) {
+
+ var obj = this;
+
+ obj.patron_id = params['patron_id'];
+
+ obj.init_lists();
+
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ 'control_map' : {
+ 'save_columns' : [ [ 'command' ], function() { obj.list.save_columns(); } ],
+ 'save_columns2' : [ [ 'command' ], function() { obj.list2.save_columns(); } ],
+ 'cmd_broken' : [ ['command'], function() { alert('Not Yet Implemented'); } ],
+ 'sel_clip' : [ ['command'], function() { obj.list.clipboard(); } ],
+ 'sel_clip2' : [ ['command'], function() { obj.list2.clipboard(); } ],
+ 'sel_patron' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.retrieve_ids); } ],
+ 'sel_bucket' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.add_copies_to_bucket(util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_bucket2' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util');
+ cat.util.add_copies_to_bucket(util.functional.map_list( obj.retrieve_ids2, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_mark_items_damaged' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_mark_items_missing' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_mark_items_damaged2' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_damaged( util.functional.map_list( obj.retrieve_ids2, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_mark_items_missing2' : [
+ ['command'],
+ function() {
+ JSAN.use('cat.util'); JSAN.use('util.functional');
+ cat.util.mark_item_missing( util.functional.map_list( obj.retrieve_ids2, function(o) { return o.copy_id; } ) );
+ }
+ ],
+ 'sel_copy_details' : [ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ for (var i = 0; i < obj.retrieve_ids.length; i++) { circ.util.show_copy_details( obj.retrieve_ids[i].copy_id ); }
+ }
+ ],
+ 'sel_patron2' : [ ['command'], function() { JSAN.use('circ.util'); circ.util.show_last_few_circs(obj.retrieve_ids2); } ],
+ 'sel_copy_details2' : [ ['command'],
+ function() {
+ JSAN.use('circ.util');
+ for (var i = 0; i < obj.retrieve_ids2.length; i++) { circ.util.show_copy_details( obj.retrieve_ids2[i].copy_id ); }
+ }
+ ],
+ 'cmd_items_print' : [ ['command'], function() { obj.items_print(1); } ],
+ 'cmd_items_print2' : [ ['command'], function() { obj.items_print(2); } ],
+ 'cmd_items_export' : [ ['command'], function() { obj.items_export(1); } ],
+ 'cmd_items_export2' : [ ['command'], function() { obj.items_export(2); } ],
+ 'cmd_items_renew' : [ ['command'], function() { obj.items_renew(1); /* obj.retrieve();*/ } ],
+ 'cmd_items_renew_all' : [ ['command'], function() { obj.items_renew_all(); } ],
+ 'cmd_items_renew2' : [ ['command'], function() { obj.items_renew(2); /* obj.retrieve();*/ } ],
+ 'cmd_items_edit' : [ ['command'], function() { obj.items_edit(1); /*obj.retrieve();*/ } ],
+ 'cmd_items_edit2' : [ ['command'], function() { obj.items_edit(2); /*obj.retrieve();*/ } ],
+ 'cmd_items_mark_lost' : [ ['command'], function() { obj.items_mark_lost(1); /*obj.retrieve();*/ } ],
+ 'cmd_items_mark_lost2' : [ ['command'], function() { obj.items_mark_lost(2); /*obj.retrieve();*/ } ],
+ 'cmd_items_claimed_returned' : [ ['command'], function() { obj.items_claimed_returned(1); /*obj.retrieve();*/ } ],
+ 'cmd_items_claimed_returned2' : [ ['command'], function() { obj.items_claimed_returned(2); /*obj.retrieve();*/ } ],
+ 'cmd_items_checkin' : [ ['command'], function() { obj.items_checkin(1); /*obj.retrieve();*/ } ],
+ 'cmd_items_checkin2' : [ ['command'], function() { obj.items_checkin(2); /*obj.retrieve();*/ } ],
+ 'cmd_show_catalog' : [ ['command'], function() { obj.show_catalog(1); } ],
+ 'cmd_show_catalog2' : [ ['command'], function() { obj.show_catalog(2); } ],
+ 'cmd_add_billing' : [ ['command'], function() { obj.add_billing(1); /*obj.retrieve();*/ } ],
+ 'cmd_add_billing2' : [ ['command'], function() { obj.add_billing(2); /*obj.retrieve();*/ } ],
+ 'cmd_show_noncats' : [ ['command'], function() { obj.show_noncats(); } ]
+ }
+ }
+ );
+
+ obj.retrieve();
+
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_missing.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_damaged2.setAttribute('disabled','true');
+ obj.controller.view.sel_mark_items_missing2.setAttribute('disabled','true');
+ obj.controller.view.sel_clip.setAttribute('disabled','true');
+ obj.controller.view.sel_clip2.setAttribute('disabled','true');
+ obj.controller.view.sel_bucket.setAttribute('disabled','true');
+ obj.controller.view.sel_bucket2.setAttribute('disabled','true');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','true');
+ obj.controller.view.sel_patron.setAttribute('disabled','true');
+ obj.controller.view.sel_copy_details2.setAttribute('disabled','true');
+ obj.controller.view.sel_patron2.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_claimed_returned.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_renew.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_checkin.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_edit.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_mark_lost.setAttribute('disabled','true');
+ obj.controller.view.cmd_show_catalog.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_claimed_returned2.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_renew2.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_checkin2.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_edit2.setAttribute('disabled','true');
+ obj.controller.view.cmd_items_mark_lost2.setAttribute('disabled','true');
+ obj.controller.view.cmd_show_catalog2.setAttribute('disabled','true');
+ },
+
+ 'show_noncats' : function() {
+ var obj = this; var checkout = {};
+ try {
+ var robj = obj.network.simple_request('FM_ANCC_RETRIEVE_VIA_USER.authoritative',[ ses(), obj.patron_id ]);
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+
+ for (var ii = 0; ii < robj.length; ii++) {
+ try {
+ var nc_circ = obj.network.simple_request('FM_ANCC_RETRIEVE_VIA_ID',[ ses(), robj[ii] ]);
+ if (typeof nc_circ.ilsevent != 'undefined') throw(nc_circ);
+ var fake_circ = new aoc();
+ fake_circ.circ_lib( nc_circ.circ_lib() );
+ fake_circ.circ_staff( nc_circ.staff() );
+ fake_circ.usr( nc_circ.patron() );
+ fake_circ.xact_start( nc_circ.circ_time() );
+ fake_circ.renewal_remaining(0);
+ fake_circ.stop_fines('Non-Cataloged');
+
+ JSAN.use('util.date');
+ var c = nc_circ.circ_time();
+ var d = c == "now" ? new Date() : util.date.db_date2Date( c );
+ var t = obj.data.hash.cnct[ nc_circ.item_type() ];
+ if (!t) {
+ var robj2 = obj.network.simple_request('FM_CNCT_RETRIEVE',[ nc_circ.circ_lib() ]);
+ if (typeof robj2.ilsevent != 'undefined') throw(robj);
+ obj.data.stash_retrieve();
+ for (var j = 0; j < robj2.length; j++) {
+ if (! obj.data.hash.cnct[ robj2[j].id() ] ) {
+ obj.data.hash.cnct[ robj2[j].id() ] = robj2[j];
+ obj.data.list.cnct.push( robj2[j] );
+ }
+ }
+ obj.data.stash('hash','list');
+ t = obj.data.hash.cnct[ nc_circ.item_type() ];
+ }
+ var cd = t.circ_duration() || $("patronStrings").getString('staff.patron.items.show_noncats.14_days');
+ var i = util.date.interval_to_seconds( cd ) * 1000;
+ d.setTime( Date.parse(d) + i );
+ fake_circ.due_date( util.date.formatted_date(d,'%F') );
+
+ var fake_record = new mvr();
+ fake_record.title( obj.data.hash.cnct[ nc_circ.item_type() ].name());
+
+ var fake_copy = new acp();
+ fake_copy.barcode( '' );
+ fake_copy.circ_lib( nc_circ.circ_lib() );
+
+ obj.list.append( { 'row' : { 'my' : { 'circ' : fake_circ, 'mvr' : fake_record, 'acp' : fake_copy } }, 'to_bottom' : true, 'no_auto_select' : true } );
+
+ } catch(F) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.show_noncats.err_showing_noncat', [robj[ii].id()]),F);
+ }
+ }
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.show_noncats.err_showing_circulations'),E);
+ }
+ },
+
+ 'items_print' : function(which) {
+ var obj = this;
+ try {
+ var list = (which==2 ? obj.list2 : obj.list);
JSAN.use('patron.util');
var params = {
'patron' : patron.util.retrieve_fleshed_au_via_id(ses(),obj.patron_id),
'template' : 'items_out'
};
list.print( params );
- } catch(E) {
- obj.error.standard_unexpected_error_alert('printing 1',E);
- }
- },
-
- 'items_export' : function(which) {
- var obj = this;
- try {
- var list = (which==2 ? obj.list2 : obj.list);
- list.dump_csv_to_clipboard();
- } catch(E) {
- obj.error.standard_unexpected_error_alert('export 1',E);
- }
- },
-
- 'items_renew_all' : function() {
- try {
- var obj = this; var list = obj.list;
- if (list.on_all_fleshed != null) {
- var r = window.confirm($("patronStrings").getString('staff.patron.items.items_renew_all.list_is_busy'));
- if (!r) return;
- }
- var r = window.confirm($("patronStrings").getString('staff.patron.items.items_renew_all.renew_items_in_list'));
- if (!r) return;
- function flesh_callback() {
- try {
- obj.list.select_all();
- obj.items_renew(1,true);
- setTimeout(function(){list.on_all_fleshed = null; /* obj.retrieve();*/ },0);
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew_all.items_not_renewed', ['2']),E);
- }
- }
- list.on_all_fleshed = flesh_callback;
- list.full_retrieve();
- } catch(E) {
- this.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew_all.items_not_renewed', ['1']),E);
- }
- },
-
- 'items_renew' : function(which,skip_prompt) {
- var obj = this;
- try{
- JSAN.use('circ.util');
- var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
- if (!retrieve_ids || retrieve_ids.length == 0) return;
- JSAN.use('util.functional');
- if (!skip_prompt) {
- var msg = '';
- if(retrieve_ids.length > 1) {
- msg += $("patronStrings").getFormattedString('staff.patron.items.items_renew.renew_item_plural',[util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ')]);
- } else {
- msg += $("patronStrings").getFormattedString('staff.patron.items.items_renew.renew_item_singular', [util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ')]);
- }
- var r = window.confirm(msg);
- if (!r) { return; }
- }
-
- var count = 0;
-
- function gen_renew(bc,circ_id) {
- var x = document.getElementById('renew_msgs');
- if (x) {
- var l = document.createElement('label');
- l.setAttribute('value', $("patronStrings").getFormattedString('staff.patron.items.items_renew.renewing',[bc]));
- x.appendChild(l);
- }
- var renew = circ.util.renew_via_barcode( { 'barcode' : bc, 'patron' : obj.patron_id },
- function(r) {
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('printing 1',E);
+ }
+ },
+
+ 'items_export' : function(which) {
+ var obj = this;
+ try {
+ var list = (which==2 ? obj.list2 : obj.list);
+ list.dump_csv_to_clipboard();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('export 1',E);
+ }
+ },
+
+ 'items_renew_all' : function() {
+ try {
+ var obj = this; var list = obj.list;
+ if (list.on_all_fleshed != null) {
+ var r = window.confirm($("patronStrings").getString('staff.patron.items.items_renew_all.list_is_busy'));
+ if (!r) return;
+ }
+ var r = window.confirm($("patronStrings").getString('staff.patron.items.items_renew_all.renew_items_in_list'));
+ if (!r) return;
+ function flesh_callback() {
+ try {
+ obj.list.select_all();
+ obj.items_renew(1,true);
+ setTimeout(function(){list.on_all_fleshed = null; /* obj.retrieve();*/ },0);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew_all.items_not_renewed', ['2']),E);
+ }
+ }
+ list.on_all_fleshed = flesh_callback;
+ list.full_retrieve();
+ } catch(E) {
+ this.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew_all.items_not_renewed', ['1']),E);
+ }
+ },
+
+ 'items_renew' : function(which,skip_prompt) {
+ var obj = this;
+ try{
+ JSAN.use('circ.util');
+ var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
+ if (!retrieve_ids || retrieve_ids.length == 0) return;
+ JSAN.use('util.functional');
+ if (!skip_prompt) {
+ var msg = '';
+ if(retrieve_ids.length > 1) {
+ msg += $("patronStrings").getFormattedString('staff.patron.items.items_renew.renew_item_plural',[util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ')]);
+ } else {
+ msg += $("patronStrings").getFormattedString('staff.patron.items.items_renew.renew_item_singular', [util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ')]);
+ }
+ var r = window.confirm(msg);
+ if (!r) { return; }
+ }
+
+ var count = 0;
+
+ function gen_renew(bc,circ_id) {
+ var x = document.getElementById('renew_msgs');
+ if (x) {
+ var l = document.createElement('label');
+ l.setAttribute('value', $("patronStrings").getFormattedString('staff.patron.items.items_renew.renewing',[bc]));
+ x.appendChild(l);
+ }
+ var renew = circ.util.renew_via_barcode( { 'barcode' : bc, 'patron' : obj.patron_id },
+ function(r) {
try {
if ( (typeof r[0].ilsevent != 'undefined' && r[0].ilsevent == 0) ) {
l.setAttribute('value', $("patronStrings").getFormattedString('staff.patron.items.items_renew.renewed',[bc]));
}
obj.refresh(circ_id);
} catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew.err_in_renew_via_barcode',[bc]), E);
+ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew.err_in_renew_via_barcode',[bc]), E);
+ }
+ }
+ );
+ }
+
+ for (var i = 0; i < retrieve_ids.length; i++) {
+ try {
+ count++;
+ var barcode = retrieve_ids[i].barcode;
+ var circ_id = retrieve_ids[i].circ_id;
+ gen_renew(barcode,circ_id);
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew.no_renew_for_barcode',[barcode]), E);
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_renew.no_renew'),E);
+ }
+ },
+
+ 'items_edit' : function(which) {
+ var obj = this;
+ try {
+ var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
+ if (!retrieve_ids || retrieve_ids.length == 0) return;
+ function check_date(value) {
+ JSAN.use('util.date');
+ try {
+ if (! util.date.check('YYYY-MM-DD',value) ) {
+ throw($("patronStrings").getString('staff.patron.items.items_edit.invalid_date'));
}
- }
- );
- }
-
- for (var i = 0; i < retrieve_ids.length; i++) {
- try {
- count++;
- var barcode = retrieve_ids[i].barcode;
- var circ_id = retrieve_ids[i].circ_id;
- gen_renew(barcode,circ_id);
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.items_renew.no_renew_for_barcode',[barcode]), E);
- }
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_renew.no_renew'),E);
- }
- },
-
- 'items_edit' : function(which) {
- var obj = this;
- try {
- var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
- if (!retrieve_ids || retrieve_ids.length == 0) return;
- function check_date(value) {
- JSAN.use('util.date');
- try {
- if (! util.date.check('YYYY-MM-DD',value) ) {
- throw($("patronStrings").getString('staff.patron.items.items_edit.invalid_date'));
- }
- if (util.date.check_past('YYYY-MM-DD',value) ) {
- throw($("patronStrings").getString('staff.patron.items.items_edit.need_later_date'));
- }
- /*
- if ( util.date.formatted_date(new Date(),'%F') == value) {
- throw('Due date needs to be after today.');
- }
- */
- return true;
- } catch(E) {
- alert(E);
- return false;
- }
- }
-
- JSAN.use('util.functional');
- var title = '';
- if (retrieve_ids.length > 1) {
- title += $("patronStrings").getString('staff.patron.items.items_edit.edit_due_date.plural');
- } else {
- title += $("patronStrings").getString('staff.patron.items.items_edit.edit_due_date.singular');
- }
- var value = 'YYYY-MM-DD';
- var text = $("patronStrings").getFormattedString('staff.patron.items.items_edit.new_due_date', [util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ')]);
- var due_date; var invalid = true;
- while(invalid) {
- due_date = window.prompt(text,value,title);
- if (due_date) {
- invalid = ! check_date(due_date);
- } else {
- invalid = false;
- }
- }
- if (due_date) {
- var circs = util.functional.map_list(retrieve_ids,function(o){return o.circ_id;});
- for (var i = 0; i < circs.length; i++) {
- var robj = obj.network.simple_request('FM_CIRC_EDIT_DUE_DATE',[ses(),circs[i],due_date]);
- if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); }
- }
- }
- for (var i = 0; i < obj.retrieve_ids.length; i++) {
- obj.refresh(retrieve_ids[i].circ_id);
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_edit.dates_not_modified'),E);
- }
- },
-
- 'items_mark_lost' : function(which) {
- var obj = this;
- try {
- var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
- if (!retrieve_ids || retrieve_ids.length == 0) return;
- for (var i = 0; i < retrieve_ids.length; i++) {
- var barcode = retrieve_ids[i].barcode;
- dump($("patronStrings").getFormattedString('staff.patron.items.items_edit.mark_barcode_lost', [barcode]));
- var robj = obj.network.simple_request( 'MARK_ITEM_LOST', [ ses(), { barcode: barcode } ]);
- if (typeof robj.ilsevent != 'undefined') {
+ if (util.date.check_past('YYYY-MM-DD',value) ) {
+ throw($("patronStrings").getString('staff.patron.items.items_edit.need_later_date'));
+ }
+ /*
+ if ( util.date.formatted_date(new Date(),'%F') == value) {
+ throw('Due date needs to be after today.');
+ }
+ */
+ return true;
+ } catch(E) {
+ alert(E);
+ return false;
+ }
+ }
+
+ JSAN.use('util.functional');
+ var title = '';
+ if (retrieve_ids.length > 1) {
+ title += $("patronStrings").getString('staff.patron.items.items_edit.edit_due_date.plural');
+ } else {
+ title += $("patronStrings").getString('staff.patron.items.items_edit.edit_due_date.singular');
+ }
+ var value = 'YYYY-MM-DD';
+ var text = $("patronStrings").getFormattedString('staff.patron.items.items_edit.new_due_date', [util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ')]);
+ var due_date; var invalid = true;
+ while(invalid) {
+ due_date = window.prompt(text,value,title);
+ if (due_date) {
+ invalid = ! check_date(due_date);
+ } else {
+ invalid = false;
+ }
+ }
+ if (due_date) {
+ var circs = util.functional.map_list(retrieve_ids,function(o){return o.circ_id;});
+ for (var i = 0; i < circs.length; i++) {
+ var robj = obj.network.simple_request('FM_CIRC_EDIT_DUE_DATE',[ses(),circs[i],due_date]);
+ if (typeof robj.ilsevent != 'undefined') { if (robj.ilsevent != 0) throw(robj); }
+ }
+ }
+ for (var i = 0; i < obj.retrieve_ids.length; i++) {
+ obj.refresh(retrieve_ids[i].circ_id);
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_edit.dates_not_modified'),E);
+ }
+ },
+
+ 'items_mark_lost' : function(which) {
+ var obj = this;
+ try {
+ var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
+ if (!retrieve_ids || retrieve_ids.length == 0) return;
+ for (var i = 0; i < retrieve_ids.length; i++) {
+ var barcode = retrieve_ids[i].barcode;
+ dump($("patronStrings").getFormattedString('staff.patron.items.items_edit.mark_barcode_lost', [barcode]));
+ var robj = obj.network.simple_request( 'MARK_ITEM_LOST', [ ses(), { barcode: barcode } ]);
+ if (typeof robj.ilsevent != 'undefined') {
switch(Number(robj.ilsevent)) {
case 7018 /* COPY_MARKED_LOST */ :
alert( $("patronStrings").getFormattedString('staff.patron.items.items_edit.item_barcode', [barcode, robj.desc]) );
default: throw(robj);
}
} else {
- obj.refresh(retrieve_ids[i].circ_id,true);
+ obj.refresh(retrieve_ids[i].circ_id,true);
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_edit.items_not_marked_lost'),E);
+ }
+ },
+
+ 'items_claimed_returned' : function(which) {
+ var obj = this;
+ try {
+ JSAN.use('util.date');
+ var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
+ if (!retrieve_ids || retrieve_ids.length == 0) return;
+ function check_date(value) {
+ try {
+ if (! util.date.check('YYYY-MM-DD',value) ) {
+ throw($("patronStrings").getString('staff.patron.items.items_edit.invalid_date'));
+ }
+ if ( util.date.formatted_date(new Date(),'%F') == value) {
+ return true;
+ }
+ if (! util.date.check_past('YYYY-MM-DD',value) ) {
+ throw($("patronStrings").getString('staff.patron.items.items_claimed_returned.date_cannot_be_in_future'));
+ }
+ return true;
+ } catch(E) {
+ alert(E);
+ return false;
+ }
+ }
+
+ JSAN.use('util.functional');
+ var title = $("patronStrings").getString('staff.patron.items.items_claimed_returned.claimed_returned');
+ var value = 'YYYY-MM-DD';
+ var text = $("patronStrings").getFormattedString('staff.patron.items.items_claimed_returned.enter_returned_date',
+ [util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ')]);
+ var backdate; var invalid = true;
+ while(invalid) {
+ backdate = window.prompt(text,value,title);
+ if (backdate) {
+ invalid = ! check_date(backdate);
+ } else {
+ invalid = false;
}
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_edit.items_not_marked_lost'),E);
- }
- },
-
- 'items_claimed_returned' : function(which) {
- var obj = this;
- try {
- JSAN.use('util.date');
- var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
- if (!retrieve_ids || retrieve_ids.length == 0) return;
- function check_date(value) {
- try {
- if (! util.date.check('YYYY-MM-DD',value) ) {
- throw($("patronStrings").getString('staff.patron.items.items_edit.invalid_date'));
- }
- if ( util.date.formatted_date(new Date(),'%F') == value) {
- return true;
- }
- if (! util.date.check_past('YYYY-MM-DD',value) ) {
- throw($("patronStrings").getString('staff.patron.items.items_claimed_returned.date_cannot_be_in_future'));
- }
- return true;
- } catch(E) {
- alert(E);
- return false;
- }
- }
-
- JSAN.use('util.functional');
- var title = $("patronStrings").getString('staff.patron.items.items_claimed_returned.claimed_returned');
- var value = 'YYYY-MM-DD';
- var text = $("patronStrings").getFormattedString('staff.patron.items.items_claimed_returned.enter_returned_date',
- [util.functional.map_list(retrieve_ids,function(o){return o.barcode;}).join(', ')]);
- var backdate; var invalid = true;
- while(invalid) {
- backdate = window.prompt(text,value,title);
- if (backdate) {
- invalid = ! check_date(backdate);
- } else {
- invalid = false;
- }
- }
- //alert('backdate = ' + backdate);
- if (backdate) {
- backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
- var barcodes = util.functional.map_list(retrieve_ids,function(o){return o.barcode;});
+ }
+ //alert('backdate = ' + backdate);
+ if (backdate) {
+ backdate = util.date.formatted_date(backdate + ' 00:00:00','%{iso8601}');
+ var barcodes = util.functional.map_list(retrieve_ids,function(o){return o.barcode;});
var do_not_move_these = {};
- for (var i = 0; i < barcodes.length; i++) {
- var robj = obj.network.simple_request(
- 'MARK_ITEM_CLAIM_RETURNED',
- [ ses(), { barcode: barcodes[i], backdate: backdate } ],
+ for (var i = 0; i < barcodes.length; i++) {
+ var robj = obj.network.simple_request(
+ 'MARK_ITEM_CLAIM_RETURNED',
+ [ ses(), { barcode: barcodes[i], backdate: backdate } ],
null,
{
'title' : $("patronStrings").getString('staff.patron.items.set_claim_returned_failure'),
'PATRON_EXCEEDS_CLAIMS_RETURN_COUNT'
]
}
- );
- if (typeof robj.ilsevent != 'undefined') {
+ );
+ if (typeof robj.ilsevent != 'undefined') {
if (robj.ilsevent != 0 && robj.textcode != 'PATRON_EXCEEDS_CLAIMS_RETURN_COUNT' ) {
do_not_move_these[ barcodes[i] ] = true;
obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_claimed_returned.not_marked_claimed_returned'),E);
do_not_move_these[ barcodes[i] ] = true;
}
}
- }
- }
- for (var i = 0; i < retrieve_ids.length; i++) {
+ }
+ }
+ for (var i = 0; i < retrieve_ids.length; i++) {
obj.refresh(retrieve_ids[i].circ_id, !do_not_move_these[ retrieve_ids[i].barcode ]);
}
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_claimed_returned.not_marked_claimed_returned'),E);
- }
- },
-
- 'items_checkin' : function(which) {
- var obj = this;
- try {
- var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
- if (!retrieve_ids || retrieve_ids.length == 0) return;
- JSAN.use('util.functional');
- var msg = '';
- if (retrieve_ids.length > 1) {
- msg += $("patronStrings").getFormattedString('staff.patron.items.items_checkin.confirm_item_check_in.plural',
- [util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ')]);
- } else {
- msg += $("patronStrings").getFormattedString('staff.patron.items.items_checkin.confirm_item_check_in.singular',
- [util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ')]);
- }
- var r = window.confirm(msg);
- if (!r) { return; }
- JSAN.use('circ.util');
- for (var i = 0; i < retrieve_ids.length; i++) {
- var copy_id = retrieve_ids[i].copy_id;
- dump('Check in copy_id = ' + copy_id + ' barcode = ' + retrieve_ids[i].barcode + '\n');
- var robj = circ.util.checkin_via_barcode(
- ses(), { 'copy_id' : copy_id }
- );
- /* circ.util.checkin_via_barcode handles errors currently */
- }
- obj.retrieve();
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_checkin.no_checkin'),E);
- }
- },
-
- 'show_catalog' : function(which) {
- var obj = this;
- try {
- var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
- if (!retrieve_ids || retrieve_ids.length == 0) return;
- for (var i = 0; i < retrieve_ids.length; i++) {
- var doc_id = retrieve_ids[i].doc_id;
- if (!doc_id) {
- alert($("patronStrings").getFormattedString('staff.patron.items.show_catalog.barcode_not_cataloged', [retrieve_ids[i].barcode]));
- continue;
- }
- var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id;
- var content_params = {
- 'session' : ses(),
- 'authtime' : ses('authtime'),
- 'opac_url' : opac_url
- };
- xulG.new_tab(
- xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
- {'tab_name': $("patronStrings").getString('staff.patron.items.show_catalog.retrieving_title')},
- content_params
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('',E);
- }
- },
-
- 'add_billing' : function(which) {
- var obj = this;
- try {
- var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
- if (!retrieve_ids || retrieve_ids.length == 0) return;
- JSAN.use('util.window'); var win = new util.window();
- for (var i = 0; i < retrieve_ids.length; i++) {
- var circ_id = retrieve_ids[i].circ_id;
- var my_xulG = win.open(
- urls.XUL_PATRON_BILL_WIZARD,
- //+ '?patron_id=' + window.escape(obj.patron_id)
- //+ '&xact_id=' + window.escape( circ_id ),
- 'billwizard',
- 'chrome,resizable,modal',
- { 'patron_id' : obj.patron_id, 'xact_id' : circ_id }
- );
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert('',E);
- }
- },
-
- 'init_lists' : function() {
- var obj = this;
-
- JSAN.use('circ.util');
- var columns = circ.util.columns(
- {
- 'barcode' : { 'hidden' : false },
- 'checkout_lib' : { 'hidden' : false },
- 'circ_lib' : { 'hidden' : false },
- 'title' : { 'hidden' : false, 'flex' : '3' },
- 'due_date' : { 'hidden' : false },
- 'renewal_remaining' : { 'hidden' : false },
- 'stop_fines' : { 'hidden' : false }
- }
- );
- var columns2 = circ.util.columns(
- {
- 'barcode' : { 'hidden' : false },
- 'checkout_lib' : { 'hidden' : false },
- 'circ_lib' : { 'hidden' : false },
- 'title' : { 'hidden' : false, 'flex' : '3' },
- 'checkin_time' : { 'hidden' : false },
- 'stop_fines' : { 'hidden' : false }
- }
- );
-
- function retrieve_row(params) {
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_claimed_returned.not_marked_claimed_returned'),E);
+ }
+ },
+
+ 'items_checkin' : function(which) {
+ var obj = this;
+ try {
+ var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
+ if (!retrieve_ids || retrieve_ids.length == 0) return;
+ JSAN.use('util.functional');
+ var msg = '';
+ if (retrieve_ids.length > 1) {
+ msg += $("patronStrings").getFormattedString('staff.patron.items.items_checkin.confirm_item_check_in.plural',
+ [util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ')]);
+ } else {
+ msg += $("patronStrings").getFormattedString('staff.patron.items.items_checkin.confirm_item_check_in.singular',
+ [util.functional.map_list( retrieve_ids, function(o){return o.barcode;}).join(', ')]);
+ }
+ var r = window.confirm(msg);
+ if (!r) { return; }
+ JSAN.use('circ.util');
+ for (var i = 0; i < retrieve_ids.length; i++) {
+ var copy_id = retrieve_ids[i].copy_id;
+ dump('Check in copy_id = ' + copy_id + ' barcode = ' + retrieve_ids[i].barcode + '\n');
+ var robj = circ.util.checkin_via_barcode(
+ ses(), { 'copy_id' : copy_id }
+ );
+ /* circ.util.checkin_via_barcode handles errors currently */
+ }
+ obj.retrieve();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.items_checkin.no_checkin'),E);
+ }
+ },
+
+ 'show_catalog' : function(which) {
+ var obj = this;
+ try {
+ var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
+ if (!retrieve_ids || retrieve_ids.length == 0) return;
+ for (var i = 0; i < retrieve_ids.length; i++) {
+ var doc_id = retrieve_ids[i].doc_id;
+ if (!doc_id) {
+ alert($("patronStrings").getFormattedString('staff.patron.items.show_catalog.barcode_not_cataloged', [retrieve_ids[i].barcode]));
+ continue;
+ }
+ var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + doc_id;
+ var content_params = {
+ 'session' : ses(),
+ 'authtime' : ses('authtime'),
+ 'opac_url' : opac_url
+ };
+ xulG.new_tab(
+ xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
+ {'tab_name': $("patronStrings").getString('staff.patron.items.show_catalog.retrieving_title')},
+ content_params
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('',E);
+ }
+ },
+
+ 'add_billing' : function(which) {
+ var obj = this;
+ try {
+ var retrieve_ids = ( which == 2 ? obj.retrieve_ids2 : obj.retrieve_ids );
+ if (!retrieve_ids || retrieve_ids.length == 0) return;
+ JSAN.use('util.window'); var win = new util.window();
+ for (var i = 0; i < retrieve_ids.length; i++) {
+ var circ_id = retrieve_ids[i].circ_id;
+ var my_xulG = win.open(
+ urls.XUL_PATRON_BILL_WIZARD,
+ //+ '?patron_id=' + window.escape(obj.patron_id)
+ //+ '&xact_id=' + window.escape( circ_id ),
+ 'billwizard',
+ 'chrome,resizable,modal',
+ { 'patron_id' : obj.patron_id, 'xact_id' : circ_id }
+ );
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('',E);
+ }
+ },
+
+ 'init_lists' : function() {
+ var obj = this;
+
+ JSAN.use('circ.util');
+ var columns = circ.util.columns(
+ {
+ 'barcode' : { 'hidden' : false },
+ 'checkout_lib' : { 'hidden' : false },
+ 'circ_lib' : { 'hidden' : false },
+ 'title' : { 'hidden' : false, 'flex' : '3' },
+ 'due_date' : { 'hidden' : false },
+ 'renewal_remaining' : { 'hidden' : false },
+ 'stop_fines' : { 'hidden' : false }
+ }
+ );
+ var columns2 = circ.util.columns(
+ {
+ 'barcode' : { 'hidden' : false },
+ 'checkout_lib' : { 'hidden' : false },
+ 'circ_lib' : { 'hidden' : false },
+ 'title' : { 'hidden' : false, 'flex' : '3' },
+ 'checkin_time' : { 'hidden' : false },
+ 'stop_fines' : { 'hidden' : false }
+ }
+ );
+
+ function retrieve_row(params) {
try {
- var row = params.row;
+ var row = params.row;
- if (!row.my.circ_id) {
- if (typeof params.on_retrieve == 'function') {
+ if (!row.my.circ_id) {
+ if (typeof params.on_retrieve == 'function') {
params.on_retrieve(row);
}
- return row;
- }
+ return row;
+ }
- if (!row.my.circ) {
- obj.network.simple_request(
- 'FM_CIRC_DETAILS.authoritative',
- [ row.my.circ_id ],
- function(req) {
- try {
- var robj = req.getResultObject();
- if (typeof robj.ilsevent != 'undefined') throw(robj);
- if (typeof robj.ilsevent == 'null') throw('null result');
- row.my.circ = robj.circ;
- row.my.acp = robj.copy;
- row.my.mvr = robj.mvr;
- row.my.acn = robj.volume;
+ if (!row.my.circ) {
+ obj.network.simple_request(
+ 'FM_CIRC_DETAILS.authoritative',
+ [ row.my.circ_id ],
+ function(req) {
+ try {
+ var robj = req.getResultObject();
+ if (typeof robj.ilsevent != 'undefined') throw(robj);
+ if (typeof robj.ilsevent == 'null') throw('null result');
+ row.my.circ = robj.circ;
+ row.my.acp = robj.copy;
+ row.my.mvr = robj.mvr;
+ row.my.acn = robj.volume;
row.my.record = robj.record;
-
- var copy_id = row.my.circ.target_copy();
- if (typeof copy_id == 'object') {
- if (copy_id != null) {
- copy_id = copy_id.id();
- } else {
- if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id();
- }
- } else {
- if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id();
- }
-
- params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':copy_id,'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': ( row.my.record ? row.my.record.id() : null ) }) );
-
- if (typeof params.on_retrieve == 'function') {
- params.on_retrieve(row);
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve_row.callback_error'), E);
- }
- }
- );
- } else {
+
+ var copy_id = row.my.circ.target_copy();
+ if (typeof copy_id == 'object') {
+ if (copy_id != null) {
+ copy_id = copy_id.id();
+ } else {
+ if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id();
+ }
+ } else {
+ if (typeof robj.copy == 'object' && robj.copy != null) copy_id = robj.copy.id();
+ }
+
+ params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':copy_id,'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': ( row.my.record ? row.my.record.id() : null ) }) );
+
+ if (typeof params.on_retrieve == 'function') {
+ params.on_retrieve(row);
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve_row.callback_error'), E);
+ }
+ }
+ );
+ } else {
var copy_id = row.my.circ ? row.my.circ.target_copy() : null;
- if (typeof copy_id == 'object') {
- if (copy_id != null) {
- copy_id = copy_id.id();
- } else {
- if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
- }
- } else {
- if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
- }
+ if (typeof copy_id == 'object') {
+ if (copy_id != null) {
+ copy_id = copy_id.id();
+ } else {
+ if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
+ }
+ } else {
+ if (typeof row.my.acp == 'object' && row.my.acp != null) copy_id = row.my.acp.id();
+ }
- params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':row.my.acp.id(),'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': (row.my.record ? row.my.record.id() : null) }) );
- if (typeof params.on_retrieve == 'function') {
- params.on_retrieve(row);
- }
- }
+ params.row_node.setAttribute( 'retrieve_id', js2JSON({'copy_id':row.my.acp.id(),'circ_id':row.my.circ.id(),'barcode':row.my.acp.barcode(),'doc_id': (row.my.record ? row.my.record.id() : null) }) );
+ if (typeof params.on_retrieve == 'function') {
+ params.on_retrieve(row);
+ }
+ }
- return row;
+ return row;
} catch(E) {
obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve_row.error_in_retrieve_row'),E);
return params.row;
}
- }
-
- JSAN.use('util.list'); obj.list = new util.list('items_list');
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
- 'retrieve_row' : retrieve_row,
- 'on_select' : function(ev) {
- JSAN.use('util.functional');
- var sel = obj.list.retrieve_selection();
- obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
- var list = util.functional.map_list(
- sel,
- function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
- );
- if (typeof obj.on_select == 'function') {
- obj.on_select(list);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
- obj.error.sdump('D_PATRON','patron.items: Calling external .on_select()\n');
- window.xulG.on_select(list);
- } else {
- obj.error.sdump('D_PATRON','patron.items: No external .on_select()\n');
- }
- }
- }
- );
-
- obj.list2 = new util.list('items_list2');
- obj.list2.init(
- {
- 'columns' : columns2,
- 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
- 'retrieve_row' : retrieve_row,
- 'on_select' : function(ev) {
- JSAN.use('util.functional');
- var sel = obj.list2.retrieve_selection();
- obj.controller.view.sel_clip2.setAttribute('disabled',sel.length < 1);
- var list = util.functional.map_list(
- sel,
- function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
- );
- if (typeof obj.on_select2 == 'function') {
- obj.on_select2(list);
- }
- }
- }
- );
- },
-
- 'refresh' : function(circ_id,move_to_bottom_list) {
- var obj = this;
- try {
- var nparams = obj.list_circ_map[circ_id];
+ }
+
+ JSAN.use('util.list'); obj.list = new util.list('items_list');
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'retrieve_row' : retrieve_row,
+ 'on_select' : function(ev) {
+ JSAN.use('util.functional');
+ var sel = obj.list.retrieve_selection();
+ obj.controller.view.sel_clip.setAttribute('disabled',sel.length < 1);
+ var list = util.functional.map_list(
+ sel,
+ function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
+ );
+ if (typeof obj.on_select == 'function') {
+ obj.on_select(list);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
+ obj.error.sdump('D_PATRON','patron.items: Calling external .on_select()\n');
+ window.xulG.on_select(list);
+ } else {
+ obj.error.sdump('D_PATRON','patron.items: No external .on_select()\n');
+ }
+ }
+ }
+ );
+
+ obj.list2 = new util.list('items_list2');
+ obj.list2.init(
+ {
+ 'columns' : columns2,
+ 'map_row_to_columns' : circ.util.std_map_row_to_columns(),
+ 'retrieve_row' : retrieve_row,
+ 'on_select' : function(ev) {
+ JSAN.use('util.functional');
+ var sel = obj.list2.retrieve_selection();
+ obj.controller.view.sel_clip2.setAttribute('disabled',sel.length < 1);
+ var list = util.functional.map_list(
+ sel,
+ function(o) { return JSON2js( o.getAttribute('retrieve_id') ); }
+ );
+ if (typeof obj.on_select2 == 'function') {
+ obj.on_select2(list);
+ }
+ }
+ }
+ );
+ },
+
+ 'refresh' : function(circ_id,move_to_bottom_list) {
+ var obj = this;
+ try {
+ var nparams = obj.list_circ_map[circ_id];
if (move_to_bottom_list) {
obj.list_circ_map[circ_id].my_node.setAttribute('hidden','true');
- var nparams2 = obj.list2.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : 1 } );
- obj.list_circ_map[circ_id] = nparams2;
+ var nparams2 = obj.list2.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : 1 } );
+ obj.list_circ_map[circ_id] = nparams2;
} else {
- var which_list = nparams.which_list;
+ var which_list = nparams.which_list;
switch(which_list) {
case 1:
- case '1':
+ case '1':
setTimeout(function(){try{obj.list2.refresh_row(nparams);}catch(E){
- obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.refresh.error_refreshing_row2', [circ_id, nparams]),E);}},1000);
+ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.refresh.error_refreshing_row2', [circ_id, nparams]),E);}},1000);
break;
default:
setTimeout(function(){try{obj.list.refresh_row(nparams);}catch(E){
- obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.refresh.error_refreshing_row2', [circ_id, nparams]),E);}},1000);
+ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.refresh.error_refreshing_row2', [circ_id, nparams]),E);}},1000);
+ break;
+ }
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.refresh.error_refreshing_row', [circ_id, nparams]),E);
+ }
+ },
+
+ 'retrieve' : function(dont_show_me_the_list_change) {
+ var obj = this;
+ if (window.xulG && window.xulG.checkouts) {
+ obj.checkouts = window.xulG.checkouts;
+ } else {
+ obj.checkouts = [];
+ obj.checkouts2 = [];
+ var robj = obj.network.simple_request(
+ 'FM_CIRC_RETRIEVE_VIA_USER.authoritative',
+ [ ses(), obj.patron_id ]
+ );
+ if (typeof robj.ilsevent!='undefined') {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve.err_retrieving_circulations'),E);
+ } else {
+ obj.checkouts = obj.checkouts.concat( robj.overdue );
+ obj.checkouts = obj.checkouts.concat( robj.out );
+ obj.checkouts2 = obj.checkouts2.concat( robj.lost );
+ obj.checkouts2 = obj.checkouts2.concat( robj.claims_returned );
+ obj.checkouts2 = obj.checkouts2.concat( robj.long_overdue );
+ }
+ var robj = obj.network.simple_request(
+ 'FM_CIRC_IN_WITH_FINES_VIA_USER.authoritative',
+ [ ses(), obj.patron_id ]
+ );
+ if (typeof robj.ilsevent!='undefined') {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve.err_retrieving_circulations'),E);
+ } else {
+ obj.checkouts2 = obj.checkouts2.concat( robj.lost );
+ obj.checkouts2 = obj.checkouts2.concat( robj.claims_returned );
+ obj.checkouts2 = obj.checkouts2.concat( robj.long_overdue );
+ }
+ }
+
+ function gen_list_append(circ_id,which_list) {
+ return function() {
+ try {
+ var nparams;
+ switch(which_list) {
+ case 1:
+ nparams = obj.list2.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : which_list } );
break;
+ default:
+ nparams = obj.list.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : which_list } );
+ break;
+ }
+ if (nparams) {
+ obj.list_circ_map[circ_id] = nparams; // unlike item status interface, each circ should be in this list only once
+ } else {
+ throw('typeof nparams = ' + typeof nparams);
+ }
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.gen_list_append.error'),E);
}
+ };
+ }
+
+ obj.list.clear(); obj.list2.clear();
+
+ JSAN.use('util.exec'); var exec = new util.exec();
+ var rows = [];
+ for (var i in obj.checkouts) {
+ rows.push( gen_list_append(obj.checkouts[i],0) );
+ }
+ for (var i in obj.checkouts2) {
+ rows.push( gen_list_append(obj.checkouts2[i],1) );
+ }
+ exec.chain( rows );
+ if (!dont_show_me_the_list_change) {
+ if (window.xulG && typeof window.xulG.on_list_change == 'function') {
+ try { window.xulG.on_list_change(obj.checkouts); } catch(E) { this.error.sdump('D_ERROR',E); }
}
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getFormattedString('staff.patron.items.refresh.error_refreshing_row', [circ_id, nparams]),E);
- }
- },
-
- 'retrieve' : function(dont_show_me_the_list_change) {
- var obj = this;
- if (window.xulG && window.xulG.checkouts) {
- obj.checkouts = window.xulG.checkouts;
- } else {
- obj.checkouts = [];
- obj.checkouts2 = [];
- var robj = obj.network.simple_request(
- 'FM_CIRC_RETRIEVE_VIA_USER.authoritative',
- [ ses(), obj.patron_id ]
- );
- if (typeof robj.ilsevent!='undefined') {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve.err_retrieving_circulations'),E);
- } else {
- obj.checkouts = obj.checkouts.concat( robj.overdue );
- obj.checkouts = obj.checkouts.concat( robj.out );
- obj.checkouts2 = obj.checkouts2.concat( robj.lost );
- obj.checkouts2 = obj.checkouts2.concat( robj.claims_returned );
- obj.checkouts2 = obj.checkouts2.concat( robj.long_overdue );
- }
- var robj = obj.network.simple_request(
- 'FM_CIRC_IN_WITH_FINES_VIA_USER.authoritative',
- [ ses(), obj.patron_id ]
- );
- if (typeof robj.ilsevent!='undefined') {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.retrieve.err_retrieving_circulations'),E);
- } else {
- obj.checkouts2 = obj.checkouts2.concat( robj.lost );
- obj.checkouts2 = obj.checkouts2.concat( robj.claims_returned );
- obj.checkouts2 = obj.checkouts2.concat( robj.long_overdue );
- }
- }
-
- function gen_list_append(circ_id,which_list) {
- return function() {
- try {
- var nparams;
- switch(which_list) {
- case 1:
- nparams = obj.list2.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : which_list } );
- break;
- default:
- nparams = obj.list.append( { 'row' : { 'my' : { 'circ_id' : circ_id } }, 'to_bottom' : true, 'which_list' : which_list } );
- break;
- }
- if (nparams) {
- obj.list_circ_map[circ_id] = nparams; // unlike item status interface, each circ should be in this list only once
- } else {
- throw('typeof nparams = ' + typeof nparams);
- }
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.items.gen_list_append.error'),E);
- }
- };
- }
-
- obj.list.clear(); obj.list2.clear();
-
- JSAN.use('util.exec'); var exec = new util.exec();
- var rows = [];
- for (var i in obj.checkouts) {
- rows.push( gen_list_append(obj.checkouts[i],0) );
- }
- for (var i in obj.checkouts2) {
- rows.push( gen_list_append(obj.checkouts2[i],1) );
- }
- exec.chain( rows );
- if (!dont_show_me_the_list_change) {
- if (window.xulG && typeof window.xulG.on_list_change == 'function') {
- try { window.xulG.on_list_change(obj.checkouts); } catch(E) { this.error.sdump('D_ERROR',E); }
- }
- }
- },
-
- 'on_select' : function(list) {
-
- dump('patron.items.on_select list = ' + js2JSON(list) + '\n');
-
- var obj = this;
-
- obj.controller.view.cmd_items_claimed_returned.setAttribute('disabled','false');
- obj.controller.view.cmd_items_renew.setAttribute('disabled','false');
- obj.controller.view.cmd_items_checkin.setAttribute('disabled','false');
- obj.controller.view.cmd_items_edit.setAttribute('disabled','false');
- obj.controller.view.cmd_items_mark_lost.setAttribute('disabled','false');
- obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
- obj.controller.view.sel_copy_details.setAttribute('disabled','false');
- obj.controller.view.sel_bucket.setAttribute('disabled','false');
- obj.controller.view.sel_patron.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
-
- obj.retrieve_ids = list;
- },
-
- 'on_select2' : function(list) {
-
- dump('patron.items.on_select2 list = ' + js2JSON(list) + '\n');
-
- var obj = this;
-
- obj.controller.view.cmd_items_claimed_returned2.setAttribute('disabled','false');
- obj.controller.view.cmd_items_renew2.setAttribute('disabled','false');
- obj.controller.view.cmd_items_checkin2.setAttribute('disabled','false');
- obj.controller.view.cmd_items_edit2.setAttribute('disabled','false');
- obj.controller.view.cmd_items_mark_lost2.setAttribute('disabled','false');
- obj.controller.view.cmd_show_catalog2.setAttribute('disabled','false');
- obj.controller.view.sel_copy_details2.setAttribute('disabled','false');
- obj.controller.view.sel_bucket2.setAttribute('disabled','false');
- obj.controller.view.sel_patron2.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_damaged2.setAttribute('disabled','false');
- obj.controller.view.sel_mark_items_missing2.setAttribute('disabled','false');
-
- this.retrieve_ids2 = list;
- }
+ }
+ },
+
+ 'on_select' : function(list) {
+
+ dump('patron.items.on_select list = ' + js2JSON(list) + '\n');
+
+ var obj = this;
+
+ obj.controller.view.cmd_items_claimed_returned.setAttribute('disabled','false');
+ obj.controller.view.cmd_items_renew.setAttribute('disabled','false');
+ obj.controller.view.cmd_items_checkin.setAttribute('disabled','false');
+ obj.controller.view.cmd_items_edit.setAttribute('disabled','false');
+ obj.controller.view.cmd_items_mark_lost.setAttribute('disabled','false');
+ obj.controller.view.cmd_show_catalog.setAttribute('disabled','false');
+ obj.controller.view.sel_copy_details.setAttribute('disabled','false');
+ obj.controller.view.sel_bucket.setAttribute('disabled','false');
+ obj.controller.view.sel_patron.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_damaged.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_missing.setAttribute('disabled','false');
+
+ obj.retrieve_ids = list;
+ },
+
+ 'on_select2' : function(list) {
+
+ dump('patron.items.on_select2 list = ' + js2JSON(list) + '\n');
+
+ var obj = this;
+
+ obj.controller.view.cmd_items_claimed_returned2.setAttribute('disabled','false');
+ obj.controller.view.cmd_items_renew2.setAttribute('disabled','false');
+ obj.controller.view.cmd_items_checkin2.setAttribute('disabled','false');
+ obj.controller.view.cmd_items_edit2.setAttribute('disabled','false');
+ obj.controller.view.cmd_items_mark_lost2.setAttribute('disabled','false');
+ obj.controller.view.cmd_show_catalog2.setAttribute('disabled','false');
+ obj.controller.view.sel_copy_details2.setAttribute('disabled','false');
+ obj.controller.view.sel_bucket2.setAttribute('disabled','false');
+ obj.controller.view.sel_patron2.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_damaged2.setAttribute('disabled','false');
+ obj.controller.view.sel_mark_items_missing2.setAttribute('disabled','false');
+
+ this.retrieve_ids2 = list;
+ }
}
JSAN.errorLevel = "die"; // none, warn, or die
JSAN.addRepository('..');
- JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+ JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
JSAN.use('util.error'); error = new util.error();
JSAN.use('util.widgets');
if (typeof patron == 'undefined') patron = {};
patron.search_form = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- this.w = window;
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ this.w = window;
}
patron.search_form.prototype = {
- 'init' : function( params ) {
+ 'init' : function( params ) {
- var obj = this;
+ var obj = this;
// The bulk of params.query is getting parsed/rendered by obj.controller.init below, and will be reconstituted from possibly modified XUL elements upon Submit.
// But we're going to let search_limit and search_sort be configurable now by those spawning this interface, and let's assume there are no corresponding widgets for now.
obj.search_limit = params.query.search_limit;
obj.search_sort = JSON2js( params.query.search_sort ); // Let's assume this is encoded as JSON
- JSAN.use('OpenILS.data'); this.OpenILS = {};
- obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
+ JSAN.use('OpenILS.data'); this.OpenILS = {};
+ obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'cmd_broken' : [
- ['command'],
- function() { alert($("commonStrings").getString('common.unimplemented')); }
- ],
- 'cmd_patron_search_submit' : [
- ['command'],
- function() {
- obj.submit();
- }
- ],
- 'cmd_patron_search_clear' : [
- ['command'],
- function() {
- obj.controller.render();
- window.xulG.clear_left_deck();
- }
- ],
- 'family_name' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.family_name) {
- e.setAttribute('value',params.query.family_name);
- e.value = params.query.family_name;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'first_given_name' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.first_given_name) {
- e.setAttribute('value',params.query.first_given_name);
- e.value = params.query.first_given_name;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'second_given_name' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.second_given_name) {
- e.setAttribute('value',params.query.second_given_name);
- e.value = params.query.second_given_name;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'alias' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.alias) {
- e.setAttribute('value',params.query.alias);
- e.value = params.query.alias;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'usrname' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.usrname) {
- e.setAttribute('value',params.query.usrname);
- e.value = params.query.usrname;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'card' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.card) {
- e.setAttribute('value',params.query.card);
- e.value = params.query.card;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'email' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.email) {
- e.setAttribute('value',params.query.email);
- e.value = params.query.email;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'phone' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.phone) {
- e.setAttribute('value',params.query.phone);
- e.value = params.query.phone;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'ident' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.ident) {
- e.setAttribute('value',params.query.ident);
- e.value = params.query.ident;
- } else if (params.query&¶ms.query.ident_value) {
- e.setAttribute('value',params.query.ident_value);
- e.value = params.query.ident_value;
- } else if (params.query&¶ms.query.ident_value2) {
- e.setAttribute('value',params.query.ident_value2);
- e.value = params.query.ident_value2;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'street1' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.street1) {
- e.setAttribute('value',params.query.street1);
- e.value = params.query.street1;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'street2' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.street2) {
- e.setAttribute('value',params.query.street2);
- e.value = params.query.street2;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'city' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.city) {
- e.setAttribute('value',params.query.city);
- e.value = params.query.city;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'state' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.state) {
- e.setAttribute('value',params.query.state);
- e.value = params.query.state;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'post_code' : [
- ['render'],
- function(e) {
- return function() {
- if (params.query&¶ms.query.post_code) {
- e.setAttribute('value',params.query.post_code);
- e.value = params.query.post_code;
- } else {
- e.value = '';
- }
- };
- }
- ],
- 'inactive' : [ ['render'], function(e) {
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert($("commonStrings").getString('common.unimplemented')); }
+ ],
+ 'cmd_patron_search_submit' : [
+ ['command'],
+ function() {
+ obj.submit();
+ }
+ ],
+ 'cmd_patron_search_clear' : [
+ ['command'],
+ function() {
+ obj.controller.render();
+ window.xulG.clear_left_deck();
+ }
+ ],
+ 'family_name' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.family_name) {
+ e.setAttribute('value',params.query.family_name);
+ e.value = params.query.family_name;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'first_given_name' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.first_given_name) {
+ e.setAttribute('value',params.query.first_given_name);
+ e.value = params.query.first_given_name;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'second_given_name' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.second_given_name) {
+ e.setAttribute('value',params.query.second_given_name);
+ e.value = params.query.second_given_name;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'alias' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.alias) {
+ e.setAttribute('value',params.query.alias);
+ e.value = params.query.alias;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'usrname' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.usrname) {
+ e.setAttribute('value',params.query.usrname);
+ e.value = params.query.usrname;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'card' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.card) {
+ e.setAttribute('value',params.query.card);
+ e.value = params.query.card;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'email' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.email) {
+ e.setAttribute('value',params.query.email);
+ e.value = params.query.email;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'phone' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.phone) {
+ e.setAttribute('value',params.query.phone);
+ e.value = params.query.phone;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'ident' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.ident) {
+ e.setAttribute('value',params.query.ident);
+ e.value = params.query.ident;
+ } else if (params.query&¶ms.query.ident_value) {
+ e.setAttribute('value',params.query.ident_value);
+ e.value = params.query.ident_value;
+ } else if (params.query&¶ms.query.ident_value2) {
+ e.setAttribute('value',params.query.ident_value2);
+ e.value = params.query.ident_value2;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'street1' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.street1) {
+ e.setAttribute('value',params.query.street1);
+ e.value = params.query.street1;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'street2' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.street2) {
+ e.setAttribute('value',params.query.street2);
+ e.value = params.query.street2;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'city' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.city) {
+ e.setAttribute('value',params.query.city);
+ e.value = params.query.city;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'state' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.state) {
+ e.setAttribute('value',params.query.state);
+ e.value = params.query.state;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'post_code' : [
+ ['render'],
+ function(e) {
+ return function() {
+ if (params.query&¶ms.query.post_code) {
+ e.setAttribute('value',params.query.post_code);
+ e.value = params.query.post_code;
+ } else {
+ e.value = '';
+ }
+ };
+ }
+ ],
+ 'inactive' : [ ['render'], function(e) {
return function() {};
}
],
return function() {};
}
],
- }
- }
- );
+ }
+ }
+ );
- obj.controller.render();
- var nl = document.getElementsByTagName('textbox');
- for (var i = 0; i < nl.length; i++) {
- nl[i].addEventListener('keypress',function(ev){
- if (ev.target.tagName != 'textbox') return;
- if (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* enter on a mac */) setTimeout( function() { obj.submit(); }, 0);
- },false);
- }
- document.getElementById('family_name').focus();
+ obj.controller.render();
+ var nl = document.getElementsByTagName('textbox');
+ for (var i = 0; i < nl.length; i++) {
+ nl[i].addEventListener('keypress',function(ev){
+ if (ev.target.tagName != 'textbox') return;
+ if (ev.keyCode == 13 /* enter */ || ev.keyCode == 77 /* enter on a mac */) setTimeout( function() { obj.submit(); }, 0);
+ },false);
+ }
+ document.getElementById('family_name').focus();
JSAN.use('util.file'); JSAN.use('util.widgets'); JSAN.use('util.functional');
util.widgets.remove_children(obj.controller.view.search_depth);
ml.setAttribute('id','search_depth_ml');
obj.controller.view.search_depth.appendChild(ml);
- var file = new util.file('patron_search_prefs.'+obj.OpenILS.data.server_unadorned);
- util.widgets.load_attributes(file);
- ml.value = ml.getAttribute('value');
- if (! ml.value) {
- ml.value = 0
- ml.setAttribute('value',ml.value);
- }
+ var file = new util.file('patron_search_prefs.'+obj.OpenILS.data.server_unadorned);
+ util.widgets.load_attributes(file);
+ ml.value = ml.getAttribute('value');
+ if (! ml.value) {
+ ml.value = 0
+ ml.setAttribute('value',ml.value);
+ }
var cb = obj.controller.view.inactive;
cb.addEventListener('command',function() {
);
cb.checked = cb.getAttribute('value') == "true" ? true : false;
- },
+ },
- 'on_submit' : function(q) {
- var msg = 'Query = ' + q;
- this.error.sdump('D_PATRON', msg);
- },
+ 'on_submit' : function(q) {
+ var msg = 'Query = ' + q;
+ this.error.sdump('D_PATRON', msg);
+ },
- 'submit' : function() {
- window.xulG.clear_left_deck();
- var obj = this;
- var query = {};
- for (var i = 0; i < obj.controller.render_list.length; i++) {
- var id = obj.controller.render_list[i][0];
- var node = document.getElementById(id);
- if (node && node.value != '') {
- if (id == 'inactive') {
- query[id] = node.getAttribute('value');
- obj.error.sdump('D_DEBUG','id = ' + id + ' value = ' + node.getAttribute('value') + '\n');
+ 'submit' : function() {
+ window.xulG.clear_left_deck();
+ var obj = this;
+ var query = {};
+ for (var i = 0; i < obj.controller.render_list.length; i++) {
+ var id = obj.controller.render_list[i][0];
+ var node = document.getElementById(id);
+ if (node && node.value != '') {
+ if (id == 'inactive') {
+ query[id] = node.getAttribute('value');
+ obj.error.sdump('D_DEBUG','id = ' + id + ' value = ' + node.getAttribute('value') + '\n');
} else {
if (id == 'search_depth') {
query[id] = node.firstChild.getAttribute('value');
- } else {
- var value = node.value.replace(/^\s+/,'').replace(/[\\\s]+$/,'');
- //value = value.replace(/\d/g,'');
- switch(id) {
- case 'family_name' :
- case 'first_given_name' :
- case 'second_given_name' :
- value = value.replace(/^[\d\s]+/g,'').replace(/[\d\s]+$/g,'')
- break;
- }
- if (value != '') {
- query[id] = value;
- obj.error.sdump('D_DEBUG','id = ' + id + ' value = ' + value + '\n');
- }
- }
+ } else {
+ var value = node.value.replace(/^\s+/,'').replace(/[\\\s]+$/,'');
+ //value = value.replace(/\d/g,'');
+ switch(id) {
+ case 'family_name' :
+ case 'first_given_name' :
+ case 'second_given_name' :
+ value = value.replace(/^[\d\s]+/g,'').replace(/[\d\s]+$/g,'')
+ break;
+ }
+ if (value != '') {
+ query[id] = value;
+ obj.error.sdump('D_DEBUG','id = ' + id + ' value = ' + value + '\n');
+ }
+ }
}
- }
- }
- if (typeof obj.on_submit == 'function') {
- obj.on_submit(query,obj.search_limit,obj.search_sort);
- }
- if (typeof window.xulG == 'object'
- && typeof window.xulG.on_submit == 'function') {
- obj.error.sdump('D_PATRON','patron.search_form: Calling external .on_submit()\n');
- window.xulG.on_submit(query,obj.search_limit,obj.search_sort);
- } else {
- obj.error.sdump('D_PATRON','patron.search_form: No external .on_query()\n');
- }
- },
+ }
+ }
+ if (typeof obj.on_submit == 'function') {
+ obj.on_submit(query,obj.search_limit,obj.search_sort);
+ }
+ if (typeof window.xulG == 'object'
+ && typeof window.xulG.on_submit == 'function') {
+ obj.error.sdump('D_PATRON','patron.search_form: Calling external .on_submit()\n');
+ window.xulG.on_submit(query,obj.search_limit,obj.search_sort);
+ } else {
+ obj.error.sdump('D_PATRON','patron.search_form: No external .on_query()\n');
+ }
+ },
}
if (typeof patron == 'undefined') patron = {};
patron.search_result = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.network'); this.network = new util.network();
- this.w = window;
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.network'); this.network = new util.network();
+ this.w = window;
}
patron.search_result.prototype = {
- 'result_cap' : 50,
+ 'result_cap' : 50,
- 'init' : function( params ) {
+ 'init' : function( params ) {
- var obj = this;
+ var obj = this;
- obj.query = params['query'];
+ obj.query = params['query'];
obj.search_limit = params['search_limit'];
obj.search_sort = params['search_sort'];
- JSAN.use('OpenILS.data'); this.OpenILS = {};
- obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
+ JSAN.use('OpenILS.data'); this.OpenILS = {};
+ obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
var obscure_dob = String( obj.OpenILS.data.hash.aous['circ.obscure_dob'] ) == 'true';
- JSAN.use('util.list'); obj.list = new util.list('patron_list');
-
- JSAN.use('patron.util');
- var columns = patron.util.columns(
- {
- /* 'active' : { 'hidden' : 'false' }, */
- 'barred' : { 'hidden' : 'false' },
- 'family_name' : { 'hidden' : 'false' },
- 'first_given_name' : { 'hidden' : 'false' },
- 'second_given_name' : { 'hidden' : 'false' },
- 'dob' : { 'hidden' : obscure_dob }
- },
- {
- 'except_these' : [
- 'barcode',
- ]
- }
- );
- obj.list.init(
- {
- 'columns' : columns,
- 'map_row_to_columns' : patron.util.std_map_row_to_columns(),
- 'retrieve_row' : function(params) {
- var id = params.retrieve_id;
- var au_obj = patron.util.retrieve_au_via_id( ses(), id,
- function(req) {
- try {
- var row = params.row;
- if (typeof row.my == 'undefined') row.my = {};
- row.my.au = req.getResultObject();
- if (typeof params.on_retrieve == 'function') {
- params.on_retrieve(row);
- } else {
- alert($("patronStrings").getFormattedString('staff.patron.search_result.init.typeof_params', [typeof params.on_retrieve]));
- }
- } catch(E) {
- alert('error: ' + E);
- }
- }
- );
- },
- 'on_select' : function(ev) {
- JSAN.use('util.functional');
- var sel = obj.list.retrieve_selection();
- var list = util.functional.map_list(
- sel,
- function(o) { return o.getAttribute('retrieve_id'); }
- );
- obj.controller.view.cmd_sel_clip.setAttribute('disabled', list.length < 1 );
- if (typeof obj.on_select == 'function') {
- obj.on_select(list);
- }
- if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
- obj.error.sdump('D_PATRON','patron.search_result: Calling external .on_select()\n');
- window.xulG.on_select(list);
- } else {
- obj.error.sdump('D_PATRON','patron.search_result: No external .on_select()\n');
- }
- }
- }
- );
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'cmd_broken' : [
- ['command'],
- function() { alert($("commonStrings").getString('common.unimplemented')); }
- ],
- 'cmd_search_print' : [
- ['command'],
- function() {
+ JSAN.use('util.list'); obj.list = new util.list('patron_list');
+
+ JSAN.use('patron.util');
+ var columns = patron.util.columns(
+ {
+ /* 'active' : { 'hidden' : 'false' }, */
+ 'barred' : { 'hidden' : 'false' },
+ 'family_name' : { 'hidden' : 'false' },
+ 'first_given_name' : { 'hidden' : 'false' },
+ 'second_given_name' : { 'hidden' : 'false' },
+ 'dob' : { 'hidden' : obscure_dob }
+ },
+ {
+ 'except_these' : [
+ 'barcode',
+ ]
+ }
+ );
+ obj.list.init(
+ {
+ 'columns' : columns,
+ 'map_row_to_columns' : patron.util.std_map_row_to_columns(),
+ 'retrieve_row' : function(params) {
+ var id = params.retrieve_id;
+ var au_obj = patron.util.retrieve_au_via_id( ses(), id,
+ function(req) {
+ try {
+ var row = params.row;
+ if (typeof row.my == 'undefined') row.my = {};
+ row.my.au = req.getResultObject();
+ if (typeof params.on_retrieve == 'function') {
+ params.on_retrieve(row);
+ } else {
+ alert($("patronStrings").getFormattedString('staff.patron.search_result.init.typeof_params', [typeof params.on_retrieve]));
+ }
+ } catch(E) {
+ alert('error: ' + E);
+ }
+ }
+ );
+ },
+ 'on_select' : function(ev) {
+ JSAN.use('util.functional');
+ var sel = obj.list.retrieve_selection();
+ var list = util.functional.map_list(
+ sel,
+ function(o) { return o.getAttribute('retrieve_id'); }
+ );
+ obj.controller.view.cmd_sel_clip.setAttribute('disabled', list.length < 1 );
+ if (typeof obj.on_select == 'function') {
+ obj.on_select(list);
+ }
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_select == 'function') {
+ obj.error.sdump('D_PATRON','patron.search_result: Calling external .on_select()\n');
+ window.xulG.on_select(list);
+ } else {
+ obj.error.sdump('D_PATRON','patron.search_result: No external .on_select()\n');
+ }
+ }
+ }
+ );
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert($("commonStrings").getString('common.unimplemented')); }
+ ],
+ 'cmd_search_print' : [
+ ['command'],
+ function() {
+ try {
+ var p = {
+ 'template' : 'patron'
+ };
+ obj.list.print( p );
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.search_result.init.search_print'),E);
+ }
+ }
+ ],
+ 'cmd_sel_clip' : [
+ ['command'],
+ function() {
try {
- var p = {
- 'template' : 'patron'
- };
- obj.list.print( p );
+ obj.list.clipboard();
} catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.search_result.init.search_print'),E);
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.search_result.init.search_clipboard'),E);
}
- }
- ],
- 'cmd_sel_clip' : [
- ['command'],
- function() {
- try {
- obj.list.clipboard();
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.search_result.init.search_clipboard'),E);
- }
- }
- ],
- 'cmd_save_cols' : [
- ['command'],
- function() {
- try {
- obj.list.save_columns();
- } catch(E) {
- obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.search_result.init.search_saving_columns'),E);
- }
- }
- ],
- }
- }
- );
-
- if (obj.query) obj.search(obj.query);
- },
-
- 'search' : function(query) {
- var obj = this;
- var search_hash = {};
- obj.search_term_count = 0;
- var inactive = false;
+ }
+ ],
+ 'cmd_save_cols' : [
+ ['command'],
+ function() {
+ try {
+ obj.list.save_columns();
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert($("patronStrings").getString('staff.patron.search_result.init.search_saving_columns'),E);
+ }
+ }
+ ],
+ }
+ }
+ );
+
+ if (obj.query) obj.search(obj.query);
+ },
+
+ 'search' : function(query) {
+ var obj = this;
+ var search_hash = {};
+ obj.search_term_count = 0;
+ var inactive = false;
var search_depth = 0;
- for (var i in query) {
- switch( i ) {
+ for (var i in query) {
+ switch( i ) {
case 'card':
- search_hash[ i ] = {};
- search_hash[ i ].value = query[i];
- search_hash[i].group = 3;
- obj.search_term_count++;
- break;
-
- case 'phone': case 'ident':
-
- search_hash[ i ] = {};
- search_hash[ i ].value = query[i];
- search_hash[i].group = 2;
- obj.search_term_count++;
- break;
-
- case 'street1': case 'street2': case 'city': case 'state': case 'post_code':
-
- search_hash[ i ] = {};
- search_hash[ i ].value = query[i];
- search_hash[i].group = 1;
- obj.search_term_count++;
- break;
-
- case 'family_name': case 'first_given_name': case 'second_given_name': case 'email': case 'alias': case 'usrname':
-
- search_hash[ i ] = {};
- search_hash[ i ].value = query[i];
- search_hash[i].group = 0;
- obj.search_term_count++;
- break;
-
- case 'inactive':
- if (query[i] == 'checked' || query[i] == 'true') inactive = true;
- break;
+ search_hash[ i ] = {};
+ search_hash[ i ].value = query[i];
+ search_hash[i].group = 3;
+ obj.search_term_count++;
+ break;
+
+ case 'phone': case 'ident':
+
+ search_hash[ i ] = {};
+ search_hash[ i ].value = query[i];
+ search_hash[i].group = 2;
+ obj.search_term_count++;
+ break;
+
+ case 'street1': case 'street2': case 'city': case 'state': case 'post_code':
+
+ search_hash[ i ] = {};
+ search_hash[ i ].value = query[i];
+ search_hash[i].group = 1;
+ obj.search_term_count++;
+ break;
+
+ case 'family_name': case 'first_given_name': case 'second_given_name': case 'email': case 'alias': case 'usrname':
+
+ search_hash[ i ] = {};
+ search_hash[ i ].value = query[i];
+ search_hash[i].group = 0;
+ obj.search_term_count++;
+ break;
+
+ case 'inactive':
+ if (query[i] == 'checked' || query[i] == 'true') inactive = true;
+ break;
case 'search_depth':
search_depth = function(a){return a;}(query[i]);
break;
- }
- }
- try {
- var results = [];
+ }
+ }
+ try {
+ var results = [];
- var params = [
+ var params = [
ses(),
search_hash,
typeof obj.search_limit != 'undefined' && typeof obj.search_limit != 'null' ? obj.search_limit : obj.result_cap + 1,
typeof obj.search_sort != 'undefined' ? obj.search_sort : [ 'family_name ASC', 'first_given_name ASC', 'second_given_name ASC', 'dob DESC' ]
];
- if (inactive) {
- params.push(1);
- if (document.getElementById('active')) {
- document.getElementById('active').setAttribute('hidden','false');
- document.getElementById('active').hidden = false;
- }
- } else {
+ if (inactive) {
+ params.push(1);
+ if (document.getElementById('active')) {
+ document.getElementById('active').setAttribute('hidden','false');
+ document.getElementById('active').hidden = false;
+ }
+ } else {
params.push(0);
}
params.push(search_depth);
- if (obj.search_term_count > 0) {
- //alert('search params = ' + obj.error.pretty_print( js2JSON( params ) ) );
- results = this.network.simple_request( 'FM_AU_IDS_RETRIEVE_VIA_HASH', params );
+ if (obj.search_term_count > 0) {
+ //alert('search params = ' + obj.error.pretty_print( js2JSON( params ) ) );
+ results = this.network.simple_request( 'FM_AU_IDS_RETRIEVE_VIA_HASH', params );
if ( results == null ) results = [];
- if (typeof results.ilsevent != 'undefined') throw(results);
- if (results.length == 0) {
- alert($("patronStrings").getString('staff.patron.search_result.search.no_patrons_found'));
- return;
- }
- if (results.length == typeof obj.search_limit != 'undefined' && typeof obj.search_limit != 'null' ? obj.search_limit : obj.result_cap+1) {
- results.pop();
- alert($("patronStrings").getFormattedString('staff.patron.search_result.search.capped_results', [typeof obj.search_limit != 'undefined' && typeof obj.search_limit != 'null' ? obj.search_limit : obj.result_cap]));
- }
- } else {
- alert($("patronStrings").getString('staff.patron.search_result.search.enter_search_terms'));
- return;
- }
+ if (typeof results.ilsevent != 'undefined') throw(results);
+ if (results.length == 0) {
+ alert($("patronStrings").getString('staff.patron.search_result.search.no_patrons_found'));
+ return;
+ }
+ if (results.length == typeof obj.search_limit != 'undefined' && typeof obj.search_limit != 'null' ? obj.search_limit : obj.result_cap+1) {
+ results.pop();
+ alert($("patronStrings").getFormattedString('staff.patron.search_result.search.capped_results', [typeof obj.search_limit != 'undefined' && typeof obj.search_limit != 'null' ? obj.search_limit : obj.result_cap]));
+ }
+ } else {
+ alert($("patronStrings").getString('staff.patron.search_result.search.enter_search_terms'));
+ return;
+ }
obj.list.clear();
- //this.list.append( { 'retrieve_id' : results[i], 'row' : {} } );
- var funcs = [];
-
- function gen_func(r) {
- return function() {
- obj.list.append( { 'retrieve_id' : r, 'row' : {}, 'to_bottom' : true, 'no_auto_select' : true } );
- }
- }
-
- for (var i = 0; i < results.length; i++) {
- funcs.push( gen_func(results[i]) );
- }
- JSAN.use('util.exec'); var exec = new util.exec(4);
- exec.chain( funcs );
-
- } catch(E) {
- this.error.standard_unexpected_error_alert('patron.search_result.search',E);
- }
- }
+ //this.list.append( { 'retrieve_id' : results[i], 'row' : {} } );
+ var funcs = [];
+
+ function gen_func(r) {
+ return function() {
+ obj.list.append( { 'retrieve_id' : r, 'row' : {}, 'to_bottom' : true, 'no_auto_select' : true } );
+ }
+ }
+
+ for (var i = 0; i < results.length; i++) {
+ funcs.push( gen_func(results[i]) );
+ }
+ JSAN.use('util.exec'); var exec = new util.exec(4);
+ exec.chain( funcs );
+
+ } catch(E) {
+ this.error.standard_unexpected_error_alert('patron.search_result.search',E);
+ }
+ }
}
JSAN.errorLevel = "die"; // none, warn, or die
JSAN.addRepository('..');
- JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
+ JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.stash_retrieve();
XML_HTTP_SERVER = data.server_unadorned;
JSAN.use('util.error'); error = new util.error();
if (typeof patron == 'undefined') patron = {};
patron.summary = function (params) {
- JSAN.use('util.error'); this.error = new util.error();
- JSAN.use('util.window'); this.window = new util.window();
- JSAN.use('util.network'); this.network = new util.network();
+ JSAN.use('util.error'); this.error = new util.error();
+ JSAN.use('util.window'); this.window = new util.window();
+ JSAN.use('util.network'); this.network = new util.network();
JSAN.use('util.widgets');
- this.w = window;
+ this.w = window;
}
patron.summary.prototype = {
- 'init' : function( params ) {
+ 'init' : function( params ) {
- var obj = this;
+ var obj = this;
- obj.barcode = params['barcode'];
- obj.id = params['id'];
- if (params['show_name']) {
- document.getElementById('patron_name').hidden = false;
- document.getElementById('patron_name').setAttribute('hidden','false');
- }
+ obj.barcode = params['barcode'];
+ obj.id = params['id'];
+ if (params['show_name']) {
+ document.getElementById('patron_name').hidden = false;
+ document.getElementById('patron_name').setAttribute('hidden','false');
+ }
- JSAN.use('OpenILS.data'); this.OpenILS = {};
- obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
+ JSAN.use('OpenILS.data'); this.OpenILS = {};
+ obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
var obscure_dob = String( obj.OpenILS.data.hash.aous['circ.obscure_dob'] ) == 'true';
- JSAN.use('util.controller'); obj.controller = new util.controller();
- obj.controller.init(
- {
- control_map : {
- 'cmd_broken' : [
- ['command'],
- function() { alert($("commonStrings").getString('common.unimplemented')); }
- ],
- 'patron_alert' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text( e, obj.patron.alert_message() || '' );
- if (obj.patron.alert_message()) {
- e.parentNode.hidden = false;
- } else {
- e.parentNode.hidden = true;
- }
- };
- }
- ],
- 'patron_usrname' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,obj.patron.usrname());
- };
- }
- ],
- 'patron_profile' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.OpenILS.data.hash.pgt[
- obj.patron.profile()
- ].name()
- );
- };
- }
- ],
- 'patron_net_access' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- patronStrings.getString('staff.patron.summary.patron_net_access') +
- ' ' + obj.OpenILS.data.hash.cnal[
- obj.patron.net_access_level()
- ].name()
- );
- };
- }
- ],
- 'patron_credit' : [
- ['render'],
- function(e) {
- return function() {
- JSAN.use('util.money');
- util.widgets.set_text(e,
- '$' +
- util.money.sanitize(
- obj.patron.credit_forward_balance()
- )
- );
- };
- }
- ],
- 'patron_bill' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,'...');
+ JSAN.use('util.controller'); obj.controller = new util.controller();
+ obj.controller.init(
+ {
+ control_map : {
+ 'cmd_broken' : [
+ ['command'],
+ function() { alert($("commonStrings").getString('common.unimplemented')); }
+ ],
+ 'patron_alert' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text( e, obj.patron.alert_message() || '' );
+ if (obj.patron.alert_message()) {
+ e.parentNode.hidden = false;
+ } else {
+ e.parentNode.hidden = true;
+ }
+ };
+ }
+ ],
+ 'patron_usrname' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,obj.patron.usrname());
+ };
+ }
+ ],
+ 'patron_profile' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.OpenILS.data.hash.pgt[
+ obj.patron.profile()
+ ].name()
+ );
+ };
+ }
+ ],
+ 'patron_net_access' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ patronStrings.getString('staff.patron.summary.patron_net_access') +
+ ' ' + obj.OpenILS.data.hash.cnal[
+ obj.patron.net_access_level()
+ ].name()
+ );
+ };
+ }
+ ],
+ 'patron_credit' : [
+ ['render'],
+ function(e) {
+ return function() {
+ JSAN.use('util.money');
+ util.widgets.set_text(e,
+ '$' +
+ util.money.sanitize(
+ obj.patron.credit_forward_balance()
+ )
+ );
+ };
+ }
+ ],
+ 'patron_bill' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,'...');
var under_btn;
if (xulG) {
if (xulG.display_window) {
if (under_btn) util.widgets.set_text(under_btn,'...');
}
}
- obj.network.simple_request(
- 'FM_MOUS_RETRIEVE.authoritative',
- [ ses(), obj.patron.id() ],
- function(req) {
+ obj.network.simple_request(
+ 'FM_MOUS_RETRIEVE.authoritative',
+ [ ses(), obj.patron.id() ],
+ function(req) {
try {
JSAN.use('util.money');
var robj = req.getResultObject();
} catch(E) {
alert('Error in summary.js, patron_bill callback: ' + E);
}
- }
- );
- };
- }
- ],
- 'patron_checkouts' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,'...');
- var e2 = document.getElementById( 'patron_overdue' ); if (e2) util.widgets.set_text(e2,'...');
- var e3 = document.getElementById( 'patron_claimed_returned' ); if (e3) util.widgets.set_text(e3,'...');
- var e4 = document.getElementById( 'patron_long_overdue' ); if (e4) util.widgets.set_text(e4,'...');
- var e5 = document.getElementById( 'patron_lost' ); if (e5) util.widgets.set_text(e5,'...');
- var e6 = document.getElementById( 'patron_noncat' ); if (e6) util.widgets.set_text(e6,'...');
+ }
+ );
+ };
+ }
+ ],
+ 'patron_checkouts' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,'...');
+ var e2 = document.getElementById( 'patron_overdue' ); if (e2) util.widgets.set_text(e2,'...');
+ var e3 = document.getElementById( 'patron_claimed_returned' ); if (e3) util.widgets.set_text(e3,'...');
+ var e4 = document.getElementById( 'patron_long_overdue' ); if (e4) util.widgets.set_text(e4,'...');
+ var e5 = document.getElementById( 'patron_lost' ); if (e5) util.widgets.set_text(e5,'...');
+ var e6 = document.getElementById( 'patron_noncat' ); if (e6) util.widgets.set_text(e6,'...');
var under_btn;
if (xulG) {
if (xulG.display_window) {
if (under_btn) util.widgets.set_text(under_btn,'...');
}
}
- obj.network.simple_request(
- 'FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative',
- [ ses(), obj.patron.id() ],
- function(req) {
- try {
- var robj = req.getResultObject();
- util.widgets.set_text(e, robj.out + robj.overdue + robj.claims_returned + robj.long_overdue );
- if (e2) util.widgets.set_text(e2, robj.overdue );
- if (e3) util.widgets.set_text(e3, robj.claims_returned );
- if (e4) util.widgets.set_text(e4, robj.long_overdue );
- if (e5) util.widgets.set_text(e5, robj.lost );
+ obj.network.simple_request(
+ 'FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative',
+ [ ses(), obj.patron.id() ],
+ function(req) {
+ try {
+ var robj = req.getResultObject();
+ util.widgets.set_text(e, robj.out + robj.overdue + robj.claims_returned + robj.long_overdue );
+ if (e2) util.widgets.set_text(e2, robj.overdue );
+ if (e3) util.widgets.set_text(e3, robj.claims_returned );
+ if (e4) util.widgets.set_text(e4, robj.long_overdue );
+ if (e5) util.widgets.set_text(e5, robj.lost );
if (under_btn) util.widgets.set_text(under_btn,
String( robj.out + robj.overdue + robj.claims_returned + robj.long_overdue) +
( robj.overdue > 0 ? '*' : '' )
);
- } catch(E) {
- alert(E);
- }
- }
- );
- obj.network.simple_request(
- 'FM_ANCC_RETRIEVE_VIA_USER.authoritative',
- [ ses(), obj.patron.id() ],
- function(req) {
- var robj = req.getResultObject();
- if (e6) util.widgets.set_text(e6,robj.length);
- }
- );
- };
- }
- ],
- 'patron_overdue' : [
- ['render'],
- function(e) {
- return function() {
- /* handled by 'patron_checkouts' */
- };
- }
- ],
- 'patron_holds' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,'...');
- var e2 = document.getElementById('patron_holds_available');
- if (e2) util.widgets.set_text(e2,'...');
+ } catch(E) {
+ alert(E);
+ }
+ }
+ );
+ obj.network.simple_request(
+ 'FM_ANCC_RETRIEVE_VIA_USER.authoritative',
+ [ ses(), obj.patron.id() ],
+ function(req) {
+ var robj = req.getResultObject();
+ if (e6) util.widgets.set_text(e6,robj.length);
+ }
+ );
+ };
+ }
+ ],
+ 'patron_overdue' : [
+ ['render'],
+ function(e) {
+ return function() {
+ /* handled by 'patron_checkouts' */
+ };
+ }
+ ],
+ 'patron_holds' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,'...');
+ var e2 = document.getElementById('patron_holds_available');
+ if (e2) util.widgets.set_text(e2,'...');
var under_btn;
if (xulG) {
if (xulG.display_window) {
if (under_btn) util.widgets.set_text(under_btn,'...');
}
}
- obj.network.simple_request(
- 'FM_AHR_COUNT_RETRIEVE.authoritative',
- [ ses(), obj.patron.id() ],
- function(req) {
+ obj.network.simple_request(
+ 'FM_AHR_COUNT_RETRIEVE.authoritative',
+ [ ses(), obj.patron.id() ],
+ function(req) {
var robj = req.getResultObject();
- util.widgets.set_text(e,
- robj.total
- );
- if (e2) util.widgets.set_text(e2,
- robj.ready
- );
+ util.widgets.set_text(e,
+ robj.total
+ );
+ if (e2) util.widgets.set_text(e2,
+ robj.ready
+ );
if (under_btn) util.widgets.set_text(under_btn, req.getResultObject().ready + '/' + req.getResultObject().total );
obj.holds_summary = robj;
if (obj.holds_summary && obj.bills_summary)
- if (typeof window.xulG == 'object' && typeof window.xulG.stop_sign_page == 'function')
+ if (typeof window.xulG == 'object' && typeof window.xulG.stop_sign_page == 'function')
window.xulG.stop_sign_page( obj.patron, { 'holds_summary' : obj.holds_summary, 'bills_summary' : obj.bills_summary } );
- }
- );
- };
- }
- ],
- 'patron_holds_available' : [
- ['render'],
- function(e) {
- return function() {
- /* handled by 'patron_holds' */
- };
- }
- ],
- 'patron_card' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.card().barcode()
- );
- };
- }
- ],
- 'patron_ident_type_1' : [
- ['render'],
- function(e) {
- return function() {
- var ident_string = '';
- var ident = obj.OpenILS.data.hash.cit[
- obj.patron.ident_type()
- ];
- if (ident) ident_string = ident.name()
- util.widgets.set_text(e,
- ident_string
- );
- };
- }
- ],
- 'patron_ident_value_1' : [
- ['render'],
- function(e) {
- return function() {
- var val = obj.patron.ident_value();
- val = val.replace(/.+(\d\d\d\d)$/,'xxxx$1');
- util.widgets.set_text(e, val);
- };
- }
- ],
- 'patron_ident_type_2' : [
- ['render'],
- function(e) {
- return function() {
- var ident_string = '';
- var ident = obj.OpenILS.data.hash.cit[
- obj.patron.ident_type2()
- ];
- if (ident) ident_string = ident.name()
- util.widgets.set_text(e,
- ident_string
- );
- };
- }
- ],
- 'patron_ident_value_2' : [
- ['render'],
- function(e) {
- return function() {
- var val = obj.patron.ident_value2();
- val = val.replace(/.+(\d\d\d\d)$/,'xxxx$1');
- util.widgets.set_text(e, val);
- };
- }
- ],
- 'patron_date_of_exp' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- patronStrings.getString('staff.patron.summary.expires_on') + ' ' + (
- obj.patron.expire_date() ?
- obj.patron.expire_date().substr(0,10) :
- patronStrings.getString('staff.patron.field.unset')
- )
- );
- };
- }
- ],
+ }
+ );
+ };
+ }
+ ],
+ 'patron_holds_available' : [
+ ['render'],
+ function(e) {
+ return function() {
+ /* handled by 'patron_holds' */
+ };
+ }
+ ],
+ 'patron_card' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.card().barcode()
+ );
+ };
+ }
+ ],
+ 'patron_ident_type_1' : [
+ ['render'],
+ function(e) {
+ return function() {
+ var ident_string = '';
+ var ident = obj.OpenILS.data.hash.cit[
+ obj.patron.ident_type()
+ ];
+ if (ident) ident_string = ident.name()
+ util.widgets.set_text(e,
+ ident_string
+ );
+ };
+ }
+ ],
+ 'patron_ident_value_1' : [
+ ['render'],
+ function(e) {
+ return function() {
+ var val = obj.patron.ident_value();
+ val = val.replace(/.+(\d\d\d\d)$/,'xxxx$1');
+ util.widgets.set_text(e, val);
+ };
+ }
+ ],
+ 'patron_ident_type_2' : [
+ ['render'],
+ function(e) {
+ return function() {
+ var ident_string = '';
+ var ident = obj.OpenILS.data.hash.cit[
+ obj.patron.ident_type2()
+ ];
+ if (ident) ident_string = ident.name()
+ util.widgets.set_text(e,
+ ident_string
+ );
+ };
+ }
+ ],
+ 'patron_ident_value_2' : [
+ ['render'],
+ function(e) {
+ return function() {
+ var val = obj.patron.ident_value2();
+ val = val.replace(/.+(\d\d\d\d)$/,'xxxx$1');
+ util.widgets.set_text(e, val);
+ };
+ }
+ ],
+ 'patron_date_of_exp' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ patronStrings.getString('staff.patron.summary.expires_on') + ' ' + (
+ obj.patron.expire_date() ?
+ obj.patron.expire_date().substr(0,10) :
+ patronStrings.getString('staff.patron.field.unset')
+ )
+ );
+ };
+ }
+ ],
'patron_hold_alias' : [
['render'],
function(e) {
}
}
],
- 'patron_date_of_birth' : [
- ['render'],
- function(e) {
- return function() {
+ 'patron_date_of_birth' : [
+ ['render'],
+ function(e) {
+ return function() {
var hide_value = e.getAttribute('hide_value');
if ( obscure_dob && hide_value == 'true' ) {
e.setAttribute( 'hidden_value',
}
}
}
- };
- }
- ],
- 'patron_day_phone' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.day_phone()
- );
- };
- }
- ],
- 'patron_evening_phone' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.evening_phone()
- );
- };
- }
- ],
- 'patron_other_phone' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.other_phone()
- );
- };
- }
- ],
- 'patron_email' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.email()
- );
- };
- }
- ],
- 'patron_alias' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.alias()
- );
- };
- }
- ],
- 'patron_photo_url' : [
- ['render'],
- function(e) {
- return function() {
- e.setAttribute('src',
- obj.patron.photo_url()
- );
- };
- }
- ],
- 'patron_library' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.OpenILS.data.hash.aou[
- obj.patron.home_ou()
- ].shortname()
- );
- e.setAttribute('tooltiptext',
- obj.OpenILS.data.hash.aou[
- obj.patron.home_ou()
- ].name()
- );
- };
- }
- ],
- 'patron_last_library' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.OpenILS.data.hash.aou[
- obj.patron.home_ou()
- ].shortname()
- );
- e.setAttribute('tooltiptext',
- obj.OpenILS.data.hash.aou[
- obj.patron.home_ou()
- ].name()
- );
- };
- }
- ],
- 'patron_mailing_address_street1' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.mailing_address().street1()
- );
- if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ],
- 'patron_mailing_address_street2' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.mailing_address().street2()
- );
- if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ],
- 'patron_mailing_address_city' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.mailing_address().city()
- );
- if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ],
- 'patron_mailing_address_state' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.mailing_address().state()
- );
- if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ],
- 'patron_mailing_address_post_code' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.mailing_address().post_code()
- );
- if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ],
- 'patron_physical_address_street1' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.billing_address().street1()
- );
- if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ],
- 'patron_physical_address_street2' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.billing_address().street2()
- );
- if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ],
- 'patron_physical_address_city' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.billing_address().city()
- );
- if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ],
- 'patron_physical_address_state' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.billing_address().state()
- );
- if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ],
- 'patron_physical_address_post_code' : [
- ['render'],
- function(e) {
- return function() {
- util.widgets.set_text(e,
- obj.patron.billing_address().post_code()
- );
- if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
- };
- }
- ]
- }
- }
- );
-
- obj.retrieve();
-
- try {
- var caption = document.getElementById("PatronSummaryContact_caption");
- var arrow = document.getAnonymousNodes(caption)[0];
- var gb_content = document.getAnonymousNodes(caption.parentNode)[1];
- arrow.addEventListener(
- 'click',
- function() {
- setTimeout(
- function() {
- //alert('setting shrink_state to ' + gb_content.hidden);
- //caption.setAttribute('shrink_state',gb_content.hidden);
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('patron_id_shrink');
- file.set_object(String(gb_content.hidden)); file.close();
- }, 0
- );
- }, false
- );
- //var shrink_state = caption.getAttribute('shrink_state');
- var shrink_state = false;
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
- JSAN.use('util.file'); var file = new util.file('patron_id_shrink');
- if (file._file.exists()) {
- shrink_state = file.get_object(); file.close();
- }
- //alert('shrink_state retrieved as ' + shrink_state);
- if (shrink_state != 'false' && shrink_state) {
- //alert('clicking the widget');
- util.widgets.click( arrow );
- }
- } catch(E) {
- obj.error.sdump('D_ERROR','with shrink_state in summary.js: ' + E);
- }
- },
-
- 'retrieve' : function() {
-
- try {
-
- var obj = this;
-
- var chain = [];
-
- // Retrieve the patron
- function blah_retrieve() {
- try {
- var robj;
- if (obj.barcode && obj.barcode != 'null') {
- robj = obj.network.simple_request(
- 'FM_AU_RETRIEVE_VIA_BARCODE.authoritative',
- [ ses(), obj.barcode ]
- );
- } else if (obj.id && obj.id != 'null') {
- robj = obj.network.simple_request(
- 'FM_AU_FLESHED_RETRIEVE_VIA_ID',
- [ ses(), obj.id ]
- );
- } else {
- throw(patronStrings.getString('staff.patron.summary.retrieve.no_barcode'));
- }
- if (robj) {
-
- if (instanceOf(robj,au)) {
-
- obj.patron = robj;
- JSAN.use('patron.util');
- util.widgets.set_text('patron_name',
+ };
+ }
+ ],
+ 'patron_day_phone' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.day_phone()
+ );
+ };
+ }
+ ],
+ 'patron_evening_phone' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.evening_phone()
+ );
+ };
+ }
+ ],
+ 'patron_other_phone' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.other_phone()
+ );
+ };
+ }
+ ],
+ 'patron_email' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.email()
+ );
+ };
+ }
+ ],
+ 'patron_alias' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.alias()
+ );
+ };
+ }
+ ],
+ 'patron_photo_url' : [
+ ['render'],
+ function(e) {
+ return function() {
+ e.setAttribute('src',
+ obj.patron.photo_url()
+ );
+ };
+ }
+ ],
+ 'patron_library' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.OpenILS.data.hash.aou[
+ obj.patron.home_ou()
+ ].shortname()
+ );
+ e.setAttribute('tooltiptext',
+ obj.OpenILS.data.hash.aou[
+ obj.patron.home_ou()
+ ].name()
+ );
+ };
+ }
+ ],
+ 'patron_last_library' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.OpenILS.data.hash.aou[
+ obj.patron.home_ou()
+ ].shortname()
+ );
+ e.setAttribute('tooltiptext',
+ obj.OpenILS.data.hash.aou[
+ obj.patron.home_ou()
+ ].name()
+ );
+ };
+ }
+ ],
+ 'patron_mailing_address_street1' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.mailing_address().street1()
+ );
+ if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ],
+ 'patron_mailing_address_street2' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.mailing_address().street2()
+ );
+ if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ],
+ 'patron_mailing_address_city' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.mailing_address().city()
+ );
+ if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ],
+ 'patron_mailing_address_state' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.mailing_address().state()
+ );
+ if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ],
+ 'patron_mailing_address_post_code' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.mailing_address().post_code()
+ );
+ if (!get_bool(obj.patron.mailing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ],
+ 'patron_physical_address_street1' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.billing_address().street1()
+ );
+ if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ],
+ 'patron_physical_address_street2' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.billing_address().street2()
+ );
+ if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ],
+ 'patron_physical_address_city' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.billing_address().city()
+ );
+ if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ],
+ 'patron_physical_address_state' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.billing_address().state()
+ );
+ if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ],
+ 'patron_physical_address_post_code' : [
+ ['render'],
+ function(e) {
+ return function() {
+ util.widgets.set_text(e,
+ obj.patron.billing_address().post_code()
+ );
+ if (!get_bool(obj.patron.billing_address().valid())){e.setAttribute('style','color: red');}
+ };
+ }
+ ]
+ }
+ }
+ );
+
+ obj.retrieve();
+
+ try {
+ var caption = document.getElementById("PatronSummaryContact_caption");
+ var arrow = document.getAnonymousNodes(caption)[0];
+ var gb_content = document.getAnonymousNodes(caption.parentNode)[1];
+ arrow.addEventListener(
+ 'click',
+ function() {
+ setTimeout(
+ function() {
+ //alert('setting shrink_state to ' + gb_content.hidden);
+ //caption.setAttribute('shrink_state',gb_content.hidden);
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('patron_id_shrink');
+ file.set_object(String(gb_content.hidden)); file.close();
+ }, 0
+ );
+ }, false
+ );
+ //var shrink_state = caption.getAttribute('shrink_state');
+ var shrink_state = false;
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+ JSAN.use('util.file'); var file = new util.file('patron_id_shrink');
+ if (file._file.exists()) {
+ shrink_state = file.get_object(); file.close();
+ }
+ //alert('shrink_state retrieved as ' + shrink_state);
+ if (shrink_state != 'false' && shrink_state) {
+ //alert('clicking the widget');
+ util.widgets.click( arrow );
+ }
+ } catch(E) {
+ obj.error.sdump('D_ERROR','with shrink_state in summary.js: ' + E);
+ }
+ },
+
+ 'retrieve' : function() {
+
+ try {
+
+ var obj = this;
+
+ var chain = [];
+
+ // Retrieve the patron
+ function blah_retrieve() {
+ try {
+ var robj;
+ if (obj.barcode && obj.barcode != 'null') {
+ robj = obj.network.simple_request(
+ 'FM_AU_RETRIEVE_VIA_BARCODE.authoritative',
+ [ ses(), obj.barcode ]
+ );
+ } else if (obj.id && obj.id != 'null') {
+ robj = obj.network.simple_request(
+ 'FM_AU_FLESHED_RETRIEVE_VIA_ID',
+ [ ses(), obj.id ]
+ );
+ } else {
+ throw(patronStrings.getString('staff.patron.summary.retrieve.no_barcode'));
+ }
+ if (robj) {
+
+ if (instanceOf(robj,au)) {
+
+ obj.patron = robj;
+ JSAN.use('patron.util');
+ util.widgets.set_text('patron_name',
patron.util.format_name( obj.patron )
- );
- patron.util.set_penalty_css(obj.patron);
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- data.last_patron = obj.patron.id(); data.stash('last_patron');
-
- } else {
-
- throw(robj);
-
- }
- } else {
-
- throw(robj);
-
- }
-
- } catch(E) {
- throw(E);
- }
- };
- blah_retrieve();
-
- /*
- // Retrieve the survey responses for required surveys
- chain.push(
- function() {
- try {
- var surveys = obj.OpenILS.data.list.my_asv;
- var survey_responses = {};
- for (var i = 0; i < surveys.length; i++) {
- var s = obj.network.request(
- api.FM_ASVR_RETRIEVE.app,
- api.FM_ASVR_RETRIEVE.method,
- [ ses(), surveys[i].id(), obj.patron.id() ]
- );
- survey_responses[ surveys[i].id() ] = s;
- }
- obj.patron.survey_responses( survey_responses );
- } catch(E) {
- var error = ('patron.summary.retrieve : ' + js2JSON(E));
- obj.error.sdump('D_ERROR',error);
- throw(error);
- }
- }
- );
- */
-
- // Update the screen
- chain.push( function() { obj.controller.render(); } );
-
- // On Complete
-
- chain.push( function() {
-
- if (typeof window.xulG == 'object' && typeof window.xulG.on_finished == 'function') {
- obj.error.sdump('D_PATRON_SUMMARY',
- 'patron.summary: Calling external .on_finished()\n');
- window.xulG.on_finished(obj.patron);
- } else {
- obj.error.sdump('D_PATRON_SUMMARY','patron.summary: No external .on_finished()\n');
- }
-
- } );
-
- // Do it
- JSAN.use('util.exec'); obj.exec = new util.exec();
- obj.exec.on_error = function(E) {
-
- if (typeof window.xulG == 'object' && typeof window.xulG.on_error == 'function') {
- window.xulG.on_error(E);
- } else {
- alert(js2JSON(E));
- }
-
- }
- this.exec.chain( chain );
-
- } catch(E) {
- if (typeof window.xulG == 'object' && typeof window.xulG.on_error == 'function') {
- window.xulG.on_error(E);
- } else {
- alert(js2JSON(E));
- }
- }
- }
+ );
+ patron.util.set_penalty_css(obj.patron);
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ data.last_patron = obj.patron.id(); data.stash('last_patron');
+
+ } else {
+
+ throw(robj);
+
+ }
+ } else {
+
+ throw(robj);
+
+ }
+
+ } catch(E) {
+ throw(E);
+ }
+ };
+ blah_retrieve();
+
+ /*
+ // Retrieve the survey responses for required surveys
+ chain.push(
+ function() {
+ try {
+ var surveys = obj.OpenILS.data.list.my_asv;
+ var survey_responses = {};
+ for (var i = 0; i < surveys.length; i++) {
+ var s = obj.network.request(
+ api.FM_ASVR_RETRIEVE.app,
+ api.FM_ASVR_RETRIEVE.method,
+ [ ses(), surveys[i].id(), obj.patron.id() ]
+ );
+ survey_responses[ surveys[i].id() ] = s;
+ }
+ obj.patron.survey_responses( survey_responses );
+ } catch(E) {
+ var error = ('patron.summary.retrieve : ' + js2JSON(E));
+ obj.error.sdump('D_ERROR',error);
+ throw(error);
+ }
+ }
+ );
+ */
+
+ // Update the screen
+ chain.push( function() { obj.controller.render(); } );
+
+ // On Complete
+
+ chain.push( function() {
+
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_finished == 'function') {
+ obj.error.sdump('D_PATRON_SUMMARY',
+ 'patron.summary: Calling external .on_finished()\n');
+ window.xulG.on_finished(obj.patron);
+ } else {
+ obj.error.sdump('D_PATRON_SUMMARY','patron.summary: No external .on_finished()\n');
+ }
+
+ } );
+
+ // Do it
+ JSAN.use('util.exec'); obj.exec = new util.exec();
+ obj.exec.on_error = function(E) {
+
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_error == 'function') {
+ window.xulG.on_error(E);
+ } else {
+ alert(js2JSON(E));
+ }
+
+ }
+ this.exec.chain( chain );
+
+ } catch(E) {
+ if (typeof window.xulG == 'object' && typeof window.xulG.on_error == 'function') {
+ window.xulG.on_error(E);
+ } else {
+ alert(js2JSON(E));
+ }
+ }
+ }
}
dump('exiting patron.summary.js\n');
-var cgi = null;
-var clone = false;
-var patron = null;
-var counter = 0;
-var identTypesCache = {};
-var statCatsCache = {};
-var surveysCache = {};
-var surveyQuestionsCache = {};
-var surveyAnswersCache = {};
-var userCache = {};
-var groupsCache = {};
-var netLevelsCache = {};
+var cgi = null;
+var clone = false;
+var patron = null;
+var counter = 0;
+var identTypesCache = {};
+var statCatsCache = {};
+var surveysCache = {};
+var surveyQuestionsCache = {};
+var surveyAnswersCache = {};
+var userCache = {};
+var groupsCache = {};
+var netLevelsCache = {};
var orgSettings = [];
-//var guardianNote = null;
+//var guardianNote = null;
var uEditUsePhonePw = false;
if(!window.xulG) var xulG = null;
/* fetch the necessary data to start off */
function uEditInit() {
- _debug('uEditInit(): ' + location.search);
+ _debug('uEditInit(): ' + location.search);
- cgi = new CGI();
- session = cgi.param('ses');
- if (xulG) if (xulG.ses) session = xulG.ses;
- if (xulG) if (xulG.params) if (xulG.params.ses) session = xulG.params.ses;
- clone = cgi.param('clone');
- if (xulG) if (xulG.clone) clone = xulG.clone;
- if (xulG) if (xulG.params) if (xulG.params.clone) clone = xulG.params.clone;
- if(!session) throw $("patronStrings").getString('web.staff.patron.ue.session_no_defined');
+ cgi = new CGI();
+ session = cgi.param('ses');
+ if (xulG) if (xulG.ses) session = xulG.ses;
+ if (xulG) if (xulG.params) if (xulG.params.ses) session = xulG.params.ses;
+ clone = cgi.param('clone');
+ if (xulG) if (xulG.clone) clone = xulG.clone;
+ if (xulG) if (xulG.params) if (xulG.params.clone) clone = xulG.params.clone;
+ if(!session) throw $("patronStrings").getString('web.staff.patron.ue.session_no_defined');
- fetchUser(session);
- $('uedit_user').appendChild(text(USER.usrname()));
+ fetchUser(session);
+ $('uedit_user').appendChild(text(USER.usrname()));
- setTimeout( function() {
- uEditBuild(); uEditShowPage('uedit_userid'); }, 20 );
+ setTimeout( function() {
+ uEditBuild(); uEditShowPage('uedit_userid'); }, 20 );
}
function uEditSetUnload() {
/* Fetch code
/* ------------------------------------------------------------------------------ */
function uEditFetchIdentTypes() {
- _debug("uEditFetchIdentTypes()");
- var s = fetchXULStash();
- if (typeof s.list != 'undefined')
- if (typeof s.list.cit != 'undefined') return s.list.cit;
- var req = new Request(FETCH_ID_TYPES);
- req.send(true);
- return req.result();
+ _debug("uEditFetchIdentTypes()");
+ var s = fetchXULStash();
+ if (typeof s.list != 'undefined')
+ if (typeof s.list.cit != 'undefined') return s.list.cit;
+ var req = new Request(FETCH_ID_TYPES);
+ req.send(true);
+ return req.result();
}
function uEditFetchStatCats() {
- _debug("uEditFetchStatCats()");
- var s = fetchXULStash();
- if (typeof s.list != 'undefined')
- if (typeof s.list.my_actsc != 'undefined') return s.list.my_actsc;
- var req = new Request(SC_FETCH_ALL, SESSION);
- req.send(true);
- return req.result();
+ _debug("uEditFetchStatCats()");
+ var s = fetchXULStash();
+ if (typeof s.list != 'undefined')
+ if (typeof s.list.my_actsc != 'undefined') return s.list.my_actsc;
+ var req = new Request(SC_FETCH_ALL, SESSION);
+ req.send(true);
+ return req.result();
}
function uEditFetchSurveys() {
- _debug("uEditFetchSurveys()");
- var s = fetchXULStash();
- if (typeof s.list != 'undefined')
- if (typeof s.list.asv != 'undefined') return s.list.asv;
- var req = new Request(SV_FETCH_ALL, SESSION);
- req.send(true);
- return req.result();
+ _debug("uEditFetchSurveys()");
+ var s = fetchXULStash();
+ if (typeof s.list != 'undefined')
+ if (typeof s.list.asv != 'undefined') return s.list.asv;
+ var req = new Request(SV_FETCH_ALL, SESSION);
+ req.send(true);
+ return req.result();
}
function uEditFetchGroups() {
- _debug("uEditFetchGroups()");
- var s = fetchXULStash();
- if (typeof s.tree != 'undefined')
- if (typeof s.tree.pgt != 'undefined') return s.tree.pgt;
- var req = new Request(FETCH_GROUPS);
- req.send(true);
- return req.result();
+ _debug("uEditFetchGroups()");
+ var s = fetchXULStash();
+ if (typeof s.tree != 'undefined')
+ if (typeof s.tree.pgt != 'undefined') return s.tree.pgt;
+ var req = new Request(FETCH_GROUPS);
+ req.send(true);
+ return req.result();
}
function uEditFetchNetLevels() {
- _debug("uEditFetchNetLevels()");
- var s = fetchXULStash();
- if (typeof s.list != 'undefined')
- if (typeof s.list.cnal != 'undefined') return s.list.cnal;
- var req = new Request(FETCH_NET_LEVELS, SESSION);
- req.send(true);
- return req.result();
+ _debug("uEditFetchNetLevels()");
+ var s = fetchXULStash();
+ if (typeof s.list != 'undefined')
+ if (typeof s.list.cnal != 'undefined') return s.list.cnal;
+ var req = new Request(FETCH_NET_LEVELS, SESSION);
+ req.send(true);
+ return req.result();
}
/* ------------------------------------------------------------------------------ */
* provided by descending through the group tree
*/
function buildAppPermList(list, group) {
- if(!group) return;
- if(group.application_perm() )
+ if(!group) return;
+ if(group.application_perm() )
list.push(group.application_perm());
for(i in group.children()) {
buildAppPermList(list, group.children()[i]);
perms.push(myPerms[p]);
myPerms = perms;
- fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
+ fetchHighestPermOrgs( SESSION, USER.id(), myPerms );
- uEditBuildLibSelector();
- var usr = cgi.param('usr');
- if (xulG) if (xulG.usr) usr = xulG.usr;
- if (xulG) if (xulG.params) if (xulG.params.usr) usr = xulG.params.usr;
+ uEditBuildLibSelector();
+ var usr = cgi.param('usr');
+ if (xulG) if (xulG.usr) usr = xulG.usr;
+ if (xulG) if (xulG.params) if (xulG.params.usr) usr = xulG.params.usr;
orgSettings = fetchBatchOrgSetting(USER.ws_ou(), [
'global.juvenile_age_threshold',
uEditUsePhonePw = (orgSettings['patron.password.use_phone'] &&
orgSettings['patron.password.use_phone'].value);
- patron = fetchFleshedUser(usr);
- if(!patron) patron = uEditNewPatron();
-
- uEditDraw(
- uEditFetchIdentTypes(),
+ patron = fetchFleshedUser(usr);
+ if(!patron) patron = uEditNewPatron();
+
+ uEditDraw(
+ uEditFetchIdentTypes(),
groups,
- uEditFetchStatCats(),
- uEditFetchSurveys(),
- uEditFetchNetLevels()
- );
+ uEditFetchStatCats(),
+ uEditFetchSurveys(),
+ uEditFetchNetLevels()
+ );
- if(patron.isnew()) {
- if(clone) uEditClone(clone);
- else uEditCreateNewAddr();
+ if(patron.isnew()) {
+ if(clone) uEditClone(clone);
+ else uEditCreateNewAddr();
- } else {
+ } else {
- /* do we need to display the parent / gurdian field? */
- uEditCheckDOB(uEditFindFieldByKey('dob'));
+ /* do we need to display the parent / gurdian field? */
+ uEditCheckDOB(uEditFindFieldByKey('dob'));
- $('ue_barcode').disabled = true;
- unHideMe($('ue_mark_card_lost'));
- unHideMe($('ue_reset_pw'));
- uEditCheckEditPerm();
- }
+ $('ue_barcode').disabled = true;
+ unHideMe($('ue_mark_card_lost'));
+ unHideMe($('ue_reset_pw'));
+ uEditCheckEditPerm();
+ }
uEditCheckBarredPerm();
}
function uEditCheckBarredPerm() {
- if(PERMS['BAR_PATRON'] != -1)
+ if(PERMS['BAR_PATRON'] != -1)
return;
if(isTrue(patron.barred()) && PERMS['UNBAR_PATRON'] != -1)
/* if this user does not have permission to put users into
- the edited users group, they do not have permission to
- edit this user */
+ the edited users group, they do not have permission to
+ edit this user */
function uEditCheckEditPerm() {
- var perm = uEditFindGroupPerm(groupsCache[patron.profile()]);
- /*
- _debug("editing user with group app perm "+patron.profile()+' : '+
- groupsCache[patron.profile()].name() +', and perm = ' + perm);
- */
-
- if(PERMS[perm] != -1) return;
-
- /* we can edit our own account, but not others in our group */
- if( patron.id() != USER.id() ){
- _debug("we are not allowed to edit this user");
-
- $('ue_save').disabled = true;
- $('ue_save_clone').disabled = true;
- $('ue_mark_card_lost').disabled = true;
- $('ue_reset_pw').disabled = true;
-
- uEditIterateFields(
- function(f) {
- if( f && f.widget && f.widget.node )
- f.widget.node.disabled = true;
- }
- );
+ var perm = uEditFindGroupPerm(groupsCache[patron.profile()]);
+ /*
+ _debug("editing user with group app perm "+patron.profile()+' : '+
+ groupsCache[patron.profile()].name() +', and perm = ' + perm);
+ */
+
+ if(PERMS[perm] != -1) return;
+
+ /* we can edit our own account, but not others in our group */
+ if( patron.id() != USER.id() ){
+ _debug("we are not allowed to edit this user");
+
+ $('ue_save').disabled = true;
+ $('ue_save_clone').disabled = true;
+ $('ue_mark_card_lost').disabled = true;
+ $('ue_reset_pw').disabled = true;
+
+ uEditIterateFields(
+ function(f) {
+ if( f && f.widget && f.widget.node )
+ f.widget.node.disabled = true;
+ }
+ );
- }
+ }
- var node = $('ue_profile').parentNode;
- node.removeChild($('ue_profile'));
- node.appendChild(elem('span',null,groupsCache[patron.profile()].name()));
+ var node = $('ue_profile').parentNode;
+ node.removeChild($('ue_profile'));
+ node.appendChild(elem('span',null,groupsCache[patron.profile()].name()));
- var field = uEditFindFieldByKey('profile');
- field.required = false;
- removeCSSClass(field.widget.node, CSS_INVALID_DATA);
- uEditCheckErrors();
+ var field = uEditFindFieldByKey('profile');
+ field.required = false;
+ removeCSSClass(field.widget.node, CSS_INVALID_DATA);
+ uEditCheckErrors();
}
/* creates a new patron object with card attached */
var uEditCardVirtId = -1;
function uEditNewPatron() {
- var patron = new au();
- patron.isnew(1);
- patron.id(-1);
- card = new ac();
- card.id(uEditCardVirtId--);
- card.isnew(1);
- patron.card(card);
- patron.cards([card]);
+ var patron = new au();
+ patron.isnew(1);
+ patron.id(-1);
+ card = new ac();
+ card.id(uEditCardVirtId--);
+ card.isnew(1);
+ patron.card(card);
+ patron.cards([card]);
patron.net_access_level(defaultNetLevel);
- patron.stat_cat_entries([]);
- patron.survey_responses([]);
- patron.addresses([]);
- patron.home_ou(USER.ws_ou());
- uEditMakeRandomPw(patron);
- return patron;
+ patron.stat_cat_entries([]);
+ patron.survey_responses([]);
+ patron.addresses([]);
+ patron.home_ou(USER.ws_ou());
+ uEditMakeRandomPw(patron);
+ return patron;
}
function uEditMakeRandomPw(patron) {
if(uEditUsePhonePw) return;
- var rand = Math.random();
- rand = parseInt(rand * 10000) + '';
- while(rand.length < 4) rand += '0';
- appendClear($('ue_password_plain'),text(rand));
- unHideMe($('ue_password_gen'));
- patron.passwd(rand);
- return rand;
+ var rand = Math.random();
+ rand = parseInt(rand * 10000) + '';
+ while(rand.length < 4) rand += '0';
+ appendClear($('ue_password_plain'),text(rand));
+ unHideMe($('ue_password_gen'));
+ patron.passwd(rand);
+ return rand;
}
function uEditMakePhonePw() {
(pw = patron.evening_phone()) || (pw = patron.other_phone()) ) {
pw = pw.substring(pw.length - 4); // this is iffy
uEditResetPw(pw);
- appendClear($('ue_password_plain'), text(pw));
- unHideMe($('ue_password_gen'));
- patron.passwd(pw);
+ appendClear($('ue_password_plain'), text(pw));
+ unHideMe($('ue_password_gen'));
+ patron.passwd(pw);
}
}
function uEditResetPw(pw) {
- if(!pw) pw = uEditMakeRandomPw(patron);
- $('ue_password1').value = pw;
- $('ue_password2').value = pw;
+ if(!pw) pw = uEditMakeRandomPw(patron);
+ $('ue_password1').value = pw;
+ $('ue_password2').value = pw;
$('ue_password1').onchange();
}
function uEditClone(clone) {
- var cloneUser = fetchFleshedUser(clone);
- patron.usrgroup(cloneUser.usrgroup());
+ var cloneUser = fetchFleshedUser(clone);
+ patron.usrgroup(cloneUser.usrgroup());
- if( cloneUser.day_phone() ) {
- $('ue_day_phone').value = cloneUser.day_phone();
- $('ue_day_phone').onchange();
+ if( cloneUser.day_phone() ) {
+ $('ue_day_phone').value = cloneUser.day_phone();
+ $('ue_day_phone').onchange();
}
- if( cloneUser.evening_phone() ) {
- $('ue_night_phone').value = cloneUser.evening_phone();
- $('ue_night_phone').onchange();
+ if( cloneUser.evening_phone() ) {
+ $('ue_night_phone').value = cloneUser.evening_phone();
+ $('ue_night_phone').onchange();
}
- if( cloneUser.other_phone() ) {
- $('ue_other_phone').value = cloneUser.other_phone();
- $('ue_other_phone').onchange();
+ if( cloneUser.other_phone() ) {
+ $('ue_other_phone').value = cloneUser.other_phone();
+ $('ue_other_phone').onchange();
}
- setSelector($('ue_org_selector'), cloneUser.home_ou());
- setSelector($('ue_profile'), cloneUser.profile());
-
- /* force the expire date to be set */
- $('ue_profile').onchange();
- $('ue_org_selector').onchange();
-
- for( var a in cloneUser.addresses() ) {
- var addr = cloneUser.addresses()[a];
- if( cloneUser.mailing_address &&
- addr.id() == cloneUser.mailing_address().id() )
- patron.mailing_address(addr);
- if( cloneUser.billing_address() &&
- addr.id() == cloneUser.billing_address().id() )
- patron.billing_address(addr);
- patron.addresses().push(addr);
- }
+ setSelector($('ue_org_selector'), cloneUser.home_ou());
+ setSelector($('ue_profile'), cloneUser.profile());
+
+ /* force the expire date to be set */
+ $('ue_profile').onchange();
+ $('ue_org_selector').onchange();
+
+ for( var a in cloneUser.addresses() ) {
+ var addr = cloneUser.addresses()[a];
+ if( cloneUser.mailing_address &&
+ addr.id() == cloneUser.mailing_address().id() )
+ patron.mailing_address(addr);
+ if( cloneUser.billing_address() &&
+ addr.id() == cloneUser.billing_address().id() )
+ patron.billing_address(addr);
+ patron.addresses().push(addr);
+ }
- uEditBuildAddrs(patron);
+ uEditBuildAddrs(patron);
}
/* Creates a new blank address,
- adds it to the user and the fields array */
+ adds it to the user and the fields array */
var uEditVirtualAddrId = -1;
function uEditCreateNewAddr() {
- var addr = new aua();
+ var addr = new aua();
- addr.id(uEditVirtualAddrId--);
- addr.isnew(1);
- addr.usr(patron.id());
- addr.country(defaultCountry);
+ addr.id(uEditVirtualAddrId--);
+ addr.isnew(1);
+ addr.usr(patron.id());
+ addr.country(defaultCountry);
- if(!patron.addresses())
- patron.addresses([]);
+ if(!patron.addresses())
+ patron.addresses([]);
- if(patron.addresses().length == 0) {
- patron.mailing_address(addr);
- patron.billing_address(addr);
- }
+ if(patron.addresses().length == 0) {
+ patron.mailing_address(addr);
+ patron.billing_address(addr);
+ }
- addr.valid(1);
- addr.within_city_limits(1);
+ addr.valid(1);
+ addr.within_city_limits(1);
- uEditBuildAddrFields(patron, addr);
- patron.addresses().push(addr);
- uEditIterateFields(function(f) { uEditCheckValid(f); });
- uEditCheckErrors();
+ uEditBuildAddrFields(patron, addr);
+ patron.addresses().push(addr);
+ uEditIterateFields(function(f) { uEditCheckValid(f); });
+ uEditCheckErrors();
}
/* kicks off the UI drawing */
function uEditDraw(identTypes, groups, statCats, surveys, netLevels ) {
- hideMe($('uedit_loading'));
- unHideMe($('ue_maintd'));
+ hideMe($('uedit_loading'));
+ unHideMe($('ue_maintd'));
- dataFields = [];
- uEditDrawIDTypes(identTypes);
- uEditDrawGroups(groups, null, null, true);
- uEditDrawStatCats(statCats);
- uEditDrawSurveys(surveys);
- uEditDrawNetLevels(netLevels);
- uEditDefineData(patron);
+ dataFields = [];
+ uEditDrawIDTypes(identTypes);
+ uEditDrawGroups(groups, null, null, true);
+ uEditDrawStatCats(statCats);
+ uEditDrawSurveys(surveys);
+ uEditDrawNetLevels(netLevels);
+ uEditDefineData(patron);
- uEditIterateFields(function(f) { uEditActivateField(f) });
- uEditIterateFields(function(f) { uEditCheckValid(f); });
- uEditCheckErrors();
+ uEditIterateFields(function(f) { uEditActivateField(f) });
+ uEditIterateFields(function(f) { uEditCheckValid(f); });
+ uEditCheckErrors();
}
/** Applies the event handlers and sets the data for the field */
function uEditActivateField(field) {
- if( field.widget.id ) {
- field.widget.node = $(field.widget.id);
+ if( field.widget.id ) {
+ field.widget.node = $(field.widget.id);
- } else {
- field.widget.node =
- $n(field.widget.base, field.widget.name);
- }
+ } else {
+ field.widget.node =
+ $n(field.widget.base, field.widget.name);
+ }
- uEditSetOnchange(field);
+ uEditSetOnchange(field);
- if(field.widget.onblur) {
- field.widget.node.onblur =
- function() { field.widget.onblur(field); };
- }
+ if(field.widget.onblur) {
+ field.widget.node.onblur =
+ function() { field.widget.onblur(field); };
+ }
- field.widget.node.disabled = field.widget.disabled;
- if(field.object == null) return;
- var val = field.object[field.key]();
- if(val == null) return;
+ field.widget.node.disabled = field.widget.disabled;
+ if(field.object == null) return;
+ var val = field.object[field.key]();
+ if(val == null) return;
- if( field.widget.type == 'input' )
- field.widget.node.value = val;
+ if( field.widget.type == 'input' )
+ field.widget.node.value = val;
- if( field.widget.type == 'select' )
- setSelector(field.widget.node, val);
+ if( field.widget.type == 'select' )
+ setSelector(field.widget.node, val);
- if( field.widget.type == 'checkbox' )
- field.widget.node.checked =
- (val && val != 'f') ? true : false;
+ if( field.widget.type == 'checkbox' )
+ field.widget.node.checked =
+ (val && val != 'f') ? true : false;
- if( field.widget.onload )
- field.widget.onload(val);
+ if( field.widget.onload )
+ field.widget.onload(val);
}
/* set up the onchange event for the field */
function uEditSetOnchange(field) {
- var func = function() {uEditOnChange( field );}
- field.widget.node.onchange = func;
+ var func = function() {uEditOnChange( field );}
+ field.widget.node.onchange = func;
- if(field.widget.type != 'select')
- field.widget.node.onkeyup = func;
+ if(field.widget.type != 'select')
+ field.widget.node.onkeyup = func;
}
/* find the current value of the field object's widget */
function uEditNodeVal(field) {
- if(field.widget.type == 'input')
- return field.widget.node.value;
+ if(field.widget.type == 'input')
+ return field.widget.node.value;
- if(field.widget.type == 'checkbox')
- return field.widget.node.checked;
+ if(field.widget.type == 'checkbox')
+ return field.widget.node.checked;
- if(field.widget.type == 'select')
- return getSelectorVal(field.widget.node);
+ if(field.widget.type == 'select')
+ return getSelectorVal(field.widget.node);
}
/* update a field value */
function uEditOnChange(field) {
- var newval = uEditNodeVal(field);
- field.object[field.key](newval);
- field.object.ischanged(1);
+ var newval = uEditNodeVal(field);
+ field.object[field.key](newval);
+ field.object.ischanged(1);
- if(field.widget.onpostchange)
- field.widget.onpostchange(field, newval);
+ if(field.widget.onpostchange)
+ field.widget.onpostchange(field, newval);
- //_debug(field.key+' = '+newval);
+ //_debug(field.key+' = '+newval);
- uEditIterateFields(function(f) { uEditCheckValid(f); });
- uEditCheckErrors();
+ uEditIterateFields(function(f) { uEditCheckValid(f); });
+ uEditCheckErrors();
uEditSetUnload();
}
function uEditCheckValid(field) {
- var newval = uEditNodeVal(field);
+ var newval = uEditNodeVal(field);
- if(newval) {
+ if(newval) {
- if(field.widget.regex) {
- if(newval.match(field.widget.regex))
- removeCSSClass(field.widget.node, CSS_INVALID_DATA);
- else
- addCSSClass(field.widget.node, CSS_INVALID_DATA);
+ if(field.widget.regex) {
+ if(newval.match(field.widget.regex))
+ removeCSSClass(field.widget.node, CSS_INVALID_DATA);
+ else
+ addCSSClass(field.widget.node, CSS_INVALID_DATA);
- } else {
- removeCSSClass(field.widget.node, CSS_INVALID_DATA);
- }
+ } else {
+ removeCSSClass(field.widget.node, CSS_INVALID_DATA);
+ }
- } else {
+ } else {
- if(field.required) {
- addCSSClass(field.widget.node, CSS_INVALID_DATA);
+ if(field.required) {
+ addCSSClass(field.widget.node, CSS_INVALID_DATA);
- } else {
- removeCSSClass(field.widget.node, CSS_INVALID_DATA);
- }
- }
+ } else {
+ removeCSSClass(field.widget.node, CSS_INVALID_DATA);
+ }
+ }
}
/* find a field object by object key */
function uEditFindFieldByKey(key) {
- var fields = grep( dataFields,
- function(item) { return (item.key == key); });
- return (fields) ? fields[0] : null;
+ var fields = grep( dataFields,
+ function(item) { return (item.key == key); });
+ return (fields) ? fields[0] : null;
}
/* find a list of fields by object key */
function uEditFindFieldsByKey(key) {
- return grep( dataFields,
- function(item) { return (item.key == key); });
+ return grep( dataFields,
+ function(item) { return (item.key == key); });
}
/* find a field object by widget id */
function uEditFindFieldByWId(id) {
- var fields = grep( dataFields,
- function(item) { return (item.widget.id == id); });
- return (fields) ? fields[0] : null;
+ var fields = grep( dataFields,
+ function(item) { return (item.widget.id == id); });
+ return (fields) ? fields[0] : null;
}
function uEditIterateFields(callback) {
- for( var f in dataFields )
- callback(dataFields[f]);
+ for( var f in dataFields )
+ callback(dataFields[f]);
}
function uEditGetErrorStrings() {
- var errors = [];
- uEditIterateFields(
- function(field) {
- if(field.errkey) {
- if( !field.object.isdeleted() ) {
- if( field.widget.node.className.indexOf(CSS_INVALID_DATA) != -1) {
- var str = $(field.errkey).innerHTML;
- if(str) errors.push(str);
- }
- }
- }
- }
- );
-
- /* munge up something for all of the required surveys
- (which are not registered with the fields) */
- if( patron.isnew() ) {
- var sel = $('ue_survey_table');
-
- if( sel ) {
- var rows = sel.getElementsByTagName('tr');
-
- for( var r in rows ) {
-
- var row = rows[r];
- var sel = $n(row, 'ue_survey_answer');
- if(!sel) continue;
- var qstn = row.getAttribute('question');
-
- if(qstn) {
- qstn = surveyQuestionsCache[qstn];
- survey = surveysCache[qstn.survey()];
- var val = getSelectorVal(sel);
- if(!val && isTrue(survey.required()))
- errors.push($('ue_bad_survey').innerHTML + ' : ' + qstn.question());
- }
- }
- }
- }
-
- /* ------------------------------------------------------------ */
-
- if(errors[0]) return errors;
- return null;
+ var errors = [];
+ uEditIterateFields(
+ function(field) {
+ if(field.errkey) {
+ if( !field.object.isdeleted() ) {
+ if( field.widget.node.className.indexOf(CSS_INVALID_DATA) != -1) {
+ var str = $(field.errkey).innerHTML;
+ if(str) errors.push(str);
+ }
+ }
+ }
+ }
+ );
+
+ /* munge up something for all of the required surveys
+ (which are not registered with the fields) */
+ if( patron.isnew() ) {
+ var sel = $('ue_survey_table');
+
+ if( sel ) {
+ var rows = sel.getElementsByTagName('tr');
+
+ for( var r in rows ) {
+
+ var row = rows[r];
+ var sel = $n(row, 'ue_survey_answer');
+ if(!sel) continue;
+ var qstn = row.getAttribute('question');
+
+ if(qstn) {
+ qstn = surveyQuestionsCache[qstn];
+ survey = surveysCache[qstn.survey()];
+ var val = getSelectorVal(sel);
+ if(!val && isTrue(survey.required()))
+ errors.push($('ue_bad_survey').innerHTML + ' : ' + qstn.question());
+ }
+ }
+ }
+ }
+
+ /* ------------------------------------------------------------ */
+
+ if(errors[0]) return errors;
+ return null;
}
function uEditAlertErrors() {
- var errors = uEditGetErrorStrings();
- if(!errors) return false;
- alert(errors.join("\n"));
- return true;
+ var errors = uEditGetErrorStrings();
+ if(!errors) return false;
+ alert(errors.join("\n"));
+ return true;
}
/* send the user to the database */
function uEditSaveUser(cloneme) {
- if(uEditGetErrorStrings()) {
- uEditAlertErrors();
- return;
- }
+ if(uEditGetErrorStrings()) {
+ uEditAlertErrors();
+ return;
+ }
- /* null is unique in the db, but '' is not */
- if( ! patron.ident_value() ) patron.ident_value(null);
- //if( ! patron.ident_type2() ) patron.ident_type2(null);
- if( ! patron.ident_value2() ) patron.ident_value2(null);
- patron.ident_type2(null);
+ /* null is unique in the db, but '' is not */
+ if( ! patron.ident_value() ) patron.ident_value(null);
+ //if( ! patron.ident_type2() ) patron.ident_type2(null);
+ if( ! patron.ident_value2() ) patron.ident_value2(null);
+ patron.ident_type2(null);
- if(! patron.dob() ) patron.dob(null);
+ if(! patron.dob() ) patron.dob(null);
- _debug("Saving patron with card: " + js2JSON(patron.card()));
- _debug("Saving full patron: " + js2JSON(patron));
+ _debug("Saving patron with card: " + js2JSON(patron.card()));
+ _debug("Saving full patron: " + js2JSON(patron));
- //for( var c in patron
+ //for( var c in patron
- var req = new Request(UPDATE_PATRON, SESSION, patron);
- req.alertEvent = false;
- req.send(true);
- var newuser = req.result();
+ var req = new Request(UPDATE_PATRON, SESSION, patron);
+ req.alertEvent = false;
+ req.send(true);
+ var newuser = req.result();
uEditClearUnload();
- var evt;
- if( (evt = checkILSEvent(newuser)) || ! newuser ) {
- if(evt) {
+ var evt;
+ if( (evt = checkILSEvent(newuser)) || ! newuser ) {
+ if(evt) {
evt = newuser;
if( evt.textcode == 'XACT_COLLISION' ) {
if( confirmId('ue_xact_collision') )
return;
}
var j = js2JSON(evt);
- alert(j);
- _debug("USER UPDATE FAILED:\n" + j);
- }
- return;
- }
+ alert(j);
+ _debug("USER UPDATE FAILED:\n" + j);
+ }
+ return;
+ }
- alert($('ue_success').innerHTML);
+ alert($('ue_success').innerHTML);
- if(cloneme) {
- /* if the user we just created was a clone, and we want to clone it,
- we really want to clone the original */
- if( clone ) cloneme = clone;
- else cloneme = newuser.id();
- }
+ if(cloneme) {
+ /* if the user we just created was a clone, and we want to clone it,
+ we really want to clone the original */
+ if( clone ) cloneme = clone;
+ else cloneme = newuser.id();
+ }
- if( cloneme ) {
+ if( cloneme ) {
- if(window.xulG &&
- typeof window.xulG.spawn_editor == 'function' &&
+ if(window.xulG &&
+ typeof window.xulG.spawn_editor == 'function' &&
- !patron.isnew() ) {
- _debug("xulG clone spawning new interface...");
- var ses = cgi.param('ses');
- if (xulG) if (xulG.ses) ses = xulG.ses;
- if (xulG) if (xulG.params) if (xulG.params.ses) ses = xulG.params.ses;
- window.xulG.spawn_editor({ses:ses,clone:cloneme});
- uEditRefresh();
+ !patron.isnew() ) {
+ _debug("xulG clone spawning new interface...");
+ var ses = cgi.param('ses');
+ if (xulG) if (xulG.ses) ses = xulG.ses;
+ if (xulG) if (xulG.params) if (xulG.params.ses) ses = xulG.params.ses;
+ window.xulG.spawn_editor({ses:ses,clone:cloneme});
+ uEditRefresh();
- } else {
+ } else {
- var href = location.href;
- href = href.replace(/\&?usr=\d+/, '');
- href = href.replace(/\&?clone=\d+/, '');
- href += '&clone=' + cloneme;
- location.href = href;
- }
+ var href = location.href;
+ href = href.replace(/\&?usr=\d+/, '');
+ href = href.replace(/\&?clone=\d+/, '');
+ href += '&clone=' + cloneme;
+ location.href = href;
+ }
- } else {
+ } else {
- uEditRefresh();
- }
+ uEditRefresh();
+ }
- uEditRefreshXUL(newuser);
+ uEditRefreshXUL(newuser);
}
function uEditRefreshXUL(newuser) {
- if (window.xulG && typeof window.xulG.on_save == 'function')
- window.xulG.on_save(newuser);
+ if (window.xulG && typeof window.xulG.on_save == 'function')
+ window.xulG.on_save(newuser);
}
function uEditRefresh() {
- var href = location.href;
- href = href.replace(/\&?clone=\d+/, '');
- location.href = href;
+ var href = location.href;
+ href = href.replace(/\&?clone=\d+/, '');
+ location.href = href;
}
function uEditCancel() {
- var href = location.href;
- href = href.replace(/\&?usr=\d+/, '');
- href = href.replace(/\&?clone=\d+/, '');
- var id = cgi.param('usr');
- if (xulG) if (xulG.usr) id = xulG.usr;
- if (xulG) if (xulG.params) if (xulG.params.usr) id = xulG.params.usr;
- /* reload the current user if available */
- if( id ) href += (href.match(/\?/) ? "&" : "?") + "usr=" + id;
- location.href = href;
+ var href = location.href;
+ href = href.replace(/\&?usr=\d+/, '');
+ href = href.replace(/\&?clone=\d+/, '');
+ var id = cgi.param('usr');
+ if (xulG) if (xulG.usr) id = xulG.usr;
+ if (xulG) if (xulG.params) if (xulG.params.usr) id = xulG.params.usr;
+ /* reload the current user if available */
+ if( id ) href += (href.match(/\?/) ? "&" : "?") + "usr=" + id;
+ location.href = href;
}
function uEditRunDupeSearch(type, search_hash) {
- if(!patron.isnew()) return;
+ if(!patron.isnew()) return;
- _debug('dup search: ' + js2JSON(search_hash));
+ _debug('dup search: ' + js2JSON(search_hash));
- var req = new Request(PATRON_SEARCH, SESSION, search_hash);
+ var req = new Request(PATRON_SEARCH, SESSION, search_hash);
- var container = $('dup_div_container');
- if(!uEditDupTemplate)
- uEditDupTemplate = container.removeChild($('dup_div'));
+ var container = $('dup_div_container');
+ if(!uEditDupTemplate)
+ uEditDupTemplate = container.removeChild($('dup_div'));
- /* clear any existing dups for this type */
- iterate( container.getElementsByTagName('div'),
- function(d) {
- if( d.getAttribute('type') == type ) {
- container.removeChild(d)
- return;
- }
- }
- );
+ /* clear any existing dups for this type */
+ iterate( container.getElementsByTagName('div'),
+ function(d) {
+ if( d.getAttribute('type') == type ) {
+ container.removeChild(d)
+ return;
+ }
+ }
+ );
- req.callback(
- function(r) {
- uEditHandleDupResults( r.getResultObject(), search_hash, type, container );
- }
- );
- req.send();
+ req.callback(
+ function(r) {
+ uEditHandleDupResults( r.getResultObject(), search_hash, type, container );
+ }
+ );
+ req.send();
}
function uEditHandleDupResults(ids, search_hash, type, container) {
- _debug('dup search results: ' + js2JSON(ids));
+ _debug('dup search results: ' + js2JSON(ids));
- if(!(ids && ids[0])) /* no results */
- return uEditDupHashes[type] = null;
+ if(!(ids && ids[0])) /* no results */
+ return uEditDupHashes[type] = null;
- /* add a dup link to the UI and plug in the data */
- var node = uEditDupTemplate.cloneNode(true);
- container.appendChild(node);
- node.setAttribute('type', type);
+ /* add a dup link to the UI and plug in the data */
+ var node = uEditDupTemplate.cloneNode(true);
+ container.appendChild(node);
+ node.setAttribute('type', type);
- var link = $n(node, 'link');
- link.setAttribute('type', type);
- unHideMe(link);
- $n(node,'count').appendChild(text(ids.length));
+ var link = $n(node, 'link');
+ link.setAttribute('type', type);
+ unHideMe(link);
+ $n(node,'count').appendChild(text(ids.length));
- for( var o in search_hash )
- $n(node, 'data').appendChild(
- text(search_hash[o].value + ' '));
+ for( var o in search_hash )
+ $n(node, 'data').appendChild(
+ text(search_hash[o].value + ' '));
- uEditDupHashes[type] = search_hash;
+ uEditDupHashes[type] = search_hash;
- switch(type) {
- case 'ident' :
- if(confirm($('ue_dup_ident1').innerHTML))
- uEditShowSearch(null, type);
- break;
- }
+ switch(type) {
+ case 'ident' :
+ if(confirm($('ue_dup_ident1').innerHTML))
+ uEditShowSearch(null, type);
+ break;
+ }
}
function uEditShowSearch(link,type) {
- if(!type) type = link.getAttribute('type');
- if(window.xulG)
- window.xulG.spawn_search(uEditDupHashes[type]);
- else alert($("patronStrings").getString('web.staff.patron.ue.uedit_show_search.search_would_be', js2JSON(uEditDupHashes[type])));
+ if(!type) type = link.getAttribute('type');
+ if(window.xulG)
+ window.xulG.spawn_search(uEditDupHashes[type]);
+ else alert($("patronStrings").getString('web.staff.patron.ue.uedit_show_search.search_would_be', js2JSON(uEditDupHashes[type])));
}
function uEditMarkCardLost() {
- for( var c in patron.cards() ) {
-
- var card = patron.cards()[c];
- if( patron.card().id() == card.id() ) {
+ for( var c in patron.cards() ) {
- /* de-activite the current card */
- card.ischanged(1);
- card.active(0);
+ var card = patron.cards()[c];
+ if( patron.card().id() == card.id() ) {
- if( !card.barcode() ) {
- /* a card exists in the array with no barcode */
- ueRemoveCard(card.id());
+ /* de-activite the current card */
+ card.ischanged(1);
+ card.active(0);
- } else if( card.isnew() && card.active() == 0 ) {
- /* a new card was created, then never used, removing.. */
- _debug("removing new inactive card "+card.barcode());
- ueRemoveCard(card.id());
- }
-
- /* create a new card for the patron */
- var newcard = new ac();
- newcard.id(uEditCardVirtId--);
- newcard.isnew(1);
- patron.card(newcard);
- patron.cards().push(newcard);
+ if( !card.barcode() ) {
+ /* a card exists in the array with no barcode */
+ ueRemoveCard(card.id());
+ } else if( card.isnew() && card.active() == 0 ) {
+ /* a new card was created, then never used, removing.. */
+ _debug("removing new inactive card "+card.barcode());
+ ueRemoveCard(card.id());
+ }
- /* reset the widget */
- var field = uEditFindFieldByWId('ue_barcode');
- field.widget.node.disabled = false;
- field.widget.node.value = "";
- field.widget.node.onchange();
- field.object = newcard;
- _debug("uEditMarkCardLost(): created new card object for user");
- }
- }
+ /* create a new card for the patron */
+ var newcard = new ac();
+ newcard.id(uEditCardVirtId--);
+ newcard.isnew(1);
+ patron.card(newcard);
+ patron.cards().push(newcard);
+
+
+ /* reset the widget */
+ var field = uEditFindFieldByWId('ue_barcode');
+ field.widget.node.disabled = false;
+ field.widget.node.value = "";
+ field.widget.node.onchange();
+ field.object = newcard;
+ _debug("uEditMarkCardLost(): created new card object for user");
+ }
+ }
}
function ueRemoveCard(id) {
- _debug("removing card from cards() array: " + id);
- var cds = grep( patron.cards(), function(c){return (c.id() != id)});
- if(!cds) cds = [];
- for( var j = 0; j < cds.length; j++ )
- _debug("patron card array now has : "+cds[j].id());
- patron.cards(cds);
+ _debug("removing card from cards() array: " + id);
+ var cds = grep( patron.cards(), function(c){return (c.id() != id)});
+ if(!cds) cds = [];
+ for( var j = 0; j < cds.length; j++ )
+ _debug("patron card array now has : "+cds[j].id());
+ patron.cards(cds);
}
function compactArray(arr) {
- var a = [];
- for( var i = 0; arr && i < arr.length; i++ ) {
- if( arr[i] != null )
- a.push(arr[i]);
- }
- return a;
+ var a = [];
+ for( var i = 0; arr && i < arr.length; i++ ) {
+ if( arr[i] != null )
+ a.push(arr[i]);
+ }
+ return a;
}
/* -----------------------------------------------------------------------
- ----------------------------------------------------------------------- */
-const SC_FETCH_ALL = 'open-ils.circ:open-ils.circ.stat_cat.actor.retrieve.all';
-const SC_CREATE_MAP = 'open-ils.circ:open-ils.circ.stat_cat.actor.user_map.create';
-const SV_FETCH_ALL = 'open-ils.circ:open-ils.circ.survey.retrieve.all';
-const FETCH_ID_TYPES = 'open-ils.actor:open-ils.actor.user.ident_types.retrieve';
-const FETCH_GROUPS = 'open-ils.actor:open-ils.actor.groups.tree.retrieve';
-const FETCH_NET_LEVELS = 'open-ils.actor:open-ils.actor.net_access_level.retrieve.all';
-const UPDATE_PATRON = 'open-ils.actor:open-ils.actor.patron.update';
-const PATRON_SEARCH = 'open-ils.actor:open-ils.actor.patron.search.advanced';
-const ZIP_SEARCH = 'open-ils.search:open-ils.search.zip';
-const APPROVE_ADDR = 'open-ils.actor:open-ils.actor.user.pending_address.approve';
-const FETCH_ADDR_MEMS = 'open-ils.actor:open-ils.actor.address.members';
-const FETCH_GRP_MEMS = 'open-ils.actor:open-ils.actor.usergroup.members.retrieve';
-const CREATE_USER_NOTE = 'open-ils.actor:open-ils.actor.note.create';
-const CHECK_BARCODE = 'open-ils.actor:open-ils.actor.barcode.exists';
-const defaultState = 'GA';
-const defaultCountry = 'USA';
-const defaultNetAccess = 'None';
+ ----------------------------------------------------------------------- */
+const SC_FETCH_ALL = 'open-ils.circ:open-ils.circ.stat_cat.actor.retrieve.all';
+const SC_CREATE_MAP = 'open-ils.circ:open-ils.circ.stat_cat.actor.user_map.create';
+const SV_FETCH_ALL = 'open-ils.circ:open-ils.circ.survey.retrieve.all';
+const FETCH_ID_TYPES = 'open-ils.actor:open-ils.actor.user.ident_types.retrieve';
+const FETCH_GROUPS = 'open-ils.actor:open-ils.actor.groups.tree.retrieve';
+const FETCH_NET_LEVELS = 'open-ils.actor:open-ils.actor.net_access_level.retrieve.all';
+const UPDATE_PATRON = 'open-ils.actor:open-ils.actor.patron.update';
+const PATRON_SEARCH = 'open-ils.actor:open-ils.actor.patron.search.advanced';
+const ZIP_SEARCH = 'open-ils.search:open-ils.search.zip';
+const APPROVE_ADDR = 'open-ils.actor:open-ils.actor.user.pending_address.approve';
+const FETCH_ADDR_MEMS = 'open-ils.actor:open-ils.actor.address.members';
+const FETCH_GRP_MEMS = 'open-ils.actor:open-ils.actor.usergroup.members.retrieve';
+const CREATE_USER_NOTE = 'open-ils.actor:open-ils.actor.note.create';
+const CHECK_BARCODE = 'open-ils.actor:open-ils.actor.barcode.exists';
+const defaultState = 'GA';
+const defaultCountry = 'USA';
+const defaultNetAccess = 'None';
const defaultNetLevel = 1;
-const CSS_INVALID_DATA = 'invalid_value';
+const CSS_INVALID_DATA = 'invalid_value';
// if no org setting exists
-const DEFAULT_ADULT_AGE = '18 years';
+const DEFAULT_ADULT_AGE = '18 years';
-//const GUARDIAN_NOTE = 'SYSTEM: Parent/Guardian';
+//const GUARDIAN_NOTE = 'SYSTEM: Parent/Guardian';
var dataFields;
-const numRegex = /^\d+$/;
-const wordRegex = /^[\w-]+$/;
-const unameRegex = /^\w[\.\w\@-]*$/;
-const ssnRegex = /^\d{3}-\d{2}-\d{4}$/;
-const dlRegex = /^[a-zA-Z]{2}-\w+/; /* driver's license */
-const phoneRegex = /^\d{3}-\d{3}-\d{4}(| \S+.*)$/i;
-const nonumRegex = /^[^\d\s]+[\d]*$/; /* no numbers, no beginning whitespace */
-const dateRegex = /^\d{4}-\d{2}-\d{2}/;
-const zipRegex = /^\d{5}(-\d{4}|-?$)|(^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$)/;
+const numRegex = /^\d+$/;
+const wordRegex = /^[\w-]+$/;
+const unameRegex = /^\w[\.\w\@-]*$/;
+const ssnRegex = /^\d{3}-\d{2}-\d{4}$/;
+const dlRegex = /^[a-zA-Z]{2}-\w+/; /* driver's license */
+const phoneRegex = /^\d{3}-\d{3}-\d{4}(| \S+.*)$/i;
+const nonumRegex = /^[^\d\s]+[\d]*$/; /* no numbers, no beginning whitespace */
+const dateRegex = /^\d{4}-\d{2}-\d{2}/;
+const zipRegex = /^\d{5}(-\d{4}|-?$)|(^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$)/;
var barredAlerted = false;
function uEditUsrnameBlur(field) {
- var usrname = uEditNodeVal(field);
- if (!usrname) { return; }
- var req = new Request(CHECK_USERNAME, SESSION, usrname);
- req.callback(
- function(r) {
- var res = r.getResultObject();
- if( res !== null && res != patron.id() ) {
- field.widget.onblur = null; /* prevent alert storm */
- alertId('ue_dup_username');
- field.widget.onblur = uEditUsrnameBlur;
- setTimeout(
- function() {
- field.widget.node.focus();
- field.widget.node.select();
- }, 10
- );
- }
- }
- );
- req.send();
+ var usrname = uEditNodeVal(field);
+ if (!usrname) { return; }
+ var req = new Request(CHECK_USERNAME, SESSION, usrname);
+ req.callback(
+ function(r) {
+ var res = r.getResultObject();
+ if( res !== null && res != patron.id() ) {
+ field.widget.onblur = null; /* prevent alert storm */
+ alertId('ue_dup_username');
+ field.widget.onblur = uEditUsrnameBlur;
+ setTimeout(
+ function() {
+ field.widget.node.focus();
+ field.widget.node.select();
+ }, 10
+ );
+ }
+ }
+ );
+ req.send();
}
function uEditBarcodeBlur(field) {
- var barcode = uEditNodeVal(field);
- if(!barcode) return;
- _debug("blurring card with new value " + barcode);
- var req = new Request(CHECK_BARCODE, SESSION, barcode);
- req.callback(
- function(r) {
- var res = r.getResultObject();
- if( res == 1 ) {
- field.widget.onblur = null; /* prevent alert storm */
- alertId('ue_dup_barcode');
- field.widget.onblur = uEditBarcodeBlur;
- setTimeout(
- function() {
- field.widget.node.focus();
- field.widget.node.select();
- }, 10
- );
- } else {
- var node = uEditFindFieldByWId("ue_username");
- if(!node.widget.node.value) {
- node.widget.node.value = barcode;
- node.widget.node.onchange();
- }
- }
- }
- );
- req.send();
+ var barcode = uEditNodeVal(field);
+ if(!barcode) return;
+ _debug("blurring card with new value " + barcode);
+ var req = new Request(CHECK_BARCODE, SESSION, barcode);
+ req.callback(
+ function(r) {
+ var res = r.getResultObject();
+ if( res == 1 ) {
+ field.widget.onblur = null; /* prevent alert storm */
+ alertId('ue_dup_barcode');
+ field.widget.onblur = uEditBarcodeBlur;
+ setTimeout(
+ function() {
+ field.widget.node.focus();
+ field.widget.node.select();
+ }, 10
+ );
+ } else {
+ var node = uEditFindFieldByWId("ue_username");
+ if(!node.widget.node.value) {
+ node.widget.node.value = barcode;
+ node.widget.node.onchange();
+ }
+ }
+ }
+ );
+ req.send();
}
function uEditDefineData(patron) {
- var fields = [
- {
- required : true,
- object : patron.card(),
- key : 'barcode',
- errkey : 'ue_bad_barcode',
- widget : {
- id : 'ue_barcode',
- regex : wordRegex,
- type : 'input',
- onblur : uEditBarcodeBlur
- }
- },
- {
- required : true,
- object : patron,
- key : 'usrname',
- errkey : 'ue_bad_username',
- widget : {
- id : 'ue_username',
- regex : unameRegex,
- type : 'input',
- onblur : uEditUsrnameBlur
- }
- },
- {
- required : (patron.isnew()) ? true : false,
- object : patron,
- key : 'passwd',
- errkey : 'ue_bad_password',
- widget : {
- id : 'ue_password1',
- type : 'input',
- onpostchange : function(field, newval) {
- var pw2 = uEditFindFieldByWId('ue_password2');
- /* tell the second passsword input to re-validate */
- pw2.widget.node.onchange();
- }
-
- }
- },
- {
- required : (patron.isnew()) ? true : false,
- object : patron,
- key : 'passwd',
- errkey : 'ue_bad_password',
- widget : {
- id : 'ue_password2',
- type : 'input',
- onpostchange : function(field, newval) {
- var pw1f = uEditFindFieldByWId('ue_password1');
- var pw1 = uEditNodeVal(pw1f);
- field.widget.regex = new RegExp('^'+pw1+'$');
- if( pw1 ) field.required = true;
- else {
- if(!patron.isnew())
- field.required = false;
- }
- }
- }
- },
- {
- required : true,
- object : patron,
- key : 'first_given_name',
- errkey : 'ue_bad_firstname',
- widget : {
- id : 'ue_firstname',
- regex : nonumRegex,
- type : 'input',
- onblur : function(field) {
- uEditCheckNamesDup('first', field );
- }
- }
- },
- {
- required : false,
- object : patron,
- key : 'second_given_name',
- errkey : 'ue_bad_middlename',
- widget : {
- id : 'ue_middlename',
- regex : nonumRegex,
- type : 'input'
- }
- },
- {
- required : true,
- object : patron,
- key : 'family_name',
- errkey : 'ue_bad_lastname',
- widget : {
- id : 'ue_lastname',
- regex : nonumRegex,
- type : 'input',
- onblur : function(field) {
- uEditCheckNamesDup('last', field );
- }
- }
- },
- {
- required : false,
- object : patron,
- key : 'suffix',
- widget : {
- id : 'ue_suffix',
- type : 'input',
- onload : function(val) {
- setSelector($('ue_suffix_selector'), val);
- $('ue_suffix_selector').onchange = function() {
- uEditFindFieldByKey('suffix').widget.node.onchange();
- }
- },
- }
- },
- {
- required : false,
- object : patron,
- key : 'alias',
- widget : {
- id : 'ue_alias',
- type : 'input',
- }
- },
- {
- required : false,
- object : patron,
- key : 'dob',
- errkey : 'ue_bad_dob',
- widget : {
- id : 'ue_dob',
- regex : dateRegex,
- type : 'input',
- onpostchange : function(field) { uEditCheckDOB(field); },
- onblur : function(field) { uEditCheckDOB(field); }
- }
- },
- {
- required : true,
- object : patron,
- key : 'ident_type',
- errkey : 'ue_no_ident',
- widget : {
- id : 'ue_primary_ident_type',
- regex : numRegex,
- type : 'select',
- onpostchange : function(field, newval)
- { _uEditIdentPostchange('primary', field, newval); }
- }
- },
- {
- required : false,
- object : patron,
- key : 'ident_value',
- widget : {
- id : 'ue_primary_ident',
- type : 'input',
- onblur : function(field) {
- uEditCheckIdentDup(field);
- }
- }
- },
- {
- required : false,
- object : patron,
- key : 'ident_value2',
- widget : {
- id : 'ue_secondary_ident',
- type : 'input'
- }
- },
- {
- required : false,
- object : patron,
- key : 'email',
- errkey : 'ue_bad_email',
- widget : {
- id : 'ue_email',
- type : 'input',
- regex : /.+\@.+\..+/, /* make me better */
- onblur : function(field) {
- var val = uEditNodeVal(field);
- if( val && val != field.oldemail ) {
- uEditRunDupeSearch('email',
- { email : { value : val, group : 0 } });
- field.oldemail = val;
- }
- }
- }
- },
- {
- required : false,
- object : patron,
- key : 'day_phone',
- errkey : 'ue_bad_phone',
- widget : {
- id : 'ue_day_phone',
- type : 'input',
- regex : phoneRegex,
+ var fields = [
+ {
+ required : true,
+ object : patron.card(),
+ key : 'barcode',
+ errkey : 'ue_bad_barcode',
+ widget : {
+ id : 'ue_barcode',
+ regex : wordRegex,
+ type : 'input',
+ onblur : uEditBarcodeBlur
+ }
+ },
+ {
+ required : true,
+ object : patron,
+ key : 'usrname',
+ errkey : 'ue_bad_username',
+ widget : {
+ id : 'ue_username',
+ regex : unameRegex,
+ type : 'input',
+ onblur : uEditUsrnameBlur
+ }
+ },
+ {
+ required : (patron.isnew()) ? true : false,
+ object : patron,
+ key : 'passwd',
+ errkey : 'ue_bad_password',
+ widget : {
+ id : 'ue_password1',
+ type : 'input',
+ onpostchange : function(field, newval) {
+ var pw2 = uEditFindFieldByWId('ue_password2');
+ /* tell the second passsword input to re-validate */
+ pw2.widget.node.onchange();
+ }
+
+ }
+ },
+ {
+ required : (patron.isnew()) ? true : false,
+ object : patron,
+ key : 'passwd',
+ errkey : 'ue_bad_password',
+ widget : {
+ id : 'ue_password2',
+ type : 'input',
+ onpostchange : function(field, newval) {
+ var pw1f = uEditFindFieldByWId('ue_password1');
+ var pw1 = uEditNodeVal(pw1f);
+ field.widget.regex = new RegExp('^'+pw1+'$');
+ if( pw1 ) field.required = true;
+ else {
+ if(!patron.isnew())
+ field.required = false;
+ }
+ }
+ }
+ },
+ {
+ required : true,
+ object : patron,
+ key : 'first_given_name',
+ errkey : 'ue_bad_firstname',
+ widget : {
+ id : 'ue_firstname',
+ regex : nonumRegex,
+ type : 'input',
+ onblur : function(field) {
+ uEditCheckNamesDup('first', field );
+ }
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'second_given_name',
+ errkey : 'ue_bad_middlename',
+ widget : {
+ id : 'ue_middlename',
+ regex : nonumRegex,
+ type : 'input'
+ }
+ },
+ {
+ required : true,
+ object : patron,
+ key : 'family_name',
+ errkey : 'ue_bad_lastname',
+ widget : {
+ id : 'ue_lastname',
+ regex : nonumRegex,
+ type : 'input',
+ onblur : function(field) {
+ uEditCheckNamesDup('last', field );
+ }
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'suffix',
+ widget : {
+ id : 'ue_suffix',
+ type : 'input',
+ onload : function(val) {
+ setSelector($('ue_suffix_selector'), val);
+ $('ue_suffix_selector').onchange = function() {
+ uEditFindFieldByKey('suffix').widget.node.onchange();
+ }
+ },
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'alias',
+ widget : {
+ id : 'ue_alias',
+ type : 'input',
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'dob',
+ errkey : 'ue_bad_dob',
+ widget : {
+ id : 'ue_dob',
+ regex : dateRegex,
+ type : 'input',
+ onpostchange : function(field) { uEditCheckDOB(field); },
+ onblur : function(field) { uEditCheckDOB(field); }
+ }
+ },
+ {
+ required : true,
+ object : patron,
+ key : 'ident_type',
+ errkey : 'ue_no_ident',
+ widget : {
+ id : 'ue_primary_ident_type',
+ regex : numRegex,
+ type : 'select',
+ onpostchange : function(field, newval)
+ { _uEditIdentPostchange('primary', field, newval); }
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'ident_value',
+ widget : {
+ id : 'ue_primary_ident',
+ type : 'input',
+ onblur : function(field) {
+ uEditCheckIdentDup(field);
+ }
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'ident_value2',
+ widget : {
+ id : 'ue_secondary_ident',
+ type : 'input'
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'email',
+ errkey : 'ue_bad_email',
+ widget : {
+ id : 'ue_email',
+ type : 'input',
+ regex : /.+\@.+\..+/, /* make me better */
+ onblur : function(field) {
+ var val = uEditNodeVal(field);
+ if( val && val != field.oldemail ) {
+ uEditRunDupeSearch('email',
+ { email : { value : val, group : 0 } });
+ field.oldemail = val;
+ }
+ }
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'day_phone',
+ errkey : 'ue_bad_phone',
+ widget : {
+ id : 'ue_day_phone',
+ type : 'input',
+ regex : phoneRegex,
onblur : function() {
if(uEditUsePhonePw)
uEditMakePhonePw();
uEditMakePhonePw();
}
}
- }
- },
- {
- required : false,
- object : patron,
- key : 'evening_phone',
- errkey : 'ue_bad_phone',
- widget : {
- id : 'ue_night_phone',
- type : 'input',
- regex : phoneRegex,
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'evening_phone',
+ errkey : 'ue_bad_phone',
+ widget : {
+ id : 'ue_night_phone',
+ type : 'input',
+ regex : phoneRegex,
onblur : function() {
if(uEditUsePhonePw)
uEditMakePhonePw();
}
- }
- },
- {
- required : false,
- object : patron,
- key : 'other_phone',
- errkey : 'ue_bad_phone',
- widget : {
- id : 'ue_other_phone',
- type : 'input',
- regex : phoneRegex,
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'other_phone',
+ errkey : 'ue_bad_phone',
+ widget : {
+ id : 'ue_other_phone',
+ type : 'input',
+ regex : phoneRegex,
onblur : function() {
if(uEditUsePhonePw)
uEditMakePhonePw();
}
- }
- },
- {
- required : true,
- object : patron,
- key : 'home_ou',
- widget : {
- id : 'ue_org_selector',
- type : 'select',
- regex : numRegex,
- }
- },
- {
- required : true,
- object : patron,
- key : 'expire_date',
- errkey : 'ue_bad_expire',
- widget : {
- id : 'ue_expire',
- type : 'input',
- regex : dateRegex,
- }
- },
- {
- required : false,
- object : patron,
- key : 'active',
- widget : {
- id : 'ue_active',
- type : 'checkbox',
- }
- },
- {
- required : false,
- object : patron,
- key : 'juvenile',
- widget : {
- id : 'ue_juvenile',
- type : 'checkbox',
- onpostchange : function(field) { uEditCheckDOB(uEditFindFieldByKey('dob')); },
- onblur : function(field) { uEditCheckDOB(uEditFindFieldByKey('dob')); }
- }
- },
- {
- required : false,
- object : patron,
- key : 'barred',
- widget : {
- id : 'ue_barred',
- type : 'checkbox',
- onpostchange : function(field, val) {
- var afield = uEditFindFieldByKey('alert_message');
- if( val ) {
- if( !barredAlerted ) {
- barredAlerted = true;
- alertId('ue_made_barred');
- }
- afield.required = true;
- } else {
- afield.required = false;
- }
- }
- }
- },
- {
- required : true,
- object : patron,
- key : 'profile',
- errkey : 'ue_no_profile',
- widget : {
- id : 'ue_profile',
- type : 'select',
- regex : numRegex,
- onpostchange : function(field, value) {
- var type = groupsCache[value];
- if(!type) return;
- var interval = type.perm_interval();
-
- /* interval_to_seconds expects 'M' for months, 'm' for minutes */
- interval = interval.replace(/mon/, 'Mon');
- var intsecs = parseInt(interval_to_seconds(interval));
-
- var expdate = new Date();
- var exptime = expdate.getTime();
- exptime += intsecs * 1000;
- expdate.setTime(exptime);
-
- _debug("profile change (interval= '"+interval+"', seconds="+intsecs+")\n\tgenerated a date of " + expdate);
-
- var year = expdate.getYear() + 1900;
- var month = (expdate.getMonth() + 1) + '';
- var day = (expdate.getDate()) + '';
-
- if(!month.match(/\d{2}/)) month = '0' + month;
- if(!day.match(/\d{2}/)) day = '0' + day;
-
-
- var node = $('ue_expire');
- node.value = year+'-'+month+'-'+day;
-
- _debug("profile change formatted date to "+ node.value);
- node.onchange();
- }
- }
- },
- {
- required : false,
- object : patron,
- key : 'net_access_level',
- widget : {
- id : 'ue_net_level',
- type : 'select'
- }
- },
- {
- required : false,
- object : patron,
- key : 'master_account',
- widget : {
- id : 'ue_group_lead',
- type : 'checkbox',
- }
- },
- {
- required : true,
- object : patron,
- key : 'claims_returned_count',
- widget : {
- id : 'ue_claims_returned',
- type : 'input',
- regex : numRegex,
- disabled : true
- }
- },
- {
- required : false,
- object : patron,
- key : 'alert_message',
- widget : {
- id : 'ue_alert_message',
- type : 'input',
- }
- }
- ];
-
- for( var f in fields )
- dataFields.push(fields[f]);
-
- uEditBuildAddrs(patron);
- uEditBuildPatronSCM(patron);
+ }
+ },
+ {
+ required : true,
+ object : patron,
+ key : 'home_ou',
+ widget : {
+ id : 'ue_org_selector',
+ type : 'select',
+ regex : numRegex,
+ }
+ },
+ {
+ required : true,
+ object : patron,
+ key : 'expire_date',
+ errkey : 'ue_bad_expire',
+ widget : {
+ id : 'ue_expire',
+ type : 'input',
+ regex : dateRegex,
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'active',
+ widget : {
+ id : 'ue_active',
+ type : 'checkbox',
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'juvenile',
+ widget : {
+ id : 'ue_juvenile',
+ type : 'checkbox',
+ onpostchange : function(field) { uEditCheckDOB(uEditFindFieldByKey('dob')); },
+ onblur : function(field) { uEditCheckDOB(uEditFindFieldByKey('dob')); }
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'barred',
+ widget : {
+ id : 'ue_barred',
+ type : 'checkbox',
+ onpostchange : function(field, val) {
+ var afield = uEditFindFieldByKey('alert_message');
+ if( val ) {
+ if( !barredAlerted ) {
+ barredAlerted = true;
+ alertId('ue_made_barred');
+ }
+ afield.required = true;
+ } else {
+ afield.required = false;
+ }
+ }
+ }
+ },
+ {
+ required : true,
+ object : patron,
+ key : 'profile',
+ errkey : 'ue_no_profile',
+ widget : {
+ id : 'ue_profile',
+ type : 'select',
+ regex : numRegex,
+ onpostchange : function(field, value) {
+ var type = groupsCache[value];
+ if(!type) return;
+ var interval = type.perm_interval();
+
+ /* interval_to_seconds expects 'M' for months, 'm' for minutes */
+ interval = interval.replace(/mon/, 'Mon');
+ var intsecs = parseInt(interval_to_seconds(interval));
+
+ var expdate = new Date();
+ var exptime = expdate.getTime();
+ exptime += intsecs * 1000;
+ expdate.setTime(exptime);
+
+ _debug("profile change (interval= '"+interval+"', seconds="+intsecs+")\n\tgenerated a date of " + expdate);
+
+ var year = expdate.getYear() + 1900;
+ var month = (expdate.getMonth() + 1) + '';
+ var day = (expdate.getDate()) + '';
+
+ if(!month.match(/\d{2}/)) month = '0' + month;
+ if(!day.match(/\d{2}/)) day = '0' + day;
+
+
+ var node = $('ue_expire');
+ node.value = year+'-'+month+'-'+day;
+
+ _debug("profile change formatted date to "+ node.value);
+ node.onchange();
+ }
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'net_access_level',
+ widget : {
+ id : 'ue_net_level',
+ type : 'select'
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'master_account',
+ widget : {
+ id : 'ue_group_lead',
+ type : 'checkbox',
+ }
+ },
+ {
+ required : true,
+ object : patron,
+ key : 'claims_returned_count',
+ widget : {
+ id : 'ue_claims_returned',
+ type : 'input',
+ regex : numRegex,
+ disabled : true
+ }
+ },
+ {
+ required : false,
+ object : patron,
+ key : 'alert_message',
+ widget : {
+ id : 'ue_alert_message',
+ type : 'input',
+ }
+ }
+ ];
+
+ for( var f in fields )
+ dataFields.push(fields[f]);
+
+ uEditBuildAddrs(patron);
+ uEditBuildPatronSCM(patron);
}
var uEditOldFirstName;
var uEditOldMiddleName; /* future */
var uEditOldLastName;
function uEditCheckNamesDup(type, field) {
- var newval = uEditNodeVal(field);
- if(!newval) return;
-
- var dosearch = false;
-
- if(type =='first') {
- if( newval != uEditOldFirstName )
- dosearch = true;
- uEditOldFirstName = newval;
- }
-
- if(type =='last') {
- if( newval != uEditOldLastName )
- dosearch = true;
- uEditOldLastName = newval;
- }
-
- if( dosearch && uEditOldFirstName && uEditOldLastName ) {
- var search_hash = {};
- search_hash['first_given_name'] = { value : uEditOldFirstName, group : 0 };
- search_hash['family_name'] = { value : uEditOldLastName, group : 0 };
- uEditRunDupeSearch('names', search_hash);
- }
+ var newval = uEditNodeVal(field);
+ if(!newval) return;
+
+ var dosearch = false;
+
+ if(type =='first') {
+ if( newval != uEditOldFirstName )
+ dosearch = true;
+ uEditOldFirstName = newval;
+ }
+
+ if(type =='last') {
+ if( newval != uEditOldLastName )
+ dosearch = true;
+ uEditOldLastName = newval;
+ }
+
+ if( dosearch && uEditOldFirstName && uEditOldLastName ) {
+ var search_hash = {};
+ search_hash['first_given_name'] = { value : uEditOldFirstName, group : 0 };
+ search_hash['family_name'] = { value : uEditOldLastName, group : 0 };
+ uEditRunDupeSearch('names', search_hash);
+ }
}
var uEditOldIdentValue;
function uEditCheckIdentDup(field) {
- var newval = uEditNodeVal(field);
- if( newval && newval != uEditOldIdentValue ) {
- /* searches all ident_value fields */
- var search_hash = { ident : { value : newval, group : 2 } };
- uEditRunDupeSearch('ident', search_hash);
- uEditOldIdentValue = newval;
- }
+ var newval = uEditNodeVal(field);
+ if( newval && newval != uEditOldIdentValue ) {
+ /* searches all ident_value fields */
+ var search_hash = { ident : { value : newval, group : 2 } };
+ uEditRunDupeSearch('ident', search_hash);
+ uEditOldIdentValue = newval;
+ }
}
/* Adds all of the addresses attached to the patron object
- to the fields array */
+ to the fields array */
var uEditAddrTemplate;
function uEditBuildAddrs(patron) {
- var tbody = $('ue_address_tbody');
- if(!uEditAddrTemplate)
- uEditAddrTemplate = tbody.removeChild($('ue_address_template'));
- for( var a in patron.addresses() )
- uEditBuildAddrFields( patron, patron.addresses()[a]);
+ var tbody = $('ue_address_tbody');
+ if(!uEditAddrTemplate)
+ uEditAddrTemplate = tbody.removeChild($('ue_address_template'));
+ for( var a in patron.addresses() )
+ uEditBuildAddrFields( patron, patron.addresses()[a]);
}
function uEditDeleteAddr( tbody, row, address, detach ) {
- if(!confirm($('ue_delete_addr_warn').innerHTML)) return;
- if(address.isnew()) {
- patron.addresses(
- grep( patron.addresses(),
- function(i) {
- return (i.id() != address.id());
- }
- )
- );
+ if(!confirm($('ue_delete_addr_warn').innerHTML)) return;
+ if(address.isnew()) {
+ patron.addresses(
+ grep( patron.addresses(),
+ function(i) {
+ return (i.id() != address.id());
+ }
+ )
+ );
if(!patron.addresses())
patron.addresses([]);
- /* XXX */
- for( var f in dataFields ) {
- if( dataFields[f].object == address ) {
- dataFields[f] = null;
- }
- }
-
- dataFields = compactArray(dataFields);
-
- } else {
-
- if( detach ) { /* remove the offending address from the list */
- patron.addresses(
- grep(
- patron.addresses(),
- function(i) {
- return (i.id() != address.id());
- }
- )
- );
+ /* XXX */
+ for( var f in dataFields ) {
+ if( dataFields[f].object == address ) {
+ dataFields[f] = null;
+ }
+ }
+
+ dataFields = compactArray(dataFields);
+
+ } else {
+
+ if( detach ) { /* remove the offending address from the list */
+ patron.addresses(
+ grep(
+ patron.addresses(),
+ function(i) {
+ return (i.id() != address.id());
+ }
+ )
+ );
if(!patron.addresses()) {
patron.addresses([]);
patron.billing_address(null);
}
- } else {
- address.isdeleted(1);
- }
- }
+ } else {
+ address.isdeleted(1);
+ }
+ }
- tbody.removeChild(row);
+ tbody.removeChild(row);
- var bid = patron.billing_address();
+ var bid = patron.billing_address();
bid = (bid != null && typeof bid == 'object') ? bid.id() : bid;
- var mid = patron.mailing_address();
+ var mid = patron.mailing_address();
mid = (mid != null && typeof mid == 'object') ? mid.id() : mid;
- /* -----------------------------------------------------------------------
- if we're deleting a billing or mailing address
- make sure some other address is automatically
- assigned as the billing or mailng address
- ----------------------------------------------------------------------- */
-
- if( bid == address.id() ) {
- for( var a in patron.addresses() ) {
- var addr = patron.addresses()[a];
- if(!addr.isdeleted() && addr.id() != address.id()) {
- var node = uEditFindAddrInput('billing', addr.id());
- node.checked = true;
- uEditAddrTypeClick(node, 'billing');
- break;
- }
- }
- }
-
- if( mid == address.id() ) {
- for( var a in patron.addresses() ) {
- var addr = patron.addresses()[a];
- if(!addr.isdeleted() && addr.id() != address.id()) {
- var node = uEditFindAddrInput('mailing', addr.id());
- node.checked = true;
- uEditAddrTypeClick(node, 'mailing');
- break;
- }
- }
- }
+ /* -----------------------------------------------------------------------
+ if we're deleting a billing or mailing address
+ make sure some other address is automatically
+ assigned as the billing or mailng address
+ ----------------------------------------------------------------------- */
+
+ if( bid == address.id() ) {
+ for( var a in patron.addresses() ) {
+ var addr = patron.addresses()[a];
+ if(!addr.isdeleted() && addr.id() != address.id()) {
+ var node = uEditFindAddrInput('billing', addr.id());
+ node.checked = true;
+ uEditAddrTypeClick(node, 'billing');
+ break;
+ }
+ }
+ }
+
+ if( mid == address.id() ) {
+ for( var a in patron.addresses() ) {
+ var addr = patron.addresses()[a];
+ if(!addr.isdeleted() && addr.id() != address.id()) {
+ var node = uEditFindAddrInput('mailing', addr.id());
+ node.checked = true;
+ uEditAddrTypeClick(node, 'mailing');
+ break;
+ }
+ }
+ }
}
var oldId = r.getResultObject();
if(oldId != null) {
// remove the replaced address
- patron.addresses(
- grep( patron.addresses(),
- function(i) { return (i.id() != oldId); }
- )
- );
+ patron.addresses(
+ grep( patron.addresses(),
+ function(i) { return (i.id() != oldId); }
+ )
+ );
// update the ID on the new address
address.id(oldId);
address.replaces(null);
address.pending('f');
removeChildren($('ue_address_tbody'));
- uEditBuildAddrs(patron);
+ uEditBuildAddrs(patron);
}
}
);
function uEditFindAddrInput(type, id) {
- var tbody = $('ue_address_tbody');
- var rows = tbody.getElementsByTagName('tr');
- for( var r in rows ) {
- var row = rows[r];
- if(row.parentNode != tbody) continue;
- var node = $n(row, 'ue_addr_'+type+'_yes');
- if( node.getAttribute('address') == id )
- return node;
- }
+ var tbody = $('ue_address_tbody');
+ var rows = tbody.getElementsByTagName('tr');
+ for( var r in rows ) {
+ var row = rows[r];
+ if(row.parentNode != tbody) continue;
+ var node = $n(row, 'ue_addr_'+type+'_yes');
+ if( node.getAttribute('address') == id )
+ return node;
+ }
}
function uEditAddrTypeClick(input, type) {
- var tbody = $('ue_address_tbody');
- var rows = tbody.getElementsByTagName('tr');
- for( var r in rows ) {
- var row = rows[r];
- if(row.parentNode != tbody) continue;
- var node = $n(row, 'ue_addr_'+type+'_yes');
- removeCSSClass(node.parentNode,'addr_info_checked');
- }
-
- addCSSClass(input.parentNode,'addr_info_checked');
- patron[type+'_address'](input.getAttribute('address'));
- patron.ischanged(1);
+ var tbody = $('ue_address_tbody');
+ var rows = tbody.getElementsByTagName('tr');
+ for( var r in rows ) {
+ var row = rows[r];
+ if(row.parentNode != tbody) continue;
+ var node = $n(row, 'ue_addr_'+type+'_yes');
+ removeCSSClass(node.parentNode,'addr_info_checked');
+ }
+
+ addCSSClass(input.parentNode,'addr_info_checked');
+ patron[type+'_address'](input.getAttribute('address'));
+ patron.ischanged(1);
}
/* Creates the field entries for an address object. */
function uEditBuildAddrFields(patron, address) {
- var tbody = $('ue_address_tbody');
+ var tbody = $('ue_address_tbody');
- var row = tbody.appendChild(
- uEditAddrTemplate.cloneNode(true));
+ var row = tbody.appendChild(
+ uEditAddrTemplate.cloneNode(true));
- uEditCheckSharedAddr(patron, address, tbody, row);
+ uEditCheckSharedAddr(patron, address, tbody, row);
// see if this is a pending address
if( isTrue(address.pending()) ) {
}
}
- $n(row, 'ue_addr_delete').onclick =
- function() {
- uEditDeleteAddr(tbody, row, address);
- uEditCheckErrors();
- };
-
- if( patron.billing_address() &&
- address.id() == patron.billing_address().id() )
- $n(row, 'ue_addr_billing_yes').checked = true;
-
- if( patron.mailing_address() &&
- address.id() == patron.mailing_address().id() )
- $n(row, 'ue_addr_mailing_yes').checked = true;
-
- $n(row, 'ue_addr_billing_yes').setAttribute('address', address.id());
- $n(row, 'ue_addr_mailing_yes').setAttribute('address', address.id());
-
- /* currently, non-owners cannot edit an address */
- var disabled = (address.usr() != patron.id())
-
- var fields = [
- {
- required : false,
- object : address,
- key : 'address_type',
- widget : {
- base : row,
- name : 'ue_addr_label',
- type : 'input',
- disabled : disabled,
- }
- },
- {
- required : true,
- object : address,
- key : 'street1',
- errkey : 'ue_bad_addr_street',
- widget : {
- base : row,
- name : 'ue_addr_street1',
- type : 'input',
- disabled : disabled,
- }
- },
- {
- required : false,
- object : address,
- key : 'street2',
- errkey : 'ue_bad_addr_street',
- widget : {
- base : row,
- name : 'ue_addr_street2',
- type : 'input',
- disabled : disabled,
- }
- },
- {
- required : true,
- object : address,
- key : 'city',
- errkey : 'ue_bad_addr_city',
- widget : {
- base : row,
- name : 'ue_addr_city',
- type : 'input',
- disabled : disabled,
- }
- },
- {
- required : false,
- object : address,
- key : 'county',
- widget : {
- base : row,
- name : 'ue_addr_county',
- type : 'input',
- disabled : disabled,
- }
- },
- {
- required : true,
- object : address,
- key : 'state',
- errkey : 'ue_bad_addr_state',
- widget : {
- base : row,
- name : 'ue_addr_state',
- type : 'input',
- disabled : disabled,
- }
- },
- {
- required : true,
- object : address,
- key : 'country',
- errkey : 'ue_bad_addr_country',
- widget : {
- base : row,
- name : 'ue_addr_country',
- type : 'input',
- disabled : disabled,
- }
- },
- {
- required : true,
- object : address,
- key : 'post_code',
- errkey : 'ue_bad_addr_zip',
- widget : {
- base : row,
- name : 'ue_addr_zip',
- type : 'input',
- disabled : disabled,
- regex : zipRegex,
- onblur : function(f) {
- var v = uEditNodeVal(f);
- var req = new Request(ZIP_SEARCH, v);
- req.callback(
- function(r) {
- var info = r.getResultObject();
- if(!info) return;
- var state = $n(f.widget.base, 'ue_addr_state');
- var county = $n(f.widget.base, 'ue_addr_county');
- var city = $n(f.widget.base, 'ue_addr_city');
- state.value = info.state;
- state.onchange();
- county.value = info.county;
- county.onchange();
- city.value = info.city;
- city.onchange();
- }
- );
- req.send();
- }
- }
- },
- {
- required : false,
- object : address,
- key : 'within_city_limits',
- widget : {
- base : row,
- name : 'ue_addr_inc_yes',
- type : 'checkbox',
- disabled : disabled,
- }
- },
- {
- required : false,
- object : address,
- key : 'valid',
- widget : {
- base : row,
- name : 'ue_addr_valid_yes',
- type : 'checkbox',
- disabled : disabled,
- }
- }
- ];
-
- for( var f in fields ) {
- dataFields.push(fields[f]);
- uEditActivateField(fields[f]);
- }
+ $n(row, 'ue_addr_delete').onclick =
+ function() {
+ uEditDeleteAddr(tbody, row, address);
+ uEditCheckErrors();
+ };
+
+ if( patron.billing_address() &&
+ address.id() == patron.billing_address().id() )
+ $n(row, 'ue_addr_billing_yes').checked = true;
+
+ if( patron.mailing_address() &&
+ address.id() == patron.mailing_address().id() )
+ $n(row, 'ue_addr_mailing_yes').checked = true;
+
+ $n(row, 'ue_addr_billing_yes').setAttribute('address', address.id());
+ $n(row, 'ue_addr_mailing_yes').setAttribute('address', address.id());
+
+ /* currently, non-owners cannot edit an address */
+ var disabled = (address.usr() != patron.id())
+
+ var fields = [
+ {
+ required : false,
+ object : address,
+ key : 'address_type',
+ widget : {
+ base : row,
+ name : 'ue_addr_label',
+ type : 'input',
+ disabled : disabled,
+ }
+ },
+ {
+ required : true,
+ object : address,
+ key : 'street1',
+ errkey : 'ue_bad_addr_street',
+ widget : {
+ base : row,
+ name : 'ue_addr_street1',
+ type : 'input',
+ disabled : disabled,
+ }
+ },
+ {
+ required : false,
+ object : address,
+ key : 'street2',
+ errkey : 'ue_bad_addr_street',
+ widget : {
+ base : row,
+ name : 'ue_addr_street2',
+ type : 'input',
+ disabled : disabled,
+ }
+ },
+ {
+ required : true,
+ object : address,
+ key : 'city',
+ errkey : 'ue_bad_addr_city',
+ widget : {
+ base : row,
+ name : 'ue_addr_city',
+ type : 'input',
+ disabled : disabled,
+ }
+ },
+ {
+ required : false,
+ object : address,
+ key : 'county',
+ widget : {
+ base : row,
+ name : 'ue_addr_county',
+ type : 'input',
+ disabled : disabled,
+ }
+ },
+ {
+ required : true,
+ object : address,
+ key : 'state',
+ errkey : 'ue_bad_addr_state',
+ widget : {
+ base : row,
+ name : 'ue_addr_state',
+ type : 'input',
+ disabled : disabled,
+ }
+ },
+ {
+ required : true,
+ object : address,
+ key : 'country',
+ errkey : 'ue_bad_addr_country',
+ widget : {
+ base : row,
+ name : 'ue_addr_country',
+ type : 'input',
+ disabled : disabled,
+ }
+ },
+ {
+ required : true,
+ object : address,
+ key : 'post_code',
+ errkey : 'ue_bad_addr_zip',
+ widget : {
+ base : row,
+ name : 'ue_addr_zip',
+ type : 'input',
+ disabled : disabled,
+ regex : zipRegex,
+ onblur : function(f) {
+ var v = uEditNodeVal(f);
+ var req = new Request(ZIP_SEARCH, v);
+ req.callback(
+ function(r) {
+ var info = r.getResultObject();
+ if(!info) return;
+ var state = $n(f.widget.base, 'ue_addr_state');
+ var county = $n(f.widget.base, 'ue_addr_county');
+ var city = $n(f.widget.base, 'ue_addr_city');
+ state.value = info.state;
+ state.onchange();
+ county.value = info.county;
+ county.onchange();
+ city.value = info.city;
+ city.onchange();
+ }
+ );
+ req.send();
+ }
+ }
+ },
+ {
+ required : false,
+ object : address,
+ key : 'within_city_limits',
+ widget : {
+ base : row,
+ name : 'ue_addr_inc_yes',
+ type : 'checkbox',
+ disabled : disabled,
+ }
+ },
+ {
+ required : false,
+ object : address,
+ key : 'valid',
+ widget : {
+ base : row,
+ name : 'ue_addr_valid_yes',
+ type : 'checkbox',
+ disabled : disabled,
+ }
+ }
+ ];
+
+ for( var f in fields ) {
+ dataFields.push(fields[f]);
+ uEditActivateField(fields[f]);
+ }
}
function uEditBuildPatronSCM(patron) {
- /* get the list of pre-defined maps */
- var fields = uEditFindFieldsByKey('stat_cat_entry');
- var map;
- var newmaps = [];
-
- /* for each user stat cat, pop it off the list,
- updated the existing stat map field to match
- the popped map and shove the existing stat
- map field onto the user's list of stat maps */
- while( (map = patron.stat_cat_entries().pop()) ) {
-
- var field = grep(fields,
- function(item) {
- return (item.object.stat_cat() == map.stat_cat());
- }
- );
-
- if(field) {
- var val = map.stat_cat_entry();
- field = field[0];
- $n(field.widget.base, field.widget.name).value = val;
- setSelector($n(field.widget.base, 'ue_stat_cat_selector'), val );
- field.object.stat_cat_entry(val);
- field.object.id(map.id());
- newmaps.push(field.object);
- }
- }
-
- for( var m in newmaps )
- patron.stat_cat_entries().push(newmaps[m]);
+ /* get the list of pre-defined maps */
+ var fields = uEditFindFieldsByKey('stat_cat_entry');
+ var map;
+ var newmaps = [];
+
+ /* for each user stat cat, pop it off the list,
+ updated the existing stat map field to match
+ the popped map and shove the existing stat
+ map field onto the user's list of stat maps */
+ while( (map = patron.stat_cat_entries().pop()) ) {
+
+ var field = grep(fields,
+ function(item) {
+ return (item.object.stat_cat() == map.stat_cat());
+ }
+ );
+
+ if(field) {
+ var val = map.stat_cat_entry();
+ field = field[0];
+ $n(field.widget.base, field.widget.name).value = val;
+ setSelector($n(field.widget.base, 'ue_stat_cat_selector'), val );
+ field.object.stat_cat_entry(val);
+ field.object.id(map.id());
+ newmaps.push(field.object);
+ }
+ }
+
+ for( var m in newmaps )
+ patron.stat_cat_entries().push(newmaps[m]);
}
function uEditBuildSCMField(statcat, row) {
- var map = new actscecm();
- map.stat_cat(statcat.id());
- map.target_usr(patron.id());
-
- var field = {
- required : false,
- object : map,
- key : 'stat_cat_entry',
- widget : {
- base : row,
- name : 'ue_stat_cat_newval',
- type : 'input',
-
- onpostchange : function( field, newval ) {
-
- /* see if the current map already resides in
- the patron entry list */
- var exists = grep( patron.stat_cat_entries(),
- function(item) {
- return (item.stat_cat() == statcat.id());
- }
- );
-
- if(newval) {
- map.isdeleted(0);
- setSelector($n(row, 'ue_stat_cat_selector'), newval);
- }
-
- if(exists) {
- if(!newval) {
-
- /* if the map is new but currently contains no value
- remove it from the set of new maps */
- if(map.isnew()) {
- patron.stat_cat_entries(
- grep( patron.stat_cat_entries(),
- function(item) {
- return (item.stat_cat() != map.stat_cat());
- }
- )
- );
-
- } else {
- map.isdeleted(1);
- map.ischanged(0);
- }
- }
-
- } else {
-
- /* map does not exist in the map array but now has data */
- if(newval) {
- map.isnew(1);
- if(!patron.stat_cat_entries())
- patron.stat_cat_entries([]);
- patron.stat_cat_entries().push(map);
- }
- }
- }
- }
- }
-
- dataFields.push(field);
+ var map = new actscecm();
+ map.stat_cat(statcat.id());
+ map.target_usr(patron.id());
+
+ var field = {
+ required : false,
+ object : map,
+ key : 'stat_cat_entry',
+ widget : {
+ base : row,
+ name : 'ue_stat_cat_newval',
+ type : 'input',
+
+ onpostchange : function( field, newval ) {
+
+ /* see if the current map already resides in
+ the patron entry list */
+ var exists = grep( patron.stat_cat_entries(),
+ function(item) {
+ return (item.stat_cat() == statcat.id());
+ }
+ );
+
+ if(newval) {
+ map.isdeleted(0);
+ setSelector($n(row, 'ue_stat_cat_selector'), newval);
+ }
+
+ if(exists) {
+ if(!newval) {
+
+ /* if the map is new but currently contains no value
+ remove it from the set of new maps */
+ if(map.isnew()) {
+ patron.stat_cat_entries(
+ grep( patron.stat_cat_entries(),
+ function(item) {
+ return (item.stat_cat() != map.stat_cat());
+ }
+ )
+ );
+
+ } else {
+ map.isdeleted(1);
+ map.ischanged(0);
+ }
+ }
+
+ } else {
+
+ /* map does not exist in the map array but now has data */
+ if(newval) {
+ map.isnew(1);
+ if(!patron.stat_cat_entries())
+ patron.stat_cat_entries([]);
+ patron.stat_cat_entries().push(map);
+ }
+ }
+ }
+ }
+ }
+
+ dataFields.push(field);
}
/** Run this after a new ident type is selected */
function _uEditIdentPostchange(type, field, newval) {
- if(!newval) return;
-
- /* When the ident type is changed, we change the
- regex on the ident_value to match the selected type */
- var vfname = 'ident_value';
- if(type == 'secondary') vfname = 'ident_value2';
- var vfield = uEditFindFieldByKey(vfname);
- var name = identTypesCache[uEditNodeVal(field)].name();
-
- hideMe($(type+'_ident_ssn_help'));
- hideMe($(type+'_ident_dl_help'));
-
- if(name.match(/ssn/i)) {
- vfield.widget.regex = ssnRegex;
- vfield.errkey = 'ue_bad_ident_ssn';
- unHideMe($(type+'_ident_ssn_help'));
-
- } else {
-
- if(name.match(/driver/i)) {
- vfield.widget.regex = dlRegex;
- vfield.errkey = 'ue_bad_ident_dl';
- unHideMe($(type+'_ident_dl_help'));
- if(!uEditNodeVal(vfield))
- vfield.widget.node.value = defaultState + '-';
-
- } else {
- vfield.widget.regex = null;
- vfield.errkey = null;
- }
- }
-
- /* focus then valdate the value field */
- vfield.widget.node.onchange();
- vfield.widget.node.focus();
+ if(!newval) return;
+
+ /* When the ident type is changed, we change the
+ regex on the ident_value to match the selected type */
+ var vfname = 'ident_value';
+ if(type == 'secondary') vfname = 'ident_value2';
+ var vfield = uEditFindFieldByKey(vfname);
+ var name = identTypesCache[uEditNodeVal(field)].name();
+
+ hideMe($(type+'_ident_ssn_help'));
+ hideMe($(type+'_ident_dl_help'));
+
+ if(name.match(/ssn/i)) {
+ vfield.widget.regex = ssnRegex;
+ vfield.errkey = 'ue_bad_ident_ssn';
+ unHideMe($(type+'_ident_ssn_help'));
+
+ } else {
+
+ if(name.match(/driver/i)) {
+ vfield.widget.regex = dlRegex;
+ vfield.errkey = 'ue_bad_ident_dl';
+ unHideMe($(type+'_ident_dl_help'));
+ if(!uEditNodeVal(vfield))
+ vfield.widget.node.value = defaultState + '-';
+
+ } else {
+ vfield.widget.regex = null;
+ vfield.errkey = null;
+ }
+ }
+
+ /* focus then valdate the value field */
+ vfield.widget.node.onchange();
+ vfield.widget.node.focus();
}
function uEditCheckSharedAddr(patron, address, tbody, row) {
- if( address.isnew() || (patron.isnew() && !clone) ) return;
-
- var req = new Request(FETCH_ADDR_MEMS, SESSION, address.id());
- req.callback(
- function(r) {
-
- var members = r.getResultObject();
- var shared = false;
-
- for( var m in members ) {
- var id = members[m];
-
- if( id != patron.id() ) {
-
- addCSSClass(row.getElementsByTagName('table')[0], 'shared_address');
- unHideMe($n(row, 'shared_row'));
- $n(row, 'ue_addr_delete').disabled = true;
-
- if( address.usr() != patron.id() ) {
- var button = $n(row, 'ue_addr_detach');
- unHideMe(button);
- button.onclick =
- function() { uEditDeleteAddr( tbody, row, address, true ); }
- }
-
- shared = true;
- break;
- }
- }
-
- if( shared ) {
-
- /* if this is a shared address, set the owner field and
- give the staff a chance to edit the owner if it's not this user */
-
- var nnode = $n(row, 'addr_owner_name');
- var link = $n(row, 'addr_owner');
- var id = address.usr();
-
- if( id == patron.id() ) {
-
- nnode.appendChild(text(
- patron.first_given_name() + ' ' + patron.family_name()));
- hideMe($n(row, 'owner_link_div'));
-
- } else {
-
- var ses = cgi.param('ses');
- if (xulG) if (xulG.ses) ses = xulG.ses;
- if (xulG) if (xulG.params) if (xulG.params.ses) ses = xulG.params.ses;
- link.onclick =
- function() { window.xulG.spawn_editor({ses:ses,usr:id}) };
-
- if( userCache[id] ) {
+ if( address.isnew() || (patron.isnew() && !clone) ) return;
+
+ var req = new Request(FETCH_ADDR_MEMS, SESSION, address.id());
+ req.callback(
+ function(r) {
+
+ var members = r.getResultObject();
+ var shared = false;
+
+ for( var m in members ) {
+ var id = members[m];
+
+ if( id != patron.id() ) {
+
+ addCSSClass(row.getElementsByTagName('table')[0], 'shared_address');
+ unHideMe($n(row, 'shared_row'));
+ $n(row, 'ue_addr_delete').disabled = true;
+
+ if( address.usr() != patron.id() ) {
+ var button = $n(row, 'ue_addr_detach');
+ unHideMe(button);
+ button.onclick =
+ function() { uEditDeleteAddr( tbody, row, address, true ); }
+ }
+
+ shared = true;
+ break;
+ }
+ }
+
+ if( shared ) {
+
+ /* if this is a shared address, set the owner field and
+ give the staff a chance to edit the owner if it's not this user */
+
+ var nnode = $n(row, 'addr_owner_name');
+ var link = $n(row, 'addr_owner');
+ var id = address.usr();
+
+ if( id == patron.id() ) {
+
+ nnode.appendChild(text(
+ patron.first_given_name() + ' ' + patron.family_name()));
+ hideMe($n(row, 'owner_link_div'));
+
+ } else {
+
+ var ses = cgi.param('ses');
+ if (xulG) if (xulG.ses) ses = xulG.ses;
+ if (xulG) if (xulG.params) if (xulG.params.ses) ses = xulG.params.ses;
+ link.onclick =
+ function() { window.xulG.spawn_editor({ses:ses,usr:id}) };
+
+ if( userCache[id] ) {
var usr = userCache[id];
- nnode.appendChild(text(
- usr.first_given_name() + ' ' + usr.family_name()));
-
- } else {
-
- fetchFleshedUser( id,
- function(usr) {
- userCache[usr.id()] = usr;
- nnode.appendChild(text(
- usr.first_given_name() + ' ' + usr.family_name()));
- }
- );
- }
- }
- }
- }
- );
-
- req.send();
+ nnode.appendChild(text(
+ usr.first_given_name() + ' ' + usr.family_name()));
+
+ } else {
+
+ fetchFleshedUser( id,
+ function(usr) {
+ userCache[usr.id()] = usr;
+ nnode.appendChild(text(
+ usr.first_given_name() + ' ' + usr.family_name()));
+ }
+ );
+ }
+ }
+ }
+ }
+ );
+
+ req.send();
}
var __lastdob;
function uEditCheckDOB(field) {
- var dob = uEditNodeVal(field);
+ var dob = uEditNodeVal(field);
var ident_field = uEditFindFieldByKey('ident_value2');
if(dob) {
unHideMe(ident_field.widget.node.parentNode.parentNode.parentNode);
if( dob < base ) { /* patron is of age */
ident_field.required = false;
- uEditFindFieldByKey('juvenile').widget.node.checked = false;
+ uEditFindFieldByKey('juvenile').widget.node.checked = false;
if(!uEditNodeVal(ident_field))
hideMe(ident_field.widget.node.parentNode.parentNode.parentNode);
return;
unHideMe(ident_field.widget.node.parentNode.parentNode.parentNode);
if(!uEditFindFieldByKey('juvenile').widget.node.checked)
- uEditFindFieldByKey('juvenile').widget.node.checked = true;
- ident_field.required = true;
- uEditCheckErrors();
+ uEditFindFieldByKey('juvenile').widget.node.checked = true;
+ ident_field.required = true;
+ uEditCheckErrors();
}
/* -----------------------------------------------------------------------
- UI code for the user editor. Handles breaking up the components
- into a wizard-like interface.
- ----------------------------------------------------------------------- */
+ UI code for the user editor. Handles breaking up the components
+ into a wizard-like interface.
+ ----------------------------------------------------------------------- */
var pages = [
- 'uedit_userid',
- 'uedit_contact_info',
- 'uedit_addresses',
- 'uedit_groups',
- 'uedit_stat_cats',
- 'uedit_surveys',
- 'uedit_finalize',
- ];
+ 'uedit_userid',
+ 'uedit_contact_info',
+ 'uedit_addresses',
+ 'uedit_groups',
+ 'uedit_stat_cats',
+ 'uedit_surveys',
+ 'uedit_finalize',
+ ];
/* ID's of objects that should be focused when their page is made visible */
var pageFocus = [
- 'ue_barcode',
- 'ue_email',
- 'ue_addr_label_1',
- 'ue_profile',
- 'ue_stat_cat_selector_1',
- 'ue_survey_selector_1',
- 'ue_view_summary'
+ 'ue_barcode',
+ 'ue_email',
+ 'ue_addr_label_1',
+ 'ue_profile',
+ 'ue_stat_cat_selector_1',
+ 'ue_survey_selector_1',
+ 'ue_view_summary'
];
function uEditNext() {
- var i = _findActive();
- if( i < (pages.length - 1)) uEditShowPage(pages[i+1]);
+ var i = _findActive();
+ if( i < (pages.length - 1)) uEditShowPage(pages[i+1]);
}
function uEditPrev() {
- var i = _findActive();
- if( i > 0 ) uEditShowPage(pages[i-1]);
+ var i = _findActive();
+ if( i > 0 ) uEditShowPage(pages[i-1]);
}
function uEditCheckErrors() {
- var errors = uEditGetErrorStrings();
- if(errors) unHideMe($('ue_errors'));
- else hideMe($('ue_errors'));
+ var errors = uEditGetErrorStrings();
+ if(errors) unHideMe($('ue_errors'));
+ else hideMe($('ue_errors'));
}
/*
*/
function uEditShowPage(id) {
- if( id == null ) return;
+ if( id == null ) return;
- for( var p in pages ) {
- var page = pages[p];
- hideMe($(page));
- removeCSSClass($(page+'_label'), 'label_active');
- }
+ for( var p in pages ) {
+ var page = pages[p];
+ hideMe($(page));
+ removeCSSClass($(page+'_label'), 'label_active');
+ }
- var idx = _findPageIdx(id);
+ var idx = _findPageIdx(id);
- unHideMe($(id));
- addCSSClass($(id+'_label'), 'label_active');
- var fpage = pageFocus[idx];
+ unHideMe($(id));
+ addCSSClass($(id+'_label'), 'label_active');
+ var fpage = pageFocus[idx];
- var pnode = $(fpage);
- if( id == 'uedit_addresses' )
- pnode = $n( $('ue_address_tbody').
- getElementsByTagName('tr')[0], 'ue_addr_label');
+ var pnode = $(fpage);
+ if( id == 'uedit_addresses' )
+ pnode = $n( $('ue_address_tbody').
+ getElementsByTagName('tr')[0], 'ue_addr_label');
- if(pnode) {
- pnode.focus();
- try{pnode.select()}catch(e){}
- }
+ if(pnode) {
+ pnode.focus();
+ try{pnode.select()}catch(e){}
+ }
- unHideMe($('ue_back'));
- unHideMe($('ue_fwd'));
+ unHideMe($('ue_back'));
+ unHideMe($('ue_fwd'));
- if(idx == 0) hideMe($('ue_back'));
- if(idx == (pages.length-1)) hideMe($('ue_fwd'));
+ if(idx == 0) hideMe($('ue_back'));
+ if(idx == (pages.length-1)) hideMe($('ue_fwd'));
}
function _findActive() {
- for( var p in pages ) {
- if(! $(pages[p]).className.match(/hide_me/) )
- return parseInt(p);
- }
- return null;
+ for( var p in pages ) {
+ if(! $(pages[p]).className.match(/hide_me/) )
+ return parseInt(p);
+ }
+ return null;
}
function _findPageIdx(name) {
- for( var i in pages ) {
- var page = pages[i];
- if( page == name ) return i;
- }
- return -1;
+ for( var i in pages ) {
+ var page = pages[i];
+ if( page == name ) return i;
+ }
+ return -1;
}
/* ------------------------------------------------------------------------------ */
/* org selector */
function uEditBuildLibSelector( node, depth, selector ) {
- if(!selector) selector = $('ue_org_selector');
- if(!node) { depth = 0; node = globalOrgTree; }
- var opt = insertSelectorVal(
- selector, -1, node.name(), node.id(), null, depth++ );
- if(!findOrgType(node.ou_type()).can_have_users()) opt.disabled = true;
- if( node.id() == USER.ws_ou() )
- setSelector(selector, node.id());
-
- for( var c in node.children() )
- uEditBuildLibSelector(node.children()[c], depth, selector);
+ if(!selector) selector = $('ue_org_selector');
+ if(!node) { depth = 0; node = globalOrgTree; }
+ var opt = insertSelectorVal(
+ selector, -1, node.name(), node.id(), null, depth++ );
+ if(!findOrgType(node.ou_type()).can_have_users()) opt.disabled = true;
+ if( node.id() == USER.ws_ou() )
+ setSelector(selector, node.id());
+
+ for( var c in node.children() )
+ uEditBuildLibSelector(node.children()[c], depth, selector);
}
/* group tree selector */
function uEditDrawGroups(tree, depth, selector, drawme) {
- if(!selector) {
- selector = $('ue_profile');
- depth = 0;
- }
- groupsCache[tree.id()] = tree;
-
- /* if the staff does not have perms to access this group,
- remove it from the tree and don't add it's children */
- var perm = uEditFindGroupPerm(tree);
- var org = PERMS[perm];
- if( org == -1 ) drawme = false;
-
- if( drawme ) {
- var opt = insertSelectorVal( selector, -1, tree.name(), tree.id(), null, depth++ );
- if(!isTrue(tree.usergroup())) opt.disabled = true;
- }
-
- for( var c in tree.children() )
- uEditDrawGroups( tree.children()[c], depth, selector, drawme );
+ if(!selector) {
+ selector = $('ue_profile');
+ depth = 0;
+ }
+ groupsCache[tree.id()] = tree;
+
+ /* if the staff does not have perms to access this group,
+ remove it from the tree and don't add it's children */
+ var perm = uEditFindGroupPerm(tree);
+ var org = PERMS[perm];
+ if( org == -1 ) drawme = false;
+
+ if( drawme ) {
+ var opt = insertSelectorVal( selector, -1, tree.name(), tree.id(), null, depth++ );
+ if(!isTrue(tree.usergroup())) opt.disabled = true;
+ }
+
+ for( var c in tree.children() )
+ uEditDrawGroups( tree.children()[c], depth, selector, drawme );
}
function uEditFindGroupPerm(group) {
- if(!group) return null;
- if( group.application_perm() )
- return group.application_perm();
- return uEditFindGroupPerm(groupsCache[group.parent()]);
+ if(!group) return null;
+ if( group.application_perm() )
+ return group.application_perm();
+ return uEditFindGroupPerm(groupsCache[group.parent()]);
}
/* user identification types */
function uEditDrawIDTypes(types) {
- var pri_sel = $('ue_primary_ident_type');
- //var sec_sel = $('ue_secondary_ident_type');
- var idx = 1;
- for( var t in types ) {
- var type = types[t];
- if(!type.name()) continue;
- identTypesCache[type.id()] = type;
- setSelectorVal( pri_sel, idx, type.name(), type.id() );
- //setSelectorVal( sec_sel, idx++, type.name(), type.id() );
- idx++;
- }
+ var pri_sel = $('ue_primary_ident_type');
+ //var sec_sel = $('ue_secondary_ident_type');
+ var idx = 1;
+ for( var t in types ) {
+ var type = types[t];
+ if(!type.name()) continue;
+ identTypesCache[type.id()] = type;
+ setSelectorVal( pri_sel, idx, type.name(), type.id() );
+ //setSelectorVal( sec_sel, idx++, type.name(), type.id() );
+ idx++;
+ }
}
/* user statistical catagories */
function uEditDrawStatCats(cats) {
- var tbody = $('ue_stat_cat_tbody');
- var templ = tbody.removeChild($('ue_stat_cat_row'));
-
- for( var c in cats ) {
- var row = templ.cloneNode(true);
- uEditInsertCat( row, cats[c], c );
- tbody.appendChild(row);
- }
+ var tbody = $('ue_stat_cat_tbody');
+ var templ = tbody.removeChild($('ue_stat_cat_row'));
+
+ for( var c in cats ) {
+ var row = templ.cloneNode(true);
+ uEditInsertCat( row, cats[c], c );
+ tbody.appendChild(row);
+ }
}
function uEditInsertCat( row, cat, idx ) {
- cat.entries().sort( /* sort the entries by value */
- function( a, b ) {
- if( !a.value() ) return -1;
- if( !b.value() ) return 1;
- if( (a.value()+'').toLowerCase() > (b.value()+'').toLowerCase()) return 1;
- if( (a.value()+'').toLowerCase() < (b.value()+'').toLowerCase()) return -1;
- return 0;
- }
- );
+ cat.entries().sort( /* sort the entries by value */
+ function( a, b ) {
+ if( !a.value() ) return -1;
+ if( !b.value() ) return 1;
+ if( (a.value()+'').toLowerCase() > (b.value()+'').toLowerCase()) return 1;
+ if( (a.value()+'').toLowerCase() < (b.value()+'').toLowerCase()) return -1;
+ return 0;
+ }
+ );
- statCatsCache[cat.id()] = cat;
+ statCatsCache[cat.id()] = cat;
- /* register the new map object */
- uEditBuildSCMField(cat, row);
+ /* register the new map object */
+ uEditBuildSCMField(cat, row);
- var newval = $n(row, 'ue_stat_cat_newval');
- var selector = $n(row, 'ue_stat_cat_selector');
+ var newval = $n(row, 'ue_stat_cat_newval');
+ var selector = $n(row, 'ue_stat_cat_selector');
- selector.onchange = function() {
- newval.value = getSelectorVal(selector);
- if(newval.onchange) newval.onchange();
- }
+ selector.onchange = function() {
+ newval.value = getSelectorVal(selector);
+ if(newval.onchange) newval.onchange();
+ }
- if( idx == 0 ) selector.id = 'ue_stat_cat_selector_1';
+ if( idx == 0 ) selector.id = 'ue_stat_cat_selector_1';
- $n(row, 'ue_stat_cat_name').appendChild(text(cat.name()));
- $n(row, 'ue_stat_cat_owner').appendChild(
- text(fetchOrgUnit(cat.owner()).shortname()));
+ $n(row, 'ue_stat_cat_name').appendChild(text(cat.name()));
+ $n(row, 'ue_stat_cat_owner').appendChild(
+ text(fetchOrgUnit(cat.owner()).shortname()));
- for( var e in cat.entries() ) {
- var entry = cat.entries()[e];
- setSelectorVal( selector,
- (parseInt(e)+1), entry.value(), entry.value() );
- }
+ for( var e in cat.entries() ) {
+ var entry = cat.entries()[e];
+ setSelectorVal( selector,
+ (parseInt(e)+1), entry.value(), entry.value() );
+ }
}
/* draw the surveys */
function uEditDrawSurveys(surveys) {
- var div = $('uedit_surveys');
- var table = div.removeChild($('ue_survey_table'));
- if( surveys.length == 0 ) unHideMe($('uedit_no_surveys'));
-
- for( var s in surveys ) {
- var survey = surveys[s];
- surveysCache[survey.id()] = survey;
- var clone = table.cloneNode(true);
- uEditInsertSurvey( div, clone, survey, s );
- div.appendChild(clone);
- }
+ var div = $('uedit_surveys');
+ var table = div.removeChild($('ue_survey_table'));
+ if( surveys.length == 0 ) unHideMe($('uedit_no_surveys'));
+
+ for( var s in surveys ) {
+ var survey = surveys[s];
+ surveysCache[survey.id()] = survey;
+ var clone = table.cloneNode(true);
+ uEditInsertSurvey( div, clone, survey, s );
+ div.appendChild(clone);
+ }
}
/* insert the servey then insert each of that surveys questions */
function uEditInsertSurvey( div, table, survey, sidx ) {
- $n(table, 'ue_survey_name').appendChild(text(survey.name()));
- $n(table, 'ue_survey_desc').appendChild(text(survey.description()));
+ $n(table, 'ue_survey_name').appendChild(text(survey.name()));
+ $n(table, 'ue_survey_desc').appendChild(text(survey.description()));
- var tbody = $n(table, 'ue_survey_tbody');
- var templ = tbody.removeChild($n(table, 'ue_survey_row'));
+ var tbody = $n(table, 'ue_survey_tbody');
+ var templ = tbody.removeChild($n(table, 'ue_survey_row'));
- for( var q in survey.questions() ) {
- var row = templ.cloneNode(true);
- var quest = survey.questions()[q];
- uEditInsertSurveyQuestion( row, survey, quest );
- tbody.appendChild(row);
- }
+ for( var q in survey.questions() ) {
+ var row = templ.cloneNode(true);
+ var quest = survey.questions()[q];
+ uEditInsertSurveyQuestion( row, survey, quest );
+ tbody.appendChild(row);
+ }
}
function uEditInsertSurveyQuestion( row, survey, question ) {
- var selector = $n(row, 'ue_survey_answer');
- row.setAttribute('question', question.id());
- $n(row, 'ue_survey_question').appendChild(text(question.question()));
+ var selector = $n(row, 'ue_survey_answer');
+ row.setAttribute('question', question.id());
+ $n(row, 'ue_survey_question').appendChild(text(question.question()));
- for( var a in question.answers() ) {
- var answer = question.answers()[a];
- surveyAnswersCache[answer.id()] = answer;
- insertSelectorVal(selector, -1, answer.answer(), answer.id() );
- }
+ for( var a in question.answers() ) {
+ var answer = question.answers()[a];
+ surveyAnswersCache[answer.id()] = answer;
+ insertSelectorVal(selector, -1, answer.answer(), answer.id() );
+ }
- surveyQuestionsCache[question.id()] = question;
+ surveyQuestionsCache[question.id()] = question;
- if( patron.isnew() && isTrue(survey.required()) )
- addCSSClass(selector, 'invalid_value');
+ if( patron.isnew() && isTrue(survey.required()) )
+ addCSSClass(selector, 'invalid_value');
- selector.onchange = function() {
+ selector.onchange = function() {
- /* remove any existing responses for this survey */
- patron.survey_responses(
- grep( patron.survey_responses(),
- function(item) {
- return (item.survey() != survey.id());
- }
- )
- );
+ /* remove any existing responses for this survey */
+ patron.survey_responses(
+ grep( patron.survey_responses(),
+ function(item) {
+ return (item.survey() != survey.id());
+ }
+ )
+ );
- if(!patron.survey_responses())
- patron.survey_responses([]);
+ if(!patron.survey_responses())
+ patron.survey_responses([]);
- var val = getSelectorVal(selector);
+ var val = getSelectorVal(selector);
- if( patron.isnew() && isTrue(survey.required()) ) {
- if(val)
- removeCSSClass(selector, 'invalid_value');
- else
- addCSSClass(selector, 'invalid_value');
- uEditCheckErrors();
- }
+ if( patron.isnew() && isTrue(survey.required()) ) {
+ if(val)
+ removeCSSClass(selector, 'invalid_value');
+ else
+ addCSSClass(selector, 'invalid_value');
+ uEditCheckErrors();
+ }
- if(!val) return;
+ if(!val) return;
- var resp = new asvr();
- resp.isnew(1);
- resp.survey(survey.id());
- resp.usr(patron.id());
- resp.question(row.getAttribute('question'));
- resp.answer(val);
- patron.survey_responses().push( resp );
- }
+ var resp = new asvr();
+ resp.isnew(1);
+ resp.survey(survey.id());
+ resp.usr(patron.id());
+ resp.question(row.getAttribute('question'));
+ resp.answer(val);
+ patron.survey_responses().push( resp );
+ }
}
/* -----------------------------------------------------------------------
- Spit out the patron info to the summary display tables...
- ----------------------------------------------------------------------- */
+ Spit out the patron info to the summary display tables...
+ ----------------------------------------------------------------------- */
function uEditShowSummary() {
- hideMe($('main_div_container'));
- unHideMe($('summary_div_container'));
+ hideMe($('main_div_container'));
+ unHideMe($('summary_div_container'));
- for( var f in dataFields ) {
+ for( var f in dataFields ) {
- var field = dataFields[f];
- if( field.object == patron ) {
+ var field = dataFields[f];
+ if( field.object == patron ) {
- var val = uEditNodeVal(field);
+ var val = uEditNodeVal(field);
- if( field.key == 'profile' ||
- field.key == 'home_ou' ||
- field.key == 'ident_type' ||
- field.key == 'ident_type2') {
+ if( field.key == 'profile' ||
+ field.key == 'home_ou' ||
+ field.key == 'ident_type' ||
+ field.key == 'ident_type2') {
- val = getSelectorName($(field.widget.id));
- }
+ val = getSelectorName($(field.widget.id));
+ }
- var node = $('ue_summary_'+field.key);
- if(node) appendClear(node, text(val));
- }
+ var node = $('ue_summary_'+field.key);
+ if(node) appendClear(node, text(val));
+ }
- if( field.object == patron.card() )
- appendClear($('ue_summary_barcode'), text(uEditNodeVal(field)));
+ if( field.object == patron.card() )
+ appendClear($('ue_summary_barcode'), text(uEditNodeVal(field)));
- }
+ }
- var table = $('ue_summary_table');
- uEditFleshSummaryAddresses( table, patron );
- uEditFleshSummaryStatCats( table, patron );
- uEditFleshSummarySurveys( table, patron );
+ var table = $('ue_summary_table');
+ uEditFleshSummaryAddresses( table, patron );
+ uEditFleshSummaryStatCats( table, patron );
+ uEditFleshSummarySurveys( table, patron );
}
var uEditSummaryAddrRow;
function uEditFleshSummaryAddresses( table, patron ) {
- var addrtbody = $n(table, 'ue_summary_addr_tbody');
- if(!uEditSummaryAddrRow)
- uEditSummaryAddrRow =
- addrtbody.removeChild($n(addrtbody, 'ue_summary_addr_row'));
- var rowtmpl = uEditSummaryAddrRow;
- removeChildren(addrtbody);
-
- for( var a in patron.addresses() ) {
- var address = patron.addresses()[a];
- var row = rowtmpl.cloneNode(true);
- uEditFleshSummaryAddr( address, patron, row );
- addrtbody.appendChild(row);
- if(address.isdeleted()) addCSSClass(row, 'deleted');
- }
+ var addrtbody = $n(table, 'ue_summary_addr_tbody');
+ if(!uEditSummaryAddrRow)
+ uEditSummaryAddrRow =
+ addrtbody.removeChild($n(addrtbody, 'ue_summary_addr_row'));
+ var rowtmpl = uEditSummaryAddrRow;
+ removeChildren(addrtbody);
+
+ for( var a in patron.addresses() ) {
+ var address = patron.addresses()[a];
+ var row = rowtmpl.cloneNode(true);
+ uEditFleshSummaryAddr( address, patron, row );
+ addrtbody.appendChild(row);
+ if(address.isdeleted()) addCSSClass(row, 'deleted');
+ }
}
function uEditFleshSummaryAddr( address, patron, row ) {
- var yes = $('yes').innerHTML;
- var no = $('no').innerHTML;
-
- $n(row, 'label').appendChild(text(address.address_type()));
- $n(row, 'street1').appendChild(text(address.street1()));
- $n(row, 'street2').appendChild(text(address.street2()));
- $n(row, 'city').appendChild(text(address.city()));
- $n(row, 'county').appendChild(text(address.county()));
- $n(row, 'state').appendChild(text(address.state()));
- $n(row, 'country').appendChild(text(address.country()));
- $n(row, 'zip').appendChild(text(address.post_code()));
- $n(row, 'valid').appendChild(text( (isTrue(address.valid())) ? yes : no ));
- $n(row, 'incorporated').appendChild(text( (isTrue(address.within_city_limits())) ? yes : no ));
-
- var mid = patron.mailing_address();
- if( typeof patron.mailing_address() == 'object' )
- mid = patron.mailing_address().id();
- $n(row, 'mailing').appendChild(text((mid == address.id()) ? yes : no ));
-
- var bid = patron.billing_address();
- if( typeof patron.billing_address() == 'object' )
- bid = patron.billing_address().id();
- $n(row, 'billing').appendChild(text((bid == address.id()) ? yes : no ));
+ var yes = $('yes').innerHTML;
+ var no = $('no').innerHTML;
+
+ $n(row, 'label').appendChild(text(address.address_type()));
+ $n(row, 'street1').appendChild(text(address.street1()));
+ $n(row, 'street2').appendChild(text(address.street2()));
+ $n(row, 'city').appendChild(text(address.city()));
+ $n(row, 'county').appendChild(text(address.county()));
+ $n(row, 'state').appendChild(text(address.state()));
+ $n(row, 'country').appendChild(text(address.country()));
+ $n(row, 'zip').appendChild(text(address.post_code()));
+ $n(row, 'valid').appendChild(text( (isTrue(address.valid())) ? yes : no ));
+ $n(row, 'incorporated').appendChild(text( (isTrue(address.within_city_limits())) ? yes : no ));
+
+ var mid = patron.mailing_address();
+ if( typeof patron.mailing_address() == 'object' )
+ mid = patron.mailing_address().id();
+ $n(row, 'mailing').appendChild(text((mid == address.id()) ? yes : no ));
+
+ var bid = patron.billing_address();
+ if( typeof patron.billing_address() == 'object' )
+ bid = patron.billing_address().id();
+ $n(row, 'billing').appendChild(text((bid == address.id()) ? yes : no ));
}
var uEditSummaryStatCatRow;
function uEditFleshSummaryStatCats( table, patron ) {
- var tbody = $n(table, 'ue_summary_stats_tbody');
-
- if(!uEditSummaryStatCatRow)
- uEditSummaryStatCatRow =
- tbody.removeChild($n(tbody, 'ue_summary_stats_row'));
- var rowtmpl = uEditSummaryStatCatRow;
- removeChildren(tbody);
-
- for( var s in patron.stat_cat_entries() ) {
- row = rowtmpl.cloneNode(true);
- var entry = patron.stat_cat_entries()[s];
- var cat = statCatsCache[entry.stat_cat()];
- $n(row, 'ue_summary_stat_name').appendChild(text(cat.name()));
- $n(row, 'ue_summary_stat_value').appendChild(text(entry.stat_cat_entry()));
- row.setAttribute('statcat', entry.stat_cat());
- if( entry.isdeleted() ) addCSSClass(row, 'deleted');
- tbody.appendChild(row);
- }
-
- if( ! getElementsByTagNameFlat( tbody, 'tr' )[0] )
- hideMe(tbody.parentNode);
- else
- unHideMe(tbody.parentNode);
+ var tbody = $n(table, 'ue_summary_stats_tbody');
+
+ if(!uEditSummaryStatCatRow)
+ uEditSummaryStatCatRow =
+ tbody.removeChild($n(tbody, 'ue_summary_stats_row'));
+ var rowtmpl = uEditSummaryStatCatRow;
+ removeChildren(tbody);
+
+ for( var s in patron.stat_cat_entries() ) {
+ row = rowtmpl.cloneNode(true);
+ var entry = patron.stat_cat_entries()[s];
+ var cat = statCatsCache[entry.stat_cat()];
+ $n(row, 'ue_summary_stat_name').appendChild(text(cat.name()));
+ $n(row, 'ue_summary_stat_value').appendChild(text(entry.stat_cat_entry()));
+ row.setAttribute('statcat', entry.stat_cat());
+ if( entry.isdeleted() ) addCSSClass(row, 'deleted');
+ tbody.appendChild(row);
+ }
+
+ if( ! getElementsByTagNameFlat( tbody, 'tr' )[0] )
+ hideMe(tbody.parentNode);
+ else
+ unHideMe(tbody.parentNode);
}
var uEditSummarySurveyRow;
function uEditFleshSummarySurveys( table, patron ) {
- var tbody = $n(table, 'ue_summary_survey_tbody');
- if(!uEditSummarySurveyRow)
- uEditSummarySurveyRow =
- tbody.removeChild($n(tbody, 'ue_summary_survey_row'));
- var rowtmpl = uEditSummarySurveyRow;
-
- removeChildren(tbody);
-
- for( var r in patron.survey_responses() ) {
- var row = rowtmpl.cloneNode(true);
- var resp = patron.survey_responses()[r];
- var survey = surveysCache[resp.survey()];
- var quest = surveyQuestionsCache[resp.question()];
- var answer = surveyAnswersCache[resp.answer()];
- $n(row, 'ue_summary_survey_name').appendChild(text(survey.name()));
- $n(row, 'ue_summary_survey_question').appendChild(text(quest.question()));
- $n(row, 'ue_summary_survey_answer').appendChild(text(answer.answer()));
- tbody.appendChild(row);
- }
-
- if( ! getElementsByTagNameFlat(tbody, 'tr')[0])
- hideMe(tbody.parentNode);
- else
- unHideMe(tbody.parentNode);
+ var tbody = $n(table, 'ue_summary_survey_tbody');
+ if(!uEditSummarySurveyRow)
+ uEditSummarySurveyRow =
+ tbody.removeChild($n(tbody, 'ue_summary_survey_row'));
+ var rowtmpl = uEditSummarySurveyRow;
+
+ removeChildren(tbody);
+
+ for( var r in patron.survey_responses() ) {
+ var row = rowtmpl.cloneNode(true);
+ var resp = patron.survey_responses()[r];
+ var survey = surveysCache[resp.survey()];
+ var quest = surveyQuestionsCache[resp.question()];
+ var answer = surveyAnswersCache[resp.answer()];
+ $n(row, 'ue_summary_survey_name').appendChild(text(survey.name()));
+ $n(row, 'ue_summary_survey_question').appendChild(text(quest.question()));
+ $n(row, 'ue_summary_survey_answer').appendChild(text(answer.answer()));
+ tbody.appendChild(row);
+ }
+
+ if( ! getElementsByTagNameFlat(tbody, 'tr')[0])
+ hideMe(tbody.parentNode);
+ else
+ unHideMe(tbody.parentNode);
}
function uEditDrawNetLevels(netLevels) {
- var sel = $('ue_net_level');
- iterate( netLevels,
- function(i) {
- insertSelectorVal( sel, -1, i.name(), i.id() );
- }
- );
- setSelector(sel, defaultNetLevel);
+ var sel = $('ue_net_level');
+ iterate( netLevels,
+ function(i) {
+ insertSelectorVal( sel, -1, i.name(), i.id() );
+ }
+ );
+ setSelector(sel, defaultNetLevel);
}
}
function set_perm(row) {
- var pid = findNodeByName(row,'p.code').getAttribute('permid');
- var papply = findNodeByName(row,'p.id').checked;
- var pdepth = findNodeByName(row,'p.depth').options[findNodeByName(row,'p.depth').selectedIndex].value;
- var pgrant = findNodeByName(row,'p.grantable').checked;
-
- var p;
- for (var i in user_perms) {
- if (user_perms[i].perm() == pid) {
- p = user_perms[i];
- if (papply) {
- p.isdeleted(0);
- p.ischanged(1);
- p.depth(pdepth);
- p.grantable(pgrant ? 1 : 0);
- } else {
- if (p.isnew()) {
- user_perms[i] = null;
- } else {
- p.isdeleted(1);
- }
- }
- break;
- }
- }
-
- if (!p) {
- if (papply) {
- p = new pupm();
- p.isnew(1);
- p.perm(pid);
- p.usr(user.id());
- p.depth('' + pdepth);
- p.grantable(pgrant ? 1 : 0);
-
- user_perms.push(p);
- }
- }
+ var pid = findNodeByName(row,'p.code').getAttribute('permid');
+ var papply = findNodeByName(row,'p.id').checked;
+ var pdepth = findNodeByName(row,'p.depth').options[findNodeByName(row,'p.depth').selectedIndex].value;
+ var pgrant = findNodeByName(row,'p.grantable').checked;
+
+ var p;
+ for (var i in user_perms) {
+ if (user_perms[i].perm() == pid) {
+ p = user_perms[i];
+ if (papply) {
+ p.isdeleted(0);
+ p.ischanged(1);
+ p.depth(pdepth);
+ p.grantable(pgrant ? 1 : 0);
+ } else {
+ if (p.isnew()) {
+ user_perms[i] = null;
+ } else {
+ p.isdeleted(1);
+ }
+ }
+ break;
+ }
+ }
+
+ if (!p) {
+ if (papply) {
+ p = new pupm();
+ p.isnew(1);
+ p.perm(pid);
+ p.usr(user.id());
+ p.depth('' + pdepth);
+ p.grantable(pgrant ? 1 : 0);
+
+ user_perms.push(p);
+ }
+ }
}
function save_user () {
- try {
+ try {
- var save_perms = [];
- for (var i in user_perms) {
- // Group based perm? skip it.
- if (user_perms[i].id() < 0) continue;
+ var save_perms = [];
+ for (var i in user_perms) {
+ // Group based perm? skip it.
+ if (user_perms[i].id() < 0) continue;
- if (user_perms[i].depth() == null) {
- var p;
- for (var j in perm_list) {
- if (perm_list[j].id() == user_perms[i].perm()) {
- p = perm_list[j];
- break;
- }
- }
- throw $("patronStrings").getFormattedString('staff.patron.user_edit.save_user.depth_required', [p.code()]);
- }
+ if (user_perms[i].depth() == null) {
+ var p;
+ for (var j in perm_list) {
+ if (perm_list[j].id() == user_perms[i].perm()) {
+ p = perm_list[j];
+ break;
+ }
+ }
+ throw $("patronStrings").getFormattedString('staff.patron.user_edit.save_user.depth_required', [p.code()]);
+ }
- save_perms.push( user_perms[i] );
- }
+ save_perms.push( user_perms[i] );
+ }
- var save_ous = [];
- for (var i in user_work_ous) {
- if (!user_work_ous[i]) continue;
- save_ous.push( user_work_ous[i] );
- }
+ var save_ous = [];
+ for (var i in user_work_ous) {
+ if (!user_work_ous[i]) continue;
+ save_ous.push( user_work_ous[i] );
+ }
- var req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.work_ous.update', ses_id, save_ous );
- req.send(true);
- var wok = req.getResultObject();
+ var req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.work_ous.update', ses_id, save_ous );
+ req.send(true);
+ var wok = req.getResultObject();
- if (wok.ilsevent) throw wok;
+ if (wok.ilsevent) throw wok;
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.permissions.update', ses_id, save_perms );
- req.send(true);
- var pok = req.getResultObject();
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.permissions.update', ses_id, save_perms );
+ req.send(true);
+ var pok = req.getResultObject();
- if (pok.ilsevent) throw pok;
+ if (pok.ilsevent) throw pok;
- if (pok || wok) {
- alert($("patronStrings").getFormattedString('staff.patron.user_edit.save_user.user_modified_successfully', [user.usrname(), user.card().barcode(), pok, wok]));
- }
+ if (pok || wok) {
+ alert($("patronStrings").getFormattedString('staff.patron.user_edit.save_user.user_modified_successfully', [user.usrname(), user.card().barcode(), pok, wok]));
+ }
- init_editor();
+ init_editor();
- } catch (e) {
- dump( js2JSON( e ));
- alert( js2JSON( e ));
- };
+ } catch (e) {
+ dump( js2JSON( e ));
+ alert( js2JSON( e ));
+ };
- return false;
+ return false;
}
var adv_mode = true;
function apply_adv_mode (root) {
- adv_items = findNodesByClass(root,'advanced');
- for (var i in adv_items) {
- adv_mode ?
- removeCSSClass(adv_items[i], 'hideme') :
- addCSSClass(adv_items[i], 'hideme');
- }
+ adv_items = findNodesByClass(root,'advanced');
+ for (var i in adv_items) {
+ adv_mode ?
+ removeCSSClass(adv_items[i], 'hideme') :
+ addCSSClass(adv_items[i], 'hideme');
+ }
}
function init_editor (u) {
-
- var x = document.getElementById('editor').elements;
-
- cgi = new CGI();
- if (cgi.param('adv')) adv_mode = true;
- try {
- if (xulG) if (xulG.adv) adv_mode = true;
- if (xulG) if (xulG.params) if (xulG.params.adv) adv_mode = true;
- } catch (e) {}
-
- apply_adv_mode(document.getElementById('editor'));
-
- ses_id = cgi.param('ses');
- try {
- if (xulG) if (xulG.ses) ses_id = xulG.ses;
- if (xulG) if (xulG.params) if (xulG.params.ses) ses_id = xulG.params.ses;
- } catch (e) {}
-
- var usr_id = cgi.param('usr');
- try {
- if (xulG) if (xulG.usr_id) usr_id = xulG.usr_id;
- if (xulG) if (xulG.params) if (xulG.params.usr_id) usr_id = xulG.params.usr_id;
- } catch (e) {}
-
- var usr_barcode = cgi.param('barcode');
- try {
- if (xulG) if (xulG.usr_barcode) usr_ibarcode = xulG.usr_barcode;
- if (xulG) if (xulG.params) if (xulG.params.usr_barcode) usr_ibarcode = xulG.params.usr_barcode;
- } catch (e) {}
-
- try {
- var req;
- if (usr_id) {
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.fleshed.retrieve', ses_id, usr_id );
- } else {
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.fleshed.retrieve_by_barcode', ses_id, usr_barcode );
- }
- req.send(true);
- user = req.getResultObject();
- } catch (E) {
- alert(E);
- }
-
- if (user.usrname()) x['user.usrname'].value = user.usrname();
- x['user.usrname'].setAttribute('onchange','user.usrname(this.value)');
-
- if (user.card() && user.card().barcode()) x['user.card.barcode'].value = user.card().barcode();
- x['user.card.barcode'].setAttribute('onchange','user.card().barcode(this.value)');
-
- if (user.first_given_name()) x['user.first_given_name'].value = user.first_given_name();
- x['user.first_given_name'].setAttribute('onchange','user.first_given_name(this.value)');
-
- if (user.second_given_name()) x['user.second_given_name'].value = user.second_given_name();
- x['user.second_given_name'].setAttribute('onchange','user.second_given_name(this.value);');
-
- if (user.family_name()) x['user.family_name'].value = user.family_name();
- x['user.family_name'].setAttribute('onchange','user.family_name(this.value)');
-
- // grab the editing staff user object
- req = new RemoteRequest( 'open-ils.auth', 'open-ils.auth.session.retrieve', ses_id );
- req.send(true);
- var staff = req.getResultObject();
-
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.permissions.user_perms.retrieve', ses_id );
- req.send(true);
- var staff_perms = req.getResultObject();
-
- // Get the top of the staff perm org for ASSIGN_WORK_ORG_UNIT
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.perm.highest_org', ses_id, staff.id(), 'ASSIGN_WORK_ORG_UNIT' );
- req.send(true);
- var top_work_ou = req.getResultObject();
-
- // and now, the orgs where this staff member can apply the perms
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.org_tree.descendants.retrieve', top_work_ou);
- req.send(true);
- var work_ou_tree = req.getResultObject();
-
- // and now, the orgs where this staff member can apply the perms
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.get_work_ous', ses_id, user.id());
- req.send(true);
- user_work_ous = req.getResultObject();
-
- // and finally, the ou types
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.org_types.retrieve' );
- req.send(true);
- ou_type_list = req.getResultObject();
-
- user_perms = [];
- perm_list = [];
- if (user.id() > 0) {
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.permissions.user_perms.retrieve', ses_id, user.id() );
- req.send(true);
- user_perms = req.getResultObject();
-
- req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.permissions.retrieve' );
- req.send(true);
- perm_list = req.getResultObject();
- }
-
- f = document.getElementById('permissions');
- while (f.firstChild) f.removeChild(f.lastChild);
-
- var rcount = 0;
- for (var i in perm_list.sort(function(a,b){ if (a.code() < b.code()) return -1;return 1; }))
- display_perm(f,perm_list[i],staff_perms, rcount++);
-
- f = document.getElementById('work_ous');
- while (f.firstChild) f.removeChild(f.lastChild);
-
- //flatten the ou tree, keep only those with can_hav_users = true
- work_ou_list = [];
- trim_ou_tree( [work_ou_tree], work_ou_list );
-
- rcount = 0;
- for (var i in work_ou_list.sort( function(a,b){ if (a.name() < b.name()) return -1;return 1; }) )
- display_work_ou(f,work_ou_list[i], rcount++);
-
- return true;
+
+ var x = document.getElementById('editor').elements;
+
+ cgi = new CGI();
+ if (cgi.param('adv')) adv_mode = true;
+ try {
+ if (xulG) if (xulG.adv) adv_mode = true;
+ if (xulG) if (xulG.params) if (xulG.params.adv) adv_mode = true;
+ } catch (e) {}
+
+ apply_adv_mode(document.getElementById('editor'));
+
+ ses_id = cgi.param('ses');
+ try {
+ if (xulG) if (xulG.ses) ses_id = xulG.ses;
+ if (xulG) if (xulG.params) if (xulG.params.ses) ses_id = xulG.params.ses;
+ } catch (e) {}
+
+ var usr_id = cgi.param('usr');
+ try {
+ if (xulG) if (xulG.usr_id) usr_id = xulG.usr_id;
+ if (xulG) if (xulG.params) if (xulG.params.usr_id) usr_id = xulG.params.usr_id;
+ } catch (e) {}
+
+ var usr_barcode = cgi.param('barcode');
+ try {
+ if (xulG) if (xulG.usr_barcode) usr_ibarcode = xulG.usr_barcode;
+ if (xulG) if (xulG.params) if (xulG.params.usr_barcode) usr_ibarcode = xulG.params.usr_barcode;
+ } catch (e) {}
+
+ try {
+ var req;
+ if (usr_id) {
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.fleshed.retrieve', ses_id, usr_id );
+ } else {
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.fleshed.retrieve_by_barcode', ses_id, usr_barcode );
+ }
+ req.send(true);
+ user = req.getResultObject();
+ } catch (E) {
+ alert(E);
+ }
+
+ if (user.usrname()) x['user.usrname'].value = user.usrname();
+ x['user.usrname'].setAttribute('onchange','user.usrname(this.value)');
+
+ if (user.card() && user.card().barcode()) x['user.card.barcode'].value = user.card().barcode();
+ x['user.card.barcode'].setAttribute('onchange','user.card().barcode(this.value)');
+
+ if (user.first_given_name()) x['user.first_given_name'].value = user.first_given_name();
+ x['user.first_given_name'].setAttribute('onchange','user.first_given_name(this.value)');
+
+ if (user.second_given_name()) x['user.second_given_name'].value = user.second_given_name();
+ x['user.second_given_name'].setAttribute('onchange','user.second_given_name(this.value);');
+
+ if (user.family_name()) x['user.family_name'].value = user.family_name();
+ x['user.family_name'].setAttribute('onchange','user.family_name(this.value)');
+
+ // grab the editing staff user object
+ req = new RemoteRequest( 'open-ils.auth', 'open-ils.auth.session.retrieve', ses_id );
+ req.send(true);
+ var staff = req.getResultObject();
+
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.permissions.user_perms.retrieve', ses_id );
+ req.send(true);
+ var staff_perms = req.getResultObject();
+
+ // Get the top of the staff perm org for ASSIGN_WORK_ORG_UNIT
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.perm.highest_org', ses_id, staff.id(), 'ASSIGN_WORK_ORG_UNIT' );
+ req.send(true);
+ var top_work_ou = req.getResultObject();
+
+ // and now, the orgs where this staff member can apply the perms
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.org_tree.descendants.retrieve', top_work_ou);
+ req.send(true);
+ var work_ou_tree = req.getResultObject();
+
+ // and now, the orgs where this staff member can apply the perms
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.user.get_work_ous', ses_id, user.id());
+ req.send(true);
+ user_work_ous = req.getResultObject();
+
+ // and finally, the ou types
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.org_types.retrieve' );
+ req.send(true);
+ ou_type_list = req.getResultObject();
+
+ user_perms = [];
+ perm_list = [];
+ if (user.id() > 0) {
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.permissions.user_perms.retrieve', ses_id, user.id() );
+ req.send(true);
+ user_perms = req.getResultObject();
+
+ req = new RemoteRequest( 'open-ils.actor', 'open-ils.actor.permissions.retrieve' );
+ req.send(true);
+ perm_list = req.getResultObject();
+ }
+
+ f = document.getElementById('permissions');
+ while (f.firstChild) f.removeChild(f.lastChild);
+
+ var rcount = 0;
+ for (var i in perm_list.sort(function(a,b){ if (a.code() < b.code()) return -1;return 1; }))
+ display_perm(f,perm_list[i],staff_perms, rcount++);
+
+ f = document.getElementById('work_ous');
+ while (f.firstChild) f.removeChild(f.lastChild);
+
+ //flatten the ou tree, keep only those with can_hav_users = true
+ work_ou_list = [];
+ trim_ou_tree( [work_ou_tree], work_ou_list );
+
+ rcount = 0;
+ for (var i in work_ou_list.sort( function(a,b){ if (a.name() < b.name()) return -1;return 1; }) )
+ display_work_ou(f,work_ou_list[i], rcount++);
+
+ return true;
}
function grep ( code, list ) {
- var ret = [];
- for (var i in list) {
- if (code(list[i])) ret.push(list[i]);
- }
- return ret;
+ var ret = [];
+ for (var i in list) {
+ if (code(list[i])) ret.push(list[i]);
+ }
+ return ret;
}
function trim_ou_tree (tree, list) {
- for (var i in tree) {
- if (!tree[i]) continue;
+ for (var i in tree) {
+ if (!tree[i]) continue;
- var type = grep( function(x) {return x.id() == tree[i].ou_type()}, ou_type_list )[0];
- if ( type && type.can_have_users() == 't' )
- list.push(tree[i]);
+ var type = grep( function(x) {return x.id() == tree[i].ou_type()}, ou_type_list )[0];
+ if ( type && type.can_have_users() == 't' )
+ list.push(tree[i]);
- if (tree[i].children()) trim_ou_tree(tree[i].children(), list);
- }
+ if (tree[i].children()) trim_ou_tree(tree[i].children(), list);
+ }
}
function display_work_ou (root,ou_def,r) {
- var wrow = findNodeByName(document.getElementById('work_ou-tmpl'), 'wrow').cloneNode(true);
- root.appendChild(wrow);
+ var wrow = findNodeByName(document.getElementById('work_ou-tmpl'), 'wrow').cloneNode(true);
+ root.appendChild(wrow);
- var label_cell = findNodeByName(wrow,'label');
- findNodeByName(label_cell,'a.name').appendChild(text(ou_def.name()));
- findNodeByName(label_cell,'a.shortname').appendChild(text(ou_def.shortname()));
- if (r % 2) label_cell.className += ' odd';
+ var label_cell = findNodeByName(wrow,'label');
+ findNodeByName(label_cell,'a.name').appendChild(text(ou_def.name()));
+ findNodeByName(label_cell,'a.shortname').appendChild(text(ou_def.shortname()));
+ if (r % 2) label_cell.className += ' odd';
- var apply_cell = findNodeByName(wrow,'wapply');
- findNodeByName(apply_cell,'a.id').setAttribute('workou_id', ou_def.id());
- if (r % 2) apply_cell.className += ' odd';
+ var apply_cell = findNodeByName(wrow,'wapply');
+ findNodeByName(apply_cell,'a.id').setAttribute('workou_id', ou_def.id());
+ if (r % 2) apply_cell.className += ' odd';
- var has_it = grep(
- function(x){ return x.work_ou() == ou_def.id() },
- user_work_ous
- ).length;
+ var has_it = grep(
+ function(x){ return x.work_ou() == ou_def.id() },
+ user_work_ous
+ ).length;
- findNodeByName(apply_cell,'a.id').checked = has_it > 0 ? true : false;
+ findNodeByName(apply_cell,'a.id').checked = has_it > 0 ? true : false;
}
function display_perm (root,perm_def,staff_perms, r) {
- var prow = findNodeByName(document.getElementById('permission-tmpl'), 'prow').cloneNode(true);
- root.appendChild(prow);
-
- var all = false;
- for (var i in staff_perms) {
- if (staff_perms[i].perm() == -1) {
- all = true;
- break;
- }
- }
-
-
- var sp,up;
- if (!all) {
- for (var i in staff_perms) {
- if (perm_def.id() == staff_perms[i].perm() || staff_perms[i].perm() == -1) {
- sp = staff_perms[i];
- break;
- }
- }
- }
-
- for (var i in user_perms) {
- if (perm_def.id() == user_perms[i].perm())
- up = user_perms[i];
- }
-
-
- var dis = false;
- if ((up && up.id() < 0) || !sp || !sp.grantable()) dis = true;
- if (all) dis = false;
-
- var label_cell = findNodeByName(prow,'plabel');
- findNodeByName(label_cell,'p.code').appendChild(text(perm_def.code()));
- findNodeByName(label_cell,'p.code').setAttribute('title', perm_def.description());
- findNodeByName(label_cell,'p.code').setAttribute('permid', perm_def.id());
- if (r % 2) label_cell.className += ' odd';
-
- var apply_cell = findNodeByName(prow,'papply');
- findNodeByName(apply_cell,'p.id').disabled = dis;
- findNodeByName(apply_cell,'p.id').checked = up ? true : false;
- if (r % 2) apply_cell.className += ' odd';
-
- var depth_cell = findNodeByName(prow,'pdepth');
- findNodeByName(depth_cell,'p.depth').disabled = dis;
- findNodeByName(depth_cell,'p.depth').id = 'perm-depth-' + perm_def.id();
- if (r % 2) depth_cell.className += ' odd';
- selectBuilder(
- 'perm-depth-' + perm_def.id(),
- globalOrgTypes,
- (up ? up.depth() : findOrgDepth(user.home_ou())),
- { label_field : 'name',
- value_field : 'depth',
- empty_label : $("patronStrings").getString('staff.patron.user_edit.display_perm.select_one'),
- empty_value : '',
- clear : true }
- );
-
- var grant_cell = findNodeByName(prow,'pgrant');
- findNodeByName(grant_cell,'p.grantable').disabled = dis;
- findNodeByName(grant_cell,'p.grantable').checked = up ? (up.grantable() ? true : false) : false;
- if (r % 2) grant_cell.className += ' odd';
+ var prow = findNodeByName(document.getElementById('permission-tmpl'), 'prow').cloneNode(true);
+ root.appendChild(prow);
+
+ var all = false;
+ for (var i in staff_perms) {
+ if (staff_perms[i].perm() == -1) {
+ all = true;
+ break;
+ }
+ }
+
+
+ var sp,up;
+ if (!all) {
+ for (var i in staff_perms) {
+ if (perm_def.id() == staff_perms[i].perm() || staff_perms[i].perm() == -1) {
+ sp = staff_perms[i];
+ break;
+ }
+ }
+ }
+
+ for (var i in user_perms) {
+ if (perm_def.id() == user_perms[i].perm())
+ up = user_perms[i];
+ }
+
+
+ var dis = false;
+ if ((up && up.id() < 0) || !sp || !sp.grantable()) dis = true;
+ if (all) dis = false;
+
+ var label_cell = findNodeByName(prow,'plabel');
+ findNodeByName(label_cell,'p.code').appendChild(text(perm_def.code()));
+ findNodeByName(label_cell,'p.code').setAttribute('title', perm_def.description());
+ findNodeByName(label_cell,'p.code').setAttribute('permid', perm_def.id());
+ if (r % 2) label_cell.className += ' odd';
+
+ var apply_cell = findNodeByName(prow,'papply');
+ findNodeByName(apply_cell,'p.id').disabled = dis;
+ findNodeByName(apply_cell,'p.id').checked = up ? true : false;
+ if (r % 2) apply_cell.className += ' odd';
+
+ var depth_cell = findNodeByName(prow,'pdepth');
+ findNodeByName(depth_cell,'p.depth').disabled = dis;
+ findNodeByName(depth_cell,'p.depth').id = 'perm-depth-' + perm_def.id();
+ if (r % 2) depth_cell.className += ' odd';
+ selectBuilder(
+ 'perm-depth-' + perm_def.id(),
+ globalOrgTypes,
+ (up ? up.depth() : findOrgDepth(user.home_ou())),
+ { label_field : 'name',
+ value_field : 'depth',
+ empty_label : $("patronStrings").getString('staff.patron.user_edit.display_perm.select_one'),
+ empty_value : '',
+ clear : true }
+ );
+
+ var grant_cell = findNodeByName(prow,'pgrant');
+ findNodeByName(grant_cell,'p.grantable').disabled = dis;
+ findNodeByName(grant_cell,'p.grantable').checked = up ? (up.grantable() ? true : false) : false;
+ if (r % 2) grant_cell.className += ' odd';
}
function selectBuilder (id, objects, def, args) {
- var label_field = args['label_field'];
- var value_field = args['value_field'];
- var depth = args['depth'];
-
- if (!depth) depth = 0;
-
- args['depth'] = parseInt(depth) + 1;
-
- var child_field_name = args['child_field_name'];
-
- var sel = id;
- if (typeof sel != 'object')
- sel = document.getElementById(sel);
-
- if (args['clear']) {
- for (var o in sel.options) {
- sel.options[o] = null;
- }
- args['clear'] = false;
- if (args['empty_label']) {
- sel.options[0] = new Option( args['empty_label'], args['empty_value'] );
- sel.selectedIndex = 0;
- }
- }
-
- for (var i in objects) {
- var l = objects[i][label_field];
- var v = objects[i][value_field];
-
- if (typeof l == 'function')
- l = objects[i][label_field]();
-
- if (typeof v == 'function')
- v = objects[i][value_field]();
-
- var opt = new Option( l, v );
-
- if (depth) {
- var d = 10 * depth;
- opt.style.paddingLeft = '' + d + 'px';
- }
-
- sel.options[sel.options.length] = opt;
-
-
- if (typeof def == 'object') {
- for (var j in def) {
- if (v == def[j]) {
- opt.selected = true;
- sel.value = v;
- }
- }
- } else {
- if (v == def) {
- opt.selected = true;
- sel.value = v;
- }
- }
-
- if (child_field_name) {
- var c = objects[i][child_field_name];
- if (typeof c == 'function')
- c = objects[i][child_field_name]();
-
- selectBuilder(
- id,
- c,
- def,
- { label_field : args['label_field'],
- value_field : args['value_field'],
- depth : args['depth'],
- child_field_name : args['child_field_name'] }
- );
- }
-
- }
-}
+ var label_field = args['label_field'];
+ var value_field = args['value_field'];
+ var depth = args['depth'];
+
+ if (!depth) depth = 0;
+
+ args['depth'] = parseInt(depth) + 1;
+
+ var child_field_name = args['child_field_name'];
+
+ var sel = id;
+ if (typeof sel != 'object')
+ sel = document.getElementById(sel);
+
+ if (args['clear']) {
+ for (var o in sel.options) {
+ sel.options[o] = null;
+ }
+ args['clear'] = false;
+ if (args['empty_label']) {
+ sel.options[0] = new Option( args['empty_label'], args['empty_value'] );
+ sel.selectedIndex = 0;
+ }
+ }
+
+ for (var i in objects) {
+ var l = objects[i][label_field];
+ var v = objects[i][value_field];
+
+ if (typeof l == 'function')
+ l = objects[i][label_field]();
+
+ if (typeof v == 'function')
+ v = objects[i][value_field]();
+
+ var opt = new Option( l, v );
+
+ if (depth) {
+ var d = 10 * depth;
+ opt.style.paddingLeft = '' + d + 'px';
+ }
+
+ sel.options[sel.options.length] = opt;
+
+
+ if (typeof def == 'object') {
+ for (var j in def) {
+ if (v == def[j]) {
+ opt.selected = true;
+ sel.value = v;
+ }
+ }
+ } else {
+ if (v == def) {
+ opt.selected = true;
+ sel.value = v;
+ }
+ }
+
+ if (child_field_name) {
+ var c = objects[i][child_field_name];
+ if (typeof c == 'function')
+ c = objects[i][child_field_name]();
+
+ selectBuilder(
+ id,
+ c,
+ def,
+ { label_field : args['label_field'],
+ value_field : args['value_field'],
+ depth : args['depth'],
+ child_field_name : args['child_field_name'] }
+ );
+ }
+
+ }
+}
function findNodesByClass(root, nodeClass, list) {
- if(!list) list = [];
+ if(!list) list = [];
if( !root || !nodeClass) {
- return null;
- }
+ return null;
+ }
if(root.nodeType != 1) {
- return null;
- }
+ return null;
+ }
if(root.className.match(nodeClass)) list.push( root );
if (typeof patron == 'undefined') var patron = {};
patron.util = {};
-patron.util.EXPORT_OK = [
- 'columns', 'mbts_columns', 'mb_columns', 'mp_columns', /*'std_map_row_to_column',*/ 'std_map_row_to_columns',
- 'retrieve_au_via_id', 'retrieve_fleshed_au_via_id', 'retrieve_fleshed_au_via_barcode', 'set_penalty_css', 'retrieve_name_via_id',
+patron.util.EXPORT_OK = [
+ 'columns', 'mbts_columns', 'mb_columns', 'mp_columns', /*'std_map_row_to_column',*/ 'std_map_row_to_columns',
+ 'retrieve_au_via_id', 'retrieve_fleshed_au_via_id', 'retrieve_fleshed_au_via_barcode', 'set_penalty_css', 'retrieve_name_via_id',
'merge', 'ausp_columns', 'format_name'
];
-patron.util.EXPORT_TAGS = { ':all' : patron.util.EXPORT_OK };
+patron.util.EXPORT_TAGS = { ':all' : patron.util.EXPORT_OK };
patron.util.mbts_columns = function(modify,params) {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- JSAN.use('util.money'); JSAN.use('util.date');
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ JSAN.use('util.money'); JSAN.use('util.date');
var commonStrings = document.getElementById('commonStrings');
- var c = [
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mbts_id', 'label' : commonStrings.getString('staff.mbts_id_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.id(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'usr', 'label' : commonStrings.getString('staff.mbts_usr_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.usr() ? "Id = " + my.mbts.usr() : ""; }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'xact_type', 'label' : commonStrings.getString('staff.mbts_xact_type_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_type(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'balance_owed', 'label' : commonStrings.getString('staff.mbts_balance_owed_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mbts.balance_owed() ); },
- 'sort_type' : 'money'
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'total_owed', 'label' : commonStrings.getString('staff.mbts_total_owed_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mbts.total_owed() ); },
- 'sort_type' : 'money'
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'total_paid', 'label' : commonStrings.getString('staff.mbts_total_paid_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mbts.total_paid() ); },
- 'sort_type' : 'money'
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'last_billing_note', 'label' : commonStrings.getString('staff.mbts_last_billing_note_label'), 'flex' : 2,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.last_billing_note(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'last_billing_type', 'label' : commonStrings.getString('staff.mbts_last_billing_type_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.last_billing_type(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'last_billing_ts', 'label' : commonStrings.getString('staff.mbts_last_billing_timestamp_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_billing_ts(), "" ); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'last_payment_note', 'label' : commonStrings.getString('staff.mbts_last_payment_note_label'), 'flex' : 2,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.last_payment_note(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'last_payment_type', 'label' : commonStrings.getString('staff.mbts_last_payment_type_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.last_payment_type(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'last_payment_ts', 'label' : commonStrings.getString('staff.mbts_last_payment_timestamp_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_payment_ts(), "" ); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : commonStrings.getString('staff.mbts_xact_start_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_start() ? my.mbts.xact_start().toString().substr(0,10) : ""; }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : commonStrings.getString('staff.mbts_xact_finish_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_finish() ? my.mbts.xact_finish().toString().substr(0,10) : ""; }
- },
- ];
- for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ var c = [
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mbts_id', 'label' : commonStrings.getString('staff.mbts_id_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.id(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'usr', 'label' : commonStrings.getString('staff.mbts_usr_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.usr() ? "Id = " + my.mbts.usr() : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'xact_type', 'label' : commonStrings.getString('staff.mbts_xact_type_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_type(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'balance_owed', 'label' : commonStrings.getString('staff.mbts_balance_owed_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mbts.balance_owed() ); },
+ 'sort_type' : 'money'
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'total_owed', 'label' : commonStrings.getString('staff.mbts_total_owed_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mbts.total_owed() ); },
+ 'sort_type' : 'money'
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'total_paid', 'label' : commonStrings.getString('staff.mbts_total_paid_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mbts.total_paid() ); },
+ 'sort_type' : 'money'
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'last_billing_note', 'label' : commonStrings.getString('staff.mbts_last_billing_note_label'), 'flex' : 2,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.last_billing_note(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'last_billing_type', 'label' : commonStrings.getString('staff.mbts_last_billing_type_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.last_billing_type(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'last_billing_ts', 'label' : commonStrings.getString('staff.mbts_last_billing_timestamp_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_billing_ts(), "" ); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'last_payment_note', 'label' : commonStrings.getString('staff.mbts_last_payment_note_label'), 'flex' : 2,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.last_payment_note(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'last_payment_type', 'label' : commonStrings.getString('staff.mbts_last_payment_type_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mbts.last_payment_type(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'last_payment_ts', 'label' : commonStrings.getString('staff.mbts_last_payment_timestamp_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_payment_ts(), "" ); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : commonStrings.getString('staff.mbts_xact_start_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_start() ? my.mbts.xact_start().toString().substr(0,10) : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : commonStrings.getString('staff.mbts_xact_finish_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_finish() ? my.mbts.xact_finish().toString().substr(0,10) : ""; }
+ },
+ ];
+ for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
}
patron.util.mb_columns = function(modify,params) {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- JSAN.use('util.money'); JSAN.use('util.date');
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ JSAN.use('util.money'); JSAN.use('util.date');
var commonStrings = document.getElementById('commonStrings');
- var c = [
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mb_id', 'label' : commonStrings.getString('staff.mb_id_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mb.id(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'voided', 'label' : commonStrings.getString('staff.mb_voided_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return get_bool( my.mb.voided() ) ? "Yes" : "No"; }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'voider', 'label' : commonStrings.getString('staff.mb_voider_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mb.voider() ? "Id = " + my.mb.voider() : ""; }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'void_time', 'label' : commonStrings.getString('staff.mb_void_time_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mb.void_time(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'amount', 'label' : commonStrings.getString('staff.mb_amount_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mb.amount() ); },
- 'sort_type' : 'money'
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'billing_type', 'label' : commonStrings.getString('staff.mb_billing_type_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mb.billing_type(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'billing_ts', 'label' : commonStrings.getString('staff.mb_billing_ts_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mb.billing_ts(), "" ); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'note', 'label' : commonStrings.getString('staff.mb_note_label'), 'flex' : 2,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mb.note(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'xact', 'label' : commonStrings.getString('staff.mb_xact_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mb.xact(); }
- },
- ];
- for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ var c = [
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mb_id', 'label' : commonStrings.getString('staff.mb_id_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mb.id(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'voided', 'label' : commonStrings.getString('staff.mb_voided_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return get_bool( my.mb.voided() ) ? "Yes" : "No"; }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'voider', 'label' : commonStrings.getString('staff.mb_voider_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mb.voider() ? "Id = " + my.mb.voider() : ""; }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'void_time', 'label' : commonStrings.getString('staff.mb_void_time_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mb.void_time(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'amount', 'label' : commonStrings.getString('staff.mb_amount_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mb.amount() ); },
+ 'sort_type' : 'money'
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'billing_type', 'label' : commonStrings.getString('staff.mb_billing_type_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mb.billing_type(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'billing_ts', 'label' : commonStrings.getString('staff.mb_billing_ts_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mb.billing_ts(), "" ); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'note', 'label' : commonStrings.getString('staff.mb_note_label'), 'flex' : 2,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mb.note(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'xact', 'label' : commonStrings.getString('staff.mb_xact_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mb.xact(); }
+ },
+ ];
+ for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
}
patron.util.mp_columns = function(modify,params) {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- JSAN.use('util.money'); JSAN.use('util.date'); JSAN.use('patron.util');
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ JSAN.use('util.money'); JSAN.use('util.date'); JSAN.use('patron.util');
var commonStrings = document.getElementById('commonStrings');
- var c = [
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mp_id', 'label' : commonStrings.getString('staff.mp_id_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mp.id(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mp_amount', 'label' : commonStrings.getString('staff.mp_amount_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mp.amount() ); },
- 'sort_type' : 'money'
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mp_payment_type', 'label' : commonStrings.getString('staff.mp_payment_type_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mp.payment_type(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mp_payment_ts', 'label' : commonStrings.getString('staff.mp_payment_timestamp_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mp.payment_ts(), "" ); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mp_note', 'label' : commonStrings.getString('staff.mp_note_label'), 'flex' : 2,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mp.note(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mp_ws', 'label' : commonStrings.getString('staff.mp_cash_drawer_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mp.cash_drawer().name(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mp_staff', 'label' : commonStrings.getString('staff.mp_accepting_usr_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { var s = my.mp.accepting_usr(); if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s); return s.family_name() + " (" + s.card().barcode() + ") @ " + data.hash.aou[ s.home_ou() ].shortname(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'mp_xact', 'label' : commonStrings.getString('staff.mp_xact_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mp.xact(); }
- },
- ];
- for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ var c = [
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mp_id', 'label' : commonStrings.getString('staff.mp_id_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mp.id(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mp_amount', 'label' : commonStrings.getString('staff.mp_amount_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.money.sanitize( my.mp.amount() ); },
+ 'sort_type' : 'money'
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mp_payment_type', 'label' : commonStrings.getString('staff.mp_payment_type_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mp.payment_type(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mp_payment_ts', 'label' : commonStrings.getString('staff.mp_payment_timestamp_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mp.payment_ts(), "" ); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mp_note', 'label' : commonStrings.getString('staff.mp_note_label'), 'flex' : 2,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mp.note(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mp_ws', 'label' : commonStrings.getString('staff.mp_cash_drawer_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mp.cash_drawer().name(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mp_staff', 'label' : commonStrings.getString('staff.mp_accepting_usr_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { var s = my.mp.accepting_usr(); if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s); return s.family_name() + " (" + s.card().barcode() + ") @ " + data.hash.aou[ s.home_ou() ].shortname(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'mp_xact', 'label' : commonStrings.getString('staff.mp_xact_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.mp.xact(); }
+ },
+ ];
+ for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
}
patron.util.ausp_columns = function(modify,params) {
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
JSAN.use('util.functional');
var commonStrings = document.getElementById('commonStrings');
- var c = [
- {
- 'persist' : 'hidden width ordinal', 'id' : 'csp_id', 'label' : commonStrings.getString('staff.csp_id_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return typeof my.csp == 'object' ? my.csp.id() : my.csp; }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'csp_name', 'label' : commonStrings.getString('staff.csp_name_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return typeof my.csp == 'object' ? my.csp.name() : data.hash.csp[ my.csp ].name(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'csp_label', 'label' : commonStrings.getString('staff.csp_label_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return typeof my.csp == 'object' ? my.csp.label() : data.hash.csp[ my.csp ].label(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'csp_block_list', 'label' : commonStrings.getString('staff.csp_block_list_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return typeof my.csp == 'object' ? my.csp.block_list() : data.hash.csp[ my.csp ].block_list(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'csp_block_circ', 'label' : commonStrings.getString('staff.csp_block_circ_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) {
+ var c = [
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'csp_id', 'label' : commonStrings.getString('staff.csp_id_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return typeof my.csp == 'object' ? my.csp.id() : my.csp; }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'csp_name', 'label' : commonStrings.getString('staff.csp_name_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return typeof my.csp == 'object' ? my.csp.name() : data.hash.csp[ my.csp ].name(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'csp_label', 'label' : commonStrings.getString('staff.csp_label_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return typeof my.csp == 'object' ? my.csp.label() : data.hash.csp[ my.csp ].label(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'csp_block_list', 'label' : commonStrings.getString('staff.csp_block_list_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return typeof my.csp == 'object' ? my.csp.block_list() : data.hash.csp[ my.csp ].block_list(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'csp_block_circ', 'label' : commonStrings.getString('staff.csp_block_circ_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) {
var my_csp = typeof my.csp == 'object' ? my.csp : data.hash.csp[ my.csp ];
return String( my_csp.block_list() ).match('CIRC') ? commonStrings.getString('staff.csp_block_circ_yes') : commonStrings.getString('staff.csp_block_circ_no');
}
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'csp_block_renew', 'label' : commonStrings.getString('staff.csp_block_renew_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) {
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'csp_block_renew', 'label' : commonStrings.getString('staff.csp_block_renew_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) {
var my_csp = typeof my.csp == 'object' ? my.csp : data.hash.csp[ my.csp ];
return String( my_csp.block_list() ).match('RENEW') ? commonStrings.getString('staff.csp_block_renew_yes') : commonStrings.getString('staff.csp_block_renew_no');
}
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'csp_block_hold', 'label' : commonStrings.getString('staff.csp_block_hold_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) {
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'csp_block_hold', 'label' : commonStrings.getString('staff.csp_block_hold_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) {
var my_csp = typeof my.csp == 'object' ? my.csp : data.hash.csp[ my.csp ];
return String( my_csp.block_list() ).match('HOLD') ? commonStrings.getString('staff.csp_block_hold_yes') : commonStrings.getString('staff.csp_block_hold_no');
}
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'ausp_id', 'label' : commonStrings.getString('staff.ausp_id_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ausp ? my.ausp.id() : ''; }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'ausp_staff', 'label' : commonStrings.getString('staff.ausp_staff_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) {
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'ausp_id', 'label' : commonStrings.getString('staff.ausp_id_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ausp ? my.ausp.id() : ''; }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'ausp_staff', 'label' : commonStrings.getString('staff.ausp_staff_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) {
return my.ausp ? my.ausp.staff() : '';
}
},
- {
- 'persist' : 'hidden width ordinal', 'id' : 'ausp_set_date', 'label' : commonStrings.getString('staff.ausp_set_date_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) {
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'ausp_set_date', 'label' : commonStrings.getString('staff.ausp_set_date_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) {
return my.ausp ? my.ausp.set_date() : '';
}
},
- {
- 'persist' : 'hidden width ordinal', 'id' : 'ausp_note', 'label' : commonStrings.getString('staff.ausp_note_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) {
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'ausp_note', 'label' : commonStrings.getString('staff.ausp_note_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) {
return my.ausp ? my.ausp.note() : '';
}
},
- {
- 'persist' : 'hidden width ordinal', 'id' : 'ausp_org_unit', 'label' : commonStrings.getString('staff.ausp_org_unit_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) {
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'ausp_org_unit', 'label' : commonStrings.getString('staff.ausp_org_unit_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) {
return my.ausp ? data.hash.aou[ my.ausp.org_unit() ].shortname() : '';
}
}
- ];
- for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ ];
+ for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
}
patron.util.columns = function(modify,params) {
-
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
var commonStrings = document.getElementById('commonStrings');
- var c = [
- {
- 'persist' : 'hidden width ordinal', 'id' : 'barcode', 'label' : commonStrings.getString('staff.card_barcode_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.card().barcode(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'usrname', 'label' : commonStrings.getString('staff.au_usrname_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.usrname(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'profile', 'label' : commonStrings.getString('staff.au_profile_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.pgt[ my.au.profile() ].name(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'active', 'label' : commonStrings.getString('staff.au_active_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return get_bool( my.au.active() ) ? "Yes" : "No"; }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'barred', 'label' : commonStrings.getString('staff.au_barred_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return get_bool( my.au.barred() ) ? "Yes" : "No"; }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'au_id', 'label' : document.getElementById('commonStrings').getString('staff.au_id_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.id(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'prefix', 'label' : document.getElementById('commonStrings').getString('staff.au_name_prefix_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.prefix(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'family_name', 'label' : document.getElementById('commonStrings').getString('staff.au_family_name_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.family_name(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'first_given_name', 'label' : document.getElementById('commonStrings').getString('staff.au_first_given_name_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.first_given_name(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'second_given_name', 'label' : document.getElementById('commonStrings').getString('staff.au_second_given_name_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.second_given_name(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'suffix', 'label' : document.getElementById('commonStrings').getString('staff.au_name_suffix_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.suffix(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'alert_message', 'label' : commonStrings.getString('staff.au_alert_message_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.alert_message(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'claims_returned_count', 'label' : commonStrings.getString('staff.au_claims_returned_count_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.claims_returned_count(); },
- 'sort_type' : 'number'
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : commonStrings.getString('staff.au_create_date_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.create_date(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'expire_date', 'label' : commonStrings.getString('staff.au_expire_date_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.expire_date().substr(0,10); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'home_ou', 'label' : commonStrings.getString('staff.au_home_library_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.aou[ my.au.home_ou() ].shortname(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'home_ou_fullname', 'label' : commonStrings.getString('staff.au_home_library_fullname_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.aou[ my.au.home_ou() ].name(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'credit_forward_balance', 'label' : commonStrings.getString('staff.au_credit_forward_balance_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.credit_forward_balance(); },
- 'sort_type' : 'money'
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'day_phone', 'label' : commonStrings.getString('staff.au_day_phone_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.day_phone(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'evening_phone', 'label' : commonStrings.getString('staff.au_evening_phone_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.evening_phone(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'other_phone', 'label' : commonStrings.getString('staff.au_other_phone_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.other_phone(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'email', 'label' : commonStrings.getString('staff.au_email_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.email(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'alias', 'label' : commonStrings.getString('staff.au_alias_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.alias(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'dob', 'label' : commonStrings.getString('staff.au_birth_date_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.dob().substr(0,10); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'ident_type', 'label' : commonStrings.getString('staff.au_ident_type_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.cit[ my.au.ident_type() ].name(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'ident_value', 'label' : commonStrings.getString('staff.au_ident_value_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.ident_value(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'ident_type2', 'label' : commonStrings.getString('staff.au_ident_type2_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.cit[ my.au.ident_type2() ].name(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'ident_value2', 'label' : commonStrings.getString('staff.au_ident_value2_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.ident_value2(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'net_access_level', 'label' : commonStrings.getString('staff.au_net_access_level_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.net_access_level(); }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'master_account', 'label' : commonStrings.getString('staff.au_master_account_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return get_bool( my.au.master_account() ) ? "Yes" : "No"; }
- },
- {
- 'persist' : 'hidden width ordinal', 'id' : 'usrgroup', 'label' : commonStrings.getString('staff.au_group_id_label'), 'flex' : 1,
- 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.usrgroup(); }
- },
- ];
- for (var i = 0; i < c.length; i++) {
- if (modify[ c[i].id ]) {
- for (var j in modify[ c[i].id ]) {
- c[i][j] = modify[ c[i].id ][j];
- }
- }
- }
- if (params) {
- if (params.just_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < params.just_these.length; i++) {
- var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
- new_c.push( function(y){ return y; }( x ) );
- }
- c = new_c;
- }
- if (params.except_these) {
- JSAN.use('util.functional');
- var new_c = [];
- for (var i = 0; i < c.length; i++) {
- var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
- if (!x) new_c.push(c[i]);
- }
- c = new_c;
- }
-
- }
- return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
+ var c = [
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'barcode', 'label' : commonStrings.getString('staff.card_barcode_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.card().barcode(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'usrname', 'label' : commonStrings.getString('staff.au_usrname_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.usrname(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'profile', 'label' : commonStrings.getString('staff.au_profile_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.pgt[ my.au.profile() ].name(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'active', 'label' : commonStrings.getString('staff.au_active_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return get_bool( my.au.active() ) ? "Yes" : "No"; }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'barred', 'label' : commonStrings.getString('staff.au_barred_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return get_bool( my.au.barred() ) ? "Yes" : "No"; }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'au_id', 'label' : document.getElementById('commonStrings').getString('staff.au_id_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.id(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'prefix', 'label' : document.getElementById('commonStrings').getString('staff.au_name_prefix_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.prefix(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'family_name', 'label' : document.getElementById('commonStrings').getString('staff.au_family_name_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.family_name(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'first_given_name', 'label' : document.getElementById('commonStrings').getString('staff.au_first_given_name_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.first_given_name(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'second_given_name', 'label' : document.getElementById('commonStrings').getString('staff.au_second_given_name_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.second_given_name(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'suffix', 'label' : document.getElementById('commonStrings').getString('staff.au_name_suffix_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.suffix(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'alert_message', 'label' : commonStrings.getString('staff.au_alert_message_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.alert_message(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'claims_returned_count', 'label' : commonStrings.getString('staff.au_claims_returned_count_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.claims_returned_count(); },
+ 'sort_type' : 'number'
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : commonStrings.getString('staff.au_create_date_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.create_date(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'expire_date', 'label' : commonStrings.getString('staff.au_expire_date_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.expire_date().substr(0,10); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'home_ou', 'label' : commonStrings.getString('staff.au_home_library_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.aou[ my.au.home_ou() ].shortname(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'home_ou_fullname', 'label' : commonStrings.getString('staff.au_home_library_fullname_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.aou[ my.au.home_ou() ].name(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'credit_forward_balance', 'label' : commonStrings.getString('staff.au_credit_forward_balance_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.credit_forward_balance(); },
+ 'sort_type' : 'money'
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'day_phone', 'label' : commonStrings.getString('staff.au_day_phone_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.day_phone(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'evening_phone', 'label' : commonStrings.getString('staff.au_evening_phone_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.evening_phone(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'other_phone', 'label' : commonStrings.getString('staff.au_other_phone_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.other_phone(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'email', 'label' : commonStrings.getString('staff.au_email_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.email(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'alias', 'label' : commonStrings.getString('staff.au_alias_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.alias(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'dob', 'label' : commonStrings.getString('staff.au_birth_date_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.dob().substr(0,10); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'ident_type', 'label' : commonStrings.getString('staff.au_ident_type_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.cit[ my.au.ident_type() ].name(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'ident_value', 'label' : commonStrings.getString('staff.au_ident_value_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.ident_value(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'ident_type2', 'label' : commonStrings.getString('staff.au_ident_type2_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return data.hash.cit[ my.au.ident_type2() ].name(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'ident_value2', 'label' : commonStrings.getString('staff.au_ident_value2_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.ident_value2(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'net_access_level', 'label' : commonStrings.getString('staff.au_net_access_level_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.net_access_level(); }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'master_account', 'label' : commonStrings.getString('staff.au_master_account_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return get_bool( my.au.master_account() ) ? "Yes" : "No"; }
+ },
+ {
+ 'persist' : 'hidden width ordinal', 'id' : 'usrgroup', 'label' : commonStrings.getString('staff.au_group_id_label'), 'flex' : 1,
+ 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.au.usrgroup(); }
+ },
+ ];
+ for (var i = 0; i < c.length; i++) {
+ if (modify[ c[i].id ]) {
+ for (var j in modify[ c[i].id ]) {
+ c[i][j] = modify[ c[i].id ][j];
+ }
+ }
+ }
+ if (params) {
+ if (params.just_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < params.just_these.length; i++) {
+ var x = util.functional.find_list(c,function(d){return(d.id==params.just_these[i]);});
+ new_c.push( function(y){ return y; }( x ) );
+ }
+ c = new_c;
+ }
+ if (params.except_these) {
+ JSAN.use('util.functional');
+ var new_c = [];
+ for (var i = 0; i < c.length; i++) {
+ var x = util.functional.find_list(params.except_these,function(d){return(d==c[i].id);});
+ if (!x) new_c.push(c[i]);
+ }
+ c = new_c;
+ }
+
+ }
+ return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } );
}
patron.util.std_map_row_to_columns = function(error_value) {
- return function(row,cols) {
- // row contains { 'my' : { 'au' : {} } }
- // cols contains all of the objects listed above in columns
-
- var obj = {}; obj.OpenILS = {};
- JSAN.use('util.error'); obj.error = new util.error();
- JSAN.use('OpenILS.data'); obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
- JSAN.use('util.date'); JSAN.use('util.money');
-
- var my = row.my;
- var values = [];
- var cmd = '';
- try {
- for (var i = 0; i < cols.length; i++) {
- switch (typeof cols[i].render) {
- case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
- case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
- default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
- }
- }
- if (cmd) eval( cmd );
- } catch(E) {
- obj.error.sdump('D_WARN','map_row_to_column: ' + E);
- if (error_value) { value = error_value; } else { value = ' ' };
- }
- return values;
- }
+ return function(row,cols) {
+ // row contains { 'my' : { 'au' : {} } }
+ // cols contains all of the objects listed above in columns
+
+ var obj = {}; obj.OpenILS = {};
+ JSAN.use('util.error'); obj.error = new util.error();
+ JSAN.use('OpenILS.data'); obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
+ JSAN.use('util.date'); JSAN.use('util.money');
+
+ var my = row.my;
+ var values = [];
+ var cmd = '';
+ try {
+ for (var i = 0; i < cols.length; i++) {
+ switch (typeof cols[i].render) {
+ case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break;
+ case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break;
+ default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; ';
+ }
+ }
+ if (cmd) eval( cmd );
+ } catch(E) {
+ obj.error.sdump('D_WARN','map_row_to_column: ' + E);
+ if (error_value) { value = error_value; } else { value = ' ' };
+ }
+ return values;
+ }
}
patron.util.retrieve_au_via_id = function(session, id, f) {
- JSAN.use('util.network');
- var network = new util.network();
- var patron_obj = network.simple_request(
- 'FM_AU_RETRIEVE_VIA_ID',
- [ session, id ],
- f
- );
- return patron_obj;
+ JSAN.use('util.network');
+ var network = new util.network();
+ var patron_obj = network.simple_request(
+ 'FM_AU_RETRIEVE_VIA_ID',
+ [ session, id ],
+ f
+ );
+ return patron_obj;
}
patron.util.retrieve_name_via_id = function(session, id) {
- JSAN.use('util.network');
- var network = new util.network();
- var parts = network.simple_request(
- 'BLOB_AU_PARTS_RETRIEVE',
- [ session, id, ['family_name', 'first_given_name', 'second_given_name', 'home_ou' ] ]
- );
- return parts;
+ JSAN.use('util.network');
+ var network = new util.network();
+ var parts = network.simple_request(
+ 'BLOB_AU_PARTS_RETRIEVE',
+ [ session, id, ['family_name', 'first_given_name', 'second_given_name', 'home_ou' ] ]
+ );
+ return parts;
}
patron.util.retrieve_fleshed_au_via_id = function(session, id) {
- JSAN.use('util.network');
- var network = new util.network();
- var patron_obj = network.simple_request(
- 'FM_AU_FLESHED_RETRIEVE_VIA_ID.authoritative',
- [ session, id ]
- );
- patron.util.set_penalty_css(patron_obj);
- return patron_obj;
+ JSAN.use('util.network');
+ var network = new util.network();
+ var patron_obj = network.simple_request(
+ 'FM_AU_FLESHED_RETRIEVE_VIA_ID.authoritative',
+ [ session, id ]
+ );
+ patron.util.set_penalty_css(patron_obj);
+ return patron_obj;
}
patron.util.retrieve_fleshed_au_via_barcode = function(session, id) {
- JSAN.use('util.network');
- var network = new util.network();
- var patron_obj = network.simple_request(
- 'FM_AU_RETRIEVE_VIA_BARCODE.authoritative',
- [ session, id ]
- );
- if (typeof patron_obj.ilsevent == 'undefined') patron.util.set_penalty_css(patron_obj);
- return patron_obj;
+ JSAN.use('util.network');
+ var network = new util.network();
+ var patron_obj = network.simple_request(
+ 'FM_AU_RETRIEVE_VIA_BARCODE.authoritative',
+ [ session, id ]
+ );
+ if (typeof patron_obj.ilsevent == 'undefined') patron.util.set_penalty_css(patron_obj);
+ return patron_obj;
}
var TIME = { minute : 60, hour : 60*60, day : 60*60*24, year : 60*60*24*365 };
patron.util.set_penalty_css = function(patron) {
- try {
- removeCSSClass(document.documentElement,'PATRON_HAS_BILLS');
- removeCSSClass(document.documentElement,'PATRON_HAS_OVERDUES');
- removeCSSClass(document.documentElement,'PATRON_HAS_NOTES');
- removeCSSClass(document.documentElement,'PATRON_EXCEEDS_CHECKOUT_COUNT');
- removeCSSClass(document.documentElement,'PATRON_EXCEEDS_OVERDUE_COUNT');
- removeCSSClass(document.documentElement,'PATRON_EXCEEDS_FINES');
- removeCSSClass(document.documentElement,'NO_PENALTIES');
- removeCSSClass(document.documentElement,'ONE_PENALTY');
- removeCSSClass(document.documentElement,'MULTIPLE_PENALTIES');
- removeCSSClass(document.documentElement,'PATRON_HAS_ALERT');
- removeCSSClass(document.documentElement,'PATRON_BARRED');
- removeCSSClass(document.documentElement,'PATRON_INACTIVE');
- removeCSSClass(document.documentElement,'PATRON_EXPIRED');
- removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_DOB');
- removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_ADDRESS');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_65');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_65');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_24');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_24');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_21');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_21');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_18');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_18');
- removeCSSClass(document.documentElement,'PATRON_AGE_GE_13');
- removeCSSClass(document.documentElement,'PATRON_AGE_LT_13');
- removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_1');
- removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_2');
- removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_3');
-
- JSAN.use('util.network'); var net = new util.network();
- net.simple_request('FM_MOUS_RETRIEVE.authoritative',[ ses(), patron.id() ], function(req) {
- if (req.getResultObject().balance_owed() > 0) addCSSClass(document.documentElement,'PATRON_HAS_BILLS');
- });
- net.simple_request('FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative',[ ses(), patron.id() ], function(req) {
- try {
- var co = req.getResultObject();
- if (co.overdue > 0 || co.long_overdue > 0) addCSSClass(document.documentElement,'PATRON_HAS_OVERDUES');
- } catch(E) {
- alert(E);
- }
- });
- net.simple_request('FM_AUN_RETRIEVE_ALL.authoritative',[ ses(), { 'patronid' : patron.id() } ], function(req) {
- var notes = req.getResultObject();
- if (notes.length > 0) addCSSClass(document.documentElement,'PATRON_HAS_NOTES');
- });
-
- /*
- JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
- data.last_patron = patron.id(); data.stash('last_patron');
- */
-
- var penalties = patron.standing_penalties();
- for (var i = 0; i < penalties.length; i++) {
- /* this comes from /opac/common/js/utils.js */
- addCSSClass(document.documentElement,penalties[i].standing_penalty().name());
- }
-
- switch(penalties.length) {
- case 0: addCSSClass(document.documentElement,'NO_PENALTIES'); break;
- case 1: addCSSClass(document.documentElement,'ONE_PENALTY'); break;
- default: addCSSClass(document.documentElement,'MULTIPLE_PENALTIES'); break;
- }
-
- if (patron.alert_message()) {
- addCSSClass(document.documentElement,'PATRON_HAS_ALERT');
- }
-
- if (get_bool( patron.barred() )) {
- addCSSClass(document.documentElement,'PATRON_BARRED');
- }
-
- if (!get_bool( patron.active() )) {
- addCSSClass(document.documentElement,'PATRON_INACTIVE');
- }
-
- try { addCSSClass(document.documentElement,'PATRON_NET_ACCESS_' + patron.net_access_level()); } catch(E) {}
-
- var now = new Date();
- now = now.getTime()/1000;
-
- var expire_parts = patron.expire_date().substr(0,10).split('-');
- expire_parts[1] = expire_parts[1] - 1;
-
- var expire = new Date();
- expire.setFullYear(expire_parts[0], expire_parts[1], expire_parts[2]);
- expire = expire.getTime()/1000
-
- if (expire < now) addCSSClass(document.documentElement,'PATRON_EXPIRED');
-
- if (patron.dob()) {
- var age_parts = patron.dob().substr(0,10).split('-');
- age_parts[1] = age_parts[1] - 1;
-
- var born = new Date();
- born.setFullYear(age_parts[0], age_parts[1], age_parts[2]);
- born = born.getTime()/1000
-
- var patron_age = now - born;
- var years_old = Number(patron_age / TIME.year);
-
- addCSSClass(document.documentElement,'PATRON_AGE_IS_' + years_old);
-
- if ( years_old >= 65 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_65');
- if ( years_old < 65 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_65');
-
- if ( years_old >= 24 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_24');
- if ( years_old < 24 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_24');
-
- if ( years_old >= 21 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_21');
- if ( years_old < 21 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_21');
-
- if ( years_old >= 18 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_18');
- if ( years_old < 18 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_18');
-
- if ( years_old >= 13 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_13');
- if ( years_old < 13 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_13');
- } else {
- addCSSClass(document.documentElement,'PATRON_HAS_INVALID_DOB');
- }
+ try {
+ removeCSSClass(document.documentElement,'PATRON_HAS_BILLS');
+ removeCSSClass(document.documentElement,'PATRON_HAS_OVERDUES');
+ removeCSSClass(document.documentElement,'PATRON_HAS_NOTES');
+ removeCSSClass(document.documentElement,'PATRON_EXCEEDS_CHECKOUT_COUNT');
+ removeCSSClass(document.documentElement,'PATRON_EXCEEDS_OVERDUE_COUNT');
+ removeCSSClass(document.documentElement,'PATRON_EXCEEDS_FINES');
+ removeCSSClass(document.documentElement,'NO_PENALTIES');
+ removeCSSClass(document.documentElement,'ONE_PENALTY');
+ removeCSSClass(document.documentElement,'MULTIPLE_PENALTIES');
+ removeCSSClass(document.documentElement,'PATRON_HAS_ALERT');
+ removeCSSClass(document.documentElement,'PATRON_BARRED');
+ removeCSSClass(document.documentElement,'PATRON_INACTIVE');
+ removeCSSClass(document.documentElement,'PATRON_EXPIRED');
+ removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_DOB');
+ removeCSSClass(document.documentElement,'PATRON_HAS_INVALID_ADDRESS');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_65');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_65');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_24');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_24');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_21');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_21');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_18');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_18');
+ removeCSSClass(document.documentElement,'PATRON_AGE_GE_13');
+ removeCSSClass(document.documentElement,'PATRON_AGE_LT_13');
+ removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_1');
+ removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_2');
+ removeCSSClass(document.documentElement,'PATRON_NET_ACCESS_3');
+
+ JSAN.use('util.network'); var net = new util.network();
+ net.simple_request('FM_MOUS_RETRIEVE.authoritative',[ ses(), patron.id() ], function(req) {
+ if (req.getResultObject().balance_owed() > 0) addCSSClass(document.documentElement,'PATRON_HAS_BILLS');
+ });
+ net.simple_request('FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative',[ ses(), patron.id() ], function(req) {
+ try {
+ var co = req.getResultObject();
+ if (co.overdue > 0 || co.long_overdue > 0) addCSSClass(document.documentElement,'PATRON_HAS_OVERDUES');
+ } catch(E) {
+ alert(E);
+ }
+ });
+ net.simple_request('FM_AUN_RETRIEVE_ALL.authoritative',[ ses(), { 'patronid' : patron.id() } ], function(req) {
+ var notes = req.getResultObject();
+ if (notes.length > 0) addCSSClass(document.documentElement,'PATRON_HAS_NOTES');
+ });
+
+ /*
+ JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+ data.last_patron = patron.id(); data.stash('last_patron');
+ */
+
+ var penalties = patron.standing_penalties();
+ for (var i = 0; i < penalties.length; i++) {
+ /* this comes from /opac/common/js/utils.js */
+ addCSSClass(document.documentElement,penalties[i].standing_penalty().name());
+ }
+
+ switch(penalties.length) {
+ case 0: addCSSClass(document.documentElement,'NO_PENALTIES'); break;
+ case 1: addCSSClass(document.documentElement,'ONE_PENALTY'); break;
+ default: addCSSClass(document.documentElement,'MULTIPLE_PENALTIES'); break;
+ }
+
+ if (patron.alert_message()) {
+ addCSSClass(document.documentElement,'PATRON_HAS_ALERT');
+ }
+
+ if (get_bool( patron.barred() )) {
+ addCSSClass(document.documentElement,'PATRON_BARRED');
+ }
+
+ if (!get_bool( patron.active() )) {
+ addCSSClass(document.documentElement,'PATRON_INACTIVE');
+ }
+
+ try { addCSSClass(document.documentElement,'PATRON_NET_ACCESS_' + patron.net_access_level()); } catch(E) {}
+
+ var now = new Date();
+ now = now.getTime()/1000;
+
+ var expire_parts = patron.expire_date().substr(0,10).split('-');
+ expire_parts[1] = expire_parts[1] - 1;
+
+ var expire = new Date();
+ expire.setFullYear(expire_parts[0], expire_parts[1], expire_parts[2]);
+ expire = expire.getTime()/1000
+
+ if (expire < now) addCSSClass(document.documentElement,'PATRON_EXPIRED');
+
+ if (patron.dob()) {
+ var age_parts = patron.dob().substr(0,10).split('-');
+ age_parts[1] = age_parts[1] - 1;
+
+ var born = new Date();
+ born.setFullYear(age_parts[0], age_parts[1], age_parts[2]);
+ born = born.getTime()/1000
+
+ var patron_age = now - born;
+ var years_old = Number(patron_age / TIME.year);
+
+ addCSSClass(document.documentElement,'PATRON_AGE_IS_' + years_old);
+
+ if ( years_old >= 65 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_65');
+ if ( years_old < 65 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_65');
+
+ if ( years_old >= 24 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_24');
+ if ( years_old < 24 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_24');
+
+ if ( years_old >= 21 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_21');
+ if ( years_old < 21 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_21');
+
+ if ( years_old >= 18 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_18');
+ if ( years_old < 18 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_18');
+
+ if ( years_old >= 13 ) addCSSClass(document.documentElement,'PATRON_AGE_GE_13');
+ if ( years_old < 13 ) addCSSClass(document.documentElement,'PATRON_AGE_LT_13');
+ } else {
+ addCSSClass(document.documentElement,'PATRON_HAS_INVALID_DOB');
+ }
if ( get_bool( patron.juvenile() ) ) addCSSClass(document.documentElement,'PATRON_JUVENILE');
else removeCSSClass(document.documentElement,'PATRON_JUVENILE');
- if (patron.mailing_address()) {
- if (!get_bool(patron.mailing_address().valid())) {
- addCSSClass(document.documentElement,'PATRON_HAS_INVALID_ADDRESS');
- }
- }
- if (patron.billing_address()) {
- if (!get_bool(patron.billing_address().valid())) {
- addCSSClass(document.documentElement,'PATRON_HAS_INVALID_ADDRESS');
- }
- }
-
- } catch(E) {
- dump('patron.util.set_penalty_css: ' + E + '\n');
- alert('patron.util.set_penalty_css: ' + E + '\n');
- }
+ if (patron.mailing_address()) {
+ if (!get_bool(patron.mailing_address().valid())) {
+ addCSSClass(document.documentElement,'PATRON_HAS_INVALID_ADDRESS');
+ }
+ }
+ if (patron.billing_address()) {
+ if (!get_bool(patron.billing_address().valid())) {
+ addCSSClass(document.documentElement,'PATRON_HAS_INVALID_ADDRESS');
+ }
+ }
+
+ } catch(E) {
+ dump('patron.util.set_penalty_css: ' + E + '\n');
+ alert('patron.util.set_penalty_css: ' + E + '\n');
+ }
}
patron.util.merge = function(record_ids) {
if (Number(robj) != 1) { throw(robj); }
return fancy_prompt_data.lead;
} catch(E) {
- dump('patron.util.merge: ' + js2JSON(E) + '\n');
+ dump('patron.util.merge: ' + js2JSON(E) + '\n');
try { error.standard_unexpected_error_alert('Error in patron.util.merge',E); } catch(F) { alert('patron.util.merge: ' + E + '\n'); }
return false;
}