[Koha-patches] [biblibre-integration 17/19] [3.0.x](bug #3555) This sets the default branch to the logged user branch when IndependantBranches is active
Henri-Damien LAURENT
henridamien.laurent at biblibre.com
Fri Aug 28 23:47:52 CEST 2009
From: Jean-André Santoni <jeanandre.santoni at biblibre.com>
In the advanced search form, when IndependantBranches is activated, the default
branch should be set to the logged user branch.
---
catalogue/search.pl | 7 ++++++-
.../prog/en/modules/catalogue/advsearch.tmpl | 4 ++++
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/catalogue/search.pl b/catalogue/search.pl
index f30d068..22fbcaa 100755
--- a/catalogue/search.pl
+++ b/catalogue/search.pl
@@ -206,8 +206,13 @@ if (C4::Context->preference("marcflavour") eq "UNIMARC" ) {
my $branches = GetBranches();
my @branch_loop;
+# we need to know the borrower branch code to set a default branch
+my $borrowerbranchcode = C4::Context->userenv->{'branch'};
+
for my $branch_hash (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
- push @branch_loop, {value => "$branch_hash" , branchname => $branches->{$branch_hash}->{'branchname'}, };
+ # if independantbranches is activated, set the default branch to the borrower branch
+ my $selected = (C4::Context->preference("independantbranches") and ($borrowerbranchcode eq $branch_hash)) ? 1 : undef;
+ push @branch_loop, {value => "$branch_hash" , branchname => $branches->{$branch_hash}->{'branchname'}, selected => $selected};
}
my $categories = GetBranchCategories(undef,'searchdomain');
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl
index c51ef15..d5fb462 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl
@@ -257,7 +257,11 @@
<label for="branchloop">Individual Libraries:</label><select name="limit" id="branchloop" onchange='if(this.value != ""){document.getElementById("categoryloop").disabled=true;} else {document.getElementById("categoryloop").disabled=false;}'>
<option value="">All Libraries</option>
<!-- TMPL_LOOP NAME="branchloop" -->
+ <!-- TMPL_IF NAME="selected" -->
+ <option value="branch:<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
+ <!-- TMPL_ELSE -->
<option value="branch:<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
+ <!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select>
<!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
--
1.6.0.4
More information about the Koha-patches
mailing list