|
Lines 1-100
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
|
2 |
|
| 3 |
# script to find a guarantor |
|
|
| 4 |
|
| 5 |
# Copyright 2006 OUEST PROVENCE |
| 6 |
# |
| 7 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
| 8 |
# |
4 |
# |
| 9 |
# Koha is free software; you can redistribute it and/or modify it under the |
5 |
# Copyright 2014 BibLibre |
| 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. |
| 13 |
# |
6 |
# |
| 14 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
7 |
# Koha is free software; you can redistribute it and/or modify it |
| 15 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
8 |
# under the terms of the GNU General Public License as published by |
| 16 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
9 |
# the Free Software Foundation; either version 3 of the License, or |
|
|
10 |
# (at your option) any later version. |
| 17 |
# |
11 |
# |
| 18 |
# You should have received a copy of the GNU General Public License along |
12 |
# Koha is distributed in the hope that it will be useful, but |
| 19 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 21 |
|
19 |
|
| 22 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 23 |
|
21 |
|
| 24 |
use CGI qw ( -utf8 ); |
22 |
use CGI qw ( -utf8 ); |
| 25 |
|
|
|
| 26 |
use C4::Auth; |
23 |
use C4::Auth; |
| 27 |
use C4::Output; |
24 |
use C4::Output; |
| 28 |
use C4::Dates qw/format_date/; |
|
|
| 29 |
use C4::Members; |
25 |
use C4::Members; |
| 30 |
|
26 |
|
| 31 |
my $input = new CGI; |
27 |
my $input = new CGI; |
| 32 |
my ( $template, $loggedinuser, $cookie ); |
|
|
| 33 |
|
28 |
|
| 34 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
29 |
my $dbh = C4::Context->dbh; |
| 35 |
{ |
30 |
|
| 36 |
template_name => "members/guarantor_search.tt", |
31 |
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user( |
|
|
32 |
{ template_name => "common/patron_search.tt", |
| 37 |
query => $input, |
33 |
query => $input, |
| 38 |
type => "intranet", |
34 |
type => "intranet", |
| 39 |
authnotrequired => 0, |
35 |
authnotrequired => 0, |
| 40 |
flagsrequired => { borrowers => 1 }, |
36 |
flagsrequired => { borrowers => 1 }, |
| 41 |
debug => 1, |
|
|
| 42 |
} |
37 |
} |
| 43 |
); |
38 |
); |
| 44 |
|
39 |
|
| 45 |
my $member = $input->param('member') // ''; |
40 |
my $q = $input->param('q') || ''; |
| 46 |
my $orderby = $input->param('orderby'); |
41 |
my $op = $input->param('op') || ''; |
| 47 |
my $category_type = $input->param('category_type'); |
|
|
| 48 |
|
| 49 |
$orderby = "surname,firstname" unless $orderby; |
| 50 |
$member =~ s/,//g; #remove any commas from search string |
| 51 |
$member =~ s/\*/%/g; |
| 52 |
|
| 53 |
$template->param( results => $member ); |
| 54 |
|
42 |
|
| 55 |
my $search_category = 'A'; |
43 |
my $referer = $input->referer(); |
| 56 |
if ( $category_type eq 'P' ) { |
|
|
| 57 |
$search_category = 'I'; |
| 58 |
} |
| 59 |
|
| 60 |
my ( $count, $results ); |
| 61 |
my @resultsdata; |
| 62 |
|
| 63 |
if ( $member ne '' ) { |
| 64 |
$results = |
| 65 |
Search( { '' => $member, category_type => $search_category }, $orderby ); |
| 66 |
|
| 67 |
$count = $results ? @$results : 0; |
| 68 |
|
| 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'} |
| 87 |
); |
| 88 |
|
| 89 |
push( @resultsdata, \%row ); |
| 90 |
} |
| 91 |
} |
| 92 |
|
44 |
|
| 93 |
$template->param( |
45 |
$template->param( |
| 94 |
member => $member, |
46 |
view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results", |
| 95 |
numresults => $count, |
47 |
columns => ['cardnumber', 'dateofbirth', 'address', 'action' ], |
| 96 |
category_type => $category_type, |
48 |
json_template => 'members/tables/guarantor_search.tt', |
| 97 |
resultsloop => \@resultsdata |
49 |
selection_type => 'select', |
| 98 |
); |
50 |
); |
| 99 |
|
51 |
output_html_with_http_headers( $input, $cookie, $template->output ); |
| 100 |
output_html_with_http_headers $input, $cookie, $template->output; |
|
|
| 101 |
- |
|
|