3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 my $batch_id = $cgi->param('batch_id') || 0;
33 my $startfrom = $cgi->param('startfrom')||1;
34 my $resultsperpage = $cgi->param('resultsperpage')||C4::Context->preference("PatronsPerPage")||20;
35 my $category = $cgi->param('category') || undef;
36 my $member = $cgi->param('member') || '';
37 utf8::decode($member);
38 my $orderby = $cgi->param('orderby') || undef;
40 my @categories=C4::Category->all;
41 my %categories_display;
43 foreach my $category (@categories) {
45 category_description=>$$category{description},
46 category_type=>$$category{category_type}
48 $categories_display{$$category{categorycode}} = $hash;
51 my ($template, $loggedinuser, $cookie) = get_template_and_user({
52 template_name => "patroncards/members-search.tmpl",
56 flagsrequired => {borrowers => 1},
59 $orderby = "surname,firstname" unless $orderby;
60 $member =~ s/,//g; #remove any commas from search string
63 if ($member || $category) {
64 my $results = $category ? Search({''=>$member, categorycode=>$category}, $orderby)
65 : Search($member, $orderby);
66 my $count = $results ? @$results : 0;
69 my $to = ($count>($startfrom * $resultsperpage)?$startfrom * $resultsperpage:$count);
70 for (my $i = ($startfrom-1) * $resultsperpage; $i < $to; $i++){
72 my ($od,$issue,$fines) = GetMemberIssuesAndFines($results->[$i]{'borrowernumber'});
75 %{$categories_display{$results->[$i]{categorycode}}},
76 borrowernumber => $results->[$i]{'borrowernumber'},
77 cardnumber => $results->[$i]{'cardnumber'},
78 surname => $results->[$i]{'surname'},
79 firstname => $results->[$i]{'firstname'},
80 categorycode => $results->[$i]{'categorycode'},
81 address => $results->[$i]{'address'},
82 address2 => $results->[$i]{'address2'},
83 city => $results->[$i]{'city'},
84 zipcode => $results->[$i]{'zipcode'},
85 country => $results->[$i]{'country'},
86 branchcode => $results->[$i]{'branchcode'},
89 odissue => "$od/$issue",
90 fines => ($fines ? sprintf("%.2f",$fines) : ''),
91 borrowernotes => $results->[$i]{'borrowernotes'},
92 sort1 => $results->[$i]{'sort1'},
93 sort2 => $results->[$i]{'sort2'},
94 dateexpiry => C4::Dates->new($results->[$i]{'dateexpiry'},'iso')->output('syspref'),
96 push(@resultsdata, \%row);
98 my $base_url = '?' . join('&', map { $_->{term} . '=' . $_->{val} } (
99 { term => 'member', val => $member },
100 { term => 'category', val => $category },
101 { term => 'orderby', val => $orderby },
102 { term => 'resultsperpage', val => $resultsperpage },
103 { term => 'batch_id', val => $batch_id },)
106 paginationbar => pagination_bar(
107 $base_url, int( $count / $resultsperpage ) + 1,
108 $startfrom, 'startfrom'
110 startfrom => $startfrom,
111 from => ($startfrom-1) * $resultsperpage + 1,
113 multipage => ($count != $to || $startfrom != 1),
116 category_type => $category,
117 numresults => $count,
118 resultsloop => \@resultsdata,
119 batch_id => $batch_id,
123 $template->param( batch_id => $batch_id);
126 $template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
128 output_html_with_http_headers $cgi, $cookie, $template->output;
132 #script to do a borrower enquiry/bring up borrower details etc
133 #written 20/12/99 by chris@katipo.co.nz