From 0521e274b4da2143d7c4b16b141684d330cc3d97 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Mon, 21 Oct 2013 11:54:16 +0200 Subject: [PATCH 1/2] Bug 11091 - limits in catalog search when creating subscription When creating a new subscription, you can click on "Search for Bilbio" to search into catalog. A popup opens with a text field for search terms and a combo-box to limit search. This combo-box uses the syspref AdvancedSearchTypes to know what list of values display. The bug is that the code acts has if AdvancedSearchTypes has always one value, but since Bug 7031, this syspref can have several values (item types, collection codes and locations). This patch removes the use of AdvancedSearchTypes syspref and defines search form with 2 limits : item types and collection codes (from authorised values CCODE). One or both of this information can be on biblio. Searching by location seems to be useless because this information is always on item. If CCODE authorised value does not exist or is empty, the collection code filter is not displayed. Test plan : - Check CCODE authorised value exists with some values - Choose a biblio indexed with both itemtype and ccode indexes - Go to Serials module and click on "New subscription" - In form, click on "Search for Biblio" => The popup "serials/subscription-bib-search.pl" appears with two limits - Enter a word of biblio title, select its item type and select its collection code - Click on "Search" => You get the biblio --- .../en/modules/serials/subscription-bib-search.tt | 55 +++++++++++------- serials/subscription-bib-search.pl | 66 +++++++--------------- 2 files changed, 53 insertions(+), 68 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt index f78d5e0..6c710e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-bib-search.tt @@ -14,28 +14,41 @@
-
-
    -
  1. -
  2. - - -
  3. - +
    +
      +
    1. + +
    2. - -
    -
    -
    - - +
  4. + + +
  5. + [%- IF ccodeloop %] +
  6. + + +
  7. + [%- END %] +
+
+
+ +
diff --git a/serials/subscription-bib-search.pl b/serials/subscription-bib-search.pl index 95e4aa7..c512ac4 100755 --- a/serials/subscription-bib-search.pl +++ b/serials/subscription-bib-search.pl @@ -70,7 +70,6 @@ $startfrom=0 unless $startfrom; my ($template, $loggedinuser, $cookie); my $resultsperpage; -my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype'; my $query = $input->param('q'); @@ -87,23 +86,12 @@ if ($op eq "do_search" && $query) { } ); - # add the itemtype limit if applicable + # add the limits if applicable my $itemtypelimit = $input->param('itemtypelimit'); - if ( $itemtypelimit ) { - my $QParser; - $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser')); - my $op; - if ($QParser) { - $op = '&&'; - } else { - $op = 'and'; - } - if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { - $query .= " $op $itype_or_itemtype:$itemtypelimit"; - } else { - $query .= " $op $advanced_search_types:$itemtypelimit"; - } - } + my $ccodelimit = $input->param('ccodelimit'); + my $op = C4::Context->preference('UseQueryParser') ? '&&' : 'and'; + $query .= " $op $itype_or_itemtype:$itemtypelimit" if $itemtypelimit; + $query .= " $op ccode:$ccodelimit" if $ccodelimit; $debug && warn $query; $resultsperpage= $input->param('resultsperpage'); $resultsperpage = 20 if(!defined $resultsperpage); @@ -200,50 +188,34 @@ else { flagsrequired => {catalogue => 1, serials => '*'}, debug => 1, }); + # load the itemtypes - my $itemtypes = GetItemTypes; + my $itemtypes = GetItemTypes(); my @itemtypesloop; - if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { - # load the itemtypes - my $itemtypes = GetItemTypes; - my $selected=1; - my $cnt; foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { my %row =( code => $thisitemtype, - selected => $selected, description => $itemtypes->{$thisitemtype}->{'description'}, ); - $selected = 0 if ($selected) ; push @itemtypesloop, \%row; } - - } else { - my $advsearchtypes = GetAuthorisedValues($advanced_search_types); - my $cnt; - my $selected=1; - for my $thisitemtype (sort {$a->{'lib'} cmp $b->{'lib'}} @$advsearchtypes) { + # load Collection Codes + my $authvalues = GetAuthorisedValues('CCODE'); + my @ccodesloop; + for my $thisauthvalue (sort {$a->{'lib'} cmp $b->{'lib'}} @$authvalues) { my %row =( - number=>$cnt++, - ccl => $advanced_search_types, - code => $thisitemtype->{authorised_value}, - selected => $selected, - description => $thisitemtype->{'lib'}, - count5 => $cnt % 4, - imageurl=> getitemtypeimagelocation( 'intranet', $thisitemtype->{'imageurl'} ), + code => $thisauthvalue->{'authorised_value'}, + description => $thisauthvalue->{'lib'}, ); - push @itemtypesloop, \%row; + push @ccodesloop, \%row; } - } - - if ($op eq "do_search") { - $template->param("no_query" => 1); - } else { - $template->param("no_query" => 0); - } - $template->param(itemtypeloop => \@itemtypesloop); + $template->param( + itemtypeloop => \@itemtypesloop, + ccodeloop => \@ccodesloop, + no_query => $op eq "do_search" ? 1 : 0, + ); } # Print the page output_html_with_http_headers $input, $cookie, $template->output; -- 1.8.3.2