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_barcode_map' : {},
'init' : function( params ) {
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 ); }; }(barcode) );
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
}
- alert('Action complete.');
for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ alert('Action complete.');
} catch(E) {
obj.error.standard_unexpected_error_alert('Checkin did not likely happen.',E);
}
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 ); }; }(new_bc) );
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(new_bc) );
} catch(E) {
obj.error.standard_unexpected_error_alert('Barcode ' + barcode + ' was not likely replaced.',E);
}
}
- alert('Action complete.');
for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ alert('Action complete.');
} catch(E) {
obj.error.standard_unexpected_error_alert('Barcode replacements did not likely happen.',E);
}
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 ); }; }(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) {
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 ); }; }(barcode) );
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
}
- alert('Action complete.');
for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ alert('Action complete.');
}
],
'sel_patron' : [
var barcode = obj.selection_list[i].barcode;
if (test == 't') {
circ.util.renew_via_barcode( barcode );
- funcs.push( function(a) { return function() { obj.copy_status( a ); }; }(barcode) );
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
} else {
alert('Item with barcode ' + barcode + ' is not circulating.');
}
}
- alert('Action complete.');
for (var i = 0; i < funcs.length; i++) { funcs[i](); }
+ alert('Action complete.');
}
],
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 ); }; }(barcode) );
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
}
for (var i = 0; i < funcs.length; i++) { funcs[i](); }
}
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 ); }; }(barcode) );
+ funcs.push( function(a) { return function() { obj.copy_status( a, true ); }; }(barcode) );
}
for (var i = 0; i < funcs.length; i++) { funcs[i](); }
}
obj.copy_status();
}
],
+ 'cmd_copy_status_upload_file' : [
+ ['command'],
+ function() {
+ function pick_file(mode) {
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ var nsIFilePicker = Components.interfaces.nsIFilePicker;
+ var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance( nsIFilePicker );
+ fp.init(
+ window,
+ mode == 'open' ? "Import Barcode File" : "Save Barcode File As",
+ mode == 'open' ? nsIFilePicker.modeOpen : nsIFilePicker.modeSave
+ );
+ fp.appendFilters( nsIFilePicker.filterAll );
+ if ( fp.show( ) == nsIFilePicker.returnOK && fp.file ) {
+ return fp.file;
+ } else {
+ return null;
+ }
+ }
+ netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect UniversalBrowserWrite');
+ JSAN.use('util.file');
+ var f = pick_file('open');
+ var i_file = new util.file(''); i_file._file = f;
+ var content = i_file.get_content();
+ i_file.close();
+ 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('File uploaded.'); } );
+ exec.chain( funcs );
+ } else {
+ alert('No barcodes found in file.');
+ }
+
+ }
+ ],
'cmd_copy_status_print' : [
['command'],
function() {
}
},
- 'copy_status' : function(barcode) {
+ 'copy_status' : function(barcode,refresh) {
var obj = this;
try {
try { document.getElementById('last_scanned').setAttribute('value',''); } catch(E) {}
if ( obj.test_barcode(barcode) ) { /* good */ } else { /* bad */ return; }
}
JSAN.use('circ.util');
- obj.network.simple_request('FM_ACP_DETAILS_VIA_BARCODE', [ ses(), barcode ], function(req) {
+ function handle_req(req) {
try {
var details = req.getResultObject();
if (details == null) {
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' : 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,
+ 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_barcode_map[barcode] == 'undefined') obj.list_barcode_map[barcode] =[];
+ obj.list_barcode_map[barcode].push(nparams);
+ }
+ } else {
+ if (!document.getElementById('trim_list').checked) {
+ for (var i = 0; i < obj.list_barcode_map[barcode].length; i++) {
+ params.my_node = obj.list_barcode_map[barcode][i].my_node;
+ obj.list.refresh_row(params);
+ }
+ } else {
+ obj.list.append(params);
}
- );
+ }
} catch(E) {
- obj.error.standard_unexpected_error_alert('',E);
+ obj.error.standard_unexpected_error_alert('barcode = ' + barcode,E);
}
- } );
+ }
+ var result = obj.network.simple_request('FM_ACP_DETAILS_VIA_BARCODE', [ ses(), barcode ]);
+ handle_req({'getResultObject':function(){return result;}}); // used to be async
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('',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();
}