4 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha › Catalog › Search history</title>
8 [% INCLUDE 'doc-head-close.inc' %]
11 <body id="catalogue_search-history" class="catalogue">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'cat-search.inc' %]
16 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
19 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
22 <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
25 <a href="#" aria-current="page">
32 <div class="container-fluid">
34 <div class="col-sm-12 col-md-8 col-md-offset-2">
36 <h1>Search history</h1>
37 <div id="tabs" class="toptabs">
39 <li><a href="#biblio_tab">Catalog</a></li>
40 <li><a href="#authority_tab">Authority</a></li>
43 [% IF ( current_biblio_searches ) %]
44 <h2>Current session</h2>
45 <form id="current_cat" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
46 <p class="selections-toolbar">
47 <a class="CheckAll" data-form="current_cat" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
48 <span class="sep">|</span>
49 <a class="CheckNone" data-form="current_cat" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
50 <span class="sep">|</span>
52 <span class="selections">Select searches to: </span>
53 <a href="#" class="action_delete disabled">Delete</a>
56 <input type="hidden" name="action" value="delete" />
57 <table class="historyt">
67 [% FOREACH s IN current_biblio_searches %]
69 <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
70 <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
71 <td><a href="/cgi-bin/koha/catalogue/search.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
72 <td>[% s.total | html %]</td>
80 [% IF ( current_biblio_searches && previous_biblio_searches) %]
84 [% IF ( previous_biblio_searches ) %]
85 <h2>Previous sessions</h2>
86 <form id="previous_cat" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
87 <p class="selections-toolbar">
88 <a class="CheckAll" data-form="previous_cat" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
89 <span class="sep">|</span>
90 <a class="CheckNone" data-form="previous_cat" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
91 <span class="sep">|</span>
93 <span class="selections">Select searches to: </span>
94 <a href="#" class="action_delete disabled">Delete</a>
97 <input type="hidden" name="action" value="delete" />
98 <table class="historyt">
108 [% FOREACH s IN previous_biblio_searches %]
110 <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
111 <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
112 <td><a href="/cgi-bin/koha/catalogue/search.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
113 <td>[% s.total | html %]</td>
121 [% IF !current_biblio_searches && !previous_biblio_searches %]
122 <p>Your catalog search history is empty.</p>
126 <div id="authority_tab">
127 [% IF ( current_authority_searches ) %]
128 <h2>Current session</h2>
129 <form id="current_auth" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
130 <p class="selections-toolbar">
131 <a class="CheckAll" data-form="current_auth" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
132 <span class="sep">|</span>
133 <a class="CheckNone" data-form="current_auth" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
134 <span class="sep">|</span>
136 <span class="selections">Select searches to: </span>
137 <a href="#" class="action_delete disabled">Delete</a>
140 <input type="hidden" name="action" value="delete" />
141 <table class="historyt">
151 [% FOREACH s IN current_authority_searches %]
153 <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
154 <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
155 <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
156 <td>[% s.total | html %]</td>
164 [% IF ( current_authority_searches && previous_authority_searches) %]
168 [% IF ( previous_authority_searches ) %]
169 <h2>Previous sessions</h2>
170 <form id="previous_auth" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
171 <p class="selections-toolbar">
172 <a class="CheckAll" data-form="previous_auth" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
173 <span class="sep">|</span>
174 <a class="CheckNone" data-form="previous_auth" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
175 <span class="sep">|</span>
177 <span class="selections">Select searches to: </span>
178 <a href="#" class="action_delete disabled">Delete</a>
181 <input type="hidden" name="action" value="delete" />
182 <table class="historyt">
192 [% FOREACH s IN previous_authority_searches %]
194 <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
195 <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
196 <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
197 <td>[% s.total | html %]</td>
205 [% IF !current_authority_searches && !previous_authority_searches %]
206 <p>Your authority search history is empty.</p>
208 </div> [% # /authority_tab %]
210 </div> [% # /div.col-md-8 %]
211 </div> [% # /div.row %]
213 [% MACRO jsinclude BLOCK %]
214 [% INCLUDE 'datatables.inc' %]
216 $(document).ready(function() {
217 // We show table ordered by descending dates by default
218 // (so that the more recent query is shown first)
219 $(".historyt").dataTable($.extend(true, {}, dataTablesDefaults, {
220 "aaSorting": [[ 1, "desc" ]],
222 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
223 { "aTargets": [ 1 ], "sType": "title-string" },
225 "sPaginationType": "full_numbers"
230 // DataTables removes hidden rows from the DOM, so we can't expect a
231 // "regular" submit to work and we need to build another form containing
232 // all form elements, and then submit this form.
233 $('#tabs form').submit(function(e) {
237 var table = form.find('table').dataTable();
239 var new_form = $('<form>')
240 .attr('action', form.attr('action'))
241 .attr('method', form.attr('method'));
242 form.find('input[type="hidden"]')
243 .add(table.$('input:checkbox:checked'))
245 var input = $('<input type="hidden">')
246 .attr('name', $(this).attr('name'))
247 .attr('value', $(this).attr('value'));
248 new_form.append(input);
250 $(document.body).append(new_form);
254 $(".CheckNone").click(function(e){
256 var form = $(this).data("form");
257 $("#" + form ).find('table input[type="checkbox"]').prop('checked', false);
258 enableCheckboxActions($("#" + form ));
260 $(".CheckAll").click(function(e){
262 var form = $(this).data("form");
263 $("#" + form ).find('table input[type="checkbox"]').prop('checked', true);
264 enableCheckboxActions($("#" + form ));
267 $('#tabs table').on('click', 'input:checkbox', function() {
268 var form = $(this).parents("form").first();
269 enableCheckboxActions(form);
272 $(".action_delete").click(function(e){
274 var form = $(this).parents("form").first();
275 var table = form.find('table').dataTable();
276 var ids = table.$("input:checkbox:checked");
277 if ( $(ids).length < 1 ) {
282 if (ids.length == 1) {
283 msg = _("Are you sure you want to delete the selected search history entry?");
285 msg = _("Are you sure you want to delete the %s selected search history entries?").format(ids.length);
288 if ( confirm(msg) ) {
294 $('#tabs form').each(function() {
295 enableCheckboxActions($(this));
299 function enableCheckboxActions(form){
300 // Enable/disable controls if checkboxes are checked
301 var table = form.find('table').dataTable();
302 var checked_count = table.$("input:checkbox:checked").length;
304 if (checked_count == 1) {
305 form.find(".selections").html(_("With selected search: "));
307 form.find(".selections").html(_("With %s selected searches: ").format(checked_count));
309 form.find(".selections-toolbar .links a").removeClass("disabled");
311 form.find(".selections").html(_("Select searches to: "));
312 form.find(".selections-toolbar .links a").addClass("disabled");
319 [% INCLUDE 'intranet-bottom.inc' %]