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