Bug 22981: Remove type attribute from script tags: Catalog
[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>Koha &rsaquo; Catalog &rsaquo; Search history</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 <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 | 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>
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 | html %]" /></td>
95                     <td><span title="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</span></td>
96                     <td><a href="/cgi-bin/koha/catalogue/search.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
97                     <td>[% s.total | html %]</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 | html %]" /></td>
138                     <td><span title="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</span></td>
139                     <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
140                     <td>[% s.total | html %]</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 | html %]" /></td>
175                     <td><span title="[% s.time | html %]">[% s.time |$KohaDates  with_hours => 1 %]</span></td>
176                     <td><a href="/cgi-bin/koha/authorities/authorities-home.pl?[% s.query_cgi | $raw %]">[% s.query_desc | html %]</a></td>
177                     <td>[% s.total | html %]</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") | $raw %]
196     <script>
197     $(document).ready(function() {
198         // We show table ordered by descending dates by default
199         // (so that the more recent query is shown first)
200         $(".historyt").dataTable($.extend(true, {}, dataTablesDefaults, {
201             "aaSorting": [[ 1, "desc" ]],
202             "aoColumnDefs": [
203                 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
204                 { "aTargets": [ 1 ], "sType": "title-string" },
205             ],
206             "sPaginationType": "full_numbers"
207         }));
208
209         $('#tabs').tabs();
210
211         // DataTables removes hidden rows from the DOM, so we can't expect a
212         // "regular" submit to work and we need to build another form containing
213         // all form elements, and then submit this form.
214         $('#tabs form').submit(function(e) {
215             e.preventDefault();
216
217             var form = $(this);
218             var table = form.find('table').dataTable();
219
220             var new_form = $('<form>')
221                 .attr('action', form.attr('action'))
222                 .attr('method', form.attr('method'));
223             form.find('input[type="hidden"]')
224                 .add(table.$('input:checkbox:checked'))
225                 .each(function() {
226                     var input = $('<input type="hidden">')
227                         .attr('name', $(this).attr('name'))
228                         .attr('value', $(this).attr('value'));
229                     new_form.append(input);
230                 });
231             $(document.body).append(new_form);
232             new_form.submit();
233         });
234
235         $(".CheckNone").click(function(e){
236             e.preventDefault();
237             var form = $(this).parents("form").first();
238             form.find('table input[type="checkbox"]').prop('checked', false);
239             enableCheckboxActions(form);
240         });
241         $(".CheckAll").click(function(e){
242             e.preventDefault();
243             var form = $(this).parents("form").first();
244             form.find('table input[type="checkbox"]').prop('checked', true);
245             enableCheckboxActions(form);
246         });
247
248         $('#tabs table').on('click', 'input:checkbox', function() {
249             var form = $(this).parents("form").first();
250             enableCheckboxActions(form);
251         });
252
253         $(".action_delete").click(function(e){
254             e.preventDefault();
255             var form = $(this).parents("form").first();
256             var table = form.find('table').dataTable();
257             var ids = table.$("input:checkbox:checked");
258             if ( $(ids).length < 1 ) {
259                 return false;
260             }
261
262             var msg;
263             if (ids.length == 1) {
264               msg = _("Are you sure you want to delete the selected search history entry?");
265             } else {
266               msg = _("Are you sure you want to delete the %s selected search history entries?").format(ids.length);
267             }
268
269             if ( confirm(msg) ) {
270                 form.submit();
271             }
272             return false;
273         });
274
275         $('#tabs form').each(function() {
276             enableCheckboxActions($(this));
277         });
278     });
279
280     function enableCheckboxActions(form){
281         // Enable/disable controls if checkboxes are checked
282         var table = form.find('table').dataTable();
283         var checked_count = table.$("input:checkbox:checked").length;
284         if (checked_count) {
285           if (checked_count == 1) {
286             form.find(".selections").html(_("With selected search: "));
287           } else {
288             form.find(".selections").html(_("With %s selected searches: ").format(checked_count));
289           }
290           form.find(".selections-toolbar .links a").removeClass("disabled");
291         } else {
292           form.find(".selections").html(_("Select searches to: "));
293           form.find(".selections-toolbar .links a").addClass("disabled");
294         }
295     }
296
297     </script>
298 [% END %]
299
300 [% INCLUDE 'intranet-bottom.inc' %]