4 #script to do a borrower enquiry/bring up borrower details etc
5 #written 20/12/99 by chris@katipo.co.nz
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
33 my $quicksearch = $input->param('quicksearch');
34 my $startfrom = $input->param('startfrom')||1;
35 my $resultsperpage = $input->param('resultsperpage')||C4::Context->preference("PatronsPerPage")||20;
37 my ($template, $loggedinuser, $cookie);
39 ($template, $loggedinuser, $cookie)
40 = get_template_and_user({template_name => "members/member-quicksearch-results.tmpl",
44 flagsrequired => {borrowers => 1},
48 ($template, $loggedinuser, $cookie)
49 = get_template_and_user({template_name => "members/member.tmpl",
53 flagsrequired => {borrowers => 1},
57 my $theme = $input->param('theme') || "default";
58 # only used if allowthemeoverride is set
59 #my %tmpldata = pathtotemplate ( template => 'member.tmpl', theme => $theme, language => 'fi' );
60 # FIXME - Error-checking
61 #my $template = HTML::Template->new( filename => $tmpldata{'path'},
62 # die_on_bad_params => 0,
63 # loop_context_vars => 1 );
66 my $member=$input->param('member');
67 my $orderby=$input->param('orderby');
68 $orderby = "surname,firstname" unless $orderby;
69 $member =~ s/,//g; #remove any commas from search string
74 if(length($member) == 1)
76 ($count,$results)=SearchMember($member,$orderby,"simple");
80 ($count,$results)=SearchMember($member,$orderby,"advanced");
86 my $to=($count>($startfrom*$resultsperpage)?$startfrom*$resultsperpage:$count);
87 for (my $i=($startfrom-1)*$resultsperpage; $i < $to; $i++){
89 my ($od,$issue,$fines)=GetMemberIssuesAndFines($results->[$i]{'borrowernumber'});
94 borrowernumber => $results->[$i]{'borrowernumber'},
95 cardnumber => $results->[$i]{'cardnumber'},
96 surname => $results->[$i]{'surname'},
97 firstname => $results->[$i]{'firstname'},
98 categorycode => $results->[$i]{'categorycode'},
99 category_type => $results->[$i]{'category_type'},
100 category_description => $results->[$i]{'description'},
101 address => $results->[$i]{'address'},
102 address2 => $results->[$i]{'address2'},
103 city => $results->[$i]{'city'},
104 zipcode => $results->[$i]{'zipcode'},
105 branchcode => $results->[$i]{'branchcode'},
108 odissue => "$od/$issue",
109 fines => sprintf("%.2f",$fines),
110 borrowernotes => $results->[$i]{'borrowernotes'},
111 sort1 => $results->[$i]{'sort1'},
112 sort2 => $results->[$i]{'sort2'},
113 dateexpiry => C4::Dates->new($results->[$i]{'dateexpiry'},'iso')->output('syspref'),
115 if ( $toggle ) { $toggle = 0; } else {$toggle = 1; }
116 push(@resultsdata, \%row);
122 map { $_->{term} . '=' . $_->{val} } (
123 { term => 'member', val => $member},
124 { term => 'orderby', val => $orderby },
125 { term => 'resultsperpage', val => $resultsperpage },
126 { term => 'type', val => 'intranet' },
131 paginationbar => pagination_bar(
132 $base_url, int( $count / $resultsperpage ) + 1,
133 $startfrom, 'startfrom'
135 startfrom => $startfrom,
136 from => ($startfrom-1)*$resultsperpage+1,
138 multipage => ($count != $to || $startfrom!=1),
144 numresults => $count,
145 resultsloop => \@resultsdata,
148 output_html_with_http_headers $input, $cookie, $template->output;