Adding RIS And BibTex Export Followup
[koha.git] / members / guarantor_search.pl
blob4224da8e2d19a6dd62b69aad8753e5bf7a11868d
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 streetnumber => $results->[$i]{'streetnumber'},
83 address => $results->[$i]{'address'},
84 city => $results->[$i]{'city'},
85 zipcode => $results->[$i]{'zipcode'},
86 country => $results->[$i]{'country'},
87 branchcode => $results->[$i]{'branchcode'},
88 guarantorinfo =>$guarantorinfo,
89 #op
90 dateofbirth =>format_date($results->[$i]{'dateofbirth'}),
91 #fi op
93 odissue => "$od/$issue",
94 fines => $fines,
95 borrowernotes => $results->[$i]{'borrowernotes'});
96 if ( $background ) { $background = 0; } else {$background = 1; }
97 push(@resultsdata, \%row);
100 $template->param(
101 member => $member,
102 numresults => $count,
104 resultsloop => \@resultsdata );
106 output_html_with_http_headers $input, $cookie, $template->output;