Bug 11430 [Follow-up] Search history: Delete selected lines
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-search-history.tt
1 [% USE Koha %]
2 [% USE KohaDates %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your search history
5 [% INCLUDE 'doc-head-close.inc' %]
6 [% BLOCK cssinclude %][% END %]
7 </head>
8 [% INCLUDE 'bodytag.inc' bodyid='opac-search-history' bodyclass='scrollto' %]
9 [% INCLUDE 'masthead.inc' %]
10
11 <div class="main">
12     <ul class="breadcrumb">
13         <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
14         [% IF ( loggedinusername ) %]
15             <li><a href="#">Your search history</a></li>
16         [% ELSE %]
17             <li><a href="#">Search history</a></li>
18         [% END %]
19     </ul>
20
21     <div class="container-fluid">
22         <div class="row-fluid">
23             [% IF ( OpacNav||loggedinusername ) %]
24                 <div class="span2">
25                     <div id="navigation">
26                         [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
27                     </div>
28                 </div>
29                 <div class="span10">
30             [% ELSE %]
31                 <div class="span12">
32             [% END %]
33                 <div id="searchhistory" class="maincontent">
34                     <h1>Search history</h1>
35                     [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]
36                         <div id="tabs" class="toptabs">
37                             <ul>
38                                 <li><a href="#biblio_tab">Catalog</a></li>
39                                 <li><a href="#authority_tab">Authority</a></li>
40                             </ul>
41                     [% END %]
42                         <div id="biblio_tab">
43                             <div id="current_biblio">
44                                 [% IF ( current_biblio_searches ) %]
45                                     <h2>Current session</h2>
46                                     <form action="/cgi-bin/koha/opac-search-history.pl" method="get">
47                                         <div class="selections-toolbar toolbar">
48                                             <a class="CheckAll" href="#">Select all</a>
49                                             <a class="CheckNone" href="#">Clear all</a>
50                                             <span class="sep">|</span>
51                                             <span class="links">
52                                                 <span class="selections">Select searches to: </span>
53                                                 <a href="#" class="removeitems disabled">Delete</a>
54                                             </span>
55                                         </div>
56                                         <input type="hidden" name="action" value="delete" />
57                                         <table class="historyt table table-bordered table-striped">
58                                             <thead>
59                                                 <tr>
60                                                     <th></th>
61                                                     <th>Date</th>
62                                                     <th>Search</th>
63                                                     <th>Results</th>
64                                                 </tr>
65                                             </thead>
66                                             <tbody>
67                                                 [% FOREACH s IN current_biblio_searches %]
68                                                     <tr>
69                                                         <td><input type="checkbox" name="id" value="[% s.id %]" /></td>
70                                                         <td><span title="[% s.time %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
71                                                         <td><a href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html |url %][% limit_cgi |html | url %]&amp;[% s.query_cgi |html %]&amp;count=[% countrss |html %]&amp;sort_by=acqdate_dsc&amp;format=rss2" class="rsssearchlink"><img src="[% interface %]/[% theme %]/images/feed-icon-16x16.png" alt="Subscribe to this search" title="Subscribe to this search" class="rsssearchicon"/></a> <a href="/cgi-bin/koha/opac-search.pl?[% s.query_cgi |html %]">[% s.query_desc |html %]</a></td>
72                                                         <td>[% s.total %]</td>
73                                                     </tr>
74                                                 [% END %]
75                                             </tbody>
76                                         </table>
77                                         <input type="submit" class="btn btn-danger remove-selected" value="Remove selected searches">
78                                     </form>
79                                 [% END # IF ( current_biblio_searches ) %]
80                             </div> <!-- / #current_biblio -->
81
82                             <div id="previous_biblio">
83                                 [% IF ( previous_biblio_searches ) %]
84                                     <h2>Previous sessions</h2>
85                                     <form action="/cgi-bin/koha/opac-search-history.pl" method="get">
86                                         <div class="selections-toolbar toolbar">
87                                             <a class="CheckAll" href="#">Select all</a>
88                                             <a class="CheckNone" href="#">Clear all</a>
89                                             <span class="sep">|</span>
90                                             <span class="links">
91                                                 <span class="selections">Select searches to: </span>
92                                                 <a href="#" class="removeitems disabled">Delete</a>
93                                             </span>
94                                         </div>
95
96                                         <input type="hidden" name="action" value="delete" />
97                                         <table class="historyt table table-bordered table-striped">
98                                             <thead>
99                                                 <tr>
100                                                     <th></th>
101                                                     <th>Date</th>
102                                                     <th>Search</th>
103                                                     <th>Results</th>
104                                                 </tr>
105                                             </thead>
106                                             <tbody>
107                                             [% FOREACH s IN previous_biblio_searches %]
108                                                 <tr>
109                                                     <td><input type="checkbox" name="id" value="[% s.id %]" /></td>
110                                                     <td><span title="[% s.time %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
111                                                     <td><a href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi |html |url %][% limit_cgi |html | url %]&amp;[% s.query_cgi |html %]&amp;count=[% countrss |html %]&amp;sort_by=acqdate_dsc&amp;format=rss2" class="rsssearchlink"><img src="[% interface %]/[% theme %]/images/feed-icon-16x16.png" alt="Subscribe to this search" title="Subscribe to this search" class="rsssearchicon"/></a> <a href="/cgi-bin/koha/opac-search.pl?[% s.query_cgi |html %]">[% s.query_desc |html %]</a></td>
112                                                     <td>[% s.total %]</td>
113                                                 </tr>
114                                             [% END %]
115                                             </tbody>
116                                         </table>
117                                         <input type="submit" class="btn btn-danger remove-selected" value="Remove selected searches">
118                                     </form>
119                                 [% END # IF ( previous_biblio_searches ) %]
120                             </div> <!-- / #previous_biblio -->
121
122                             [% IF !current_biblio_searches && !previous_biblio_searches %]
123                                 <p>Your catalog search history is empty.</p>
124                             [% END %]
125                         </div> <!-- / #biblio_tab -->
126
127                         [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]
128                             <div id="authority_tab">
129                                 [% IF ( current_authority_searches ) %]
130                                     <h2>Current session</h2>
131                                     <form action="/cgi-bin/koha/opac-search-history.pl" method="get">
132                                         <div class="selections-toolbar toolbar">
133                                             <a class="CheckAll" href="#">Select all</a>
134                                             <a class="CheckNone" href="#">Clear all</a>
135                                             <span class="sep">|</span>
136                                             <span class="links">
137                                                 <span class="selections">Select searches to: </span>
138                                                 <a href="#" class="removeitems disabled">Delete</a>
139                                             </span>
140                                         </div>
141                                         <input type="hidden" name="action" value="delete" />
142                                         <table class="historyt table table-bordered table-striped">
143                                             <thead>
144                                                 <tr>
145                                                     <th></th>
146                                                     <th>Date</th>
147                                                     <th>Search</th>
148                                                     <th>Results</th>
149                                                 </tr>
150                                             </thead>
151                                             <tbody>
152                                                 [% FOREACH s IN current_authority_searches %]
153                                                     <tr>
154                                                         <td><input type="checkbox" name="id" value="[% s.id %]" /></td>
155                                                         <td><span title="[% s.time %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
156                                                         <td><a href="/cgi-bin/koha/opac-authorities-home.pl?[% s.query_cgi |html %]">[% s.query_desc |html %]</a></td>
157                                                         <td>[% s.total %]</td>
158                                                     </tr>
159                                                 [% END %]
160                                             </tbody>
161                                         </table>
162                                         <input type="submit" class="btn btn-danger remove-selected" value="Remove selected searches">
163                                     </form>
164                                 [% END # / IF ( current_authority_searches ) %]
165
166                                 [% IF ( previous_authority_searches ) %]
167                                     <h2>Previous sessions</h2>
168                                     <form action="/cgi-bin/koha/opac-search-history.pl" method="get">
169                                         <div class="selections-toolbar toolbar">
170                                             <a class="CheckAll" href="#">Select all</a>
171                                             <a class="CheckNone" href="#">Clear all</a>
172                                             <span class="sep">|</span>
173                                             <span class="links">
174                                                 <span class="selections">Select searches to: </span>
175                                                 <a href="#" class="removeitems disabled">Delete</a>
176                                             </span>
177                                         </div>
178                                         <input type="hidden" name="action" value="delete" />
179                                         <table class="historyt table table-bordered table-striped">
180                                             <thead>
181                                                 <tr>
182                                                     <th></th>
183                                                     <th>Date</th>
184                                                     <th>Search</th>
185                                                     <th>Results</th>
186                                                 </tr>
187                                             </thead>
188                                             <tbody>
189                                                 [% FOREACH s IN previous_authority_searches %]
190                                                     <tr>
191                                                         <td><input type="checkbox" name="id" value="[% s.id %]" /></td>
192                                                         <td><span title="[% s.time %]">[% s.time |$KohaDates with_hours => 1 %]</span></td>
193                                                         <td><a href="/cgi-bin/koha/opac-authorities-home.pl?[% s.query_cgi |html %]">[% s.query_desc |html %]</a></td>
194                                                         <td>[% s.total %]</td>
195                                                     </tr>
196                                                 [% END %]
197                                             </tbody>
198                                         </table>
199                                         <input type="submit" class="btn btn-danger remove-selected" value="Remove selected searches">
200                                     </form>
201                                 [% END # / IF ( previous_authority_searches )%]
202
203                                 [% IF !current_authority_searches && !previous_authority_searches %]
204                                     <p>Your authority search history is empty.</p>
205                                 [% END %]
206                             </div> <!-- / #authority_tab -->
207                         [% END # / IF Koha.Preference( 'OpacAuthorities' ) %]
208                     </div> <!-- / #tabs -->
209                 </div> <!-- / #searchhistory -->
210             </div> <!-- / .span10/12 -->
211         </div> <!-- / .row-fluid -->
212     </div> <!-- / .container-fluid -->
213 </div> <!-- / #main -->
214
215 [% INCLUDE 'opac-bottom.inc' %]
216 [% BLOCK jsinclude %]
217 [% INCLUDE 'datatables.inc' %]
218 <script type="text/javascript" src="[% interface %]/[% theme %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
219 <script type="text/javascript">
220 //<![CDATA[
221     var MSG_CONFIRM_DELETE_HISTORY = _("Are you sure you want to delete selected search history entries?");
222     $(document).ready(function() {
223         // We show table ordered by descending dates by default
224         // (so that the more recent query is shown first)
225         $(".historyt").dataTable($.extend(true, {}, dataTablesDefaults, {
226             "aaSorting": [[ 1, "desc" ]],
227             "aoColumnDefs": [
228                 { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
229                 { "aTargets": [ 1 ], "sType": "title-string" },
230             ]
231         }));
232
233         [% IF Koha.Preference( 'OpacAuthorities' ) == 1 %]$('#tabs').tabs();[% END %]
234
235         $(".CheckNone").click(function(e){
236             e.preventDefault();
237             var form = $(this).parents("form").get(0);
238             $(form).unCheckCheckboxes();
239             enableCheckboxActions(form);
240         });
241         $(".CheckAll").click(function(e){
242             e.preventDefault();
243             var form = $(this).parents("form").get(0);
244             $(form).checkCheckboxes();
245             enableCheckboxActions(form);
246         });
247
248         $("input:checkbox").click(function(){
249             var form = $(this).parents("form").get(0);
250             enableCheckboxActions(form);
251         });
252
253         $(".removeitems,.remove-selected").click(function(e){
254             e.preventDefault();
255             var form = $(this).parents("form").get(0);
256             var ids = $(form).find("input:checkbox:checked");
257             if ( $(ids).length < 1 ) {
258                 return false;
259             }
260             if ( confirm(MSG_CONFIRM_DELETE_HISTORY) ) {
261                 $(form).submit();
262             }
263             return false;
264         });
265     });
266
267     function enableCheckboxActions(form){
268         // Enable/disable controls if checkboxes are checked
269         var checkedBoxes = $(form).find("input:checkbox:checked");
270         if ($(checkedBoxes).size()) {
271             $(form).find(".selections").html(_("With selected searches: "));
272             $(form).find(".selections-toolbar .links a").removeClass("disabled");
273         } else {
274             $(form).find(".selections").html(_("Select searches to: "));
275             $(form).find(".selections-toolbar .links a").addClass("disabled");
276         }
277     }
278
279 //]]>
280
281 </script>
282 [% END %]