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