Lines 130-135
BEGIN {
Link Here
|
130 |
&AlterPriority |
130 |
&AlterPriority |
131 |
&ToggleLowestPriority |
131 |
&ToggleLowestPriority |
132 |
|
132 |
|
|
|
133 |
&RevertWaitingStatus |
134 |
&RevertItemLevelHoldToBibLevelHold |
133 |
&ReserveSlip |
135 |
&ReserveSlip |
134 |
&ToggleSuspend |
136 |
&ToggleSuspend |
135 |
&SuspendAll |
137 |
&SuspendAll |
Lines 198-220
sub AddReserve {
Link Here
|
198 |
# Don't add itemtype limit if specific item is selected |
200 |
# Don't add itemtype limit if specific item is selected |
199 |
$itemtype = undef if $checkitem; |
201 |
$itemtype = undef if $checkitem; |
200 |
|
202 |
|
201 |
# updates take place here |
203 |
# Create reserves with with originalholdtype="B" if biblio level hold and "I" if item level hold |
202 |
my $hold = Koha::Hold->new( |
204 |
my $hold; |
203 |
{ |
205 |
if (!($checkitem)) { |
204 |
borrowernumber => $borrowernumber, |
206 |
# updates take place here |
205 |
biblionumber => $biblionumber, |
207 |
$hold = Koha::Hold->new( |
206 |
reservedate => $resdate, |
208 |
{ |
207 |
branchcode => $branch, |
209 |
borrowernumber => $borrowernumber, |
208 |
priority => $priority, |
210 |
biblionumber => $biblionumber, |
209 |
reservenotes => $notes, |
211 |
reservedate => $resdate, |
210 |
itemnumber => $checkitem, |
212 |
branchcode => $branch, |
211 |
found => $found, |
213 |
priority => $priority, |
212 |
waitingdate => $waitingdate, |
214 |
reservenotes => $notes, |
213 |
expirationdate => $expdate, |
215 |
itemnumber => $checkitem, |
214 |
itemtype => $itemtype, |
216 |
found => $found, |
215 |
} |
217 |
waitingdate => $waitingdate, |
216 |
)->store(); |
218 |
expirationdate => $expdate, |
217 |
$hold->set_waiting() if $found eq 'W'; |
219 |
itemtype => $itemtype, |
|
|
220 |
originalholdtype => 'B', |
221 |
} |
222 |
)->store(); |
223 |
$hold->set_waiting() if $found eq 'W'; |
224 |
} else { |
225 |
# updates take place here |
226 |
$hold = Koha::Hold->new( |
227 |
{ |
228 |
borrowernumber => $borrowernumber, |
229 |
biblionumber => $biblionumber, |
230 |
reservedate => $resdate, |
231 |
branchcode => $branch, |
232 |
priority => $priority, |
233 |
reservenotes => $notes, |
234 |
itemnumber => $checkitem, |
235 |
found => $found, |
236 |
waitingdate => $waitingdate, |
237 |
expirationdate => $expdate, |
238 |
itemtype => $itemtype, |
239 |
originalholdtype => 'I', |
240 |
} |
241 |
)->store(); |
242 |
$hold->set_waiting() if $found eq 'W'; |
243 |
} |
218 |
|
244 |
|
219 |
logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) ) |
245 |
logaction( 'HOLDS', 'CREATE', $hold->id, Dumper($hold->unblessed) ) |
220 |
if C4::Context->preference('HoldsLog'); |
246 |
if C4::Context->preference('HoldsLog'); |
Lines 1405-1415
sub _FixPriority {
Link Here
|
1405 |
$hold = Koha::Holds->find( $reserve_id ); |
1431 |
$hold = Koha::Holds->find( $reserve_id ); |
1406 |
return unless $hold; |
1432 |
return unless $hold; |
1407 |
} |
1433 |
} |
1408 |
|
|
|
1409 |
unless ( $biblionumber ) { # FIXME This is a very weird API |
1434 |
unless ( $biblionumber ) { # FIXME This is a very weird API |
1410 |
$biblionumber = $hold->biblionumber; |
1435 |
$biblionumber = $hold->biblionumber; |
1411 |
} |
1436 |
} |
1412 |
|
|
|
1413 |
if ( $rank eq "del" ) { # FIXME will crash if called without $hold |
1437 |
if ( $rank eq "del" ) { # FIXME will crash if called without $hold |
1414 |
$hold->cancel; |
1438 |
$hold->cancel; |
1415 |
} |
1439 |
} |
Lines 1521-1527
sub _Findgroupreserve {
Link Here
|
1521 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1545 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1522 |
reserves.itemnumber AS itemnumber, |
1546 |
reserves.itemnumber AS itemnumber, |
1523 |
reserves.reserve_id AS reserve_id, |
1547 |
reserves.reserve_id AS reserve_id, |
1524 |
reserves.itemtype AS itemtype |
1548 |
reserves.itemtype AS itemtype, |
|
|
1549 |
reserves.originalholdtype AS originalholdtype |
1525 |
FROM reserves |
1550 |
FROM reserves |
1526 |
JOIN biblioitems USING (biblionumber) |
1551 |
JOIN biblioitems USING (biblionumber) |
1527 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber) |
1552 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber) |
Lines 1556-1562
sub _Findgroupreserve {
Link Here
|
1556 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1581 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1557 |
reserves.itemnumber AS itemnumber, |
1582 |
reserves.itemnumber AS itemnumber, |
1558 |
reserves.reserve_id AS reserve_id, |
1583 |
reserves.reserve_id AS reserve_id, |
1559 |
reserves.itemtype AS itemtype |
1584 |
reserves.itemtype AS itemtype, |
|
|
1585 |
reserves.originalholdtype AS originalholdtype |
1560 |
FROM reserves |
1586 |
FROM reserves |
1561 |
JOIN biblioitems USING (biblionumber) |
1587 |
JOIN biblioitems USING (biblionumber) |
1562 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber) |
1588 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber) |
Lines 1590-1596
sub _Findgroupreserve {
Link Here
|
1590 |
reserves.timestamp AS timestamp, |
1616 |
reserves.timestamp AS timestamp, |
1591 |
reserves.itemnumber AS itemnumber, |
1617 |
reserves.itemnumber AS itemnumber, |
1592 |
reserves.reserve_id AS reserve_id, |
1618 |
reserves.reserve_id AS reserve_id, |
1593 |
reserves.itemtype AS itemtype |
1619 |
reserves.itemtype AS itemtype, |
|
|
1620 |
reserves.originalholdtype AS originalholdtype |
1594 |
FROM reserves |
1621 |
FROM reserves |
1595 |
WHERE reserves.biblionumber = ? |
1622 |
WHERE reserves.biblionumber = ? |
1596 |
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) |
1623 |
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) |
Lines 1910-1915
sub RevertWaitingStatus {
Link Here
|
1910 |
_FixPriority( { biblionumber => $reserve->{biblionumber} } ); |
1937 |
_FixPriority( { biblionumber => $reserve->{biblionumber} } ); |
1911 |
} |
1938 |
} |
1912 |
|
1939 |
|
|
|
1940 |
|
1941 |
=head2 RevertItemLevelHoldToBibLevelHold |
1942 |
|
1943 |
RevertItemLevelHoldToBibLevelHold({ reserveid => $reserveid }); |
1944 |
|
1945 |
Reverts a item level hold (which was originally a bib-level hold, which is determined by the value of reserves.originalholdtype) back to a bib-level hold. |
1946 |
|
1947 |
=cut |
1948 |
|
1949 |
sub RevertItemLevelHoldToBibLevelHold { |
1950 |
my ( $params ) = @_; |
1951 |
my $reserve_id = $params->{'reserveid'}; |
1952 |
|
1953 |
return unless ( $reserve_id ); |
1954 |
my $dbh = C4::Context->dbh; |
1955 |
|
1956 |
#Get the waiting reserve we want to revert |
1957 |
my $query = " |
1958 |
SELECT * FROM reserves |
1959 |
WHERE reserve_id = ? |
1960 |
AND itemnumber IS NOT NULL |
1961 |
"; |
1962 |
my $sth = $dbh->prepare( $query ); |
1963 |
$sth->execute( $reserve_id ); |
1964 |
my $reserve = $sth->fetchrow_hashref(); |
1965 |
|
1966 |
## Set the itemnumber to 'NULL' |
1967 |
$query = " |
1968 |
UPDATE reserves |
1969 |
SET |
1970 |
itemnumber = NULL |
1971 |
WHERE |
1972 |
reserve_id = ? |
1973 |
"; |
1974 |
$sth = $dbh->prepare( $query ); |
1975 |
$sth->execute( $reserve_id ); |
1976 |
} |
1977 |
|
1913 |
=head2 ReserveSlip |
1978 |
=head2 ReserveSlip |
1914 |
|
1979 |
|
1915 |
ReserveSlip( |
1980 |
ReserveSlip( |