Bug 15128 - Followup
authorNick Clemens <nick@bywatersolutions.com>
Mon, 20 Jun 2016 20:04:21 +0000 (16:04 -0400)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 8 Jul 2016 14:09:48 +0000 (14:09 +0000)
Only check limit for signed in borrower
Show all suggestions after a new one is added

Signed-off-by: Barbara Walters <bwalters@ncrl.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
opac/opac-suggestions.pl

index 6d2b88b..ff64dcb 100755 (executable)
@@ -112,12 +112,14 @@ if ( $op eq 'else' ) {
     }
 }
 
-my $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) };
+my $patrons_pending_suggestions_count = 0;
+if ( $borrowernumber ) {
+    my $patrons_pending_suggestions_count = scalar @{ SearchSuggestion( { suggestedby => $borrowernumber, STATUS => 'ASKED' } ) } ;
+}
 
 my $suggestions_loop = &SearchSuggestion($suggestion);
 if ( $op eq "add_confirm" ) {
-    my $count_own_suggestions = $borrowernumber ? &SearchSuggestion( { suggestedby => $borrowernumber } ) : 0;
-    if ( $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") )
+    if ( $patrons_pending_suggestions_count >= C4::Context->preference("MaxOpenSuggestions") ) #only check limit for signed in borrowers
     {
         push @messages, { type => 'error', code => 'too_many' };
     }
@@ -149,7 +151,7 @@ if ( $op eq "add_confirm" ) {
 
         # delete empty fields, to avoid filter in "SearchSuggestion"
         foreach my $field ( qw( title author publishercode copyrightdate place collectiontitle isbn STATUS ) ) {
-            delete $suggestion->{$field} unless $suggestion->{$field};
+            delete $suggestion->{$field}; #clear search filters (except borrower related) to show all suggestions after placing a new one
         }
         $suggestions_loop = &SearchSuggestion($suggestion);
         push @messages, { type => 'info', code => 'success_on_inserted' };