MARCSUBJECT template loops structure was incorrect, now displays subjects, with corre...
[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 #
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 $toggle = 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     toggle => $toggle,
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     address => $results->[$i]{'address'},
98         address2 => $results->[$i]{'address2'},
99     city => $results->[$i]{'city'},
100         zipcode => $results->[$i]{'zipcode'},
101     branchcode => $results->[$i]{'branchcode'},
102     overdues => $od,
103     issues => $issue,
104     odissue => "$od/$issue",
105     fines =>  sprintf("%.2f",$fines),
106     borrowernotes => $results->[$i]{'borrowernotes'},
107     sort1 => $results->[$i]{'sort1'},
108     sort2 => $results->[$i]{'sort2'},
109     );
110   if ( $toggle ) { $toggle = 0; } else {$toggle = 1; }
111   push(@resultsdata, \%row);
112 }
113
114 $template->param( 
115         searching       => "1",
116         member          => $member,
117         numresults      => $count,
118         resultsloop     => \@resultsdata,
119             );
120
121 output_html_with_http_headers $input, $cookie, $template->output;