Lines 193-198
sub AddReserve {
Link Here
|
193 |
my $found = $params->{found}; |
193 |
my $found = $params->{found}; |
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 $hold_group_id = $params->{hold_group_id}; |
196 |
|
197 |
|
197 |
$resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) |
198 |
$resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) |
198 |
or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); |
199 |
or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); |
Lines 255-260
sub AddReserve {
Link Here
|
255 |
itemtype => $itemtype, |
256 |
itemtype => $itemtype, |
256 |
item_level_hold => $checkitem ? 1 : 0, |
257 |
item_level_hold => $checkitem ? 1 : 0, |
257 |
non_priority => $non_priority ? 1 : 0, |
258 |
non_priority => $non_priority ? 1 : 0, |
|
|
259 |
hold_group_id => $hold_group_id, |
258 |
} |
260 |
} |
259 |
)->store(); |
261 |
)->store(); |
260 |
$hold->set_waiting() if $found && $found eq 'W'; |
262 |
$hold->set_waiting() if $found && $found eq 'W'; |
Lines 520-537
sub CanItemBeReserved {
Link Here
|
520 |
biblionumber => $item->biblionumber, |
522 |
biblionumber => $item->biblionumber, |
521 |
}; |
523 |
}; |
522 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
524 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
523 |
my $holds = Koha::Holds->search($search_params); |
525 |
my $holds_count = Koha::Holds->count_holds($search_params); |
524 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record } if $holds->count() >= $holds_per_record; |
526 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record } if $holds_count >= $holds_per_record; |
525 |
} |
527 |
} |
526 |
} |
528 |
} |
527 |
|
529 |
|
528 |
if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '') |
530 |
if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne '') |
529 |
{ |
531 |
{ |
530 |
my $today_holds = Koha::Holds->search({ |
532 |
my $today_holds_count = Koha::Holds->count_holds({ |
531 |
borrowernumber => $patron->borrowernumber, |
533 |
borrowernumber => $patron->borrowernumber, |
532 |
reservedate => dt_from_string->date |
534 |
reservedate => dt_from_string->date |
533 |
}); |
535 |
}); |
534 |
return { status => 'tooManyReservesToday', limit => $holds_per_day } if $today_holds->count() >= $holds_per_day; |
536 |
return { status => 'tooManyReservesToday', limit => $holds_per_day } if $today_holds_count >= $holds_per_day; |
535 |
} |
537 |
} |
536 |
|
538 |
|
537 |
# we check if it's ok or not |
539 |
# we check if it's ok or not |
Lines 1235-1240
sub ModReserveAffect {
Link Here
|
1235 |
|
1237 |
|
1236 |
$hold->itemnumber($itemnumber); |
1238 |
$hold->itemnumber($itemnumber); |
1237 |
|
1239 |
|
|
|
1240 |
my @reserve_ids; |
1241 |
push @reserve_ids, $hold->reserve_id; |
1242 |
|
1238 |
if ($transferToDo) { |
1243 |
if ($transferToDo) { |
1239 |
$hold->set_transfer(); |
1244 |
$hold->set_transfer(); |
1240 |
} elsif (C4::Context->preference('HoldsNeedProcessingSIP') |
1245 |
} elsif (C4::Context->preference('HoldsNeedProcessingSIP') |
Lines 1247-1252
sub ModReserveAffect {
Link Here
|
1247 |
# Complete transfer if one exists |
1252 |
# Complete transfer if one exists |
1248 |
my $transfer = $hold->item->get_transfer; |
1253 |
my $transfer = $hold->item->get_transfer; |
1249 |
$transfer->receive if $transfer; |
1254 |
$transfer->receive if $transfer; |
|
|
1255 |
|
1256 |
# if this hold was part of a group, cancel other holds in the group |
1257 |
if ( $hold->hold_group_id ) { |
1258 |
my @holds = $hold->hold_group->holds->as_list; |
1259 |
foreach my $h ( @holds ) { |
1260 |
push @reserve_ids, $h->reserve_id; |
1261 |
$h->cancel unless $h->reserve_id == $hold->reserve_id; |
1262 |
} |
1263 |
} |
1250 |
} |
1264 |
} |
1251 |
|
1265 |
|
1252 |
_koha_notify_hold_changed( $hold ) if $notify_library; |
1266 |
_koha_notify_hold_changed( $hold ) if $notify_library; |
Lines 1258-1275
sub ModReserveAffect {
Link Here
|
1258 |
CartToShelf( $itemnumber ); |
1272 |
CartToShelf( $itemnumber ); |
1259 |
} |
1273 |
} |
1260 |
|
1274 |
|
1261 |
my $std = $dbh->prepare(q{ |
1275 |
foreach my $id ( @reserve_ids ) { |
1262 |
DELETE q, t |
1276 |
my $std = $dbh->prepare(q{ |
1263 |
FROM tmp_holdsqueue q |
1277 |
DELETE q, t |
1264 |
INNER JOIN hold_fill_targets t |
1278 |
FROM tmp_holdsqueue q |
1265 |
ON q.borrowernumber = t.borrowernumber |
1279 |
INNER JOIN hold_fill_targets t |
1266 |
AND q.biblionumber = t.biblionumber |
1280 |
ON q.borrowernumber = t.borrowernumber |
1267 |
AND q.itemnumber = t.itemnumber |
1281 |
AND q.biblionumber = t.biblionumber |
1268 |
AND q.item_level_request = t.item_level_request |
1282 |
AND q.itemnumber = t.itemnumber |
1269 |
AND q.holdingbranch = t.source_branchcode |
1283 |
AND q.item_level_request = t.item_level_request |
1270 |
WHERE t.reserve_id = ? |
1284 |
AND q.holdingbranch = t.source_branchcode |
1271 |
}); |
1285 |
WHERE t.reserve_id = ? |
1272 |
$std->execute($hold->reserve_id); |
1286 |
}); |
|
|
1287 |
$std->execute($id); |
1288 |
} |
1273 |
|
1289 |
|
1274 |
logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) |
1290 |
logaction( 'HOLDS', 'MODIFY', $hold->reserve_id, $hold ) |
1275 |
if C4::Context->preference('HoldsLog'); |
1291 |
if C4::Context->preference('HoldsLog'); |