From f1a469ac5680347f6af1efec1e53dc041b606205 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 8 Mar 2022 16:43:01 +0000 Subject: [PATCH] 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 Signed-off-by: Jessie Zairo Signed-off-by: Katrin Fischer --- .../prog/en/includes/members-toolbar.inc | 4 +++ members/notices.pl | 35 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc index 6b0d8c12ac..0b3d74095d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -64,6 +64,10 @@ [% END %] [% END %] + [% IF CAN_user_borrowers_edit_borrowers %] +
  • Send welcome email
  • + [% END %] + [% IF CAN_user_borrowers_delete_borrowers %]
  • Delete
  • [% ELSE %] diff --git a/members/notices.pl b/members/notices.pl index c729d3fb1e..dad8f07e8b 100755 --- a/members/notices.pl +++ b/members/notices.pl @@ -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}); -- 2.30.2