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

(-)a/catalogue/search.pl (-2 / +13 lines)
Lines 397-407 my @nolimits = map uri_unescape($_), $cgi->multi_param('nolimit'); Link Here
397
my %is_nolimit = map { $_ => 1 } @nolimits;
397
my %is_nolimit = map { $_ => 1 } @nolimits;
398
@limits = grep { not $is_nolimit{$_} } @limits;
398
@limits = grep { not $is_nolimit{$_} } @limits;
399
399
400
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
401
400
if($params->{'multibranchlimit'}) {
402
if($params->{'multibranchlimit'}) {
401
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
403
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
402
    my @libraries = $search_group->all_libraries;
404
    my @libraries = $search_group->all_libraries;
403
    my $multibranch = '('.join( " or ", map { 'branch: ' . $_->branchcode } @libraries ) .')';
405
     my $multihomebranch = '('.join( " or ", map { 'homebranch:     ' . $_->id } @libraries ) .')';
404
    push @limits, $multibranch if ($multibranch ne  '()');
406
     my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
407
408
    if ( $branchfield eq "homebranch") {
409
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
410
    } elsif ( $branchfield eq "holdingbranch") {
411
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
412
    } else {
413
        my $multihomeandholdingbranch = '('.join( " or ", map { 'homebranch: ' . $_->id, 'holdingbranch: ' . $_->id}  @libraries ) .')';
414
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
415
    }
405
}
416
}
406
417
407
my $available;
418
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 151-156 Searching: Link Here
151
                  az: from A to Z.
151
                  az: from A to Z.
152
                  za: from Z to A.
152
                  za: from Z to A.
153
        -
153
        -
154
            - pref: AdvancedSearchBranchFieldToUse
155
              default: homebranch and holdingbranch
156
              choices:
157
                  homebranch: homebranch
158
                  holdingbranch: holdingbranch
159
                  homebranch and holdingbranch: homebranch and holdingbranch
160
            - When a library or group of libraries is selected from the advanced search compare the selected branch value against this branch field(s) selected
161
        -
154
            - pref: displayFacetCount
162
            - pref: displayFacetCount
155
              type: boolean
163
              type: boolean
156
              default: no
164
              default: no
(-)a/opac/opac-search.pl (-3 / +13 lines)
Lines 494-504 if (@searchCategories > 0) { Link Here
494
494
495
@limits = map { uri_unescape($_) } @limits;
495
@limits = map { uri_unescape($_) } @limits;
496
496
497
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
498
497
if($params->{'multibranchlimit'}) {
499
if($params->{'multibranchlimit'}) {
498
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
500
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
499
    my @libraries = $search_group->all_libraries;
501
    my @libraries = $search_group->all_libraries;
500
    my $multibranch = '('.join( " or ", map { 'branch: ' . $_->branchcode } @libraries ) .')';
502
    my $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')';
501
    push @limits, $multibranch if ($multibranch ne  '()');
503
    my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
504
505
    if ( $branchfield eq "homebranch" ) {
506
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
507
    } elsif ( $branchfield eq "holdingbranch") {
508
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
509
    } else {
510
        my $multihomeandholdingbranch = '('.join( " or ", map { 'homebranch: ' . $_->id, 'holdingbranch: ' . $_->id}  @libraries ) .')';
511
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
512
    }
502
}
513
}
503
514
504
my $available;
515
my $available;
505
- 

Return to bug 21249