Lines 1-6
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
|
|
|
4 |
# script to find a guarantor |
3 |
# script to find a guarantor |
5 |
|
4 |
|
6 |
# Copyright 2006 OUEST PROVENCE |
5 |
# Copyright 2006 OUEST PROVENCE |
Lines 20-107
Link Here
|
20 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
19 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
21 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
22 |
|
21 |
|
23 |
use strict; |
22 |
use Modern::Perl; |
24 |
#use warnings; FIXME - Bug 2505 |
23 |
|
|
|
24 |
use CGI; |
25 |
|
25 |
use C4::Auth; |
26 |
use C4::Auth; |
26 |
use C4::Output; |
27 |
use C4::Output; |
27 |
use CGI; |
|
|
28 |
use C4::Dates qw/format_date/; |
28 |
use C4::Dates qw/format_date/; |
29 |
use C4::Members; |
29 |
use C4::Members; |
30 |
|
30 |
|
31 |
my $input = new CGI; |
31 |
my $input = new CGI; |
32 |
my ($template, $loggedinuser, $cookie); |
32 |
my ( $template, $loggedinuser, $cookie ); |
33 |
|
33 |
|
34 |
($template, $loggedinuser, $cookie) |
34 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
35 |
= get_template_and_user({template_name => "members/guarantor_search.tmpl", |
35 |
{ |
36 |
query => $input, |
36 |
template_name => "members/guarantor_search.tmpl", |
37 |
type => "intranet", |
37 |
query => $input, |
38 |
authnotrequired => 0, |
38 |
type => "intranet", |
39 |
flagsrequired => {borrowers => 1}, |
39 |
authnotrequired => 0, |
40 |
debug => 1, |
40 |
flagsrequired => { borrowers => 1 }, |
41 |
}); |
41 |
debug => 1, |
42 |
# } |
42 |
} |
43 |
my $theme = $input->param('theme') || "default"; |
43 |
); |
44 |
# only used if allowthemeoverride is set |
44 |
|
45 |
|
45 |
my $member = $input->param('member'); |
46 |
|
46 |
my $orderby = $input->param('orderby'); |
47 |
my $member=$input->param('member'); |
47 |
my $category_type = $input->param('category_type'); |
48 |
my $orderby=$input->param('orderby'); |
48 |
|
49 |
my $category_type=$input->param('category_type'); |
|
|
50 |
$orderby = "surname,firstname" unless $orderby; |
49 |
$orderby = "surname,firstname" unless $orderby; |
51 |
$member =~ s/,//g; #remove any commas from search string |
50 |
$member =~ s/,//g; #remove any commas from search string |
52 |
$member =~ s/\*/%/g; |
51 |
$member =~ s/\*/%/g; |
53 |
if ($member eq ''){ |
52 |
|
54 |
$template->param(results=>0); |
53 |
$template->param( results => $member ); |
55 |
}else{ |
|
|
56 |
$template->param(results=>1); |
57 |
} |
58 |
|
54 |
|
59 |
my $search_category = 'A'; |
55 |
my $search_category = 'A'; |
60 |
if ($category_type eq 'P'){ |
56 |
if ( $category_type eq 'P' ) { |
61 |
$search_category = 'I'; |
57 |
$search_category = 'I'; |
62 |
} |
58 |
} |
63 |
|
59 |
|
64 |
my ($count,$results); |
60 |
my ( $count, $results ); |
65 |
my @resultsdata; |
61 |
my @resultsdata; |
66 |
my $background = 0; |
|
|
67 |
|
62 |
|
68 |
if ($member ne ''){ |
63 |
if ( $member ne '' ) { |
69 |
$results = Search({''=>$member, category_type=>$search_category},$orderby); |
64 |
$results = |
|
|
65 |
Search( { '' => $member, category_type => $search_category }, $orderby ); |
66 |
|
70 |
$count = $results ? @$results : 0; |
67 |
$count = $results ? @$results : 0; |
71 |
|
68 |
|
72 |
for (my $i=0; $i < $count; $i++){ |
69 |
for ( my $i = 0 ; $i < $count ; $i++ ) { |
73 |
#find out stats |
70 |
my %row = ( |
74 |
my $guarantorinfo=uc($results->[$i]{'surname'})." , ".ucfirst($results->[$i]{'firstname'}); |
71 |
count => $i + 1, |
75 |
my %row = ( |
72 |
borrowernumber => $results->[$i]{'borrowernumber'}, |
76 |
background => $background, |
73 |
cardnumber => $results->[$i]{'cardnumber'}, |
77 |
count => $i+1, |
74 |
surname => $results->[$i]{'surname'}, |
78 |
borrowernumber => $results->[$i]{'borrowernumber'}, |
75 |
firstname => $results->[$i]{'firstname'}, |
79 |
cardnumber => $results->[$i]{'cardnumber'}, |
76 |
categorycode => $results->[$i]{'categorycode'}, |
80 |
surname => $results->[$i]{'surname'}, |
77 |
streetnumber => $results->[$i]{'streetnumber'}, |
81 |
firstname => $results->[$i]{'firstname'}, |
78 |
address => $results->[$i]{'address'}, |
82 |
categorycode => $results->[$i]{'categorycode'}, |
79 |
address2 => $results->[$i]{'address2'}, |
83 |
streetnumber => $results->[$i]{'streetnumber'}, |
80 |
city => $results->[$i]{'city'}, |
84 |
address => $results->[$i]{'address'}, |
81 |
state => $results->[$i]{'state'}, |
85 |
address2 => $results->[$i]{'address2'}, |
82 |
zipcode => $results->[$i]{'zipcode'}, |
86 |
city => $results->[$i]{'city'}, |
83 |
country => $results->[$i]{'country'}, |
87 |
state => $results->[$i]{'state'}, |
84 |
branchcode => $results->[$i]{'branchcode'}, |
88 |
zipcode => $results->[$i]{'zipcode'}, |
85 |
dateofbirth => format_date( $results->[$i]{'dateofbirth'} ), |
89 |
country => $results->[$i]{'country'}, |
86 |
borrowernotes => $results->[$i]{'borrowernotes'} |
90 |
branchcode => $results->[$i]{'branchcode'}, |
87 |
); |
91 |
guarantorinfo =>$guarantorinfo, |
88 |
|
92 |
#op |
89 |
push( @resultsdata, \%row ); |
93 |
dateofbirth =>format_date($results->[$i]{'dateofbirth'}), |
90 |
} |
94 |
#fi op |
|
|
95 |
|
96 |
borrowernotes => $results->[$i]{'borrowernotes'}); |
97 |
if ( $background ) { $background = 0; } else {$background = 1; } |
98 |
push(@resultsdata, \%row); |
99 |
} |
100 |
} |
91 |
} |
101 |
$template->param( |
92 |
|
102 |
member => $member, |
93 |
$template->param( |
103 |
numresults => $count, |
94 |
member => $member, |
104 |
category_type => $category_type, |
95 |
numresults => $count, |
105 |
resultsloop => \@resultsdata ); |
96 |
category_type => $category_type, |
|
|
97 |
resultsloop => \@resultsdata |
98 |
); |
106 |
|
99 |
|
107 |
output_html_with_http_headers $input, $cookie, $template->output; |
100 |
output_html_with_http_headers $input, $cookie, $template->output; |
108 |
- |
|
|