]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0208.data.titles_received_worksheet_tweaks.sql
LP#1917826: tweaks to data update
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0208.data.titles_received_worksheet_tweaks.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0208'); 
4
5 UPDATE action_trigger.event_definition SET 
6     name = 'Lineitem Worksheet',
7     template = 
8 $$
9 [%- USE date -%]
10 [%- SET li = target; -%]
11 <div class="wrapper">
12     <div class="summary" style='font-size:110%; font-weight:bold;'>
13
14         <div>Title: [% helpers.get_li_attr("title", "", li.attributes) %]</div>
15         <div>Author: [% helpers.get_li_attr("author", "", li.attributes) %]</div>
16         <div class="count">Item Count: [% li.lineitem_details.size %]</div>
17         <div class="lineid">Lineitem ID: [% li.id %]</div>
18
19         [% IF li.distribution_formulas.size > 0 %]
20             [% SET forms = [] %]
21             [% FOREACH form IN li.distribution_formulas; forms.push(form.formula.name); END %]
22             <div>Distribution Formulas: [% forms.join(',') %]</div>
23         [% END %]
24
25         [% IF li.lineitem_notes.size > 0 %]
26             Lineitem Notes:
27             <ul>
28                 [%- FOR note IN li.lineitem_notes -%]
29                     <li>
30                     [% IF note.alert_text %]
31                         [% note.alert_text.code -%] 
32                         [% IF note.value -%]
33                             : [% note.value %]
34                         [% END %]
35                     [% ELSE %]
36                         [% note.value -%] 
37                     [% END %]
38                     </li>
39                 [% END %]
40             </ul>
41         [% END %]
42     </div>
43     <br/>
44     <table>
45         <thead>
46             <tr>
47                 <th>Branch</th>
48                 <th>Barcode</th>
49                 <th>Call Number</th>
50                 <th>Fund</th>
51                 <th>Recd.</th>
52                 <th>Notes</th>
53             </tr>
54         </thead>
55         <tbody>
56         [% FOREACH detail IN li.lineitem_details.sort('owning_lib') %]
57             [% 
58                 IF copy.eg_copy_id;
59                     SET copy = copy.eg_copy_id;
60                     SET cn_label = copy.call_number.label;
61                 ELSE; 
62                     SET copy = detail; 
63                     SET cn_label = detail.cn_label;
64                 END 
65             %]
66             <tr>
67                 <!-- acq.lineitem_detail.id = [%- detail.id -%] -->
68                 <td style='padding:5px;'>[% detail.owning_lib.shortname %]</td>
69                 <td style='padding:5px;'>[% IF copy.barcode   %]<span class="barcode"  >[% detail.barcode   %]</span>[% END %]</td>
70                 <td style='padding:5px;'>[% IF cn_label %]<span class="cn_label" >[% cn_label  %]</span>[% END %]</td>
71                 <td style='padding:5px;'>[% IF detail.fund %]<span class="fund">[% detail.fund.code %] ([% detail.fund.year %])</span>[% END %]</td>
72                 <td style='padding:5px;'>[% IF detail.recv_time %]<span class="recv_time">[% detail.recv_time %]</span>[% END %]</td>
73                 <td style='padding:5px;'>[% detail.note %]</td>
74             </tr>
75         [% END %]
76         </tbody>
77     </table>
78 </div>
79 $$
80 WHERE id = 14;
81
82
83 INSERT INTO action_trigger.environment (event_def, path) VALUES
84     ( 14, 'lineitem_notes.alert_text' ),
85     ( 14, 'distribution_formulas.formula' ),
86     ( 14, 'lineitem_details.fund' ),
87     ( 14, 'lineitem_details.eg_copy_id' ),
88     ( 14, 'lineitem_details.eg_copy_id.call_number' )
89 ;
90
91 COMMIT;
92