Bug 11466: improve selection of item types for purchase order desired format list
authorOlli-Antti Kivilahti <olli-antti.kivilahti@jns.fi>
Thu, 2 Jan 2014 08:21:49 +0000 (10:21 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Sun, 4 May 2014 23:20:33 +0000 (23:20 +0000)
This patch ensures that the list of desired formats for a purchase
suggestion includes the list of item types so long as the
AdvancedSearchTypes system preference includes 'itemtypes'.

--------------
-- Synopsis --
--------------

When system preference AdvancedSearchTypes has other values than 'itemtypes',
for ex 'itemtypes|loc', itemtypes selection in opac-suggestions.pl
is not populated with available itemtypes.

This patch fixes the issue by broadening the strict comparison of
($advanced_search_types eg 'itemtypes') #fails 'itemtypes|loc'
to
($advanced_search_types =~ 'itemtypes') #succeeds 'itemtypes|loc'

Unit tests included

---------------
-- Test plan --
---------------

REPLICATING THE ISSUE
1. Set system preference  AdvancedSearchTypes to itemtypes|loc
2. Go to opac-suggestions.pl and observe Item type <select> dropdown list
2.1. List should have only the default value

AFTER APPLYING THIS PATCH
1. Set system preference  AdvancedSearchTypes to itemtypes|loc
2. Go to opac-suggestions.pl and observe Item type <select> dropdown list
2.1. List should have itemtypes available for selection

Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Tests worked as expected. Placed a suggestion and saw the whole
list of item types, chose one, saved, checked staff and it loaded
as expected. Changed item type in staff and it applied in both
views.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described, passes all tests including new regression tests.
Restores old functionality.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>

C4/Koha.pm
t/db_dependent/Suggestions.t

index c7aa3ed..68652ff 100644 (file)
@@ -189,7 +189,7 @@ build a HTML select with the following code :
 
 sub GetSupportList{
        my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes");
-       if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {  
+    if (!$advanced_search_types or $advanced_search_types =~ /itemtypes/) {
                my $query = qq|
                        SELECT *
                        FROM   itemtypes
index f285929..51c21b8 100644 (file)
@@ -9,10 +9,11 @@ use Data::Dumper;
 
 use C4::Suggestions;
 
-use Test::More tests =>9;
+use Test::More tests =>12;
 
 BEGIN {
     use_ok('C4::Suggestions');
+    use_ok('C4::Koha');
 }
 
 my ($suggestionid, $suggestion, $status, $biblionumber);
@@ -26,3 +27,12 @@ ok($suggestion= GetSuggestionFromBiblionumber( $biblionumber ), "GetSuggestionFr
 ok($suggestion= GetSuggestionInfoFromBiblionumber( $biblionumber ), "GetSuggestionInfoFromBiblionumber OK");
 ok(@{SearchSuggestion( {STATUS=>'STALLED'} )}>0, "SearchSuggestion Status OK");
 
+## Bug 11466, making sure GetSupportList() returns itemtypes, even if AdvancedSearchTypes has multiple values
+C4::Context->set_preference("AdvancedSearchTypes", 'itemtypes|loc|ccode');
+my $itemtypes = C4::Koha::GetSupportList();
+ok(scalar @$itemtypes, "Purchase suggestion itemtypes collected, multiple AdvancedSearchTypes");
+
+C4::Context->set_preference("AdvancedSearchTypes", 'itemtypes');
+$itemtypes = C4::Koha::GetSupportList();
+ok(scalar @$itemtypes, "Purchase suggestion itemtypes collected, default AdvancedSearchTypes");
+##EO Bug 11466
\ No newline at end of file