Bug 21225: (follow-up) Account for Syndetics lightbox
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / catalogue / search-history.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 [% USE Koha %]
6 [% USE KohaDates %]
7 <title>Search history &rsaquo; Catalog &rsaquo; Koha</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 </head>
10
11 <body id="catalogue_search-history" class="catalogue">
12
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'cat-search.inc' %]
15
16 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
17     <ol>
18         <li>
19             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
20         </li>
21         <li>
22             <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a>
23         </li>
24         <li>
25             <a href="#" aria-current="page">
26                 Search history
27             </a>
28         </li>
29     </ol>
30 </nav>
31
32 <div class="container-fluid">
33     <div class="row">
34         <div class="col-sm-12 col-md-8 col-md-offset-2">
35
36       <h1>Search history</h1>
37         <div id="tabs" class="toptabs">
38             <ul class="nav nav-tabs" role="tablist">
39                 <li role="presentation" class="active"><a href="#biblio_tab" aria-controls="biblio_tab" role="tab" data-toggle="tab">Catalog</a></li>
40                 <li role="presentation"><a href="#authority_tab" aria-controls="authority_tab" role="tab" data-toggle="tab">Authority</a></li>
41             </ul>
42             <div class="tab-content">
43                 <div role="tabpanel" class="tab-pane active" id="biblio_tab">
44                     [% IF ( current_biblio_searches ) %]
45                         <h2>Current session</h2>
46                         <form id="current_cat" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
47                             <p class="selections-toolbar">
48                                 <a class="CheckAll" data-form="current_cat" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
49                                 <span class="sep">|</span>
50                                 <a class="CheckNone" data-form="current_cat" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
51                                 <span class="sep">|</span>
52                                 <span class="links">
53                                 <span class="selections">Select searches to: </span>
54                                 <a href="#" class="action_delete disabled">Delete</a>
55                                 </span>
56                             </p>
57                             <input type="hidden" name="action" value="delete" />
58                             <table class="historyt">
59                                 <thead>
60                                     <tr>
61                                         <th></th>
62                                         <th>Date</th>
63                                         <th>Search</th>
64                                         <th>Results</th>
65                                     </tr>
66                                 </thead>
67                                 <tbody>
68                                     [% FOREACH s IN current_biblio_searches %]
69                                         <tr>
70                                             <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
71                                             <td data-order="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</td>
72                                             <td><a href="/cgi-bin/koha/catalogue/search.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
73                                             <td>[% s.total | html %]</td>
74                                         </tr>
75                                     [% END %]
76                                 </tbody>
77                             </table>
78                         </form>
79                     [% END %]
80
81                     [% IF ( current_biblio_searches && previous_biblio_searches) %]
82                         <hr />
83                     [% END %]
84
85                     [% IF ( previous_biblio_searches ) %]
86                         <h2>Previous sessions</h2>
87                         <form id="previous_cat" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
88                             <p class="selections-toolbar">
89                                 <a class="CheckAll" data-form="previous_cat" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
90                                 <span class="sep">|</span>
91                                 <a class="CheckNone" data-form="previous_cat" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
92                                 <span class="sep">|</span>
93                                 <span class="links">
94                                 <span class="selections">Select searches to: </span>
95                                 <a href="#" class="action_delete disabled">Delete</a>
96                                 </span>
97                             </p>
98                             <input type="hidden" name="action" value="delete" />
99                             <table class="historyt">
100                                 <thead>
101                                     <tr>
102                                         <th></th>
103                                         <th>Date</th>
104                                         <th>Search</th>
105                                         <th>Results</th>
106                                     </tr>
107                                 </thead>
108                                 <tbody>
109                                     [% FOREACH s IN previous_biblio_searches %]
110                                         <tr>
111                                             <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
112                                             <td data-order="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</td>
113                                             <td><a href="/cgi-bin/koha/catalogue/search.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
114                                             <td>[% s.total | html %]</td>
115                                         </tr>
116                                     [% END %]
117                                 </tbody>
118                             </table>
119                         </form>
120                     [% END %]
121
122                     [% IF !current_biblio_searches && !previous_biblio_searches %]
123                         <p>Your catalog search history is empty.</p>
124                     [% END %]
125                 </div> <!-- /#biblio_tab -->
126
127                 <div id="authority_tab" role="tabpanel" class="tab-pane">
128                     [% IF ( current_authority_searches ) %]
129                         <h2>Current session</h2>
130                         <form id="current_auth" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
131                             <p class="selections-toolbar">
132                                 <a class="CheckAll" data-form="current_auth" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
133                                 <span class="sep">|</span>
134                                 <a class="CheckNone" data-form="current_auth" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
135                                 <span class="sep">|</span>
136                                 <span class="links">
137                                 <span class="selections">Select searches to: </span>
138                                 <a href="#" class="action_delete disabled">Delete</a>
139                                 </span>
140                             </p>
141                             <input type="hidden" name="action" value="delete" />
142                             <table class="historyt">
143                                 <thead>
144                                     <tr>
145                                         <th></th>
146                                         <th>Date</th>
147                                         <th>Search</th>
148                                         <th>Results</th>
149                                     </tr>
150                                 </thead>
151                                 <tbody>
152                                     [% FOREACH s IN current_authority_searches %]
153                                         <tr>
154                                             <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
155                                             <td data-order="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</td>
156                                             <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
157                                             <td>[% s.total | html %]</td>
158                                         </tr>
159                                     [% END %]
160                                 </tbody>
161                             </table>
162                         </form>
163                     [% END %]
164
165                     [% IF ( current_authority_searches && previous_authority_searches) %]
166                         <hr />
167                     [% END %]
168
169                     [% IF ( previous_authority_searches ) %]
170                         <h2>Previous sessions</h2>
171                         <form id="previous_auth" action="/cgi-bin/koha/catalogue/search-history.pl" method="post">
172                             <p class="selections-toolbar">
173                                 <a class="CheckAll" data-form="previous_auth" href="#"><i class="fa fa-check"></i> Select all visible rows</a>
174                                 <span class="sep">|</span>
175                                 <a class="CheckNone" data-form="previous_auth" href="#"><i class="fa fa-remove"></i> Clear selection on visible rows</a>
176                                 <span class="sep">|</span>
177                                 <span class="links">
178                                 <span class="selections">Select searches to: </span>
179                                 <a href="#" class="action_delete disabled">Delete</a>
180                                 </span>
181                             </p>
182                             <input type="hidden" name="action" value="delete" />
183                             <table class="historyt">
184                                 <thead>
185                                     <tr>
186                                         <th></th>
187                                         <th>Date</th>
188                                         <th>Search</th>
189                                         <th>Results</th>
190                                     </tr>
191                                 </thead>
192                                 <tbody>
193                                     [% FOREACH s IN previous_authority_searches %]
194                                         <tr>
195                                             <td><input type="checkbox" name="id" value="[% s.id | html %]" /></td>
196                                             <td data-order="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</td>
197                                             <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
198                                             <td>[% s.total | html %]</td>
199                                         </tr>
200                                     [% END %]
201                                 </tbody>
202                             </table>
203                         </form>
204                     [% END %]
205
206                     [% IF !current_authority_searches && !previous_authority_searches %]
207                         <p>Your authority search history is empty.</p>
208                     [% END %]
209                 </div> [% # /authority_tab %]
210             </div> <!-- /.tab-content -->
211         </div> [% # /tabs %]
212     </div> [% # /div.col-md-8 %]
213   </div> [% # /div.row %]
214
215 [% MACRO jsinclude BLOCK %]
216     [% INCLUDE 'datatables.inc' %]
217     <script>
218     $(document).ready(function() {
219         // We show table ordered by descending dates by default
220         // (so that the more recent query is shown first)
221         $(".historyt").dataTable($.extend(true, {}, dataTablesDefaults, {
222             "aaSorting": [[ 1, "desc" ]],
223             "aoColumnDefs": [
224                 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }
225             ],
226             "sPaginationType": "full_numbers"
227         }));
228
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) {
233             e.preventDefault();
234
235             var form = $(this);
236             var table = form.find('table').dataTable();
237
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'))
243                 .each(function() {
244                     var input = $('<input type="hidden">')
245                         .attr('name', $(this).attr('name'))
246                         .attr('value', $(this).attr('value'));
247                     new_form.append(input);
248                 });
249             $(document.body).append(new_form);
250             new_form.submit();
251         });
252
253         $(".CheckNone").click(function(e){
254             e.preventDefault();
255             var form = $(this).data("form");
256             $("#" + form ).find('table input[type="checkbox"]').prop('checked', false);
257             enableCheckboxActions($("#" + form ));
258         });
259         $(".CheckAll").click(function(e){
260             e.preventDefault();
261             var form = $(this).data("form");
262             $("#" + form ).find('table input[type="checkbox"]').prop('checked', true);
263             enableCheckboxActions($("#" + form ));
264         });
265
266         $('#tabs table').on('click', 'input:checkbox', function() {
267             var form = $(this).parents("form").first();
268             enableCheckboxActions(form);
269         });
270
271         $(".action_delete").click(function(e){
272             e.preventDefault();
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 ) {
277                 return false;
278             }
279
280             var msg;
281             if (ids.length == 1) {
282               msg = _("Are you sure you want to delete the selected search history entry?");
283             } else {
284               msg = _("Are you sure you want to delete the %s selected search history entries?").format(ids.length);
285             }
286
287             if ( confirm(msg) ) {
288                 form.submit();
289             }
290             return false;
291         });
292
293         $('#tabs form').each(function() {
294             enableCheckboxActions($(this));
295         });
296     });
297
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;
302         if (checked_count) {
303           if (checked_count == 1) {
304             form.find(".selections").html(_("With selected search: "));
305           } else {
306             form.find(".selections").html(_("With %s selected searches: ").format(checked_count));
307           }
308           form.find(".selections-toolbar .links a").removeClass("disabled");
309         } else {
310           form.find(".selections").html(_("Select searches to: "));
311           form.find(".selections-toolbar .links a").addClass("disabled");
312         }
313     }
314
315     </script>
316 [% END %]
317
318 [% INCLUDE 'intranet-bottom.inc' %]