lengthen cardnumber to 16 and make it unique
[koha.git] / member.pl
1 #!/usr/bin/perl
2
3 # $Id$
4
5 #script to do a borrower enquiery/brin up borrower details etc
6 #written 20/12/99 by chris@katipo.co.nz
7
8
9 # Copyright 2000-2002 Katipo Communications
10 #
11 # This file is part of Koha.
12 #
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.
17 #
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.
21 #
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA  02111-1307 USA
25
26 use strict;
27 use C4::Auth;
28 use C4::Output;
29 use C4::Interface::CGI::Output;
30 use CGI;
31 use C4::Search;
32 use HTML::Template;
33
34 my $input = new CGI;
35
36 my $theme = $input->param('theme') || "default";
37                         # only used if allowthemeoverride is set
38 #my %tmpldata = pathtotemplate ( template => 'member.tmpl', theme => $theme, language => 'fi' );
39         # FIXME - Error-checking
40 #my $template = HTML::Template->new( filename => $tmpldata{'path'},
41 #                                   die_on_bad_params => 0,
42 #                                   loop_context_vars => 1 );
43 my ($template, $loggedinuser, $cookie)
44     = get_template_and_user({template_name => "members/member.tmpl",
45                              query => $input,
46                              type => "intranet",
47                              authnotrequired => 0,
48                              flagsrequired => {borrowers => 1},
49                              debug => 1,
50                              });
51
52 my $member=$input->param('member');
53
54 my $env;
55
56 my ($count,$results);
57
58 if(length($member) == 1)
59 {
60         ($count,$results)=BornameSearch($env,$member,"simple");
61 }
62 else
63 {
64         ($count,$results)=BornameSearch($env,$member,"advanced");
65 }
66
67
68 my @resultsdata;
69 my $background = 0;
70 for (my $i=0; $i < $count; $i++){
71   #find out stats
72   my ($od,$issue,$fines)=borrdata2($env,$results->[$i]{'borrowernumber'});
73
74   my %row = (
75         background => $background,
76         borrowernumber => $results->[$i]{'borrowernumber'},
77         cardnumber => $results->[$i]{'cardnumber'},
78         surname => $results->[$i]{'surname'},
79         firstname => $results->[$i]{'firstname'},
80         categorycode => $results->[$i]{'categorycode'},
81         streetaddress => $results->[$i]{'streetaddress'},
82         city => $results->[$i]{'city'},
83         odissue => "$od/$issue",
84         fines => $fines,
85         borrowernotes => $results->[$i]{'borrowernotes'});
86   if ( $background ) { $background = 0; } else {$background = 1; }
87   push(@resultsdata, \%row);
88 }
89
90 $template->param( 
91                         member          => $member,
92                         resultsloop     => \@resultsdata );
93
94 output_html_with_http_headers $input, $cookie, $template->output;