View | Details | Raw Unified | Return to bug 21249
Collapse All | Expand All

(-)a/catalogue/search.pl (-2 / +13 lines)
Lines 379-389 my @nolimits = map uri_unescape($_), $cgi->multi_param('nolimit'); Link Here
379
my %is_nolimit = map { $_ => 1 } @nolimits;
379
my %is_nolimit = map { $_ => 1 } @nolimits;
380
@limits = grep { not $is_nolimit{$_} } @limits;
380
@limits = grep { not $is_nolimit{$_} } @limits;
381
381
382
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
383
382
if($params->{'multibranchlimit'}) {
384
if($params->{'multibranchlimit'}) {
383
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
385
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
384
    my @libraries = $search_group->all_libraries;
386
    my @libraries = $search_group->all_libraries;
385
    my $multibranch = '('.join( " OR ", map { '(homebranch: ' . $_->branchcode .')' } @libraries ) .')';
387
386
    push @limits, $multibranch if ($multibranch ne  '()');
388
    if ( $branchfield eq "homebranch") {
389
        my $multihomebranch = '('.join( " OR ", map { 'homebranch:     ' . $_->branchcode } @libraries ) .')';
390
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
391
    } elsif ( $branchfield eq "holdingbranch") {
392
        my $multiholdingbranch = '('.join( " OR ", map { 'holdingbranch: ' . $_->branchcode } @libraries ) .')';
393
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
394
    } else {
395
        my $multihomeandholdingbranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode, 'holdingbranch: ' . $_->branchcode}  @libraries ) .')';
396
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
397
    }
387
}
398
}
388
399
389
my $available;
400
my $available;
(-)a/installer/data/mysql/atomicupdate/bug_21249-Branch_to_limit_advanced_search_results.sql (+1 lines)
Line 0 Link Here
1
INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('AdvancedSearchBranchFieldToUse', 'homebranch and holdingbranch', 'homebranch|holdingbranch|homebranch and holdingbranch', 'When a library or group of libraries is selected from the advanced search compare the selected branch value against this branch field(s) selected', 'choice');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (+8 lines)
Lines 167-172 Searching: Link Here
167
                  dsc: descending.
167
                  dsc: descending.
168
                  az: from A to Z.
168
                  az: from A to Z.
169
                  za: from Z to A.
169
                  za: from Z to A.
170
        -
171
            - pref: AdvancedSearchBranchFieldToUse
172
              default: homebranch and holdingbranch
173
              choices:
174
                  homebranch: homebranch
175
                  holdingbranch: holdingbranch
176
                  homebranch and holdingbranch: homebranch and holdingbranch
177
            - When a library or group of libraries is selected from the advanced search compare the selected branch value against this branch field(s) selected
170
        -
178
        -
171
            - pref: displayFacetCount
179
            - pref: displayFacetCount
172
              type: boolean
180
              type: boolean
(-)a/opac/opac-search.pl (-3 / +13 lines)
Lines 484-494 if (@searchCategories > 0) { Link Here
484
484
485
@limits = map { uri_unescape($_) } @limits;
485
@limits = map { uri_unescape($_) } @limits;
486
486
487
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
488
487
if($params->{'multibranchlimit'}) {
489
if($params->{'multibranchlimit'}) {
488
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
490
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
489
    my @libraries = $search_group->all_libraries;
491
    my @libraries = $search_group->all_libraries;
490
    my $multibranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode } @libraries ) .')';
492
491
    push @limits, $multibranch if ($multibranch ne  '()');
493
    if ( $branchfield eq "homebranch" ) {
494
        my $multihomebranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode } @libraries ) .')';
495
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
496
    } elsif ( $branchfield eq "holdingbranch") {
497
        my $multiholdingbranch = '('.join( " OR ", map { 'holdingbranch: ' . $_->branchcode } @libraries ) .')';
498
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
499
    } else {
500
        my $multihomeandholdingbranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode, 'holdingbranch: ' . $_->branchcode}  @libraries ) .')';
501
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
502
    }
492
}
503
}
493
504
494
my $available;
505
my $available;
495
- 

Return to bug 21249