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

(-)a/C4/Search.pm (+11 lines)
Lines 1322-1327 sub buildQuery { Link Here
1322
            }
1322
            }
1323
            $q .= ' and '.join(' and ', @limits) if @limits;
1323
            $q .= ' and '.join(' and ', @limits) if @limits;
1324
        }
1324
        }
1325
        #TODO withoutitems limit
1325
        return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $original_q, '', '', '', 'ccl' );
1326
        return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $original_q, '', '', '', 'ccl' );
1326
    }
1327
    }
1327
    if ( $query =~ /^cql=/ ) {
1328
    if ( $query =~ /^cql=/ ) {
Lines 1515-1520 sub buildQuery { Link Here
1515
    # add limits
1516
    # add limits
1516
    my %group_OR_limits;
1517
    my %group_OR_limits;
1517
    my $availability_limit;
1518
    my $availability_limit;
1519
    my $withoutitems_limit;
1518
    foreach my $this_limit (@limits) {
1520
    foreach my $this_limit (@limits) {
1519
        next unless $this_limit;
1521
        next unless $this_limit;
1520
        if ( $this_limit =~ /available/ ) {
1522
        if ( $this_limit =~ /available/ ) {
Lines 1527-1532 sub buildQuery { Link Here
1527
            $limit_cgi  .= "&limit=available";
1529
            $limit_cgi  .= "&limit=available";
1528
            $limit_desc .= "";
1530
            $limit_desc .= "";
1529
        }
1531
        }
1532
        elsif ( $this_limit =~ /withoutitems/ ) {
1533
            $withoutitems_limit = "( allrecords,AlwaysMatches='' not(homebranch,AlwaysMatches='') )";
1534
            $limit_cgi  .= "&limit=withoutitems";
1535
            $limit_desc .= "";
1536
        }
1530
1537
1531
        # group_OR_limits, prefixed by mc-
1538
        # group_OR_limits, prefixed by mc-
1532
        # OR every member of the group
1539
        # OR every member of the group
Lines 1571-1576 sub buildQuery { Link Here
1571
        $limit .= " and " if ( $query || $limit );
1578
        $limit .= " and " if ( $query || $limit );
1572
        $limit .= "($availability_limit)";
1579
        $limit .= "($availability_limit)";
1573
    }
1580
    }
1581
    if ($withoutitems_limit) {
1582
        $limit .= " and " if ( $query || $limit );
1583
        $limit .= "($withoutitems_limit)";
1584
    }
1574
1585
1575
    # Normalize the query and limit strings
1586
    # Normalize the query and limit strings
1576
    # This is flawed , means we can't search anything with : in it
1587
    # This is flawed , means we can't search anything with : in it
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (+3 lines)
Lines 1012-1017 sub _fix_limit_special_cases { Link Here
1012
        elsif ( $l =~ /^available$/ ) {
1012
        elsif ( $l =~ /^available$/ ) {
1013
            push @new_lim, 'onloan:false';
1013
            push @new_lim, 'onloan:false';
1014
        }
1014
        }
1015
        elsif ( $l =~ /^withoutitems$/ ) {
1016
            push @new_lim, 'NOT homebranch:*';
1017
        }
1015
        else {
1018
        else {
1016
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
1019
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
1017
            $field =~ s/,phr$//; #We are quoting all the limits as phrase, this prevents from quoting again later
1020
            $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 382-394 if($params->{'multibranchlimit'}) { Link Here
382
    push @limits, $multibranch if ($multibranch ne  '()');
382
    push @limits, $multibranch if ($multibranch ne  '()');
383
}
383
}
384
384
385
my $available;
385
my ($available, $withoutitems);
386
foreach my $limit(@limits) {
386
foreach my $limit(@limits) {
387
    if ($limit =~/available/) {
387
    if ($limit =~/available/) {
388
        $available = 1;
388
        $available = 1;
389
    }
389
    }
390
    if ($limit =~/withoutitems/) {
391
        $withoutitems = 1;
392
    }
390
}
393
}
391
$template->param(available => $available);
394
$template->param(
395
    available    => $available,
396
    withoutitems => $withoutitems,
397
);
392
398
393
# append year limits if they exist
399
# append year limits if they exist
394
my $limit_yr;
400
my $limit_yr;
Lines 578-583 for (my $i=0;$i<@servers;$i++) { Link Here
578
                my $limit_cgi_not_availablity = $limit_cgi;
584
                my $limit_cgi_not_availablity = $limit_cgi;
579
                $limit_cgi_not_availablity =~ s/&limit=available//g;
585
                $limit_cgi_not_availablity =~ s/&limit=available//g;
580
                $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity);
586
                $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity);
587
                my $limit_cgi_not_withoutitems = $limit_cgi;
588
                $limit_cgi_not_withoutitems =~ s/&limit=withoutitems//g;
589
                $template->param(limit_cgi_not_withoutitems => $limit_cgi_not_withoutitems);
581
            }
590
            }
582
            $template->param(limit_cgi => $limit_cgi);
591
            $template->param(limit_cgi => $limit_cgi);
583
            $template->param(query_cgi => $query_cgi);
592
            $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 264-270 Link Here
264
<!-- AVAILABILITY LIMITS -->
264
<!-- AVAILABILITY LIMITS -->
265
    <fieldset id="availability"><legend>Location and availability</legend>
265
    <fieldset id="availability"><legend>Location and availability</legend>
266
<fieldset id="currently-avail">
266
<fieldset id="currently-avail">
267
        <p><label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" /></p>
267
    <p>
268
        <label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" />
269
        <label for="withoutitems">Only records without items:</label> <input type="checkbox" id="withoutitems" name="limit" value="withoutitems" />
270
    </p>
268
</fieldset>
271
</fieldset>
269
272
270
<fieldset id="select-libs">
273
<fieldset id="select-libs">
271
- 

Return to bug 26860