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

(-)a/C4/Search.pm (+11 lines)
Lines 1241-1246 sub buildQuery { Link Here
1241
            }
1241
            }
1242
            $q .= ' and '.join(' and ', @limits) if @limits;
1242
            $q .= ' and '.join(' and ', @limits) if @limits;
1243
        }
1243
        }
1244
        #TODO withoutitems limit
1244
        return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $original_q, '', '', '', 'ccl' );
1245
        return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $original_q, '', '', '', 'ccl' );
1245
    }
1246
    }
1246
    if ( $query =~ /^cql=/ ) {
1247
    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 1019-1024 sub _fix_limit_special_cases { Link Here
1019
        elsif ( $l =~ /^available$/ ) {
1019
        elsif ( $l =~ /^available$/ ) {
1020
            push @new_lim, 'onloan:false';
1020
            push @new_lim, 'onloan:false';
1021
        }
1021
        }
1022
        elsif ( $l =~ /^withoutitems$/ ) {
1023
            push @new_lim, 'NOT homebranch:*';
1024
        }
1022
        else {
1025
        else {
1023
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
1026
            my ( $field, $term ) = $l =~ /^\s*([\w,-]*?):(.*)/;
1024
            $field =~ s/,phr$//; #We are quoting all the limits as phrase, this prevents from quoting again later
1027
            $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 268-274 Link Here
268
<!-- AVAILABILITY LIMITS -->
268
<!-- AVAILABILITY LIMITS -->
269
    <fieldset id="availability"><legend>Location and availability</legend>
269
    <fieldset id="availability"><legend>Location and availability</legend>
270
<fieldset id="currently-avail">
270
<fieldset id="currently-avail">
271
        <p><label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" /></p>
271
    <p>
272
        <label for="available-items">Only items currently available:</label> <input type="checkbox" id="available-items" name="limit" value="available" />
273
        <label for="withoutitems">Only records without items:</label> <input type="checkbox" id="withoutitems" name="limit" value="withoutitems" />
274
    </p>
272
</fieldset>
275
</fieldset>
273
276
274
<fieldset id="select-libs">
277
<fieldset id="select-libs">
275
- 

Return to bug 26860