Added select to patron search to choose between searching
for fields that either contain the string, or begin with
the string.
---
 .../prog/en/includes/patron-search.inc             |    4 ++++
 members/member.pl                                  |   14 ++++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

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 803184b..e7aa36b 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
@@ -48,6 +48,10 @@ YAHOO.util.Event.onContentReady("header_search", function() {
        <div id="patron_search" class="residentsearch">
        <p class="tip">Enter patron card number or partial name:</p>
        <form action="/cgi-bin/koha/members/member.pl" method="post">
+       <select name="search_scope">
+               <option value="field_start_with">Starts with</option>
+               <option value="contain">Contains</option>
+       </select>
     <input id="searchmember" size="25" class="focus" name="member" type="text" 
value="<!--TMPL_VAR Name="member"-->"/>
        <!--TMPL_IF Name="branchloop"-->
        <span class="filteraction" id="filteraction_off"> <a href="#" 
onclick="$('#filters').toggle();$('.filteraction').toggle();">[-]</a></span>
diff --git a/members/member.pl b/members/member.pl
index 58485b6..4d7a720 100755
--- a/members/member.pl
+++ b/members/member.pl
@@ -74,6 +74,10 @@ if (C4::Context->preference("AddPatronLists")=~/code/){
 
 my $member=$input->param('member');
 my $orderbyparams=$input->param('orderby');
+
+my $search_scope = $input->param('search_scope');
+$search_scope = 'contain' if ( $quicksearch );
+
 my @orderby;
 if ($orderbyparams){
        my @orderbyelt=split(/,/,$orderbyparams);
@@ -93,9 +97,8 @@ push @searchpatron, $member if ($member);
 push @searchpatron, $patron if (keys %$patron);
 my $from= ($startfrom-1)*$resultsperpage;
 my $to=$from+$resultsperpage;
- 
#($results)=Search(\...@searchpatron,{surname=>1,firstname=>1},[$from,$to],undef,["firstname","surname","email","othernames"]
  ) if (@searchpatron);
- my $search_scope=($quicksearch?"field_start_with":"contain");
- 
($results)=Search(\...@searchpatron,\...@orderby,undef,undef,["firstname","surname","email","othernames","cardnumber","userid"],$search_scope
  ) if (@searchpatron);
+ 
($results)=Search(\...@searchpatron,\...@orderby,undef,undef,[$field],$search_scope
  ) if (@searchpatron) && $field; 
+ 
($results)=Search(\...@searchpatron,\...@orderby,undef,undef,["firstname","surname","email","othernames","cardnumber","userid"],$search_scope
  ) if (@searchpatron) && !$field;
 if ($results){
        $count =scalar(@$results);
 }
@@ -134,7 +137,9 @@ my %parameters=
         (  %$patron
                , 'orderby'                     => $orderbyparams 
                , 'resultsperpage'      => $resultsperpage 
-        , 'type'=> 'intranet'); 
+        , 'type'=> 'intranet'
+        , 'search_scope' => $search_scope
+        ); 
 my $base_url =
     'member.pl?&amp;'
   . join(
@@ -167,6 +172,7 @@ $template->param(
                %$patron,
         numresults      => $count,
         resultsloop     => \...@resultsdata,
+        search_scope => $search_scope,
             );
 
 output_html_with_http_headers $input, $cookie, $template->output;
-- 
1.5.6.5

_______________________________________________
Koha-patches mailing list
Koha-patches@lists.koha.org
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to