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

(-)a/catalogue/search.pl (-2 / +13 lines)
Lines 420-430 my @nolimits = map uri_unescape($_), $cgi->multi_param('nolimit'); Link Here
420
my %is_nolimit = map { $_ => 1 } @nolimits;
420
my %is_nolimit = map { $_ => 1 } @nolimits;
421
@limits = grep { not $is_nolimit{$_} } @limits;
421
@limits = grep { not $is_nolimit{$_} } @limits;
422
422
423
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
424
423
if($params->{'multibranchlimit'}) {
425
if($params->{'multibranchlimit'}) {
424
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
426
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
425
    my @libraries = $search_group->all_libraries;
427
    my @libraries = $search_group->all_libraries;
426
    my $multibranch = '('.join( " OR ", map { '(homebranch: ' . $_->branchcode .')' } @libraries ) .')';
428
427
    push @limits, $multibranch if ($multibranch ne  '()');
429
    if ( $branchfield eq "homebranch") {
430
        my $multihomebranch = '('.join( " OR ", map { 'homebranch:     ' . $_->branchcode } @libraries ) .')';
431
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
432
    } elsif ( $branchfield eq "holdingbranch") {
433
        my $multiholdingbranch = '('.join( " OR ", map { 'holdingbranch: ' . $_->branchcode } @libraries ) .')';
434
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
435
    } else {
436
        my $multihomeandholdingbranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode, 'holdingbranch: ' . $_->branchcode}  @libraries ) .')';
437
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
438
    }
428
}
439
}
429
440
430
my $available;
441
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 168-173 Searching: Link Here
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
        -
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
178
        -
171
            - pref: displayFacetCount
179
            - pref: displayFacetCount
172
              type: boolean
180
              type: boolean
173
              default: no
181
              default: no
(-)a/opac/opac-search.pl (-3 / +13 lines)
Lines 495-505 if (@searchCategories > 0) { Link Here
495
495
496
@limits = map { uri_unescape($_) } @limits;
496
@limits = map { uri_unescape($_) } @limits;
497
497
498
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
499
498
if($params->{'multibranchlimit'}) {
500
if($params->{'multibranchlimit'}) {
499
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
501
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
500
    my @libraries = $search_group->all_libraries;
502
    my @libraries = $search_group->all_libraries;
501
    my $multibranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode } @libraries ) .')';
503
502
    push @limits, $multibranch if ($multibranch ne  '()');
504
    if ( $branchfield eq "homebranch" ) {
505
        my $multihomebranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode } @libraries ) .')';
506
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
507
    } elsif ( $branchfield eq "holdingbranch") {
508
        my $multiholdingbranch = '('.join( " OR ", map { 'holdingbranch: ' . $_->branchcode } @libraries ) .')';
509
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
510
    } else {
511
        my $multihomeandholdingbranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode, 'holdingbranch: ' . $_->branchcode}  @libraries ) .')';
512
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
513
    }
503
}
514
}
504
515
505
my $available;
516
my $available;
506
- 

Return to bug 21249