Bug 2505 - Add commented use warnings where missing in the catalogue/ directory
[koha.git] / catalogue / search.pl
index 85981af..ba0d044 100755 (executable)
@@ -15,9 +15,9 @@
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 =head1 NAME
 
@@ -132,6 +132,7 @@ Not yet completed...
 =cut
 
 use strict;            # always use
+#use warnings; FIXME - Bug 2505
 
 ## STEP 1. Load things that are used in both search page and
 # results page and decide which template to load, operations 
@@ -140,10 +141,11 @@ use strict;            # always use
 ## load Koha modules
 use C4::Context;
 use C4::Output;
-use C4::Auth;
+use C4::Auth qw(:DEFAULT get_session);
 use C4::Search;
 use C4::Languages qw(getAllLanguages);
 use C4::Koha;
+use C4::VirtualShelves qw(GetRecentShelves);
 use POSIX qw(ceil floor);
 use C4::Branch; # GetBranches
 
@@ -206,8 +208,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');
@@ -312,6 +319,8 @@ if ( $template_type eq 'advsearch' ) {
         $template->param( expanded_options => $cgi->param('expanded_options'));
     }
 
+    $template->param(virtualshelves => C4::Context->preference("virtualshelves"));
+
     output_html_with_http_headers $cgi, $cookie, $template->output;
     exit;
 }
@@ -631,4 +640,26 @@ if ($query_desc || $limit_desc) {
 }
 
 # VI. BUILD THE TEMPLATE
+
+# Build drop-down list for 'Add To:' menu...
+
+my $row_count = 10; # FIXME:This probably should be a syspref
+my ($pubshelves, $total) = GetRecentShelves(2, $row_count, undef);
+my ($barshelves, $total) = GetRecentShelves(1, $row_count, $borrowernumber);
+
+my @pubshelves = @{$pubshelves};
+my @barshelves = @{$barshelves};
+
+if (@pubshelves) {
+        $template->param( addpubshelves     => scalar (@pubshelves));
+        $template->param( addpubshelvesloop => @pubshelves);
+}
+
+if (@barshelves) {
+        $template->param( addbarshelves     => scalar (@barshelves));
+        $template->param( addbarshelvesloop => @barshelves);
+}
+
+
+
 output_html_with_http_headers $cgi, $cookie, $template->output;