From a8c9f851be18b66a5aa1de95c3a934a0d9d099f1 Mon Sep 17 00:00:00 2001
From: pines
Date: Tue, 27 Mar 2007 01:57:11 +0000
Subject: [PATCH] backporting shortname print macro and holding maintenance
fixes. and no_auto_select fix for offline xact manager and transit list
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0_4@7110 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
.../staff_client/chrome/content/OpenILS/data.js | 18 ++--
.../xul/staff_client/chrome/content/util/print.js | 2 +
.../server/admin/offline_manage_xacts.js | 113 ++++++++++++++++++---
.../xul/staff_client/server/admin/transit_list.js | 4 +-
.../xul/staff_client/server/cat/copy_browser.js | 12 ++-
5 files changed, 120 insertions(+), 29 deletions(-)
diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
index 59e5404b43..2b6c7ca2dd 100644
--- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
+++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
@@ -150,25 +150,25 @@ OpenILS.data.prototype = {
'type' : 'items',
'header' : 'The following items have been examined:
',
'line_item' : '- %title%
\r\nBarcode: %barcode%\r\n',
- 'footer' : '
%PINES_CODE% %TODAY_TRIM%
\r\n
\r\n',
+ 'footer' : '
%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n',
},
'transit_list' : {
'type' : 'transits',
'header' : 'Transits:
',
'line_item' : '- From: %transit_source% To: %transit_dest_lib%
\r\nWhen: %transit_source_send_time%
\r\nBarcode: %transit_item_barcode% Title: %transit_item_title%
\r\n',
- 'footer' : '
%PINES_CODE% %TODAY_TRIM%
\r\n
\r\n',
+ 'footer' : '
%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n',
},
'items_out' : {
'type' : 'items',
'header' : 'Welcome to %LIBRARY%!
\r\nYou have the following items:
',
'line_item' : '- %title%
\r\nBarcode: %barcode% Due: %due_date%\r\n',
- 'footer' : '
%PINES_CODE% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n',
+ 'footer' : '
%SHORTNAME% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n',
},
'checkout' : {
'type' : 'items',
'header' : 'Welcome to %LIBRARY%!
\r\nYou checked out the following items:
',
'line_item' : '- %title%
\r\nBarcode: %barcode% Due: %due_date%\r\n',
- 'footer' : '
%PINES_CODE% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n',
+ 'footer' : '
%SHORTNAME% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n',
},
'offline_checkout' : {
'type' : 'offline_checkout',
@@ -180,25 +180,25 @@ OpenILS.data.prototype = {
'type' : 'items',
'header' : 'You checked in the following items:
',
'line_item' : '- %title%
\r\nBarcode: %barcode% Call Number: %call_number%\r\n',
- 'footer' : '
%PINES_CODE% %TODAY_TRIM%
\r\n
\r\n',
+ 'footer' : '
%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n',
},
'bill_payment' : {
'type' : 'payment',
'header' : 'Welcome to %LIBRARY%!
A receipt of your transaction:
| Original Balance: | $%original_balance% |
| Payment Method: | %payment_type% |
| Payment Received: | $%payment_received% |
| Payment Applied: | $%payment_applied% |
| Billings Voided: | %voided_balance% |
| Change Given: | $%change_given% |
| New Balance: | $%new_balance% |
Note: %note%
Specific bills:
',
'line_item' : 'Bill #%bill_id% %last_billing_type% Received: $%payment%
%barcode% %title%
',
- 'footer' : '
%PINES_CODE% %TODAY_TRIM%
',
+ 'footer' : '
%SHORTNAME% %TODAY_TRIM%
',
},
'bills_historical' : {
'type' : 'bills',
'header' : 'Welcome to %LIBRARY%!
You had the following bills:
',
'line_item' : '- Bill #%id%
-
| Date: | %xact_start% |
| Type: | %xact_type% |
| Last Billing: | %last_billing_type% %last_billing_note% |
| Total Billed: | $%total_owed% |
| Last Payment: | %last_payment_type% %last_payment_note% |
| Total Paid: | $%total_paid% |
| Balance: | $%balance_owed% |
',
- 'footer' : '
%PINES_CODE% %TODAY_TRIM%
\r\n
\r\n',
+ 'footer' : '
%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n',
},
'bills_current' : {
'type' : 'bills',
'header' : 'Welcome to %LIBRARY%!
You have the following bills:
',
'line_item' : '- Bill #%id%
-
| Date: | %xact_start% |
| Type: | %xact_type% |
| Last Billing: | %last_billing_type% %last_billing_note% |
| Total Billed: | $%total_owed% |
| Last Payment: | %last_payment_type% %last_payment_note% |
| Total Paid: | $%total_paid% |
| Balance: | $%balance_owed% |
',
- 'footer' : '
%PINES_CODE% %TODAY_TRIM%
\r\n
\r\n',
+ 'footer' : '
%SHORTNAME% %TODAY_TRIM%
\r\n
\r\n',
},
'offline_checkin' : {
'type' : 'offline_checkin',
@@ -228,7 +228,7 @@ OpenILS.data.prototype = {
'type' : 'holds',
'header' : 'Welcome to %LIBRARY%!
\r\nYou have the following titles on hold:
',
'line_item' : '- %title%\r\n',
- 'footer' : '
%PINES_CODE% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n',
+ 'footer' : '
%SHORTNAME% %TODAY_TRIM%
\r\nYou were helped by %STAFF_FIRSTNAME%
\r\n
\r\n',
}
};
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/print.js b/Open-ILS/xul/staff_client/chrome/content/util/print.js
index d516b33cd0..b4d6f9b863 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/print.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js
@@ -154,6 +154,8 @@ util.print.prototype = {
catch(E){s = b; this.error.sdump('D_WARN','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
try{b = s; s = s.replace(/%PINES_CODE%/,params.lib.shortname());}
catch(E){s = b; this.error.sdump('D_WARN','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
+ try{b = s; s = s.replace(/%SHORTNAME%/,params.lib.shortname());}
+ catch(E){s = b; this.error.sdump('D_WARN','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
try{b = s; s = s.replace(/%STAFF_FIRSTNAME%/,params.staff.first_given_name());}
catch(E){s = b; this.error.sdump('D_WARN','string = <' + s + '> error = ' + js2JSON(E)+'\n');}
try{b = s; s = s.replace(/%STAFF_LASTNAME%/,params.staff.family_name());}
diff --git a/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js b/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js
index 2d20e1bb24..aed9b2a88d 100644
--- a/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js
+++ b/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js
@@ -367,17 +367,23 @@ admin.offline_manage_xacts.prototype = {
'check_perm' : function(perms) {
var obj = this;
- 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;
+ 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('Error checking permissions',E);
}
- return robj.length == 0 ? true : false;
},
'execute_ses' : function() {
var obj = this;
+ try {
+
clear_the_cache();
obj.data.stash_retrieve();
@@ -393,17 +399,24 @@ admin.offline_manage_xacts.prototype = {
x.send(null);
dump(url + ' = ' + x.responseText + '\n' );
+ if (!x.responseText) throw('Bad response from CGI component');
var robj = JSON2js(x.responseText);
if (robj.ilsevent != 0) { alert('Execute error: ' + x.responseText); }
obj.retrieve_seslist(); obj.render_seslist();
}
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Error executing session',E);
+ }
},
'ses_errors' : function() {
var obj = this;
+ try {
+
clear_the_cache();
obj.data.stash_retrieve();
@@ -418,15 +431,23 @@ admin.offline_manage_xacts.prototype = {
x.send(null);
dump(url + ' = ' + x.responseText + '\n' );
+ if (!x.responseText) throw('Bad response from CGI component');
var robj = JSON2js(x.responseText);
return { 'errors' : robj, 'description' : obj.seslist[ obj.sel_list[0] ].description };
+ } catch(E) {
+ throw('Error retrieving session errors: ' + 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("Can't rename a non-existent file"); }
@@ -439,29 +460,50 @@ admin.offline_manage_xacts.prototype = {
if (count++>100) throw("Taking too long to find a unique filename.");
}
pending._file.moveTo(null,obj.transition_filename);
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Error renaming xact 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('Something bad happened. New offline transactions were accumulated during our attempted upload. Tell your system admin that the file involved is ' + obj.transition_filename,'Scary Error','Ok',null,null,'Check here to confirm this message'); return; }
var file = new util.file(obj.transition_filename);
file._file.moveTo(null,'pending_xacts');
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Error reverting xact 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')
+ if (file._file.exists()) file._file.moveTo(null,obj.transition_filename + '.complete');
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Error archiving xact file',E);
+ }
},
'upload' : function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var obj = this;
+
+ try {
+
if (obj.sel_list.length == 0) { alert('Please select a session to upload to.'); return; }
if (obj.sel_list.length > 1) { alert('Please select a single session to upload to.'); return; }
@@ -517,11 +559,17 @@ admin.offline_manage_xacts.prototype = {
}
};
x.contentWindow.xulG = newG;
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Error uploading xacts',E);
+ }
},
'ses_status' : function() {
var obj = this;
+ try {
+
clear_the_cache();
obj.data.stash_retrieve();
@@ -536,15 +584,25 @@ admin.offline_manage_xacts.prototype = {
x.send(null);
dump(url + ' = ' + x.responseText + '\n' );
+ if (!x.responseText) throw('Bad response from CGI component');
var robj = JSON2js(x.responseText);
return robj;
+
+ } catch(E) {
+
+ obj.error.standard_unexpected_error_alert('Error retrieving session status',E);
+ return { 'ilsevent' : -2 };
+
+ }
},
'create_ses' : function() {
var obj = this;
+ try {
+
var desc = window.prompt('Please enter a description:','','Create an Offline Transaction Session');
if (desc=='' || desc==null) { return; }
@@ -561,12 +619,18 @@ admin.offline_manage_xacts.prototype = {
x.send(null);
dump(url + ' = ' + x.responseText + '\n' );
+ if (!x.responseText) throw('Bad response from CGI component');
var robj = JSON2js(x.responseText);
if (robj.ilsevent == 0) {
obj.retrieve_seslist(); obj.render_seslist();
} else {
alert('Error: ' + x.responseText);
}
+
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Error creating session',E);
+ }
+
},
'retrieve_seslist' : function() {
@@ -587,11 +651,15 @@ admin.offline_manage_xacts.prototype = {
x.open("GET",url,false);
x.send(null);
- dump(url + ' = ' + x.responseText + '\n' );
+ dump(url + ' = ' + typeof(x.responseText) + '\n' );
+
+ if (!x.responseText) throw('Bad response from CGI component');
var robj = JSON2js( x.responseText );
if (typeof robj.ilsevent != 'undefined') throw(robj);
+ if (!robj) throw(robj);
+
obj.seslist = robj.sort(
function(a,b) {
return b.create_time - a.create_time;
@@ -607,6 +675,8 @@ admin.offline_manage_xacts.prototype = {
var obj = this;
+ try {
+
var old_idx = obj.list.node.currentIndex;
if (old_idx < 0) old_idx = 0;
@@ -617,7 +687,7 @@ admin.offline_manage_xacts.prototype = {
funcs.push(
function(idx,row){
return function(){
- obj.list.append( { 'retrieve_id' : idx, 'row' : row } );
+ obj.list.append( { 'retrieve_id' : idx, 'row' : row, 'no_auto_select' : true } );
if (idx == old_idx) obj.list.node.view.selection.select(idx);
};
}(i,{ 'my' : obj.seslist[i] })
@@ -630,16 +700,21 @@ admin.offline_manage_xacts.prototype = {
document.getElementById('execute').disabled = true;
document.getElementById('upload').disabled = true;
+ } catch(E) {
+ obj.error.standard_unexpected_error_alert('Error rendering session list',E);
+ }
},
'render_scriptlist' : function() {
dump('render_scriptlist\n');
- document.getElementById('deck').selectedIndex = 1;
-
var obj = this;
+ try {
+
+ document.getElementById('deck').selectedIndex = 1;
+
obj.script_list.clear();
var status = obj.ses_status();
@@ -652,23 +727,29 @@ admin.offline_manage_xacts.prototype = {
funcs.push(
function(row){
return function(){
- obj.script_list.append( { 'row' : row } );
+ 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('Error rendering script list',E);
+ }
},
'render_errorlist' : function() {
dump('render_errorlist\n');
- document.getElementById('deck').selectedIndex = 2;
-
var obj = this;
+ try {
+
+ document.getElementById('deck').selectedIndex = 2;
+
obj.error_list.clear();
var error_meta = obj.ses_errors();
@@ -681,13 +762,17 @@ admin.offline_manage_xacts.prototype = {
funcs.push(
function(idx,row){
return function(){
- obj.error_list.append( { 'retrieve_id' : idx, 'row' : row } );
+ 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('Error rendering error list',E);
+ }
},
'render_status' : function() {
diff --git a/Open-ILS/xul/staff_client/server/admin/transit_list.js b/Open-ILS/xul/staff_client/server/admin/transit_list.js
index b301a0b453..10a697117b 100644
--- a/Open-ILS/xul/staff_client/server/admin/transit_list.js
+++ b/Open-ILS/xul/staff_client/server/admin/transit_list.js
@@ -37,8 +37,8 @@ admin.transit_list.prototype = {
function gen_list_append(id,which_list) {
return function() {
switch(which_list) {
- case 0: obj.list.append( { 'row' : { 'my' : { 'transit_id' : id } } } ); break;
- case 1: obj.list2.append( { 'row' : { 'my' : { 'transit_id' : id } } } ); break;
+ case 0: obj.list.append( { 'row' : { 'my' : { 'transit_id' : id } }, 'no_auto_select' : true } ); break;
+ case 1: obj.list2.append( { 'row' : { 'my' : { 'transit_id' : id } }, 'no_auto_select' : true } ); break;
}
};
}
diff --git a/Open-ILS/xul/staff_client/server/cat/copy_browser.js b/Open-ILS/xul/staff_client/server/cat/copy_browser.js
index b0c916d719..8c31a51937 100644
--- a/Open-ILS/xul/staff_client/server/cat/copy_browser.js
+++ b/Open-ILS/xul/staff_client/server/cat/copy_browser.js
@@ -874,7 +874,7 @@ cat.copy_browser.prototype = {
'command',
function(ev) {
//obj.show_my_libs(ev.target.value);
- JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
+ 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();
},
@@ -886,14 +886,18 @@ cat.copy_browser.prototype = {
JSAN.use('util.widgets');
- file = new util.file('copy_browser_prefs');
+ 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');
+ 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
@@ -902,7 +906,7 @@ cat.copy_browser.prototype = {
document.getElementById('show_acps').addEventListener(
'command',
function(ev) {
- JSAN.use('util.file'); var file = new util.file('copy_browser_prefs');
+ 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
--
2.11.0