Fix for Bug 4945 - Patron search is limited by default to the currently logged-in library
I couldn't figure out how (or whether) GetBranchesLoop could be convinced to return a list of branches without selecting one, so I swapped GetBranchesLoop with GetBranches. This will preselect a branch only if a branch has been submitted as part of a query. This does NOT preselect the correct branch when IndependantBranches is turned on. I also added a template variable which is true if a query has been submitted with a branch or a category so that the extra form fields can be displayed, reminding the user that they added limiters to their query. Signed-off-by: Nicole Engard <nengard@bywatersolutions.com> Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
parent
15334926ad
commit
98efac4c0a
3 changed files with 33 additions and 20 deletions
|
@ -114,8 +114,9 @@ YAHOO.util.Event.onContentReady("header_search", function() {
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">//<![CDATA[
|
<script type="text/javascript">//<![CDATA[
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#filters").toggle();
|
<!-- TMPL_IF NAME="advsearch" -->$("#filteraction_on").toggle();
|
||||||
$("#filteraction_off").toggle();
|
<!-- TMPL_ELSE -->$("#filters").toggle();
|
||||||
|
$("#filteraction_off").toggle();<!-- /TMPL_IF -->
|
||||||
});
|
});
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -51,9 +51,19 @@ my $patron = $input->Vars;
|
||||||
foreach (keys %$patron){
|
foreach (keys %$patron){
|
||||||
delete $$patron{$_} unless($$patron{$_});
|
delete $$patron{$_} unless($$patron{$_});
|
||||||
}
|
}
|
||||||
|
|
||||||
my @categories=C4::Category->all;
|
my @categories=C4::Category->all;
|
||||||
my $branches=(defined $$patron{branchcode}?GetBranchesLoop($$patron{branchcode}):GetBranchesLoop());
|
|
||||||
|
my $branches = GetBranches;
|
||||||
|
my @branchloop;
|
||||||
|
|
||||||
|
foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
|
||||||
|
my $selected = 1 if $branches->{$_}->{branchcode} eq $$patron{branchcode};
|
||||||
|
my %row = ( value => $_,
|
||||||
|
selected => $selected,
|
||||||
|
branchname => $branches->{$_}->{branchname},
|
||||||
|
);
|
||||||
|
push @branchloop, \%row;
|
||||||
|
}
|
||||||
|
|
||||||
my %categories_dislay;
|
my %categories_dislay;
|
||||||
|
|
||||||
|
@ -119,11 +129,6 @@ foreach my $borrower(@$results[$from..$to-1]){
|
||||||
push(@resultsdata, \%row);
|
push(@resultsdata, \%row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($$patron{branchcode}){
|
|
||||||
foreach my $branch (grep{$_->{value} eq $$patron{branchcode}}@$branches){
|
|
||||||
$$branch{selected}=1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($$patron{categorycode}){
|
if ($$patron{categorycode}){
|
||||||
foreach my $category (grep{$_->{categorycode} eq $$patron{categorycode}}@categories){
|
foreach my $category (grep{$_->{categorycode} eq $$patron{categorycode}}@categories){
|
||||||
$$category{selected}=1;
|
$$category{selected}=1;
|
||||||
|
@ -142,9 +147,9 @@ my $base_url =
|
||||||
);
|
);
|
||||||
|
|
||||||
my @letters = map { {letter => $_} } ( 'A' .. 'Z');
|
my @letters = map { {letter => $_} } ( 'A' .. 'Z');
|
||||||
$template->param( letters => \@letters );
|
|
||||||
|
|
||||||
$template->param(
|
$template->param(
|
||||||
|
letters => \@letters,
|
||||||
paginationbar => pagination_bar(
|
paginationbar => pagination_bar(
|
||||||
$base_url,
|
$base_url,
|
||||||
int( $count / $resultsperpage ) + ($count % $resultsperpage ? 1 : 0),
|
int( $count / $resultsperpage ) + ($count % $resultsperpage ? 1 : 0),
|
||||||
|
@ -154,15 +159,10 @@ $template->param(
|
||||||
from => ($startfrom-1)*$resultsperpage+1,
|
from => ($startfrom-1)*$resultsperpage+1,
|
||||||
to => $to,
|
to => $to,
|
||||||
multipage => ($count != $to+1 || $startfrom!=1),
|
multipage => ($count != $to+1 || $startfrom!=1),
|
||||||
);
|
advsearch => ($$patron{categorycode} || $$patron{branchcode}),
|
||||||
$template->param(
|
branchloop=>\@branchloop,
|
||||||
branchloop=>$branches,
|
|
||||||
categories=>\@categories,
|
categories=>\@categories,
|
||||||
);
|
searching => "1",
|
||||||
|
|
||||||
|
|
||||||
$template->param(
|
|
||||||
searching => "1",
|
|
||||||
actionname =>basename($0),
|
actionname =>basename($0),
|
||||||
%$patron,
|
%$patron,
|
||||||
numresults => $count,
|
numresults => $count,
|
||||||
|
|
|
@ -51,9 +51,21 @@ if($quicksearch){
|
||||||
debug => 1,
|
debug => 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $branches = GetBranches;
|
||||||
|
my @branchloop;
|
||||||
|
foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
|
||||||
|
my $selected = 1 if $branches->{$_}->{branchcode} eq $branch;
|
||||||
|
my %row = ( value => $_,
|
||||||
|
selected => $selected,
|
||||||
|
branchname => $branches->{$_}->{branchname},
|
||||||
|
);
|
||||||
|
push @branchloop, \%row;
|
||||||
|
}
|
||||||
|
|
||||||
my @categories=C4::Category->all;
|
my @categories=C4::Category->all;
|
||||||
$template->param(
|
$template->param(
|
||||||
branchloop=>(defined $branch?GetBranchesLoop($branch):GetBranchesLoop()),
|
branchloop=>\@branchloop,
|
||||||
categories=>\@categories,
|
categories=>\@categories,
|
||||||
);
|
);
|
||||||
$template->param(
|
$template->param(
|
||||||
|
|
Loading…
Reference in a new issue