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";
61 "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
63 if (C4::Context->preference("AddPatronLists")=~/code/){
64 my $categories=GetBorrowercategoryList;
65 $categories->[0]->{'first'}=1;
66 $template->param(categories=>$categories);
68 # only used if allowthemeoverride is set
69 #my %tmpldata = pathtotemplate ( template => 'member.tmpl', theme => $theme, language => 'fi' );
70 # FIXME - Error-checking
71 #my $template = HTML::Template->new( filename => $tmpldata{'path'},
72 # die_on_bad_params => 0,
73 # loop_context_vars => 1 );
75 my $member=$input->param('member');
76 my $orderby=$input->param('orderby');
77 $orderby = "surname,firstname" unless $orderby;
78 $member =~ s/,//g; #remove any commas from search string
83 if(length($member) == 1)
85 ($count,$results)=SearchMember($member,$orderby,"simple");
89 ($count,$results)=SearchMember($member,$orderby,"advanced");
94 my $to=($count>($startfrom*$resultsperpage)?$startfrom*$resultsperpage:$count);
95 for (my $i=($startfrom-1)*$resultsperpage; $i < $to; $i++){
97 my ($od,$issue,$fines)=GetMemberIssuesAndFines($results->[$i]{'borrowernumber'});
101 borrowernumber => $results->[$i]{'borrowernumber'},
102 cardnumber => $results->[$i]{'cardnumber'},
103 surname => $results->[$i]{'surname'},
104 firstname => $results->[$i]{'firstname'},
105 categorycode => $results->[$i]{'categorycode'},
106 category_type => $results->[$i]{'category_type'},
107 category_description => $results->[$i]{'description'},
108 address => $results->[$i]{'address'},
109 address2 => $results->[$i]{'address2'},
110 city => $results->[$i]{'city'},
111 zipcode => $results->[$i]{'zipcode'},
112 branchcode => $results->[$i]{'branchcode'},
115 odissue => "$od/$issue",
116 fines => sprintf("%.2f",$fines),
117 borrowernotes => $results->[$i]{'borrowernotes'},
118 sort1 => $results->[$i]{'sort1'},
119 sort2 => $results->[$i]{'sort2'},
120 dateexpiry => C4::Dates->new($results->[$i]{'dateexpiry'},'iso')->output('syspref'),
122 push(@resultsdata, \%row);
128 map { $_->{term} . '=' . $_->{val} } (
129 { term => 'member', val => $member},
130 { term => 'orderby', val => $orderby },
131 { term => 'resultsperpage', val => $resultsperpage },
132 { term => 'type', val => 'intranet' },
137 paginationbar => pagination_bar(
138 $base_url, int( $count / $resultsperpage ) + 1,
139 $startfrom, 'startfrom'
141 startfrom => $startfrom,
142 from => ($startfrom-1)*$resultsperpage+1,
144 multipage => ($count != $to || $startfrom!=1),
150 numresults => $count,
151 resultsloop => \@resultsdata,
154 output_html_with_http_headers $input, $cookie, $template->output;