authorities result lists where badly paged.
authorHenri-Damien LAURENT <henridamien@koha-fr.org>
Fri, 14 Dec 2007 00:21:57 +0000 (18:21 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Fri, 14 Dec 2007 00:25:52 +0000 (18:25 -0600)
finalresult contained the whole list and not only the useful results.
resultlist contained only 19 elements. adding one
parameters passed through pages contained also empty parameters deleting them.
Conflicts:

C4/AuthoritiesMarc.pm

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/AuthoritiesMarc.pm
authorities/authorities-home.pl

index e336026..e440f1d 100644 (file)
@@ -146,30 +146,31 @@ sub SearchAuthorities {
                 $result{$title.$authid}=$authid;
             }
             # sort the hash and return the same structure as GetRecords (Zebra querying)
-            my @finalresult = ();
+            my @listresult = ();
             my $numbers=0;
             if ($sortby eq 'HeadingDsc') { # sort by mainmainentry desc
                 foreach my $key (sort {$b cmp $a} (keys %result)) {
-                    push @finalresult, $result{$key};
+                    push @listresult, $result{$key};
 #                     warn "push..."$#finalresult;
                     $numbers++;
                 }
             } else { # sort by mainmainentry ASC
                 foreach my $key (sort (keys %result)) {
-                    push @finalresult, $result{$key};
+                    push @listresult, $result{$key};
 #                     warn "push..."$#finalresult;
                     $numbers++;
                 }
             }
             # limit the $results_per_page to result size if it's more
-            $length = $numbers-1 if $numbers < $length;
+            $length = $numbers-1-$offset if $numbers < ($offset+$length);
             # for the requested page, replace authid by the complete record
             # speed improvement : avoid reading too much things
-            for (my $counter=$offset;$counter<=$offset+$length;$counter++) {
+            my @finalresult;      
+            for (my $counter=$offset;$counter<=$offset+$length-1;$counter++) {
 #                 $finalresult[$counter] = GetAuthority($finalresult[$counter])->as_usmarc;
                 my $separator=C4::Context->preference('authoritysep');
-                my $authrecord = MARC::File::USMARC::decode(GetAuthority($finalresult[$counter])->as_usmarc);
-                my $authid=$authrecord->field('001')->data()
+                my $authrecord =GetAuthority($listresult[$counter]);
+                my $authid=$listresult[$counter]
                 my $summary=BuildSummary($authrecord,$authid,$authtypecode);
                 my $query_auth_tag = "SELECT auth_tag_to_report FROM auth_types WHERE authtypecode=?";
                 my $sth = $dbh->prepare($query_auth_tag);
@@ -180,7 +181,7 @@ sub SearchAuthorities {
                 $newline{summary} = $summary;
                 $newline{authid} = $authid;
                 $newline{even} = $counter % 2;
-                $finalresult[$counter]= \%newline;
+                push @finalresult, \%newline;
             }
             return (\@finalresult, $numbers);
         } else {
index cccab21..9ffd6e2 100755 (executable)
@@ -61,13 +61,13 @@ if ( $op eq "do_search" ) {
     my @value     = $query->param('value');
 
     my $startfrom      = $query->param('startfrom')      || 1;
-    my $resultsperpage = $query->param('resultsperpage') || 19;
+    my $resultsperpage = $query->param('resultsperpage') || 20;
 
     my ( $results, $total ) =
       SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value,
         ( $startfrom - 1 ) * $resultsperpage,
         $resultsperpage, $authtypecode, $orderby );
-
+#     use Data::Dumper; warn Data::Dumper::Dumper(@$results);
     ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         {
             template_name   => "authorities/searchresultlist.tmpl",
@@ -86,11 +86,13 @@ if ( $op eq "do_search" ) {
     # next/previous would not work anymore
     my @marclist_ini = $query->param('marclist');
     for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
-        push @field_data, { term => "marclist",  val => $marclist_ini[$i] };
-        push @field_data, { term => "and_or",    val => $and_or[$i] };
-        push @field_data, { term => "excluding", val => $excluding[$i] };
-        push @field_data, { term => "operator",  val => $operator[$i] };
-        push @field_data, { term => "value",     val => $value[$i] };
+        if ($value[$i]){   
+          push @field_data, { term => "marclist",  val => $marclist_ini[$i] };
+          push @field_data, { term => "and_or",    val => $and_or[$i] };
+          push @field_data, { term => "excluding", val => $excluding[$i] };
+          push @field_data, { term => "operator",  val => $operator[$i] };
+          push @field_data, { term => "value",     val => $value[$i] };
+        }    
     }
 
     # construction of the url of each page