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