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 1391-1401
sub _FixPriority {
Link Here
|
1391 |
$hold = Koha::Holds->find( $reserve_id ); |
1417 |
$hold = Koha::Holds->find( $reserve_id ); |
1392 |
return unless $hold; |
1418 |
return unless $hold; |
1393 |
} |
1419 |
} |
1394 |
|
|
|
1395 |
unless ( $biblionumber ) { # FIXME This is a very weird API |
1420 |
unless ( $biblionumber ) { # FIXME This is a very weird API |
1396 |
$biblionumber = $hold->biblionumber; |
1421 |
$biblionumber = $hold->biblionumber; |
1397 |
} |
1422 |
} |
1398 |
|
|
|
1399 |
if ( $rank eq "del" ) { # FIXME will crash if called without $hold |
1423 |
if ( $rank eq "del" ) { # FIXME will crash if called without $hold |
1400 |
$hold->cancel; |
1424 |
$hold->cancel; |
1401 |
} |
1425 |
} |
Lines 1507-1513
sub _Findgroupreserve {
Link Here
|
1507 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1531 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1508 |
reserves.itemnumber AS itemnumber, |
1532 |
reserves.itemnumber AS itemnumber, |
1509 |
reserves.reserve_id AS reserve_id, |
1533 |
reserves.reserve_id AS reserve_id, |
1510 |
reserves.itemtype AS itemtype |
1534 |
reserves.itemtype AS itemtype, |
|
|
1535 |
reserves.originalholdtype AS originalholdtype |
1511 |
FROM reserves |
1536 |
FROM reserves |
1512 |
JOIN biblioitems USING (biblionumber) |
1537 |
JOIN biblioitems USING (biblionumber) |
1513 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber) |
1538 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber) |
Lines 1542-1548
sub _Findgroupreserve {
Link Here
|
1542 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1567 |
biblioitems.biblioitemnumber AS biblioitemnumber, |
1543 |
reserves.itemnumber AS itemnumber, |
1568 |
reserves.itemnumber AS itemnumber, |
1544 |
reserves.reserve_id AS reserve_id, |
1569 |
reserves.reserve_id AS reserve_id, |
1545 |
reserves.itemtype AS itemtype |
1570 |
reserves.itemtype AS itemtype, |
|
|
1571 |
reserves.originalholdtype AS originalholdtype |
1546 |
FROM reserves |
1572 |
FROM reserves |
1547 |
JOIN biblioitems USING (biblionumber) |
1573 |
JOIN biblioitems USING (biblionumber) |
1548 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber) |
1574 |
JOIN hold_fill_targets USING (biblionumber, borrowernumber) |
Lines 1576-1582
sub _Findgroupreserve {
Link Here
|
1576 |
reserves.timestamp AS timestamp, |
1602 |
reserves.timestamp AS timestamp, |
1577 |
reserves.itemnumber AS itemnumber, |
1603 |
reserves.itemnumber AS itemnumber, |
1578 |
reserves.reserve_id AS reserve_id, |
1604 |
reserves.reserve_id AS reserve_id, |
1579 |
reserves.itemtype AS itemtype |
1605 |
reserves.itemtype AS itemtype, |
|
|
1606 |
reserves.originalholdtype AS originalholdtype |
1580 |
FROM reserves |
1607 |
FROM reserves |
1581 |
WHERE reserves.biblionumber = ? |
1608 |
WHERE reserves.biblionumber = ? |
1582 |
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) |
1609 |
AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) |
Lines 1896-1901
sub RevertWaitingStatus {
Link Here
|
1896 |
_FixPriority( { biblionumber => $reserve->{biblionumber} } ); |
1923 |
_FixPriority( { biblionumber => $reserve->{biblionumber} } ); |
1897 |
} |
1924 |
} |
1898 |
|
1925 |
|
|
|
1926 |
|
1927 |
=head2 RevertItemLevelHoldToBibLevelHold |
1928 |
|
1929 |
RevertItemLevelHoldToBibLevelHold({ reserveid => $reserveid }); |
1930 |
|
1931 |
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. |
1932 |
|
1933 |
=cut |
1934 |
|
1935 |
sub RevertItemLevelHoldToBibLevelHold { |
1936 |
my ( $params ) = @_; |
1937 |
my $reserve_id = $params->{'reserveid'}; |
1938 |
|
1939 |
return unless ( $reserve_id ); |
1940 |
my $dbh = C4::Context->dbh; |
1941 |
|
1942 |
#Get the waiting reserve we want to revert |
1943 |
my $query = " |
1944 |
SELECT * FROM reserves |
1945 |
WHERE reserve_id = ? |
1946 |
AND itemnumber IS NOT NULL |
1947 |
"; |
1948 |
my $sth = $dbh->prepare( $query ); |
1949 |
$sth->execute( $reserve_id ); |
1950 |
my $reserve = $sth->fetchrow_hashref(); |
1951 |
|
1952 |
## Set the itemnumber to 'NULL' |
1953 |
$query = " |
1954 |
UPDATE reserves |
1955 |
SET |
1956 |
itemnumber = NULL |
1957 |
WHERE |
1958 |
reserve_id = ? |
1959 |
"; |
1960 |
$sth = $dbh->prepare( $query ); |
1961 |
$sth->execute( $reserve_id ); |
1962 |
} |
1963 |
|
1899 |
=head2 ReserveSlip |
1964 |
=head2 ReserveSlip |
1900 |
|
1965 |
|
1901 |
ReserveSlip( |
1966 |
ReserveSlip( |