Bug 27728: Add a search box on OPAC Search history
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-search-history.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your search history</title>
7 [% INCLUDE 'doc-head-close.inc' %]
8 [% BLOCK cssinclude %][% END %]
9 </head>
10 [% INCLUDE 'bodytag.inc' bodyid='opac-search-history' bodyclass='scrollto' %]
11 [% INCLUDE 'masthead.inc' %]
12
13 <div class="main">
14     <nav aria-label="breadcrumb">
15         <ul class="breadcrumb">
16             <li class="breadcrumb-item">
17                 <a href="/cgi-bin/koha/opac-main.pl">Home</a>
18             </li>
19             [% IF ( loggedinusername ) %]
20                 <li class="breadcrumb-item">
21                     <a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>
22                 </li>
23                 <li class="breadcrumb-item">
24                     <a href="#">Your search history</a>
25                 </li>
26             [% ELSE %]
27                 <li class="breadcrumb-item">
28                     <a href="#">Search history</a>
29                 </li>
30             [% END %]
31         </ul>
32     </nav>
33
34     <div class="container-fluid">
35         <div class="row">
36             [% IF ( OpacNav||loggedinusername ) %]
37                 <div class="col col-lg-2 order-2 order-lg-1">
38                     <div id="navigation">
39                         [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
40                     </div>
41                 </div>
42                 <div class="col-md-12 col-lg-10 order-1">
43             [% ELSE %]
44                 <div class="col order-first order-md-first order-lg-2">
45             [% END %]
46
47                 <div id="searchhistory" class="maincontent">
48                     <h1>Search history</h1>
49                     [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]
50                         <div id="tabs" class="toptabs">
51                             <ul>
52                                 <li><a href="#biblio_tab">Catalog</a></li>
53                                 <li><a href="#authority_tab">Authority</a></li>
54                             </ul>
55                     [% END %]
56                         <div id="biblio_tab">
57                             <div id="current_biblio">
58                                 [% IF ( current_biblio_searches ) %]
59                                     <h2>Current session</h2>
60                                     <form action="/cgi-bin/koha/opac-search-history.pl" method="post">
61
62                                         [% INCLUDE 'toolbar_controls' %]
63                                         <input type="hidden" name="action" value="delete" />
64                                         <table class="historyt table table-bordered table-striped">
65                                             <thead>
66                                                 <tr>
67                                                     <th></th>
68                                                     <th>Date</th>
69                                                     <th>Search</th>
70                                                     <th>Results</th>
71                                                 </tr>
72                                             </thead>
73                                             <tbody>
74                                                 [% FOREACH s IN current_biblio_searches %]
75                                                     <tr>
76                                                         <td class="selectcol">
77                                                             <input type="checkbox" name="id" value="[% s.id | html %]" id="result[% s.id | html %]" />
78                                                         </td>
79                                                         <td>
80                                                             <label for="result[% s.id | html %]">
81                                                                 <span title="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</span>
82                                                             </label>
83                                                         </td>
84                                                         <td>
85                                                             <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;[% s.query_cgi | $raw %]&amp;count=[% countrss | uri %]&amp;sort_by=acqdate_dsc&amp;format=rss" aria-label="Subscribe to this search" class="rsssearchlink">
86                                                                 <i class="fa fa-rss rsssearchicon" aria-hidden="true" title="Subscribe to this search"></i>
87                                                             </a>
88                                                             <a href="/cgi-bin/koha/opac-search.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a>
89                                                         </td>
90                                                         <td>[% s.total | html %]</td>
91                                                     </tr>
92                                                 [% END %]
93                                             </tbody>
94                                         </table>
95                                         <input type="submit" class="btn btn-danger remove-selected" value="Remove selected searches">
96                                     </form>
97                                 [% END # IF ( current_biblio_searches ) %]
98                             </div> <!-- / #current_biblio -->
99                             <hr />
100                             <div id="previous_biblio">
101                                 [% IF ( previous_biblio_searches ) %]
102                                     <h2>Previous sessions</h2>
103                                     <form action="/cgi-bin/koha/opac-search-history.pl" method="post">
104                                         [% INCLUDE 'toolbar_controls' %]
105
106                                         <input type="hidden" name="action" value="delete" />
107                                         <table class="historyt table table-bordered table-striped">
108                                             <thead>
109                                                 <tr>
110                                                     <th></th>
111                                                     <th>Date</th>
112                                                     <th>Search</th>
113                                                     <th>Results</th>
114                                                 </tr>
115                                             </thead>
116                                             <tbody>
117                                             [% FOREACH s IN previous_biblio_searches %]
118                                                 <tr>
119                                                     <td class="selectcol">
120                                                         <input type="checkbox" name="id" value="[% s.id | html %]" id="result[% s.id | html %]" />
121                                                     </td>
122                                                     <td>
123                                                         <label for="result[% s.id | html %]">
124                                                             <span title="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</span>
125                                                         </label>
126                                                     </td>
127                                                     <td>
128                                                         <a href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %]&amp;[% s.query_cgi | $raw %]&amp;count=[% countrss | uri %]&amp;sort_by=acqdate_dsc&amp;format=rss" aria-label="Subscribe to this search" class="rsssearchlink">
129                                                             <i class="fa fa-rss rsssearchicon" aria-hidden="true" title="Subscribe to this search"></i>
130                                                         </a>
131                                                         <a href="/cgi-bin/koha/opac-search.pl?[% s.query_cgi | $raw %]">
132                                                             [% s.query_desc | html %]
133                                                         </a>
134                                                     </td>
135                                                     <td>[% s.total | html %]</td>
136                                                 </tr>
137                                             [% END %]
138                                             </tbody>
139                                         </table>
140                                         <input type="submit" class="btn btn-danger remove-selected" value="Remove selected searches">
141                                     </form>
142                                 [% END # IF ( previous_biblio_searches ) %]
143                             </div> <!-- / #previous_biblio -->
144
145                             [% IF !current_biblio_searches && !previous_biblio_searches %]
146                                 <p>Your catalog search history is empty.</p>
147                             [% END %]
148                         </div> <!-- / #biblio_tab -->
149
150                         [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]
151                             <div id="authority_tab">
152                                 [% IF ( current_authority_searches ) %]
153                                     <h2>Current session</h2>
154                                     <form action="/cgi-bin/koha/opac-search-history.pl" method="post">
155                                         [% INCLUDE 'toolbar_controls' %]
156                                         <input type="hidden" name="action" value="delete" />
157                                         <table class="historyt table table-bordered table-striped">
158                                             <thead>
159                                                 <tr>
160                                                     <th></th>
161                                                     <th>Date</th>
162                                                     <th>Search</th>
163                                                     <th>Results</th>
164                                                 </tr>
165                                             </thead>
166                                             <tbody>
167                                                 [% FOREACH s IN current_authority_searches %]
168                                                     <tr>
169                                                         <td class="selectcol">
170                                                             <input type="checkbox" name="id" value="[% s.id | html %]" id="result[% s.id | html %]" />
171                                                         </td>
172                                                         <td>
173                                                             <label for="result[% s.id | html %]">
174                                                                 <span title="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</span>
175                                                             </label>
176                                                         </td>
177                                                         <td><a href="/cgi-bin/koha/opac-authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
178                                                         <td>[% s.total | html %]</td>
179                                                     </tr>
180                                                 [% END %]
181                                             </tbody>
182                                         </table>
183                                         <input type="submit" class="btn btn-danger remove-selected" value="Remove selected searches">
184                                     </form>
185                                 [% END # / IF ( current_authority_searches ) %]
186
187                                 [% IF ( previous_authority_searches ) %]
188                                     <h2>Previous sessions</h2>
189                                     <form action="/cgi-bin/koha/opac-search-history.pl" method="post">
190                                         [% INCLUDE 'toolbar_controls' %]
191                                         <input type="hidden" name="action" value="delete" />
192                                         <table class="historyt table table-bordered table-striped">
193                                             <thead>
194                                                 <tr>
195                                                     <th></th>
196                                                     <th>Date</th>
197                                                     <th>Search</th>
198                                                     <th>Results</th>
199                                                 </tr>
200                                             </thead>
201                                             <tbody>
202                                                 [% FOREACH s IN previous_authority_searches %]
203                                                     <tr>
204                                                         <td class="selectcol">
205                                                             <input type="checkbox" name="id" value="[% s.id | html %]" id="result[% s.id | html %]" />
206                                                         </td>
207                                                         <td>
208                                                             <label for="result[% s.id | html %]">
209                                                                 <span title="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</span>
210                                                             </label>
211                                                         </td>
212                                                         <td><a href="/cgi-bin/koha/opac-authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
213                                                         <td>[% s.total | html %]</td>
214                                                     </tr>
215                                                 [% END %]
216                                             </tbody>
217                                         </table>
218                                         <input type="submit" class="btn btn-danger remove-selected" value="Remove selected searches">
219                                     </form>
220                                 [% END # / IF ( previous_authority_searches )%]
221
222                                 [% IF !current_authority_searches && !previous_authority_searches %]
223                                     <p>Your authority search history is empty.</p>
224                                 [% END %]
225                             </div> <!-- / #authority_tab -->
226                         [% END # / IF Koha.Preference( 'OpacAuthorities' ) %]
227                     </div> <!-- / #tabs -->
228                 </div> <!-- / #searchhistory -->
229             </div> <!-- / .col-lg-10/12 -->
230         </div> <!-- / .row -->
231     </div> <!-- / .container-fluid -->
232 </div> <!-- / #main -->
233
234 [% INCLUDE 'opac-bottom.inc' %]
235
236 [% BLOCK toolbar_controls %]
237     [% # Identical controls shown at the top of each table of search history %]
238     <div class="selections-toolbar toolbar">
239         <div class="check_control">
240             <a class="CheckAll btn btn-link btn-sm" href="#">Select all</a>
241             <a class="CheckNone btn btn-link btn-sm" href="#">Clear all</a>
242         </div>
243         <div class="links">
244             <span class="selections">Select searches to: </span>
245             <a href="#" class="removeitems disabled btn btn-sm btn-link"><i class="fa fa-trash" aria-hidden="true"></i> Delete</a>
246         </div>
247     </div>
248 [% END %]
249
250 [% BLOCK jsinclude %]
251 [% INCLUDE 'datatables.inc' %]
252 <script>
253
254     var MSG_CONFIRM_DELETE_HISTORY = _("Are you sure you want to delete selected search history entries?");
255     $(document).ready(function() {
256         // We show table ordered by descending dates by default
257         // (so that the more recent query is shown first)
258         $(".historyt").dataTable($.extend(true, {}, dataTablesDefaults, {
259             "order": [[ 1, "desc" ]],
260             "dom": '<"top"<"table_entries"><"table_controls"fB>>t',
261             "columnDefs": [
262                 { "targets": [ 0 ], "sortable": false, "searchable": false },
263                 { "targets": [ 1 ], "type": "title-string" },
264             ],
265             "language": {
266                 "search": "_INPUT_",
267                 "searchPlaceholder": _("Search")
268             }
269         }));
270
271         [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]$('#tabs').tabs();[% END %]
272
273         $(".CheckNone").click(function(e){
274             e.preventDefault();
275             var form = $(this).parents("form").get(0);
276             $(form).find("input:checkbox").prop("checked", false);
277             enableCheckboxActions(form);
278         });
279         $(".CheckAll").click(function(e){
280             e.preventDefault();
281             var form = $(this).parents("form").get(0);
282             $(form).find("input:checkbox").prop("checked", true);
283             enableCheckboxActions(form);
284         });
285
286         $("input:checkbox").click(function(){
287             var form = $(this).parents("form").get(0);
288             enableCheckboxActions(form);
289         });
290
291         $(".removeitems,.remove-selected").click(function(e){
292             e.preventDefault();
293             var form = $(this).parents("form").get(0);
294             var ids = $(form).find("input:checkbox:checked");
295             if ( $(ids).length < 1 ) {
296                 return false;
297             }
298             if ( confirm(MSG_CONFIRM_DELETE_HISTORY) ) {
299                 $(form).submit();
300             }
301             return false;
302         });
303         $(".remove-selected").addClass("disabled");
304     });
305
306     function enableCheckboxActions(form){
307         // Enable/disable controls if checkboxes are checked
308         var checkedBoxes = $(form).find("input:checkbox:checked");
309         if ($(checkedBoxes).size()) {
310             $(form).find(".selections").html(_("With selected searches: "));
311             $(form).find(".selections-toolbar .links a").removeClass("disabled");
312             $(form).find(".remove-selected").removeClass("disabled");
313         } else {
314             $(form).find(".selections").html(_("Select searches to: "));
315             $(form).find(".selections-toolbar .links a").addClass("disabled");
316             $(form).find(".remove-selected").addClass("disabled");
317         }
318     }
319
320
321
322 </script>
323 [% END %]