@@ -, +, @@
- cd installer/data/mysql
- sudo koha-shell
- ./updatedatabase.pl
- KohaAdminEmailAddress syspref
- EmailAddressForPatronRegistrations syspref
- Email address in the library branch
---
Koha/Patron.pm | 65 +++++++++++++++++++
...lAddressForPatronRegistrations_sysprefs.pl | 19 +++---
.../mysql/en/mandatory/sample_notices.yml | 19 +++---
opac/opac-memberentry.pl | 7 ++
opac/opac-registration-verify.pl | 6 ++
5 files changed, 96 insertions(+), 20 deletions(-)
--- a/Koha/Patron.pm
+++ a/Koha/Patron.pm
@@ -2063,6 +2063,71 @@ sub recalls {
return Koha::Recalls->search({ borrowernumber => $self->borrowernumber });
}
+=head3 account_balance
+
+ my $balance = $patron->account_balance
+
+Return the patron's account balance
+
+=cut
+
+sub account_balance {
+ my ($self) = @_;
+ return $self->account->balance;
+}
+
+=head3 notify_library_of_registration
+
+$patron->notify_library_of_registration( $email_patron_registrations );
+
+Send patron registration email to library if EmailPatronRegistrations system preference is enabled.
+
+=cut
+
+sub notify_library_of_registration {
+ my ( $self, $email_patron_registrations ) = @_;
+
+ if (
+ my $letter = C4::Letters::GetPreparedLetter(
+ module => 'members',
+ letter_code => 'OPAC_REG',
+ branchcode => $self->branchcode,
+ lang => $self->lang || 'default',
+ tables => {
+ 'borrowers' => $self->borrowernumber
+ },
+ )
+ ) {
+ my $to_address;
+ if ( $email_patron_registrations eq "BranchEmailAddress" ) {
+ my $library = Koha::Libraries->find( $self->branchcode );
+ $to_address = $library->inbound_email_address;
+ }
+ elsif ( $email_patron_registrations eq "KohaAdminEmailAddress" ) {
+ $to_address = C4::Context->preference('ReplytoDefault')
+ || C4::Context->preference('KohaAdminEmailAddress');
+ }
+ else {
+ $to_address =
+ C4::Context->preference('EmailAddressForPatronRegistrations')
+ || C4::Context->preference('ReplytoDefault')
+ || C4::Context->preference('KohaAdminEmailAddress');
+ }
+
+ my $message_id = C4::Letters::EnqueueLetter(
+ {
+ letter => $letter,
+ borrowernumber => $self->borrowernumber,
+ to_address => $to_address,
+ message_transport_type => 'email'
+ }
+ ) or warn "can't enqueue letter $letter";
+ if ( $message_id ) {
+ return 1;
+ }
+ }
+}
+
=head2 Internal methods
=head3 _type
--- a/installer/data/mysql/atomicupdate/bug23538-add_EmailPatronRegistrations_and_EmailAddressForPatronRegistrations_sysprefs.pl
+++ a/installer/data/mysql/atomicupdate/bug23538-add_EmailPatronRegistrations_and_EmailAddressForPatronRegistrations_sysprefs.pl
@@ -13,16 +13,15 @@ return {
'New OPAC self-registration
Self-registration made by
- - <> <>
- - Physical address: <> <> <> <>, <>, <> <>, <>
- - Email: <>
- - Phone: <>
- - Mobile: <>
- - Fax: <>
- - Secondary email: <>
- - Secondary phone:<>
- - Home library: <>
- - Temporary patron category: <>
+ - <> <>
+ - Email: <>
+ - Phone: <>
+ - Mobile: <>
+ - Fax: <>
+ - Secondary email: <>
+ - Secondary phone:<>
+ - Home library: <>
+ - Patron category: <>
', 'email', 'default') });
},
--- a/installer/data/mysql/en/mandatory/sample_notices.yml
+++ a/installer/data/mysql/en/mandatory/sample_notices.yml
@@ -1648,15 +1648,14 @@ tables:
- "New OPAC self-registration
"
- "Self-registration made by
"
- ""
- - "- <> <>
"
- - "- Physical address: <> <> <> <>, <>, <> <>, <>
"
- - "- Email: <>
"
- - "- Phone: <>
"
- - "- Mobile: <>
"
- - "- Fax: <>
"
- - "- Secondary email: <>
"
- - "- Secondary phone:<>
"
- - "- Home library: <>
"
- - "- Temporary patron category: <>
"
+ - "- <> <>
"
+ - "- Email: <>
"
+ - "- Phone: <>
"
+ - "- Mobile: <>
"
+ - "- Fax: <>
"
+ - "- Secondary email: <>
"
+ - "- Secondary phone:<>
"
+ - "- Home library: <>
"
+ - "- Temporary patron category: <>
"
- "
"
- ""
--- a/opac/opac-memberentry.pl
+++ a/opac/opac-memberentry.pl
@@ -274,6 +274,13 @@ if ( $action eq 'create' ) {
};
}
}
+
+ # Notify library of new patron registration
+ my $notify_library = C4::Context->preference('EmailPatronRegistrations');
+ if ($notify_library) {
+ $patron->notify_library_of_registration($notify_library);
+ }
+
} else {
# FIXME Handle possible errors here
}
--- a/opac/opac-registration-verify.pl
+++ a/opac/opac-registration-verify.pl
@@ -110,6 +110,12 @@ if (
}
}
+ # Notify library of new patron registration
+ my $notify_library = C4::Context->preference("EmailPatronRegistrations");
+ if ($notify_library) {
+ $patron->notify_library_of_registration($notify_library);
+ }
+
$template->param(
PatronSelfRegistrationAdditionalInstructions =>
C4::Context->preference(
--