From a7a07f7e806c49d39f2a64b92f26ecad990f0ef2 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. --- .../prog/en/includes/members-toolbar.inc | 4 +++ members/notices.pl | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+) 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..13d1816a36 100755 --- a/members/notices.pl +++ b/members/notices.pl @@ -60,6 +60,42 @@ 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' + } + ); + }; + if ($@) { + $template->param( error_alert => $@ ); + } + } + + # 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.20.1