]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0355.data.missing_pieces_format.sql
LP#1178377: Make bib source optional element from unapi.bre
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0355.data.missing_pieces_format.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0355'); -- phasefx
4
5 INSERT INTO action_trigger.hook (key,core_type,description,passive) VALUES 
6     (   'circ.format.missing_pieces.slip.print',
7         'circ', 
8         oils_i18n_gettext(
9             'circ.format.missing_pieces.slip.print',
10             'A missing pieces slip needs to be formatted for printing.',
11             'ath',
12             'description'
13         ), 
14         FALSE
15     )
16     ,(  'circ.format.missing_pieces.letter.print',
17         'circ', 
18         oils_i18n_gettext(
19             'circ.format.missing_pieces.letter.print',
20             'A missing pieces patron letter needs to be formatted for printing.',
21             'ath',
22             'description'
23         ), 
24         FALSE
25     )
26 ;
27
28 INSERT INTO action_trigger.event_definition (
29         id,
30         active,
31         owner,
32         name,
33         hook,
34         validator,
35         reactor,
36         group_field,
37         granularity,
38         template
39     ) VALUES (
40         33,
41         TRUE,
42         1,
43         'circ.missing_pieces.slip.print',
44         'circ.format.missing_pieces.slip.print',
45         'NOOP_True',
46         'ProcessTemplate',
47         'usr',
48         'print-on-demand',
49 $$
50 [%- USE date -%]
51 [%- SET user = target.0.usr -%]
52 <div style="li { padding: 8px; margin 5px; }">
53     <div>[% date.format %]</div><br/>
54     Missing pieces for:
55     <ol>
56     [% FOR circ IN target %]
57         <li>Barcode: [% circ.target_copy.barcode %] Transaction ID: [% circ.id %] Due: [% circ.due_date.format %]<br />
58             [% helpers.get_copy_bib_basics(circ.target_copy.id).title %]
59         </li>
60     [% END %]
61     </ol>
62 </div>
63 $$
64     )
65     ,(
66         34,
67         TRUE,
68         1,
69         'circ.missing_pieces.letter.print',
70         'circ.format.missing_pieces.letter.print',
71         'NOOP_True',
72         'ProcessTemplate',
73         'usr',
74         'print-on-demand',
75 $$
76 [%- USE date -%]
77 [%- SET user = target.0.usr -%]
78 [% date.format %]
79 Dear [% user.prefix %] [% user.first_given_name %] [% user.family_name %],
80
81 We are missing pieces for the following returned items:
82 [% FOR circ IN target %]
83 Barcode: [% circ.target_copy.barcode %] Transaction ID: [% circ.id %] Due: [% circ.due_date.format %]
84 [% helpers.get_copy_bib_basics(circ.target_copy.id).title %]
85 [% END %]
86
87 Please return these pieces as soon as possible.
88
89 Thanks!
90
91 Library Staff
92 $$
93     )
94 ;
95
96 INSERT INTO action_trigger.environment (
97         event_def,
98         path
99     ) VALUES -- for fleshing circ objects
100          ( 33, 'usr')
101         ,( 33, 'target_copy')
102         ,( 33, 'target_copy.circ_lib')
103         ,( 33, 'target_copy.circ_lib.mailing_address')
104         ,( 33, 'target_copy.circ_lib.billing_address')
105         ,( 33, 'target_copy.call_number')
106         ,( 33, 'target_copy.call_number.owning_lib')
107         ,( 33, 'target_copy.call_number.owning_lib.mailing_address')
108         ,( 33, 'target_copy.call_number.owning_lib.billing_address')
109         ,( 33, 'circ_lib')
110         ,( 33, 'circ_lib.mailing_address')
111         ,( 33, 'circ_lib.billing_address')
112         ,( 34, 'usr')
113         ,( 34, 'target_copy')
114         ,( 34, 'target_copy.circ_lib')
115         ,( 34, 'target_copy.circ_lib.mailing_address')
116         ,( 34, 'target_copy.circ_lib.billing_address')
117         ,( 34, 'target_copy.call_number')
118         ,( 34, 'target_copy.call_number.owning_lib')
119         ,( 34, 'target_copy.call_number.owning_lib.mailing_address')
120         ,( 34, 'target_copy.call_number.owning_lib.billing_address')
121         ,( 34, 'circ_lib')
122         ,( 34, 'circ_lib.mailing_address')
123         ,( 34, 'circ_lib.billing_address')
124 ;
125
126 -- DELETE FROM config.upgrade_log WHERE version = 'temp'; DELETE FROM action_trigger.event WHERE event_def IN (33,34); DELETE FROM action_trigger.environment WHERE event_def IN (33,34); DELETE FROM action_trigger.event_definition WHERE id IN (33,34); DELETE FROM action_trigger.hook WHERE key IN ( 'circ.format.missing_pieces.slip.print', 'circ.format.missing_pieces.letter.print' );
127
128 COMMIT;
129