Merge remote-tracking branch 'origin/new/bug_6634'
[koha.git] / serials / subscription-bib-search.pl
index d1b0f63..623efe2 100755 (executable)
@@ -2,6 +2,7 @@
 # WARNING: 4-character tab stops here
 
 # Copyright 2000-2002 Katipo Communications
+# Parts Copyright 2010 Biblibre
 #
 # This file is part of Koha.
 #
@@ -76,6 +77,16 @@ my $query = $input->param('q');
 # don't run the search if no search term !
 if ($op eq "do_search" && $query) {
 
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {   template_name   => "serials/result.tmpl",
+            query           => $input,
+            type            => "intranet",
+            authnotrequired => 0,
+            flagsrequired => {catalogue => 1, serials => '*'},
+            debug           => 1,
+        }
+    );
+
     # add the itemtype limit if applicable
     my $itemtypelimit = $input->param('itemtypelimit');
     if ( $itemtypelimit ) {
@@ -90,7 +101,10 @@ if ($op eq "do_search" && $query) {
     $resultsperpage = 20 if(!defined $resultsperpage);
 
     my ($error, $marcrecords, $total_hits) = SimpleSearch($query, $startfrom*$resultsperpage, $resultsperpage);
-    my $total = scalar @$marcrecords;
+    my $total = 0;
+    if (defined $marcrecords ) {
+        $total = scalar @{$marcrecords};
+    }
 
     if (defined $error) {
         $template->param(query_error => $error);
@@ -113,19 +127,11 @@ if ($op eq "do_search" && $query) {
         $resultsloop{author}          = $biblio->{'author'};
         $resultsloop{publishercode}   = $biblio->{'publishercode'};
         $resultsloop{publicationyear} = $biblio->{'publicationyear'};
+        $resultsloop{issn}            = $biblio->{'issn'};
 
         push @results, \%resultsloop;
     }
 
-    ($template, $loggedinuser, $cookie)
-        = get_template_and_user({template_name => "serials/result.tmpl",
-                query => $input,
-                type => "intranet",
-                authnotrequired => 0,
-                flagsrequired => {catalogue => 1, serials => '*'},
-                debug => 1,
-                });
-
     # multi page display gestion
     my $displaynext=0;
     my $displayprev=$startfrom;
@@ -223,15 +229,6 @@ else {
        }
     }
 
-    ($template, $loggedinuser, $cookie)
-        = get_template_and_user({template_name => "serials/subscription-bib-search.tmpl",
-                query => $input,
-                type => "intranet",
-                authnotrequired => 0,
-                flagsrequired => {catalogue => 1, serials => '*'},
-                debug => 1,
-                });
-
 
     if ($op eq "do_search") {
        $template->param("no_query" => 1);