Bug 22621: Fix filters on subscription search results
[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 [% USE Koha %]
8 [% SET footerjs = 1 %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Koha &rsaquo; Serials [% biblionumber | html %]</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 <style>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) %]
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="1" placeholder="Search ISSN" /></td>
72           <td><input type="text" class="dt-filter" data-column_num="2" placeholder="Search title" /></td>
73           <td><input type="text" class="dt-filter" data-column_num="3" placeholder="Search notes" /></td>
74           <td><input type="text" class="dt-filter" data-column_num="4" placeholder="Search library" /></td>
75           <td><input type="text" class="dt-filter" data-column_num="5" placeholder="Search location" /></td>
76           <td><input type="text" class="dt-filter" data-column_num="6" placeholder="Search callnumber" /></td>
77           [% SET column_num = 6 %]
78           [% UNLESS closed %]
79               <td><input type="text" class="dt-filter" data-column_num="7" placeholder="Search expiration date" /></td>
80               [% SET column_num = column_num + 1 %]
81           [% END %]
82           [% FOR field IN additional_fields_for_subscription %]
83             <td><input type="text" class="dt-filter" data-column_num="[% loop.count + column_num | html %]" placeholder="Search [% field.name | html %]" /></td>
84           [% END %]
85           <td></td>
86         </tr>
87       </tfoot>
88       <tbody>
89         [% FOREACH subscription IN subscriptions %]
90         [% UNLESS subscription.cannotdisplay %]
91           <tr>
92             <td>
93                 [% UNLESS subscription.cannotedit %]
94                     <input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid | html %]" />
95                 [% ELSE %]
96                     <input type="checkbox" name="subscriptionid" value="[% subscription.subscriptionid | html %]" disabled="disabled" title="You cannot edit this subscription" />
97                 [% END %]
98             </td>
99             <td>
100             [% IF ( subscription.issn ) %][% subscription.issn | html %]
101             [% END %]
102             </td>
103             <td><a href="/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% subscription.subscriptionid | uri %]" class="button" title="subscription detail">[% subscription.title | html %]</a>
104             </td>
105             <td>[% IF ( subscription.publicnotes ) %][% subscription.publicnotes | html %][% END %]
106             [% IF ( subscription.internalnotes ) %]([% subscription.internalnotes | html %])[% END %]
107             </td>
108             <td>
109               [% IF ( subscription.branchcode ) %][% Branches.GetName( subscription.branchcode ) | html %][% END %]
110             </td>
111             <td>
112               [% IF ( subscription.location ) %][% AuthorisedValues.GetByCode( 'LOC', subscription.location ) | html %][% END %]
113             </td>
114             <td>
115               [% IF ( subscription.callnumber ) %][% subscription.callnumber | html %][% END %]
116             </td>
117             [% UNLESS closed %]
118                 <td>
119                     [% IF ( subscription.enddate ) %]
120                         <span title="[% subscription.enddate | html %]">[% subscription.enddate | $KohaDates %]</span>
121                     [% ELSE %]
122                         <span title="0000-00-00"></span>
123                     [% END %]
124                 </td>
125             [% END %]
126
127             [% FOR field IN additional_fields_for_subscription %]
128               [% IF field.authorised_value_category %]
129                 <td>[% AuthorisedValues.GetByCode( field.authorised_value_category, subscription.additional_fields.${field.name} ) | html %]</td>
130               [% ELSE %]
131                 <td>[% subscription.additional_fields.${field.name} | html %]</td>
132               [% END %]
133             [% END %]
134
135             <td>
136                 <div class="dropdown">
137                     [% IF closed %]
138                         <a class="btn btn-default btn-xs dropdown-toggle" id="closedsubactions[% subscription.subscriptionid | html %]" role="button" data-toggle="dropdown" href="#">
139                            Actions <b class="caret"></b>
140                         </a>
141                         <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="closedsubactions[% subscription.subscriptionid | html %]">
142
143                             [% IF ( routing && CAN_user_serials_routing ) %]
144                                 [% UNLESS ( subscription.cannotedit ) %]
145                                     <li>
146                                         <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>
147                                     </li>
148                                 [% END %]
149                             [% END # IF ( routing && CAN_user_serials_routing ) %]
150
151                             <li>
152                                 <a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-list-alt"></i> Issue history</a>
153                             </li>
154
155                         </ul>
156                     [% ELSE %]
157                         <div class="btn-group">
158                             [% IF ( CAN_user_serials_receive_serials ) %]
159                                 [%# There should be no space between these two buttons, it would render badly %]
160                                 <a class="btn btn-default btn-xs" role="button"
161                                    href="/cgi-bin/koha/serials/serials-edit.pl?subscriptionid=[% subscription.subscriptionid | html %]&amp;serstatus=1,3,7"><i
162                                    class="fa fa-inbox"></i> Serial receive</a><a
163                                    class="btn btn-default btn-xs dropdown-toggle" id="subactions[% subscription.subscriptionid | html %]" role="button"
164                                    data-toggle="dropdown" href="#"><b class="caret"></b></a>
165                             [% ELSE %]
166                                 <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>
167                             [% END %]
168                         <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="subactions[% subscription.subscriptionid | html %]">
169
170                             [% IF ( routing && CAN_user_serials_routing ) %]
171                                 [% IF ( subscription.cannotedit ) %]
172                                 [% ELSE %]
173                                     [% IF ( subscription.routingedit ) %]
174                                         <li>
175                                             <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>
176                                         </li>
177                                     [% ELSE %]
178                                         <li>
179                                             <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>
180                                         </li>
181                                     [% END %]
182                                 [% END %]
183                             [% END # IF ( routing && CAN_user_serials_routing ) %]
184
185                             <li>
186                                 <a href="/cgi-bin/koha/serials/serials-collection.pl?subscriptionid=[% subscription.subscriptionid | uri %]"><i class="fa fa-list-alt"></i> Issue history</a>
187                             </li>
188                         </ul>
189                         </div>
190                     [% END %]
191                 </div>
192             </td>
193
194           </tr>
195           [% END %]
196         [% END %]
197       </tbody>
198     </table>
199   </form>
200 [% END %]
201
202 <div class="main container-fluid">
203     <div class="row">
204         <div class="col-sm-10 col-sm-push-2">
205             <main>
206
207       [% INCLUDE 'serials-toolbar.inc' %]
208
209       [% IF ( done_searched ) %]
210         <h2>Serials subscriptions ([% total | html %] found)</h2>
211       [% ELSE %]
212         <h2>Serials subscriptions search</h2>
213       [% END %]
214
215       [% UNLESS ( done_searched ) %]
216       <div id="advsearch" style="padding-bottom:3em;">
217         <form action="/cgi-bin/koha/serials/serials-search.pl" method="get">
218           <fieldset class="rows">
219           <legend>Search subscriptions</legend>
220               <ol>
221                 <li>
222                   <label for="issn">ISSN:</label>
223                   <input type="text" id="issn" name="ISSN_filter" value="[% ISSN_filter | html %]" />
224                 </li>
225                 <li>
226                   <label for="title">Title:</label>
227                   <input type="text" id="title" name="title_filter" value="[% title_filter | html %]" />
228                 </li>
229                 [% IF ( marcflavour == "UNIMARC" ) %]
230                 <li>
231                   <label for="ean">EAN:</label>
232                   <input type="text" id="ean" name="EAN_filter" value="[% EAN_filter | html %]" />
233                 </li>
234                 [% END %]
235                 <li>
236                   <label for="callnumber">Call number:</label>
237                   <input type="text" id="callnumber" name="callnumber_filter" value="[% callnumber_filter | html %]" />
238                 </li>
239                 <li>
240                   <label for="publisher">Publisher:</label>
241                   <input type="text" id="publisher" name="publisher_filter" value="[% publisher_filter | html %]" />
242                 </li>
243                 <li>
244                   <label for="bookseller">Vendor:</label>
245                   <input type="text" id="bookseller" name="bookseller_filter" value="[% bookseller_filter | html %]" />
246                 </li>
247                 <li>
248                   <label for="branch">Library:</label>
249                   <select id="branch" name="branch_filter">
250                     <option value="">All</option>
251                     [%# FIXME Should not we filter the libraries? %]
252                     [% PROCESS options_for_libraries libraries => Branches.all( selected => branch_filter, unfiltered => 1 ) %]
253                   </select>
254                 </li>
255                 <li>
256                   <label for="location">Location:</label>
257                   [% PROCESS 'av-build-dropbox.inc' name="location_filter", category="LOC", default=location_filter, all=1 %]
258                 </li>
259                 <li>
260                   <label for="to">Expires before:</label>
261                   <input type="text" id="to" name="expiration_date_filter" value="[% expiration_date_filter | $KohaDates %]" size="10" maxlength="10" class="datepickerto" />
262                 </li>
263                 [% INCLUDE 'additional-fields-entry.inc' available=additional_fields_for_subscription values=additional_field_filters wrap_fieldset=0 %]
264               </ol>
265               <input type="hidden" name="searched" value="1" />
266               [% IF ( mana ) %]<input type="hidden" name="mana" value="1" />[% END %]
267               <fieldset class="action">
268                 <input type="submit" value="Search" />
269               </fieldset>
270           </fieldset>
271         </form>
272       </div>
273       [% END %]
274       [% IF ( done_searched ) %]
275         [% IF ( total ) %]
276           <div id="serialstabs" class="toptabs" style="clear:both;">
277             <ul class="ui-tabs-nav">
278               [% IF mana %]
279                 <li><a href="#mana">Mana ([% total || 0 | html %])</a></li>
280               [% ELSE %]
281                 <li><a href="#opened">Open ([% openedsubscriptions.size || 0 | html %])</a></li>
282                 <li><a href="#closed">Closed ([% closedsubscriptions.size || 0 | html %])</a></li>
283               [% END %]
284             </ul>
285             [% IF mana %]
286                 <div id="mana">
287                     [% INCLUDE 'mana/mana-subscription-search-result.inc' %]
288                 </div>
289             [% ELSE %]
290             <div id="opened">
291               [% IF openedsubscriptions %]
292                   [% INCLUDE subscriptions_table subscriptions = openedsubscriptions %]
293               [% ELSE %]
294                 <div class="dialog message">
295                   <p>Your search returned no open subscriptions.</p>
296                 </div>
297               [% END %]
298             </div>
299             <div id="closed">
300               [% IF closedsubscriptions %]
301                 [% INCLUDE subscriptions_table subscriptions = closedsubscriptions closed = 1 %]
302               [% ELSE %]
303                 <div class="dialog message">
304                   <p>Your search returned no closed subscriptions.</p>
305                 </div>
306               [% END %]
307             </div>
308             [% END %]
309           </div>
310         [% ELSE %]
311             <div class="dialog message">
312               <p>Your search returned no results.</p>
313             </div>
314         [% END %]
315       [% END %]
316
317             </main>
318         </div> <!-- /.col-sm-10.col-sm-push-2 -->
319
320         <div class="col-sm-2 col-sm-pull-10">
321             <aside>
322
323     [% INCLUDE 'serials-menu.inc' %]
324     [% IF ( done_searched ) %]
325     [% UNLESS ( mana ) %]
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_category %]
378                       <select id="additional_field_[% field.id | html %]" name="additional_field_[% field.id | html %]">
379                         <option value="">All</option>
380                         [% FOREACH av IN AuthorisedValues.GetAuthValueDropbox(field.authorised_value_category) %]
381                           [% IF av.authorised_value == additional_field_filters.${field.id} %]
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.id} | html %]" name="additional_field_[% field.id | html %]" />
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
399             </div>
400           </fieldset>
401         </form>
402       [% END %]
403       [% END %]
404             </aside>
405         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
406      </div> <!-- /.row -->
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                 "order": [[ 2, "asc" ]],
449                 "aoColumnDefs": [
450                     { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
451                     { "sType": "title-string", "aTargets" : [ "title-string" ] },
452                     { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
453                 ]
454             }));
455
456             var csrlt = $("#closed table").dataTable($.extend(true, {}, dataTablesDefaults, {
457                 // FIXME sort function of additional_fields!
458                 "order": [[ 2, "asc" ]],
459                 "sPaginationType": "four_button",
460                 "aoColumnDefs": [
461                     { 'bSortable': false, 'aTargets': [ 'NoSort' ] },
462                     { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
463                 ]
464             }));
465
466             var manarlt = $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults, {
467                 "sPaginationType": "four_button",
468                 "aoColumnDefs": [
469                     { 'bSortable': false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
470                     { "sType": "title-string", "aTargets" : [ "title-string" ] },
471                     { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] }
472                 ]
473             }));
474
475             osrlt.fnAddFilters("dt-filter", 750);
476             csrlt.fnAddFilters("dt-filter", 750);
477             manarlt.fnAddFilters("dt-filter", 750);
478
479             $('#serialstabs').tabs();
480             $("#reopensub").click(function(){
481                 return confirm(_("Are you sure you want to reopen this subscription?"));
482             });
483
484             $('.select-all, .clear-all').on('click', function(e) {
485                 e.preventDefault();
486                 var checkboxes = $(this).parents('form').find('input[type="checkbox"]');
487                 checkboxes.prop('checked', $(this).hasClass('select-all'));
488                 var tab = $(this).data("tab");
489                 itemSelectionBuildActionLinks(tab);
490             });
491
492             itemSelectionBuildActionLinks("opened");
493             itemSelectionBuildActionLinks("closed");
494             $("input[name='subscriptionid'][type='checkbox']").change(function() {
495                 var div = $(this).parents('form').parent().attr("id");
496                 itemSelectionBuildActionLinks(div);
497             });
498
499             [% IF ( mana ) %]
500                 $("label[for=callnumber], input#callnumber").hide();
501                 $("label[for=bookseller], input#bookseller").hide();
502                 $("label[for=branch], select#branch").hide();
503                 $("label[for=to], input#to").hide();
504                 $(".ui-datepicker-trigger").hide();
505                 $("label[for=location], select#location_filter").hide();
506                 [% FOR field IN additional_fields_for_subscription %]
507                       $("label[for=additional_field_[% field.id | $raw %]], input#additional_field_[% field.id | $raw %]").hide();
508                 [% END %]
509             [% END %]
510         });
511     </script>
512 [% END %]
513
514 [% INCLUDE 'intranet-bottom.inc' %]