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

(-)a/misc/cronjobs/automatic_renewals.pl (-10 / +9 lines)
Lines 108-115 to 'Never send emails' or 'Follow patron messaging preferences' Link Here
108
108
109
END_WARN
109
END_WARN
110
} else {
110
} else {
111
    # If not following cron then we should not send if set to never
111
    # If not following cron then:
112
    # and always send any generated according to preferences if following those
112
    # - we should not send if set to never
113
    # - we will send any notice generated according to preferences if following those
113
    $send_notices = $send_notices_pref eq 'never' ? 0 : 1;
114
    $send_notices = $send_notices_pref eq 'never' ? 0 : 1;
114
}
115
}
115
116
Lines 140-146 my %report; Link Here
140
while ( my $auto_renew = $auto_renews->next ) {
141
while ( my $auto_renew = $auto_renews->next ) {
141
    print "examining item '" . $auto_renew->itemnumber . "' to auto renew\n" if $verbose;
142
    print "examining item '" . $auto_renew->itemnumber . "' to auto renew\n" if $verbose;
142
143
143
    my ( $borrower_preferences, $wants_email, $wants_digest );
144
    my ( $borrower_preferences, $wants_email, $wants_digest ) = ( undef, 0, 0 );
144
    if ( $send_notices_pref eq 'preferences' ){
145
    if ( $send_notices_pref eq 'preferences' ){
145
        $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences(
146
        $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences(
146
            {
147
            {
Lines 155-166 while ( my $auto_renew = $auto_renews->next ) { Link Here
155
        $wants_digest = 1
156
        $wants_digest = 1
156
            if $wants_email
157
            if $wants_email
157
            && $borrower_preferences->{wants_digest};
158
            && $borrower_preferences->{wants_digest};
159
    } else { # Preference is never or cron
160
        $wants_email = $send_notices;
161
        $wants_digest = 0;
158
    }
162
    }
159
163
160
    $send_notices = 1
161
      if !$send_notices
162
      && $wants_email;
163
164
    # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script
164
    # CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script
165
    my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber, undef, 1 );
165
    my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber, undef, 1 );
166
    my $updated;
166
    my $updated;
Lines 175-181 while ( my $auto_renew = $auto_renews->next ) { Link Here
175
            $auto_renew->auto_renew_error(undef)->store;
175
            $auto_renew->auto_renew_error(undef)->store;
176
        }
176
        }
177
        push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
177
        push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
178
            if $send_notices && !$wants_digest;
178
            if ( $wants_email ) && !$wants_digest;
179
    } elsif ( $error eq 'too_many'
179
    } elsif ( $error eq 'too_many'
180
        or $error eq 'on_reserve'
180
        or $error eq 'on_reserve'
181
        or $error eq 'restriction'
181
        or $error eq 'restriction'
Lines 194-200 while ( my $auto_renew = $auto_renews->next ) { Link Here
194
        if ( not $auto_renew->auto_renew_error or $updated ) {
194
        if ( not $auto_renew->auto_renew_error or $updated ) {
195
            $auto_renew->auto_renew_error($error)->store if $confirm;
195
            $auto_renew->auto_renew_error($error)->store if $confirm;
196
            push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
196
            push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
197
              if $error ne 'auto_too_soon' && ( $send_notices && !$wants_digest );    # Do not notify if it's too soon
197
              if $error ne 'auto_too_soon' && ( $wants_email  && !$wants_digest );    # Do not notify if it's too soon
198
        }
198
        }
199
    }
199
    }
200
200
201
- 

Return to bug 30222