diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index 052c095121..fa2f564cb4 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -126,13 +126,15 @@ Returns hold queue for a holding branch. If branch is omitted, then whole queue sub GetHoldsQueueItems { my $params = shift; - my $dbh = C4::Context->dbh; + my $dbh = C4::Context->dbh; my $search_params; - $search_params->{'me.holdingbranch'} = $params->{branchlimit} if $params->{branchlimit}; - $search_params->{'itype'} = $params->{itemtypeslimit} if $params->{itemtypeslimit}; - $search_params->{'ccode'} = $params->{ccodeslimit} if $params->{ccodeslimit}; - $search_params->{'location'} = $params->{locationslimit} if $params->{locationslimit}; + $search_params->{'me.holdingbranch'} = $params->{branchlimit} if $params->{branchlimit}; + $search_params->{'itype'} = $params->{itemtypeslimit} if $params->{itemtypeslimit}; + $search_params->{'ccode'} = $params->{ccodeslimit} if $params->{ccodeslimit}; + $search_params->{'location'} = $params->{locationslimit} if $params->{locationslimit}; + my $rows = $params->{limit} || 20; + my $page = $params->{page} || 1; my $results = Koha::Hold::HoldsQueueItems->search( $search_params, @@ -143,20 +145,35 @@ sub GetHoldsQueueItems { prefetch => [ 'biblio', 'biblioitem', - { - 'item' => { - 'item_group_item' => 'item_group' - } - } + { 'item' => { 'item_group_item' => 'item_group' } } ], order_by => [ 'ccode', 'location', 'item.cn_sort', 'author', 'biblio.title', 'pickbranch', 'reservedate' ], + rows => $rows, + page => $page } ); + my $total_results = Koha::Hold::HoldsQueueItems->search( + $search_params, + { + join => [ + 'borrower', + ], + prefetch => [ + 'biblio', + 'biblioitem', + { 'item' => { 'item_group_item' => 'item_group' } } + ], + order_by => [ + 'ccode', 'location', 'item.cn_sort', 'author', + 'biblio.title', 'pickbranch', 'reservedate' + ], + } + )->count; - return $results; + return ( $results, $total_results ); } =head2 CreateQueue diff --git a/circ/view_holdsqueue.pl b/circ/view_holdsqueue.pl index 241697ab03..5de503c157 100755 --- a/circ/view_holdsqueue.pl +++ b/circ/view_holdsqueue.pl @@ -25,7 +25,7 @@ =head1 view_holdsqueue 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,27 +44,46 @@ =head1 view_holdsqueue 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( + my ( $items, $total ) = GetHoldsQueueItems( { branchlimit => $branchlimit, itemtypeslimit => $itemtypeslimit, ccodeslimit => $ccodeslimit, - locationslimit => $locationslimit + 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 => $items->count, + total => $total, 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, + } + ), ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt index 49f2342125..b64299e55b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt @@ -68,6 +68,29 @@ [% IF ( ccodeslimit ) %] and collection: [% 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 %] + +
+