7f149f019f677c00c1517a9e6c8d721ffa2cc3ea
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-recordedbooks-search.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE AdditionalContents %]
5 [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
6 [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>RecordedBooks search for '[% q | html %]' &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% BLOCK cssinclude %]
11 [% END %]
12 </head>
13 [% INCLUDE 'bodytag.inc' bodyid='recordedbooks-results-page' bodyclass='scrollto' %]
14 [% INCLUDE 'masthead.inc' %]
15
16     <div class="main">
17         <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumbs">
18             <ol class="breadcrumb">
19                 <li class="breadcrumb-item">
20                     <a href="/cgi-bin/koha/opac-main.pl">Home</a>
21                 </li>
22                 <li class="breadcrumb-item active">
23                     <a href="#" aria-current="page">RecordedBooks search for '[% q | html %]'</a>
24                 </li>
25             </ol>
26         </nav> <!-- /#breadcrumbs -->
27
28         <div class="container-fluid">
29             <div class="row">
30                 <div class="col-lg-2">
31                     [% IF ( OpacNav || OpacNavBottom ) %]
32                         [% INCLUDE 'navigation.inc' %]
33                     [% END %]
34                 </div>
35                 <div class="col-lg-10 order-first order-md-first order-lg-2">
36                     <div id="recordedbooks-results-content" class="maincontent searchresults">
37                         <h1>RecordedBooks search for '[% q | html %]'</h1>
38                             [% UNLESS ( logged_in_user ) %]
39                                  <h2 class="rb_login">Sign in to view availability and checkout items or place holds</h2>
40                             [% END %]
41
42                             <div id="breadcrumbs">
43                                 <p></p>
44                             </div>
45
46                             <div id="top-pages">
47                                 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
48                                 </nav>
49                             </div>
50
51                             <table id="recordedbooks-results-list" class="table table-striped">
52                                 <tbody>
53                                 </tbody>
54                             </table>
55
56                             <div id="bottom-pages">
57                                 <nav class="pagination pagination-sm noprint" aria-label="Search results pagination">
58                                 </nav>
59                             </div>
60
61                     </div> <!-- / #recordedbooks-results-content -->
62                 </div> <!-- / .col-lg-10 -->
63             </div> <!-- / .row -->
64         </div> <!-- / .container-fluid -->
65     </div> <!-- / .main -->
66
67 [% INCLUDE 'recordedbooks-checkout.inc' %]
68
69 [% INCLUDE 'opac-bottom.inc' %]
70 [% BLOCK jsinclude %]
71     [% Asset.js("js/recordedbooks.js") | $raw %]
72     <script>
73         var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
74         var results_per_page = [% OPACnumSearchResults || 20 | html %];
75
76         function search( page ) {
77             $( '#recordedbooks-status' ).html( MSG_SEARCHING.format("RecordedBooks") + ' <img class="throbber" src="[% interface | html %]/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
78
79             KOHA.RecordedBooks.search( querystring, results_per_page, page, function( data ) {
80                 if ( data.error ) {
81                     $( '#recordedbooks-status' ).html( '<strong class="unavailable">' + MSG_ERROR_SEARCHING_COLLECTION.format("RecordedBooks") + ': ' + data.error + '</strong>' );
82                     return;
83                 }
84
85                 if ( !data.total ) {
86                     $( '#recordedbooks-status' ).html( '<strong>' + MSG_NO_RESULTS_FOUND_IN_COLLECTION.format("RecordedBooks") + '</strong>' );
87                     return;
88                 }
89
90                 $( '#recordedbooks-results-list tbody' ).empty();
91
92                 $( '#recordedbooks-status' ).html( '<strong>' + MSG_RESULTS_FOUND_IN_COLLECTION.format(data.total, "RecordedBooks") + '</strong>' );
93
94                 for ( var i = 0; data.items[i]; i++ ) {
95                     var prod = data.items[i];
96                     var results = [];
97                     results.push( '<tr>' );
98
99                     results.push( '<td class="info"><span class="title">' );
100                     if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
101                     results.push( prod.title );
102                     if (prod.url) results.push( '</a>' );
103                     results.push( '</span>' );
104                     results.push( '<p>' + MSG_BY + ' ', prod.author, '</p>' );
105                     if (prod.description) results.push( '<p>' + prod.description, '</p>' );
106                     results.push( '<span class="results_summary mediatype"><span class="label">' + MSG_TYPE + ': </span>', prod.media, '</span>' );
107
108                     results.push( '</td>' );
109
110                     results.push( '<td>' );
111                     if ( prod.images && prod.images.medium ) {
112                         if (prod.url) results.push( '<a href="', prod.url, '" target="recordedbooks">' );
113                         results.push( '<img class="thumbnail" src="', prod.images.medium, '" />' );
114                         if (prod.url) results.push( '</a>' );
115                     }
116                     results.push( '</td>' );
117
118                     results.push( '</tr>' );
119                     var $tr = $( results.join( '' ));
120                     $( '#recordedbooks-results-list tbody' ).append( $tr );
121
122                     $tr.find( '.info' ).each(function() {
123                         KOHA.RecordedBooks.add_actions(this, prod.isbn);
124                     });
125                 }
126
127                 $( '#recordedbooks-results-list tr:odd' ).addClass( 'highlight' );
128
129                 var pages = [];
130
131                 var max_page = Math.floor( data.total / results_per_page );
132                 if (data.total == page*results_per_page) max_page++;
133
134                 if ( page != 1 ) {
135                     pages.push( '<li class="page-item"><a class="page-link od-nav" href="#" data-page="' + (page - 1) + '">&laquo; ' + MSG_PREVIOUS + '</a></li>' );
136                 }
137
138                 for ( var p = Math.max( 0, page - 9 ); p <= Math.min( max_page, p + 9 ); p++ ) {
139                     if ( p == page ) {
140                         pages.push( ' <li class="page-item disabled"><a class="page-link" href="#">' + ( p + 1 ) + '</a></li>' );
141                     } else {
142                         pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-page="' +  p + '">' + p + '</a></li>' );
143                     }
144                 }
145
146                 if ( page < max_page ) {
147                     pages.push( ' <li class="page-item"><a class="page-link od-nav" href="#" data-page="' + (page + 1) + '">' + MSG_NEXT + ' &raquo;</a></li>' );
148                 }
149
150                 if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pagination' ).html( '<ul class="pagination">' + pages.join( '' ) + '</ul>');
151
152                 if( KOHA.RecordedBooks.is_identified() == false ){
153                     $("#breadcrumbs").before('<h3 class="rb_register"><a href="https://[% Koha.Preference('RecordedBooksDomain') | uri %]">To see availability you must register for RecordedBooks using your cardnumber and the email associated with your Koha account</a></h3>');
154                 }
155
156             } );
157         }
158
159         $( document ).ready( function() {
160             $( '#breadcrumbs p' )
161                 .append( ' ' )
162                 .append( '<span id="recordedbooks-status"></span>' );
163
164             $( document ).on( 'click', 'a.od-nav', function() {
165                 search( $( this ).data( 'page' ) );
166                 return false;
167             });
168
169             [% IF ( logged_in_user ) %]
170             KOHA.RecordedBooks.with_account_details("#breadcrumbs", function() {
171                 search( 1 );
172             });
173             [% ELSE %]
174                 search( 1 );
175             [% END %]
176         } );
177     </script>
178 [% END %]