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