import of the authorized values fails on the step 3 of the web-installation (ru-RU)
[koha.git] / members / member.pl
1 #!/usr/bin/perl
2
3
4 #script to do a borrower enquiry/bring up borrower details etc
5 #written 20/12/99 by chris@katipo.co.nz
6
7
8 # Copyright 2000-2002 Katipo Communications
9 #
10 # This file is part of Koha.
11 #
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
15 # version.
16 #
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.
20 #
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
24
25 use strict;
26 use C4::Auth;
27 use C4::Output;
28 use CGI;
29 use C4::Members;
30
31
32 my $input = new CGI;
33 my $quicksearch = $input->param('quicksearch');
34 my $startfrom = $input->param('startfrom')||1;
35 my $resultsperpage = $input->param('resultsperpage')||C4::Context->preference("PatronsPerPage")||20;
36
37 my ($template, $loggedinuser, $cookie);
38 if($quicksearch){
39     ($template, $loggedinuser, $cookie)
40     = get_template_and_user({template_name => "members/member-quicksearch-results.tmpl",
41                  query => $input,
42                  type => "intranet",
43                  authnotrequired => 0,
44                  flagsrequired => {borrowers => 1},
45                  debug => 1,
46                  });
47 } else {
48     ($template, $loggedinuser, $cookie)
49     = get_template_and_user({template_name => "members/member.tmpl",
50                  query => $input,
51                  type => "intranet",
52                  authnotrequired => 0,
53                  flagsrequired => {borrowers => 1},
54                  debug => 1,
55                  });
56 }
57 my $theme = $input->param('theme') || "default";
58
59
60 $template->param( 
61         "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1",
62             );
63 if (C4::Context->preference("AddPatronLists")=~/code/){
64     my $categories=GetBorrowercategoryList;
65     $categories->[0]->{'first'}=1;
66     $template->param(categories=>$categories);  
67 }  
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 );
74
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
79 $member =~ s/\*/%/g;
80
81 my ($count,$results);
82
83 if(length($member) == 1)
84 {
85     ($count,$results)=SearchMember($member,$orderby,"simple");
86 }
87 else
88 {
89     ($count,$results)=SearchMember($member,$orderby,"advanced");
90 }
91
92
93 my @resultsdata;
94 my $toggle = 0;
95 my $to=($count>($startfrom*$resultsperpage)?$startfrom*$resultsperpage:$count);
96 for (my $i=($startfrom-1)*$resultsperpage; $i < $to; $i++){
97   #find out stats
98   my ($od,$issue,$fines)=GetMemberIssuesAndFines($results->[$i]{'borrowernumber'});
99
100   my %row = (
101     toggle => $toggle,
102     count => $i+1,
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'},
115     overdues => $od,
116     issues => $issue,
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'),
123     );
124   if ( $toggle ) { $toggle = 0; } else {$toggle = 1; }
125   push(@resultsdata, \%row);
126 }
127 my $base_url =
128     'member.pl?&amp;'
129   . join(
130     '&amp;',
131     map { $_->{term} . '=' . $_->{val} } (
132         { term => 'member', val => $member},
133         { term => 'orderby', val => $orderby },
134         { term => 'resultsperpage', val => $resultsperpage },
135         { term => 'type',           val => 'intranet' },
136     )
137   );
138
139 $template->param(
140     paginationbar => pagination_bar(
141         $base_url,  int( $count / $resultsperpage ) + 1,
142         $startfrom, 'startfrom'
143     ),
144     startfrom => $startfrom,
145     from      => ($startfrom-1)*$resultsperpage+1,  
146     to        => $to,
147     multipage => ($count != $to || $startfrom!=1),
148 );
149
150 $template->param( 
151         searching       => "1",
152         member          => $member,
153         numresults      => $count,
154         resultsloop     => \@resultsdata,
155             );
156
157 output_html_with_http_headers $input, $cookie, $template->output;