MT3346 : overdue_notices
[koha.git] / members / member.pl
index 2937706..700f200 100755 (executable)
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 use strict;
+#use warnings; FIXME - Bug 2505
 use C4::Auth;
 use C4::Output;
 use CGI;
@@ -37,24 +38,14 @@ my $quicksearch = $input->param('quicksearch');
 my $startfrom = $input->param('startfrom')||1;
 my $resultsperpage = $input->param('resultsperpage')||C4::Context->preference("PatronsPerPage")||20;
 
-my ($template, $loggedinuser, $cookie);
-if($quicksearch){
-    ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "members/member-quicksearch-results.tmpl",
-                 query => $input,
-                 type => "intranet",
-                 authnotrequired => 0,
-                 flagsrequired => {borrowers => 1},
-                 });
-} else {
-    ($template, $loggedinuser, $cookie)
+my ($template, $loggedinuser, $cookie)
     = get_template_and_user({template_name => "members/member.tmpl",
                  query => $input,
                  type => "intranet",
                  authnotrequired => 0,
                  flagsrequired => {borrowers => 1},
                  });
-}
+
 my $theme = $input->param('theme') || "default";
 
 my $patron = $input->Vars;
@@ -89,9 +80,9 @@ if ($orderbyparams){
        push @orderby, {$orderbyelt[0]=>$orderbyelt[1]||0};
 }
 else {
-       @orderby = ({surname=>1},{firstname=>1});
+       @orderby = ({firstname=>1},{surname=>1});
 }
-warn Data::Dumper::Dumper(@orderby);
+
 $member =~ s/,//g;   #remove any commas from search string
 $member =~ s/\*/%/g;
 
@@ -103,7 +94,8 @@ 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);
- ($results)=Search(\@searchpatron,\@orderby,undef,undef,["firstname","surname","email","othernames","cardnumber","userid"],"start_with"  ) 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);
 if ($results){
        $count =scalar(@$results);
 }
@@ -150,6 +142,9 @@ my $base_url =
     map { "$_=$parameters{$_}" } (keys %parameters)
   );
 
+my @letters = map { {letter => $_} } ( 'A' .. 'Z');
+$template->param( letters => \@letters );
+
 $template->param(
     paginationbar => pagination_bar(
         $base_url,  int( $count / $resultsperpage ) + 1,