Lines 98-105
GetOptions(
Link Here
|
98 |
|
98 |
|
99 |
pod2usage(0) if $help; |
99 |
pod2usage(0) if $help; |
100 |
|
100 |
|
101 |
my $send_notices_pref = C4::Context->preference('AutoRenewalNotices') |
101 |
my $send_notices_pref = C4::Context->preference('AutoRenewalNotices'); |
102 |
if ( $send_notices_pref = 'cron' ) { |
102 |
if ( $send_notices_pref eq 'cron' ) { |
103 |
warn <<'END_WARN'; |
103 |
warn <<'END_WARN'; |
104 |
|
104 |
|
105 |
The "AutoRenewalNotices" syspref is set to 'Follow the cron switch'. |
105 |
The "AutoRenewalNotices" syspref is set to 'Follow the cron switch'. |
Lines 144-149
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
144 |
$borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $auto_renew->borrowernumber, |
144 |
$borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $auto_renew->borrowernumber, |
145 |
message_name => 'auto_renewals' } ) if $send_notices_pref eq 'preferences'; |
145 |
message_name => 'auto_renewals' } ) if $send_notices_pref eq 'preferences'; |
146 |
|
146 |
|
|
|
147 |
$send_notices = 1 if !$send_notices && $send_notices_pref eq 'preferences' && $borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email}; |
148 |
|
147 |
# CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script |
149 |
# CanBookBeRenewed returns 'auto_renew' when the renewal should be done by this script |
148 |
my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber, undef, 1 ); |
150 |
my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber, undef, 1 ); |
149 |
if ( $error eq 'auto_renew' ) { |
151 |
if ( $error eq 'auto_renew' ) { |
Lines 155-161
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
155 |
my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0 ); |
157 |
my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0 ); |
156 |
$auto_renew->auto_renew_error(undef)->store; |
158 |
$auto_renew->auto_renew_error(undef)->store; |
157 |
} |
159 |
} |
158 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew unless $borrower_preferences && (!$borrower_preferences->{transports} || !$borrower_preferences->{transports}->{email} || $borrower_preferences->{'wants_digest'}); |
160 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew unless $send_notices_pref ne 'cron' && (!$borrower_preferences || !$borrower_preferences->{transports} || !$borrower_preferences->{transports}->{email} || $borrower_preferences->{'wants_digest'}); |
159 |
} elsif ( $error eq 'too_many' |
161 |
} elsif ( $error eq 'too_many' |
160 |
or $error eq 'on_reserve' |
162 |
or $error eq 'on_reserve' |
161 |
or $error eq 'restriction' |
163 |
or $error eq 'restriction' |
Lines 173-179
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
173 |
if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) { |
175 |
if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) { |
174 |
$auto_renew->auto_renew_error($error)->store if $confirm; |
176 |
$auto_renew->auto_renew_error($error)->store if $confirm; |
175 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
177 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
176 |
if $error ne 'auto_too_soon' && (!$borrower_preferences || ($borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && !$borrower_preferences->{'wants_digest'})); # Do not notify if it's too soon |
178 |
if $error ne 'auto_too_soon' && ($send_notices_pref eq 'cron' || ($borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && !$borrower_preferences->{'wants_digest'})); # Do not notify if it's too soon |
177 |
} |
179 |
} |
178 |
} |
180 |
} |
179 |
|
181 |
|
Lines 182-190
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
182 |
if ($digest_per_branch) { |
184 |
if ($digest_per_branch) { |
183 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; |
185 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; |
184 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error == 'auto_too_soon' ; |
186 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error == 'auto_too_soon' ; |
|
|
187 |
push @{$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; |
185 |
} else { |
188 |
} else { |
186 |
$renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew'; |
189 |
$renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew'; |
187 |
$renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon' ; |
190 |
$renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon' ; |
|
|
191 |
push @{$renew_digest->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; |
188 |
} |
192 |
} |
189 |
} |
193 |
} |
190 |
|
194 |
|
Lines 293-298
sub send_digests {
Link Here
|
293 |
error => $digest->{error}||0, |
297 |
error => $digest->{error}||0, |
294 |
success => $digest->{success}||0, |
298 |
success => $digest->{success}||0, |
295 |
}, |
299 |
}, |
|
|
300 |
loops => { issues => \@{$digest->{issues}} }, |
296 |
tables => { |
301 |
tables => { |
297 |
borrowers => $patron->borrowernumber, |
302 |
borrowers => $patron->borrowernumber, |
298 |
}, |
303 |
}, |
299 |
- |
|
|