Koha/members/members-update.pl
Owen Leonard 7e1227890b Bug 28073: Patron modifications should auto-open panel for referring patron record
This patch makes it possible to link directly to the correct panel on
the "Update patron records" page. The link on the checkout and patron
details screen has been updated to read "Patron has pending
modifications."

Also changed: Moved the "Patron's address in doubt" message so that it
is above the table of changed fields.

To test, apply the patch and if necessary submit patron modification
requests from multiple patrons via the OPAC.

 - Open the checkout page for one of these patrons.
   - If you are logged in as a user with permission to edit patron
     records you should see a message, "Pending modifications: Review
     pending modifications," which links to the pending modifications
     page.
     - Clicking the link should open the page for reviewing pending
       patron modifications, and the correct panel should be
       automatically expanded.
   - If you are logged in as a user without permission to edit patrons
     you should see the message "Pending modifications: Patron has
     pending modifications," which isn't linked.
 - The process should work exactly the same from the patron detail page.
 - Following the "Pending modifications" link from the staff interface
   home page or the patrons home page should work as before: The page
   opens with the first panel expanded.

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-07-26 12:46:32 +02:00

79 lines
2.6 KiB
Perl
Executable file

#!/usr/bin/perl
# Parts Copyright Biblibre 2010
# 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 qw( output_html_with_http_headers );
use C4::Context;
use C4::Members;
use Koha::Patron::Attribute::Types;
use Koha::Patron::Attributes;
use Koha::Patron::Modifications;
use Koha::Patrons;
use List::MoreUtils qw( uniq );
my $query = CGI->new;
my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
{ template_name => "members/members-update.tt",
query => $query,
type => "intranet",
flagsrequired => { borrowers => 'edit_borrowers' },
}
);
my $branch
= ( C4::Context->preference("IndependentBranchesPatronModifications")
|| C4::Context->preference("IndependentBranches") )
&& !$flags->{'superlibrarian'}
? C4::Context->userenv()->{'branch'}
: undef;
my $pending_modifications = Koha::Patron::Modifications->pending($branch);
my $borrowers;
foreach my $pm (@$pending_modifications) {
my @modified_atypes = uniq( map { $_->code } @{ $pm->{extended_attributes} } );
my $modified_attributes;
foreach my $type (@modified_atypes) {
my $type_obj = Koha::Patron::Attribute::Types->find($type);
my @before = Koha::Patron::Attributes->search(
{ borrowernumber => $pm->{borrowernumber}, code => $type } );
my @after = grep { $_->code eq $type } @{ $pm->{extended_attributes} };
push @{$modified_attributes}, { type => $type_obj, before => \@before, after => \@after };
}
$borrowers->{ $pm->{borrowernumber} } = Koha::Patrons->find($pm->{borrowernumber})->unblessed;
$borrowers->{ $pm->{borrowernumber} }->{modified_attributes} = $modified_attributes;
}
$template->param(
PendingModifications => $pending_modifications,
borrowers => $borrowers,
active => ( $query->param('active') || 0 ),
);
output_html_with_http_headers $query, $cookie, $template->output;
1;