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

(-)a/installer/data/mysql/atomicupdate/bug-18532.perl (+68 lines)
Line 0 Link Here
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 ignore into borrower_message_preferences (categorycode, message_attribute_id, days_in_advance, wants_digest)
33
        select 	c.categorycode, 7, NULL, 1
34
        from    categories c
35
        left join
36
                borrower_message_preferences p
37
        on      c.categorycode = p.categorycode
38
                and p.message_attribute_id = 7
39
        where   p.categorycode is null
40
41
    });
42
43
    $dbh->do( qq{
44
        insert ignore into borrower_message_preferences (borrowernumber, message_attribute_id, days_in_advance, wants_digest)
45
        select 	b.borrowernumber, 7, NULL, 1
46
        from    borrowers b
47
        left join
48
                borrower_message_preferences p
49
        on      b.borrowernumber = p.borrowernumber
50
                and p.message_attribute_id = 7
51
        where   p.borrowernumber is null
52
    });
53
54
    $dbh->do( qq{
55
        insert into borrower_message_transport_preferences (borrower_message_preference_id, message_transport_type)
56
        select  p.borrower_message_preference_id, 'email'
57
        from    borrower_message_preferences p
58
        left join
59
                borrower_message_transport_preferences t
60
        on      p.borrower_message_preference_id = t.borrower_message_preference_id
61
        where   p.message_attribute_id = 7
62
                and t.borrower_message_preference_id is null;
63
    });
64
65
    # Always end with this (adjust the bug info)
66
    SetVersion( $DBversion );
67
    print "Upgrade to $DBversion done (Bug 18532 - Add AUTO_RENEWALS in message_attributes and add AUTO_RENEWALS_DGST letter)\n";
68
}
(-)a/installer/data/mysql/en/mandatory/sample_notices.sql (+31 lines)
Lines 382-384 INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, Link Here
382
    </tr>
382
    </tr>
383
</tfoot>
383
</tfoot>
384
</table>', 'print', 'default');
384
</table>', 'print', 'default');
385
386
INSERT INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS', 'notification on auto renewing', 'Auto renewals',
387
"Dear [% borrower.firstname %] [% borrower.surname %],
388
[% IF checkout.auto_renew_error %]
389
The following item [% biblio.title %] has not been correctly renewed
390
[% IF checkout.auto_renew_error == 'too_many' %]
391
You have reach the maximum of checkouts possible.
392
[% ELSIF checkout.auto_renew_error == 'on_reserve' %]
393
This item is on hold for another patron.
394
[% ELSIF checkout.auto_renew_error == 'restriction' %]
395
You are currently restricted.
396
[% ELSIF checkout.auto_renew_error == 'overdue' %]
397
You have overdues.
398
[% ELSIF checkout.auto_renew_error == 'auto_too_late' %]
399
It\'s too late to renew this checkout.
400
[% ELSIF checkout.auto_renew_error == 'auto_too_much_oweing' %]
401
You have too much unpaid fines.
402
[% END %]
403
[% ELSE %]
404
The following item [% biblio.title %] has correctly been renewed and is now due [% checkout.date_due %]
405
[% END %]", 'email');
406
407
INSERT INTO letter (module, code, name, title, content, message_transport_type) VALUES ('circulation', 'AUTO_RENEWALS_DGST', 'notification on auto renewing', 'Auto renewals (Digest)',
408
"Dear [% borrower.firstname %] [% borrower.surname %],
409
[% IF <<error>> %]
410
There were <<error>> items that where not correctly renewed.
411
[% END %]
412
[% IF <<success>> %]
413
There were <<success>> items that where correctly renewed.
414
[% END %]
415
", 'email');
(-)a/installer/data/mysql/mandatory/sample_notices_message_attributes.sql (-1 / +2 lines)
Lines 5-9 values Link Here
5
(2, 'Advance_Notice', 1),
5
(2, 'Advance_Notice', 1),
6
(4, 'Hold_Filled', 0),
6
(4, 'Hold_Filled', 0),
7
(5, 'Item_Check_in', 0),
7
(5, 'Item_Check_in', 0),
8
(6, 'Item_Checkout', 0);
8
(6, 'Item_Checkout', 0),
9
(7, 'Auto_Renewals', 0);
9
10
(-)a/installer/data/mysql/mandatory/sample_notices_message_transports.sql (-2 / +5 lines)
Lines 17-20 values Link Here
17
(5, 'email', 0, 'circulation', 'CHECKIN'),
17
(5, 'email', 0, 'circulation', 'CHECKIN'),
18
(5, 'sms',   0, 'circulation', 'CHECKIN'),
18
(5, 'sms',   0, 'circulation', 'CHECKIN'),
19
(6, 'email', 0, 'circulation', 'CHECKOUT'),
19
(6, 'email', 0, 'circulation', 'CHECKOUT'),
20
(6, 'sms',   0, 'circulation', 'CHECKOUT');
20
(6, 'sms',   0, 'circulation', 'CHECKOUT'),
21
(7, 'email', 0, 'circulation', 'AUTO_RENEWALS'),
22
(7, 'sms', 0, 'circulation', 'AUTO_RENEWALS'),
23
(7, 'email', 1, 'circulation', 'AUTO_RENEWALS_DGST'),
24
(7, 'sms', 1, 'circulation', 'AUTO_RENEWALS_DGST');
21
- 

Return to bug 18532