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