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.
26 use C4
::Auth
; # checkauth, getborrowernumber.
31 use C4
::Dates qw
/format_date/;
33 use C4
::Members
::Attributes
;
38 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
40 template_name
=> "opac-userupdate.tmpl",
44 flagsrequired
=> { borrow
=> 1 },
49 # get borrower information ....
50 my ( $borr ) = GetMemberDetails
( $borrowernumber );
51 my ( $patronemail ) = GetFirstValidEmailAddress
($borrowernumber);
52 my $lib = GetBranchDetail
($borr->{'branchcode'});
54 # handle the new information....
55 # collect the form values and send an email.
57 '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'
60 my $updateemailaddress = $lib->{'branchemail'};
61 $updateemailaddress = C4
::Context
->preference('KohaAdminEmailAddress') unless( $updateemailaddress =~ /\w+@\w+/);
62 if ( !$updateemailaddress || $updateemailaddress eq '' ) {
64 "KohaAdminEmailAddress system preference not set. Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
65 my ($template) = get_template_and_user
(
67 template_name
=> "kohaerror.tmpl",
71 flagsrequired
=> { borrow
=> 1 },
80 output_html_with_http_headers
$query, $cookie, $template->output;
84 if ( !$patronemail || $patronemail eq '' ) {
85 $patronemail = $updateemailaddress;
88 if ( $query->param('modify') ) {
91 my $message = <<"EOF";
92 Patron $borr->{'cardnumber'} has requested to change her/his personal details.
93 Please check these new details and make the changes to these fields:
97 my $streetnumber = $borr->{'streetnumber'} || '';
98 my $address = $borr->{'address'} || '';
99 my $address2 = $borr->{'address2'} || '';
100 my $B_streetnumber = $borr->{'B_streetnumber'} || '';
101 my $B_address = $borr->{'B_address'} || '';
102 my $B_address2 = $borr->{'B_address2'} || '';
104 foreach my $field (@fields) {
105 my $newfield = $query->param($field) || '';
106 my $borrowerfield = '';
107 if($borr->{$field}) {
108 $borrowerfield = $borr->{$field};
111 if($field eq "dateofbirth") {
112 $borrowerfield = format_date
( $borr->{'dateofbirth'} ) || '';
115 if($borrowerfield ne $newfield) {
116 $message .= $field . " : $borrowerfield --> $newfield\n";
120 $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 ');
122 $message .= "\n\nThanks,\nKoha\n\n";
124 To
=> $updateemailaddress,
125 From
=> $patronemail,
126 Subject
=> "User Request for update of Record.",
128 'Content-Type' => 'text/plain; charset="utf8"',
131 if ( sendmail
%mail ) {
133 # do something if it works....
134 print $query->redirect('/cgi-bin/koha/opac-user.pl?patronupdate=sent');
139 # do something if it doesnt work....
140 warn "Error sending mail: $Mail::Sendmail::error \n";
144 $borr->{'ethnicity'} = fixEthnicity
( $borr->{'ethnicity'} );
145 $borr->{'branchname'} = GetBranchName
($borr->{'branchcode'});
147 if (C4
::Context
->preference('ExtendedPatronAttributes')) {
148 my $attributes = C4
::Members
::Attributes
::GetBorrowerAttributes
($borrowernumber, 'opac');
149 if (scalar(@
$attributes) > 0) {
150 $borr->{ExtendedPatronAttributes
} = 1;
151 $borr->{patron_attributes
} = $attributes;
155 my $checkin_prefs = C4
::Members
::Messaging
::GetMessagingPreferences
({
156 borrowernumber
=> $borrowernumber,
157 message_name
=> 'Item Checkout'
159 for ( keys %{ $checkin_prefs->{transports
} }) {
160 $borr->{"items_returned_$_"} = 1;
162 my $checkout_prefs = C4
::Members
::Messaging
::GetMessagingPreferences
({
163 borrowernumber
=> $borrowernumber,
164 message_name
=> 'Item Check-in'
166 for ( keys %{ $checkout_prefs->{transports
} }) {
167 $borr->{"items_borrowed_$_"} = 1;
170 if (C4
::Context
->preference('OPACpatronimages')) {
171 my ($image, $dberror) = GetPatronImage
($borr->{'cardnumber'});
174 display_patron_image
=> 1
183 BORROWER_INFO
=> \
@bordat,
187 output_html_with_http_headers
$query, $cookie, $template->output;