View | Details | Raw Unified | Return to bug 23070
Collapse All | Expand All

(-)a/C4/Reserves.pm (-22 / +11 lines)
Lines 1962-1992 sub RevertWaitingStatus { Link Here
1962
    my $dbh = C4::Context->dbh;
1962
    my $dbh = C4::Context->dbh;
1963
1963
1964
    ## Get the waiting reserve we want to revert
1964
    ## Get the waiting reserve we want to revert
1965
    my $query = "
1965
    my $hold = Koha::Holds->search(
1966
        SELECT * FROM reserves
1966
        {
1967
        WHERE itemnumber = ?
1967
            itemnumber => $itemnumber,
1968
        AND found IS NOT NULL
1968
            found => { not => undef },
1969
    ";
1969
        }
1970
    my $sth = $dbh->prepare( $query );
1970
    )->next;
1971
    $sth->execute( $itemnumber );
1972
    my $reserve = $sth->fetchrow_hashref();
1973
1974
    my $hold = Koha::Holds->find( $reserve->{reserve_id} ); # TODO Remove the next raw SQL statements and use this instead
1975
1971
1976
    ## Increment the priority of all other non-waiting
1972
    ## Increment the priority of all other non-waiting
1977
    ## reserves for this bib record
1973
    ## reserves for this bib record
1978
    $query = "
1974
    my $holds = Koha::Holds->search({ biblionumber => $hold->biblionumber, priority => { '>' => 0 } });
1979
        UPDATE reserves
1975
    while ( my $h = $holds->next ) {
1980
        SET
1976
        $h->priority( $h->priority + 1 )->store;
1981
          priority = priority + 1
1977
    }
1982
        WHERE
1983
          biblionumber =  ?
1984
        AND
1985
          priority > 0
1986
    ";
1987
    $sth = $dbh->prepare( $query );
1988
    $sth->execute( $reserve->{'biblionumber'} );
1989
1978
1979
    ## Fix up the currently waiting reserve
1990
    $hold->set(
1980
    $hold->set(
1991
        {
1981
        {
1992
            priority    => 1,
1982
            priority    => 1,
1993
- 

Return to bug 23070