Lines 140-150
my %report;
Link Here
|
140 |
while ( my $auto_renew = $auto_renews->next ) { |
140 |
while ( my $auto_renew = $auto_renews->next ) { |
141 |
print "examining item '" . $auto_renew->itemnumber . "' to auto renew\n" if $verbose; |
141 |
print "examining item '" . $auto_renew->itemnumber . "' to auto renew\n" if $verbose; |
142 |
|
142 |
|
143 |
my $borrower_preferences; |
143 |
my ( $borrower_preferences, $wants_email, $wants_digest ); |
144 |
$borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $auto_renew->borrowernumber, |
144 |
if ( $send_notices_pref eq 'preferences' ){ |
145 |
message_name => 'auto_renewals' } ) if $send_notices_pref eq 'preferences'; |
145 |
$borrower_preferences = C4::Members::Messaging::GetMessagingPreferences( |
|
|
146 |
{ |
147 |
borrowernumber => $auto_renew->borrowernumber, |
148 |
message_name => 'auto_renewals' |
149 |
} |
150 |
); |
151 |
$wants_email = 1 |
152 |
if $borrower_preferences |
153 |
&& $borrower_preferences->{transports} |
154 |
&& $borrower_preferences->{transports}->{email}; |
155 |
$wants_digest = 1 |
156 |
if $wants_email |
157 |
&& $borrower_preferences->{wants_digest}; |
158 |
} |
146 |
|
159 |
|
147 |
$send_notices = 1 if !$send_notices && $send_notices_pref eq 'preferences' && $borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email}; |
160 |
$send_notices = 1 |
|
|
161 |
if !$send_notices |
162 |
&& $wants_email; |
148 |
|
163 |
|
149 |
# 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 |
150 |
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 ); |
Lines 159-165
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
159 |
my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0 ); |
174 |
my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode, undef, undef, undef, 0 ); |
160 |
$auto_renew->auto_renew_error(undef)->store; |
175 |
$auto_renew->auto_renew_error(undef)->store; |
161 |
} |
176 |
} |
162 |
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'}); |
177 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
|
|
178 |
if $send_notices && !$wants_digest; |
163 |
} elsif ( $error eq 'too_many' |
179 |
} elsif ( $error eq 'too_many' |
164 |
or $error eq 'on_reserve' |
180 |
or $error eq 'on_reserve' |
165 |
or $error eq 'restriction' |
181 |
or $error eq 'restriction' |
Lines 178-188
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
178 |
if ( not $auto_renew->auto_renew_error or $updated ) { |
194 |
if ( not $auto_renew->auto_renew_error or $updated ) { |
179 |
$auto_renew->auto_renew_error($error)->store if $confirm; |
195 |
$auto_renew->auto_renew_error($error)->store if $confirm; |
180 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
196 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
181 |
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 |
197 |
if $error ne 'auto_too_soon' && ( $send_notices && !$wants_digest ); # Do not notify if it's too soon |
182 |
} |
198 |
} |
183 |
} |
199 |
} |
184 |
|
200 |
|
185 |
if ( $borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && $borrower_preferences->{'wants_digest'} ) { |
201 |
if ( $wants_digest ) { |
186 |
# cache this one to process after we've run through all of the items. |
202 |
# cache this one to process after we've run through all of the items. |
187 |
if ($digest_per_branch) { |
203 |
if ($digest_per_branch) { |
188 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; |
204 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; |
189 |
- |
|
|