-
- # if independent branches is on we need to check if the person can reserve
- # for branches they arent logged in to
- if ( C4::Context->preference("IndependantBranches") ) {
- if (! C4::Context->preference("canreservefromotherbranches")){
- # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
- my $userenv = C4::Context->userenv;
- if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
- $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
- }
- }
- }
- # An item is available only if:
- if (
- not defined $reservedate # not reserved yet
- and $issues->{'date_due'} eq '' # not currently on loan
- and not $item->{itemlost} # not lost
- and not $item->{notforloan} # not forbidden to loan
- and not $item->{cantreserve}
- and $transfertwhen eq '' # not currently on transfert
- )
- {
- $item->{available} = 1;
+
+ # if independent branches is on we need to check if the person can reserve
+ # for branches they arent logged in to
+ if ( C4::Context->preference("IndependantBranches") ) {
+ if (! C4::Context->preference("canreservefromotherbranches")){
+ # cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
+ my $userenv = C4::Context->userenv;
+ if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
+ $item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
+ }
+ }
+ }
+
+ my $branchitemrule = GetBranchItemRule( $item->{'homebranch'}, $item->{'itype'} );
+ my $policy_holdallowed = 1;
+
+ $item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
+
+ if ( $branchitemrule->{'holdallowed'} == 0 ||
+ ( $branchitemrule->{'holdallowed'} == 1 && $borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) ) {
+ $policy_holdallowed = 0;