3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
26 use C4::Auth; # checkauth, getborrowernumber.
29 use C4::Circulation::Circ2;
30 use C4::Interface::CGI::Output;
37 my ($template, $borrowernumber, $cookie)
38 = get_template_and_user({template_name => "opac-userupdate.tmpl",
42 flagsrequired => {borrow => 1},
46 # get borrower information ....
47 my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
50 # handle the new information....
51 # collect the form values and send an email.
52 my @fields = ('title', 'surname', 'firstname', 'phone', 'faxnumber', 'streetaddress', 'emailaddress', 'city');
54 my $updateemailaddress= C4::Context->preference('KohaAdminEmailAddress');
55 if ($updateemailaddress eq '') {
56 warn "KohaAdminEmailAddress system preference not set. Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
57 my($template) = get_template_and_user({template_name => "kohaerror.tmpl",
61 flagsrequired => {borrow => 1},
65 $template->param(errormessage => 'KohaAdminEmailAddress system preference
66 is not set. Please visit the library to update your user record');
68 output_html_with_http_headers $query, $cookie, $template->output;
72 if ($query->{'title'}) {
74 my $message = <<"EOF";
75 Borrower $borr->{'cardnumber'}
77 has requested to change her/his personal details.
78 Please check these new details and make the changes:
80 foreach my $field (@fields){
81 my $newfield = $query->param($field);
82 $message .= "$field : $borr->{$field} --> $newfield\n";
84 $message .= "\n\nThanks,\nKoha\n\n";
85 my %mail = ( To => $updateemailaddress ,
86 From => $updateemailaddress ,
87 Subject => "User Request for update of Record.",
88 Message => $message );
90 # do something if it works....
91 warn "Mail sent ok\n";
92 print $query->redirect('/cgi-bin/koha/opac-user.pl');
95 # do something if it doesnt work....
96 warn "Error sending mail: $Mail::Sendmail::error \n";
101 $borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'});
102 $borr->{'expiry'} = format_date($borr->{'expiry'});
103 $borr->{'dateofbirth'} = format_date($borr->{'dateofbirth'});
104 $borr->{'ethnicity'} = fixEthnicity($borr->{'ethnicity'});
110 $template->param(BORROWER_INFO => \@bordat,
113 output_html_with_http_headers $query, $cookie, $template->output;