Resolves bug 2250: RFC: New System Preference to Determine which 'Types' and associat...
authorJoshua Ferraro <jmf@liblime.com>
Wed, 18 Jun 2008 18:01:20 +0000 (13:01 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 18 Jun 2008 18:01:20 +0000 (13:01 -0500)
For documentation, please indicate that as part of profiling,
staff can refer to the AdvancedSearchTypes system preference to
choose where to draw the advanced search 'Types' from. Currently
this is implemented as a choice, between itemtypes and ccodes,
but it's been designed to work with any authorised value so long
as an index exists for searching by that authorised value.

By default, and if this syspref doesn't exist, it will pull from
itemtypes as before.

catalogue/search.pl
installer/data/mysql/en/mandatory/sysprefs.sql
installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tmpl
kohaversion.pl
opac/opac-search.pl

index 10ec0e3..101fd68 100755 (executable)
@@ -216,28 +216,44 @@ my $categories = GetBranchCategories(undef,'searchdomain');
 
 $template->param(branchloop => \@branch_loop, searchdomainloop => $categories);
 
-# load the itemtypes
+# load the Type stuff
+# load the Type stuff
 my $itemtypes = GetItemTypes;
 my @itemtypesloop;
 my $selected=1;
 my $cnt;
 my $imgdir = getitemtypeimagesrc('intranet');
-foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
+my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
+
+if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {                                                                 foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
     my %row =(  number=>$cnt++,
                 imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"",
+                ccl => 'itemtype',
                 code => $thisitemtype,
                 selected => $selected,
                 description => $itemtypes->{$thisitemtype}->{'description'},
                 count5 => $cnt % 4,
             );
-    $selected = 0 if ($selected) ;
-    push @itemtypesloop, \%row;
+        $selected = 0 if ($selected) ;
+        push @itemtypesloop, \%row;
+    }
+    $template->param(itemtypeloop => \@itemtypesloop);
+} else {
+    my $advsearchtypes = GetAuthorisedValues($advanced_search_types);
+    for my $thisitemtype (@$advsearchtypes) {
+        my %row =(
+                number=>$cnt++,
+                imageurl=> $imgdir."/".$thisitemtype->{'imageurl'},
+                ccl => $advanced_search_types,
+                code => $thisitemtype->{authorised_value},
+                selected => $selected,
+                description => $thisitemtype->{'lib'},
+                count5 => $cnt % 4,
+            );
+        push @itemtypesloop, \%row;
+    }
+    $template->param(itemtypeloop => \@itemtypesloop);
 }
-$template->param(itemtypeloop => \@itemtypesloop);
-
-# load the ccodes 
-# my ($ccodecount,@ccode_loop) = GetCcodes();
-# $template->param(ccodeloop=>\@ccode_loop,);
 
 # The following should only be loaded if we're bringing up the advanced search template
 if ( $template_type eq 'advsearch' ) {
index 9313f0f..9282a7f 100755 (executable)
@@ -209,5 +209,5 @@ INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
 INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
 ('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC WARNING: MARC21 Only','YesNo'),
 ('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC WARNING: MARC21 Only','YesNo');
-
+INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice');
 -- FIXME: add FrameworksLoaded, noOPACUserLogin, ReadingHistory ?
index fbfddfc..ad6242c 100755 (executable)
@@ -209,3 +209,4 @@ INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES
 INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('OPACShelfBrowser','1','','Active le parcours des rayonnages sur la page de détail','YesNo');
 INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC WARNING: MARC21 Only','YesNo');
 INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC WARNING: MARC21 Only','YesNo');
+INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice');
index 3b273a1..df5b8cb 100755 (executable)
@@ -1622,6 +1622,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.00.00.089";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice')");
+       print "Upgrade to $DBversion done (added new AdvancedSearchTypes syspref)\n";
+    SetVersion ($DBversion);
+}
 
 =item DropAllForeignKeys($table)
 
index 4511761..d58ad06 100644 (file)
@@ -91,8 +91,8 @@
       <!--TMPL_LOOP Name="itemtypeloop"-->
         <td>
         <!-- TMPL_IF name="imageurl"--><img border="0" src="<!--TMPL_VAR Name="imageurl" -->" alt="<!--TMPL_VAR Name="description" -->" /><!-- /TMPL_IF -->
-               <input type="checkbox" id="mc-<!--TMPL_VAR Name="number" -->" name="limit" value="mc:<!--TMPL_VAR Name="code" -->" />&nbsp;
-        <label for="mc-<!--TMPL_VAR Name="number" -->"><!--TMPL_VAR Name="description" --></label></td>
+               <input type="checkbox" id="<!-- TMPL_VAR NAME="ccl" -->-<!--TMPL_VAR Name="number" -->" name="limit" value="<!-- TMPL_VAR NAME="ccl" -->:<!--TMPL_VAR Name="code" -->" />&nbsp;
+        <label for="<!-- TMPL_VAR NAME="ccl" -->-<!--TMPL_VAR Name="number" -->"><!--TMPL_VAR Name="description" --></label></td>
         <!-- TMPL_UNLESS name="count5" --></tr><tr><!-- /TMPL_UNLESS -->
       <!--/TMPL_LOOP-->
          <!-- FIXME: for validation, avoid generating empty row -->
index 03679fb..a9194d6 100644 (file)
     </fieldset></div>
 <!-- /BOOLEAN SEARCH OPTIONS -->
     <div id="advsearch-itemtype" class="container">
-    <h3>Itemtype limit to any of the following:</h3>
+    <h3>Limit type to: match any of the following:</h3>
     <table>
         <tr>
       <!--TMPL_LOOP Name="itemtypeloop"-->
-        <td><input type="checkbox" id="mc-<!--TMPL_VAR Name="number" -->" name="limit" value="mc:<!--TMPL_VAR Name="code" -->"/><!-- TMPL_IF name="imageurl"--><img border="0" src="<!--TMPL_VAR Name="imageurl" -->" alt="<!--TMPL_VAR Name="description" -->" /><!-- /TMPL_IF -->&nbsp;
+        <td><input type="checkbox" id="<!-- TMPL_VAR NAME="ccl" -->-<!--TMPL_VAR Name="number" -->" name="limit" value="<!-- TMPL_VAR NAME="ccl" -->:<!--TMPL_VAR Name="code" -->"/><!-- TMPL_IF name="imageurl"--><img border="0" src="<!--TMPL_VAR Name="imageurl" -->" alt="<!--TMPL_VAR Name="description" -->" /><!-- /TMPL_IF -->&nbsp;
         <!--TMPL_VAR Name="description" --></td>
         <!-- TMPL_UNLESS name="count5" --></tr><tr><!-- /TMPL_UNLESS -->
       <!--/TMPL_LOOP-->
index bbb64c2..5f23daa 100644 (file)
@@ -10,7 +10,7 @@
 use strict;
 
 sub kohaversion {
-    our $VERSION = "3.00.00.088";
+    our $VERSION = "3.00.00.089";
     # version needs to be set this way
     # so that it can be picked up by Makefile.PL
     # during install
index dd545b3..45d03fa 100755 (executable)
@@ -125,25 +125,44 @@ my $categories = GetBranchCategories(undef,'searchdomain');
 
 $template->param(branchloop => \@branch_loop, searchdomainloop => $categories);
 
-# load the itemtypes
+# load the Type stuff
 my $itemtypes = GetItemTypes;
 my @itemtypesloop;
 my $selected=1;
 my $cnt;
 my $imgdir = getitemtypeimagesrc('opac');
+my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
 
-foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
+if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {
+       foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
     my %row =(  number=>$cnt++,
                 imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"",
+                               ccl => 'itemtype',
                 code => $thisitemtype,
                 selected => $selected,
                 description => $itemtypes->{$thisitemtype}->{'description'},
                 count5 => $cnt % 4,
             );
-    $selected = 0 if ($selected) ;
-    push @itemtypesloop, \%row;
+       $selected = 0 if ($selected) ;
+       push @itemtypesloop, \%row;
+       }
+       $template->param(itemtypeloop => \@itemtypesloop);
+} else {
+    my $advsearchtypes = GetAuthorisedValues($advanced_search_types);
+       for my $thisitemtype (@$advsearchtypes) {
+               my %row =(
+                               number=>$cnt++,
+                imageurl=> $imgdir."/".$thisitemtype->{'imageurl'},
+                               ccl => $advanced_search_types,
+                code => $thisitemtype->{authorised_value},
+                selected => $selected,
+                description => $thisitemtype->{'lib'},
+                count5 => $cnt % 4,
+            );
+               push @itemtypesloop, \%row;
+       }
+       $template->param(itemtypeloop => \@itemtypesloop);
 }
-$template->param(itemtypeloop => \@itemtypesloop);
 
 # # load the itypes (Called item types in the template -- just authorized values for searching)
 # my ($itypecount,@itype_loop) = GetCcodes();