]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates/opac/myopac/holds.tt2
LP# 1086934 - TPAC: Complete column sorting in some screens
[Evergreen.git] / Open-ILS / src / templates / opac / myopac / holds.tt2
1 [%  PROCESS "opac/parts/header.tt2";
2     PROCESS "opac/parts/misc_util.tt2";
3     PROCESS "opac/parts/hold_status.tt2";
4     PROCESS "opac/parts/myopac/column_sort_support.tt2";
5     WRAPPER "opac/parts/myopac/base.tt2";
6     myopac_page = "holds";
7     limit = (ctx.holds_limit.defined) ? ctx.holds_limit : 0;
8     offset = (ctx.holds_offset.defined) ? ctx.holds_offset : 0;
9     count = (ctx.holds_ids.size.defined) ? ctx.holds_ids.size : 0;
10 %]
11 <h3 class="sr-only">[% l('My Holds') %]</h3>
12 <div id='myopac_holds_div'>
13
14     <div id="acct_holds_tabs">
15         <div class="align selected">
16             <a href='#'>[% l("Items on Hold") %]</a>
17         </div>
18         <div class="align">
19             <a href='[% mkurl('hold_history', {}, ['limit','offset','available','sort','sort_type']) %]'>[% l("Holds History") %]</a>
20         </div>
21     </div>
22
23     <div class="header_middle">
24         <span id="acct_holds_header" style="float:left;">
25             [%  IF CGI.param("available");
26                     l("Items Ready for Pickup");
27                 ELSE;
28                     l("Current Items on Hold");
29                 END
30             %]
31         </span>
32         <span class='float-left' style='padding-left: 10px;'>
33             <a href='[% mkurl('holds', {limit => limit,offset => (offset - limit)}) %]'
34                 [% IF offset <= 0 %] class='invisible' [% END %]><span class="nav_arrow_fix">&#9668;</span>[% l('Previous') %]</a>
35             [% IF offset > 0 || count > limit;
36                 curpage = 0;
37                 WHILE curpage * limit < count;
38                     IF curpage * limit == offset;
39             %]
40             [% curpage + 1 %]
41                     [%- ELSE %]
42             <a href='[% mkurl('holds', {limit => limit, offset => (curpage * limit)}) %]'>[% curpage + 1 %]</a>
43                     [%- END;
44                     curpage = curpage + 1;
45                 END;
46             END %]
47             <a href='[% mkurl('holds', {limit => limit, offset => (offset + limit)}) %]'
48                [% IF count <= limit + offset %] class='invisible' [% END %] >[% l('Next') %]<span class="nav_arrow_fix">&#9658;</span></a>
49         </span>
50
51     </div>
52     <div class="clear-both"></div>
53     <div id='holds_main'>
54         <form method="post">
55         <table class="table_no_border_space table_no_cell_pad opac-auto-097"
56             title="[% l('Actions for Items on Hold') %]">
57             <tr>
58                 <td>
59                     <select name="action" id="acct_holds_actions" 
60                       title="[% l('Select your action for the selected holds') %]">
61                         <option id='myopac_holds_actions_none' value=''>
62                         -- [% l("Actions for selected holds") %] --
63                         </option>
64                         <option value='suspend'>[% l("Suspend") %]</option>
65                         <option value='activate'>[% l("Activate") %]</option>
66                         <!-- XXX maybe later <option value='thaw_date'>[% l("Set Active Date") %]</option> -->
67                         <option value='cancel'>[% l("Cancel") %]</option>
68                     </select>
69                 </td>
70                 <td style="padding-left:9px;">
71                     <input type="submit" value="[% l('Go') %]"
72                         title="[% l('Go') %]" class="opac-button" />
73                 </td>
74                 <td style="padding-left:5px;">
75                     <a href="#"><img
76                         alt="[% l('Holds Help') %]"
77                         title="[% l('Actions for selected holds') %]"
78                         src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
79                 </td>
80                 <td style="padding-left:5px;" class='error'>
81                     [%  IF ctx.hold_suspend_post_capture;
82                             l('One or more holds could not be suspended because the item is at (or en route to) the pickup library.');
83                         END;
84                     %]
85                 </td>
86                 <td align="right">
87                     [% IF CGI.param("available") -%]
88                     <a href="[% mkurl('holds', {}, ['limit','offset','available']) %]">[% l('Show all holds') %]</a> |
89                     <strong>[% l("Show only available holds") %]</strong>
90                     [% ELSE -%]
91                     <strong>[% l("Show all holds") %]</strong> |
92                     <a href="[% mkurl('holds',{available => 1},['limit','offset']) %]">[% l("Show only available holds") %]</a>
93                     [% END -%]
94                 </td>
95             </tr>
96         </table>
97         [% IF ctx.holds.size && ctx.holds.size < 1 %]
98         <div class="warning_box">[% l('No holds found.') %]</div>
99         [% ELSE %]
100         <table id="acct_holds_main_header" title="[% l('Items on Hold') %]"
101             class="table_no_border_space table_no_cell_pad">
102             <thead>
103             <tr>
104                 <th align="center">
105                     <input type="checkbox" title="[% l('Select All Holds') %]"
106                       onclick="var inputs=document.getElementsByTagName('input'); for (i = 0; i < inputs.length; i++) { if (inputs[i].name == 'hold_id' &amp;&amp; !inputs[i].disabled) inputs[i].checked = this.checked;}"/>
107                 </th>
108                 <th>[% sort_head("sort_title", l('Title')) %]</th>
109                 <th>[% sort_head("author", l('Author')) %]</th>
110                 <th>[% sort_head("format", l('Format')) %]</th>
111                 <th>[% l('Pickup Location') %]</th>
112                 <th>[% l('Activate') %]</th>
113                 <th>[% l('Cancel if not filled by') %]</th>
114                 <th>[% l('Active') %]</th>
115                 <th>[% l('Status') %]</th>
116                 <th>[% l('Notes') %]</th>
117             </tr>
118             </thead>
119             <tbody id="holds_temp_parent">
120
121                 [%# Copy the ctx.holds into a local array, then add a SORT field
122                     that contains the value to sort on.  Since we need the item attrs,
123                     invoke it and save the result in ATTRS.
124                 %]
125                 [% 
126                 hold_items = ctx.holds;
127
128                 sort_field = CGI.param('sort');
129
130                 FOR hold IN hold_items;
131                     hold.ATTRS = {marc_xml => hold.marc_xml};
132                     PROCESS get_marc_attrs args=hold.ATTRS;
133
134                     SWITCH sort_field;
135
136                        CASE "sort_title";
137                           hold.SORTING = hold.ATTRS.sort_title;
138
139                        CASE "author";
140                           hold.SORTING = hold.ATTRS.author;
141
142                        CASE "format";
143                           hold.SORTING = hold.ATTRS.format_label;
144                        
145                        CASE;
146                           sort_field = "";
147                     END; # SWITCH
148                 END; #FOR hold
149
150                 IF (sort_field != "sort_title");
151                    deemphasize_class = "";
152                 ELSE;
153                    deemphasize_class = " class=\"sort_deemphasize\"";
154                 END;
155
156                 # Apply sorting to hold_items
157                 IF (sort_field != "");
158                     hold_items = hold_items.sort("SORTING");
159                     IF (CGI.param("sort_type") == "desc");
160                         hold_items = hold_items.reverse;
161                     END;
162
163                     # Shorten the hold_items list per offset/limit/count 
164                     hi = offset + limit - 1;
165                     hi = hi > hold_items.max ? hold_items.max : hi;
166
167                     hold_items = hold_items.slice(offset, hi);
168                 END;
169
170                 # hold_items list is now sorted.  Traverse and dump the information.
171                
172                 FOR hold IN hold_items;
173                     ahr = hold.hold.hold %]
174                 <tr name="acct_holds_temp"
175                     class="acct_holds_temp[% ahr.frozen == 't' ? ' inactive-hold' : '' %]">
176                     <td align="center" style="text-align:center;">
177                         <input type="checkbox" name="hold_id" value="[% ahr.id %]" 
178                             [% html_text_attr('title', l('Select hold [_1]', attrs.title)) %]/>
179                     </td>
180                     <td>
181                         <div>
182                             [% title = hold.ATTRS.title;
183                             IF ahr.hold_type == 'P';
184                                 title = l('[_1] ([_2])', title, hold.hold.part.label);
185                             END; %]
186
187                             <a href="[% mkurl(ctx.opac_root _ '/record/' _ 
188                                 hold.hold.bre_id, {}, 1) %]"
189                                 name="[% l('Catalog record') %]"><span[%- deemphasize_class -%]>
190                                 [%- title.substr(0,hold.ATTRS.nonfiling_characters) | html %]</span>
191                                 [%- title.substr(hold.ATTRS.nonfiling_characters)   | html %]</a>
192                         </div>
193                     </td>
194                     <td>
195                         <div>
196                             <a href="[% mkurl(ctx.opac_root _ '/results',
197                                 {qtype => 'author', query => hold.ATTRS.author.replace('[,\.:;]', '')},
198                                 1
199                             ) %]">[% hold.ATTRS.author | html %]</a>
200                         </div>
201                     </td>
202                     <td>
203                         <div class="format_icon">
204                           [% 
205                             formats = hold.ATTRS.all_formats;
206                             IF ahr.hold_type == 'M';
207                               # only show selected formats for metarecords
208                               formats = [];
209                               FOR ccvm IN hold.metarecord_selected_filters.icons;
210                                 NEXT IF ccvm.opac_visible == 'f';
211                                 format = {};
212                                 format.label = ccvm.search_label || ccvm.value;
213                                 format.icon = PROCESS get_ccvm_icon ccvm=ccvm;
214                                 formats.push(format);
215                               END;
216                             END;
217                             FOR format IN formats 
218                           %]
219                             <img title="[% format.label | html %]" 
220                               alt="[% format.label | html %]" src="[% format.icon %]" />
221                             [% END %]
222                         </div>
223                     </td>
224                     <td>
225                         [% ctx.get_aou(ahr.pickup_lib).name | html %]
226                     </td>
227                     <td>
228                         [% IF ahr.frozen == 't' AND ahr.thaw_date;
229                             date.format(ctx.parse_datetime(ahr.thaw_date), DATE_FORMAT);
230                         END %]
231                     </td>
232                     <td>
233                         [% IF ahr.expire_time;
234                             date.format(ctx.parse_datetime(ahr.expire_time), DATE_FORMAT);
235                         END %]
236                     </td>
237                     <td>
238                         [% l(ahr.frozen == 'f' ? 'Active' : 'Suspended') %]
239                     </td>
240                     <td>
241                         <div name="acct_holds_status">
242                             [% PROCESS get_hold_status hold=hold; %]
243                         </div>
244                     </td>
245                     <td class="hold_notes">
246                     [%- FOREACH pubnote IN ahr.notes;
247                         IF pubnote.pub == 't';
248                     %]
249                         <div class="hold_note">
250                             <span class="hold_note_title">[% pubnote.title | html %]</span>
251                             <br />
252                             <span class="hold_note_body">[% pubnote.body | html %]</span>
253                         </div>
254                     [%- END; END; %]
255                     </td>
256                     <td class="opac-auto-161">
257                         <a href="[% mkurl(ctx.opac_root _ '/myopac/holds/edit', {id => ahr.id}) %]"
258                             [% html_text_attr('title', l('Edit hold for item [_1]', attrs.title)) %]>
259                             [% l('Edit') %]
260                         </a>
261                     </td>
262                 </tr>
263                 [% END %]
264             </tbody>
265         </table>
266         [% END %]
267         </form>
268     </div>
269 </div>
270 [% END %]