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

(-)a/C4/Search.pm (+11 lines)
Lines 1242-1247 sub buildQuery { Link Here
1242
            }
1242
            }
1243
            $q .= ' and '.join(' and ', @limits) if @limits;
1243
            $q .= ' and '.join(' and ', @limits) if @limits;
1244
        }
1244
        }
1245
        #TODO withoutitems limit
1245
        return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $original_q, '', '', '', 'ccl' );
1246
        return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $original_q, '', '', '', 'ccl' );
1246
    }
1247
    }
1247
    if ( $query =~ /^cql=/ ) {
1248
    if ( $query =~ /^cql=/ ) {
Lines 1441-1446 sub buildQuery { Link Here
1441
    # add limits
1442
    # add limits
1442
    my %group_OR_limits;
1443
    my %group_OR_limits;
1443
    my $availability_limit;
1444
    my $availability_limit;
1445
    my $withoutitems_limit;
1444
    foreach my $this_limit (@limits) {
1446
    foreach my $this_limit (@limits) {
1445
        next unless $this_limit;
1447
        next unless $this_limit;
1446
        if ( $this_limit =~ /available/ ) {
1448
        if ( $this_limit =~ /available/ ) {
Lines 1453-1458 sub buildQuery { Link Here
1453
            $limit_cgi  .= "&limit=available";
1455
            $limit_cgi  .= "&limit=available";
1454
            $limit_desc .= "";
1456
            $limit_desc .= "";
1455
        }
1457
        }
1458
        elsif ( $this_limit =~ /withoutitems/ ) {
1459
            $withoutitems_limit = "( allrecords,AlwaysMatches='' not(homebranch,AlwaysMatches='') )";
1460
            $limit_cgi  .= "&limit=withoutitems";
1461
            $limit_desc .= "";
1462
        }
1456
1463
1457
        # group_OR_limits, prefixed by mc-
1464
        # group_OR_limits, prefixed by mc-
1458
        # OR every member of the group
1465
        # OR every member of the group
Lines 1497-1502 sub buildQuery { Link Here
1497
        $limit .= " and " if ( $query || $limit );
1504
        $limit .= " and " if ( $query || $limit );
1498
        $limit .= "($availability_limit)";
1505
        $limit .= "($availability_limit)";
1499
    }
1506
    }
1507
    if ($withoutitems_limit) {
1508
        $limit .= " and " if ( $query || $limit );
1509
        $limit .= "($withoutitems_limit)";
1510
    }
1500
1511
1501
    # Normalize the query and limit strings
1512
    # Normalize the query and limit strings
1502
    # This is flawed , means we can't search anything with : in it
1513
    # This is flawed , means we can't search anything with : in it
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (+3 lines)
Lines 1013-1018 sub _fix_limit_special_cases { Link Here
1013
        elsif ( $l =~ /^available$/ ) {
1013
        elsif ( $l =~ /^available$/ ) {
1014
            push @new_lim, 'onloan:false';
1014
            push @new_lim, 'onloan:false';
1015
        }
1015
        }
1016
        elsif ( $l =~ /^withoutitems$/ ) {
1017
            push @new_lim, 'NOT homebranch:*';
1018
        }
1016
        else {
1019
        else {
1017
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
1020
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
1018
            $field =~ s/,phr$//; #We are quoting all the limits as phrase, this prevents from quoting again later
1021
            $field =~ s/,phr$//; #We are quoting all the limits as phrase, this prevents from quoting again later
(-)a/catalogue/search.pl (-2 / +11 lines)
Lines 417-429 for ( my $i=0; $i<@limits; $i++ ) { Link Here
417
    }
417
    }
418
}
418
}
419
419
420
my $available;
420
my ($available, $withoutitems);
421
foreach my $limit(@limits) {
421
foreach my $limit(@limits) {
422
    if ($limit =~/available/) {
422
    if ($limit =~/available/) {
423
        $available = 1;
423
        $available = 1;
424
    }
424
    }
425
    if ($limit =~/withoutitems/) {
426
        $withoutitems = 1;
427
    }
425
}
428
}
426
$template->param(available => $available);
429
$template->param(
430
    available    => $available,
431
    withoutitems => $withoutitems,
432
);
427
433
428
# append year limits if they exist
434
# append year limits if they exist
429
my $limit_yr;
435
my $limit_yr;
Lines 613-618 for (my $i=0;$i<@servers;$i++) { Link Here
613
                my $limit_cgi_not_availablity = $limit_cgi;
619
                my $limit_cgi_not_availablity = $limit_cgi;
614
                $limit_cgi_not_availablity =~ s/&limit=available//g;
620
                $limit_cgi_not_availablity =~ s/&limit=available//g;
615
                $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity);
621
                $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity);
622
                my $limit_cgi_not_withoutitems = $limit_cgi;
623
                $limit_cgi_not_withoutitems =~ s/&limit=withoutitems//g;
624
                $template->param(limit_cgi_not_withoutitems => $limit_cgi_not_withoutitems);
616
            }
625
            }
617
            $template->param(limit_cgi => $limit_cgi);
626
            $template->param(limit_cgi => $limit_cgi);
618
            $template->param(query_cgi => $query_cgi);
627
            $template->param(query_cgi => $query_cgi);
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc (+11 lines)
Lines 17-22 Link Here
17
    [% END %]
17
    [% END %]
18
    </ul>
18
    </ul>
19
  </li>
19
  </li>
20
  <li id="withoutitems_id">
21
    <span id="facet-withoutitems">Without items</span>
22
    <ul>
23
    [% IF ( withoutitems ) %]
24
      <li><strong>Showing only without items</strong></li>
25
      <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi_not_withoutitems | $raw %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %]">Show all records</a></li>
26
    [% ELSE %]
27
      <li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi | $raw %][% limit_cgi | $raw %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by | uri %][% END %]&amp;limit=withoutitems">Limit to records without items</a></li>
28
    [% END %]
29
    </ul>
30
  </li>
20
  [% IF ( related ) %] <li>(related searches: [% FOREACH relate IN related %][% relate.related_search | html %][% END %])</li>[% END %]
31
  [% IF ( related ) %] <li>(related searches: [% FOREACH relate IN related %][% relate.related_search | html %][% END %])</li>[% END %]
21
32
22
[% FOREACH facets_loo IN facets_loop %]
33
[% FOREACH facets_loo IN facets_loop %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt (-2 / +4 lines)
Lines 280-286 Link Here
280
<!-- AVAILABILITY LIMITS -->
280
<!-- AVAILABILITY LIMITS -->
281
    <fieldset id="availability"><legend>Location and availability</legend>
281
    <fieldset id="availability"><legend>Location and availability</legend>
282
<fieldset id="currently-avail">
282
<fieldset id="currently-avail">
283
        <p><label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" /></p>
283
    <p>
284
        <label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" />
285
        <label for="withoutitems">Only records without items:</label> <input type="checkbox" id="withoutitems" name="limit" value="withoutitems" />
286
    </p>
284
</fieldset>
287
</fieldset>
285
288
286
<fieldset id="select-libs">
289
<fieldset id="select-libs">
287
- 

Return to bug 26860