# 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->{'withdrawn'} );
+ 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->{'withdrawn'} );
if ($resfound) {
$resrec->{'ResFound'} = $resfound;
$messages->{'ResFound'} = $resrec;
($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
=cut
sub CheckReserves {
- my ( $item, $barcode ) = @_;
+ my ( $item, $barcode, $lookahead_days) = @_;
my $dbh = C4::Context->dbh;
my $sth;
my $select;
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,
=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
=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.
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 );
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 );
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 );
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;
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;
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;
- 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:
yes: Allow
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
<input type="text" size="10" id="to" name="to" value="[% to %]" class="datepickerto" />
</li>
</ol>
-<p><i>(Inclusive, default is [% HoldsToPullStartDate %] days ago to today, set other date ranges as needed. )</i></p>
+<p><i>(Inclusive, default is [% HoldsToPullStartDate %] days ago to [% IF ( HoldsToPullEndDate ) %][% HoldsToPullEndDate %] days ahead[% ELSE %]today[% END %], set other date ranges as needed. )</i></p>
<fieldset class="action"><input type="submit" name="run_report" value="Submit" class="submit"/></fieldset>
</fieldset>
</form>