Updating french translations
[koha.git] / cataloguing / value_builder / unimarc_field_4XX.pl
index 44bc27c..a55ceef 100755 (executable)
@@ -19,7 +19,7 @@
 
 
 use strict;
-require Exporter;
+
 use CGI;
 use C4::Output;
 use C4::Context;
@@ -52,7 +52,7 @@ sub plugin_javascript {
 
         function Clic$function_name(i) {
             defaultvalue=document.getElementById(\"$field_number\").value;
-            window.open(\"/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_4XX.pl&index=$field_number&result=\"+defaultvalue,\"unimarc field 4\"+i+\"\",'width=900,height=700,toolbar=false,scrollbars=yes');
+            window.open(\"/cgi-bin/koha/cataloguing/plugin_launcher.pl?plugin_name=unimarc_field_4XX.pl&index=\" + i + \"&result=\"+defaultvalue,\"unimarc field 4\"+i+\"\",'width=900,height=700,toolbar=false,scrollbars=yes');
 
         }
     </script>
@@ -328,11 +328,10 @@ sub plugin {
     elsif ( $op eq "do_search" ) {
         my $search         = $query->param('search');
         my $startfrom      = $query->param('startfrom');
-        my $resultsperpage = $query->param('resultsperpage');
+        my $resultsperpage = $query->param('resultsperpage') || 20;
         my $orderby;
-        my ( $errors, $results, $total_hits ) = SimpleSearch($search);
+        my ( $errors, $results, $total_hits ) = SimpleSearch($search, $startfrom * $resultsperpage, $resultsperpage );
         my $total = scalar(@$results);
-        $resultsperpage = 20 unless $resultsperpage;
 
         #        warn " biblio count : ".$total;
 
@@ -350,17 +349,15 @@ sub plugin {
         # 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 @arrayresults;
         my @field_data = ($search);
          for (
-             my $i = $startfrom * $resultsperpage ;
-             $i < (( $startfrom * $resultsperpage + $resultsperpage  < scalar(@$results))
-                 ? $startfrom * $resultsperpage + $resultsperpage
-                 : scalar(@$results)
-             ) ;
+             my $i = 0 ;
+             $i < $resultsperpage ;
              $i++
            )
          {
@@ -415,11 +412,10 @@ sub plugin {
         my $from = $startfrom * $resultsperpage + 1;
         my $to;
 
-        if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
-            $to = $total;
-        }
-        else {
-            $to = ( ( $startfrom + 1 ) * $resultsperpage );
+        if ( $total_hits < $from + $resultsperpage ) {
+            $to = $total_hits;
+        }else{
+            $to = $from + $resultsperpage ;
         }
         my $defaultview =
           'BiblioDefaultView' . C4::Context->preference('BiblioDefaultView');
@@ -446,7 +442,7 @@ sub plugin {
             startfromnext  => $startfrom + 1,
             startfromprev  => $startfrom - 1,
             searchdata     => \@field_data,
-            total          => $total,
+            total          => $total_hits,
             from           => $from,
             to             => $to,
             numbers        => \@numbers,