Bug 21526: uri escape TT variables when used in 'a href'
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / serials / serials-search.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE AuthorisedValues %]
4 [% USE Branches %]
5 [% USE CGI %]
6 [% USE KohaDates %]
7 [% SET footerjs = 1 %]
8 [% INCLUDE 'doc-head-open.inc' %]
9 <title>Koha &rsaquo; Serials [% biblionumber | html %]</title>
10 [% INCLUDE 'doc-head-close.inc' %]
11 [% Asset.css("css/datatables.css") | $raw %]
12 <style type="text/css">input.dt-filter { width : 100%; font-size : 85%; }</style>
13 </head>
14
15 <body id="ser_serials-home" class="ser">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'serials-search.inc' %]
18
19 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; [% IF ( done_searched ) %]<a href="/cgi-bin/koha/serials/serials-home.pl">Serials</a> &rsaquo; Search results[% ELSE %]Serials [% END %] </div>
20
21 [% url_params = [] %]
22 [% FOREACH param IN CGI.params.pairs %]
23     [% escaped_value = BLOCK %][% param.value | uri %][% END %]
24     [% url_params.push(param.key _ '=' _ escaped_value) | html %]
25 [% END %]
26 [% SET referrer = '/cgi-bin/koha/serials/serials-search.pl?' %]
27 [% referrer = BLOCK %][% referrer | url %][% url_params.join("&amp;") |uri %][% END %]
28 [% SET edit_action_link = '/cgi-bin/koha/serials/subscription-batchedit.pl?referrer=' _ referrer %]
29
30 [% BLOCK subscriptions_table %]
31   <form method="post">
32
33     [% IF closed %]
34         [% SET tab = 'closed' %]
35     [% ELSE %]
36         [% SET tab = 'opened' %]
37     [% END %]
38     [% IF CAN_user_serials_edit_subscription %]
39         <div class="actions">
40             <a class="select-all" href="#" data-tab="[% tab | html %]"><i class="fa fa-check"></i> Select all</a>
41             |
42             <a class="clear-all" href="#" data-tab="[% tab | html %]"><i class="fa fa-remove"></i> Clear all</a>
43             <span class="itemselection_actions">
44                 | Actions:
45                 <a class="itemselection_action_modify"><i class="fa fa-pencil"></i> Edit selected serials</a>
46             </span>
47         </div>
48     [% END %]
49     <table>
50       <thead>
51         <tr>
52             <th></th>
53             <th>ISSN</th>
54             <th class="anti-the">Title</th>
55             <th>Notes</th>
56             <th>Library</th>
57             <th>Location</th>
58             <th>Call number</th>
59             [% UNLESS closed %]
60                 <th class="title-string">Expiration date</th>
61             [% END %]
62             [% FOR field IN additional_fields_for_subscription %]
63               <th>[% field.name | html %]</th>
64             [% END %]
65             <th class="NoSort">Actions</th>
66         </tr>
67       </thead>
68       <tfoot>
69         <tr>
70           <td></td>
71           <td><input type="text" class="dt-filter" data-column_num="0" placeholder="Search ISSN" /></td>
72           <td><input type="text" class="dt-filter" data-column_num="1" placeholder="Search title" /></td>
73           <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search notes" /></td>
74           <td><input type="text" class="dt-filter" data-column_num="3" placeholder="Search library" /></td>
75           <td><input type="text" class="dt-filter" data-column_num="4" placeholder="Search location" /></td>
76           <td><input type="text" class="dt-filter" data-column_num="5" placeholder="Search callnumber" /></td>
77           [% UNLESS closed %]
78               <td><input type="text" class="dt-filter" data-column_num="6" placeholder="Search expiration date" /></td>
79           [% END %]
80           [% FOR field IN additional_fields_for_subscription %]
81             <td><input type="text" class="dt-filter" data-column_num="[% loop.count + 6 | html %]" placeholder="Search [% field.name | html %]" /></td>
82           [% END %]
83           <td></td>
84         </tr>
85       </tfoot>
86       <tbody>
87         [% FOREACH subscription IN subscriptions %]
88         [% UNLESS subscription.cannotdisplay %]
89           <tr>
90             <td>
91                 [% UNLESS subscription.cannotedit %]
92                     <input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid | html %]" />
93                 [% ELSE %]
94                     <input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid | html %]" disabled="disabled" title="You cannot edit this subscription" />
95                 [% END %]
96             </td>
97             <td>
98             [% IF ( subscription.issn ) %][% subscription.issn | html %]
99             [% END %]
100             </td>
101             <td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid | uri %]" class="button" title="subscription detail">[% subscription.title | html %]</a>
102             </td>
103             <td>[% IF ( subscription.publicnotes ) %][% subscription.publicnotes | html %][% END %]
104             [% IF ( subscription.internalnotes ) %]([% subscription.internalnotes | html %])[% END %]
105             </td>
106             <td>
107               [% IF ( subscription.branchcode ) %][% Branches.GetName( subscription.branchcode ) | html %][% END %]
108             </td>
109             <td>
110               [% IF ( subscription.location ) %][% AuthorisedValues.GetByCode( 'LOC', subscription.location ) | html %][% END %]
111             </td>
112             <td>
113               [% IF ( subscription.callnumber ) %][% subscription.callnumber | html %][% END %]
114             </td>
115             [% UNLESS closed %]
116                 <td>
117                     [% IF ( subscription.enddate ) %]
118                         <span title="[% subscription.enddate | html %]">[% subscription.enddate | $KohaDates %]</span>
119                     [% ELSE %]
120                         <span title="0000-00-00"></span>
121                     [% END %]
122                 </td>
123             [% END %]
124
125             [% FOR field IN additional_fields_for_subscription %]
126               [% IF field.authorised_value_category %]
127                 <td>[% AuthorisedValues.GetByCode( field.authorised_value_category, subscription.additional_fields.${field.name} ) | html %]</td>
128               [% ELSE %]
129                 <td>[% subscription.additional_fields.${field.name} | html %]</td>
130               [% END %]
131             [% END %]
132
133             <td>
134                 <div class="dropdown">
135                     [% IF closed %]
136                         <a class="btn btn-default btn-xs dropdown-toggle" id="closedsubactions[% subscription.subscriptionid | html %]" role="button" data-toggle="dropdown" href="#">
137                            Actions <b class="caret"></b>
138                         </a>
139                         <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="closedsubactions[% subscription.subscriptionid | html %]">
140
141                             [% IF ( routing && CAN_user_serials_routing ) %]
142                                 [% UNLESS ( subscription.cannotedit ) %]
143                                     <li>
144                                         <a href="/cgi-bin/koha/serials/serials-search.pl?subscriptionid=[% subscription.subscriptionid | uri %]&amp;op=reopen&amp;routing=[% subscription.routing | uri %]&amp;searched=1&amp;title_filter=[% title_filter | uri %]&amp;ISSN_filter=[% ISSN_filter | uri %]&amp;EAN_filter=[% EAN_filter | uri %]&amp;published_filter=[% publisher_filter | uri %]&amp;bookseller_filter=[% bookseller_filter | uri %]&amp;branch_filter=[% branch_filter | uri %]" id="reopensub"> <i class="fa fa-repeat"></i> Reopen</a>
145                                     </li>
146                                 [% END %]
147                             [% END # IF ( routing && CAN_user_serials_routing ) %]
148
149                             <li>
150                                 <a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-list-alt"></i> Issue history</a>
151                             </li>
152
153                         </ul>
154                     [% ELSE %]
155                         <div class="btn-group">
156                             [% IF ( CAN_user_serials_receive_serials ) %]
157                                 [%# There should be no space between these two buttons, it would render badly %]
158                                 <a class="btn btn-default btn-xs" role="button"
159                                    href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid | html %]&amp;serstatus=1,3,7"><i
160                                    class="fa fa-inbox"></i> Serial receive</a><a
161                                    class="btn btn-default btn-xs dropdown-toggle" id="subactions[% subscription.subscriptionid | html %]" role="button"
162                                    data-toggle="dropdown" href="#"><b class="caret"></b></a>
163                             [% ELSE %]
164                                 <a class="btn btn-default btn-xs dropdown-toggle" id="subactions[% subscription.subscriptionid | html %]" role="button" data-toggle="dropdown" href="#">Actions <b class="caret"></b></a>
165                             [% END %]
166                         <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="subactions[% subscription.subscriptionid | html %]">
167
168                             [% IF ( routing && CAN_user_serials_routing ) %]
169                                 [% IF ( subscription.cannotedit ) %]
170                                 [% ELSE %]
171                                     [% IF ( subscription.routingedit ) %]
172                                         <li>
173                                             <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-pencil"></i> Edit routing list ([% subscription.routingedit | html %])</a>
174                                         </li>
175                                     [% ELSE %]
176                                         <li>
177                                             <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid | uri %]&amp;op=new"> <i class="fa fa-plus"></i> New routing list</a>
178                                         </li>
179                                     [% END %]
180                                 [% END %]
181                             [% END # IF ( routing && CAN_user_serials_routing ) %]
182
183                             <li>
184                                 <a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-list-alt"></i> Issue history</a>
185                             </li>
186                         </ul>
187                         </div>
188                     [% END %]
189                 </div>
190             </td>
191
192           </tr>
193           [% END %]
194         [% END %]
195       </tbody>
196     </table>
197   </form>
198 [% END %]
199
200 <div class="main container-fluid">
201     <div class="row">
202         <div class="col-sm-10 col-sm-push-2">
203             <main>
204
205       [% INCLUDE 'serials-toolbar.inc' %]
206
207       [% IF ( done_searched ) %]
208         <h2>Serials subscriptions ([% total | html %] found)</h2>
209       [% ELSE %]
210         <h2>Serials subscriptions search</h2>
211       [% END %]
212
213       [% UNLESS ( done_searched ) %]
214       <div id="advsearch" style="padding-bottom:3em;">
215         <form action="/cgi-bin/koha/serials/serials-search.pl" method="get">
216           <fieldset class="rows">
217           <legend>Search subscriptions</legend>
218               <ol>
219                 <li>
220                   <label for="issn">ISSN:</label>
221                   <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter | html %]" />
222                 </li>
223                 <li>
224                   <label for="title">Title:</label>
225                   <input type="text" id="title" name="title_filter" value="[% title_filter | html %]" />
226                 </li>
227                 [% IF ( marcflavour == "UNIMARC" ) %]
228                 <li>
229                   <label for="ean">EAN:</label>
230                   <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter | html %]" />
231                 </li>
232                 [% END %]
233                 <li>
234                   <label for="callnumber">Call number:</label>
235                   <input type="text" id="callnumber" name="callnumber_filter" value="[% callnumber_filter | html %]" />
236                 </li>
237                 <li>
238                   <label for="publisher">Publisher:</label>
239                   <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter | html %]" />
240                 </li>
241                 <li>
242                   <label for="bookseller">Vendor:</label>
243                   <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter | html %]" />
244                 </li>
245                 <li>
246                   <label for="branch">Library:</label>
247                   <select id="branch" name="branch_filter">
248                     <option value="">All</option>
249                     [%# FIXME Should not we filter the libraries? %]
250                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
251                   </select>
252                 </li>
253                 <li>
254                   <label for="location">Location:</label>
255                   [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %]
256                 </li>
257                 <li>
258                   <label for="to">Expires before:</label>
259                   <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
260                 </li>
261                 [% FOR field IN additional_fields_for_subscription %]
262                   <li>
263                     <label for="additional_field_[% field.id | html %]"> [% field.name | html %]: </label>
264                     [% IF field.authorised_value_choices %]
265                       <select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]_filter">
266                         <option value="">All</option>
267                         [% FOREACH av IN field.authorised_value_choices %]
268                           <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
269                         [% END %]
270                       </select>
271                     [% ELSE %]
272                       <input id="additional_field_[% field.id | html %]" type="text" value="[% additional_fields.${field.name} | html %]" name="additional_field_[% field.id | html %]_filter" />
273                     [% END %]
274                   </li>
275                 [% END %]
276               </ol>
277               <input type="hidden" name="searched" value="1" />
278               <fieldset class="action">
279                 <input type="submit" value="Search" />
280               </fieldset>
281           </fieldset>
282         </form>
283       </div>
284       [% END %]
285       [% IF ( done_searched ) %]
286         [% IF ( total ) %]
287           <div id="serialstabs" class="toptabs" style="clear:both;">
288             <ul class="ui-tabs-nav">
289               <li><a href="#opened">Open ([% openedsubscriptions.size || 0 | html %])</a></li>
290               <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 | html %])</a></li>
291             </ul>
292             <div id="opened">
293               [% IF openedsubscriptions %]
294                   [% INCLUDE subscriptions_table subscriptions = openedsubscriptions %]
295               [% ELSE %]
296                 <div class="dialog message">
297                   <p>Your search returned no open subscriptions.</p>
298                 </div>
299               [% END %]
300             </div>
301             <div id="closed">
302               [% IF closedsubscriptions %]
303                 [% INCLUDE subscriptions_table subscriptions = closedsubscriptions closed = 1 %]
304               [% ELSE %]
305                 <div class="dialog message">
306                   <p>Your search returned no closed subscriptions.</p>
307                 </div>
308               [% END %]
309             </div>
310           </div>
311         [% ELSE %]
312             <div class="dialog message">
313               <p>Your search returned no results.</p>
314             </div>
315         [% END %]
316       [% END %]
317
318             </main>
319         </div> <!-- /.col-sm-10.col-sm-push-2 -->
320
321         <div class="col-sm-2 col-sm-pull-10">
322             <aside>
323
324     [% INCLUDE 'serials-menu.inc' %]
325     [% IF ( done_searched ) %]
326     <div id="advsearch">
327         <form action="/cgi-bin/koha/serials/serials-search.pl" method="get">
328           <fieldset class="brief">
329             <h4>Search subscriptions</h4>
330               <ol>
331                 <li>
332                   <label for="issn">ISSN:</label>
333                   <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter | html %]" />
334                 </li>
335                 <li>
336                   <label for="title">Title:</label>
337                   <input type="text" id="title" name="title_filter" value="[% title_filter | html %]" />
338                 </li>
339                 [% IF ( marcflavour == "UNIMARC" ) %]
340                 <li>
341                   <label for="ean">EAN:</label>
342                   <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter | html %]" />
343                 </li>
344                 [% END %]
345                 <li>
346                   <label for="callnumber">Call number:</label>
347                   <input type="text" id="callnumber" name="callnumber_filter" value="[% callnumber_filter | html %]" />
348                 </li>
349                 <li>
350                   <label for="publisher">Publisher:</label>
351                   <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter | html %]" />
352                 </li>
353                 <li>
354                   <label for="bookseller">Vendor:</label>
355                   <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter | html %]" />
356                 </li>
357                 <li>
358                   <label for="branch">Library:</label>
359                   <select id="branch" name="branch_filter">
360                     <option value="">All</option>
361                     [%# FIXME Should not we filter the libraries? %]
362                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
363                   </select>
364                 </li>
365                 <li>
366                   <label for="location">Location:</label>
367                   [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %]
368                 </li>
369                 <li>
370                   <label for="to">Expires before:</label>
371                   <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
372                 </li>
373
374                 [% FOR field IN additional_fields_for_subscription %]
375                   <li>
376                     <label for="additional_field_[% field.id | html %]ID"> [% field.name | html %]: </label>
377                     [% IF field.authorised_value_choices %]
378                       <select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]_filter">
379                         <option value="">All</option>
380                         [% FOREACH av IN field.authorised_value_choices %]
381                           [% IF av.authorised_value == additional_field_filters.${field.name}.value %]
382                             <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
383                           [% ELSE %]
384                             <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
385                           [% END %]
386                         [% END %]
387                       </select>
388                     [% ELSE %]
389                       <input id="additional_field_[% field.id | html %]" type="text" value="[% additional_field_filters.${field.name}.value | html %]" name="additional_field_[% field.id | html %]_filter" />
390                     [% END %]
391                   </li>
392                 [% END %]
393               </ol>
394               <input type="hidden" name="searched" value="1" />
395               <fieldset class="action">
396                 <input type="submit" value="Search" />
397               </fieldset>
398             </div>
399           </fieldset>
400         </form>
401       [% END %]
402
403             </aside>
404         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
405      </div> <!-- /.row -->
406
407
408 [% MACRO jsinclude BLOCK %]
409     [% INCLUDE 'calendar.inc' %]
410     [% INCLUDE 'datatables.inc' %]
411     <script>
412         var subscriptionid = "[% subscriptionid | html %]";
413         var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?");
414         var MSG_REOPEN_SUBSCRIPTION = _("Are you sure you want to reopen this subscription?");
415         var CONFIRM_DELETE_SUBSCRIPTION = _("Are you sure you want to delete this subscription?");
416     </script>
417     [% Asset.js("js/serials-toolbar.js") | $raw %]
418     <script>
419
420             function itemSelectionBuildEditLink(div) {
421                 var subscription_ids = new Array();
422                 $("input[name='subscriptionid'][type='checkbox']:checked", div).each(function() {
423                     subscription_ids.push($(this).val());
424                 });
425                 if (subscription_ids.length > 0) {
426                     var url = "[% edit_action_link | html %]";
427                     url += '&subscriptionid=' + subscription_ids.join('&subscriptionid=');
428                     $('a.itemselection_action_modify').attr('href', url);
429                 } else {
430                     return false;
431                 }
432                 return true;
433             }
434
435             function itemSelectionBuildActionLinks(tab) {
436                 var div = $("#" + tab);
437                 var modify_link_ok = itemSelectionBuildEditLink(div);
438                 if (modify_link_ok) {
439                     $('.itemselection_actions', div).show();
440                 } else {
441                     $('.itemselection_actions', div).hide();
442                 }
443             }
444
445         $(document).ready(function() {
446             var osrlt = $("#opened table").dataTable($.extend(true, {}, dataTablesDefaults, {
447                 "sPaginationType": "four_button",
448                 "aoColumnDefs": [
449                     { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
450                     { "sType": "title-string", "aTargets" : [ "title-string" ] },
451                     { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
452                 ]
453             }));
454
455             var csrlt = $("#closed table").dataTable($.extend(true, {}, dataTablesDefaults, {
456                 // FIXME sort function of additional_fields!
457                 "sPaginationType": "four_button",
458                 "aoColumnDefs": [
459                     { 'bSortable': false, 'aTargets': [ 'NoSort' ] },
460                     { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
461                 ]
462             }));
463
464             osrlt.fnAddFilters("dt-filter", 750);
465             csrlt.fnAddFilters("dt-filter", 750);
466
467             $('#serialstabs').tabs();
468             $("#reopensub").click(function(){
469                 return confirm(_("Are you sure you want to reopen this subscription?"));
470             });
471
472             $('.select-all, .clear-all').on('click', function(e) {
473                 e.preventDefault();
474                 var checkboxes = $(this).parents('form').find('input[type="checkbox"]');
475                 checkboxes.prop('checked', $(this).hasClass('select-all'));
476                 var tab = $(this).data("tab");
477                 itemSelectionBuildActionLinks(tab);
478             });
479
480             itemSelectionBuildActionLinks("opened");
481             itemSelectionBuildActionLinks("closed");
482             $("input[name='subscriptionid'][type='checkbox']").change(function() {
483                 var div = $(this).parents('form').parent().attr("id");
484                 itemSelectionBuildActionLinks(div);
485             });
486
487         });
488     </script>
489 [% END %]
490
491 [% INCLUDE 'intranet-bottom.inc' %]