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

(-)a/catalogue/search.pl (-2 / +13 lines)
Lines 412-422 my @nolimits = map uri_unescape($_), $cgi->multi_param('nolimit'); Link Here
412
my %is_nolimit = map { $_ => 1 } @nolimits;
412
my %is_nolimit = map { $_ => 1 } @nolimits;
413
@limits = grep { not $is_nolimit{$_} } @limits;
413
@limits = grep { not $is_nolimit{$_} } @limits;
414
414
415
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
416
415
if($params->{'multibranchlimit'}) {
417
if($params->{'multibranchlimit'}) {
416
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
418
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
417
    my @libraries = $search_group->all_libraries;
419
    my @libraries = $search_group->all_libraries;
418
    my $multibranch = '('.join( " or ", map { 'branch: ' . $_->branchcode } @libraries ) .')';
420
     my $multihomebranch = '('.join( " or ", map { 'homebranch:     ' . $_->id } @libraries ) .')';
419
    push @limits, $multibranch if ($multibranch ne  '()');
421
     my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
422
423
    if ( $branchfield eq "homebranch") {
424
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
425
    } elsif ( $branchfield eq "holdingbranch") {
426
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
427
    } else {
428
        my $multihomeandholdingbranch = '('.join( " or ", map { 'homebranch: ' . $_->id, 'holdingbranch: ' . $_->id}  @libraries ) .')';
429
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
430
    }
420
}
431
}
421
432
422
my $available;
433
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 159-164 Searching: Link Here
159
                  az: from A to Z.
159
                  az: from A to Z.
160
                  za: from Z to A.
160
                  za: from Z to A.
161
        -
161
        -
162
            - pref: AdvancedSearchBranchFieldToUse
163
              default: homebranch and holdingbranch
164
              choices:
165
                  homebranch: homebranch
166
                  holdingbranch: holdingbranch
167
                  homebranch and holdingbranch: homebranch and holdingbranch
168
            - When a library or group of libraries is selected from the advanced search compare the selected branch value against this branch field(s) selected
169
        -
162
            - pref: displayFacetCount
170
            - pref: displayFacetCount
163
              type: boolean
171
              type: boolean
164
              default: no
172
              default: no
(-)a/opac/opac-search.pl (-3 / +13 lines)
Lines 500-510 if (@searchCategories > 0) { Link Here
500
500
501
@limits = map { uri_unescape($_) } @limits;
501
@limits = map { uri_unescape($_) } @limits;
502
502
503
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
504
503
if($params->{'multibranchlimit'}) {
505
if($params->{'multibranchlimit'}) {
504
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
506
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
505
    my @libraries = $search_group->all_libraries;
507
    my @libraries = $search_group->all_libraries;
506
    my $multibranch = '('.join( " or ", map { 'branch: ' . $_->branchcode } @libraries ) .')';
508
    my $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')';
507
    push @limits, $multibranch if ($multibranch ne  '()');
509
    my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
510
511
    if ( $branchfield eq "homebranch" ) {
512
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
513
    } elsif ( $branchfield eq "holdingbranch") {
514
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
515
    } else {
516
        my $multihomeandholdingbranch = '('.join( " or ", map { 'homebranch: ' . $_->id, 'holdingbranch: ' . $_->id}  @libraries ) .')';
517
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
518
    }
508
}
519
}
509
520
510
my $available;
521
my $available;
511
- 

Return to bug 21249