Bug 29987: Add register support to manual credits
[koha-ffzg.git] / members / member.pl
index 2fc7fb4..54c3e81 100755 (executable)
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
-use C4::Auth;
-use C4::Output;
+use C4::Auth qw( get_template_and_user );
+use C4::Output qw( output_html_with_http_headers );
 use CGI qw( -utf8 );
-use Koha::DateUtils;
-use Koha::List::Patron;
+use Koha::List::Patron qw( GetPatronLists );
 use Koha::Patrons;
+use Koha::Patron::Attribute::Types;
 
-my $input = new CGI;
+my $input = CGI->new;
 
 my ($template, $loggedinuser, $cookie)
     = get_template_and_user({template_name => "members/member.tt",
                  query => $input,
                  type => "intranet",
-                 authnotrequired => 0,
                  flagsrequired => {borrowers => 'edit_borrowers'},
                  });
 
@@ -45,16 +44,22 @@ my $theme = $input->param('theme') || "default";
 
 my $searchmember = $input->param('searchmember');
 my $quicksearch = $input->param('quicksearch') // 0;
+my $circsearch = $input->param('circsearch') // 0;
 
-if ( $quicksearch and $searchmember ) {
+if ( $quicksearch and $searchmember && !$circsearch ) {
     my $branchcode;
     if ( C4::Context::only_my_library ) {
         my $userenv = C4::Context->userenv;
         $branchcode = $userenv->{'branch'};
     }
     my $patron = Koha::Patrons->find( { cardnumber => $searchmember } );
-    if( ( $branchcode and $patron and $patron->branchcode eq $branchcode ) or ( not $branchcode and $patron ) ){
-        print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $patron->borrowernumber);
+    if (
+        $patron
+        and (  ( $branchcode and $patron->branchcode eq $branchcode )
+            or ( not $branchcode ) )
+      )
+    {
+        print $input->redirect( "/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $patron->borrowernumber );
         exit;
     }
 }
@@ -63,7 +68,7 @@ my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
 
 $template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
 
-my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
+my $defer_loading = $input->request_method() eq "GET"  && !$circsearch ? 1 : 0;
 
 $template->param(
     patron_lists => [ GetPatronLists() ],
@@ -73,7 +78,11 @@ $template->param(
     searchtype          => scalar $input->param('searchtype') || 'contain',
     searchfieldstype    => $searchfieldstype,
     PatronsPerPage      => C4::Context->preference("PatronsPerPage") || 20,
-    view                => $view,
+    do_not_defer_loading => !$defer_loading,
+    circsearch          => $circsearch,
+    attribute_type_codes => ( C4::Context->preference('ExtendedPatronAttributes')
+        ? [ Koha::Patron::Attribute::Types->search( { staff_searchable => 1 } )->get_column('code') ]
+        : [] ),
 );
 
 output_html_with_http_headers $input, $cookie, $template->output;