Convert opac-reserve to use GetBranchesLoop.
authorJoe Atzberger <joe.atzberger@liblime.com>
Tue, 24 Mar 2009 21:36:11 +0000 (16:36 -0500)
committerGalen Charlton <galen.charlton@liblime.com>
Sat, 28 Mar 2009 00:06:54 +0000 (19:06 -0500)
Removed irrelevant and unused variables dealing with branches.
Also pulled default branch from userenv when not specified as a param.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl
opac/opac-reserve.pl

index f02ef54..214a7ba 100644 (file)
                           <!-- TMPL_UNLESS NAME="holdable" -->disabled="disabled"<!-- /TMPL_UNLESS --> >
                           <!-- TMPL_LOOP NAME="branchChoicesLoop" -->
                             <!-- TMPL_IF name="selected" -->
-                              <option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branch" --></option>
+                              <option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
                             <!-- TMPL_ELSE -->
-                              <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branch" --></option>
+                              <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
                             <!-- /TMPL_IF -->
                           <!-- /TMPL_LOOP -->
                         </select>
index 9394dfa..4395f38 100755 (executable)
@@ -88,39 +88,14 @@ if (($#biblionumbers < 0) && (! $query->param('place_reserve'))) {
 }
 
 # pass the pickup branch along....
-my $branch = $query->param('branch');
+my $branch = $query->param('branch') || C4::Context->userenv->{branch} || '' ;
+($branches->{$branch}) or $branch = "";     # Confirm branch is real
 $template->param( branch => $branch );
 
-# make sure it's a real branch
-if ( !$branch || !$branches->{$branch} ) {
-    $branch = '';
-}
-$template->param( branchname => $branches->{$branch}->{'branchname'} );
-
 # make branch selection options...
-my @branches;
-my @select_branch;
-my %select_branches;
-
-my @CGIbranchlooparray;
-
-foreach my $branch ( keys %$branches ) {
-    if ($branch) {
-        my %line;
-        $line{branch} = $branches->{$branch}->{'branchname'};
-        $line{value}  = $branch;
-        if ($line{value} eq C4::Context->userenv->{'branch'}) {
-            $line{selected} = 1;
-        }
-        push @CGIbranchlooparray, \%line;
-    }
-}
-@CGIbranchlooparray = sort { $a->{branch} cmp $b->{branch} } @CGIbranchlooparray;
-  
-my $CGIbranchloop = \@CGIbranchlooparray;
+my $CGIbranchloop = GetBranchesLoop($branch);
 $template->param( CGIbranch => $CGIbranchloop );
 
-
 #Debug
 #output_html_with_http_headers($query,$cookie,"<html><head></head><body> @biblionumbers </body></html>\n");
 #exit;