(bug #3355) add pagination in bib search for subscriptions
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Wed, 24 Jun 2009 09:00:48 +0000 (11:00 +0200)
committerGalen Charlton <galen.charlton@liblime.com>
Mon, 13 Jul 2009 02:45:14 +0000 (22:45 -0400)
This add the support of pagination, delete a javascript call, and use now a get method(why post was used?).

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
koha-tmpl/intranet-tmpl/prog/en/modules/serials/result.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tmpl
serials/subscription-bib-search.pl

index abef705..acd48cf 100644 (file)
@@ -21,7 +21,7 @@ function GetIt(bibno,title)
    <div id="bd">
        
 
-<h1>Search results</h1>
+<h1>Search results from <!-- TMPL_VAR NAME="from" --> to <!-- TMPL_VAR NAME="to" --> of <!-- TMPL_VAR NAME="total" --></h1>
 <!-- TMPL_IF NAME="total"-->
 <table>
     <tr>
@@ -54,15 +54,15 @@ function GetIt(bibno,title)
 <!-- TMPL_ELSE -->
 <h2>No results found for <b><!-- TMPL_VAR NAME="query" --></b></h2>
 <!-- /TMPL_IF-->
-<a onclick="Plugin(f)" href="">Search for another Biblio</a>
+<!-- TMPL_IF NAME="displayprev" -->
+<a href="/cgi-bin/koha/serials/subscription-bib-search.pl?op=do_search&type=intranet&startfrom=<!-- TMPL_VAR ESCAPE="URL" NAME="startfromprev" -->&q=<!-- TMPL_VAR ESCAPE="URL" NAME="query" -->">&lt;&lt;</a>
+<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="displaynext" -->
+<a href="/cgi-bin/koha/serials/subscription-bib-search.pl?op=do_search&type=intranet&startfrom=<!-- TMPL_VAR ESCAPE="URL" NAME="startfromnext" -->&q=<!-- TMPL_VAR ESCAPE="URL" NAME="query" -->">&gt;&gt;</a>
+<!-- /TMPL_IF -->
+<br/>
+<a href="subscription-bib-search.pl">Search for another Biblio</a>
 <a class="button" href="#" onclick="window.close()">  Close</a></p>
 </div>
 
-<script type="text/javascript">
-function Plugin(f)
-{
-    window.open('subscription-bib-search.pl','FindABibIndex','width=800,height=400,toolbar=no,scrollbars=yes');
-}
-</script>
-
 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
index 2a17a72..a8cf0cf 100644 (file)
@@ -12,7 +12,7 @@
 <!-- TMPL_IF name="no_query" -->
     <div class="warning">You must enter a term to search on </div>
 <!-- /TMPL_IF -->
-<form name="f" action="/cgi-bin/koha/serials/subscription-bib-search.pl" method="post">
+<form name="f" action="/cgi-bin/koha/serials/subscription-bib-search.pl" method="get">
     <input type="hidden" name="op" value="do_search" />
     <input type="hidden" name="type" value="intranet" />
     <label for="q">Keyword</label>
index 01c341d..e486f0c 100755 (executable)
@@ -79,9 +79,9 @@ if ($op eq "do_search" && $query) {
     }
     
     $resultsperpage= $input->param('resultsperpage');
-    $resultsperpage = 19 if(!defined $resultsperpage);
+    $resultsperpage = 20 if(!defined $resultsperpage);
 
-    my ($error, $marcrecords, $total_hits) = SimpleSearch($query, $startfrom, $resultsperpage);
+    my ($error, $marcrecords, $total_hits) = SimpleSearch($query, $startfrom*$resultsperpage, $resultsperpage);
     my $total = scalar @$marcrecords;
 
     if (defined $error) {
@@ -122,14 +122,14 @@ if ($op eq "do_search" && $query) {
     # multi page display gestion
     my $displaynext=0;
     my $displayprev=$startfrom;
-    if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
+    if(($total_hits - (($startfrom+1)*($resultsperpage))) > 0 ){
         $displaynext = 1;
     }
 
 
     my @numbers = ();
 
-    if ($total>$resultsperpage)
+    if ($total_hits>$resultsperpage)
     {
         for (my $i=1; $i<$total/$resultsperpage+1; $i++)
         {
@@ -144,11 +144,12 @@ if ($op eq "do_search" && $query) {
             }
         }
     }
-
-    my $from = $startfrom*$resultsperpage+1;
+    
+    my $from = 0;
+    $from = $startfrom*$resultsperpage+1 if($total_hits > 0);
     my $to;
 
-    if($total < (($startfrom+1)*$resultsperpage))
+    if($total_hits < (($startfrom+1)*$resultsperpage))
     {
         $to = $total;
     } else {
@@ -163,7 +164,7 @@ if ($op eq "do_search" && $query) {
                             resultsperpage => $resultsperpage,
                             startfromnext => $startfrom+1,
                             startfromprev => $startfrom-1,
-                            total=>$total,
+                            total=>$total_hits,
                             from=>$from,
                             to=>$to,
                             numbers=>\@numbers,