Browse Source

Bug 9761: Make it possible to confirm future hold requests at checkin time

Description:

A new pref ConfirmFutureHolds is added. When confirming a hold at checkin time,
the number of days in this pref is taken into account when looking for reserves.
Note that this pref does not interfere with renewing, issuing or transferring
a book. For report Holds to pull, the default end date is calculated with this
new preference.
The use of ConfirmFutureHolds is useful only when future holds are allowed.

Test plan:
1) Enable future holds. Add a number of days into ConfirmFutureHolds.
2) Place a future hold within this number of days.
3) Run holds to pull report. Check default startdate and enddate.
4) Check this book in. Can you confirm the hold? Do not confirm.
5) Issue the book to another patron. You should not see a warning.
6) Renew the book for this patron via opac or staff. No warning either.
7) Check in again. Warning pops up again.
8) Transfer book. Switch branch. Check in. Hold found pops up. Do not confirm.
9) Back to first branch. Check in (with popup). Remove the hold. Add new future
hold past the number of days. Check in (no warn).

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
new/bootstrap-opac
Marcel de Rooy 10 years ago
committed by Galen Charlton
parent
commit
ded520afdc
  1. 3
      C4/Circulation.pm
  2. 23
      C4/Reserves.pm
  3. 25
      circ/pendingreserves.pl
  4. 7
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
  5. 2
      koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt

3
C4/Circulation.pm

@ -1885,7 +1885,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->{'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;

23
C4/Reserves.pm

@ -812,10 +812,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
@ -836,7 +838,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;
@ -883,7 +885,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,
@ -1706,11 +1708,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
@ -1722,7 +1725,7 @@ C<biblioitemnumber>.
=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.
@ -1747,11 +1750,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 );
@ -1778,11 +1781,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 );
@ -1810,11 +1813,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 );

25
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;

7
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref

@ -61,7 +61,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:
@ -369,6 +369,11 @@ Circulation:
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

2
koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt

@ -174,7 +174,7 @@ $(document).ready(function() {
<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>

Loading…
Cancel
Save