Bugzilla – Attachment 131252 Details for
Bug 29005
Add option to send WELCOME notice for new patrons added via patron imports
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29005: Add option to send welcome email from patron imports
Bug-29005-Add-option-to-send-welcome-email-from-pa.patch (text/plain), 6.67 KB, created by
Martin Renvoize (ashimema)
on 2022-03-02 14:24:10 UTC
(
hide
)
Description:
Bug 29005: Add option to send welcome email from patron imports
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-03-02 14:24:10 UTC
Size:
6.67 KB
patch
obsolete
>From e64ae86e3e699e65e8defb4afe12beb2cfda997f Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 1 Oct 2021 10:40:50 +0100 >Subject: [PATCH] Bug 29005: Add option to send welcome email from patron > imports > >This patch adds the ability to send the ACCTDETAILS notice for new users >added using the patron import tool. > >Test plan >1. Create a valid csv for patron import that includes some new users, > ensuring you add a valid email address for which you have access. >2. Import the users using the patron import tool and select the new > 'Send email to new patrons' checkbox. >3. Check that the notice appears in the new patrons notices >4. Check that you received a welcome email for the user. >--- > Koha/Patrons/Import.pm | 50 ++++++++++++++++++- > .../prog/en/modules/tools/import_borrowers.tt | 11 ++++ > tools/import_borrowers.pl | 2 + > 3 files changed, 61 insertions(+), 2 deletions(-) > >diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm >index fe3fd80c11..ae5ebe6058 100644 >--- a/Koha/Patrons/Import.pm >+++ b/Koha/Patrons/Import.pm >@@ -24,6 +24,7 @@ use Encode qw( decode_utf8 ); > use Try::Tiny qw( catch try ); > > use C4::Members qw( checkcardnumber ); >+use C4::Letters qw( GetPreparedLetter EnqueueLetter ); > > use Koha::Libraries; > use Koha::Patrons; >@@ -74,6 +75,7 @@ sub import_patrons { > my $overwrite_cardnumber = $params->{overwrite_cardnumber}; > my $overwrite_passwords = $params->{overwrite_passwords}; > my $dry_run = $params->{dry_run}; >+ my $send_welcome = $params->{send_welcome}; > my $extended = C4::Context->preference('ExtendedPatronAttributes'); > my $set_messaging_prefs = C4::Context->preference('EnhancedMessagingPreferences'); > >@@ -196,11 +198,13 @@ sub import_patrons { > } > } > >+ my $is_new = 0; > if ($patron) { > $member = $patron->unblessed; > $borrowernumber = $member->{'borrowernumber'}; > } else { > $member = {}; >+ $is_new = 1; > } > > if ( C4::Members::checkcardnumber( $borrower{cardnumber}, $borrowernumber ) ) { >@@ -277,7 +281,6 @@ sub import_patrons { > } > } > >- my $patron = Koha::Patrons->find( $borrowernumber ); > try { > $schema->storage->txn_do(sub { > $patron->set(\%borrower)->store; >@@ -373,7 +376,7 @@ sub import_patrons { > else { > try { > $schema->storage->txn_do(sub { >- my $patron = Koha::Patron->new(\%borrower)->store; >+ $patron = Koha::Patron->new(\%borrower)->store; > $borrowernumber = $patron->id; > > if ( $patron->is_debarred ) { >@@ -439,6 +442,49 @@ sub import_patrons { > > next LINE unless $success; > >+ # Send ACCTDETAILS welcome email is the user is new and we're set to send mail >+ if ($send_welcome && $is_new) { >+ my $emailaddr = $patron->notice_email_address; >+ >+ # if we manage to find a valid email address, send notice >+ if ($emailaddr) { >+ eval { >+ my $letter = GetPreparedLetter( >+ module => 'members', >+ letter_code => 'ACCTDETAILS', >+ branchcode => $patron->branchcode,, >+ lang => $patron->lang || 'default', >+ tables => { >+ 'branches' => $patron->branchcode, >+ 'borrowers' => $patron->borrowernumber, >+ }, >+ want_librarian => 1, >+ ) or return; >+ >+ my $message_id = EnqueueLetter( >+ { >+ letter => $letter, >+ borrowernumber => $patron->id, >+ to_address => $emailaddr, >+ message_transport_type => 'email' >+ } >+ ); >+ }; >+ if ($@) { >+ push @errors, { welcome_email_err => 1, borrowernumber => $borrowernumber }; >+ } else { >+ push( >+ @feedback, >+ { >+ feedback => 1, >+ name => 'welcome_sent', >+ value => $borrower{'surname'} . ' / ' . $borrowernumber . ' / ' . $emailaddr >+ } >+ ); >+ } >+ } >+ } >+ > # Add a guarantor if we are given a relationship > if ( $guarantor_id ) { > my $relationship = Koha::Patron::Relationships->find( >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt >index a0bb8409b7..42c6718337 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/import_borrowers.tt >@@ -344,6 +344,17 @@ > </fieldset> > [% END %] > >+ <fieldset class="rows"> >+ <legend>Welcome email</legend> >+ <ul> >+ <li> >+ <input class="welcome_new" type="checkbox" id="welcome_new" name="welcome_new"/> >+ <label class="welcome_new" for="welcome_new">Send email to new patrons</label> >+ <span class="hint"> ACCTDETAILS notice is used</span> >+ </li> >+ </ul> >+ </fieldset> >+ > <fieldset class="action"> > <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" /> > <input type="submit" value="Import" /> >diff --git a/tools/import_borrowers.pl b/tools/import_borrowers.pl >index d02d671d41..28e9670501 100755 >--- a/tools/import_borrowers.pl >+++ b/tools/import_borrowers.pl >@@ -97,6 +97,7 @@ my @preserve_fields = $input->param('preserve_existing'); > > my $uploadborrowers = $input->param('uploadborrowers'); > my $matchpoint = $input->param('matchpoint'); >+my $welcome_new = $input->param('welcome_new'); > if ($matchpoint) { > $matchpoint =~ s/^patron_attribute_//; > } >@@ -128,6 +129,7 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) { > overwrite_passwords => $overwrite_passwords, > preserve_extended_attributes => scalar $input->param( 'ext_preserve' ) || 0, > preserve_fields => \@preserve_fields, >+ send_welcome => $welcome_new, > } > ); > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29005
:
125598
|
126039
|
126040
|
131246
|
131247
|
131248
|
131249
|
131250
|
131251
|
131252
|
131253
|
131254
|
132782
|
132783
|
132784
|
132909
|
132910