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