From ff083d56923e2314143a257a6554bf8f773cffcf Mon Sep 17 00:00:00 2001
From: Jason Etheridge <jason@esilibrary.com>
Date: Tue, 14 Jun 2011 14:50:33 -0400
Subject: [PATCH] when using params.data keys as print macros, render bare
 numbers correctly, and treat nulls as empty strings

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 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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 28d78f9b97..34a71573af 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/print.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/print.js
@@ -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);}
                         }
                     }
                 }
-- 
2.11.0