Bug 15407: Koha::Patron::Categories - replace C4::Category->all
[koha.git] / members / member.pl
1 #!/usr/bin/perl
2
3
4 #script to do a borrower enquiry/bring up borrower details etc
5 #written 20/12/99 by chris@katipo.co.nz
6
7
8 # Copyright 2000-2002 Katipo Communications
9 # Copyright 2013 BibLibre
10 #
11 # This file is part of Koha.
12 #
13 # Koha is free software; you can redistribute it and/or modify it
14 # under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 3 of the License, or
16 # (at your option) any later version.
17 #
18 # Koha is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with Koha; if not, see <http://www.gnu.org/licenses>.
25
26 use Modern::Perl;
27 use C4::Auth;
28 use C4::Output;
29 use CGI qw( -utf8 );
30 use C4::Branch;
31 use C4::Members qw( GetMember );
32 use Koha::DateUtils;
33 use Koha::List::Patron;
34
35 my $input = new CGI;
36
37 my ($template, $loggedinuser, $cookie)
38     = get_template_and_user({template_name => "members/member.tt",
39                  query => $input,
40                  type => "intranet",
41                  authnotrequired => 0,
42                  flagsrequired => {borrowers => 1},
43                  });
44
45 my $theme = $input->param('theme') || "default";
46
47 my $searchmember = $input->param('searchmember');
48 my $quicksearch = $input->param('quicksearch') // 0;
49
50 if ( $quicksearch and $searchmember ) {
51     my $branchcode;
52     if ( C4::Branch::onlymine ) {
53         my $userenv = C4::Context->userenv;
54         $branchcode = $userenv->{'branch'};
55     }
56     my $member = GetMember(
57         cardnumber => $searchmember,
58         ( $branchcode ? ( branchcode => $branchcode ) : () ),
59     );
60     if( $member ){
61         print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $member->{borrowernumber});
62         exit;
63     }
64 }
65
66 my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
67
68 if ( $searchfieldstype eq "dateofbirth" ) {
69     $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
70 }
71
72 $template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
73
74 my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
75
76 $template->param(
77     patron_lists => [ GetPatronLists() ],
78     searchmember        => $searchmember,
79     branchcode_filter   => scalar $input->param('branchcode_filter'),
80     categorycode_filter => scalar $input->param('categorycode_filter'),
81     searchtype          => scalar $input->param('searchtype') || 'contain',
82     searchfieldstype    => $searchfieldstype,
83     PatronsPerPage      => C4::Context->preference("PatronsPerPage") || 20,
84     view                => $view,
85 );
86
87 output_html_with_http_headers $input, $cookie, $template->output;