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 $lib = GetBranchDetail
($borr->{'branchcode'});
53 # handle the new information....
54 # collect the form values and send an email.
56 'surname','firstname','othernames','streetnumber','address','address2','city','zipcode','country','phone','mobile','fax','phonepro', 'emailaddress','emailpro','B_streetnumber','B_address','B_address2','B_city','B_zipcode','B_country','B_phone','B_email','dateofbirth','sex'
59 my $updateemailaddress = $lib->{'branchemail'};
60 $updateemailaddress = C4
::Context
->preference('KohaAdminEmailAddress') unless( $updateemailaddress =~ /\w+@\w+/);
61 if ( !$updateemailaddress || $updateemailaddress eq '' ) {
63 "KohaAdminEmailAddress system preference not set. Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
64 my ($template) = get_template_and_user
(
66 template_name
=> "kohaerror.tmpl",
70 flagsrequired
=> { borrow
=> 1 },
79 output_html_with_http_headers
$query, $cookie, $template->output;
83 if ( $query->param('modify') ) {
86 my $message = <<"EOF";
87 Borrower $borr->{'cardnumber'}
89 has requested to change her/his personal details.
90 Please check these new details and make the changes:
93 my $streetnumber = $borr->{'streetnumber'} || '';
94 my $address = $borr->{'address'} || '';
95 my $address2 = $borr->{'address2'} || '';
96 my $B_streetnumber = $borr->{'B_streetnumber'} || '';
97 my $B_address = $borr->{'B_address'} || '';
98 my $B_address2 = $borr->{'B_address2'} || '';
100 foreach my $field (@fields) {
101 my $newfield = $query->param($field) || '';
102 my $borrowerfield = '';
103 if($borr->{$field}) {
104 $borrowerfield = $borr->{$field};
107 # reconstruct the address
108 if($field eq "address") {
109 $borrowerfield = "$streetnumber $address, $address2";
112 # reconstruct the alternate address
113 if($field eq "B_address") {
114 $borrowerfield = "$B_streetnumber $B_address, $B_address2";
117 if($field eq "dateofbirth") {
118 $borrowerfield = format_date
( $borr->{'dateofbirth'} ) || '';
121 if($borrowerfield eq $newfield) {
122 $message .= "$field : $borrowerfield --> $newfield\n";
124 $message .= uc($field) . " : $borrowerfield --> $newfield\n";
127 $message .= "\n\nThanks,\nKoha\n\n";
129 To
=> $updateemailaddress,
130 From
=> $updateemailaddress,
131 Subject
=> "User Request for update of Record.",
133 'Content-Type' => 'text/plain; charset="utf8"',
136 if ( sendmail
%mail ) {
138 # do something if it works....
139 print $query->redirect('/cgi-bin/koha/opac-user.pl?patronupdate=sent');
144 # do something if it doesnt work....
145 warn "Error sending mail: $Mail::Sendmail::error \n";
149 $borr->{'dateenrolled'} = format_date
( $borr->{'dateenrolled'} );
150 $borr->{'dateexpiry'} = format_date
( $borr->{'dateexpiry'} );
151 $borr->{'dateofbirth'} = format_date
( $borr->{'dateofbirth'} );
152 $borr->{'ethnicity'} = fixEthnicity
( $borr->{'ethnicity'} );
154 if (C4
::Context
->preference('ExtendedPatronAttributes')) {
155 my $attributes = C4
::Members
::Attributes
::GetBorrowerAttributes
($borrowernumber, 'opac');
156 if (scalar(@
$attributes) > 0) {
157 $borr->{ExtendedPatronAttributes
} = 1;
158 $borr->{patron_attributes
} = $attributes;
162 my $checkin_prefs = C4
::Members
::Messaging
::GetMessagingPreferences
({
163 borrowernumber
=> $borrowernumber,
164 message_name
=> 'Item Checkout'
166 for (@
{ $checkin_prefs->{transports
} }) {
167 $borr->{"items_returned_$_"} = 1;
169 my $checkout_prefs = C4
::Members
::Messaging
::GetMessagingPreferences
({
170 borrowernumber
=> $borrowernumber,
171 message_name
=> 'Item Check-in'
173 for (@
{ $checkout_prefs->{transports
} }) {
174 $borr->{"items_borrowed_$_"} = 1;
181 BORROWER_INFO
=> \
@bordat,
185 output_html_with_http_headers
$query, $cookie, $template->output;