Lines 199-204
sub AddReserve {
Link Here
|
199 |
my $itemtype = $params->{itemtype}; |
199 |
my $itemtype = $params->{itemtype}; |
200 |
my $non_priority = $params->{non_priority}; |
200 |
my $non_priority = $params->{non_priority}; |
201 |
my $item_group_id = $params->{item_group_id}; |
201 |
my $item_group_id = $params->{item_group_id}; |
|
|
202 |
my $hold_group_id = $params->{hold_group_id}; |
202 |
|
203 |
|
203 |
$resdate ||= dt_from_string; |
204 |
$resdate ||= dt_from_string; |
204 |
|
205 |
|
Lines 259-264
sub AddReserve {
Link Here
|
259 |
itemtype => $itemtype, |
260 |
itemtype => $itemtype, |
260 |
item_level_hold => $checkitem ? 1 : 0, |
261 |
item_level_hold => $checkitem ? 1 : 0, |
261 |
non_priority => $non_priority ? 1 : 0, |
262 |
non_priority => $non_priority ? 1 : 0, |
|
|
263 |
hold_group_id => $hold_group_id, |
262 |
} |
264 |
} |
263 |
)->store(); |
265 |
)->store(); |
264 |
$hold->set_waiting() if $found && $found eq 'W'; |
266 |
$hold->set_waiting() if $found && $found eq 'W'; |
Lines 565-582
sub CanItemBeReserved {
Link Here
|
565 |
borrowernumber => $patron->borrowernumber, |
567 |
borrowernumber => $patron->borrowernumber, |
566 |
biblionumber => $item->biblionumber, |
568 |
biblionumber => $item->biblionumber, |
567 |
}; |
569 |
}; |
568 |
my $holds = Koha::Holds->search($search_params); |
570 |
my $holds_count = Koha::Holds->count_holds($search_params); |
569 |
return _cache { status => "tooManyHoldsForThisRecord", limit => $holds_per_record } if $holds->count() >= $holds_per_record; |
571 |
return _cache { status => "tooManyHoldsForThisRecord", limit => $holds_per_record } |
|
|
572 |
if $holds_count >= $holds_per_record; |
570 |
} |
573 |
} |
571 |
} |
574 |
} |
572 |
|
575 |
|
573 |
if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '') |
576 |
if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '') |
574 |
{ |
577 |
{ |
575 |
my $today_holds = Koha::Holds->search({ |
578 |
my $today_holds_count = Koha::Holds->count_holds( |
576 |
borrowernumber => $patron->borrowernumber, |
579 |
{ |
577 |
reservedate => dt_from_string->date |
580 |
borrowernumber => $patron->borrowernumber, |
578 |
}); |
581 |
reservedate => dt_from_string->date |
579 |
return _cache { status => 'tooManyReservesToday', limit => $holds_per_day } if $today_holds->count() >= $holds_per_day; |
582 |
} |
|
|
583 |
); |
584 |
return _cache { status => 'tooManyReservesToday', limit => $holds_per_day } |
585 |
if $today_holds_count >= $holds_per_day; |
580 |
} |
586 |
} |
581 |
|
587 |
|
582 |
# we check if it's ok or not |
588 |
# we check if it's ok or not |
Lines 1247-1252
sub ModReserveAffect {
Link Here
|
1247 |
|
1253 |
|
1248 |
$hold->itemnumber($itemnumber); |
1254 |
$hold->itemnumber($itemnumber); |
1249 |
|
1255 |
|
|
|
1256 |
my @reserve_ids; |
1257 |
push @reserve_ids, $hold->reserve_id; |
1258 |
|
1250 |
if ($transferToDo) { |
1259 |
if ($transferToDo) { |
1251 |
$hold->set_transfer(); |
1260 |
$hold->set_transfer(); |
1252 |
} elsif (C4::Context->preference('HoldsNeedProcessingSIP') |
1261 |
} elsif (C4::Context->preference('HoldsNeedProcessingSIP') |
Lines 1259-1264
sub ModReserveAffect {
Link Here
|
1259 |
# Complete transfer if one exists |
1268 |
# Complete transfer if one exists |
1260 |
my $transfer = $hold->item->get_transfer; |
1269 |
my $transfer = $hold->item->get_transfer; |
1261 |
$transfer->receive if $transfer; |
1270 |
$transfer->receive if $transfer; |
|
|
1271 |
|
1272 |
# if this hold was part of a group, cancel other holds in the group |
1273 |
if ( $hold->hold_group_id ) { |
1274 |
my @holds = $hold->hold_group->holds->as_list; |
1275 |
foreach my $h (@holds) { |
1276 |
push @reserve_ids, $h->reserve_id; |
1277 |
$h->cancel unless $h->reserve_id == $hold->reserve_id; |
1278 |
} |
1279 |
} |
1262 |
} |
1280 |
} |
1263 |
|
1281 |
|
1264 |
_koha_notify_hold_changed( $hold ) if $notify_library; |
1282 |
_koha_notify_hold_changed( $hold ) if $notify_library; |
Lines 1270-1287
sub ModReserveAffect {
Link Here
|
1270 |
CartToShelf( $itemnumber ); |
1288 |
CartToShelf( $itemnumber ); |
1271 |
} |
1289 |
} |
1272 |
|
1290 |
|
1273 |
my $std = $dbh->prepare(q{ |
1291 |
foreach my $id (@reserve_ids) { |
1274 |
DELETE q, t |
1292 |
my $std = $dbh->prepare( |
1275 |
FROM tmp_holdsqueue q |
1293 |
q{ |
1276 |
INNER JOIN hold_fill_targets t |
1294 |
DELETE q, t |
1277 |
ON q.borrowernumber = t.borrowernumber |
1295 |
FROM tmp_holdsqueue q |
1278 |
AND q.biblionumber = t.biblionumber |
1296 |
INNER JOIN hold_fill_targets t |
1279 |
AND q.itemnumber = t.itemnumber |
1297 |
ON q.borrowernumber = t.borrowernumber |
1280 |
AND q.item_level_request = t.item_level_request |
1298 |
AND q.biblionumber = t.biblionumber |
1281 |
AND q.holdingbranch = t.source_branchcode |
1299 |
AND q.itemnumber = t.itemnumber |
1282 |
WHERE t.reserve_id = ? |
1300 |
AND q.item_level_request = t.item_level_request |
1283 |
}); |
1301 |
AND q.holdingbranch = t.source_branchcode |
1284 |
$std->execute($hold->reserve_id); |
1302 |
WHERE t.reserve_id = ? |
|
|
1303 |
} |
1304 |
); |
1305 |
$std->execute($id); |
1306 |
} |
1285 |
|
1307 |
|
1286 |
logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) |
1308 |
logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) |
1287 |
if C4::Context->preference('HoldsLog'); |
1309 |
if C4::Context->preference('HoldsLog'); |