|
Lines 483-495
sub CanItemBeReserved {
Link Here
|
| 483 |
branchcode => $reserves_control_branch, |
483 |
branchcode => $reserves_control_branch, |
| 484 |
rules => ['holds_per_record','holds_per_day','opacitemholds'] |
484 |
rules => ['holds_per_record','holds_per_day','opacitemholds'] |
| 485 |
}); |
485 |
}); |
|
|
486 |
my $branchitemrule = |
| 487 |
C4::Circulation::GetBranchItemRule( $reserves_control_branch, $item->effective_itemtype ); |
| 488 |
|
| 489 |
$rights->{holdallowed} = $branchitemrule->{holdallowed}; |
| 490 |
|
| 486 |
my $holds_per_record = $rights->{holds_per_record} // 1; |
491 |
my $holds_per_record = $rights->{holds_per_record} // 1; |
| 487 |
my $holds_per_day = $rights->{holds_per_day}; |
492 |
my $holds_per_day = $rights->{holds_per_day}; |
| 488 |
my $opacitemholds = $rights->{opacitemholds} // 'Y'; |
493 |
my $opacitemholds = $rights->{opacitemholds} // 'Y'; |
| 489 |
|
494 |
|
| 490 |
if ( defined $holds_per_record && $holds_per_record ne '' ){ |
495 |
if ( defined $holds_per_record && $holds_per_record ne '' ){ |
| 491 |
if ( $holds_per_record == 0 ) { |
496 |
if ( $holds_per_record == 0 ) { |
| 492 |
return { status => "noReservesAllowed" }; |
497 |
return { status => "noReservesAllowed", rights => $rights }; |
| 493 |
} |
498 |
} |
| 494 |
if ( !$params->{ignore_hold_counts} ) { |
499 |
if ( !$params->{ignore_hold_counts} ) { |
| 495 |
my $search_params = { |
500 |
my $search_params = { |
|
Lines 498-504
sub CanItemBeReserved {
Link Here
|
| 498 |
}; |
503 |
}; |
| 499 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
504 |
$search_params->{found} = undef if $params->{ignore_found_holds}; |
| 500 |
my $holds = Koha::Holds->search($search_params); |
505 |
my $holds = Koha::Holds->search($search_params); |
| 501 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record } if $holds->count() >= $holds_per_record; |
506 |
return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record, rights => $rights } if $holds->count() >= $holds_per_record; |
| 502 |
} |
507 |
} |
| 503 |
} |
508 |
} |
| 504 |
|
509 |
|
|
Lines 508-514
sub CanItemBeReserved {
Link Here
|
| 508 |
borrowernumber => $patron->borrowernumber, |
513 |
borrowernumber => $patron->borrowernumber, |
| 509 |
reservedate => dt_from_string->date |
514 |
reservedate => dt_from_string->date |
| 510 |
}); |
515 |
}); |
| 511 |
return { status => 'tooManyReservesToday', limit => $holds_per_day } if $today_holds->count() >= $holds_per_day; |
516 |
return { status => 'tooManyReservesToday', limit => $holds_per_day, rights => $rights } if $today_holds->count() >= $holds_per_day; |
| 512 |
} |
517 |
} |
| 513 |
|
518 |
|
| 514 |
# we check if it's ok or not |
519 |
# we check if it's ok or not |
|
Lines 550-556
sub CanItemBeReserved {
Link Here
|
| 550 |
$reservecount = $rowcount->{count}; |
555 |
$reservecount = $rowcount->{count}; |
| 551 |
} |
556 |
} |
| 552 |
|
557 |
|
| 553 |
return { status => 'tooManyReserves', limit => $allowedreserves } if $reservecount >= $allowedreserves; |
558 |
return { status => 'tooManyReserves', limit => $allowedreserves, rights => $rights } if $reservecount >= $allowedreserves; |
| 554 |
} |
559 |
} |
| 555 |
} |
560 |
} |
| 556 |
|
561 |
|
|
Lines 569-594
sub CanItemBeReserved {
Link Here
|
| 569 |
} |
574 |
} |
| 570 |
)->count(); |
575 |
)->count(); |
| 571 |
|
576 |
|
| 572 |
return { status => 'tooManyReserves', limit => $rule->rule_value} if $total_holds_count >= $rule->rule_value; |
577 |
return { status => 'tooManyReserves', limit => $rule->rule_value, rights => $rights } if $total_holds_count >= $rule->rule_value; |
| 573 |
} |
578 |
} |
| 574 |
|
579 |
|
| 575 |
my $branchitemrule = |
|
|
| 576 |
C4::Circulation::GetBranchItemRule( $reserves_control_branch, $item->effective_itemtype ); |
| 577 |
|
| 578 |
if ( $branchitemrule->{holdallowed} eq 'not_allowed' ) { |
580 |
if ( $branchitemrule->{holdallowed} eq 'not_allowed' ) { |
| 579 |
return { status => 'notReservable' }; |
581 |
return { status => 'notReservable', rights => $rights }; |
| 580 |
} |
582 |
} |
| 581 |
|
583 |
|
| 582 |
if ( $branchitemrule->{holdallowed} eq 'from_home_library' |
584 |
if ( $branchitemrule->{holdallowed} eq 'from_home_library' |
| 583 |
&& $borrower->{branchcode} ne $item->homebranch ) |
585 |
&& $borrower->{branchcode} ne $item->homebranch ) |
| 584 |
{ |
586 |
{ |
| 585 |
return { status => 'cannotReserveFromOtherBranches' }; |
587 |
return { status => 'cannotReserveFromOtherBranches', rights => $rights }; |
| 586 |
} |
588 |
} |
| 587 |
|
589 |
|
| 588 |
my $item_library = Koha::Libraries->find( {branchcode => $item->homebranch} ); |
590 |
my $item_library = Koha::Libraries->find( {branchcode => $item->homebranch} ); |
| 589 |
if ( $branchitemrule->{holdallowed} eq 'from_local_hold_group') { |
591 |
if ( $branchitemrule->{holdallowed} eq 'from_local_hold_group') { |
| 590 |
if($patron->branchcode ne $item->homebranch && !$item_library->validate_hold_sibling( {branchcode => $patron->branchcode} )) { |
592 |
if($patron->branchcode ne $item->homebranch && !$item_library->validate_hold_sibling( {branchcode => $patron->branchcode} )) { |
| 591 |
return { status => 'branchNotInHoldGroup' }; |
593 |
return { status => 'branchNotInHoldGroup', rights => $rights }; |
| 592 |
} |
594 |
} |
| 593 |
} |
595 |
} |
| 594 |
|
596 |
|
|
Lines 598-616
sub CanItemBeReserved {
Link Here
|
| 598 |
}); |
600 |
}); |
| 599 |
|
601 |
|
| 600 |
unless ($destination) { |
602 |
unless ($destination) { |
| 601 |
return { status => 'libraryNotFound' }; |
603 |
return { status => 'libraryNotFound', rights => $rights }; |
| 602 |
} |
604 |
} |
| 603 |
unless ($destination->pickup_location) { |
605 |
unless ($destination->pickup_location) { |
| 604 |
return { status => 'libraryNotPickupLocation' }; |
606 |
return { status => 'libraryNotPickupLocation', rigths => $rights }; |
| 605 |
} |
607 |
} |
| 606 |
unless ($item->can_be_transferred({ to => $destination })) { |
608 |
unless ($item->can_be_transferred({ to => $destination })) { |
| 607 |
return { status => 'cannotBeTransferred' }; |
609 |
return { status => 'cannotBeTransferred', rights => $rights }; |
| 608 |
} |
610 |
} |
| 609 |
if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup' && !$item_library->validate_hold_sibling( {branchcode => $pickup_branchcode} )) { |
611 |
if ($branchitemrule->{hold_fulfillment_policy} eq 'holdgroup' && !$item_library->validate_hold_sibling( {branchcode => $pickup_branchcode} )) { |
| 610 |
return { status => 'pickupNotInHoldGroup' }; |
612 |
return { status => 'pickupNotInHoldGroup', rights => $rights }; |
| 611 |
} |
613 |
} |
| 612 |
if ($branchitemrule->{hold_fulfillment_policy} eq 'patrongroup' && !Koha::Libraries->find({branchcode => $borrower->{branchcode}})->validate_hold_sibling({branchcode => $pickup_branchcode})) { |
614 |
if ($branchitemrule->{hold_fulfillment_policy} eq 'patrongroup' && !Koha::Libraries->find({branchcode => $borrower->{branchcode}})->validate_hold_sibling({branchcode => $pickup_branchcode})) { |
| 613 |
return { status => 'pickupNotInHoldGroup' }; |
615 |
return { status => 'pickupNotInHoldGroup', rights => $rights }; |
| 614 |
} |
616 |
} |
| 615 |
} |
617 |
} |
| 616 |
|
618 |
|