Lines 194-199
sub AddReserve {
Link Here
|
194 |
my $itemtype = $params->{itemtype}; |
194 |
my $itemtype = $params->{itemtype}; |
195 |
my $non_priority = $params->{non_priority}; |
195 |
my $non_priority = $params->{non_priority}; |
196 |
my $item_group_id = $params->{item_group_id}; |
196 |
my $item_group_id = $params->{item_group_id}; |
|
|
197 |
my $hold_group_id = $params->{hold_group_id}; |
197 |
|
198 |
|
198 |
$resdate ||= dt_from_string; |
199 |
$resdate ||= dt_from_string; |
199 |
|
200 |
|
Lines 256-261
sub AddReserve {
Link Here
|
256 |
itemtype => $itemtype, |
257 |
itemtype => $itemtype, |
257 |
item_level_hold => $checkitem ? 1 : 0, |
258 |
item_level_hold => $checkitem ? 1 : 0, |
258 |
non_priority => $non_priority ? 1 : 0, |
259 |
non_priority => $non_priority ? 1 : 0, |
|
|
260 |
hold_group_id => $hold_group_id, |
259 |
} |
261 |
} |
260 |
)->store(); |
262 |
)->store(); |
261 |
$hold->set_waiting() if $found && $found eq 'W'; |
263 |
$hold->set_waiting() if $found && $found eq 'W'; |
Lines 569-589
sub CanItemBeReserved {
Link Here
|
569 |
borrowernumber => $patron->borrowernumber, |
571 |
borrowernumber => $patron->borrowernumber, |
570 |
biblionumber => $item->biblionumber, |
572 |
biblionumber => $item->biblionumber, |
571 |
}; |
573 |
}; |
572 |
my $holds = Koha::Holds->search($search_params); |
574 |
my $holds_count = Koha::Holds->count_holds($search_params); |
573 |
return _cache { status => "tooManyHoldsForThisRecord", limit => $holds_per_record } |
575 |
return _cache { status => "tooManyHoldsForThisRecord", limit => $holds_per_record } |
574 |
if $holds->count() >= $holds_per_record; |
576 |
if $holds_count >= $holds_per_record; |
575 |
} |
577 |
} |
576 |
} |
578 |
} |
577 |
|
579 |
|
578 |
if ( !$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '' ) { |
580 |
if ( !$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '' ) { |
579 |
my $today_holds = Koha::Holds->search( |
581 |
my $today_holds_count = Koha::Holds->count_holds( |
580 |
{ |
582 |
{ |
581 |
borrowernumber => $patron->borrowernumber, |
583 |
borrowernumber => $patron->borrowernumber, |
582 |
reservedate => dt_from_string->date |
584 |
reservedate => dt_from_string->date |
583 |
} |
585 |
} |
584 |
); |
586 |
); |
585 |
return _cache { status => 'tooManyReservesToday', limit => $holds_per_day } |
587 |
return _cache { status => 'tooManyReservesToday', limit => $holds_per_day } |
586 |
if $today_holds->count() >= $holds_per_day; |
588 |
if $today_holds_count >= $holds_per_day; |
587 |
} |
589 |
} |
588 |
|
590 |
|
589 |
# we check if it's ok or not |
591 |
# we check if it's ok or not |
Lines 1239-1244
sub ModReserveAffect {
Link Here
|
1239 |
|
1241 |
|
1240 |
$hold->itemnumber($itemnumber); |
1242 |
$hold->itemnumber($itemnumber); |
1241 |
|
1243 |
|
|
|
1244 |
my @reserve_ids; |
1245 |
push @reserve_ids, $hold->reserve_id; |
1246 |
|
1242 |
if ($transferToDo) { |
1247 |
if ($transferToDo) { |
1243 |
$hold->set_transfer(); |
1248 |
$hold->set_transfer(); |
1244 |
} elsif ( C4::Context->preference('HoldsNeedProcessingSIP') |
1249 |
} elsif ( C4::Context->preference('HoldsNeedProcessingSIP') |
Lines 1253-1258
sub ModReserveAffect {
Link Here
|
1253 |
# Complete transfer if one exists |
1258 |
# Complete transfer if one exists |
1254 |
my $transfer = $hold->item->get_transfer; |
1259 |
my $transfer = $hold->item->get_transfer; |
1255 |
$transfer->receive if $transfer; |
1260 |
$transfer->receive if $transfer; |
|
|
1261 |
|
1262 |
# if this hold was part of a group, cancel other holds in the group |
1263 |
if ( $hold->hold_group_id ) { |
1264 |
my @holds = $hold->hold_group->holds->as_list; |
1265 |
foreach my $h (@holds) { |
1266 |
push @reserve_ids, $h->reserve_id; |
1267 |
$h->cancel unless $h->reserve_id == $hold->reserve_id; |
1268 |
} |
1269 |
} |
1256 |
} |
1270 |
} |
1257 |
|
1271 |
|
1258 |
_koha_notify_hold_changed($hold) if $notify_library; |
1272 |
_koha_notify_hold_changed($hold) if $notify_library; |
Lines 1266-1273
sub ModReserveAffect {
Link Here
|
1266 |
CartToShelf($itemnumber); |
1280 |
CartToShelf($itemnumber); |
1267 |
} |
1281 |
} |
1268 |
|
1282 |
|
1269 |
my $std = $dbh->prepare( |
1283 |
foreach my $id (@reserve_ids) { |
1270 |
q{ |
1284 |
my $std = $dbh->prepare( |
|
|
1285 |
q{ |
1271 |
DELETE q, t |
1286 |
DELETE q, t |
1272 |
FROM tmp_holdsqueue q |
1287 |
FROM tmp_holdsqueue q |
1273 |
INNER JOIN hold_fill_targets t |
1288 |
INNER JOIN hold_fill_targets t |
Lines 1277-1285
sub ModReserveAffect {
Link Here
|
1277 |
AND q.item_level_request = t.item_level_request |
1292 |
AND q.item_level_request = t.item_level_request |
1278 |
AND q.holdingbranch = t.source_branchcode |
1293 |
AND q.holdingbranch = t.source_branchcode |
1279 |
WHERE t.reserve_id = ? |
1294 |
WHERE t.reserve_id = ? |
|
|
1295 |
} |
1296 |
); |
1297 |
$std->execute($id); |
1280 |
} |
1298 |
} |
1281 |
); |
|
|
1282 |
$std->execute( $hold->reserve_id ); |
1283 |
|
1299 |
|
1284 |
logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold, undef, $original ) |
1300 |
logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold, undef, $original ) |
1285 |
if C4::Context->preference('HoldsLog'); |
1301 |
if C4::Context->preference('HoldsLog'); |