Lines 1990-2020
sub RevertWaitingStatus {
Link Here
|
1990 |
my $dbh = C4::Context->dbh; |
1990 |
my $dbh = C4::Context->dbh; |
1991 |
|
1991 |
|
1992 |
## Get the waiting reserve we want to revert |
1992 |
## Get the waiting reserve we want to revert |
1993 |
my $query = " |
1993 |
my $hold = Koha::Holds->search( |
1994 |
SELECT * FROM reserves |
1994 |
{ |
1995 |
WHERE itemnumber = ? |
1995 |
itemnumber => $itemnumber, |
1996 |
AND found IS NOT NULL |
1996 |
found => { not => undef }, |
1997 |
"; |
1997 |
} |
1998 |
my $sth = $dbh->prepare( $query ); |
1998 |
)->next; |
1999 |
$sth->execute( $itemnumber ); |
|
|
2000 |
my $reserve = $sth->fetchrow_hashref(); |
2001 |
|
2002 |
my $hold = Koha::Holds->find( $reserve->{reserve_id} ); # TODO Remove the next raw SQL statements and use this instead |
2003 |
|
1999 |
|
2004 |
## Increment the priority of all other non-waiting |
2000 |
## Increment the priority of all other non-waiting |
2005 |
## reserves for this bib record |
2001 |
## reserves for this bib record |
2006 |
$query = " |
2002 |
my $holds = Koha::Holds->search({ biblionumber => $hold->biblionumber, priority => { '>' => 0 } }); |
2007 |
UPDATE reserves |
2003 |
while ( my $h = $holds->next ) { |
2008 |
SET |
2004 |
$h->priority( $h->priority + 1 )->store; |
2009 |
priority = priority + 1 |
2005 |
} |
2010 |
WHERE |
|
|
2011 |
biblionumber = ? |
2012 |
AND |
2013 |
priority > 0 |
2014 |
"; |
2015 |
$sth = $dbh->prepare( $query ); |
2016 |
$sth->execute( $reserve->{'biblionumber'} ); |
2017 |
|
2006 |
|
|
|
2007 |
## Fix up the currently waiting reserve |
2018 |
$hold->set( |
2008 |
$hold->set( |
2019 |
{ |
2009 |
{ |
2020 |
priority => 1, |
2010 |
priority => 1, |
Lines 2024-2030
sub RevertWaitingStatus {
Link Here
|
2024 |
} |
2014 |
} |
2025 |
)->store(); |
2015 |
)->store(); |
2026 |
|
2016 |
|
2027 |
_FixPriority( { biblionumber => $reserve->{biblionumber} } ); |
2017 |
_FixPriority( { biblionumber => $hold->biblionumber } ); |
2028 |
|
2018 |
|
2029 |
return $hold; |
2019 |
return $hold; |
2030 |
} |
2020 |
} |
2031 |
- |
|
|