}
},
+ 'load_saved_print_templates' : function() {
+ var obj = this;
+ try {
+ JSAN.use('util.file'); var file = new util.file('print_list_templates');
+ 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();
+ } catch(E) {
+ alert("Error in OpenILS.data, load_saved_print_templates(): " + E);
+ }
+ },
+
+ 'fetch_print_strategy' : function() {
+ var obj = this;
+ try {
+ 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);
+ }
+ }
+ file.close();
+ }
+ obj.stash('print_strategy');
+ } catch(E) {
+ alert('Error in OpenILS.data, fetch_print_strategy(): ' + E);
+ }
+ },
+
'print_list_defaults' : function() {
var obj = this;
//if (typeof obj.print_list_templates == 'undefined') {
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 {
}
file.close();
- 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);
- }
- }
- file.close();
- }
- obj.stash('print_strategy');
-
+ obj.print_list_defaults();
+ obj.data_progress('Default print templates set. ');
+ obj.load_saved_print_templates();
+ obj.fetch_print_strategy();
JSAN.use('util.print'); (new util.print()).GetPrintSettings();
obj.data_progress('Printer settings retrieved. ');
},
'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();
+ data.print_list_defaults();
+ data.load_saved_print_templates();
+ data.fetch_print_strategy();
+ JSAN.use('util.print'); (new util.print()).GetPrintSettings();
},
'patron_init' : function() {