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

(-)a/installer/data/mysql/atomicupdate/bug-18532.perl (-4 / +12 lines)
Lines 4-14 if( CheckVersion( $DBversion ) ) { Link Here
4
    $dbh->do( qq{
4
    $dbh->do( qq{
5
        INSERT IGNORE INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS_DGST', 'notification on auto renewing', 'Auto renewals (Digest)',
5
        INSERT IGNORE INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS_DGST', 'notification on auto renewing', 'Auto renewals (Digest)',
6
        "Dear [% borrower.firstname %] [% borrower.surname %],
6
        "Dear [% borrower.firstname %] [% borrower.surname %],
7
        [% IF checkout.auto_renew_errors %]
7
        [% IF error %]
8
        There were [% checkout.auto_renew_errors %] items that where not correctly renewed.
8
            There were [% error %] items that were not correctly renewed.
9
        [% END %]
9
        [% END %]
10
        [% IF checkout.auto_renew %]
10
        [% IF success %]
11
        There were [% checkout.auto_renew %] items that where correctly renewed.
11
            There were [% success %] items that where correctly renewed.
12
        [% END %]
13
        [% FOREACH checkout IN checkouts %]
14
            [% checkout.item.biblio.title %] : [% checkout.item.barcode %]
15
            [% IF !checkout.auto_renew_error %]
16
                was renewed until [% checkout.date_due %]
17
            [% ELSE %]
18
                was not renewed with error: [% checkout.auto_renew_error %]
19
            [% END %]
12
        [% END %]
20
        [% END %]
13
        ", 'email');
21
        ", 'email');
14
    });
22
    });
(-)a/installer/data/mysql/pl-PL/mandatory/sample_notices.sql (-17 / +14 lines)
Lines 397-420 Your total unpaid fines are too high. Link Here
397
[% ELSE %]
397
[% ELSE %]
398
The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due | $KohaDates as_due_date => 1 %]
398
The following item, [% biblio.title %], has correctly been renewed and is now due on [% checkout.date_due | $KohaDates as_due_date => 1 %]
399
[% END %]", 'email');
399
[% END %]", 'email');
400
=======
401
You have overdues.
402
[% ELSIF checkout.auto_renew_error == 'auto_too_late' %]
403
It\'s too late to renew this checkout.
404
[% ELSIF checkout.auto_renew_error == 'auto_too_much_oweing' %]
405
You have too much unpaid fines.
406
[% END %]
407
[% ELSE %]
408
The following item [% biblio.title %] has correctly been renewed and is now due [% checkout.date_due %]
409
[% END %]", 'email');
410
400
411
INSERT INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS_DGST', 'notification on auto renewing', 'Auto renewals (Digest)',
401
INSERT IGNORE INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS_DGST', 'notification on auto renewing', 'Auto renewals (Digest)',
412
"Dear [% borrower.firstname %] [% borrower.surname %],
402
"Dear [% borrower.firstname %] [% borrower.surname %],
413
[% IF <<error>> %]
403
[% IF error %]
414
There were <<error>> items that where not correctly renewed.
404
    There were [% error %] items that were not correctly renewed.
405
[% END %]
406
[% IF success %]
407
    There were [% success %] items that where correctly renewed.
415
[% END %]
408
[% END %]
416
[% IF <<success>> %]
409
[% FOREACH checkout IN checkouts %]
417
There were <<success>> items that where correctly renewed.
410
    [% checkout.item.biblio.title %] : [% checkout.item.barcode %]
411
    [% IF !checkout.auto_renew_error %]
412
        was renewed until [% checkout.date_due | $KohaDates %]
413
    [% ELSE %]
414
        was not renewed with error: [% checkout.auto_renew_error %]
415
    [% END %]
418
[% END %]
416
[% END %]
419
", 'email');
417
", 'email');
420
>>>>>>> Bug 18532: Add new letter AUTO_RENEWALS_DGST, new Auto_Renewals in message_attributes, and configured message_transports:installer/data/mysql/en/mandatory/sample_notices.sql
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc (+1 lines)
Lines 13-18 Link Here
13
        <!-- <th>RSS</th> -->
13
        <!-- <th>RSS</th> -->
14
    </tr>
14
    </tr>
15
    [% FOREACH messaging_preference IN messaging_preferences %]
15
    [% FOREACH messaging_preference IN messaging_preferences %]
16
          [% NEXT IF messaging_preference.Auto_Renewals && Koha.Preference('AutoRenewalNotices') != 'preferences' %]
16
    <tr>
17
    <tr>
17
      <td>[% IF ( messaging_preference.Item_Due ) %]Item due
18
      <td>[% IF ( messaging_preference.Item_Due ) %]Item due
18
          [% ELSIF ( messaging_preference.Advance_Notice ) %]Advance notice
19
          [% ELSIF ( messaging_preference.Advance_Notice ) %]Advance notice
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt (+1 lines)
Lines 45-50 Link Here
45
                                </thead>
45
                                </thead>
46
                                <tbody>
46
                                <tbody>
47
                                [% FOREACH messaging_preference IN messaging_preferences %]
47
                                [% FOREACH messaging_preference IN messaging_preferences %]
48
                                    [% NEXT IF messaging_preference.Auto_Renewals && Koha.Preference('AutoRenewalNotices') != 'preferences' %]
48
                                    <tr>
49
                                    <tr>
49
                                        <td>[% IF ( messaging_preference.Item_Due ) %]Item due
50
                                        <td>[% IF ( messaging_preference.Item_Due ) %]Item due
50
                                              [% ELSIF ( messaging_preference.Advance_Notice ) %]Advance notice
51
                                              [% ELSIF ( messaging_preference.Advance_Notice ) %]Advance notice
(-)a/misc/cronjobs/automatic_renewals.pl (-5 / +9 lines)
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 );
150
    my ( $ok, $error ) = CanBookBeRenewed( $auto_renew->borrowernumber, $auto_renew->itemnumber );
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 );
157
            my $date_due = AddRenewal( $auto_renew->borrowernumber, $auto_renew->itemnumber, $auto_renew->branchcode );
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 172-178 while ( my $auto_renew = $auto_renews->next ) { Link Here
172
        if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) {
174
        if ( not $auto_renew->auto_renew_error or $error ne $auto_renew->auto_renew_error ) {
173
            $auto_renew->auto_renew_error($error)->store if $confirm;
175
            $auto_renew->auto_renew_error($error)->store if $confirm;
174
            push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
176
            push @{ $report{ $auto_renew->borrowernumber } }, $auto_renew
175
              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
177
              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
176
        }
178
        }
177
    }
179
    }
178
180
Lines 181-189 while ( my $auto_renew = $auto_renews->next ) { Link Here
181
        if ($digest_per_branch) {
183
        if ($digest_per_branch) {
182
            $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew';
184
            $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{success}++ if $error eq 'auto_renew';
183
            $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error == 'auto_too_soon' ;
185
            $renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error == 'auto_too_soon' ;
186
            push @{$renew_digest->{ $auto_renew->branchcode }->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber;
184
        } else {
187
        } else {
185
            $renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew';
188
            $renew_digest->{ $auto_renew->borrowernumber }->{success} ++ if $error eq 'auto_renew';
186
            $renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon' ;
189
            $renew_digest->{ $auto_renew->borrowernumber }->{error}++ unless $error eq 'auto_renew' || $error eq 'auto_too_soon' ;
190
            push @{$renew_digest->{ $auto_renew->borrowernumber }->{issues}}, $auto_renew->itemnumber;
187
        }
191
        }
188
    }
192
    }
189
193
Lines 292-297 sub send_digests { Link Here
292
                    error => $digest->{error}||0,
296
                    error => $digest->{error}||0,
293
                    success => $digest->{success}||0,
297
                    success => $digest->{success}||0,
294
                },
298
                },
299
                loops => { issues => \@{$digest->{issues}} },
295
                tables      => {
300
                tables      => {
296
                    borrowers => $patron->borrowernumber,
301
                    borrowers => $patron->borrowernumber,
297
                },
302
                },
298
- 

Return to bug 18532