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