From 9a322e444341e07aeb9713445ce2df03e44068fd Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 7 Nov 2019 14:42:12 +0100 Subject: [PATCH] Bug 23590: Add the ability to notify a new manager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer --- .../prog/en/modules/suggestion/suggestion.tt | 14 +++++++++ suggestion/suggestion.pl | 35 +++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index 9b50d2938f..ec3798e89f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -396,6 +396,10 @@ Keep existing manager [% END %] + +
+ + @@ -876,6 +880,15 @@ $('#managedby_name').html(managerlink); $('#managedby').val(borrowernumber); } + + var notify = $('#notify'); + if ( notify.length ) { + if ( borrowernumber == [% logged_in_user.borrowernumber | html %] || borrowernumber == [% managedby_patron.borrowernumber | html %] ) { + $(notify).prop('checked', false).prop('disabled', true); + } else { + $(notify).prop('disabled', false); + } + } } $(document).ready(function(){ @@ -1062,6 +1075,7 @@ + borrowername + ''; $('#managedby_name').html(managerlink); $('#managedby').val([% managedby_patron.borrowernumber | html %]); + $('#notify').prop('checked', false).prop('disabled', true); }); }); diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl index 7e8e2b2d0c..1dad30a2f7 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -91,6 +91,7 @@ my $managedby = $input->param('managedby'); my $displayby = $input->param('displayby') || ''; my $tabcode = $input->param('tabcode'); my $save_confirmed = $input->param('save_confirmed') || 0; +my $notify = $input->param('notify'); my $reasonsloop = GetAuthorisedValues("SUGGEST"); @@ -103,7 +104,7 @@ my $columns = ' '.join(' ', $schema->source('Suggestion')->columns).' '; my $suggestion_only = { map { $columns =~ / $_ / ? ($_ => $suggestion_ref->{$_}) : () } keys %$suggestion_ref }; $suggestion_only->{STATUS} = $suggestion_ref->{STATUS}; -delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field ); +delete $$suggestion_ref{$_} foreach qw( suggestedbyme op displayby tabcode edit_field notify ); foreach (keys %$suggestion_ref){ delete $$suggestion_ref{$_} if (!$$suggestion_ref{$_} && ($op eq 'else' )); } @@ -163,7 +164,39 @@ if ( $op =~ /save/i ) { } if ( $suggestion_only->{'suggestionid'} > 0 ) { + &ModSuggestion($suggestion_only); + + if ( $notify ) { + my $patron = Koha::Patrons->find( $suggestion_only->{managedby} ); + my $email_address = $patron->notice_email_address; + if ($patron->notice_email_address) { + my $budget = C4::Budgets::GetBudget( $suggestion_only->{budgetid} ); + my $library = $patron->library; + my $admin_email_address = $library->branchemail + || C4::Context->preference('KohaAdminEmailAddress'); + + my $letter = C4::Letters::GetPreparedLetter( + module => 'suggestions', + letter_code => 'TO_PROCESS', + branchcode => $patron->branchcode, + lang => $patron->lang, + tables => { + suggestions => $suggestion_only->{suggestionid}, + branches => $patron->branchcode, + borrowers => $patron->borrowernumber, + }, + ); + C4::Letters::EnqueueLetter( + { + letter => $letter, + borrowernumber => $patron->borrowernumber, + message_transport_type => 'email', + from_address => $admin_email_address, + } + ); + } + } } else { ###FIXME:Search here if suggestion already exists. my $suggestions_loop = -- 2.11.0