[Koha-patches] [PATCH] Expanding IndependantBranches to resident search box
Michael Hafen
mdhafen at washk12.org
Tue May 27 20:24:34 CEST 2008
Added "search all branches" checkbox to Patrons resident search
Changed ysearch.pl to honor IndependantBranches
---
circ/ysearch.pl | 11 ++++++++---
.../prog/en/includes/patron-search.inc | 2 ++
members/member.pl | 5 +++--
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/circ/ysearch.pl b/circ/ysearch.pl
index cdd2530..af57b90 100755
--- a/circ/ysearch.pl
+++ b/circ/ysearch.pl
@@ -43,9 +43,14 @@ if ($auth_status ne "ok") {
my $dbh = C4::Context->dbh;
my $sql = qq(SELECT surname, firstname, cardnumber, address, city, zipcode
FROM borrowers
- WHERE surname LIKE ?
- OR firstname LIKE ?
- ORDER BY surname, firstname);
+ WHERE ( surname LIKE ?
+ OR firstname LIKE ? ));
+if (C4::Context->preference("IndependantBranches")){
+ if (C4::Context->userenv && C4::Context->userenv->{'branch'}){
+ $sql .= qq( AND borrowers.branchcode =) . $dbh->quote(C4::Context->userenv->{'branch'}) unless (C4::Context->userenv->{'branch'} eq "insecure");
+ }
+}
+$sql .= qq( ORDER BY surname, firstname);
#"OR cardnumber LIKE '" . $query . "%' " .
my $sth = $dbh->prepare( $sql );
$sth->execute("$query%", "$query%");
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
index 9439e22..3b5f673 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
@@ -49,6 +49,8 @@ YAHOO.util.Event.onContentReady("header_search", function() {
<p class="tip">Enter patron card number or partial name:</p>
<form action="/cgi-bin/koha/members/member.pl" method="post">
<input id="searchmember" size="25" class="focus" name="member" type="text" />
+ search all branches:
+ <input type="checkbox" name="showallbranches"/>
order by:
<select name="orderby" id="searchorderby">
<option value="surname,firstname">Surname</option>
diff --git a/members/member.pl b/members/member.pl
index 5a71380..3360d8c 100755
--- a/members/member.pl
+++ b/members/member.pl
@@ -74,6 +74,7 @@ if (C4::Context->preference("AddPatronLists")=~/code/){
my $member=$input->param('member');
my $orderby=$input->param('orderby');
+my $all=$input->param('showallbranches');
$orderby = "surname,firstname" unless $orderby;
$member =~ s/,//g; #remove any commas from search string
$member =~ s/\*/%/g;
@@ -86,11 +87,11 @@ my ($count,$results);
if(length($member) == 1)
{
- ($count,$results)=SearchMember($member,$orderby,"simple");
+ ($count,$results)=SearchMember($member,$orderby,"simple",undef,undef,$all);
}
else
{
- ($count,$results)=SearchMember($member,$orderby,"advanced");
+ ($count,$results)=SearchMember($member,$orderby,"advanced",undef,undef,$all);
}
--
1.5.4.3
More information about the Koha-patches
mailing list