3 # script to find a guarantor
5 # Copyright 2006 OUEST PROVENCE
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License as published by the Free Software
11 # Foundation; either version 2 of the License, or (at your option) any later
14 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with Koha; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 use C4
::Dates qw
/format_date/;
32 my ( $template, $loggedinuser, $cookie );
34 ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
36 template_name
=> "members/guarantor_search.tt",
40 flagsrequired
=> { borrowers
=> 1 },
45 my $member = $input->param('member') // '';
46 my $orderby = $input->param('orderby');
47 my $category_type = $input->param('category_type');
49 $orderby = "surname,firstname" unless $orderby;
50 $member =~ s/,//g; #remove any commas from search string
53 $template->param( results
=> $member );
55 my $search_category = 'A';
56 if ( $category_type eq 'P' ) {
57 $search_category = 'I';
60 my ( $count, $results );
63 if ( $member ne '' ) {
65 Search
( { '' => $member, category_type
=> $search_category }, $orderby );
67 $count = $results ? @
$results : 0;
69 for ( my $i = 0 ; $i < $count ; $i++ ) {
72 borrowernumber
=> $results->[$i]{'borrowernumber'},
73 cardnumber
=> $results->[$i]{'cardnumber'},
74 surname
=> $results->[$i]{'surname'},
75 firstname
=> $results->[$i]{'firstname'},
76 categorycode
=> $results->[$i]{'categorycode'},
77 streetnumber
=> $results->[$i]{'streetnumber'},
78 address
=> $results->[$i]{'address'},
79 address2
=> $results->[$i]{'address2'},
80 city
=> $results->[$i]{'city'},
81 state => $results->[$i]{'state'},
82 zipcode
=> $results->[$i]{'zipcode'},
83 country
=> $results->[$i]{'country'},
84 branchcode
=> $results->[$i]{'branchcode'},
85 dateofbirth
=> format_date
( $results->[$i]{'dateofbirth'} ),
86 borrowernotes
=> $results->[$i]{'borrowernotes'}
89 push( @resultsdata, \
%row );
96 category_type
=> $category_type,
97 resultsloop
=> \
@resultsdata
100 output_html_with_http_headers
$input, $cookie, $template->output;