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

(-)a/catalogue/search.pl (-14 / +16 lines)
Lines 375-395 my @nolimits = map uri_unescape($_), $cgi->multi_param('nolimit'); Link Here
375
my %is_nolimit = map { $_ => 1 } @nolimits;
375
my %is_nolimit = map { $_ => 1 } @nolimits;
376
@limits = grep { not $is_nolimit{$_} } @limits;
376
@limits = grep { not $is_nolimit{$_} } @limits;
377
377
378
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
378
if ( $params->{'multibranchlimit'} ) {
379
379
    my $branchfield  = C4::Context->preference('AdvancedSearchBranchFieldToUse');
380
if($params->{'multibranchlimit'}) {
381
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
380
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
382
    my @libraries = $search_group->all_libraries;
381
    my @branchcodes  = map { $_->branchcode } $search_group->all_libraries;
383
382
384
    if ( $branchfield eq "homebranch") {
383
    if (@branchcodes) {
385
        my $multihomebranch = '('.join( " OR ", map { 'homebranch:     ' . $_->branchcode } @libraries ) .')';
384
        if ( $branchfield eq "homebranch" ) {
386
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
385
            push @limits, sprintf "(%s)", join " or ", map { 'homebranch: ' . $_ } @branchcodes;
387
    } elsif ( $branchfield eq "holdingbranch") {
386
        }
388
        my $multiholdingbranch = '('.join( " OR ", map { 'holdingbranch: ' . $_->branchcode } @libraries ) .')';
387
        elsif ( $branchfield eq "holdingbranch" ) {
389
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
388
            push @limits, sprintf "(%s)", join " or ", map { 'holdingbranch: ' . $_ } @branchcodes;
390
    } else {
389
        }
391
        my $multihomeandholdingbranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode, 'holdingbranch: ' . $_->branchcode}  @libraries ) .')';
390
        else {
392
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
391
            push @limits, sprintf "(%s or %s)",
392
              join( " or ", map { 'homebranch: ' . $_ } @branchcodes ),
393
              join( " or ", map { 'holdingbranch: ' . $_ } @branchcodes );
394
        }
393
    }
395
    }
394
}
396
}
395
397
(-)a/opac/opac-search.pl (-13 / +17 lines)
Lines 497-515 if (@searchCategories > 0) { Link Here
497
497
498
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
498
my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse');
499
499
500
if($params->{'multibranchlimit'}) {
500
if ( $params->{'multibranchlimit'} ) {
501
    my $branchfield  = C4::Context->preference('AdvancedSearchBranchFieldToUse');
501
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
502
    my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
502
    my @libraries = $search_group->all_libraries;
503
503
504
    my @branchcodes  = map { $_->branchcode } $search_group->all_libraries;
504
    if ( $branchfield eq "homebranch" ) {
505
505
        my $multihomebranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode } @libraries ) .')';
506
    if (@branchcodes) {
506
        push @limits, $multihomebranch if ( $multihomebranch ne '()');
507
        if ( $branchfield eq "homebranch" ) {
507
    } elsif ( $branchfield eq "holdingbranch") {
508
            push @limits, sprintf "(%s)", join " or ", map { 'homebranch: ' . $_ } @branchcodes;
508
        my $multiholdingbranch = '('.join( " OR ", map { 'holdingbranch: ' . $_->branchcode } @libraries ) .')';
509
        }
509
        push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()');
510
        elsif ( $branchfield eq "holdingbranch" ) {
510
    } else {
511
            push @limits, sprintf "(%s)", join " or ", map { 'holdingbranch: ' . $_ } @branchcodes;
511
        my $multihomeandholdingbranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode, 'holdingbranch: ' . $_->branchcode}  @libraries ) .')';
512
        }
512
        push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne  '()');
513
        else {
514
            push @limits, sprintf "(%s or %s)",
515
              join( " or ", map { 'homebranch: ' . $_ } @branchcodes ),
516
              join( " or ", map { 'holdingbranch: ' . $_ } @branchcodes );
517
        }
513
    }
518
    }
514
}
519
}
515
520
516
- 

Return to bug 21249