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