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

(-)a/catalogue/search.pl (-3 / +13 lines)
Lines 397-408 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 $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')';
405
     my $multihomebranch = '('.join( " or ", map { 'homebranch:     ' . $_->id } @libraries ) .')';
404
    my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
406
     my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
405
    push @limits, $multihomebranch . " or " .  $multiholdingbranch if ($multihomebranch && $multiholdingbranch ne  '()');
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
    }
406
}
416
}
407
417
408
my $available;
418
my $available;
(-)a/installer/data/mysql/atomicupdate/bug_21249-Branch_to_limit_advanced_search_results.sql (+2 lines)
Line 0 Link Here
1
INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('AdvancedSearchBranchToLimit', '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');
2
(-)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 (-2 / +11 lines)
Lines 490-501 if (@searchCategories > 0) { Link Here
490
490
491
@limits = map { uri_unescape($_) } @limits;
491
@limits = map { uri_unescape($_) } @limits;
492
492
493
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
494
493
if($params->{'multibranchlimit'}) {
495
if($params->{'multibranchlimit'}) {
494
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
496
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
495
    my @libraries = $search_group->all_libraries;
497
    my @libraries = $search_group->all_libraries;
496
    my $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')';
498
    my $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')';
497
    my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
499
    my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
498
    push @limits, $multihomebranch . " or " .  $multiholdingbranch if ($multihomebranch && $multiholdingbranch ne  '()');
500
501
    if ( $branchfield eq "homebranch" ) {
502
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
503
    } elsif ( $branchfield eq "holdingbranch") {
504
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
505
    } else {
506
        my $multihomeandholdingbranch = '('.join( " or ", map { 'homebranch: ' . $_->id, 'holdingbranch: ' . $_->id}  @libraries ) .')';
507
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
508
    }
499
}
509
}
500
510
501
my $available;
511
my $available;
502
- 

Return to bug 21249