From 1a99af35f68c7624193069579d3944b4863216f3 Mon Sep 17 00:00:00 2001 From: Kyle Hall Date: Tue, 8 Nov 2022 15:10:07 -0500 Subject: [PATCH] Bug 21699: Allow circulation messages to be editable During a Webinar discussion regarding the new placement of the circulation messages appearing in the Patron Detail page. It was commented by a librarian that it would be nice to have the circulation messages editable. At times libraries need to keep a specific message on a patrons account with the details such as what branch it was written from and the staff member that wrote it, but it would be nice to be able to edit this message. Test Plan: 1) Apply this patch 2) Restart all the things! 3) Browser to a patron record 4) Create a new patron message 5) Note the patron message now has an "edit" button 6) Edit the existing message using the edit button and form 7) Check the action logs for that message, note there is a modification logged to that message if BorrowersLog is enabled Signed-off-by: Barbara Johnson Signed-off-by: Laura Escamilla Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- Koha/Patron/Message.pm | 9 +++- circ/add_message.pl | 23 +++++---- .../prog/en/includes/patron_messages.inc | 47 ++++++++++++++++++- .../prog/en/modules/tools/viewlog.tt | 3 +- 4 files changed, 69 insertions(+), 13 deletions(-) diff --git a/Koha/Patron/Message.pm b/Koha/Patron/Message.pm index fa4473d220..ccba93a0d6 100644 --- a/Koha/Patron/Message.pm +++ b/Koha/Patron/Message.pm @@ -53,8 +53,13 @@ sub store { $self->manager_id( $userenv ? $userenv->{number} : undef ); } - C4::Log::logaction( "MEMBERS", "ADDCIRCMESSAGE", $self->borrowernumber, $self->message ) - if C4::Context->preference("BorrowersLog"); + if ( C4::Context->preference("BorrowersLog") ) { + if ( $self->in_storage ) { + C4::Log::logaction( "MEMBERS", "MODCIRCMESSAGE", $self->borrowernumber, $self->message ) + } else { + C4::Log::logaction( "MEMBERS", "ADDCIRCMESSAGE", $self->borrowernumber, $self->message ) + } + } return $self->SUPER::store($self); } diff --git a/circ/add_message.pl b/circ/add_message.pl index ee90af3522..37fb2d14bc 100755 --- a/circ/add_message.pl +++ b/circ/add_message.pl @@ -35,20 +35,27 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +my $message_id = $input->param('message_id'); my $borrowernumber = $input->param('borrowernumber'); my $branchcode = $input->param('branchcode'); my $message_type = $input->param('message_type'); my $borrower_message = $input->param('borrower_message'); my $batch = $input->param('batch'); -Koha::Patron::Message->new( - { - borrowernumber => $borrowernumber, - branchcode => $branchcode, - message_type => $message_type, - message => $borrower_message, - } -)->store; +if ($message_id) { + my $message = Koha::Patron::Messages->find($message_id); + $message->update( { message => $borrower_message } ) if $message; +} +else { + Koha::Patron::Message->new( + { + borrowernumber => $borrowernumber, + branchcode => $branchcode, + message_type => $message_type, + message => $borrower_message, + } + )->store; +} my $url = $input->referer; if ( $url ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc index cefe1d10a9..183fd3f31b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc @@ -314,9 +314,11 @@ [% IF patron_message.branchcode == Branches.GetLoggedInBranchcode OR Koha.Preference('AllowAllMessageDeletion') %] [% IF moremember %] - Delete + Edit + Delete [% ELSE %] - Delete + Edit + Delete [% END %] [% END %] @@ -324,4 +326,45 @@ Add a new message + + [% FOREACH pm IN patron_messages %] + + [% END %] + [% END # /IF patron_messages %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt index 76281191b4..7682adb029 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -119,6 +119,7 @@ [% CASE 'RENEWAL' %]Renew [% CASE 'CHANGE PASS' %]Change password [% CASE 'ADDCIRCMESSAGE' %]Add circulation message +[% CASE 'MODCIRCMESSAGE' %]Modify circulation message [% CASE 'DELCIRCMESSAGE' %]Delete circulation message [% CASE 'STATUS_CHANGE' %]Change ILL request status [% CASE 'PATRON_NOTICE' %]ILL notice sent to patron @@ -243,7 +244,7 @@ [% END %] - [% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'FILL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'PATRON_NOTICE' 'CHANGE PASS' 'Run' 'End' 'EDIT_MAPPINGS' 'RESET_MAPPINGS' 'ADD_BASKET' 'MODIFY_BASKET' 'MODIFY_BASKET_HEADER' 'MODIFY_BASKET_USERS' 'CLOSE_BASKET' 'APPROVE_BASKET' 'REOPEN_BASKET' 'CANCEL_ORDER' 'CREATE_ORDER' 'MODIFY_ORDER' 'CREATE_INVOICE_ADJUSTMENT' 'UPDATE_INVOICE_ADJUSTMENT' 'DELETE_INVOICE_ADJUSTMENT' 'RECEIVE_ORDER' 'MODIFY_BUDGET' 'MODIFY_FUND' 'CREATE_FUND' 'DELETE_FUND' 'OVERDUE' 'EXPIRE' ] %] + [% FOREACH actx IN [ 'ADD' 'DELETE' 'MODIFY' 'ISSUE' 'RETURN' 'RENEW' 'CREATE' 'CANCEL' 'FILL' 'SUSPEND' 'RESUME' 'ADDCIRCMESSAGE' 'MODCIRCMESSAGE' 'DELCIRCMESSAGE' 'STATUS_CHANGE' 'PATRON_NOTICE' 'CHANGE PASS' 'Run' 'End' 'EDIT_MAPPINGS' 'RESET_MAPPINGS' 'ADD_BASKET' 'MODIFY_BASKET' 'MODIFY_BASKET_HEADER' 'MODIFY_BASKET_USERS' 'CLOSE_BASKET' 'APPROVE_BASKET' 'REOPEN_BASKET' 'CANCEL_ORDER' 'CREATE_ORDER' 'MODIFY_ORDER' 'CREATE_INVOICE_ADJUSTMENT' 'UPDATE_INVOICE_ADJUSTMENT' 'DELETE_INVOICE_ADJUSTMENT' 'RECEIVE_ORDER' 'MODIFY_BUDGET' 'MODIFY_FUND' 'CREATE_FUND' 'DELETE_FUND' 'OVERDUE' 'EXPIRE' ] %] [% IF actions.grep(actx).size %] [% ELSE %] -- 2.39.5