@@ -, +, @@ checkin time --- C4/Circulation.pm | 3 ++- C4/Reserves.pm | 23 +++++++++++--------- circ/pendingreserves.pl | 25 ++++++++++++---------- .../en/modules/admin/preferences/circulation.pref | 7 +++++- .../prog/en/modules/circ/pendingreserves.tt | 2 +- 5 files changed, 36 insertions(+), 24 deletions(-) --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -1876,7 +1876,8 @@ sub AddReturn { # find reserves..... # if we don't have a reserve with the status W, we launch the Checkreserves routine my ($resfound, $resrec); - ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'} ) unless ( $item->{'wthdrawn'} ); + my $lookahead= C4::Context->preference('ConfirmFutureHolds'); #number of days to look for future holds + ($resfound, $resrec, undef) = C4::Reserves::CheckReserves( $item->{'itemnumber'}, undef, $lookahead ) unless ( $item->{'wthdrawn'} ); if ($resfound) { $resrec->{'ResFound'} = $resfound; $messages->{'ResFound'} = $resrec; --- a/C4/Reserves.pm +++ a/C4/Reserves.pm @@ -775,10 +775,12 @@ sub GetReserveStatus { ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber); ($status, $reserve, $all_reserves) = &CheckReserves(undef, $barcode); + ($status, $reserve, $all_reserves) = &CheckReserves($itemnumber,undef,$lookahead); Find a book in the reserves. C<$itemnumber> is the book's item number. +C<$lookahead> is the number of days to look in advance for future reserves. As I understand it, C<&CheckReserves> looks for the given item in the reserves. If it is found, that's a match, and C<$status> is set to @@ -799,7 +801,7 @@ table in the Koha database. =cut sub CheckReserves { - my ( $item, $barcode ) = @_; + my ( $item, $barcode, $lookahead_days) = @_; my $dbh = C4::Context->dbh; my $sth; my $select; @@ -846,7 +848,7 @@ sub CheckReserves { return ( '' ) if ( $notforloan_per_item > 0 ) or $notforloan_per_itemtype; # Find this item in the reserves - my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber ); + my @reserves = _Findgroupreserve( $bibitem, $biblio, $itemnumber, $lookahead_days); # $priority and $highest are used to find the most important item # in the list returned by &_Findgroupreserve. (The lower $priority, @@ -1728,11 +1730,12 @@ sub _FixPriority { =head2 _Findgroupreserve - @results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber); + @results = &_Findgroupreserve($biblioitemnumber, $biblionumber, $itemnumber, $lookahead); Looks for an item-specific match first, then for a title-level match, returning the first match found. If neither, then we look for a 3rd kind of match based on reserve constraints. +Lookahead is the number of days to look in advance. TODO: add more explanation about reserve constraints @@ -1744,7 +1747,7 @@ C. =cut sub _Findgroupreserve { - my ( $bibitem, $biblio, $itemnumber ) = @_; + my ( $bibitem, $biblio, $itemnumber, $lookahead) = @_; my $dbh = C4::Context->dbh; # TODO: consolidate at least the SELECT portion of the first 2 queries to a common $select var. @@ -1768,11 +1771,11 @@ sub _Findgroupreserve { AND priority > 0 AND item_level_request = 1 AND itemnumber = ? - AND reservedate <= CURRENT_DATE() + AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) AND suspend = 0 /; my $sth = $dbh->prepare($item_level_target_query); - $sth->execute($itemnumber); + $sth->execute($itemnumber, $lookahead||0); my @results; if ( my $data = $sth->fetchrow_hashref ) { push( @results, $data ); @@ -1799,11 +1802,11 @@ sub _Findgroupreserve { AND priority > 0 AND item_level_request = 0 AND hold_fill_targets.itemnumber = ? - AND reservedate <= CURRENT_DATE() + AND reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) AND suspend = 0 /; $sth = $dbh->prepare($title_level_target_query); - $sth->execute($itemnumber); + $sth->execute($itemnumber, $lookahead||0); @results = (); if ( my $data = $sth->fetchrow_hashref ) { push( @results, $data ); @@ -1831,11 +1834,11 @@ sub _Findgroupreserve { AND reserves.reservedate = reserveconstraints.reservedate ) OR reserves.constrainttype='a' ) AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) - AND reserves.reservedate <= CURRENT_DATE() + AND reserves.reservedate <= DATE_ADD(NOW(),INTERVAL ? DAY) AND suspend = 0 /; $sth = $dbh->prepare($query); - $sth->execute( $biblio, $bibitem, $itemnumber ); + $sth->execute( $biblio, $bibitem, $itemnumber, $lookahead||0); @results = (); while ( my $data = $sth->fetchrow_hashref ) { push( @results, $data ); --- a/circ/pendingreserves.pl +++ a/circ/pendingreserves.pl @@ -25,6 +25,10 @@ use strict; #use warnings; FIXME - Bug 2505 + +use constant TWO_DAYS => 2; +use constant TWO_DAYS_AGO => -2; + use C4::Context; use C4::Output; use CGI; @@ -66,26 +70,24 @@ my $author; my ( $year, $month, $day ) = Today(); my $todaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", $year, $month, $day); -my $yesterdaysdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -1)); -# changed from delivered range of 10 years-yesterday to 2 days ago-today -# Find two days ago for the default shelf pull start and end dates, unless HoldsToPullStartDate sys pref is set. -my $defaultstartdate = ( C4::Context->preference('HoldsToPullStartDate') ) ? "-".C4::Context->preference('HoldsToPullStartDate') : -2; -my $pastdate = sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, $defaultstartdate)); - -# Predefine the start and end dates if they are not already defined $startdate =~ s/^\s+//; $startdate =~ s/\s+$//; $enddate =~ s/^\s+//; $enddate =~ s/\s+$//; -# Check if null, should string match, if so set start and end date to yesterday + if (!defined($startdate) or $startdate eq "") { + # changed from delivered range of 10 years-yesterday to 2 days ago-today + # Find two days ago for the default shelf pull start date, unless HoldsToPullStartDate sys pref is set. + my $pastdate= sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -C4::Context->preference('HoldsToPullStartDate')||TWO_DAYS_AGO )); $startdate = format_date($pastdate); } + if (!defined($enddate) or $enddate eq "") { - $enddate = format_date($todaysdate); + #similarly: calculate end date with ConfirmFutureHolds (days) + my $d=sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, C4::Context->preference('ConfirmFutureHolds')||0 )); + $enddate = format_date($d); } - my @reservedata; if ( $run_report ) { my $dbh = C4::Context->dbh; @@ -202,7 +204,8 @@ $template->param( run_report => $run_report, reserveloop => \@reservedata, "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, - HoldsToPullStartDate => (C4::Context->preference('HoldsToPullStartDate')?C4::Context->preference('HoldsToPullStartDate'):2), + HoldsToPullStartDate=> C4::Context->preference('HoldsToPullStartDate')||TWO_DAYS, + HoldsToPullEndDate => C4::Context->preference('ConfirmFutureHolds')||0, ); output_html_with_http_headers $input, $cookie, $template->output; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -55,7 +55,7 @@ Circulation: - Set the default start date for the Holds to pull list to - pref: HoldsToPullStartDate class: integer - - day(s) ago. + - day(s) ago. Note that the default end date is controlled by preference ConfirmFutureHolds. - - pref: AllowAllMessageDeletion choices: @@ -358,6 +358,11 @@ Circulation: no: "Don't allow" - "patrons to place holds that don't enter the waiting list until a certain future date. (AllowHoldDateInFuture must also be enabled)." - + - Confirm future hold requests at checkin within + - pref: ConfirmFutureHolds + class: integer + - day(s). Note that this number of days will be used too in calculating the default end date for the Holds to pull-report. (As may be obvious, use of this preference becomes useful only when allowing future holds. + - - Check the - pref: ReservesControlBranch choices: --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt @@ -174,7 +174,7 @@ $(document).ready(function() { -

(Inclusive, default is [% HoldsToPullStartDate %] days ago to today, set other date ranges as needed. )

+

(Inclusive, default is [% HoldsToPullStartDate %] days ago to [% IF ( HoldsToPullEndDate ) %][% HoldsToPullEndDate %] days ahead[% ELSE %]today[% END %], set other date ranges as needed. )

--