Ticket 1014 : Added serial collections in opac
[koha_ffzg] / koha-tmpl / opac-tmpl / prog / en / modules / opac-full-serial-issues.tmpl
index 5858232..bb33711 100644 (file)
@@ -1,5 +1,113 @@
 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><!-- TMPL_IF NAME="LibraryNameTitle" --><!-- TMPL_VAR NAME="LibraryNameTitle" --><!-- TMPL_ELSE -->Koha Online<!-- /TMPL_IF --> Catalog &rsaquo;  Serials
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<script type="text/javascript" language="javascript">
+//<![CDATA[
+
+$(document).ready(function(){
+    initFilters();
+       
+});
+
+// Filters initialization
+function initFilters() {
+
+    // Deleting everything from the library filter
+    $("#libraryfilter option").remove();
+
+    // Getting each branchcode from the currently displayed tab
+    var subarray = [];      
+    $("div#" + currentYear + " table.subscriptionstclass tbody tr:visible td.libraryfilterclass").each(function() {
+       if (subarray.indexOf($(this).text()) == -1) { subarray.push($(this).text()); }
+    });
+
+    // Setting the option values with branchcodes 
+    $("#libraryfilter").append('<option value="all">(All)</option>');    
+    for (var i = 0; i < subarray.length; i++) {
+        $("#libraryfilter").append('<option value="' + subarray[i] + '">' + subarray[i] + '</option>');    
+    }
+}
+
+// Filter by Library
+function filterByLibrary() {
+    
+    selectedStatus = $("#libraryfilter").val();
+
+    // Reset the filters but keeps the selected library
+    clearFilters(true);
+
+    if (selectedStatus != 'all') {
+
+       // We hide everything
+       $("table.subscriptionstclass tbody tr").hide();
+       
+       // Then show the lines that match the currently selected library 
+       $("table.subscriptionstclass tbody tr td.libraryfilterclass:contains(" + selectedStatus + ")").parent().show();
+
+
+       // We then prepare the subscription filter :
+       
+       // Getting subscription id's for the selected library 
+       var subarray = [];      
+       $("div#" + currentYear + " table.subscriptionstclass tbody tr:visible td.subscriptionidfilterclass").each(function() {
+           if (subarray.indexOf($(this).text()) == -1) { subarray.push($(this).text()); }
+       });
+       // Setting the option values with subscription id's
+       $("#subscriptionidfilter").append('<option value="all">(All)</option>');    
+       for (var i = 0; i < subarray.length; i++) {
+           $("#subscriptionidfilter").append('<option value="' + subarray[i] + '">' + subarray[i] + '</option>');    
+       }
+
+       // Subscription filtering is now ready
+       $("#subscriptionidfilter").removeAttr("disabled");
+    }
+}
+
+// Filter by subscription id
+function filterBySubscriptionId() {
+    
+    selectedSubscription = $("#subscriptionidfilter").val();
+    selectedLibrary      = $("#libraryfilter").val();
+    
+    if (selectedSubscription == "all") {
+       clearFilters(true);
+       filterByLibrary();
+    } else {
+
+       // We hide everything
+       $("table.subscriptionstclass tbody tr").hide();
+
+       // Then show the lines that match the currently selected library 
+       $("table.subscriptionstclass tbody tr td.libraryfilterclass:contains(" + selectedLibrary + ")").parent().show();                
+       
+       // Then hide the lines where the subscription id does not match the selected one
+       $("table.subscriptionstclass tbody tr td.subscriptionidfilterclass").not(
+           $("table.subscriptionstclass tbody tr td.subscriptionidfilterclass:contains(" + selectedSubscription + ")")
+       ).parent().hide();                
+    }
+}
+
+// Clears filters : reset everything
+// (Though preserves the selected library if the keeplibrary parameter is set to true)
+function clearFilters(keeplibrary) {
+
+    // Show all content
+    $("table.subscriptionstclass tbody tr").show();
+    
+    // Remove old subscription options
+    $("#subscriptionidfilter option").remove();
+    $("#subscriptionidfilter option").append('<option value="all">(All)</option>');
+    $("#subscriptionidfilter").attr("disabled", "disabled");
+    if (keeplibrary != true) { 
+       // Reinit library options
+       initFilters();
+       $("#libraryfilter option[@value=all]").attr("selected", "selected"); 
+    }
+}
+
+//]]>
+</script>
+
 </head>
 <body>
 <!-- TMPL_IF NAME="OpacNav" --><div id="doc3" class="yui-t1"><!-- TMPL_ELSE --><div id="doc3" class="yui-t7"><!-- /TMPL_IF -->
     <a class="tabsubs" href="opac-serial-issues.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->&selectview=small">Compact view</a>
     </div>
 
+    <form action="opac-serial-issues.pl" onsubmit="filterByLibrary(); return false;">
+       <fieldset>
+           
+           <legend>Filters :</legend>
+
+           <label for="libraryfilter">Library : </label>
+            <select id="libraryfilter" onchange="filterByLibrary();">
+            </select>
+           
+           <label for="subscriptionidfilter">Subscription : </label>
+            <select id="subscriptionidfilter" disabled="disabled" onchange="filterBySubscriptionId();">
+            </select>
+           
+           <input type="reset" value="Clear Filters" onclick="clearFilters();" />
+       
+       </fieldset>
+    </form>
     <!-- TMPL_LOOP NAME="years" -->
   <!--TMPL_IF Name="first" -->  
     <div name="yeardata" id="<!-- TMPL_VAR NAME="year" -->" class="tabsub" style="display:block"><!--TMPL_ELSE --><div name="yeardata" id="<!-- TMPL_VAR NAME="year" -->" class="tabsub" style="display:none"><!--/TMPL_IF -->
-        <table width="400px">
-            <tr>
-                <th>Date
-                </th>
-                <th>Library
-                </th>
-                <th>Notes
-                </th>
-                <th>Date received
-                </th>
-                <th>Number
-                </th>
-                <th>Status
-                </th>
-            </tr>
-        <!-- TMPL_LOOP Name="serials" -->
-            <!-- TMPL_UNLESS Name="__odd__" -->
-            <tr class="highlight">
-            <!-- TMPL_ELSE --> 
-            <tr>
-            <!-- /TMPL_UNLESS -->
-                <td>    <!-- TMPL_VAR Name="publisheddate" -->
-                </td>
-                <td>    <!-- TMPL_VAR name="branchname" -->
-                </td>
-                <td>    <!-- TMPL_VAR name="notes" -->
-                </td>
-                <td>   <!-- TMPL_IF Name="status2" --> <!-- TMPL_VAR Name="planneddate" --> <!-- /TMPL_IF -->
-                </td>
-                <td>    <!-- TMPL_VAR Name="serialseq" -->
-                </td>
-                <td>    <!-- TMPL_IF Name="status1" -->Waiting<!-- /TMPL_IF -->
-                    <!-- TMPL_IF Name="status2" -->Arrived<!-- /TMPL_IF -->
-                    <!-- TMPL_IF Name="status3" -->Late<!-- /TMPL_IF -->
-                    <!-- TMPL_IF Name="status4" -->Missing<!-- /TMPL_IF -->
-                    <!-- TMPL_IF Name="status5" -->Not Published<!-- /TMPL_IF -->
-                    <!-- TMPL_IF name="notes" -->(<!-- TMPL_VAR name="notes" -->)<!-- /TMPL_IF -->
-                </td>
-            </tr>
-            <!-- /TMPL_LOOP -->
+        <table class="subscriptionstclass" width="400px">
+           <thead>
+               <tr>
+                   <th>Date
+                   </th>
+                   <th>Library
+                   </th>
+                   <th>Notes
+                   </th>
+                   <th>Date received
+                   </th>
+                   <th>Number
+                   </th>
+                   <th>Status
+                   </th>
+                   <th>Subscription</th>
+               </tr>
+           </thead>
+           <tbody>
+               <!-- TMPL_LOOP Name="serials" -->
+               <tr>
+                   <td>    <!-- TMPL_VAR Name="publisheddate" -->
+                   </td>
+                   <td class="libraryfilterclass">    <!-- TMPL_VAR name="branchcode" -->
+                   </td>
+                   <td>    <!-- TMPL_VAR name="notes" -->
+                   </td>
+                   <td>   <!-- TMPL_IF Name="status2" --> <!-- TMPL_VAR Name="planneddate" --> <!-- /TMPL_IF -->
+                   </td>
+                   <td>    <!-- TMPL_VAR Name="serialseq" -->
+                   </td>
+                   <td>    <!-- TMPL_IF Name="status1" -->Waiting<!-- /TMPL_IF -->
+                       <!-- TMPL_IF Name="status2" -->Arrived<!-- /TMPL_IF -->
+                       <!-- TMPL_IF Name="status3" -->Late<!-- /TMPL_IF -->
+                       <!-- TMPL_IF Name="status4" -->Missing<!-- /TMPL_IF -->
+                       <!-- TMPL_IF Name="status5" -->Not Published<!-- /TMPL_IF -->
+                       <!-- TMPL_IF name="notes" -->(<!-- TMPL_VAR name="notes" -->)<!-- /TMPL_IF -->
+                   </td>
+                   <td class="subscriptionidfilterclass">    <!-- TMPL_VAR Name="subscriptionid" -->
+                   </td>
+               </tr>
+               <!-- /TMPL_LOOP -->
+           </tbody>
         </table>
     </div>
     <!--/TMPL_LOOP -->
 <script language="JavaScript" type="text/javascript">
+var currentYear;
 showlayer(<!-- TMPL_VAR name="yearmin" -->);
 function showlayer(numlayer)
 {
@@ -78,10 +207,13 @@ function showlayer(numlayer)
         ong=yeardata[i].getAttribute('id');
         if (numlayer==ong) {
             yeardata[i].style.display="block";
+           currentYear = ong;
         } else {
             yeardata[i].style.display="none";
         }
     }
+
+    clearFilters();
 }
 
 </script>