From 7fc80259784e8799103eaceee7f24c492a9dc3bc Mon Sep 17 00:00:00 2001 From: Will Stokes Date: Mon, 15 Feb 2010 09:31:08 +1300 Subject: [PATCH] Bug #2162: Step 2, add pagination. Splits results into blocks of 250 results and adds Previous and Next buttons. Achieved using forms, hidden search variables and submit buttons. Signed-off-by: Chris Cormack Signed-off-by: Galen Charlton --- circ/pendingreserves.pl | 26 +++++++- .../prog/en/modules/circ/pendingreserves.tmpl | 64 +++++++++++++++++-- 2 files changed, 83 insertions(+), 7 deletions(-) diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index ea4d61b47d..512453fee7 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -37,6 +37,7 @@ my $order = $input->param('order'); my $startdate=$input->param('from'); my $enddate=$input->param('to'); my $run_report=$input->param('run_report'); +my $report_page=$input->param('report_page'); my $theme = $input->param('theme'); # only used if allowthemeoverride is set @@ -86,9 +87,10 @@ if (!defined($enddate) or $enddate eq "") { my @reservedata; +my ($prev_results, $next_results, $next_or_previous) = (0,0,0); if ( $run_report ) { my $dbh = C4::Context->dbh; - my ($sqlorderby, $sqldatewhere) = ("",""); + my ($sqlorderby, $sqldatewhere, $sqllimitoffset) = ("","",""); $debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); my @query_params = (); if ($startdate) { @@ -100,6 +102,12 @@ if ( $run_report ) { push @query_params, format_date_in_iso($enddate); } + $sqllimitoffset = " LIMIT 251"; + if ($report_page) { + $sqllimitoffset .= " OFFSET=?"; + push @query_params, ($report_page * 250); + } + if ($order eq "biblio") { $sqlorderby = " ORDER BY biblio.title "; } elsif ($order eq "itype") { @@ -206,6 +214,18 @@ if ( $run_report ) { $sth->finish; + # Next Page? + if ($report_page > 0) { + $prev_results = $report_page - 1; + } + if ( scalar(@reservedata) > 250 ) { + $next_results = $report_page + 1; + pop(@reservedata); # .. we retrieved 251 results + } + if ($prev_results || $next_results) { + $next_or_previous = 1; + } + # *** I doubt any of this is needed now with the above fixes *** -d.u. #$strsth=~ s/AND reserves.itemnumber is NULL/AND reserves.itemnumber is NOT NULL/; @@ -260,6 +280,10 @@ $template->param( from => $startdate, to => $enddate, run_report => $run_report, + report_page => $report_page, + prev_results => $prev_results, + next_results => $next_results, + next_or_previous => $next_or_previous, reserveloop => \@reservedata, "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl index 6e1145c59f..28efee449e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tmpl @@ -49,7 +49,8 @@ $.tablesorter.addParser({
- + + @@ -81,10 +82,35 @@ $.tablesorter.addParser({ - - - - + + + + + + + + + + + @@ -125,7 +151,33 @@ $.tablesorter.addParser({

Waiting

Fullfilled

- + + + + + + + + +
Pull This Many Items Earliest Hold Date &to=">Sort
+ +
+ "> + "> + "> + +
+ +
+ +
+ "> + "> + "> + +
+ +

+ +
+ "> + "> + "> + +
+ +
+ +
+ "> + "> + "> + +
+ +
No items found.