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
34 my $quicksearch = $input->param('quicksearch');
35 my $startfrom = $input->param('startfrom')||1;
36 my $resultsperpage = $input->param('resultsperpage')||C4
::Context
->preference("PatronsPerPage")||20;
38 my ($template, $loggedinuser, $cookie);
40 ($template, $loggedinuser, $cookie)
41 = get_template_and_user
({template_name
=> "members/member-quicksearch-results.tmpl",
45 flagsrequired
=> {borrowers
=> 1},
49 ($template, $loggedinuser, $cookie)
50 = get_template_and_user
({template_name
=> "members/member.tmpl",
54 flagsrequired
=> {borrowers
=> 1},
58 my $theme = $input->param('theme') || "default";
62 "AddPatronLists_".C4
::Context
->preference("AddPatronLists")=> "1",
64 if (C4
::Context
->preference("AddPatronLists")=~/code/){
65 my $categories=GetBorrowercategoryList
;
66 $categories->[0]->{'first'}=1;
67 $template->param(categories
=>$categories);
69 # only used if allowthemeoverride is set
70 #my %tmpldata = pathtotemplate ( template => 'member.tmpl', theme => $theme, language => 'fi' );
71 # FIXME - Error-checking
72 #my $template = HTML::Template->new( filename => $tmpldata{'path'},
73 # die_on_bad_params => 0,
74 # loop_context_vars => 1 );
76 my $member=$input->param('member');
77 my $orderby=$input->param('orderby');
78 $orderby = "surname,firstname" unless $orderby;
79 $member =~ s/,//g; #remove any commas from search string
84 my $patron = $input->Vars;
85 foreach (keys %$patron){
86 delete $$patron{$_} unless($$patron{$_});
88 ($results)=Search
($patron,{surname
=>1,firstname
=>1}) if (keys %$patron);
89 $count =scalar(@
$results);
93 if(length($member) == 1)
95 ($count,$results)=SearchMember
($member,$orderby,"simple");
99 ($count,$results)=SearchMember
($member,$orderby,"advanced");
104 my $to=($count>($startfrom*$resultsperpage)?
$startfrom*$resultsperpage:$count);
105 for (my $i=($startfrom-1)*$resultsperpage; $i < $to; $i++){
107 my ($od,$issue,$fines)=GetMemberIssuesAndFines
($results->[$i]{'borrowernumber'});
109 $$results[$i]{'dateexpiry'}= C4
::Dates
->new($results->[$i]{'dateexpiry'},'iso')->output('syspref');
116 odissue
=> "$od/$issue",
117 fines
=> sprintf("%.2f",$fines),
119 push(@resultsdata, \
%row);
125 map { $_->{term
} . '=' . $_->{val
} } (
126 { term
=> 'member', val
=> $member},
127 { term
=> 'orderby', val
=> $orderby },
128 { term
=> 'resultsperpage', val
=> $resultsperpage },
129 { term
=> 'type', val
=> 'intranet' },
133 my @categories=C4
::Category
->all;
135 paginationbar
=> pagination_bar
(
136 $base_url, int( $count / $resultsperpage ) + 1,
137 $startfrom, 'startfrom'
139 startfrom
=> $startfrom,
140 from
=> ($startfrom-1)*$resultsperpage+1,
142 multipage
=> ($count != $to || $startfrom!=1),
143 branchloop
=>GetBranchesLoop
(),
144 categoryloop
=>\
@categories,
150 numresults
=> $count,
151 resultsloop
=> \
@resultsdata,
154 output_html_with_http_headers
$input, $cookie, $template->output;