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 data-order="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</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 data-order="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</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 data-order="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</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 data-order="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</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 }
224 "sPaginationType": "full_numbers"
229 // DataTables removes hidden rows from the DOM, so we can't expect a
230 // "regular" submit to work and we need to build another form containing
231 // all form elements, and then submit this form.
232 $('#tabs form').submit(function(e) {
236 var table = form.find('table').dataTable();
238 var new_form = $('<form>')
239 .attr('action', form.attr('action'))
240 .attr('method', form.attr('method'));
241 form.find('input[type="hidden"]')
242 .add(table.$('input:checkbox:checked'))
244 var input = $('<input type="hidden">')
245 .attr('name', $(this).attr('name'))
246 .attr('value', $(this).attr('value'));
247 new_form.append(input);
249 $(document.body).append(new_form);
253 $(".CheckNone").click(function(e){
255 var form = $(this).data("form");
256 $("#" + form ).find('table input[type="checkbox"]').prop('checked', false);
257 enableCheckboxActions($("#" + form ));
259 $(".CheckAll").click(function(e){
261 var form = $(this).data("form");
262 $("#" + form ).find('table input[type="checkbox"]').prop('checked', true);
263 enableCheckboxActions($("#" + form ));
266 $('#tabs table').on('click', 'input:checkbox', function() {
267 var form = $(this).parents("form").first();
268 enableCheckboxActions(form);
271 $(".action_delete").click(function(e){
273 var form = $(this).parents("form").first();
274 var table = form.find('table').dataTable();
275 var ids = table.$("input:checkbox:checked");
276 if ( $(ids).length < 1 ) {
281 if (ids.length == 1) {
282 msg = _("Are you sure you want to delete the selected search history entry?");
284 msg = _("Are you sure you want to delete the %s selected search history entries?").format(ids.length);
287 if ( confirm(msg) ) {
293 $('#tabs form').each(function() {
294 enableCheckboxActions($(this));
298 function enableCheckboxActions(form){
299 // Enable/disable controls if checkboxes are checked
300 var table = form.find('table').dataTable();
301 var checked_count = table.$("input:checkbox:checked").length;
303 if (checked_count == 1) {
304 form.find(".selections").html(_("With selected search: "));
306 form.find(".selections").html(_("With %s selected searches: ").format(checked_count));
308 form.find(".selections-toolbar .links a").removeClass("disabled");
310 form.find(".selections").html(_("Select searches to: "));
311 form.find(".selections-toolbar .links a").addClass("disabled");
318 [% INCLUDE 'intranet-bottom.inc' %]