From fbfb5f1b6dacd7787b1e79f855e9d49bf50049d0 Mon Sep 17 00:00:00 2001 From: maksim Date: Mon, 29 Jan 2018 15:07:23 -0500 Subject: [PATCH] Bug 18743 - ALTERNATE: Take IndependantBranches syspref into account MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine QUEUNE --- C4/Suggestions.pm | 14 ++++++++------ suggestion/suggestion.pl | 6 ++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 70b7b0d..13d2e9b 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -135,12 +135,14 @@ sub SearchSuggestion { if ( C4::Context->preference('IndependentBranches') ) { my $userenv = C4::Context->userenv; if ($userenv) { - if ( !C4::Context->IsSuperLibrarian() && !$suggestion->{branchcode} ) + if ( !C4::Context->IsSuperLibrarian()) { - push @sql_params, $$userenv{branch}; - push @query, q{ - AND (suggestions.branchcode=? OR suggestions.branchcode='') - }; + if( !$suggestion->{branchcode} || $suggestion->{branchcode} eq $userenv->{branch}){ + push @sql_params, $$userenv{branch}; + push @query, q{ + AND (suggestions.branchcode=? OR suggestions.branchcode='') + }; + } } } } else { @@ -405,7 +407,7 @@ sub CountSuggestion { FROM suggestions LEFT JOIN borrowers ON borrowers.borrowernumber=suggestions.suggestedby WHERE STATUS=? - AND (borrowers.branchcode='' OR borrowers.branchcode=?) + AND (suggestions.branchcode='' OR suggestions.branchcode=?) }; $sth = $dbh->prepare($query); $sth->execute( $status, $userenv->{branch} ); diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 98fcca4..48a885d 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -260,8 +260,10 @@ if ($op=~/else/) { my @allsuggestions; foreach my $criteriumvalue ( @criteria_dv ) { # By default, display suggestions from current working branch - unless ( exists $$suggestion_ref{'branchcode'} ) { - $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; + if (C4::Context->preference('IndependentBranches') && !C4::Context->IsSuperLibrarian()) { + unless ( exists $$suggestion_ref{'branchcode'} ) { + $$suggestion_ref{'branchcode'} = C4::Context->userenv->{'branch'}; + } } my $definedvalue = defined $$suggestion_ref{$displayby} && $$suggestion_ref{$displayby} ne ""; -- 2.1.4