|
Lines 2753-2805
sub CanBookBeRenewed {
Link Here
|
| 2753 |
|
2753 |
|
| 2754 |
my $patron = $issue->patron or return; |
2754 |
my $patron = $issue->patron or return; |
| 2755 |
|
2755 |
|
| 2756 |
# override_limit will override anything else except on_reserve |
|
|
| 2757 |
unless ( $override_limit ){ |
| 2758 |
my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); |
| 2759 |
my $issuing_rule = Koha::CirculationRules->get_effective_rules( |
| 2760 |
{ |
| 2761 |
categorycode => $patron->categorycode, |
| 2762 |
itemtype => $item->effective_itemtype, |
| 2763 |
branchcode => $branchcode, |
| 2764 |
rules => [ |
| 2765 |
'renewalsallowed', |
| 2766 |
'lengthunit', |
| 2767 |
'unseen_renewals_allowed' |
| 2768 |
] |
| 2769 |
} |
| 2770 |
); |
| 2771 |
|
| 2772 |
return ( 0, "too_many" ) |
| 2773 |
if not $issuing_rule->{renewalsallowed} or $issuing_rule->{renewalsallowed} <= $issue->renewals; |
| 2774 |
|
| 2775 |
return ( 0, "too_unseen" ) |
| 2776 |
if C4::Context->preference('UnseenRenewals') && |
| 2777 |
$issuing_rule->{unseen_renewals_allowed} && |
| 2778 |
$issuing_rule->{unseen_renewals_allowed} <= $issue->unseen_renewals; |
| 2779 |
|
| 2780 |
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); |
| 2781 |
my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing'); |
| 2782 |
$patron = Koha::Patrons->find($borrowernumber); # FIXME Is this really useful? |
| 2783 |
my $restricted = $patron->is_debarred; |
| 2784 |
my $hasoverdues = $patron->has_overdues; |
| 2785 |
|
| 2786 |
if ( $restricted and $restrictionblockrenewing ) { |
| 2787 |
return ( 0, 'restriction'); |
| 2788 |
} elsif ( ($hasoverdues and $overduesblockrenewing eq 'block') || ($issue->is_overdue and $overduesblockrenewing eq 'blockitem') ) { |
| 2789 |
return ( 0, 'overdue'); |
| 2790 |
} |
| 2791 |
|
| 2792 |
$auto_renew = _CanBookBeAutoRenewed({ |
| 2793 |
patron => $patron, |
| 2794 |
item => $item, |
| 2795 |
branchcode => $branchcode, |
| 2796 |
issue => $issue |
| 2797 |
}); |
| 2798 |
return ( 0, $auto_renew ) if $auto_renew =~ 'auto_account_expired'; |
| 2799 |
return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_late'; |
| 2800 |
return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_much_oweing'; |
| 2801 |
} |
| 2802 |
|
| 2803 |
my ( $resfound, $resrec, $possible_reserves ) = C4::Reserves::CheckReserves($itemnumber); |
2756 |
my ( $resfound, $resrec, $possible_reserves ) = C4::Reserves::CheckReserves($itemnumber); |
| 2804 |
|
2757 |
|
| 2805 |
# If next hold is non priority, then check if any hold with priority (non_priority = 0) exists for the same biblionumber. |
2758 |
# If next hold is non priority, then check if any hold with priority (non_priority = 0) exists for the same biblionumber. |
|
Lines 2858-2872
sub CanBookBeRenewed {
Link Here
|
| 2858 |
} |
2811 |
} |
| 2859 |
} |
2812 |
} |
| 2860 |
} |
2813 |
} |
| 2861 |
if( $cron ) { #The cron wants to return 'too_soon' over 'on_reserve' |
2814 |
#The cron wants to return 'too_soon' over 'on_reserve' |
| 2862 |
return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok"; |
2815 |
return ( 0, "on_reserve" ) if $resfound && !$cron; |
| 2863 |
return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found |
2816 |
|
| 2864 |
} else { # For other purposes we want 'on_reserve' before 'too_soon' |
2817 |
# override_limit will override anything else except on_reserve |
| 2865 |
return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found |
2818 |
unless ( $override_limit ){ |
| 2866 |
return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok"; |
2819 |
my $branchcode = _GetCircControlBranch( $item->unblessed, $patron->unblessed ); |
|
|
2820 |
my $issuing_rule = Koha::CirculationRules->get_effective_rules( |
| 2821 |
{ |
| 2822 |
categorycode => $patron->categorycode, |
| 2823 |
itemtype => $item->effective_itemtype, |
| 2824 |
branchcode => $branchcode, |
| 2825 |
rules => [ |
| 2826 |
'renewalsallowed', |
| 2827 |
'lengthunit', |
| 2828 |
'unseen_renewals_allowed' |
| 2829 |
] |
| 2830 |
} |
| 2831 |
); |
| 2832 |
|
| 2833 |
return ( 0, "too_many" ) |
| 2834 |
if not $issuing_rule->{renewalsallowed} or $issuing_rule->{renewalsallowed} <= $issue->renewals; |
| 2835 |
|
| 2836 |
return ( 0, "too_unseen" ) |
| 2837 |
if C4::Context->preference('UnseenRenewals') && |
| 2838 |
$issuing_rule->{unseen_renewals_allowed} && |
| 2839 |
$issuing_rule->{unseen_renewals_allowed} <= $issue->unseen_renewals; |
| 2840 |
|
| 2841 |
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing'); |
| 2842 |
my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing'); |
| 2843 |
$patron = Koha::Patrons->find($borrowernumber); # FIXME Is this really useful? |
| 2844 |
my $restricted = $patron->is_debarred; |
| 2845 |
my $hasoverdues = $patron->has_overdues; |
| 2846 |
|
| 2847 |
if ( $restricted and $restrictionblockrenewing ) { |
| 2848 |
return ( 0, 'restriction'); |
| 2849 |
} elsif ( ($hasoverdues and $overduesblockrenewing eq 'block') || ($issue->is_overdue and $overduesblockrenewing eq 'blockitem') ) { |
| 2850 |
return ( 0, 'overdue'); |
| 2851 |
} |
| 2852 |
|
| 2853 |
$auto_renew = _CanBookBeAutoRenewed({ |
| 2854 |
patron => $patron, |
| 2855 |
item => $item, |
| 2856 |
branchcode => $branchcode, |
| 2857 |
issue => $issue |
| 2858 |
}); |
| 2859 |
return ( 0, $auto_renew ) if $auto_renew =~ 'auto_account_expired'; |
| 2860 |
return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_late'; |
| 2861 |
return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_much_oweing'; |
| 2867 |
} |
2862 |
} |
| 2868 |
|
2863 |
|
| 2869 |
return ( 0, "auto_renew" ) if $auto_renew eq "ok" && !$override_limit; # 0 if auto-renewal should not succeed |
2864 |
return ( 0, $auto_renew ) if $auto_renew =~ 'too_soon';#$auto_renew ne "no" && $auto_renew ne "ok"; |
|
|
2865 |
return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found |
| 2866 |
return ( 0, "auto_renew" ) if $auto_renew eq "ok"; # 0 if auto-renewal should not succeed |
| 2870 |
|
2867 |
|
| 2871 |
return ( 1, undef ); |
2868 |
return ( 1, undef ); |
| 2872 |
} |
2869 |
} |
| 2873 |
- |
|
|