@@ -, +, @@ --- C4/HoldsQueue.pm | 30 ++++++++++- circ/view_holdsqueue.pl | 51 +++++++++++++------ .../prog/en/modules/circ/view_holdsqueue.tt | 27 ++++++++++ t/db_dependent/HoldsQueue.t | 10 ++-- 4 files changed, 97 insertions(+), 21 deletions(-) --- a/C4/HoldsQueue.pm +++ a/C4/HoldsQueue.pm @@ -132,6 +132,11 @@ sub GetHoldsQueueItems { my $params = shift; my $dbh = C4::Context->dbh; + my $limit = $params->{limit} || 20; + my $page = $params->{page} || 1; + + my $offset = 0 + ( $limit * ( $page - 1 ) ); + my @bind_params = (); my $query = q/SELECT borrowers.surname, borrowers.othernames, @@ -169,6 +174,7 @@ sub GetHoldsQueueItems { push @bind_params, $params->{locationslimit}; } $query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate"; + $query .= " LIMIT $limit OFFSET $offset"; my $sth = $dbh->prepare($query); $sth->execute(@bind_params); my $items = []; @@ -190,7 +196,29 @@ sub GetHoldsQueueItems { push @$items, $row; } - return $items; + + @bind_params = (); + my $total_query = "SELECT COUNT(*) FROM tmp_holdsqueue JOIN items USING (itemnumber) WHERE 1=1 "; + if ($params->{branchlimit}) { + $total_query .=" AND tmp_holdsqueue.holdingbranch = ?"; + push @bind_params, $params->{branchlimit}; + } + if( $params->{itemtypeslimit} ) { + $total_query .=" AND items.itype = ? "; + push @bind_params, $params->{itemtypeslimit}; + } + if( $params->{ccodeslimit} ) { + $total_query .=" AND items.ccode = ? "; + push @bind_params, $params->{ccodeslimit}; + } + if( $params->{locationslimit} ) { + $total_query .=" AND items.location = ? "; + push @bind_params, $params->{locationslimit}; + } + + my ($total_results) = $dbh->selectrow_array( $total_query, undef, @bind_params ); + + return ( $items, $total_results ); } =head2 CreateQueue --- a/circ/view_holdsqueue.pl +++ a/circ/view_holdsqueue.pl @@ -25,7 +25,7 @@ This script displays items in the tmp_holdsqueue table use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth qw( get_template_and_user ); -use C4::Output qw( output_html_with_http_headers ); +use C4::Output qw( output_html_with_http_headers pagination_bar ); use C4::HoldsQueue qw( GetHoldsQueueItems ); use Koha::BiblioFrameworks; use Koha::ItemTypes; @@ -44,25 +44,46 @@ my $params = $query->Vars; my $run_report = $params->{'run_report'}; my $branchlimit = $params->{'branchlimit'}; my $itemtypeslimit = $params->{'itemtypeslimit'}; -my $ccodeslimit = $params->{'ccodeslimit'}; +my $ccodeslimit = $params->{'ccodeslimit'}; my $locationslimit = $params->{'locationslimit'}; +my $limit = $params->{'limit'} || 20; +my $page = $params->{'page'} || 1; if ( $run_report ) { - my $items = GetHoldsQueueItems({ - branchlimit => $branchlimit, - itemtypeslimit => $itemtypeslimit, - ccodeslimit => $ccodeslimit, - locationslimit => $locationslimit - }); + my ( $items, $total ) = GetHoldsQueueItems( + { + branchlimit => $branchlimit, + itemtypeslimit => $itemtypeslimit, + ccodeslimit => $ccodeslimit, + locationslimit => $locationslimit, + limit => $limit, + page => $page, + } + ); + my $pages = int( $total / $limit ) + ( ( $total % $limit ) > 0 ? 1 : 0 ); $template->param( - branchlimit => $branchlimit, - itemtypeslimit => $itemtypeslimit, - ccodeslimit => $ccodeslimit, - locationslimit => $locationslimit, - total => scalar @$items, - itemsloop => $items, - run_report => $run_report, + branchlimit => $branchlimit, + itemtypeslimit => $itemtypeslimit, + ccodeslimit => $ccodeslimit, + locationslimit => $locationslimit, + total => scalar @$items, + itemsloop => $items, + run_report => $run_report, + page => $page, + limit => $limit, + pagination_bar => pagination_bar( + 'view_holdsqueue.pl', + $pages, $page, 'page', + { + branchlimit => $branchlimit, + itemtypeslimit => $itemtypeslimit, + ccodeslimit => $ccodeslimit, + locationslimit => $locationslimit, + limit => $limit, + run_report => 1, + } + ), ); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt @@ -69,6 +69,29 @@ [% IF ( ccodeslimit ) %] and collection code:([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode' authorised_value = ccodeslimit ) | html %])[% END %] [% IF ( locationslimit ) %] and shelving location:([% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location' authorised_value = locationslimit ) | html %])[% END %] + +
+