Bug 13173 - remove some operations that are no longer needed
[koha.git] / members / member.pl
blobad3ee854add188e7a3fee8ae6397114380e420c8
1 #!/usr/bin/perl
4 #script to do a borrower enquiry/bring up borrower details etc
5 #written 20/12/99 by chris@katipo.co.nz
8 # Copyright 2000-2002 Katipo Communications
9 # Copyright 2013 BibLibre
11 # This file is part of Koha.
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
16 # version.
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along
23 # with Koha; if not, write to the Free Software Foundation, Inc.,
24 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 use Modern::Perl;
27 use C4::Auth;
28 use C4::Output;
29 use CGI;
30 use C4::Branch;
31 use C4::Category;
32 use C4::Members qw( GetMember );
33 use Koha::DateUtils;
34 use Koha::List::Patron;
36 my $input = new CGI;
38 my ($template, $loggedinuser, $cookie)
39 = get_template_and_user({template_name => "members/member.tt",
40 query => $input,
41 type => "intranet",
42 authnotrequired => 0,
43 flagsrequired => {borrowers => 1},
44 });
46 my $theme = $input->param('theme') || "default";
48 my $patron = $input->Vars;
49 foreach (keys %$patron){
50 delete $patron->{$_} unless($patron->{$_});
53 my $searchmember = $input->param('searchmember');
54 my $quicksearch = $input->param('quicksearch') // 0;
56 if ( $quicksearch and $searchmember ) {
57 my $branchcode;
58 if ( C4::Branch::onlymine ) {
59 my $userenv = C4::Context->userenv;
60 $branchcode = $userenv->{'branch'};
62 my $member = GetMember(
63 cardnumber => $searchmember,
64 ( $branchcode ? ( branchcode => $branchcode ) : () ),
66 if( $member ){
67 print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $member->{borrowernumber});
68 exit;
72 my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
74 if ( $searchfieldstype eq "dateofbirth" ) {
75 $searchmember = output_pref({dt => dt_from_string($searchmember), dateformat => 'iso', dateonly => 1});
78 my $branches = C4::Branch::GetBranches;
79 my @branches_loop;
80 if ( C4::Branch::onlymine ) {
81 my $userenv = C4::Context->userenv;
82 my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
83 push @branches_loop, {
84 value => $branch->{branchcode},
85 branchcode => $branch->{branchcode},
86 branchname => $branch->{branchname},
87 selected => 1
89 } else {
90 foreach ( sort { lc($branches->{$a}->{branchname}) cmp lc($branches->{$b}->{branchname}) } keys %$branches ) {
91 my $selected = 0;
92 $selected = 1 if($patron->{branchcode} and $patron->{branchcode} eq $_);
93 push @branches_loop, {
94 value => $_,
95 branchcode => $_,
96 branchname => $branches->{$_}->{branchname},
97 selected => $selected
102 my @categories = C4::Category->all;
103 if ( $patron->{categorycode} ) {
104 foreach my $category ( grep { $_->{categorycode} eq $patron->{categorycode} } @categories ) {
105 $category->{selected} = 1;
109 $template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
111 my $view = $input->request_method() eq "GET" ? "show_form" : "show_results";
113 $template->param(
114 patron_lists => [ GetPatronLists() ],
115 searchmember => $searchmember,
116 branchloop => \@branches_loop,
117 categories => \@categories,
118 branchcode => $patron->{branchcode},
119 categorycode => $patron->{categorycode},
120 searchtype => $input->param('searchtype') || 'start_with',
121 searchfieldstype => $searchfieldstype,
122 PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
123 view => $view,
126 output_html_with_http_headers $input, $cookie, $template->output;