From 6cd9dbc1efe2917ee2fdef059d9dd06531a764ff Mon Sep 17 00:00:00 2001
From: Mason James <mtj@kohaaloha.com>
Date: Wed, 16 Sep 2015 15:28:44 +1200
Subject: [PATCH] Bug 14830 - anonymous purchase suggestions are
 invisible/inaccessible in staff interface
Content-Type: text/plain; charset="utf-8"

To test bug...

1/ set various suggestion sysprefs like so

mysql> select variable, value  from systempreferences where variable like '%sugg%';
+-------------------------------------+-------+
| variable                            | value |
+-------------------------------------+-------+
| AllowPurchaseSuggestionBranchChoice | 0     |
| AnonSuggestions                     | 1     |
| OpacSuggestionManagedBy             | 1     |
| OPACViewOthersSuggestions           | 0     |
| suggestion                          | 1     |
+-------------------------------------+-------+

2/ create an generic ANON borrower for testing

3/ set 'AnonymousPatron' syspref to ANON's borrowernumber

4/ add a suggestion from the OPAC, without being logged in (ie: an anonymous suggestion)

5/ go to staff interface , fail to see suggestion :'(
    https://demo-admin.yourkoha.foo/cgi-bin/koha/suggestion/suggestion.pl

6/ apply patch...

7/ go to staff interface , see suggestion! :) (pix attached)
    https://demo-admin.yourkoha.foo/cgi-bin/koha/suggestion/suggestion.pl

8/ reward yourself with cake (optional)
---
 C4/Suggestions.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm
index b5af96e..5d45c8e 100644
--- a/C4/Suggestions.pm
+++ b/C4/Suggestions.pm
@@ -150,7 +150,7 @@ sub SearchSuggestion {
         if ( defined $suggestion->{branchcode} && $suggestion->{branchcode} ) {
             unless ( $suggestion->{branchcode} eq '__ANY__' ) {
                 push @sql_params, $suggestion->{branchcode};
-                push @query,      qq{ AND suggestions.branchcode=? };
+                push @query,      qq{ AND (suggestions.branchcode=? or suggestions.branchcode is null) };
             }
         }
     }
-- 
2.1.4