From 5ae3c823e9e7af705ed4ae6a4e813c2196d329f7 Mon Sep 17 00:00:00 2001
From: Jason Etheridge <jason@esilibrary.com>
Date: Mon, 9 Jan 2012 15:18:15 -0500
Subject: [PATCH] Fix self-fetching callnumber columns

The callnumber (and related) columns from circ.util.columns() is meant to
retrieve call number objects if given call number id's instead of objects,
but there was a bug preventing that.

This fixes LP#906523, no call number information in billing interface

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
---
 Open-ILS/xul/staff_client/server/circ/util.js | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js
index 76ab082cbe..6bc54d2b31 100644
--- a/Open-ILS/xul/staff_client/server/circ/util.js
+++ b/Open-ILS/xul/staff_client/server/circ/util.js
@@ -580,7 +580,7 @@ circ.util.columns = function(modify,params) {
                         acn_id = my.acn;
                     }
                 } else if (my.acp) {
-                    if (typeof my.acp.call_number() == 'object') {
+                    if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) {
                         acn_id = my.acp.call_number().id();
                     } else {
                         acn_id = my.acp.call_number();
@@ -594,6 +594,9 @@ circ.util.columns = function(modify,params) {
                     return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
                 } else {
                     if (!my.acn) {
+                        if (typeof scratch_data == 'undefined' || scratch_data == null) {
+                            scratch_data = {};
+                        }
                         if (typeof scratch_data['acn_map'] == 'undefined') {
                             scratch_data['acn_map'] = {};
                         }
@@ -646,7 +649,7 @@ circ.util.columns = function(modify,params) {
                         acn_id = my.acn;
                     }
                 } else if (my.acp) {
-                    if (typeof my.acp.call_number() == 'object') {
+                    if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) {
                         acn_id = my.acp.call_number().id();
                     } else {
                         acn_id = my.acp.call_number();
@@ -660,6 +663,9 @@ circ.util.columns = function(modify,params) {
                     return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
                 } else {
                     if (!my.acn) {
+                        if (typeof scratch_data == 'undefined' || scratch_data == null) {
+                            scratch_data = {};
+                        }
                         if (typeof scratch_data['acn_map'] == 'undefined') {
                             scratch_data['acn_map'] = {};
                         }
@@ -700,7 +706,7 @@ circ.util.columns = function(modify,params) {
                         acn_id = my.acn;
                     }
                 } else if (my.acp) {
-                    if (typeof my.acp.call_number() == 'object') {
+                    if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) {
                         acn_id = my.acp.call_number().id();
                     } else {
                         acn_id = my.acp.call_number();
@@ -714,6 +720,9 @@ circ.util.columns = function(modify,params) {
                     return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
                 } else {
                     if (!my.acn) {
+                        if (typeof scratch_data == 'undefined' || scratch_data == null) {
+                            scratch_data = {};
+                        }
                         if (typeof scratch_data['acn_map'] == 'undefined') {
                             scratch_data['acn_map'] = {};
                         }
@@ -754,7 +763,7 @@ circ.util.columns = function(modify,params) {
                         acn_id = my.acn;
                     }
                 } else if (my.acp) {
-                    if (typeof my.acp.call_number() == 'object') {
+                    if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) {
                         acn_id = my.acp.call_number().id();
                     } else {
                         acn_id = my.acp.call_number();
@@ -768,6 +777,9 @@ circ.util.columns = function(modify,params) {
                     return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
                 } else {
                     if (!my.acn) {
+                        if (typeof scratch_data == 'undefined' || scratch_data == null) {
+                            scratch_data = {};
+                        }
                         if (typeof scratch_data['acn_map'] == 'undefined') {
                             scratch_data['acn_map'] = {};
                         }
@@ -2412,7 +2424,7 @@ circ.util.hold_columns = function(modify,params) {
                         acn_id = my.acn;
                     }
                 } else if (my.acp) {
-                    if (typeof my.acp.call_number() == 'object') {
+                    if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) {
                         acn_id = my.acp.call_number().id();
                     } else {
                         acn_id = my.acp.call_number();
@@ -2426,6 +2438,9 @@ circ.util.hold_columns = function(modify,params) {
                     return document.getElementById('circStrings').getString('staff.circ.utils.retrieving');
                 } else {
                     if (!my.acn) {
+                        if (typeof scratch_data == 'undefined' || scratch_data == null) {
+                            scratch_data = {};
+                        }
                         if (typeof scratch_data['acn_map'] == 'undefined') {
                             scratch_data['acn_map'] = {};
                         }
-- 
2.11.0