Changing CanBookBeRenewed to pass back the reason a renewal cannot proceed
[koha.git] / members / guarantor_search.pl
blobf1f1a5650ceb64ca33323d865e4337a0aeb2df54
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;
27 use C4::Dates qw/format_date/;
28 use C4::Members;
30 my $input = new CGI;
31 my ($template, $loggedinuser, $cookie);
33 ($template, $loggedinuser, $cookie)
34 = get_template_and_user({template_name => "members/guarantor_search.tmpl",
35 query => $input,
36 type => "intranet",
37 authnotrequired => 0,
38 flagsrequired => {borrowers => 1},
39 debug => 1,
40 });
41 # }
42 my $theme = $input->param('theme') || "default";
43 # only used if allowthemeoverride is set
46 my $member=$input->param('member');
47 my $orderby=$input->param('orderby');
48 $orderby = "surname,firstname" unless $orderby;
49 $member =~ s/,//g; #remove any commas from search string
50 $member =~ s/\*/%/g;
51 if ($member eq ''){
52 $template->param(results=>0);
53 }else{
54 $template->param(results=>1);
57 my ($count,$results);
58 my @resultsdata;
59 my $background = 0;
61 if ($member ne ''){
62 if(length($member) == 1)
64 ($count,$results)=SearchMember($member,$orderby,"simple",'A');
66 else
68 ($count,$results)=SearchMember($member,$orderby,"advanced",'A');
70 for (my $i=0; $i < $count; $i++){
71 #find out stats
72 my ($od,$issue,$fines)=GetMemberIssuesAndFines($results->[$i]{'borrowerid'});
73 my $guarantorinfo=uc($results->[$i]{'surname'})." , ".ucfirst($results->[$i]{'firstname'});
74 my %row = (
75 background => $background,
76 count => $i+1,
77 borrowernumber => $results->[$i]{'borrowernumber'},
78 cardnumber => $results->[$i]{'cardnumber'},
79 surname => $results->[$i]{'surname'},
80 firstname => $results->[$i]{'firstname'},
81 categorycode => $results->[$i]{'categorycode'},
82 address => $results->[$i]{'address'},
83 city => $results->[$i]{'city'},
84 branchcode => $results->[$i]{'branchcode'},
85 guarantorinfo =>$guarantorinfo,
86 #op
87 dateofbirth =>format_date($results->[$i]{'dateofbirth'}),
88 #fi op
90 odissue => "$od/$issue",
91 fines => $fines,
92 borrowernotes => $results->[$i]{'borrowernotes'});
93 if ( $background ) { $background = 0; } else {$background = 1; }
94 push(@resultsdata, \%row);
97 $template->param(
98 member => $member,
99 numresults => $count,
101 resultsloop => \@resultsdata );
103 output_html_with_http_headers $input, $cookie, $template->output;