LP1573734_Link_to_sibling_metarecord_bibs_in_record_detail_page
[working/Evergreen.git] / Open-ILS / src / templates / opac / parts / result / table.tt2
1 [%  PROCESS "opac/parts/misc_util.tt2";
2
3     USE ResolverResolver;
4
5     ctx.result_start = 1 + ctx.page_size * page;
6     ctx.result_stop = ctx.page_size * (page + 1);
7     IF ctx.result_stop > ctx.hit_count; ctx.result_stop = ctx.hit_count; END;
8
9     result_count = ctx.result_start;
10
11     # don't display a box for the search_format filter,
12     # as that's got its own widget
13     ignore_filters = ['search_format'];
14
15     trimmed_filters = [];
16     FOR filter IN ctx.query_struct.filters;
17         fname = filter.name;
18         IF ignore_filters.grep('^' _ fname _ '$').size;
19             NEXT;
20         END;
21         trimmed_filters.push(filter);
22     END;
23
24     ctx.query_struct.filters = trimmed_filters;
25
26 %]
27
28 [% PROCESS "opac/parts/result/paginate.tt2" %] 
29 [% ctx.results_count_header = PROCESS results_count_header;
30     ctx.results_count_header %]
31 [% IF ctx.bookbag %]
32 <div id="result-bookbag-heading">
33     <div class="result-bookbag-name">[% ctx.bookbag.name | html %]</div>
34     <div class="result-bookbag-description">[% ctx.bookbag.description | html %]</div>
35 </div>
36 [% END %]
37 <div id="result_table_div">
38     <div class="facet_sidebar_hidden" id="facet_sidebar">
39     [%- IF ctx.is_staff %]
40     <h3 class="sr-only">[% l('Saved Searches') %]</h3>
41     [% INCLUDE "opac/parts/staff_saved_searches.tt2" %]
42     [%-  END %]
43     [% IF ctx.query_struct.filters.size > 0 %]
44         [% stuff = INCLUDE 'opac/parts/result/adv_filter.tt2' %]
45         [% IF stuff %]
46         <h3 class="sr-only">[% l('Search Results filters') %]</h3>
47         <div class="facet_box_wrapper filter_box_wrapper">
48             <div class="filter_box_label">[% l('Filtered By') %]</div>
49             [% stuff %]
50         </div>
51         [% END %]
52     [% END %]
53     <h3 class="sr-only">[% l('Search Results facets') %]</h3>
54     [% INCLUDE 'opac/parts/result/facets.tt2' %]
55     <h3 class="sr-only">[% l('Search Results List') %]</h3>
56     </div>
57             <div id="result_block" class="result_block_visible">
58                 <table id="result_table_table" title="[% l('Search Results') %]"
59                   class="table_no_border_space table_no_cell_pad">
60                     <thead class="sr-only">
61                       <tr>
62                         <th>[% l('Search result number') %]</th>
63                         <th>[% l('Book jacket cover art') %]</th>
64                         <th>[% l('Item details and Actions') %]</th>
65                       </tr>
66                     </thead>
67                     <tbody id="result_table">
68                     [%  FOR rec IN ctx.records;
69                             attrs = {};
70                             attrs.marc_xml = rec.marc_xml;
71                             attrs.mr_constituent_ids = [];
72                             FOREACH mr_constituent_id IN rec.mr_constituent_ids;
73                                 attrs.mr_constituent_ids.push(mr_constituent_id);
74                             END;
75                             PROCESS get_marc_attrs args=attrs;
76                             IF show_detail_view;
77                                 attrs.title = attrs.title_extended;
78                             END;
79                             # note: rec.id refers to the record identifier, regardless
80                             # of the type of record. i.e. rec.id = mmr_id ? mmr_id : bre_id
81                             IF rec.mmr_id;
82                                 IF rec.mr_constituent_count > 1;
83                                     # metarecords link to record list page
84                                     record_url = mkurl(ctx.opac_root _ '/results', 
85                                         {metarecord => rec.mmr_id}, ['page']);
86                                 ELSE;
87                                     # for MR, bre_id refers to the master and in
88                                     # this case, only, record
89                                     record_url = mkurl(ctx.opac_root _ '/record/' _ attrs.mr_constituent_ids.0, { badges => rec.badges.join(',') });
90                                 END;
91                                 hold_type = 'M';
92                             ELSE;
93                                 record_url = mkurl(ctx.opac_root _ '/record/' _ rec.bre_id, { badges => rec.badges.join(',') });
94                                 hold_type = 'T';
95                             END;
96                     -%]
97                         <tr class="result_table_row">
98                                             <td class="results_row_count" name="results_row_count">[%
99                                                     result_count; result_count = result_count + 1
100                                                 %].</td>
101                                             <td class='result_table_pic_header'>
102                                                 <a href="[% record_url %]"><img alt="[% l('Book cover') %]"
103                                                         name='item_jacket' class='result_table_pic' width="55"
104                                                         src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/r/[% rec.bre_id | uri %]' /></a><br />
105                                             </td>
106                                             <td class='result_table_title_cell' name='result_table_title_cell'>
107                                                <div class="result_metadata">
108                                                     [% IF rec.mmr_id %]
109                                                     <abbr class="unapi-id" 
110                                                       title='tag:[% ctx.hostname %],[% date.format(date.now, '%Y') %]:metabib-metarecord/[% rec.mmr_id %]'>
111                                                     </abbr>
112                                                     [% ELSE %]
113                                                     <abbr class="unapi-id" 
114                                                       title='tag:[% ctx.hostname %],[% date.format(date.now, '%Y') %]:biblio-record_entry/[% rec.bre_id %]'>
115                                                     </abbr>
116                                                     [% END %]
117                                                     <a class='record_title search_link' name='record_[% rec.id %]'
118                                                         href="[% record_url %]"
119                                                         [% html_text_attr('title', l('Display record details for "[_1]"', attrs.title)) %]>
120                                                         [% attrs.title | html %]
121                                                      </a>
122                                                      [% IF rec.mr_constituent_count.defined && rec.mr_constituent_count > 1 %]
123                                                      <span title="[% l('This group contains [_1] records', rec.mr_constituent_count) %]">
124                                                       ([% rec.mr_constituent_count %])
125                                                      </span>
126                                                      [% END %]
127
128 [%-
129 FOR entry IN attrs.graphic_titles;
130     FOR alt IN entry.graphic;
131         diratt = "";
132         IF alt.dir;
133             diratt = ' dir="' _ alt.dir _ '"';
134         END;
135 -%]
136 <div class="graphic880"[% diratt %]>
137     [% alt.value | html %]
138 </div>
139 [%-
140     END;
141 END;
142 -%]
143  
144                                                     <div>
145                                                         <a title="[% l("Perform an Author Search") %]"
146                                                                 class="record_author"
147                                                                 href="[%- 
148                                                                     authorquery = attrs.author | replace('[#"^$\+\-,\.:;&|\[\]()]', ' ');
149                                                                     mkurl(ctx.opac_root _ '/results', {qtype => 'author', query => authorquery}, general_search_parms.merge(expert_search_parms, browse_search_parms, facet_search_parms))
150                                                                     -%]" rel="nofollow" vocab="">[% attrs.author | html %]</a>
151 [%-
152 FOR entry IN attrs.graphic_authors;
153     FOR alt IN entry.graphic;
154         diratt = "";
155         IF alt.dir;
156             diratt = ' dir="' _ alt.dir _ '"';
157         END;
158 -%]
159 <div class="graphic880"[% diratt %]>
160     [% alt.value | html %]
161 </div>
162 [%-
163     END;
164 END;
165 -%]
166
167                                                     </div>
168                                                     <div class='result_table_title_cell'>
169                                                     [%- IF attrs.format_label; %]
170                                                         [% FOR format IN attrs.all_formats %]
171                                                             <img title="[% format.label | html %]" 
172                                                                 alt="[% format.label | html %]" 
173                                                                 src="[% format.icon %]" /> 
174                                                             [% format.label | html %]
175                                                         [% END %]
176                                                     [%- END %]
177                                                     [%- UNLESS show_detail_view;
178                                                             IF attrs.pubdate;
179                                                                 pubdate_clean = attrs.pubdate | html;
180                                                                 l(" ([_1])", pubdate_clean);
181                                                             ELSIF attrs.copyright;
182                                                                 copyright_clean = attrs.copyright | html;
183                                                                 l(" ([_1])", copyright_clean);                                                                
184                                                             END;
185                                                         END
186                                                     -%]
187                                                     </div>
188                                                     [% IF rec.popularity > 0.0 %]
189                                                       <div>
190                                                         <span><strong>[% l('Popularity:') %]</strong> [% rec.popularity %] / 5.0</span>
191                                                       </div>
192                                                     [% END %]
193                                                     <table 
194                                                        role="presentation"
195                                                        title="[% l('Record Holdings Summary') %]"
196                                                        class="table_no_border_space table_no_cell_pad table_no_border results_info_table">
197                                                         [% UNLESS rec.mmr_id %]
198                                                            [% IF args.holdings.size > 0 %]
199                                                         <tr name='bib_cn_list' class='result_table_title_cell'>
200                                                             <td valign='top'>
201                                                                 <strong>[% l('Call number:') %]</strong>
202                                                             </td>
203                                                             <td>[% args.holdings.0.label | html %]</td>
204                                                         </tr>
205                                                            [% END %]
206                                                         [% END %]
207
208                                                         [%- IF show_detail_view -%]
209                                                         <!-- These fields are visible when viewing the results page in 'detailed' mode -->
210                                                         [% UNLESS rec.mmr_id %]
211                                                         <!-- Do not show publication-specific information on a metarecord search results page -->
212                                                         [% IF attrs.publisher %]
213                                                             <tr name="results_pub_tr">
214                                                                 <td valign="top">
215                                                                     <strong>[% l('Publisher:') %]</strong>
216                                                                 </td>
217                                                                 <td>[% attrs.pubplace | html; %] [% attrs.publisher | html; %] [% attrs.pubdate | html; %]
218 [%-
219 FOR entry IN attrs.graphic_pubinfos;
220     FOR alt IN entry.graphic;
221         diratt = "";
222         IF alt.dir;
223             diratt = ' dir="' _ alt.dir _ '"';
224         END;
225 -%]
226 <div class="graphic880"[% diratt %]>
227     [% alt.value | html %]
228 </div>
229 [%-
230     END;
231 END;
232 -%]
233 </td>
234                                                             </tr>
235                                                         [% ELSIF attrs.producer %]
236                                                             <tr name="results_pub_tr">
237                                                                 <td valign="top">
238                                                                     <strong>[% l('Producer:') %]</strong>
239                                                                 </td>
240                                                                 <td>[% attrs.prodplace | html; %] [% attrs.producer | html; %] [% attrs.proddate | html; %]</td>
241                                                             </tr>
242                                                         [% ELSIF attrs.distributor %]
243                                                             <tr name="results_pub_tr">
244                                                                 <td valign="top">
245                                                                     <strong>[% l('Distributor:') %]</strong>
246                                                                 </td>
247                                                                 <td>[% attrs.distplace | html; %] [% attrs.distributor | html; %] [% attrs.distdate | html; %]</td>
248                                                             </tr>
249                                                         [% ELSIF attrs.manufacturer %]
250                                                             <tr name="results_pub_tr">
251                                                                 <td valign="top">
252                                                                     <strong>[% l('Manufacturer:') %]</strong>
253                                                                 </td>
254                                                                 <td>[% attrs.manplace | html; %] [% attrs.manufacturer | html; %] [% attrs.mandate | html; %]</td>
255                                                             </tr>
256                                                         [% END %]
257                                                         [% IF attrs.isbns.size > 0 %]
258                                                             <tr name="results_isbn_tr">
259                                                                 <td valign="top">
260                                                                     <strong>[% l('ISBN:') %]</strong>
261                                                                 </td>
262                                                                 <td>[% attrs.isbns.0 | html %]</td>
263                                                             </tr>
264                                                         [% END %]
265                                                         [%- IF attrs.issns.size > 0 %]
266                                                             <tr name="results_issn_tr">
267                                                                 <td valign="top">
268                                                                     <strong>[% l('ISSN:') %]</strong>
269                                                                 </td>
270                                                                 <td>[% attrs.issns.0 | html %]</td>
271                                                             </tr>
272                                                         [%- END %]
273                                                         [%- IF openurl.enabled == 'true';
274                                                             FOREACH issn IN args.issns;
275                                                                 NEXT IF issn == '';
276                                                                 res_urls = ResolverResolver.resolve_issn(issn, openurl.baseurl);
277                                                                 FOREACH res IN res_urls;
278                                                         %]
279                                                         <tr name="results_issn_tr">
280                                                             <td valign="top">
281                                                                 <strong><a href="[% res.target_url %]">
282                                                                 [% res.public_name | html %]</a></strong>
283                                                             </td>
284                                                             <td>[% res.target_coverage | html %]
285                                                             [%- IF res.target_embargo != '';
286                                                                     ' - ';
287                                                                     res.target_embargo | html;
288                                                                 END;
289                                                             -%]
290                                                             </td>
291                                                         </tr>
292                                                                 [% END %]
293                                                             [% END %]
294                                                         [% END %]
295
296                                                         [% IF attrs.edition %]
297                                                             <tr name="results_edition_tr">
298                                                                 <td valign="top">
299                                                                     <strong>[% l('Edition:') %]</strong>
300                                                                 </td>
301                                                                 <td>[% attrs.edition | html %]
302 [%-
303 FOR entry IN attrs.graphic_editions;
304     FOR alt IN entry.graphic;
305         diratt = "";
306         IF alt.dir;
307             diratt = ' dir="' _ alt.dir _ '"';
308         END;
309 -%]
310 <div class="graphic880"[% diratt %]>
311     [% alt.value | html %]
312 </div>
313 [%-
314     END;
315 END;
316 -%]
317 </td>
318                                                             </tr>
319                                                         [% END %]
320                                                         [% IF attrs.phys_desc %]
321                                                             <tr name="results_phys_desc_tr">
322                                                                 <td nowrap="nowrap" valign="top">
323                                                                     <strong>[% l('Phys. Desc.:') %]</strong>
324                                                                 </td>
325                                                                 <td>
326                                                                     [% args.phys_desc | html %]
327                                                                 </td>
328                                                             </tr>
329                                                         [% END %]
330                                                         [% FOR uri IN args.uris %]
331                                                             <tr name='bib_uri_list' class='result_table_title_cell'>
332                                                                 <td valign='top'>
333                                                                     <strong>[% l('Electronic resource') %]</strong>
334                                                                 </td>
335                                                                 <td><a href="[% uri.href %]" class="uri_link">[% uri.link | html %]</a>[% ' - ' _ uri.note | html IF uri.note %]</td>
336                                                             </tr>
337                                                             [% END %]
338                                                          [% END %]
339                                                             [%- IF args.holdings.size > 0;
340                                                                 FOREACH copy IN args.holdings;
341                                                                     IF copy.part_label != '';
342                                                                         has_parts = 'true';
343                                                                         LAST;
344                                                                     END;
345                                                                 END;
346                                                             %]
347                                                             <tr name='bib_cn_list' class='result_table_title_cell'>
348                                                                 <td colspan='2'>
349                                                                     <table title="[% l('Record Holdings Details') %]"
350                                                                            class='result_holdings_table'>
351                                                                         <thead><tr>
352                                                                             <th>[% l('Library') %]</th>
353                                                                             <th>[% l('Shelving location') %]</th>
354                                                                             <th>[% l('Call number') %]</th>
355                                                                             [%- IF has_parts == 'true'; %]
356                                                                             <th>[% l('Part') %]</th>
357                                                                             [%- END %]
358                                                                             <th>[% l('Status') %]</th>
359                                                                         </tr></thead>
360                                                                         <tbody>
361                                                                 [% FOR copy IN args.holdings %]
362                                                                         <tr>
363                                                                             <td>
364 [%- copy_info = copy;
365     INCLUDE "opac/parts/library_name_link.tt2"; %]
366                                                                             </td>
367                                                                             <td>[% copy.location | html %]</td>
368                                                                             <td>[% copy.label | html %]</td>
369                                                                             [%- IF has_parts == 'true'; %]
370                                                                             <td>[% copy.part_label %]</td>
371                                                                             [%- END %]
372                                                                             <td>[% copy.status | html %]</td>
373                                                                         </tr>
374                                                                 [% END %]
375                                                                         </tbody>
376                                                                     </table>
377                                                                 </td>
378                                                             </tr>
379                                                             [%- has_parts = 'false';
380                                                                 END;
381                                                              %]
382                                                         [% END %] <!-- END detail_record_view -->
383                                                     </table>
384                                                     [% PROCESS "opac/parts/result/copy_counts.tt2" %]
385                                                     [% IF rec.user_circulated %]
386                                                     <div class="result_item_circulated">
387                                                         <img src="[% ctx.media_prefix %]/images/green_check.png" alt="[% l('Checked Out Before') %]"/>
388                                                         <span>[% l('I have checked this item out before') %]</span>
389                                                     </div>
390                                                     [% END %]
391                                                     [% IF ctx.bookbag;
392                                                         rec_id = rec.id;
393                                                         FOR note IN ctx.bookbag_items_by_bre_id.$rec_id.notes %]
394                                                     <div class="result-bookbag-item-note">
395                                                         [% note.note | html %]
396                                                     </div>
397                                                         [% END %]
398                                                     [% END %]
399                                                 </div>
400                                                 <div class="result_table_utils_cont">
401                                                     <div class="result_table_utils">
402 [%- search_ou = ctx.search_ou;
403     num_holdable_copies = attrs.marc_xml.findnodes('//*[local-name()="holdings" and @has_holdable="true"]').size || 0;
404     IF ctx.place_unfillable ||
405         ( num_holdable_copies > 0
406             && (ctx.holds_block.enabled != 'true' || attrs.org_copy_counts.$search_ou.available == 0)
407         )
408 %]
409                                                         <div class="results_aux_utils place_hold"><a
410                                                                 href="[% mkurl(ctx.opac_root _ '/place_hold',
411                                                                     {hold_target => rec.id, hold_type => hold_type, 
412                                                                       hold_source_page => mkurl()}, ['query','tag','subfield','term','_special','sort','page']) %]"
413                                                                 [% html_text_attr('title', l('Place Hold on [_1]', attrs.title)) %]
414                                                                     class="no-dec" rel="nofollow" vocab=""><img
415                                                                 src="[% ctx.media_prefix %]/images/green_check.png"
416                                                                 alt=""/><span class="result_place_hold">[% l('Place Hold') %]</span></a>
417                                                         </div>
418 [%- END -%]
419                                                         <div class="results_aux_utils result_util">
420                                                             [%  IF ctx.user;
421                                                                 INCLUDE "opac/parts/bookbag_actions.tt2";
422                                                             %]
423                                                             [%  ELSE;
424                                                                 operation = ctx.mylist.grep(rec.id).size ? "delete" : "add";
425                                                                 label = (operation == "add") ?  l("Add to my list") : l("Remove from my list");
426                                                                 title_label = (operation == "add") ? 
427                                                                   l("Add [_1] to my list", attrs.title) : 
428                                                                   l("Remove [_1] from my list", attrs.title);
429                                                                 href = mkurl(ctx.opac_root _ '/mylist/' _ operation, 
430                                                                         {record => rec.id, anchor => 'record_' _ rec.id}, 1);
431                                                             %]      
432                                                             <a href="[% href %]" class="no-dec" 
433                                                                 [% html_text_attr('title', title_label) %] rel="nofollow" vocab="">
434                                                                 <img src="[% ctx.media_prefix %]/images/clipboard.png" alt="" />
435                                                                 [% label %]
436                                                             </a>
437                                                             [% END %]
438                                                         </div>
439                                                         [% IF ENV.OILS_CONTENT_CAFE_USER %]
440                                                         [% ident = attrs.isbn_clean || attrs.upc %]
441                                                         <div class="results_aux_utils result_util">
442                                                             <a target='_blank' 
443                                                                [% html_text_attr('title', l('Reviews and More for [_1]', attrs.title)) %]
444                                                                 href="[% ctx.ext_proto %]://contentcafe2.btol.com/ContentCafeClient/ContentCafe.aspx?UserID=[%- 
445                                                                     ENV.OILS_CONTENT_CAFE_USER %]&amp;Password=[%-
446                                                                     ENV.OILS_CONTENT_CAFE_PASS %]&amp;ItemKey=[% ident | uri %]&amp;Options=Y" rel="nofollow" vocab="">
447                                                                 <img src='[% ctx.media_prefix %]/images/starz.png' alt="[% l('Ratings Icon') %]"/> 
448                                                                 <span class="results_reviews">[% l('Reviews &amp; More') %]</span>
449                                                             </a>
450                                                         </div>
451                                                         [% END %]
452                                                     </div>
453                                                 </div>
454
455                                             </td>
456
457                                         </tr>
458                                         [%- IF ENV.OILS_CHILIFRESH_ACCOUNT %]
459                                         <tr>
460                                             <td/>
461                                             <td align='center'> <!-- Chilifresh reviews link --> 
462                                                 <span class="chili_review" id="isbn_[% attrs.isbn_clean | html %]"> </span>
463                                             </td>
464                                         </tr>
465                                         <tr>
466                                             <td/>
467                                             <td colspan='5'> <!-- Chilifresh reviews panel -->
468                                                 <div id="chili_review_[% attrs.isbn_clean | html %]" style="display: none;" align="center"></div>
469                                             </td>
470                                         </tr>
471                                         [%- END %]
472                     [% END %]
473                     </tbody>
474                 </table>
475             </div>
476 </div>
477 <div class="result_footer_nav1">
478     [% ctx.results_count_header %]
479 </div>
480 <script>
481 resultBlock = document.getElementById('result_block');
482 resultButton = document.getElementById('return_to_hits');
483 facetSidebar = document.getElementById('facet_sidebar');
484 facetButton =  document.getElementById('refine_hits');
485 function getFacety() {
486     resultBlock.setAttribute('class', 'result_block_hidden');
487     resultButton.setAttribute('class', 'results_header_btns result_block_visible');
488     facetSidebar.setAttribute('class', 'facet_sidebar_visible');
489     facetButton.setAttribute('class', 'result_block_hidden');
490     window.location.hash = 'return_to_hits';
491 }
492 function getResulty() {
493     resultBlock.setAttribute('class', 'result_block_visible');
494     resultButton.setAttribute('class', 'result_block_hidden');
495     facetSidebar.setAttribute('class', 'facet_sidebar_hidden');
496     facetButton.setAttribute('class', 'results_header_btns result_block_visible');
497     window.location.hash = 'refine_hits';
498 }
499 </script>