Bug 5995 Follow up: variable scope in koha/sco/sco-main.pl
[koha_fer] / opac / opac-reserve.pl
index 3d547b7..d50480a 100755 (executable)
@@ -88,7 +88,7 @@ if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
 }
 
 # pass the pickup branch along....
-my $branch = $query->param('branch') || C4::Context->userenv->{branch} || '' ;
+my $branch = $query->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
 ($branches->{$branch}) or $branch = "";     # Confirm branch is real
 $template->param( branch => $branch );
 
@@ -96,6 +96,11 @@ $template->param( branch => $branch );
 my $CGIbranchloop = GetBranchesLoop($branch);
 $template->param( CGIbranch => $CGIbranchloop );
 
+# Is the person allowed to choose their branch
+my $OPACChooseBranch = (C4::Context->preference("OPACAllowUserToChooseBranch")) ? 1 : 0;
+
+$template->param( choose_branch => $OPACChooseBranch);
+
 #
 #
 # Build hashes of the requested biblio(item)s and items.
@@ -175,7 +180,7 @@ if ( $query->param('place_reserve') ) {
         my $branch    = shift(@selectedItems); # i.e., branch code, not name
 
         my $singleBranchMode = $template->param('singleBranchMode');
-        if ($singleBranchMode) {
+        if ($singleBranchMode || ! $OPACChooseBranch) { # single branch mode or disabled user choosing
             $branch = $borr->{'branchcode'};
         }
 
@@ -290,7 +295,7 @@ my $biblioLoop = [];
 my $numBibsAvailable = 0;
 my $itemdata_enumchron = 0;
 my $anyholdable;
-my $itemLevelTypes = C4::Context->preference('item_level_itypes');
+my $itemLevelTypes = C4::Context->preference('item-level_itypes');
 $template->param('item_level_itypes' => $itemLevelTypes);
 
 foreach my $biblioNum (@biblionumbers) {