]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.schema.server-print-templates.sql
a1a534903ffb218e291a227e64e73995103299ca
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.schema.server-print-templates.sql
1 BEGIN;
2
3 -- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
4
5 CREATE TABLE config.print_template (
6     id           SERIAL PRIMARY KEY,
7     name         TEXT NOT NULL, -- programatic name
8     label        TEXT NOT NULL, -- i18n
9     owner        INT NOT NULL REFERENCES actor.org_unit (id),
10     active       BOOLEAN NOT NULL DEFAULT FALSE,
11     locale       TEXT REFERENCES config.i18n_locale(code) 
12                  ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
13     content_type TEXT NOT NULL DEFAULT 'text/html',
14     template     TEXT NOT NULL,
15         CONSTRAINT   name_once_per_lib UNIQUE (owner, name),
16         CONSTRAINT   label_once_per_lib UNIQUE (owner, label)
17 );
18
19 INSERT INTO config.print_template 
20     (id, name, locale, active, owner, label, template) 
21 VALUES (
22     1, 'patron_address', 'en-US', FALSE,
23     (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
24     oils_i18n_gettext(1, 'Address Label', 'cpt', 'label'),
25 $TEMPLATE$
26 [%-
27     SET patron = template_data.patron;
28     SET addr = template_data.address;
29 -%]
30 <div>
31   <div>
32     [% patron.first_given_name %] 
33     [% patron.second_given_name %] 
34     [% patron.family_name %]
35   </div>
36   <div>[% addr.street1 %]</div>
37   [% IF addr.street2 %]<div>[% addr.street2 %]</div>[% END %]
38   <div>
39     [% addr.city %], [% addr.state %] [% addr.post_code %]
40   </div>
41 </div>
42 $TEMPLATE$
43 );
44
45 INSERT INTO config.print_template 
46     (id, name, locale, active, owner, label, template) 
47 VALUES (
48     2, 'holds_for_bib', 'en-US', FALSE,
49     (SELECT id FROM actor.org_unit WHERE parent_ou IS NULL),
50     oils_i18n_gettext(2, 'Holds for Bib Record', 'cpt', 'label'),
51 $TEMPLATE$
52 [%-
53     USE date;
54     SET holds = template_data;
55     # template_data is an arry of wide_hold hashes.
56 -%]
57 <div>
58   <div>Holds for record: [% holds.0.title %]</div>
59   <hr/>
60   <style>#holds-for-bib-table td { padding: 5px; }</style>
61   <table id="holds-for-bib-table">
62     <thead>
63       <tr>
64         <th>Request Date</th>
65         <th>Patron Barcode</th>
66         <th>Patron Last</th>
67         <th>Patron Alias</th>
68         <th>Current Item</th>
69       </tr>
70     </thead>
71     <tbody>
72       [% FOR hold IN holds %]
73       <tr>
74         <td>[% 
75           date.format(helpers.format_date(
76             hold.request_time, staff_org_timezone), '%x %r', locale) 
77         %]</td>
78         <td>[% hold.ucard_barcode %]</td>
79         <td>[% hold.usr_family_name %]</td>
80         <td>[% hold.usr_alias %]</td>
81         <td>[% hold.cp_barcode %]</td>
82       </tr>
83       [% END %]
84     </tbody>
85   </table>
86   <hr/>
87   <div>
88     [% staff_org.shortname %] 
89     [% date.format(helpers.current_date(client_timezone), '%x %r', locale) %]
90   </div>
91   <div>Printed by [% staff.first_given_name %]</div>
92 </div>
93 <br/>
94
95 $TEMPLATE$
96 );
97
98 -- Allow for 1k stock templates
99 SELECT SETVAL('config.print_template_id_seq'::TEXT, 1000);
100
101 INSERT INTO permission.perm_list (id, code, description) 
102 VALUES (611, 'ADMIN_PRINT_TEMPLATE', 
103     oils_i18n_gettext(611, 'Modify print templates', 'ppl', 'description'));
104
105 COMMIT;
106