KRT-4338 -- create barcode and stocknumber when receiving items in acq
[koha.git] / patroncards / members-search.pl
index 8ab249b..0c680a0 100755 (executable)
@@ -20,7 +20,7 @@
 use strict;
 use warnings;
 
-use CGI;
+use CGI qw ( -utf8 );
 
 use C4::Auth;
 use C4::Output;
@@ -34,11 +34,12 @@ my $startfrom = $cgi->param('startfrom')||1;
 my $resultsperpage = $cgi->param('resultsperpage')||C4::Context->preference("PatronsPerPage")||20;
 my $category = $cgi->param('category') || undef;
 my $member = $cgi->param('member') || '';
-utf8::decode($member);
 my $orderby = $cgi->param('orderby') || undef;
+my $not_attributes = $cgi->param('not_attributes') || undef;
 
 my @categories=C4::Category->all;
 my %categories_display;
+my $no_categories;
 
 foreach my $category (@categories) {
     my $hash={
@@ -48,21 +49,32 @@ foreach my $category (@categories) {
     $categories_display{$$category{categorycode}} = $hash;
 }
 
+
 my ($template, $loggedinuser, $cookie) = get_template_and_user({
-                template_name => "patroncards/members-search.tmpl",
+                template_name => "patroncards/members-search.tt",
                 query => $cgi,
                 type => "intranet",
                 authnotrequired => 0,
                 flagsrequired => {borrowers => 1},
                 debug => 1,});
 
+if(scalar(@categories) < 1){ $no_categories = 1; }
+if($no_categories && C4::Context->preference("AddPatronLists")=~/code/){
+    $template->param(no_categories => 1);
+} else {
+    $template->param(
+        categories=>\@categories,
+        category => $category
+    );
+}
+
 $orderby = "surname,firstname" unless $orderby;
 $member =~ s/,//g;   #remove any commas from search string
 $member =~ s/\*/%/g;
 
 if ($member || $category) {
-    my $results = $category ? Search({''=>$member, categorycode=>$category}, $orderby)
-                            : Search($member, $orderby);
+    my $results = $category ? Search({''=>$member, categorycode=>$category}, $orderby, undef, undef, undef, undef, $not_attributes )
+                            : Search($member, $orderby, undef, undef, undef, undef, $not_attributes);
     my $count = $results ? @$results : 0;
 
     my @resultsdata = ();