Bug 9097: Add option to manually send welcome email

This patch adds a new 'Send welcome email' option to the 'More' dropdown
menu in the patrons toolbar.

Clicking the button will queue the welcome email again for the patron and
redirect the user to the Notices tab to view it's contents.

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>
Signed-off-by: Jessie Zairo <jzairo@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Martin Renvoize 2022-03-08 16:43:01 +00:00 committed by Fridolin Somers
parent 33fb5d70a5
commit 30f598cebe
2 changed files with 38 additions and 1 deletions

View File

@ -64,6 +64,10 @@
[% END %]
[% END %]
[% IF CAN_user_borrowers_edit_borrowers %]
<li><a id="sendwelcome" href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% patron.borrowernumber | uri %]&op=send_welcome">Send welcome email</a></li>
[% END %]
[% IF CAN_user_borrowers_delete_borrowers %]
<li><a id="deletepatron" href="#">Delete</a></li>
[% ELSE %]

View File

@ -24,7 +24,7 @@ use C4::Auth qw( get_template_and_user );
use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
use CGI qw ( -utf8 );
use C4::Members;
use C4::Letters;
use C4::Letters qw( GetPreparedLetter EnqueueLetter );
use Koha::Patrons;
use Koha::Patron::Categories;
@ -60,6 +60,39 @@ if ( $op eq 'resend_notice' ) {
}
}
if ( $op eq 'send_welcome' ) {
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 => 'WELCOME',
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'
}
);
};
}
# redirect to self to avoid form submission on refresh
print $input->redirect("/cgi-bin/koha/members/notices.pl?borrowernumber=$borrowernumber");
}
# Getting the messages
my $queued_messages = C4::Letters::GetQueuedMessages({borrowernumber => $borrowernumber});