bug-1494, fixed bookfund modify code
[koha.git] / members / guarantor_search.pl
blob8059b72c9dac3f67dba5cc70a28dfa83f5a4b7e1
1 #!/usr/bin/perl
4 # script to find a guarantor
6 # Copyright 2006 OUEST PROVENCE
8 # This file is part of Koha.
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.
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.
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
23 use strict;
24 use C4::Auth;
25 use C4::Output;
26 use CGI;
28 #op
29 use C4::Date;
30 use C4::Members;
32 my $input = new CGI;
33 my ($template, $loggedinuser, $cookie);
35 ($template, $loggedinuser, $cookie)
36 = get_template_and_user({template_name => "members/guarantor_search.tmpl",
37 query => $input,
38 type => "intranet",
39 authnotrequired => 0,
40 flagsrequired => {borrowers => 1},
41 debug => 1,
42 });
43 # }
44 my $theme = $input->param('theme') || "default";
45 # only used if allowthemeoverride is set
48 my $member=$input->param('member');
49 my $orderby=$input->param('orderby');
50 $orderby = "surname,firstname" unless $orderby;
51 $member =~ s/,//g; #remove any commas from search string
52 $member =~ s/\*/%/g;
53 if ($member eq ''){
54 $template->param(results=>0);
55 }else{
56 $template->param(results=>1);
59 my ($count,$results);
60 my @resultsdata;
61 my $background = 0;
63 if ($member ne ''){
64 if(length($member) == 1)
66 ($count,$results)=SearchMember($member,$orderby,"simple",'A');
68 else
70 ($count,$results)=SearchMember($member,$orderby,"advanced",'A');
72 for (my $i=0; $i < $count; $i++){
73 #find out stats
74 my ($od,$issue,$fines)=GetMemberIssuesAndFines($results->[$i]{'borrowerid'});
75 my $guarantorinfo=uc($results->[$i]{'surname'})." , ".ucfirst($results->[$i]{'firstname'});
76 my %row = (
77 background => $background,
78 count => $i+1,
79 borrowernumber => $results->[$i]{'borrowernumber'},
80 cardnumber => $results->[$i]{'cardnumber'},
81 surname => $results->[$i]{'surname'},
82 firstname => $results->[$i]{'firstname'},
83 categorycode => $results->[$i]{'categorycode'},
84 address => $results->[$i]{'address'},
85 city => $results->[$i]{'city'},
86 branchcode => $results->[$i]{'branchcode'},
87 guarantorinfo =>$guarantorinfo,
88 #op
89 dateofbirth =>format_date($results->[$i]{'dateofbirth'}),
90 #fi op
92 odissue => "$od/$issue",
93 fines => $fines,
94 borrowernotes => $results->[$i]{'borrowernotes'});
95 if ( $background ) { $background = 0; } else {$background = 1; }
96 push(@resultsdata, \%row);
99 $template->param(
100 member => $member,
101 numresults => $count,
103 resultsloop => \@resultsdata );
105 output_html_with_http_headers $input, $cookie, $template->output;