Koha/circ/add_message.pl
Kyle Hall 1a99af35f6
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 <barbara.johnson@bedfordtx.gov>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-05-05 10:18:55 -03:00

70 lines
2.1 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright 2009 PTFS Inc.
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Auth qw( get_template_and_user );
use C4::Output;
use Koha::Patron::Message;
my $input = CGI->new;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{ template_name => "circ/circulation.tt",
query => $input,
type => "intranet",
flagsrequired => { borrowers => 'edit_borrowers' },
}
);
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');
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 ) {
if ( $url =~ m|circulation\.pl$| ) {
# Trick for POST form from batch checkouts
$url .= "?borrowernumber=$borrowernumber";
$url .= "&amp;batch=1" if $batch;
}
} else {
$url = "/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber";
}
print $input->redirect($url);