Ticket 1014 : Added serial collections in opac
authorPaul Poulain <paul.poulain@biblibre.com>
Thu, 14 May 2009 14:08:35 +0000 (16:08 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 30 Sep 2009 09:30:36 +0000 (11:30 +0200)
Added a syspref to decide what should be displayed by default (holdings
or serial collections)
Added filters for full subscription history (by branchcode and by
subscription)

Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
installer/data/mysql/en/mandatory/sysprefs.sql
installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-full-serial-issues.tmpl
opac/opac-detail.pl

index e2168d8..490e1e2 100644 (file)
@@ -69,6 +69,7 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacCloud',0,'If ON, enables subject cloud on OPAC',NULL,'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opaccolorstylesheet','colors.css','Define the color stylesheet to use in the OPAC','','free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opaccredits','','Define HTML Credits at the bottom of the OPAC page','70|10','Textarea');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacSerialDefaultTab', 'serialcollection', 'Define the default tab for serials in OPAC. If set to holdings when there are no items, then serial collections are still displayed by default.', 'holdings|serialcollection', 'Choice');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacheader','','Add HTML to be included as a custom header in the OPAC','70|10','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opaclayoutstylesheet','opac.css','Enter the name of the layout CSS stylesheet to use in the OPAC','','free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacMaintenance',0,'If ON, enables maintenance warning in OPAC','','YesNo');
index 95aacdf..2a2d2f1 100644 (file)
@@ -269,3 +269,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type)VALUES('D
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AllowAllMessageDeletion','0','Allow any Library to delete any message','','YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type)VALUES('ShowPatronImageInWebBasedSelfCheck', '0', 'Si activé, affiche la photo de l''adhérent lors de l''utilisation de la console de prêt auto-contrôlé', '', 'YesNo');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('EnableOpacSearchHistory', '1', 'Enable or disable opac search history', 'YesNo','')
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacSerialDefaultTab', 'serialcollection', 'Ce paramètre définit l''onglet par défaut pour l''affichage des périodiques dans l''OPAC. Si la préférence est sur holdings, mais qu''aucun exemplaire n''est présent, les états de collection seront tout de même affichés par défaut.', 'holdings|serialcollection', 'Choice');
index 32caa72..ec589a5 100644 (file)
@@ -322,8 +322,32 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
     <!-- TMPL_IF NAME="OPACAmazonEnabled" --><!-- TMPL_IF NAME="OPACAmazonReviews" --><li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#amazonreviews">Amazon Reviews</a></li><!-- /TMPL_IF --><!-- /TMPL_IF -->
     <!-- TMPL_IF NAME="Babeltheque" --><li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#babeltheque">Babelthèque</a></li><!-- /TMPL_IF -->
 
+    <!-- TMPL_IF NAME="serialcollection" -->
+    <li<!-- TMPL_IF NAME="defaultserialcollection" --> class="ui-tabs-selected"<!-- /TMPL_IF -->><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#serialcollection">Serial Collection</a></li>
+    <!-- /TMPL_IF -->
 </ul>
 
+<!-- TMPL_IF NAME="serialcollection" -->
+<div id="serialcollection">
+    <table id="serialcollectiont">
+       <thead>
+           <tr>
+               <th>Branch</th>
+               <th>Serial collection</th>
+           </tr>
+       </thead>
+       <tbody>
+       <!-- TMPL_LOOP NAME="serialcollections" -->
+           <tr>
+               <td><!-- TMPL_VAR NAME="branch" --></td>
+               <td><!-- TMPL_VAR NAME="text" --></td>
+           </tr>
+       <!-- /TMPL_LOOP -->
+       </tbody>
+    </table>
+</div>
+<!-- /TMPL_IF -->
+
 <div id="holdings">
 <!-- TMPL_IF name="count" -->
     <table id="holdingst">
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>
index bd4dc0a..f5fe1bd 100755 (executable)
@@ -125,6 +125,12 @@ foreach my $subscription (@subscriptions) {
 
 $dat->{'count'} = scalar(@items);
 
+# If there are no items or the syspref says so, we show serial collection as default tab
+if ($dat->{'count'} == 0 || C4::Context->preference('opacSerialDefaultTab') eq 'serialcollection') {
+       $dat->{'defaultserialcollection'} = 1;
+       
+}
+
 my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $biblionumber, $record ) );
 
 my $norequests = 1;
@@ -283,6 +289,28 @@ if (C4::Context->preference("OPACFRBRizeEditions")==1) {
     };
     if ($@) { warn "XISBN Failed $@"; }
 }
+
+# Serial Collection
+my @sc_fields = $record->field(955);
+my @serialcollections = ();
+
+foreach my $sc_field (@sc_fields) {
+    my %row_data;
+
+    $row_data{text}    = $sc_field->subfield('r');
+    $row_data{branch}  = $sc_field->subfield('9');
+
+    if ($row_data{text} && $row_data{branch}) { 
+       push (@serialcollections, \%row_data);
+    }
+}
+
+if (scalar(@serialcollections) > 0) {
+    $template->param(
+       serialcollection  => 1,
+       serialcollections => \@serialcollections);
+}
+
 # Amazon.com Stuff
 if ( C4::Context->preference("OPACAmazonEnabled") ) {
     $template->param( AmazonTld => get_amazon_tld() );