Lines 1886-1934
sub RevertWaitingStatus {
Link Here
|
1886 |
my $dbh = C4::Context->dbh; |
1886 |
my $dbh = C4::Context->dbh; |
1887 |
|
1887 |
|
1888 |
## Get the waiting reserve we want to revert |
1888 |
## Get the waiting reserve we want to revert |
1889 |
my $query = " |
1889 |
my $hold = Koha::Holds->search( |
1890 |
SELECT * FROM reserves |
1890 |
{ |
1891 |
WHERE itemnumber = ? |
1891 |
itemnumber => $itemnumber, |
1892 |
AND found IS NOT NULL |
1892 |
found => { not => undef }, |
1893 |
"; |
1893 |
} |
1894 |
my $sth = $dbh->prepare( $query ); |
1894 |
)->next; |
1895 |
$sth->execute( $itemnumber ); |
|
|
1896 |
my $reserve = $sth->fetchrow_hashref(); |
1897 |
|
1898 |
my $hold = Koha::Holds->find( $reserve->{reserve_id} ); # TODO Remove the next raw SQL statements and use this instead |
1899 |
|
1895 |
|
1900 |
## Increment the priority of all other non-waiting |
1896 |
## Increment the priority of all other non-waiting |
1901 |
## reserves for this bib record |
1897 |
## reserves for this bib record |
1902 |
$query = " |
1898 |
my $holds = Koha::Holds->search({ biblionumber => $hold->biblionumber, priority => { '>' => 0 } }); |
1903 |
UPDATE reserves |
1899 |
while ( my $h = $holds->next ) { |
1904 |
SET |
1900 |
$h->priority( $h->priority + 1 )->store; |
1905 |
priority = priority + 1 |
1901 |
} |
1906 |
WHERE |
|
|
1907 |
biblionumber = ? |
1908 |
AND |
1909 |
priority > 0 |
1910 |
"; |
1911 |
$sth = $dbh->prepare( $query ); |
1912 |
$sth->execute( $reserve->{'biblionumber'} ); |
1913 |
|
1902 |
|
1914 |
## Fix up the currently waiting reserve |
1903 |
## Fix up the currently waiting reserve |
1915 |
$query = " |
1904 |
$hold->set( { priority => 1, found => undef, waitingdate => undef } )->store; |
1916 |
UPDATE reserves |
|
|
1917 |
SET |
1918 |
priority = 1, |
1919 |
found = NULL, |
1920 |
waitingdate = NULL |
1921 |
WHERE |
1922 |
reserve_id = ? |
1923 |
"; |
1924 |
$sth = $dbh->prepare( $query ); |
1925 |
$sth->execute( $reserve->{'reserve_id'} ); |
1926 |
|
1905 |
|
1927 |
unless ( $hold->item_level_hold ) { |
1906 |
unless ( $hold->item_level_hold ) { |
1928 |
$hold->itemnumber(undef)->store; |
1907 |
$hold->itemnumber(undef)->store; |
1929 |
} |
1908 |
} |
1930 |
|
1909 |
|
1931 |
_FixPriority( { biblionumber => $reserve->{biblionumber} } ); |
1910 |
_FixPriority( { biblionumber => $hold->biblionumber } ); |
1932 |
} |
1911 |
} |
1933 |
|
1912 |
|
1934 |
=head2 ReserveSlip |
1913 |
=head2 ReserveSlip |
1935 |
- |
|
|