bug 2522 [2/3]: C4::Reserves support for request targeting

_Findgroupreserve, which identifies which hold request an
item should fill, is modified to check to see if
that item is targeted to fill a specific hold request.

It first checks for a targeted match with an item-level hold request,
then a targeted match with a title-level request.  If no
such targeted match exists, it then checks for the top entries
in the holds queue.

The hold targeting map (i.e., the hold_fill_targets table) is
populated by the build_holds_queue.pl batch job.  If that
job is not used, the behavior of _Findgroupreserve
is not changed.

This patch also

* adjusts ModReserveMinusPriority so that it calls
  _FixPriority().
* adjusts circ/returns.pl so that it
  correctly detects transfers.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
This commit is contained in:
Galen Charlton 2008-08-14 20:59:50 -05:00
parent 516ba77b8b
commit 8b48780665
2 changed files with 63 additions and 13 deletions

View File

@ -1058,16 +1058,7 @@ sub ModReserveMinusPriority {
$sth_upd->execute( $itemnumber, $borrowernumber, $biblionumber );
$sth_upd->finish;
# second step update all others reservs
$query = "
UPDATE reserves
SET priority = priority-1
WHERE biblionumber = ?
AND priority > 0
";
$sth_upd = $dbh->prepare($query);
$sth_upd->execute( $biblionumber );
$sth_upd->finish;
$sth_upd->finish;
_FixPriority($biblionumber, $borrowernumber, '0');
}
=item GetReserveInfo
@ -1294,6 +1285,65 @@ C<biblioitemnumber>.
sub _Findgroupreserve {
my ( $bibitem, $biblio, $itemnumber ) = @_;
my $dbh = C4::Context->dbh;
# check for exact targetted match
my $item_level_target_query = qq/
SELECT reserves.biblionumber AS biblionumber,
reserves.borrowernumber AS borrowernumber,
reserves.reservedate AS reservedate,
reserves.branchcode AS branchcode,
reserves.cancellationdate AS cancellationdate,
reserves.found AS found,
reserves.reservenotes AS reservenotes,
reserves.priority AS priority,
reserves.timestamp AS timestamp,
biblioitems.biblioitemnumber AS biblioitemnumber,
reserves.itemnumber AS itemnumber
FROM reserves
JOIN biblioitems USING (biblionumber)
JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber)
WHERE found IS NULL
AND priority > 0
AND item_level_request = 1
AND itemnumber = ?
/;
my $sth = $dbh->prepare($item_level_target_query);
$sth->execute($itemnumber);
my @results;
if ( my $data = $sth->fetchrow_hashref ) {
push( @results, $data );
}
return @results if @results;
# check for title-level targetted match
my $title_level_target_query = qq/
SELECT reserves.biblionumber AS biblionumber,
reserves.borrowernumber AS borrowernumber,
reserves.reservedate AS reservedate,
reserves.branchcode AS branchcode,
reserves.cancellationdate AS cancellationdate,
reserves.found AS found,
reserves.reservenotes AS reservenotes,
reserves.priority AS priority,
reserves.timestamp AS timestamp,
biblioitems.biblioitemnumber AS biblioitemnumber,
reserves.itemnumber AS itemnumber
FROM reserves
JOIN biblioitems USING (biblionumber)
JOIN hold_fill_targets USING (biblionumber, borrowernumber)
WHERE found IS NULL
AND priority > 0
AND item_level_request = 0
AND hold_fill_targets.itemnumber = ?
/;
$sth = $dbh->prepare($title_level_target_query);
$sth->execute($itemnumber);
@results = ();
if ( my $data = $sth->fetchrow_hashref ) {
push( @results, $data );
}
return @results if @results;
my $query = qq/
SELECT reserves.biblionumber AS biblionumber,
reserves.borrowernumber AS borrowernumber,
@ -1315,9 +1365,9 @@ sub _Findgroupreserve {
OR reserves.constrainttype='a' )
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?)
/;
my $sth = $dbh->prepare($query);
$sth = $dbh->prepare($query);
$sth->execute( $biblio, $bibitem, $itemnumber );
my @results;
@results = ();
while ( my $data = $sth->fetchrow_hashref ) {
push( @results, $data );
}

View File

@ -129,7 +129,7 @@ if ( $query->param('resbarcode') ) {
# addin in ModReserveAffect the possibility to check if the document is expected in this library or not,
# if not we send a value in reserve waiting for not implementting waiting status
if ($diffBranchReturned) {
if (C4::Context->userenv->{'branch'} ne $diffBranchReturned) {
$diffBranchSend = $diffBranchReturned;
}
else {