when using params.data keys as print macros, render bare numbers correctly, and treat...
authorJason Etheridge <jason@esilibrary.com>
Tue, 14 Jun 2011 18:50:33 +0000 (14:50 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 30 Jun 2011 16:58:34 +0000 (12:58 -0400)
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/xul/staff_client/chrome/content/util/print.js

index 28d78f9..34a7157 100644 (file)
@@ -294,9 +294,13 @@ util.print.prototype = {
                 if (typeof params.data != 'undefined') {
                     for (var i in params.data) {
                         var re = new RegExp('%'+i+'%',"g");
-                        if (typeof params.data[i] == 'string') {
+                        if (typeof params.data[i] == 'string' || typeof params.data[i] == 'number') {
                             try{b = s; s=s.replace(re, params.data[i]);}
                                 catch(E){s = b; this.error.standard_unexpected_error_alert('print.js, template_sub(): 3 string = <' + s + '>',E);}
+                        } else {
+                            /* likely a null, print as an empty string */
+                            try{b = s; s=s.replace(re, '');}
+                                catch(E){s = b; this.error.standard_unexpected_error_alert('print.js, template_sub(): 3 string = <' + s + '>',E);}
                         }
                     }
                 }