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:
parent
682cf34ecb
commit
3096d75677
13
C4/Koha.pm
13
C4/Koha.pm
|
|
@ -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__
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue