<!ENTITY staff.util.timestamp_dialog.apply_btn.accesskey "A">
<!ENTITY staff.printing.set_default "Set Default Printer and Print Test Page">
<!ENTITY staff.printing.page_settings "Page Settings">
+<!ENTITY staff.printing.context.header "Printer Context">
+<!ENTITY staff.printing.context.desc "Different printer settings may be configured for different contexts within the staff client (such as circulation, label printing, etc.). If settings have not been made for a given context, the staff client will fall back on the 'default' context.">
+<!ENTITY staff.printing.context.radio.default.label "Default">
+<!ENTITY staff.printing.context.radio.receipt.label "Receipt">
+<!ENTITY staff.printing.context.radio.label.label "Label">
+<!ENTITY staff.printing.context.radio.mail.label "Mail">
<!ENTITY staff.printing.normal_settings.header "Normal Settings">
<!ENTITY staff.printing.advanced_settings.header "Advanced Settings">
<!ENTITY staff.printing.advanced.mozilla_print "Use default print strategy (Mozilla Print)">
}
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. ');
+ obj.print_strategy = {};
+ var print_contexts = [ 'default', 'receipt', 'label', 'mail' ];
+ for (var i in print_contexts) {
+ JSAN.use('util.file'); var file = new util.file('print_strategy.' + print_contexts[i]);
+ if (file._file.exists()) {
+ try {
+ var x = file.get_content();
+ if (x) {
+ obj.print_strategy[ print_contexts[i] ] = x;
+ obj.data_progress('Print strategy ' + print_contexts[i] + ' retrieved from file. ');
+ }
+ } catch(E) {
+ alert(E);
}
- } catch(E) {
- alert(E);
}
+ file.close();
}
- file.close();
+ obj.stash('print_strategy');
JSAN.use('util.print'); (new util.print()).GetPrintSettings();
obj.data_progress('Printer settings retrieved. ');
obj.debug_label = params['debug_label'];
obj.passthru_content_params = params['passthru_content_params'];
obj.on_url_load = params['on_url_load'];
+ obj.printer_context = params['printer_context'] || 'default';
JSAN.use('util.controller'); obj.controller = new util.controller();
obj.controller.init(
print_params.content_type = 'text/plain';
}
JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.stash_retrieve();
- if (data.print_strategy == 'webBrowserPrint' || !data.print_strategy) {
+ if (
+ !data.print_strategy
+ || !data.print_strategy[obj.printer_context]
+ || (data.print_strategy[obj.printer_context] && data.print_strategy[obj.printer_context] == 'webBrowserPrint')
+ || !data.print_strategy['default']
+ || (data.print_strategy['default'] && data.print_strategy['default'] == 'webBrowserPrint')
+ ) {
// Override the print strategy temporarily in this context
print_params.print_strategy = 'window.print';
}
dump('entering util/print.js\n');
if (typeof util == 'undefined') util = {};
-util.print = function () {
+util.print = function (context) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
JSAN.use('util.functional');
JSAN.use('util.file');
+ this.context = context || 'default';
+
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
- var key = 'oils.printer.external.cmd';
+ var key = 'oils.printer.external.cmd.' + this.context;
var has_key = prefs.prefHasUserValue(key);
this.oils_printer_external_cmd = has_key ? prefs.getCharPref(key) : '';
var obj = this;
- obj.data.last_print = { 'msg' : msg, 'params' : params}; obj.data.stash('last_print');
+ obj.data.last_print = { 'msg' : msg, 'params' : params, 'context' : this.context};
+ obj.data.stash('last_print');
var silent = false;
if ( params && params.no_prompt && (params.no_prompt == true || params.no_prompt == 'true') ) {
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[obj.context] || obj.data.print_strategy['default']) {
- switch(params.print_strategy || obj.data.print_strategy) {
+ switch(params.print_strategy || obj.data.print_strategy[obj.context] || obj.data.print_strategy['default']) {
case 'dos.print':
params.dos_print = true;
case 'custom.print':
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[obj.context] || obj.data.print_strategy['default']) {
-dump('params.print_strategy = ' + params.print_strategy + ' || obj.data.print_strategy = ' + obj.data.print_strategy + ' => ' + ( params.print_strategy || obj.data.print_strategy ) + '\n');
- switch(params.print_strategy || obj.data.print_strategy) {
+ dump('params.print_strategy = ' + params.print_strategy
+ + ' || obj.data.print_strategy[' + obj.context + '] = ' + obj.data.print_strategy[obj.context]
+ + ' || obj.data.print_strategy[default] = ' + obj.data.print_strategy['default']
+ + ' => ' + ( params.print_strategy || obj.data.print_strategy[obj.context] || obj.data.print_strategy['default'] ) + '\n');
+ switch(params.print_strategy || obj.data.print_strategy[obj.context] || obj.data.print_strategy['default']) {
case 'dos.print':
case 'custom.print':
if (typeof w != 'string') {
try {
var error_msg = '';
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var file = new util.file('gPrintSettings');
+ var file = new util.file('gPrintSettings.' + this.context);
if (file._file.exists()) {
temp = file.get_object(); file.close();
for (var i in temp) {
try { this.gPrintSettings[i] = temp[i]; } catch(E) { error_msg += 'Error trying to set gPrintSettings.'+i+'='+temp[i]+' : ' + js2JSON(E) + '\n'; }
}
- } 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 = '';
+ } else if (this.context != 'default') {
+ var file = new util.file('gPrintSettings.default');
+ if (file._file.exists()) {
+ temp = file.get_object(); file.close();
+ for (var i in temp) {
+ try { this.gPrintSettings[i] = temp[i]; } catch(E) { error_msg += 'Error trying to set gPrintSettings.'+i+'='+temp[i]+' : ' + js2JSON(E) + '\n'; }
+ }
+ } 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 = '';
+ }
}
if (error_msg) {
this.error.sdump('D_PRINT',error_msg);
try {
var obj = this;
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
- var file = new util.file('gPrintSettings');
+ var file = new util.file('gPrintSettings.' + this.context);
if (typeof obj.gPrintSettings == 'undefined') obj.GetPrintSettings();
if (obj.gPrintSettings) file.set_object(obj.gPrintSettings);
file.close();
staff.cat.create_or_rebarcode_items=Create or Re-barcode Items
printing.nothing_to_reprint=Nothing to re-print
printing.prompt_for_external_print_cmd=Enter external print command and parameters (use %receipt.txt% or %receipt.html% as the file containing the print data. Those values will be substituted with the proper path.):
-printing.print_strategy_saved=Print strategy (%1$s) saved to file system.
+printing.print_strategy_saved=Print strategy (%1$s) for %2$s context saved to file system.
text_editor.prompt_for_external_cmd=Enter external text editor command and parameters (use %letter.txt% as the file containing the text. This value will be substituted with the proper path.):
<script type="text/javascript" src="printer_settings.js"></script>
</head><body onload="try { my_init(); } catch(E) { alert(E); }" style="background: white;">
<div class="messagecatalog" id="offlineStrings" src="/xul/server/locale/<!--#echo var='locale'-->/offline.properties" />
+ <h1>&staff.printing.context.header;</h1>
+ <p>&staff.printing.context.desc;</p>
+ <form>
+ <input type="radio" name="context" value="default" checked="checked" onclick="g.set_printer_context('default');">&staff.printing.context.radio.default.label;</input>
+ <input type="radio" name="context" value="receipt" onclick="g.set_printer_context('receipt');">&staff.printing.context.radio.receipt.label;</input>
+ <input type="radio" name="context" value="label" onclick="g.set_printer_context('label');">&staff.printing.context.radio.label.label;</input>
+ <input type="radio" name="context" value="mail" onclick="g.set_printer_context('mail');">&staff.printing.context.radio.mail.label;</input>
+ </form>
<h1>&staff.printing.normal_settings.header;</h1>
<iframe id="sample" src="printer_settings.txt"></iframe><br />
<button onclick="try { g.printer_settings(); } catch(E) { alert(E); }">&staff.printing.set_default;</button>
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();
+ g.set_printer_context();
g.prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
}
}
+g.set_printer_context = function(context) {
+ g.context = context || 'default';
+ JSAN.use('util.print'); g.print = new util.print(g.context);
+}
+
g.page_settings = function() {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
g.print.page_settings();
g.set_print_strategy = function(which) {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
if (which == 'custom.print') {
- var key = 'oils.printer.external.cmd';
+ var key = 'oils.printer.external.cmd.' + g.context;
var has_key = g.prefs.prefHasUserValue(key);
var value = has_key ? g.prefs.getCharPref(key) : '';
var cmd = window.prompt(
if (!cmd) { return; }
g.prefs.setCharPref(key,cmd);
}
- JSAN.use('util.file'); var file = new util.file('print_strategy');
+ JSAN.use('util.file'); var file = new util.file('print_strategy.' + g.context);
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');
+ if (!data.print_strategy) {
+ data.print_strategy = {};
+ }
+ data.print_strategy[g.context] = which;
+ data.stash('print_strategy');
alert(
- document.getElementById('offlineStrings').getFormattedString('printing.print_strategy_saved',[which])
+ document.getElementById('offlineStrings').getFormattedString('printing.print_strategy_saved',[which,g.context])
);
}