Bug 13618: Add html filters to all the variables
[koha.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 = [] | html %]
22 [% FOREACH param IN CGI.params.pairs %]
23     [% escaped_value = BLOCK | html %][% 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 | html %][% 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 | html %]" 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 | html %]&amp;op=reopen&amp;routing=[% subscription.routing | html %]&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 | html %]"><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 | html %]"><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 | html %]&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 | html %]"><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 id="doc3" class="yui-t2">
201   <div id="bd">
202     <div id="yui-main">
203       <div class="yui-b">
204       [% INCLUDE 'serials-toolbar.inc' %]
205
206       [% IF ( done_searched ) %]
207         <h2>Serials subscriptions ([% total | html %] found)</h2>
208       [% ELSE %]
209         <h2>Serials subscriptions search</h2>
210       [% END %]
211
212       [% UNLESS ( done_searched ) %]
213       <div id="advsearch" style="padding-bottom:3em;">
214         <form action="/cgi-bin/koha/serials/serials-search.pl" method="get">
215           <fieldset class="rows">
216           <legend>Search subscriptions</legend>
217               <ol>
218                 <li>
219                   <label for="issn">ISSN:</label>
220                   <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter | html %]" />
221                 </li>
222                 <li>
223                   <label for="title">Title:</label>
224                   <input type="text" id="title" name="title_filter" value="[% title_filter | html %]" />
225                 </li>
226                 [% IF ( marcflavour == "UNIMARC" ) %]
227                 <li>
228                   <label for="ean">EAN:</label>
229                   <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter | html %]" />
230                 </li>
231                 [% END %]
232                 <li>
233                   <label for="callnumber">Call number:</label>
234                   <input type="text" id="callnumber" name="callnumber_filter" value="[% callnumber_filter | html %]" />
235                 </li>
236                 <li>
237                   <label for="publisher">Publisher:</label>
238                   <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter | html %]" />
239                 </li>
240                 <li>
241                   <label for="bookseller">Vendor:</label>
242                   <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter | html %]" />
243                 </li>
244                 <li>
245                   <label for="branch">Library:</label>
246                   <select id="branch" name="branch_filter">
247                     <option value="">All</option>
248                     [%# FIXME Should not we filter the libraries? %]
249                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
250                   </select>
251                 </li>
252                 <li>
253                   <label for="location">Location:</label>
254                   [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %]
255                 </li>
256                 <li>
257                   <label for="to">Expires before:</label>
258                   <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
259                 </li>
260                 [% FOR field IN additional_fields_for_subscription %]
261                   <li>
262                     <label for="additional_field_[% field.id | html %]"> [% field.name | html %]: </label>
263                     [% IF field.authorised_value_choices %]
264                       <select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]_filter">
265                         <option value="">All</option>
266                         [% FOREACH av IN field.authorised_value_choices %]
267                           <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
268                         [% END %]
269                       </select>
270                     [% ELSE %]
271                       <input id="additional_field_[% field.id | html %]" type="text" value="[% additional_fields.${field.name} | html %]" name="additional_field_[% field.id | html %]_filter" />
272                     [% END %]
273                   </li>
274                 [% END %]
275               </ol>
276               <input type="hidden" name="searched" value="1" />
277               <fieldset class="action">
278                 <input type="submit" value="Search" />
279               </fieldset>
280           </fieldset>
281         </form>
282       </div>
283       [% END %]
284       [% IF ( done_searched ) %]
285         [% IF ( total ) %]
286           <div id="serialstabs" class="toptabs" style="clear:both;">
287             <ul class="ui-tabs-nav">
288               <li><a href="#opened">Open ([% openedsubscriptions.size || 0 | html %])</a></li>
289               <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 | html %])</a></li>
290             </ul>
291             <div id="opened">
292               [% IF openedsubscriptions %]
293                   [% INCLUDE subscriptions_table subscriptions = openedsubscriptions %]
294               [% ELSE %]
295                 <div class="dialog message">
296                   <p>Your search returned no open subscriptions.</p>
297                 </div>
298               [% END %]
299             </div>
300             <div id="closed">
301               [% IF closedsubscriptions %]
302                 [% INCLUDE subscriptions_table subscriptions = closedsubscriptions closed = 1 %]
303               [% ELSE %]
304                 <div class="dialog message">
305                   <p>Your search returned no closed subscriptions.</p>
306                 </div>
307               [% END %]
308             </div>
309           </div>
310         [% ELSE %]
311             <div class="dialog message">
312               <p>Your search returned no results.</p>
313             </div>
314         [% END %]
315       [% END %]
316     </div>
317   </div>
318
319   <div class="yui-b">
320     [% INCLUDE 'serials-menu.inc' %]
321     [% IF ( done_searched ) %]
322     <div id="advsearch">
323         <form action="/cgi-bin/koha/serials/serials-search.pl" method="get">
324           <fieldset class="brief">
325             <h4>Search subscriptions</h4>
326               <ol>
327                 <li>
328                   <label for="issn">ISSN:</label>
329                   <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter | html %]" />
330                 </li>
331                 <li>
332                   <label for="title">Title:</label>
333                   <input type="text" id="title" name="title_filter" value="[% title_filter | html %]" />
334                 </li>
335                 [% IF ( marcflavour == "UNIMARC" ) %]
336                 <li>
337                   <label for="ean">EAN:</label>
338                   <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter | html %]" />
339                 </li>
340                 [% END %]
341                 <li>
342                   <label for="callnumber">Call number:</label>
343                   <input type="text" id="callnumber" name="callnumber_filter" value="[% callnumber_filter | html %]" />
344                 </li>
345                 <li>
346                   <label for="publisher">Publisher:</label>
347                   <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter | html %]" />
348                 </li>
349                 <li>
350                   <label for="bookseller">Vendor:</label>
351                   <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter | html %]" />
352                 </li>
353                 <li>
354                   <label for="branch">Library:</label>
355                   <select id="branch" name="branch_filter">
356                     <option value="">All</option>
357                     [%# FIXME Should not we filter the libraries? %]
358                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
359                   </select>
360                 </li>
361                 <li>
362                   <label for="location">Location:</label>
363                   [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %]
364                 </li>
365                 <li>
366                   <label for="to">Expires before:</label>
367                   <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
368                 </li>
369
370                 [% FOR field IN additional_fields_for_subscription %]
371                   <li>
372                     <label for="additional_field_[% field.id | html %]ID"> [% field.name | html %]: </label>
373                     [% IF field.authorised_value_choices %]
374                       <select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]_filter">
375                         <option value="">All</option>
376                         [% FOREACH av IN field.authorised_value_choices %]
377                           [% IF av.authorised_value == additional_field_filters.${field.name}.value %]
378                             <option value="[% av.authorised_value | html %]" selected="selected">[% av.lib | html %]</option>
379                           [% ELSE %]
380                             <option value="[% av.authorised_value | html %]">[% av.lib | html %]</option>
381                           [% END %]
382                         [% END %]
383                       </select>
384                     [% ELSE %]
385                       <input id="additional_field_[% field.id | html %]" type="text" value="[% additional_field_filters.${field.name}.value | html %]" name="additional_field_[% field.id | html %]_filter" />
386                     [% END %]
387                   </li>
388                 [% END %]
389               </ol>
390               <input type="hidden" name="searched" value="1" />
391               <fieldset class="action">
392                 <input type="submit" value="Search" />
393               </fieldset>
394             </div>
395           </fieldset>
396         </form>
397       [% END %]
398   </div>
399 </div>
400
401 [% MACRO jsinclude BLOCK %]
402     [% INCLUDE 'calendar.inc' %]
403     [% INCLUDE 'datatables.inc' %]
404     <script type="text/javascript">
405         var subscriptionid = "[% subscriptionid | html %]";
406         var MSG_CLOSE_SUBSCRIPTION = _("Are you sure you want to close this subscription?");
407         var MSG_REOPEN_SUBSCRIPTION = _("Are you sure you want to reopen this subscription?");
408         var CONFIRM_DELETE_SUBSCRIPTION = _("Are you sure you want to delete this subscription?");
409     </script>
410     [% Asset.js("js/serials-toolbar.js") | $raw %]
411     <script type="text/javascript">
412
413             function itemSelectionBuildEditLink(div) {
414                 var subscription_ids = new Array();
415                 $("input[name='subscriptionid'][type='checkbox']:checked", div).each(function() {
416                     subscription_ids.push($(this).val());
417                 });
418                 if (subscription_ids.length > 0) {
419                     var url = "[% edit_action_link | html %]";
420                     url += '&subscriptionid=' + subscription_ids.join('&subscriptionid=');
421                     $('a.itemselection_action_modify').attr('href', url);
422                 } else {
423                     return false;
424                 }
425                 return true;
426             }
427
428             function itemSelectionBuildActionLinks(tab) {
429                 var div = $("#" + tab);
430                 var modify_link_ok = itemSelectionBuildEditLink(div);
431                 if (modify_link_ok) {
432                     $('.itemselection_actions', div).show();
433                 } else {
434                     $('.itemselection_actions', div).hide();
435                 }
436             }
437
438         $(document).ready(function() {
439             var osrlt = $("#opened table").dataTable($.extend(true, {}, dataTablesDefaults, {
440                 "sPaginationType": "four_button",
441                 "aoColumnDefs": [
442                     { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
443                     { "sType": "title-string", "aTargets" : [ "title-string" ] },
444                     { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
445                 ]
446             }));
447
448             var csrlt = $("#closed table").dataTable($.extend(true, {}, dataTablesDefaults, {
449                 // FIXME sort function of additional_fields!
450                 "sPaginationType": "four_button",
451                 "aoColumnDefs": [
452                     { 'bSortable': false, 'aTargets': [ 'NoSort' ] },
453                     { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
454                 ]
455             }));
456
457             osrlt.fnAddFilters("dt-filter", 750);
458             csrlt.fnAddFilters("dt-filter", 750);
459
460             $('#serialstabs').tabs();
461             $("#reopensub").click(function(){
462                 return confirm(_("Are you sure you want to reopen this subscription?"));
463             });
464
465             $('.select-all, .clear-all').on('click', function(e) {
466                 e.preventDefault();
467                 var checkboxes = $(this).parents('form').find('input[type="checkbox"]');
468                 checkboxes.prop('checked', $(this).hasClass('select-all'));
469                 var tab = $(this).data("tab");
470                 itemSelectionBuildActionLinks(tab);
471             });
472
473             itemSelectionBuildActionLinks("opened");
474             itemSelectionBuildActionLinks("closed");
475             $("input[name='subscriptionid'][type='checkbox']").change(function() {
476                 var div = $(this).parents('form').parent().attr("id");
477                 itemSelectionBuildActionLinks(div);
478             });
479
480         });
481     </script>
482 [% END %]
483
484 [% INCLUDE 'intranet-bottom.inc' %]