Lines 1929-1940
sub can_be_recalled {
Link Here
|
1929 |
return 0 if ( scalar @items == 0 ); |
1929 |
return 0 if ( scalar @items == 0 ); |
1930 |
|
1930 |
|
1931 |
my $checked_out_count = 0; |
1931 |
my $checked_out_count = 0; |
|
|
1932 |
my $recallable_items = scalar @items; |
1932 |
foreach (@items) { |
1933 |
foreach (@items) { |
1933 |
if ( Koha::Checkouts->search({ itemnumber => $_->itemnumber })->count > 0 ){ $checked_out_count++; } |
1934 |
my $item_recalls_allowed = Koha::CirculationRules->get_effective_rule({ |
|
|
1935 |
branchcode => $branchcode, |
1936 |
categorycode => $patron ? $patron->categorycode : undef, |
1937 |
itemtype => $_->effective_itemtype, |
1938 |
rule_name => 'recalls_allowed', |
1939 |
}); |
1940 |
if ( $item_recalls_allowed->rule_value == 0 ) { |
1941 |
# item is not allowed to be recalled |
1942 |
$recallable_items--; |
1943 |
} elsif ( $_->holds({ found => [ 'W','T','P' ] })->count > 0 ) { |
1944 |
# item is allocated for another hold |
1945 |
$recallable_items--; |
1946 |
} elsif ( Koha::Checkouts->search({ itemnumber => $_->itemnumber })->count > 0 ) { |
1947 |
$checked_out_count++; |
1948 |
} |
1934 |
} |
1949 |
} |
1935 |
|
1950 |
|
1936 |
# can't recall if on shelf recalls only allowed when all unavailable, but items are still available for checkout |
1951 |
# can't recall if on shelf recalls only allowed when all unavailable, but items are still available for checkout |
1937 |
return 0 if ( $rule->{on_shelf_recalls} eq 'all' && $checked_out_count < scalar @items ); |
1952 |
return 0 if ( $rule->{on_shelf_recalls} eq 'all' && $checked_out_count < $recallable_items ); |
1938 |
|
1953 |
|
1939 |
# can't recall if no items have been checked out |
1954 |
# can't recall if no items have been checked out |
1940 |
return 0 if ( $checked_out_count == 0 ); |
1955 |
return 0 if ( $checked_out_count == 0 ); |
1941 |
- |
|
|