Bug 3186 - invalid or uninstalled SMSSendDriver (or bad number format) causes process...
[koha.git] / members / guarantor_search.pl
blobe5b39df7a8cdec00741ae93df7e03b53098d106c
1 #!/usr/bin/perl
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
12 # version.
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.
22 use Modern::Perl;
24 use CGI;
26 use C4::Auth;
27 use C4::Output;
28 use C4::Dates qw/format_date/;
29 use C4::Members;
31 my $input = new CGI;
32 my ( $template, $loggedinuser, $cookie );
34 ( $template, $loggedinuser, $cookie ) = get_template_and_user(
36 template_name => "members/guarantor_search.tt",
37 query => $input,
38 type => "intranet",
39 authnotrequired => 0,
40 flagsrequired => { borrowers => 1 },
41 debug => 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
51 $member =~ s/\*/%/g;
53 $template->param( results => $member );
55 my $search_category = 'A';
56 if ( $category_type eq 'P' ) {
57 $search_category = 'I';
60 my ( $count, $results );
61 my @resultsdata;
63 if ( $member ne '' ) {
64 $results =
65 Search( { '' => $member, category_type => $search_category }, $orderby );
67 $count = $results ? @$results : 0;
69 for ( my $i = 0 ; $i < $count ; $i++ ) {
70 my %row = (
71 count => $i + 1,
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 );
93 $template->param(
94 member => $member,
95 numresults => $count,
96 category_type => $category_type,
97 resultsloop => \@resultsdata
100 output_html_with_http_headers $input, $cookie, $template->output;