]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/1235.schema.curbside.sql
LP1615805 No inputs after submit in patron search (AngularJS)
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 1235.schema.curbside.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1235', :eg_version);
4
5 CREATE TABLE action.curbside (
6     id          SERIAL      PRIMARY KEY,
7     patron      INT         NOT NULL REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
8     org         INT         NOT NULL REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
9     slot        TIMESTAMPTZ,
10     staged      TIMESTAMPTZ,
11     stage_staff     INT     REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
12     arrival     TIMESTAMPTZ,
13     delivered   TIMESTAMPTZ,
14     delivery_staff  INT     REFERENCES actor.usr (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
15     notes       TEXT
16 );
17
18 INSERT INTO config.org_unit_setting_type (name, label, grp, description, datatype)
19 VALUES (
20     'circ.curbside',
21     'Enable curbside pickup functionality at library.',
22     'circ',
23     'When set to TRUE, enable staff and public interfaces to schedule curbside pickup of holds that become available for pickup.',
24     'bool'
25 );
26
27 INSERT INTO config.org_unit_setting_type (name, label, grp, description, datatype)
28 VALUES (
29     'circ.curbside.granularity',
30     'Time interval between curbside appointments',
31     'circ',
32     'Time interval between curbside appointments',
33     'interval'
34 );
35
36 INSERT INTO config.org_unit_setting_type (name, label, grp, description, datatype)
37 VALUES (
38     'circ.curbside.max_concurrent',
39     'Maximum number of patrons that may select a particular curbside pickup time',
40     'circ',
41     'Maximum number of patrons that may select a particular curbside pickup time',
42     'integer'
43 );
44
45 INSERT INTO config.org_unit_setting_type (name, label, grp, description, datatype)
46 VALUES (
47     'circ.curbside.disable_patron_input',
48     'Disable patron modification of curbside appointments in public catalog',
49     'circ',
50     'When set to TRUE, patrons cannot use the My Account interface to select curbside pickup times',
51     'bool'
52 );
53
54 INSERT INTO actor.org_unit_setting (org_unit, name, value)
55     SELECT id, 'circ.curbside', 'false' FROM actor.org_unit WHERE parent_ou IS NULL
56         UNION
57     SELECT id, 'circ.curbside.max_concurrent', '10' FROM actor.org_unit WHERE parent_ou IS NULL
58         UNION
59     SELECT id, 'circ.curbside.granularity', '"15 minutes"' FROM actor.org_unit WHERE parent_ou IS NULL
60 ;
61
62 INSERT INTO action_trigger.hook (key, core_type, description, passive)
63 VALUES (
64     'hold.offer_curbside',
65     'ahr',
66     oils_i18n_gettext(
67         'hold.offer_curbside',
68         'Hook used to trigger the notification of an offer of curbside pickup',
69         'ath',
70         'description'
71     ),
72     FALSE
73 );
74
75 INSERT INTO action_trigger.hook (key, core_type, description, passive)
76 VALUES (
77     'hold.confirm_curbside',
78     'acsp',
79     oils_i18n_gettext(
80         'hold.confirm_curbside',
81         'Hook used to trigger the notification of the creation or update of a curbside pickup appointment with an arrival URL',
82         'ath',
83         'description'
84     ),
85     FALSE
86 );
87
88 INSERT INTO action_trigger.reactor (module, description) VALUES (
89     'CurbsideSlot', 'Create a curbside pickup appointment slot when necessary'
90 );
91
92 INSERT INTO action_trigger.validator (module, description) VALUES (
93     'Curbside', 'Confirm that curbside pickup is enabled for the hold pickup library'
94 );
95
96 ------------------- Disabled example A/T defintions ------------------------------
97
98 -- Create a "dummy" slot when applicable, and trigger the "offer curbside" events
99 INSERT INTO action_trigger.event_definition (
100     active,
101     owner,
102     name,
103     hook,
104     validator,
105     reactor,
106     delay
107 ) VALUES (
108     'f',
109     1,
110     'Trigger curbside offer events and create a placeholder for the patron, where applicable',
111     'hold.available',
112     'Curbside',
113     'CurbsideSlot',
114     '00:30:00'
115 );
116
117 -- Email offer
118 INSERT INTO action_trigger.event_definition (
119     active,
120     owner,
121     name,
122     hook,
123     validator,
124     reactor,
125     delay,
126     delay_field,
127     group_field,
128     template
129 ) VALUES (
130     'f',
131     1,
132     'Curbside offer Email notification, triggered by CurbsideSlot reactor on a definition attached to the hold.available hook',
133     'hold.offer_curbside',
134     'Curbside',
135     'SendEmail',
136     '00:00:00',
137     'shelf_time',
138     'usr',
139 $$
140 [%- USE date -%]
141 [%- user = target.0.usr -%]
142 To: [%- params.recipient_email || user.email %]
143 From: [%- params.sender_email || default_sender %]
144 Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
145 Subject: Curbside Pickup
146 Auto-Submitted: auto-generated
147
148 [% target.0.pickup_lib.name %] is now offering curbside delivery
149 service.  Please call [% target.0.pickup_lib.phone %] or visit the
150 link below to schedule a pickup time.
151
152 https://example.org/eg/opac/myopac/holds_curbside
153
154 Stay safe! Wash your hands!
155 $$);
156
157 INSERT INTO action_trigger.environment (
158     event_def,
159     path
160 ) VALUES (
161     currval('action_trigger.event_definition_id_seq'),
162     'pickup_lib'
163 ), (
164     currval('action_trigger.event_definition_id_seq'),
165     'usr'
166 );
167
168 INSERT INTO action_trigger.event_params (event_def, param, value)
169     VALUES (currval('action_trigger.event_definition_id_seq'), 'check_email_notify', 1);
170
171 -- SMS offer
172 INSERT INTO action_trigger.event_definition (
173     active,
174     owner,
175     name,
176     hook,
177     validator,
178     reactor,
179     delay,
180     delay_field,
181     group_field,
182     template
183 ) VALUES (
184     false,
185     1,
186     'Curbside offer SMS notification, triggered by CurbsideSlot reactor on a definition attached to the hold.available hook',
187     'hold.offer_curbside',
188     'Curbside',
189     'SendSMS',
190     '00:00:00',
191     'shelf_time',
192     'sms_notify',
193     $$[%- USE date -%]
194 [%- user = target.0.usr -%]
195 From: [%- params.sender_email || default_sender %]
196 Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
197 To: [%- params.recipient_email || helpers.get_sms_gateway_email(target.0.sms_carrier,target.0.sms_notify) %]
198 Subject: Curbside Pickup
199 Auto-Submitted: auto-generated
200
201 [% target.0.pickup_lib.name %] offers curbside pickup.
202 Call [% target.0.pickup_lib.phone %] or visit https://example.org/eg/opac/myopac/holds_curbside
203 $$
204 );
205
206 INSERT INTO action_trigger.environment (
207     event_def,
208     path
209 ) VALUES (
210     currval('action_trigger.event_definition_id_seq'),
211     'pickup_lib'
212 ), (
213     currval('action_trigger.event_definition_id_seq'),
214     'usr'
215 );
216
217 INSERT INTO action_trigger.event_params (event_def, param, value)
218     VALUES (currval('action_trigger.event_definition_id_seq'), 'check_sms_notify', 1);
219
220 -- Email confirmation
221 INSERT INTO action_trigger.event_definition (
222     active,
223     owner,
224     name,
225     hook,
226     validator,
227     reactor,
228     delay,
229     template
230 ) VALUES (
231     'f',
232     1,
233     'Curbside confirmation Email notification',
234     'hold.confirm_curbside',
235     'Curbside',
236     'SendEmail',
237     '00:00:00',
238 $$
239 [%- USE date -%]
240 [%- user = target.patron -%]
241 To: [%- params.recipient_email || user.email %]
242 From: [%- params.sender_email || default_sender %]
243 Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
244 Subject: Curbside Pickup Confirmed
245 Auto-Submitted: auto-generated
246
247 This email is to confirm that you have scheduled a curbside item
248 pickup at [% target.org.name %] for [% date.format(helpers.format_date(target.slot), '%a, %d %b %Y %T') %].
249
250 You can cancel or change to your appointment, add vehicle description
251 notes, and alert staff to your arrival by going to the link below.
252
253 When you arrive, please call [% target.org.phone %] or visit the
254 link below to let us know you are here.
255
256 https://example.org/eg/opac/myopac/holds_curbside
257
258 Stay safe! Wash your hands!
259 $$);
260
261 INSERT INTO action_trigger.environment (
262     event_def,
263     path
264 ) VALUES (
265     currval('action_trigger.event_definition_id_seq'),
266     'org'
267 ), (
268     currval('action_trigger.event_definition_id_seq'),
269     'patron'
270 );
271
272 -- We do /not/ add this by default, treating curbside request as implicit opt-in
273 /*
274 INSERT INTO action_trigger.event_params (event_def, param, value)
275     VALUES (currval('action_trigger.event_definition_id_seq'), 'check_email_notify', 1);
276 */
277
278 -- SMS confirmation
279 INSERT INTO action_trigger.event_definition (
280     active,
281     owner,
282     name,
283     hook,
284     validator,
285     reactor,
286     delay,
287     template
288 ) VALUES (
289     false,
290     1,
291     'Curbside confirmation SMS notification',
292     'hold.confirm_curbside',
293     'Curbside',
294     'SendSMS',
295     '00:00:00',
296     $$[%- USE date -%]
297 [%- user = target.patron -%]
298 From: [%- params.sender_email || default_sender %]
299 Date: [%- date.format(date.now, '%a, %d %b %Y %T -0000', gmt => 1) %]
300 To: [%- params.recipient_email || helpers.get_sms_gateway_email(helpers.get_user_setting(user.id, 'opac.default_sms_carrier'), helpers.get_user_setting(user.id, 'opac.default_sms_notify')) %]
301 Subject: Curbside Pickup Confirmed
302 Auto-Submitted: auto-generated
303
304 Location: [% target.org.name %]
305 Time: [% date.format(helpers.format_date(target.slot), '%a, %d %b %Y %T') %]
306 Make changes at https://example.org/eg/opac/myopac/holds_curbside
307 $$
308 );
309
310 INSERT INTO action_trigger.environment (
311     event_def,
312     path
313 ) VALUES (
314     currval('action_trigger.event_definition_id_seq'),
315     'org'
316 ), (
317     currval('action_trigger.event_definition_id_seq'),
318     'patron'
319 );
320
321 -- We do /not/ add this by default, treating curbside request as implicit opt-in
322 /*
323 INSERT INTO action_trigger.event_params (event_def, param, value)
324     VALUES (currval('action_trigger.event_definition_id_seq'), 'check_sms_notify', 1);
325 */
326
327
328 COMMIT;