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

(-)a/catalogue/search.pl (-14 / +16 lines)
Lines 412-432 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');
415
if ( $params->{'multibranchlimit'} ) {
416
416
    my $branchfield  = C4::Context->preference('AdvancedSearchBranchFieldToUse');
417
if($params->{'multibranchlimit'}) {
418
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
417
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
419
    my @libraries = $search_group->all_libraries;
418
    my @branchcodes  = map { $_->branchcode } $search_group->all_libraries;
420
     my $multihomebranch = '('.join( " or ", map { 'homebranch:     ' . $_->id } @libraries ) .')';
419
421
     my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
420
    if (@branchcodes) {
422
421
        if ( $branchfield eq "homebranch" ) {
423
    if ( $branchfield eq "homebranch") {
422
            push @limits, sprintf "(%s)", join " or ", map { 'homebranch: ' . $_ } @branchcodes;
424
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
423
        }
425
    } elsif ( $branchfield eq "holdingbranch") {
424
        elsif ( $branchfield eq "holdingbranch" ) {
426
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
425
            push @limits, sprintf "(%s)", join " or ", map { 'holdingbranch: ' . $_ } @branchcodes;
427
    } else {
426
        }
428
        my $multihomeandholdingbranch = '('.join( " or ", map { 'homebranch: ' . $_->id, 'holdingbranch: ' . $_->id}  @libraries ) .')';
427
        else {
429
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
428
            push @limits, sprintf "(%s or %s)",
429
              join( " or ", map { 'homebranch: ' . $_ } @branchcodes ),
430
              join( " or ", map { 'holdingbranch: ' . $_ } @branchcodes );
431
        }
430
    }
432
    }
431
}
433
}
432
434
(-)a/opac/opac-search.pl (-13 / +16 lines)
Lines 502-520 if (@searchCategories > 0) { Link Here
502
502
503
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
503
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
504
504
505
if($params->{'multibranchlimit'}) {
505
if ( $params->{'multibranchlimit'} ) {
506
    my $branchfield  = C4::Context->preference('AdvancedSearchBranchFieldToUse');
506
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
507
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
507
    my @libraries = $search_group->all_libraries;
508
    my @branchcodes  = map { $_->branchcode } $search_group->all_libraries;
508
    my $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')';
509
509
    my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')';
510
    if (@branchcodes) {
510
511
        if ( $branchfield eq "homebranch" ) {
511
    if ( $branchfield eq "homebranch" ) {
512
            push @limits, sprintf "(%s)", join " or ", map { 'homebranch: ' . $_ } @branchcodes;
512
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
513
        }
513
    } elsif ( $branchfield eq "holdingbranch") {
514
        elsif ( $branchfield eq "holdingbranch" ) {
514
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
515
            push @limits, sprintf "(%s)", join " or ", map { 'holdingbranch: ' . $_ } @branchcodes;
515
    } else {
516
        }
516
        my $multihomeandholdingbranch = '('.join( " or ", map { 'homebranch: ' . $_->id, 'holdingbranch: ' . $_->id}  @libraries ) .')';
517
        else {
517
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
518
            push @limits, sprintf "(%s or %s)",
519
              join( " or ", map { 'homebranch: ' . $_ } @branchcodes ),
520
              join( " or ", map { 'holdingbranch: ' . $_ } @branchcodes );
521
        }
518
    }
522
    }
519
}
523
}
520
524
521
- 

Return to bug 21249