7 use C4::Auth; # checkauth, getborrowernumber.
10 use C4::Circulation::Circ2;
16 my ($template, $borrowernumber, $cookie)
17 = get_template_and_user({template_name => "opac-userupdate.tmpl",
21 flagsrequired => {borrow => 1},
25 # get borrower information ....
26 my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
29 # handle the new information....
30 # collect the form values and send an email.
31 my @fields = ('title', 'surname', 'firstname', 'phone', 'faxnumber', 'streetaddress', 'emailaddress', 'city');
33 my $updateemailaddress= C4::Context->preference('KohaAdminEmailAddress');
34 if ($updateemailaddress eq '') {
35 warn "KohaAdminEmailAddress system preference not set. Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
36 my $template = gettemplate("kohaerror.tmpl", "opac");
38 $template->param(errormessage => 'KohaAdminEmailAddress system preference
39 is not set. Please visit the library to update your user record');
41 print $query->header(), $template->output;
45 if ($query->{'title'}) {
47 my $message = <<"EOF";
48 Borrower $borr->{'cardnumber'} http://intradev.katipo.co.nz/cgi-bin/koha/moremember.pl?bornum=$borrowernumber
50 has requested to change their personal details. Please check these new details and make the changes:
52 foreach my $field (@fields){
53 my $newfield = $query->param($field);
54 $message .= "$field : $borr->{$field} --> $newfield\n";
56 $message .= "\n\nThanks,\nKoha\n\n";
57 my %mail = ( To => $updateemailaddress ,
58 From => $updateemailaddress ,
59 Subject => "User Request for update of Record.",
60 Message => $message );
62 # do something if it works....
63 warn "Mail sent ok\n";
64 print $query->redirect('/cgi-bin/koha/opac-user.pl');
67 # do something if it doesnt work....
68 warn "Error sending mail: $Mail::Sendmail::error \n";
73 $borr->{'dateenrolled'} = slashifyDate($borr->{'dateenrolled'});
74 $borr->{'expiry'} = slashifyDate($borr->{'expiry'});
75 $borr->{'dateofbirth'} = slashifyDate($borr->{'dateofbirth'});
76 $borr->{'ethnicity'} = fixEthnicity($borr->{'ethnicity'});
82 $template->param(BORROWER_INFO => \@bordat);
84 output_html_with_http_headers $query, $cookie, $template->output;