7 use C4::Auth; # checkauth, getborrowernumber.
10 use C4::Circulation::Circ2;
11 use C4::Interface::CGI::Output;
17 my ($template, $borrowernumber, $cookie)
18 = get_template_and_user({template_name => "opac-userupdate.tmpl",
22 flagsrequired => {borrow => 1},
26 # get borrower information ....
27 my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
30 # handle the new information....
31 # collect the form values and send an email.
32 my @fields = ('title', 'surname', 'firstname', 'phone', 'faxnumber', 'streetaddress', 'emailaddress', 'city');
34 my $updateemailaddress= C4::Context->preference('KohaAdminEmailAddress');
35 if ($updateemailaddress eq '') {
36 warn "KohaAdminEmailAddress system preference not set. Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
37 my($template) = get_template_and_user({template_name => "kohaerror.tmpl",
41 flagsrequired => {borrow => 1},
45 $template->param(errormessage => 'KohaAdminEmailAddress system preference
46 is not set. Please visit the library to update your user record');
48 output_html_with_http_headers $query, $cookie, $template->output;
52 if ($query->{'title'}) {
54 my $message = <<"EOF";
55 Borrower $borr->{'cardnumber'}
57 has requested to change her/his personal details.
58 Please check these new details and make the changes:
60 foreach my $field (@fields){
61 my $newfield = $query->param($field);
62 $message .= "$field : $borr->{$field} --> $newfield\n";
64 $message .= "\n\nThanks,\nKoha\n\n";
65 my %mail = ( To => $updateemailaddress ,
66 From => $updateemailaddress ,
67 Subject => "User Request for update of Record.",
68 Message => $message );
70 # do something if it works....
71 warn "Mail sent ok\n";
72 print $query->redirect('/cgi-bin/koha/opac-user.pl');
75 # do something if it doesnt work....
76 warn "Error sending mail: $Mail::Sendmail::error \n";
81 $borr->{'dateenrolled'} = format_date($borr->{'dateenrolled'});
82 $borr->{'expiry'} = format_date($borr->{'expiry'});
83 $borr->{'dateofbirth'} = format_date($borr->{'dateofbirth'});
84 $borr->{'ethnicity'} = fixEthnicity($borr->{'ethnicity'});
90 $template->param(BORROWER_INFO => \@bordat);
92 output_html_with_http_headers $query, $cookie, $template->output;