Lines 148-154
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
148 |
|
148 |
|
149 |
# 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 |
150 |
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 ); |
|
|
151 |
my $updated; |
151 |
if ( $error eq 'auto_renew' ) { |
152 |
if ( $error eq 'auto_renew' ) { |
|
|
153 |
$updated = 1; |
152 |
if ($verbose) { |
154 |
if ($verbose) { |
153 |
say sprintf "Issue id: %s for borrower: %s and item: %s %s be renewed.", |
155 |
say sprintf "Issue id: %s for borrower: %s and item: %s %s be renewed.", |
154 |
$auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $confirm ? 'will' : 'would'; |
156 |
$auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $confirm ? 'will' : 'would'; |
Lines 172-193
while ( my $auto_renew = $auto_renews->next ) {
Link Here
|
172 |
say sprintf "Issue id: %s for borrower: %s and item: %s %s not be renewed. (%s)", |
174 |
say sprintf "Issue id: %s for borrower: %s and item: %s %s not be renewed. (%s)", |
173 |
$auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $confirm ? 'will' : 'would', $error; |
175 |
$auto_renew->issue_id, $auto_renew->borrowernumber, $auto_renew->itemnumber, $confirm ? 'will' : 'would', $error; |
174 |
} |
176 |
} |
175 |
if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) { |
177 |
$updated = 1 if ($error ne $auto_renew->auto_renew_error); |
|
|
178 |
if ( not $auto_renew->auto_renew_error or $updated ) { |
176 |
$auto_renew->auto_renew_error($error)->store if $confirm; |
179 |
$auto_renew->auto_renew_error($error)->store if $confirm; |
177 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
180 |
push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew |
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 |
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 |
179 |
} |
182 |
} |
180 |
} |
183 |
} |
181 |
|
184 |
|
182 |
if ( $error ne 'auto_too_soon' && $borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && $borrower_preferences->{'wants_digest'} ) { |
185 |
if ( $borrower_preferences && $borrower_preferences->{transports} && $borrower_preferences->{transports}->{email} && $borrower_preferences->{'wants_digest'} ) { |
183 |
# cache this one to process after we've run through all of the items. |
186 |
# cache this one to process after we've run through all of the items. |
184 |
if ($digest_per_branch) { |
187 |
if ($digest_per_branch) { |
185 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; |
188 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew'; |
186 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew'; |
189 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew'; |
187 |
push @{$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; |
190 |
push @{$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; |
|
|
191 |
$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{updated} = 1 if $updated && $error ne 'auto_too_soon'; |
188 |
} else { |
192 |
} else { |
189 |
$renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew'; |
193 |
$renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew'; |
190 |
$renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew'; |
194 |
$renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew'; |
|
|
195 |
$renew_digest->{ $auto_renew->borrowernumber }->{updated} = 1 if $updated && $error ne 'auto_too_soon'; |
191 |
push @{$renew_digest->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; |
196 |
push @{$renew_digest->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber; |
192 |
} |
197 |
} |
193 |
} |
198 |
} |
Lines 271-276
sub send_digests {
Link Here
|
271 |
my $params = shift; |
276 |
my $params = shift; |
272 |
|
277 |
|
273 |
PATRON: while ( my ( $borrowernumber, $digest ) = each %{$params->{digests}} ) { |
278 |
PATRON: while ( my ( $borrowernumber, $digest ) = each %{$params->{digests}} ) { |
|
|
279 |
next unless defined $digest->{updated} && $digest->{updated} == 1; |
274 |
my $borrower_preferences = |
280 |
my $borrower_preferences = |
275 |
C4::Members::Messaging::GetMessagingPreferences( |
281 |
C4::Members::Messaging::GetMessagingPreferences( |
276 |
{ |
282 |
{ |
277 |
- |
|
|