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
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 use C4
::Auth
; # checkauth, getborrowernumber.
32 use C4
::Dates qw
/format_date/;
34 use C4
::Members
::Attributes
;
39 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
41 template_name
=> "opac-userupdate.tmpl",
45 flagsrequired
=> { borrow
=> 1 },
50 # get borrower information ....
51 my ( $borr ) = GetMemberDetails
( $borrowernumber );
52 my ( $patronemail ) = GetFirstValidEmailAddress
($borrowernumber);
53 my $lib = GetBranchDetail
($borr->{'branchcode'});
55 # handle the new information....
56 # collect the form values and send an email.
58 'surname','firstname','othernames','streetnumber','address','address2','city','state','zipcode','country','phone','mobile','fax','phonepro', 'emailaddress','emailpro','B_streetnumber','B_address','B_address2','B_city','B_state','B_zipcode','B_country','B_phone','B_email','dateofbirth','sex'
61 my $updateemailaddress = $lib->{'branchemail'};
62 $updateemailaddress = C4
::Context
->preference('KohaAdminEmailAddress') unless( $updateemailaddress =~ /\w+@\w+/);
63 if ( !$updateemailaddress || $updateemailaddress eq '' ) {
65 "KohaAdminEmailAddress system preference not set. Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
66 my ($template) = get_template_and_user
(
68 template_name
=> "kohaerror.tmpl",
72 flagsrequired
=> { borrow
=> 1 },
81 output_html_with_http_headers
$query, $cookie, $template->output;
85 if ( !$patronemail || $patronemail eq '' ) {
86 $patronemail = $updateemailaddress;
89 if ( $query->param('modify') ) {
92 my $message = <<"EOF";
93 Patron $borr->{'cardnumber'} has requested to change her/his personal details.
94 Please check these new details and make the changes to these fields:
98 my $streetnumber = $borr->{'streetnumber'} || '';
99 my $address = $borr->{'address'} || '';
100 my $address2 = $borr->{'address2'} || '';
101 my $B_streetnumber = $borr->{'B_streetnumber'} || '';
102 my $B_address = $borr->{'B_address'} || '';
103 my $B_address2 = $borr->{'B_address2'} || '';
105 foreach my $field (@fields) {
106 my $newfield = decode
('utf-8',$query->param($field)) || '';
107 my $borrowerfield = '';
108 if($borr->{$field}) {
109 $borrowerfield = $borr->{$field};
112 if($field eq "dateofbirth") {
113 $borrowerfield = format_date
( $borr->{'dateofbirth'} ) || '';
116 if($borrowerfield ne $newfield) {
117 $message .= $field . " : $borrowerfield --> $newfield\n";
121 $message .= "\nEdit this patron's record: http://".C4
::Context
->preference('staffClientBaseURL ')."/cgi-bin/koha/members/memberentry.pl?op=modify&borrowernumber=".$borr->{'borrowernumber'}."&categorycode=".$borr->{'categorycode'} if C4
::Context
->preference('staffClientBaseURL ');
123 $message .= "\n\nThanks,\nKoha\n\n";
125 To
=> $updateemailaddress,
126 From
=> $patronemail,
127 Subject
=> "User Request for update of Record.",
128 Message
=> encode
('utf-8', $message), # Mail::Sendmail doesn't like wide characters
129 'Content-Type' => 'text/plain; charset="utf-8"',
132 if ( sendmail
%mail ) {
134 # do something if it works....
135 print $query->redirect('/cgi-bin/koha/opac-user.pl?patronupdate=sent');
140 # do something if it doesnt work....
141 warn "Error sending mail: $Mail::Sendmail::error \n";
145 $borr->{'ethnicity'} = fixEthnicity
( $borr->{'ethnicity'} );
146 $borr->{'branchname'} = GetBranchName
($borr->{'branchcode'});
148 if (C4
::Context
->preference('ExtendedPatronAttributes')) {
149 my $attributes = C4
::Members
::Attributes
::GetBorrowerAttributes
($borrowernumber, 'opac');
150 if (scalar(@
$attributes) > 0) {
151 $borr->{ExtendedPatronAttributes
} = 1;
152 $borr->{patron_attributes
} = $attributes;
156 my $checkin_prefs = C4
::Members
::Messaging
::GetMessagingPreferences
({
157 borrowernumber
=> $borrowernumber,
158 message_name
=> 'Item Checkout'
160 for ( keys %{ $checkin_prefs->{transports
} }) {
161 $borr->{"items_returned_$_"} = 1;
163 my $checkout_prefs = C4
::Members
::Messaging
::GetMessagingPreferences
({
164 borrowernumber
=> $borrowernumber,
165 message_name
=> 'Item Check-in'
167 for ( keys %{ $checkout_prefs->{transports
} }) {
168 $borr->{"items_borrowed_$_"} = 1;
171 if (C4
::Context
->preference('OPACpatronimages')) {
172 my ($image, $dberror) = GetPatronImage
($borr->{'cardnumber'});
175 display_patron_image
=> 1
184 BORROWER_INFO
=> \
@bordat,
188 output_html_with_http_headers
$query, $cookie, $template->output;