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