From f22e5834f980f660b63c597727e3175288e66e49 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 23 May 2013 10:01:21 -0400 Subject: [PATCH] Bug 10304 - Add avanced search filter for "not for loan" items This patch adds a new search limit for not for loan items. This limit filters all items that have a notforloan value not equal to 0. This limit can be used in conjunction with the "available" limit so that a person may search for items that are available and can be checked out right away. Test Plan: 1) Apply this patch 2) Catalog 3 records with 1 item each. a) Mark item A as notforloan b) Mark item B as lost c) Do nothing to item C 3) Do a search limiting only to available items a) You should see item's A and C in your reults 4) Do a search limiting only to items that can be checked out a) You should see item's B and C 5) Do a seach using both limits a) You should see item C and not items A or B --- C4/Search.pm | 22 ++++++++++++++----- .../prog/en/modules/catalogue/advsearch.tt | 12 ++++++++++- .../opac-tmpl/prog/en/modules/opac-advsearch.tt | 11 +++++++++- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index aec024b..9e60f29 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1517,17 +1517,23 @@ sub buildQuery { # add limits my %group_OR_limits; my $availability_limit; + my $for_loan_limit; foreach my $this_limit (@limits) { next unless $this_limit; if ( $this_limit =~ /available/ ) { -# -## 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0) -## In English: -## all records not indexed in the onloan register (zebra) and all records with a value of lost equal to 0 + + # 'available' is defined as (items.onloan is NULL) and (items.itemlost = 0) + # In English: + # all records not indexed in the onloan register (zebra) and all records with a value of lost equal to 0 $availability_limit .= -"( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and (lost,st-numeric=0) )"; #or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; + "( ( allrecords,AlwaysMatches='' not onloan,AlwaysMatches='') and (lost,st-numeric=0) )"; #or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='')) )"; $limit_cgi .= "&limit=available"; - $limit_desc .= ""; + } + + if ( $this_limit =~ /for_loan/ ) { + + $for_loan_limit .= "( notforloan,st-numeric = 0 )"; + $limit_cgi .= "&limit=for_loan"; } # group_OR_limits, prefixed by mc- @@ -1573,6 +1579,10 @@ sub buildQuery { $limit .= " and " if ( $query || $limit ); $limit .= "($availability_limit)"; } + if ( $for_loan_limit ) { + $limit .= " and " if ( $query || $limit ); + $limit .= $for_loan_limit; + } # Normalize the query and limit strings # This is flawed , means we can't search anything with : in it diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt index c982eb4..975560e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -231,7 +231,17 @@
Location and availability
-

+

+ + + i.e. not checked out and not lost +

+
+
+

+ + +

diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt index 825e8be..f2591bc 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt @@ -304,7 +304,16 @@ [% END %] [% END %] -
+
+ +
+
+ +
[% END %] -- 1.7.2.5