Bug 7562 Add strict & warnings to KohaDates Plugin
[koha.git] / opac / opac-basket.pl
index 7b52178..5e92d15 100755 (executable)
@@ -17,7 +17,7 @@
 
 
 use strict;
-require Exporter;
+use warnings;
 use CGI;
 use C4::Koha;
 use C4::Biblio;
@@ -32,7 +32,7 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
         template_name   => "opac-basket.tmpl",
         query           => $query,
         type            => "opac",
-        authnotrequired => 1,
+        authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
         flagsrequired   => { borrow => 1 },
     }
 );
@@ -49,6 +49,12 @@ my @results;
 
 my $num = 1;
 my $marcflavour = C4::Context->preference('marcflavour');
+if (C4::Context->preference('TagsEnabled')) {
+       $template->param(TagsEnabled => 1);
+       foreach (qw(TagsShowOnList TagsInputOnList)) {
+               C4::Context->preference($_) and $template->param($_ => 1);
+       }
+}
 
 
 foreach my $biblionumber ( @bibs ) {
@@ -56,25 +62,27 @@ foreach my $biblionumber ( @bibs ) {
 
     my $dat              = &GetBiblioData($biblionumber);
     my $record           = &GetMarcBiblio($biblionumber);
+    next unless $record;
     my $marcnotesarray   = GetMarcNotes( $record, $marcflavour );
     my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour );
     my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour );
     my $marcseriesarray  = GetMarcSeries  ($record,$marcflavour);
     my $marcurlsarray    = GetMarcUrls    ($record,$marcflavour);
-    my @items            = &GetItemsInfo( $biblionumber, 'opac' );
-       
-    my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'});
-    my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'} );
+    my @items            = &GetItemsLocationInfo( $biblionumber );
+    my $subtitle         = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber));
+
+    my $hasauthors = 0;
+    if($dat->{'author'} || @$marcauthorsarray) {
+      $hasauthors = 1;
+    }
+    my $collections =  GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'}, 'opac');
 
-       for my $itm (@items) {
-           $itm->{'location_description'} = $shelflocations->{$itm->{'location'} };
-       }
        # COinS format FIXME: for books Only
         my $coins_format;
         my $fmt = substr $record->leader(), 6,2;
         my $fmts;
         $fmts->{'am'} = 'book';
-        $dat->{ocoins_format} => $fmts->{$fmt};
+        $dat->{ocoins_format} = $fmts->{$fmt};
 
     if ( $num % 2 == 1 ) {
         $dat->{'even'} = 1;
@@ -88,6 +96,8 @@ foreach my $biblionumber ( @bibs ) {
     $dat->{MARCAUTHORS}    = $marcauthorsarray;
     $dat->{MARCSERIES}  = $marcseriesarray;
     $dat->{MARCURLS}    = $marcurlsarray;
+    $dat->{HASAUTHORS}  = $hasauthors;
+    $dat->{subtitle} = $subtitle;
 
     if ( C4::Context->preference("BiblioDefaultView") eq "normal" ) {
         $dat->{dest} = "opac-detail.pl";
@@ -106,6 +116,7 @@ my $resultsarray = \@results;
 # my $itemsarray=\@items;
 
 $template->param(
+    bib_list => $bib_list,
     BIBLIO_RESULTS => $resultsarray,
 );