Bug 26141: Remove duplicated code from search.pl
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 5 Aug 2020 07:57:56 +0000 (09:57 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 5 Aug 2020 15:36:28 +0000 (17:36 +0200)
commit 417553a9e47bf31f4cb785162e3dced856a2ac2a
  Bug 12478: starting to add search to staff client

This commit added code related to the itemtypes to the advanced search, but this code already existed.

The weird bit is:
$template->param(advancedsearchesloop => \@advancedsearchesloop);
my $types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
my $advancedsearchesloop = prepare_adv_search_types($types);
$template->param(advancedsearchesloop => $advancedsearchesloop);

We are passing twice advancedsearchesloop to the template.

Test plan (for QA):
Review the changes and confirm that we can safely remove this code

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

catalogue/search.pl

index 6e5d929..1fd012d 100755 (executable)
@@ -237,52 +237,6 @@ $template->param(
 );
 
 # load the Type stuff
-my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
-# the index parameter is different for item-level itemtypes
-my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype';
-my @advancedsearchesloop;
-my $cnt;
-my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
-my @advanced_search_types = split(/\|/, $advanced_search_types);
-
-foreach my $advanced_srch_type (@advanced_search_types) {
-    $advanced_srch_type =~ s/^\s*//;
-    $advanced_srch_type =~ s/\s*$//;
-   if ($advanced_srch_type eq 'itemtypes') {
-   # itemtype is a special case, since it's not defined in authorized values
-        my @itypesloop;
-        foreach my $thisitemtype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes ) {
-           my %row =(  number=>$cnt++,
-               ccl => "$itype_or_itemtype,phr",
-                code => $thisitemtype,
-                description => $itemtypes->{$thisitemtype}->{translated_description},
-                imageurl=> getitemtypeimagelocation( 'intranet', $itemtypes->{$thisitemtype}->{'imageurl'} ),
-            );
-           push @itypesloop, \%row;
-       }
-        my %search_code = (  advanced_search_type => $advanced_srch_type,
-                             code_loop => \@itypesloop );
-        push @advancedsearchesloop, \%search_code;
-    } else {
-    # covers all the other cases: non-itemtype authorized values
-       my $advsearchtypes = GetAuthorisedValues($advanced_srch_type);
-        my @authvalueloop;
-       for my $thisitemtype (@$advsearchtypes) {
-               my %row =(
-                               number=>$cnt++,
-                               ccl => $advanced_srch_type,
-                code => $thisitemtype->{authorised_value},
-                description => $thisitemtype->{'lib'},
-                imageurl => getitemtypeimagelocation( 'intranet', $thisitemtype->{'imageurl'} ),
-                );
-               push @authvalueloop, \%row;
-       }
-        my %search_code = (  advanced_search_type => $advanced_srch_type,
-                             code_loop => \@authvalueloop );
-        push @advancedsearchesloop, \%search_code;
-    }
-}
-$template->param(advancedsearchesloop => \@advancedsearchesloop);
 my $types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
 my $advancedsearchesloop = prepare_adv_search_types($types);
 $template->param(advancedsearchesloop => $advancedsearchesloop);