diff --git a/Koha/Template/Plugin/NoticeTemplates.pm b/Koha/Template/Plugin/NoticeTemplates.pm index b7f3d09484..8cb5545c50 100644 --- a/Koha/Template/Plugin/NoticeTemplates.pm +++ b/Koha/Template/Plugin/NoticeTemplates.pm @@ -23,6 +23,8 @@ use Template::Plugin; use base qw( Template::Plugin ); use Koha::Notice::Templates; +use C4::Context; +use C4::Letters qw( GetLettersAvailableForALibrary ); sub GetByModule { my ( $self, $module ) = @_; @@ -37,6 +39,24 @@ sub GetByModule { ); } +sub GetByModuleForLibrary { + my ( $self, $module ) = @_; + my $userenv = C4::Context->userenv; + my $branchcode = $userenv->{'branch'} // ''; + + return C4::Letters::GetLettersAvailableForALibrary( + { + branchcode => $branchcode, + module => $module, + }, + { + group_by => [ 'code', 'name' ], + columns => [ 'code', 'name' ], + order_by => ['name'] + } + ); +} + =head1 NAME Koha::Template::Plugin::NoticeTemplates - TT Plugin for notice templates diff --git a/circ/add_message.pl b/circ/add_message.pl index 2e872fbc57..c8facbd5e9 100755 --- a/circ/add_message.pl +++ b/circ/add_message.pl @@ -90,6 +90,7 @@ if ( $op eq 'cud-edit_message' && $message_id ) { letter_code => $letter_code, lang => $patron->lang, message_transport_type => $message_transport_type, + branchcode => $branchcode, tables => { 'borrowers' => $borrowernumber, 'branches' => $branchcode, 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 c7389c9ae1..cb9e31f573 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc @@ -208,7 +208,7 @@ [% END %] - [% patron_letters = NoticeTemplates.GetByModule( 'add_message' ) %] + [% patron_letters = NoticeTemplates.GetByModuleForLibrary( 'add_message' ) %] [% IF patron_letters %]