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

(-)a/catalogue/search.pl (-14 / +16 lines)
Lines 379-399 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');
382
if ( $params->{'multibranchlimit'} ) {
383
383
    my $branchfield  = C4::Context->preference('AdvancedSearchBranchFieldToUse');
384
if($params->{'multibranchlimit'}) {
385
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
384
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
386
    my @libraries = $search_group->all_libraries;
385
    my @branchcodes  = map { $_->branchcode } $search_group->all_libraries;
387
386
388
    if ( $branchfield eq "homebranch") {
387
    if (@branchcodes) {
389
        my $multihomebranch = '('.join( " OR ", map { 'homebranch:     ' . $_->branchcode } @libraries ) .')';
388
        if ( $branchfield eq "homebranch" ) {
390
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
389
            push @limits, sprintf "(%s)", join " or ", map { 'homebranch: ' . $_ } @branchcodes;
391
    } elsif ( $branchfield eq "holdingbranch") {
390
        }
392
        my $multiholdingbranch = '('.join( " OR ", map { 'holdingbranch: ' . $_->branchcode } @libraries ) .')';
391
        elsif ( $branchfield eq "holdingbranch" ) {
393
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
392
            push @limits, sprintf "(%s)", join " or ", map { 'holdingbranch: ' . $_ } @branchcodes;
394
    } else {
393
        }
395
        my $multihomeandholdingbranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode, 'holdingbranch: ' . $_->branchcode}  @libraries ) .')';
394
        else {
396
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
395
            push @limits, sprintf "(%s or %s)",
396
              join( " or ", map { 'homebranch: ' . $_ } @branchcodes ),
397
              join( " or ", map { 'holdingbranch: ' . $_ } @branchcodes );
398
        }
397
    }
399
    }
398
}
400
}
399
401
(-)a/opac/opac-search.pl (-13 / +17 lines)
Lines 486-504 if (@searchCategories > 0) { Link Here
486
486
487
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
487
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
488
488
489
if($params->{'multibranchlimit'}) {
489
if ( $params->{'multibranchlimit'} ) {
490
    my $branchfield  = C4::Context->preference('AdvancedSearchBranchFieldToUse');
490
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
491
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
491
    my @libraries = $search_group->all_libraries;
492
492
493
    my @branchcodes  = map { $_->branchcode } $search_group->all_libraries;
493
    if ( $branchfield eq "homebranch" ) {
494
494
        my $multihomebranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode } @libraries ) .')';
495
    if (@branchcodes) {
495
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
496
        if ( $branchfield eq "homebranch" ) {
496
    } elsif ( $branchfield eq "holdingbranch") {
497
            push @limits, sprintf "(%s)", join " or ", map { 'homebranch: ' . $_ } @branchcodes;
497
        my $multiholdingbranch = '('.join( " OR ", map { 'holdingbranch: ' . $_->branchcode } @libraries ) .')';
498
        }
498
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
499
        elsif ( $branchfield eq "holdingbranch" ) {
499
    } else {
500
            push @limits, sprintf "(%s)", join " or ", map { 'holdingbranch: ' . $_ } @branchcodes;
500
        my $multihomeandholdingbranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode, 'holdingbranch: ' . $_->branchcode}  @libraries ) .')';
501
        }
501
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
502
        else {
503
            push @limits, sprintf "(%s or %s)",
504
              join( " or ", map { 'homebranch: ' . $_ } @branchcodes ),
505
              join( " or ", map { 'holdingbranch: ' . $_ } @branchcodes );
506
        }
502
    }
507
    }
503
}
508
}
504
509
505
- 

Return to bug 21249