Bug 18532: (follow-up) Remove digest switch and add preference
[srvgit] / installer / data / mysql / atomicupdate / bug-18532.perl
1 $DBversion = 'XXX'; # will be replaced by the RM
2 if( CheckVersion( $DBversion ) ) {
3     # you can use $dbh here like:
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)',
6         "Dear [% borrower.firstname %] [% borrower.surname %],
7         [% IF checkout.auto_renew_errors %]
8         There were [% checkout.auto_renew_errors %] items that where not correctly renewed.
9         [% END %]
10         [% IF checkout.auto_renew %]
11         There were [% checkout.auto_renew %] items that where correctly renewed.
12         [% END %]
13         ", 'email');
14     });
15
16     $dbh->do( qq{
17         INSERT IGNORE INTO `message_attributes`
18             (`message_attribute_id`, message_name, `takes_days`)
19         VALUES (7, 'Auto_Renewals', 0)
20     });
21
22     $dbh->do( qq{
23         INSERT IGNORE INTO `message_transports`
24             (`message_attribute_id`, `message_transport_type`, `is_digest`, `letter_module`, `letter_code`)
25         VALUES  (7, 'email', 0, 'circulation', 'AUTO_RENEWALS'),
26                 (7, 'sms', 0, 'circulation', 'AUTO_RENEWALS'),
27                 (7, 'email', 1, 'circulation', 'AUTO_RENEWALS_DGST'),
28                 (7, 'sms', 1, 'circulation', 'AUTO_RENEWALS_DGST')
29     });
30
31     $dbh->do( qq{
32         insert into borrower_message_transport_preferences (borrower_message_preference_id, message_transport_type)
33         select  p.borrower_message_preference_id, 'email'
34         from    borrower_message_preferences p
35         left join
36                 borrower_message_transport_preferences t
37         on      p.borrower_message_preference_id = t.borrower_message_preference_id
38         where   p.message_attribute_id = 7
39                 and t.borrower_message_preference_id is null;
40     });
41
42      $dbh->do(q{
43          INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
44          VALUES ('AutoRenewalNotices','cron','cron|preferences|never','How should Koha determine whether to end autorenewal notices','Choice')
45      });
46
47     NewVersion( $DBversion, 18532, 'Messaging preferences for auto renewals' );
48 }