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");
95 my $to=($count>($startfrom*$resultsperpage)?
$startfrom*$resultsperpage:$count);
96 for (my $i=($startfrom-1)*$resultsperpage; $i < $to; $i++){
98 my ($od,$issue,$fines)=GetMemberIssuesAndFines
($results->[$i]{'borrowernumber'});
103 borrowernumber
=> $results->[$i]{'borrowernumber'},
104 cardnumber
=> $results->[$i]{'cardnumber'},
105 surname
=> $results->[$i]{'surname'},
106 firstname
=> $results->[$i]{'firstname'},
107 categorycode
=> $results->[$i]{'categorycode'},
108 category_type
=> $results->[$i]{'category_type'},
109 category_description
=> $results->[$i]{'description'},
110 address
=> $results->[$i]{'address'},
111 address2
=> $results->[$i]{'address2'},
112 city
=> $results->[$i]{'city'},
113 zipcode
=> $results->[$i]{'zipcode'},
114 branchcode
=> $results->[$i]{'branchcode'},
117 odissue
=> "$od/$issue",
118 fines
=> sprintf("%.2f",$fines),
119 borrowernotes
=> $results->[$i]{'borrowernotes'},
120 sort1
=> $results->[$i]{'sort1'},
121 sort2
=> $results->[$i]{'sort2'},
122 dateexpiry
=> C4
::Dates
->new($results->[$i]{'dateexpiry'},'iso')->output('syspref'),
124 if ( $toggle ) { $toggle = 0; } else {$toggle = 1; }
125 push(@resultsdata, \
%row);
131 map { $_->{term
} . '=' . $_->{val
} } (
132 { term
=> 'member', val
=> $member},
133 { term
=> 'orderby', val
=> $orderby },
134 { term
=> 'resultsperpage', val
=> $resultsperpage },
135 { term
=> 'type', val
=> 'intranet' },
140 paginationbar
=> pagination_bar
(
141 $base_url, int( $count / $resultsperpage ) + 1,
142 $startfrom, 'startfrom'
144 startfrom
=> $startfrom,
145 from
=> ($startfrom-1)*$resultsperpage+1,
147 multipage
=> ($count != $to || $startfrom!=1),
153 numresults
=> $count,
154 resultsloop
=> \
@resultsdata,
157 output_html_with_http_headers
$input, $cookie, $template->output;