Bug 3663 screen changes to OPAC advanced search
[koha.git] / labels / label-item-search.pl
index 31b1d22..3bba92d 100755 (executable)
@@ -1,5 +1,4 @@
 #!/usr/bin/perl
-# WARNING: 4-character tab stops here
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -19,6 +18,8 @@
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+use warnings;
+
 use CGI;
 use C4::Auth;
 use HTML::Template::Pro;
@@ -51,10 +52,10 @@ BEGIN {
 # Using more than one scrolling list in a CGI assigns the same default value to all the
 # scrolling lists on the page !?!? That's why this function was written.
 
-my $query           = new CGI;
+my $query = new CGI;
 
 my $type      = $query->param('type');
-my $op        = $query->param('op');
+my $op        = $query->param('op') || '';
 my $batch_id  = $query->param('batch_id');
 my $ccl_query = $query->param('ccl_query');
 
@@ -62,7 +63,10 @@ my $dbh = C4::Context->dbh;
 
 my $startfrom = $query->param('startfrom') || 1;
 my ( $template, $loggedinuser, $cookie );
-my ($total_hits, $orderby, $results, $total, $error, $marcresults, $idx,       $datefrom, $dateto, $ccl_textbox);
+my (
+    $total_hits,  $orderby, $results,  $total,  $error,
+    $marcresults, $idx,     $datefrom, $dateto, $ccl_textbox
+);
 
 my $resultsperpage = C4::Context->preference('numSearchResults') || '20';
 
@@ -203,26 +207,28 @@ if ($show_results) {
                  : $startfrom + $resultsperpage - 1;
 
                # multi page display
-               my $displaynext = 0;
-               my $displayprev = $startfrom;
-
-               $displaynext = 1 if (scalar @results == $resultsperpage);
+               $displaynext = 0;
+               $displayprev = $startfrom > 1 ? $startfrom : 0;
 
-               $template->param(
+               $displaynext = 1 if $to < $total_hits;
 
-                       total          => $total_hits,
-                       from           => $from,
-                       to             => $to,
-                       startfromnext  => $startfromnext,
-                       startfromprev  => $startfromprev,
-                       startfrom      => $startfrom,
-                       displaynext    => $displaynext,
-                       displayprev    => $displayprev,
-                       resultsperpage => $resultsperpage,
-                       numbers        => \@numbers,
+       } else {
+        $displayprev = 0;
+        $displaynext = 0;
+    }
 
-               );
-       }
+       $template->param(
+               total          => $total_hits,
+               from           => $from,
+               to             => $to,
+               startfromnext  => $startfromnext,
+               startfromprev  => $startfromprev,
+               startfrom      => $startfrom,
+               displaynext    => $displaynext,
+               displayprev    => $displayprev,
+               resultsperpage => $resultsperpage,
+               numbers        => \@numbers,
+       );
 
        $template->param(
                result    => \@results,
@@ -250,32 +256,21 @@ else {
     );
     my $itemtypes = GetItemTypes;
     my @itemtypeloop;
-    foreach my $thisitemtype (keys %$itemtypes) {
-            my %row =(value => $thisitemtype,
-                           description => $itemtypes->{$thisitemtype}->{'description'},
-                            );
-            push @itemtypeloop, \%row;
+    foreach my $thisitemtype ( keys %$itemtypes ) {
+        my %row = (
+            value       => $thisitemtype,
+            description => $itemtypes->{$thisitemtype}->{'description'},
+        );
+        push @itemtypeloop, \%row;
     }
     $template->param(
-    itemtypeloop =>\@itemtypeloop,
-    batch_id     => $batch_id,
-    type         => $type,
+        itemtypeloop => \@itemtypeloop,
+        batch_id     => $batch_id,
+        type         => $type,
     );
 
 }
+
 # Print the page
-$template->param(
-    DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
-);
+$template->param( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), );
 output_html_with_http_headers $query, $cookie, $template->output;
-
-# Local Variables:
-# tab-width: 4
-# End:
-
-
-
-
-
-
-