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