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 <div id="breadcrumbs">
17 <a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> › Search history
20 <div class="container-fluid">
22 <div class="col-sm-12 col-md-8 col-md-offset-2">
24 <h1>Search history</h1>
25 <div id="tabs" class="toptabs">
27 <li><a href="#biblio_tab">Catalog</a></li>
28 <li><a href="#authority_tab">Authority</a></li>
31 [% IF ( current_biblio_searches ) %]
32 <h2>Current session</h2>
33 <form id="current_cat" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
34 <p class="selections-toolbar">
35 <a class="CheckAll" data-form="current_cat" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
36 <span class="sep">|</span>
37 <a class="CheckNone" data-form="current_cat" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
38 <span class="sep">|</span>
40 <span class="selections">Select searches to: </span>
41 <a href="#" class="action_delete disabled">Delete</a>
44 <input type="hidden" name="action" value="delete" />
45 <table class="historyt">
55 [% FOREACH s IN current_biblio_searches %]
57 <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
58 <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
59 <td><a href="/cgi-bin/koha/catalogue/search.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
60 <td>[% s.total | html %]</td>
68 [% IF ( current_biblio_searches && previous_biblio_searches) %]
72 [% IF ( previous_biblio_searches ) %]
73 <h2>Previous sessions</h2>
74 <form id="previous_cat" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
75 <p class="selections-toolbar">
76 <a class="CheckAll" data-form="previous_cat" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
77 <span class="sep">|</span>
78 <a class="CheckNone" data-form="previous_cat" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
79 <span class="sep">|</span>
81 <span class="selections">Select searches to: </span>
82 <a href="#" class="action_delete disabled">Delete</a>
85 <input type="hidden" name="action" value="delete" />
86 <table class="historyt">
96 [% FOREACH s IN previous_biblio_searches %]
98 <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
99 <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
100 <td><a href="/cgi-bin/koha/catalogue/search.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
101 <td>[% s.total | html %]</td>
109 [% IF !current_biblio_searches && !previous_biblio_searches %]
110 <p>Your catalog search history is empty.</p>
114 <div id="authority_tab">
115 [% IF ( current_authority_searches ) %]
116 <h2>Current session</h2>
117 <form id="current_auth" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
118 <p class="selections-toolbar">
119 <a class="CheckAll" data-form="current_auth" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
120 <span class="sep">|</span>
121 <a class="CheckNone" data-form="current_auth" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
122 <span class="sep">|</span>
124 <span class="selections">Select searches to: </span>
125 <a href="#" class="action_delete disabled">Delete</a>
128 <input type="hidden" name="action" value="delete" />
129 <table class="historyt">
139 [% FOREACH s IN current_authority_searches %]
141 <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
142 <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
143 <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
144 <td>[% s.total | html %]</td>
152 [% IF ( current_authority_searches && previous_authority_searches) %]
156 [% IF ( previous_authority_searches ) %]
157 <h2>Previous sessions</h2>
158 <form id="previous_auth" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
159 <p class="selections-toolbar">
160 <a class="CheckAll" data-form="previous_auth" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
161 <span class="sep">|</span>
162 <a class="CheckNone" data-form="previous_auth" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
163 <span class="sep">|</span>
165 <span class="selections">Select searches to: </span>
166 <a href="#" class="action_delete disabled">Delete</a>
169 <input type="hidden" name="action" value="delete" />
170 <table class="historyt">
180 [% FOREACH s IN previous_authority_searches %]
182 <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
183 <td><span title="[% s.time | html %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
184 <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
185 <td>[% s.total | html %]</td>
193 [% IF !current_authority_searches && !previous_authority_searches %]
194 <p>Your authority search history is empty.</p>
196 </div> [% # /authority_tab %]
198 </div> [% # /div.col-md-8 %]
199 </div> [% # /div.row %]
201 [% MACRO jsinclude BLOCK %]
202 [% INCLUDE 'datatables.inc' %]
204 $(document).ready(function() {
205 // We show table ordered by descending dates by default
206 // (so that the more recent query is shown first)
207 $(".historyt").dataTable($.extend(true, {}, dataTablesDefaults, {
208 "aaSorting": [[ 1, "desc" ]],
210 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
211 { "aTargets": [ 1 ], "sType": "title-string" },
213 "sPaginationType": "full_numbers"
218 // DataTables removes hidden rows from the DOM, so we can't expect a
219 // "regular" submit to work and we need to build another form containing
220 // all form elements, and then submit this form.
221 $('#tabs form').submit(function(e) {
225 var table = form.find('table').dataTable();
227 var new_form = $('<form>')
228 .attr('action', form.attr('action'))
229 .attr('method', form.attr('method'));
230 form.find('input[type="hidden"]')
231 .add(table.$('input:checkbox:checked'))
233 var input = $('<input type="hidden">')
234 .attr('name', $(this).attr('name'))
235 .attr('value', $(this).attr('value'));
236 new_form.append(input);
238 $(document.body).append(new_form);
242 $(".CheckNone").click(function(e){
244 var form = $(this).data("form");
245 $("#" + form ).find('table input[type="checkbox"]').prop('checked', false);
246 enableCheckboxActions($("#" + form ));
248 $(".CheckAll").click(function(e){
250 var form = $(this).data("form");
251 $("#" + form ).find('table input[type="checkbox"]').prop('checked', true);
252 enableCheckboxActions($("#" + form ));
255 $('#tabs table').on('click', 'input:checkbox', function() {
256 var form = $(this).parents("form").first();
257 enableCheckboxActions(form);
260 $(".action_delete").click(function(e){
262 var form = $(this).parents("form").first();
263 var table = form.find('table').dataTable();
264 var ids = table.$("input:checkbox:checked");
265 if ( $(ids).length < 1 ) {
270 if (ids.length == 1) {
271 msg = _("Are you sure you want to delete the selected search history entry?");
273 msg = _("Are you sure you want to delete the %s selected search history entries?").format(ids.length);
276 if ( confirm(msg) ) {
282 $('#tabs form').each(function() {
283 enableCheckboxActions($(this));
287 function enableCheckboxActions(form){
288 // Enable/disable controls if checkboxes are checked
289 var table = form.find('table').dataTable();
290 var checked_count = table.$("input:checkbox:checked").length;
292 if (checked_count == 1) {
293 form.find(".selections").html(_("With selected search: "));
295 form.find(".selections").html(_("With %s selected searches: ").format(checked_count));
297 form.find(".selections-toolbar .links a").removeClass("disabled");
299 form.find(".selections").html(_("Select searches to: "));
300 form.find(".selections-toolbar .links a").addClass("disabled");
307 [% INCLUDE 'intranet-bottom.inc' %]