]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0574.data.hold_pull_list_template.sql
LP#1947173: Clean up bad cataloging pot hole
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0574.data.hold_pull_list_template.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('0574', :eg_version);
4
5 UPDATE action_trigger.event_definition SET template =
6 $$
7 [%- USE date -%]
8 <style>
9     table { border-collapse: collapse; }
10     td { padding: 5px; border-bottom: 1px solid #888; }
11     th { font-weight: bold; }
12 </style>
13 [%
14     # Sort the holds into copy-location buckets
15     # In the main print loop, sort each bucket by callnumber before printing
16     SET holds_list = [];
17     SET loc_data = [];
18     SET current_location = target.0.current_copy.location.id;
19     FOR hold IN target;
20         IF current_location != hold.current_copy.location.id;
21             SET current_location = hold.current_copy.location.id;
22             holds_list.push(loc_data);
23             SET loc_data = [];
24         END;
25         SET hold_data = {
26             'hold' => hold,
27             'callnumber' => hold.current_copy.call_number.label
28         };
29         loc_data.push(hold_data);
30     END;
31     holds_list.push(loc_data)
32 %]
33 <table>
34     <thead>
35         <tr>
36             <th>Title</th>
37             <th>Author</th>
38             <th>Shelving Location</th>
39             <th>Call Number</th>
40             <th>Barcode/Part</th>
41             <th>Patron</th>
42         </tr>
43     </thead>
44     <tbody>
45     [% FOR loc_data IN holds_list  %]
46         [% FOR hold_data IN loc_data.sort('callnumber') %]
47             [%
48                 SET hold = hold_data.hold;
49                 SET copy_data = helpers.get_copy_bib_basics(hold.current_copy.id);
50             %]
51             <tr>
52                 <td>[% copy_data.title | truncate %]</td>
53                 <td>[% copy_data.author | truncate %]</td>
54                 <td>[% hold.current_copy.location.name %]</td>
55                 <td>[% hold.current_copy.call_number.label %]</td>
56                 <td>[% hold.current_copy.barcode %]
57                     [% FOR part IN hold.current_copy.parts %]
58                        [% part.part.label %]
59                     [% END %]
60                 </td>
61                 <td>[% hold.usr.card.barcode %]</td>
62             </tr>
63         [% END %]
64     [% END %]
65     <tbody>
66 </table>
67 $$
68     WHERE id = 35;
69
70 INSERT INTO action_trigger.environment (
71         event_def,
72         path
73     ) VALUES
74         (35, 'current_copy.parts'),
75         (35, 'current_copy.parts.part')
76 ;
77
78 COMMIT;
79