Merge branch 'new/bug_4330' into kcmaster
[koha.git] / koha-tmpl / opac-tmpl / prog / en / modules / opac-full-serial-issues.tt
1 [% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog ›  Subscription information for [% bibliotitle %]
2 [% INCLUDE 'doc-head-close.inc' %]
3 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
4 <script type="text/javascript" language="javascript">
5 //<![CDATA[
6
7 $(document).ready(function(){
8         showlayer([% yearmin %]);
9         $("a.tabsubs:first").addClass("currentsubtab");
10         $("#filterform").submit(function(){
11                 filterByLibrary();
12                 return false;
13         });
14         $("#libraryfilter").change(function(){
15                 filterByLibrary();
16         });
17         $("#subscriptionidfilter").change(function(){
18                 filterBySubscriptionId();
19         });
20         $("#reset").click(function(){
21                 clearFilters();
22         });
23         $("a.tabsubs").click(function(){
24                 $("a.tabsubs").removeClass("currentsubtab");
25                 $(this).addClass("currentsubtab");
26         });
27         $(".subscriptionstclass").tablesorter({[% IF ( dateformat == 'metric' ) %]
28     dateFormat: 'uk',[% END %]
29             widgets : ['zebra'],
30             sortList: [[0,0]]
31         });
32 });
33
34 // Filters initialization
35 function initFilters() {
36     // Deleting everything from the library filter
37     $("#libraryfilter option").remove();
38
39     // Getting each branchcode from the currently displayed tab
40     var subarray = [];      
41     $("div#" + currentYear + " table.subscriptionstclass tbody tr:visible td.libraryfilterclass").each(function() {
42         if (subarray.indexOf($(this).text()) == -1) { subarray.push($(this).text()); }
43     });
44
45     // Setting the option values with branchcodes 
46     $("#libraryfilter").append('<option value="all">(All)</option>');    
47     for (var i = 0; i < subarray.length; i++) {
48         $("#libraryfilter").append('<option value="' + subarray[i] + '">' + subarray[i] + '</option>');    
49     }
50 }
51
52 // Filter by Library
53 function filterByLibrary() {
54     
55     selectedStatus = $("#libraryfilter").val();
56
57     // Reset the filters but keeps the selected library
58     clearFilters(true);
59
60     if (selectedStatus != 'all') {
61
62         // We hide everything
63         $("table.subscriptionstclass tbody tr").hide();
64         
65         // Then show the lines that match the currently selected library 
66         $("table.subscriptionstclass tbody tr td.libraryfilterclass:contains(" + selectedStatus + ")").parent().show();
67
68
69         // We then prepare the subscription filter :
70         
71         // Getting subscription id's for the selected library 
72         var subarray = [];      
73         $("div#" + currentYear + " table.subscriptionstclass tbody tr:visible td.subscriptionidfilterclass").each(function() {
74             if (subarray.indexOf($(this).text()) == -1) { subarray.push($(this).text()); }
75         });
76         // Setting the option values with subscription id's
77         $("#subscriptionidfilter").append('<option value="all">(All)</option>');    
78         for (var i = 0; i < subarray.length; i++) {
79             $("#subscriptionidfilter").append('<option value="' + subarray[i] + '">' + subarray[i] + '</option>');    
80         }
81
82         // Subscription filtering is now ready
83         $("#subscriptionidfilter").removeAttr("disabled");
84     }
85 }
86
87 // Filter by subscription id
88 function filterBySubscriptionId() {
89     
90     selectedSubscription = $("#subscriptionidfilter").val();
91     selectedLibrary      = $("#libraryfilter").val();
92     
93     if (selectedSubscription == "all") {
94         clearFilters(true);
95         filterByLibrary();
96     } else {
97
98         // We hide everything
99         $("table.subscriptionstclass tbody tr").hide();
100
101         // Then show the lines that match the currently selected library 
102         $("table.subscriptionstclass tbody tr td.libraryfilterclass:contains(" + selectedLibrary + ")").parent().show();                
103         
104         // Then hide the lines where the subscription id does not match the selected one
105         $("table.subscriptionstclass tbody tr td.subscriptionidfilterclass").not(
106             $("table.subscriptionstclass tbody tr td.subscriptionidfilterclass:contains(" + selectedSubscription + ")")
107         ).parent().hide();                
108     }
109 }
110
111 // Clears filters : reset everything
112 // (Though preserves the selected library if the keeplibrary parameter is set to true)
113 function clearFilters(keeplibrary) {
114
115     // Show all content
116     $("table.subscriptionstclass tbody tr").show();
117     
118     // Remove old subscription options
119     $("#subscriptionidfilter option").remove();
120     $("#subscriptionidfilter option").append('<option value="all">(All)</option>');
121     $("#subscriptionidfilter").attr("disabled", "disabled");
122  
123     if (keeplibrary != true) { 
124         // Reinit library options
125         initFilters();
126         $("#libraryfilter option[value=all]").attr("selected", "selected");
127     }
128 }
129 function showlayer(numlayer){
130         $(".yeardata").each(function(){
131                 ong = $(this).attr("id");
132                 if(ong == "show"+numlayer){
133                         $(this).show();
134                         currentYear = ong;
135                 } else  {
136                         $(this).hide();
137                 }
138         });
139     clearFilters();
140 }
141 //]]>
142 </script>
143 <style type="text/css">
144         #search-facets fieldset { border: 0; margin: 0;padding:0;}#search-facets ol{padding:.3em;}#search-facets li {list-style-type:none;padding:4px 4px;}#search-facets label{font-weight:bold;display:block;margin:.2em 0;}#search-facets fieldset.action {padding-left:4px;margin:.3em;}div.tabsub { clear:both;}#subtabs a { display:block;float:left;border:1px solid #CCC;padding:.2em .4em;margin-right:.3em;text-decoration:none;font-size:115%;}#subtabs strong { display:block; float: left; font-size:115%;padding:.2em .4em; }#subtabs { margin-top : 1em; }a.currentsubtab { background-color:#FFC;}
145 </style>
146 </head>
147 <body id="opac-full-serial-issues">
148 <div id="doc3" class="yui-t1">
149    <div id="bd">
150 [% INCLUDE 'masthead.inc' %]
151
152         <div id="yui-main">
153         <div class="yui-b"><div class="yui-g">
154
155 [% UNLESS ( popup ) %]
156     <h2>Subscription information for [% bibliotitle %]</h2>
157         <div id="views">
158                 <span class="view"><a id="Normalview" href="opac-detail.pl?biblionumber=[% biblionumber %]">Normal view</a></span>
159                 <span class="view"><a id="Briefhistory" href="opac-serial-issues.pl?biblionumber=[% biblionumber %]&amp;selectview=small">Brief history</a></span>
160                 <span class="view"><span id="Fullhistory">Full history</span></span>
161         </div>
162
163 [% END %]
164     <div id="subtabs"><strong>Show year: </strong>
165     [% FOREACH year IN years %]
166         [% IF ( year.year ) %]
167             <a class="tabsubs" href="#" onclick="showlayer([% year.year %]); return false;">[% year.year %]</a>
168         [% END %]
169     [% END %]
170     </div>
171
172     [% FOREACH year IN years %]
173         [% IF loop.first %]
174            <div class="yeardata tabsub" id="show[% year.year %]" style="display:block">
175         [% ELSE %]
176            <div class="yeardata tabsub" id="show[% year.year %]" style="display:none">
177         [% END %]
178         <table class="subscriptionstclass">
179             <thead>
180                 <tr>
181                     <th>Date</th>
182                     <th>Library</th>
183                     <th>Notes</th>
184                     <th>Date received</th>
185                     <th>Number</th>
186                     <th>Status</th>
187                     <th>Subscription</th>
188                 </tr>
189             </thead>
190             <tbody>
191                 [% FOREACH serial IN year.serials %]
192                 <tr>
193                     <td>    [% serial.publisheddate %]
194                     </td>
195                     <td class="libraryfilterclass">    [% serial.branchname %]
196                     </td>
197                     <td>    [% serial.notes %]
198                     </td>
199                     <td>   [% IF ( serial.status2 ) %] [% serial.planneddate %] [% END %]
200                     </td>
201                     <td>    [% serial.serialseq %]
202                     </td>
203                     <td>    [% IF ( serial.status1 ) %]Waiting[% END %]
204                         [% IF ( serial.status2 ) %]Arrived[% END %]
205                         [% IF ( serial.status3 ) %]Late[% END %]
206                         [% IF ( serial.status4 ) %]Missing[% END %]
207                         [% IF ( serial.status5 ) %]Not Available[% END %]
208                         [% IF ( serial.status7 ) %]Claimed[% END %]
209                         [% IF ( serial.notes ) %]([% serial.notes %])[% END %]
210                     </td>
211                     <td class="subscriptionidfilterclass">    [% serial.subscriptionid %]
212                     </td>
213                 </tr>
214                 [% END %]
215             </tbody>
216         </table>
217     </div>
218     [% END %]
219
220 </div>
221 </div>
222 </div>
223 <div class="yui-b">
224 <div id="searchfacetscontainer" class="container">
225 <div id="search-facets">
226 <form action="opac-serial-issues.pl" id="filterform">
227     <h4>Refine your search</h4>
228         <fieldset>
229            <ol><li> <label for="libraryfilter">Library : </label>
230                     <select id="libraryfilter" name="libraryfilter" style="width:10em;"></select></li>
231             <li><label for="subscriptionidfilter">Subscription : </label>
232             <select id="subscriptionidfilter" name="subscriptionfilter" style="width:10em;" disabled="disabled"></select></li></ol>
233                 </fieldset>
234                 <fieldset class="action"><input type="reset" id="reset" value="Clear" /></fieldset>
235     </form>
236 </div>
237 [% IF ( OpacNav ) %][% INCLUDE 'navigation.inc' %][% END %]
238 </div>
239 </div>
240 </div>
241 [% INCLUDE 'opac-bottom.inc' %]