Make sure offline interfaces correctly load printer settings outside of logins. ...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 19 Sep 2010 03:50:28 +0000 (03:50 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 19 Sep 2010 03:50:28 +0000 (03:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17815 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
Open-ILS/xul/staff_client/chrome/content/circ/offline.js
Open-ILS/xul/staff_client/chrome/content/util/print.js

index 803e107..d318ddb 100644 (file)
@@ -244,6 +244,56 @@ OpenILS.data.prototype = {
         }
     },
 
+    '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') {
@@ -384,26 +434,6 @@ OpenILS.data.prototype = {
         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 {
@@ -434,25 +464,10 @@ OpenILS.data.prototype = {
         }
         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. ');
 
index e34e793..5fdf26e 100644 (file)
@@ -74,55 +74,11 @@ circ.offline.prototype = {
     },
 
     '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() {
index b297043..87e1618 100644 (file)
@@ -105,6 +105,11 @@ util.print.prototype = {
             netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
             obj.data.init({'via':'stash'});
 
+            if (typeof obj.data.print_strategy == 'undefined') {
+                obj.data.print_strategy = {};
+                obj.data.stash('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[obj.context] || obj.data.print_strategy['default']) {