bug fixed: on admin/stopwords, the calculation of the number of pages to

display in the pagination bar was wrong on extreme case (when number of
items equals the pagesize). Calculation replaced by a generic function
getnbpages in C4::Koha. This function could be useful elsewhere than in
stpwords management screen and avoid calculation bugs as I did.
This commit is contained in:
plg 2006-04-07 08:24:36 +00:00
parent 682cf34ecb
commit 3096d75677
2 changed files with 15 additions and 1 deletions

View File

@ -62,6 +62,7 @@ Koha.pm provides many functions for Koha scripts.
&getauthtypes &getauthtype
&getallthemes &getalllanguages
&getallbranches &getletters
getnbpages
$DEBUG);
use vars qw();
@ -732,6 +733,18 @@ sub getallthemes {
return @themes;
}
=item getnbpages
Returns the number of pages to display in a pagination bar, given the number
of items and the number of items per page.
=cut
sub getnbpages {
my ($nb_items, $nb_items_per_page) = @_;
return int(($nb_items - 1) / $nb_items_per_page) + 1;
}
1;
__END__

View File

@ -29,6 +29,7 @@ use strict;
use CGI;
use List::Util qw/min/;
use C4::Koha;
use C4::Context;
use C4::Output;
use C4::Search;
@ -161,7 +162,7 @@ $template->param(
loop => \@loop,
pagination_bar => pagination_bar(
$script_name,
int(scalar(@results) / $pagesize) + 1,
getnbpages(scalar @results, $pagesize),
$page,
'page'
)