itemtypes.pl - partial revisions, incl. replacement of invalid META Refresh calls
[koha.git] / opac / opac-userupdate.pl
blobdad7450f4a8afe7648fe372f2c46b32fc0aa7f81
1 #!/usr/bin/perl
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
10 # version.
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
20 use strict;
21 require Exporter;
22 use CGI;
23 use Mail::Sendmail;
25 use C4::Auth; # checkauth, getborrowernumber.
26 use C4::Context;
27 use C4::Koha;
28 use C4::Circulation;
29 use C4::Output;
30 use C4::Dates qw/format_date/;
31 use C4::Members;
33 my $query = new CGI;
35 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
37 template_name => "opac-userupdate.tmpl",
38 query => $query,
39 type => "opac",
40 authnotrequired => 0,
41 flagsrequired => { borrow => 1 },
42 debug => 1,
46 # get borrower information ....
47 my ( $borr, $flags ) = GetMemberDetails( $borrowernumber );
49 # handle the new information....
50 # collect the form values and send an email.
51 my @fields = (
52 'title', 'surname', 'firstname', 'phone',
53 'fax', 'streetaddress', 'emailaddress', 'city','phonepro',
55 my $update;
56 my $updateemailaddress = C4::Context->preference('KohaAdminEmailAddress');
57 if ( $updateemailaddress eq '' ) {
58 warn
59 "KohaAdminEmailAddress system preference not set. Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
60 my ($template) = get_template_and_user(
62 template_name => "kohaerror.tmpl",
63 query => $query,
64 type => "opac",
65 authnotrequired => 1,
66 flagsrequired => { borrow => 1 },
67 debug => 1,
71 $template->param(
72 errormessage => 'KohaAdminEmailAddress system preference
73 is not set. Please visit the library to update your user record'
76 output_html_with_http_headers $query, $cookie, $template->output;
77 exit;
80 if ( $query->{'modify'} ) {
82 # get all the fields:
83 my $message = <<"EOF";
84 Borrower $borr->{'cardnumber'}
86 has requested to change her/his personal details.
87 Please check these new details and make the changes:
88 EOF
89 foreach my $field (@fields) {
90 my $newfield = $query->param($field);
91 $message .= "$field : $borr->{$field} --> $newfield\n";
93 $message .= "\n\nThanks,\nKoha\n\n";
94 my %mail = (
95 To => $updateemailaddress,
96 From => $updateemailaddress,
97 Subject => "User Request for update of Record.",
98 Message => $message
101 if ( sendmail %mail ) {
103 # do something if it works....
104 warn "Mail sent ok\n";
105 print $query->redirect('/cgi-bin/koha/opac-user.pl?patronupdate=sent');
106 exit;
108 else {
110 # do something if it doesnt work....
111 warn "Error sending mail: $Mail::Sendmail::error \n";
115 $borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} );
116 $borr->{'expiry'} = format_date( $borr->{'expiry'} );
117 $borr->{'dateofbirth'} = format_date( $borr->{'dateofbirth'} );
118 $borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} );
120 my @bordat;
121 $bordat[0] = $borr;
123 $template->param(
124 BORROWER_INFO => \@bordat
127 output_html_with_http_headers $query, $cookie, $template->output;