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