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