View | Details | Raw Unified | Return to bug 9805
Collapse All | Expand All

(-)a/C4/Circulation.pm (-35 / +43 lines)
Lines 2986-3003 sub AddRenewal { Link Here
2986
        return;
2986
        return;
2987
    }
2987
    }
2988
2988
2989
    my $borrower = C4::Members::GetMemberDetails( $borrowernumber );
2990
    return unless $borrower;
2991
2989
    # If the due date wasn't specified, calculate it by adding the
2992
    # If the due date wasn't specified, calculate it by adding the
2990
    # book's loan length to today's date or the current due date
2993
    # book's loan length to today's date or the current due date
2991
    # based on the value of the RenewalPeriodBase syspref.
2994
    # based on the value of the RenewalPeriodBase syspref.
2992
    unless ($datedue) {
2995
    unless ($datedue) {
2996
        my $itemtype =
2997
          C4::Context->preference('item-level_itypes')
2998
          ? $biblio->{'itype'}
2999
          : $biblio->{'itemtype'};
2993
3000
2994
        my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber ) or return;
3001
        $datedue =
2995
        my $itemtype = (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'};
3002
          C4::Context->preference('RenewalPeriodBase') eq 'date_due'
3003
          ? dt_from_string( $issuedata->{date_due} )
3004
          : DateTime->now( time_zone => C4::Context->tz() );
2996
3005
2997
        $datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
3006
        $datedue = CalcDateDue( $datedue, $itemtype, $issuedata->{'branchcode'}, $borrower, 'is a renewal' );
2998
                                        dt_from_string( $issuedata->{date_due} ) :
2999
                                        DateTime->now( time_zone => C4::Context->tz());
3000
        $datedue =  CalcDateDue($datedue, $itemtype, $issuedata->{'branchcode'}, $borrower, 'is a renewal');
3001
    }
3007
    }
3002
3008
3003
    # Update the issues record to have the new due date, and a new count
3009
    # Update the issues record to have the new due date, and a new count
Lines 3013-3019 sub AddRenewal { Link Here
3013
    # Update the renewal count on the item, and tell zebra to reindex
3019
    # Update the renewal count on the item, and tell zebra to reindex
3014
    $renews = $biblio->{'renewals'} + 1;
3020
    $renews = $biblio->{'renewals'} + 1;
3015
3021
3016
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
3017
    my $schema = Koha::Database->new()->schema();
3022
    my $schema = Koha::Database->new()->schema();
3018
    my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => _GetCircControlBranch( $item, $borrower ) } );
3023
    my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => _GetCircControlBranch( $item, $borrower ) } );
3019
    $rule ||= $schema->resultset('DefaultCircRule')->single();
3024
    $rule ||= $schema->resultset('DefaultCircRule')->single();
Lines 3059-3085 sub AddRenewal { Link Here
3059
    }
3064
    }
3060
3065
3061
    # Send a renewal slip according to checkout alert preferencei
3066
    # Send a renewal slip according to checkout alert preferencei
3062
    if ( C4::Context->preference('RenewalSendNotice') eq '1') {
3067
    if ( C4::Context->preference('RenewalSendNotice') eq '1' ) {
3063
	my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 );
3068
        my $circulation_alert = 'C4::ItemCirculationAlertPreference';
3064
	my $circulation_alert = 'C4::ItemCirculationAlertPreference';
3069
        my %conditions        = (
3065
	my %conditions = (
3070
            branchcode   => $branch,
3066
		branchcode   => $branch,
3071
            categorycode => $borrower->{categorycode},
3067
		categorycode => $borrower->{categorycode},
3072
            item_type    => $item->{itype},
3068
		item_type    => $item->{itype},
3073
            notification => 'CHECKOUT',
3069
		notification => 'CHECKOUT',
3074
        );
3070
	);
3075
        if ( $circulation_alert->is_enabled_for( \%conditions ) ) {
3071
	if ($circulation_alert->is_enabled_for(\%conditions)) {
3076
            SendCirculationAlert(
3072
		SendCirculationAlert({
3077
                {
3073
			type     => 'RENEWAL',
3078
                    type     => 'RENEWAL',
3074
			item     => $item,
3079
                    item     => $item,
3075
		borrower => $borrower,
3080
                    borrower => $borrower,
3076
		branch   => $branch,
3081
                    branch   => $branch,
3077
		});
3082
                }
3078
	}
3083
            );
3084
        }
3079
    }
3085
    }
3080
3086
3081
    # Remove any OVERDUES related debarment if the borrower has no overdues
3087
    # Remove any OVERDUES related debarment if the borrower has no overdues
3082
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
3083
    if ( $borrowernumber
3088
    if ( $borrowernumber
3084
      && $borrower->{'debarred'}
3089
      && $borrower->{'debarred'}
3085
      && !C4::Members::HasOverdues( $borrowernumber )
3090
      && !C4::Members::HasOverdues( $borrowernumber )
Lines 3089-3103 sub AddRenewal { Link Here
3089
    }
3094
    }
3090
3095
3091
    # Log the renewal
3096
    # Log the renewal
3092
    UpdateStats({branch => $branch,
3097
    UpdateStats(
3093
                type => 'renew',
3098
        {
3094
                amount => $charge,
3099
            branch         => $branch,
3095
                itemnumber => $itemnumber,
3100
            type           => 'renew',
3096
                itemtype => $item->{itype},
3101
            amount         => $charge,
3097
                borrowernumber => $borrowernumber,
3102
            itemnumber     => $itemnumber,
3098
                ccode => $item->{'ccode'}}
3103
            itemtype       => $item->{itype},
3099
                );
3104
            borrowernumber => $borrowernumber,
3100
	return $datedue;
3105
            ccode          => $item->{'ccode'}
3106
        }
3107
    );
3108
3109
    return $datedue;
3101
}
3110
}
3102
3111
3103
sub GetRenewCount {
3112
sub GetRenewCount {
3104
- 

Return to bug 9805