Bug 2505 - Add commented use warnings where missing in the members/ directory
[wip/koha-chris_n.git] / members / guarantor_search.pl
1 #!/usr/bin/perl
2
3
4 # script to find a guarantor
5
6 # Copyright 2006 OUEST PROVENCE
7 #
8 # This file is part of Koha.
9 #
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
13 # version.
14 #
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
23 use strict;
24 #use warnings; FIXME - Bug 2505
25 use C4::Auth;
26 use C4::Output;
27 use CGI;
28 use C4::Dates qw/format_date/;
29 use C4::Members;
30
31 my $input = new CGI;
32 my ($template, $loggedinuser, $cookie);
33
34         ($template, $loggedinuser, $cookie)
35     = get_template_and_user({template_name => "members/guarantor_search.tmpl",
36                              query => $input,
37                              type => "intranet",
38                              authnotrequired => 0,
39                              flagsrequired => {borrowers => 1},
40                              debug => 1,
41                              });
42 # }
43 my $theme = $input->param('theme') || "default";
44                         # only used if allowthemeoverride is set
45
46
47 my $member=$input->param('member');
48 my $orderby=$input->param('orderby');
49 $orderby = "surname,firstname" unless $orderby;
50 $member =~ s/,//g;   #remove any commas from search string
51 $member =~ s/\*/%/g;
52 if ($member eq ''){
53                 $template->param(results=>0);
54 }else{
55                 $template->param(results=>1);
56 }       
57
58 my ($count,$results);
59 my @resultsdata;
60 my $background = 0;
61
62 if ($member ne ''){
63         if(length($member) == 1)
64         {
65                 ($count,$results)=SearchMember($member,$orderby,"simple",'A');
66         }
67         else
68         {
69                 ($count,$results)=SearchMember($member,$orderby,"advanced",'A');
70         }
71         for (my $i=0; $i < $count; $i++){
72         #find out stats
73         my ($od,$issue,$fines)=GetMemberIssuesAndFines($results->[$i]{'borrowerid'});
74         my $guarantorinfo=uc($results->[$i]{'surname'})." , ".ucfirst($results->[$i]{'firstname'});
75         my %row = (
76                 background => $background,
77                 count => $i+1,
78                 borrowernumber => $results->[$i]{'borrowernumber'},
79                 cardnumber => $results->[$i]{'cardnumber'},
80                 surname => $results->[$i]{'surname'},
81                 firstname => $results->[$i]{'firstname'},
82                 categorycode => $results->[$i]{'categorycode'},
83                 streetnumber => $results->[$i]{'streetnumber'},
84                 address => $results->[$i]{'address'},
85                 city => $results->[$i]{'city'},
86                 zipcode => $results->[$i]{'zipcode'},
87                 country => $results->[$i]{'country'},
88                 branchcode => $results->[$i]{'branchcode'},
89                 guarantorinfo =>$guarantorinfo,
90                 #op
91                 dateofbirth =>format_date($results->[$i]{'dateofbirth'}),
92                 #fi op  
93                 
94                 odissue => "$od/$issue",
95                 fines => $fines,
96                 borrowernotes => $results->[$i]{'borrowernotes'});
97         if ( $background ) { $background = 0; } else {$background = 1; }
98         push(@resultsdata, \%row);
99                 }
100 }
101 $template->param( 
102                         member          => $member,
103                         numresults              => $count,
104                         
105                         resultsloop     => \@resultsdata );
106
107 output_html_with_http_headers $input, $cookie, $template->output;