]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/1333.data.picklist-po-angular.sql
LP1942220: stamp upgrade scripts
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 1333.data.picklist-po-angular.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('1333', :eg_version);
4
5 INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
6 VALUES (
7     'eg.grid.acq.lineitem.history', 'gui', 'object',
8     oils_i18n_gettext(
9         'eg.grid.acq.lineitem.history',
10         'Grid Config: Acq Lineitem History',
11         'cwst', 'label'
12     )
13 ), (
14     'eg.grid.acq.po.history', 'gui', 'object',
15     oils_i18n_gettext(
16         'eg.grid.acq.po.history',
17         'Grid Config: Acq PO History',
18         'cwst', 'label'
19     )
20 ), (
21     'eg.grid.acq.po.edi_messages', 'gui', 'object',
22     oils_i18n_gettext(
23         'eg.grid.acq.po.edi_messages',
24         'Grid Config: Acq PO EDI Messages',
25         'cwst', 'label'
26     )
27 ), (
28     'acq.lineitem.page_size', 'gui', 'integer',
29     oils_i18n_gettext(
30         'acq.lineitem.page_size',
31         'ACQ Lineitem List Page Size',
32         'cwst', 'label'
33     )
34 ), (
35     'ui.staff.angular_acq_search.enabled', 'gui', 'bool',
36     oils_i18n_gettext(
37         'ui.staff.angular_acq_search.enabled',
38         'Enable Experimental ACQ Selection/Purchase Search Interface Links',
39         'cwst', 'label'
40     )
41 );
42
43 INSERT INTO config.print_template
44     (id, name, label, owner, active, locale, template)
45 VALUES (
46     5, 'lineitem_worksheet', 'Lineitem Worksheet', 1, TRUE, 'en-US',
47 $TEMPLATE$
48 [%- 
49   USE money=format('%.2f');
50   USE date;
51   SET li = template_data.lineitem;
52   SET title = '';
53   SET author = '';
54   FOREACH attr IN li.attributes;
55     IF attr.attr_type == 'lineitem_marc_attr_definition';
56       IF attr.attr_name == 'title';
57         title = attr.attr_value;
58       ELSIF attr.attr_name == 'author';
59         author = attr.attr_value;
60       END;
61     END;
62   END;
63 -%]
64
65 <div class="wrapper">
66     <div class="summary" style='font-size:110%; font-weight:bold;'>
67         <div>Title: [% title.substr(0, 80) %][% IF title.length > 80 %]...[% END %]</div>
68         <div>Author: [% author %]</div>
69         <div>Item Count: [% li.lineitem_details.size %]</div>
70         <div>Lineitem ID: [% li.id %]</div>
71         <div>PO # : [% li.purchase_order %]</div>
72         <div>Est. Price: [% money(li.estimated_unit_price) %]</div>
73         <div>Open Holds: [% template_data.hold_count %]</div>
74         [% IF li.cancel_reason.label %]
75         <div>[% li.cancel_reason.label %]</div>
76         [% END %]
77
78         [% IF li.distribution_formulas.size > 0 %]
79             [% SET forms = [] %]
80             [% FOREACH form IN li.distribution_formulas; forms.push(form.formula.name); END %]
81             <div>Distribution Formulas: [% forms.join(',') %]</div>
82         [% END %]
83
84         [% IF li.lineitem_notes.size > 0 %]
85             Lineitem Notes:
86             <ul>
87                 [%- FOR note IN li.lineitem_notes -%]
88                     <li>
89                     [% IF note.alert_text %]
90                         [% note.alert_text.code -%] 
91                         [% IF note.value -%]
92                             : [% note.value %]
93                         [% END %]
94                     [% ELSE %]
95                         [% note.value -%] 
96                     [% END %]
97                     </li>
98                 [% END %]
99             </ul>
100         [% END %]
101     </div>
102     <br/>
103     <table>
104         <thead>
105             <tr>
106                 <th>Branch</th>
107                 <th>Barcode</th>
108                 <th>Call Number</th>
109                 <th>Fund</th>
110                 <th>Shelving Location</th>
111                 <th>Recd.</th>
112                 <th>Notes</th>
113                 <th>Delayed / Canceled</th>
114             </tr>
115         </thead>
116         <tbody>
117         <!-- set detail.owning_lib from fm object to org name -->
118         [% FOREACH detail IN li.lineitem_details %]
119             [% detail.owning_lib = detail.owning_lib.shortname %]
120         [% END %]
121
122         [% FOREACH detail IN li.lineitem_details.sort('owning_lib') %]
123             [% 
124                 IF detail.eg_copy_id;
125                     SET copy = detail.eg_copy_id;
126                     SET cn_label = copy.call_number.label;
127                 ELSE; 
128                     SET copy = detail; 
129                     SET cn_label = detail.cn_label;
130                 END 
131             %]
132             <tr>
133                 <!-- acq.lineitem_detail.id = [%- detail.id -%] -->
134                 <td style='padding:5px;'>[% detail.owning_lib %]</td>
135                 <td style='padding:5px;'>[% IF copy.barcode   %]<span class="barcode"  >[% detail.barcode   %]</span>[% END %]</td>
136                 <td style='padding:5px;'>[% IF cn_label %]<span class="cn_label" >[% cn_label  %]</span>[% END %]</td>
137                 <td style='padding:5px;'>[% IF detail.fund %]<span class="fund">[% detail.fund.code %] ([% detail.fund.year %])</span>[% END %]</td>
138                 <td style='padding:5px;'>[% copy.location.name %]</td>
139                 <td style='padding:5px;'>[% IF detail.recv_time %]<span class="recv_time">[% date.format(helpers.format_date(detail.recv_time, staff_org_timezone), '%x %r', locale) %]</span>[% END %]</td>
140                 <td style='padding:5px;'>[% detail.note %]</td>
141                 <td style='padding:5px;'>[% detail.cancel_reason.label %]</td>
142             </tr>
143         [% END %]
144         </tbody>
145     </table>
146 </div>
147 $TEMPLATE$
148 );
149
150 INSERT INTO config.print_template
151     (id, name, label, owner, active, locale, template)
152 VALUES (6, 'purchase_order', 'Purchase Order', 1, TRUE, 'en-US', 
153 $TEMPLATE$
154
155 [%- 
156   USE date;
157   USE String;
158   USE money=format('%.2f');
159   SET po = template_data.po;
160
161   # find a lineitem attribute by name and optional type
162   BLOCK get_li_attr;
163     FOR attr IN li.attributes;
164       IF attr.attr_name == attr_name;
165         IF !attr_type OR attr_type == attr.attr_type;
166           attr.attr_value;
167           LAST;
168         END;
169       END;
170     END;
171   END;
172
173   BLOCK get_li_order_attr_value;
174     FOR attr IN li.attributes;
175       IF attr.order_ident == 't';
176         attr.attr_value;
177         LAST;
178       END;
179     END;
180   END;
181 -%]
182
183 <table style="width:100%">
184   <thead>
185     <tr>
186       <th>PO#</th>
187       <th>Line#</th>
188       <th>ISBN / Item # / Charge Type</th>
189       <th>Title</th>
190       <th>Author</th>
191       <th>Pub Info</th>
192       <th>Quantity</th>
193       <th>Unit Price</th>
194       <th>Line Total</th>
195     </tr>
196   </thead>
197   <tbody>
198 [% 
199   SET subtotal = 0;
200   FOR li IN po.lineitems;
201
202     SET idval = '';
203     IF vendnum != '';
204       idval = PROCESS get_li_attr attr_name = 'vendor_num';
205     END;
206     IF !idval;
207       idval = PROCESS get_li_order_attr_value;
208     END;
209 -%]
210     <tr>
211       <td>[% po.id %]</td>
212       <td>[% li.id %]</td>
213       <td>[% idval %]</td>
214       <td>[% PROCESS get_li_attr attr_name = 'title' %]</td>
215       <td>[% PROCESS get_li_attr attr_name = 'author' %]</td>
216       <td>
217         <div>
218           [% PROCESS get_li_attr attr_name = 'publisher' %], 
219           [% PROCESS get_li_attr attr_name = 'pubdate' %]
220         </div>
221         <div>Edition: [% PROCESS get_li_attr attr_name = 'edition' %]</div>
222       </td>
223       [%- 
224         SET count = li.lineitem_details.size;
225         SET price = li.estimated_unit_price;
226         SET itotal = (price * count);
227       %]
228       <td>[% count %]</td>
229       <td>[% money(price) %]</td>
230       <td>[% money(litotal) %]</td>
231     </tr>
232   [% END %]
233
234   </tbody>
235 </table>
236
237
238
239 $TEMPLATE$
240 );
241
242
243 COMMIT;
244
245