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
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
20 # with Koha; if not, write to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #use warnings; FIXME - Bug 2505
28 use C4
::Dates qw
/format_date/;
32 my ($template, $loggedinuser, $cookie);
34 ($template, $loggedinuser, $cookie)
35 = get_template_and_user
({template_name
=> "members/guarantor_search.tmpl",
39 flagsrequired
=> {borrowers
=> 1},
43 my $theme = $input->param('theme') || "default";
44 # only used if allowthemeoverride is set
47 my $member=$input->param('member');
48 my $orderby=$input->param('orderby');
49 my $category_type=$input->param('category_type');
50 $orderby = "surname,firstname" unless $orderby;
51 $member =~ s/,//g; #remove any commas from search string
54 $template->param(results
=>0);
56 $template->param(results
=>1);
59 my $search_category = 'A';
60 if ($category_type eq 'P'){
61 $search_category = 'I';
69 $results = Search
({''=>$member, category_type
=>$search_category},$orderby);
70 $count = $results ? @
$results : 0;
72 for (my $i=0; $i < $count; $i++){
74 my ($od,$issue,$fines)=GetMemberIssuesAndFines
($results->[$i]{'borrowerid'});
75 my $guarantorinfo=uc($results->[$i]{'surname'})." , ".ucfirst($results->[$i]{'firstname'});
77 background
=> $background,
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 streetnumber
=> $results->[$i]{'streetnumber'},
85 address
=> $results->[$i]{'address'},
86 address2
=> $results->[$i]{'address2'},
87 city
=> $results->[$i]{'city'},
88 state => $results->[$i]{'state'},
89 zipcode
=> $results->[$i]{'zipcode'},
90 country
=> $results->[$i]{'country'},
91 branchcode
=> $results->[$i]{'branchcode'},
92 guarantorinfo
=>$guarantorinfo,
94 dateofbirth
=>format_date
($results->[$i]{'dateofbirth'}),
97 odissue
=> "$od/$issue",
99 borrowernotes
=> $results->[$i]{'borrowernotes'});
100 if ( $background ) { $background = 0; } else {$background = 1; }
101 push(@resultsdata, \
%row);
106 numresults
=> $count,
107 category_type
=> $category_type,
108 resultsloop
=> \
@resultsdata );
110 output_html_with_http_headers
$input, $cookie, $template->output;