From 3f65f7891c1059f1b0aab09da562036df9207d38 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 --- .../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 a2ce6c5334..a9cf192bea 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -390,6 +390,10 @@ Keep existing manager [% END %] + +
+ + @@ -864,6 +868,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(){ @@ -1046,6 +1059,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 bcb68766ed..b67fc0df84 100755 --- a/suggestion/suggestion.pl +++ b/suggestion/suggestion.pl @@ -92,6 +92,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"); @@ -104,7 +105,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' )); } @@ -164,7 +165,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