Patch from Joe Atzberger to remove $Id$ and $Log$ from scripts
[koha.git] / members / member.pl
1 #!/usr/bin/perl
2
3
4 #script to do a borrower enquiery/brin up borrower details etc
5 #written 20/12/99 by chris@katipo.co.nz
6
7
8 # Copyright 2000-2002 Katipo Communications
9 #
10 # This file is part of Koha.
11 #
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
16 #
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA  02111-1307 USA
24
25 use strict;
26 use C4::Auth;
27 use C4::Output;
28 use CGI;
29 use C4::Members;
30
31
32 my $input = new CGI;
33 my $quicksearch = $input->param('quicksearch');
34 my ($template, $loggedinuser, $cookie);
35 if($quicksearch){
36     ($template, $loggedinuser, $cookie)
37     = get_template_and_user({template_name => "members/member-quicksearch-results.tmpl",
38                  query => $input,
39                  type => "intranet",
40                  authnotrequired => 0,
41                  flagsrequired => {borrowers => 1},
42                  debug => 1,
43                  });
44 } else {
45     ($template, $loggedinuser, $cookie)
46     = get_template_and_user({template_name => "members/member.tmpl",
47                  query => $input,
48                  type => "intranet",
49                  authnotrequired => 0,
50                  flagsrequired => {borrowers => 1},
51                  debug => 1,
52                  });
53 }
54 my $theme = $input->param('theme') || "default";
55             # only used if allowthemeoverride is set
56 #my %tmpldata = pathtotemplate ( template => 'member.tmpl', theme => $theme, language => 'fi' );
57     # FIXME - Error-checking
58 #my $template = HTML::Template->new( filename => $tmpldata{'path'},
59 #                   die_on_bad_params => 0,
60 #                   loop_context_vars => 1 );
61
62
63 my $member=$input->param('member');
64 my $orderby=$input->param('orderby');
65 $orderby = "surname,firstname" unless $orderby;
66 $member =~ s/,//g;   #remove any commas from search string
67 $member =~ s/\*/%/g;
68
69 my ($count,$results);
70
71 if(length($member) == 1)
72 {
73     ($count,$results)=SearchMember($member,$orderby,"simple");
74 }
75 else
76 {
77     ($count,$results)=SearchMember($member,$orderby,"advanced");
78 }
79
80
81 my @resultsdata;
82 my $background = 0;
83 for (my $i=0; $i < $count; $i++){
84   #find out stats
85   my ($od,$issue,$fines)=GetMemberIssuesAndFines($results->[$i]{'borrowernumber'});
86
87   my %row = (
88     background => $background,
89     count => $i+1,
90     borrowernumber => $results->[$i]{'borrowernumber'},
91     cardnumber => $results->[$i]{'cardnumber'},
92     surname => $results->[$i]{'surname'},
93     firstname => $results->[$i]{'firstname'},
94     categorycode => $results->[$i]{'categorycode'},
95     category_type => $results->[$i]{'category_type'},
96     category_description => $results->[$i]{'description'},
97     streetaddress => $results->[$i]{'streetaddress'},
98     city => $results->[$i]{'city'},
99     branchcode => $results->[$i]{'branchcode'},
100     overdues => $od,
101     issues => $issue,
102     odissue => "$od/$issue",
103     fines =>  sprintf("%.2f",$fines),
104     borrowernotes => $results->[$i]{'borrowernotes'},
105     sort1 => $results->[$i]{'sort1'},
106     sort2 => $results->[$i]{'sort2'},
107     );
108   if ( $background ) { $background = 0; } else {$background = 1; }
109   push(@resultsdata, \%row);
110 }
111
112 $template->param( 
113         searching       => "1",
114         member          => $member,
115         numresults      => $count,
116         resultsloop     => \@resultsdata,
117         intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
118         intranetstylesheet => C4::Context->preference("intranetstylesheet"),
119         IntranetNav => C4::Context->preference("IntranetNav"),
120             );
121
122 output_html_with_http_headers $input, $cookie, $template->output;