Bug 37562: Add patron title to duplicate patron warning and don't show popup if cannot see patron

This patch passes the suspected duplicate to the template and uses patron title to display very brief info.
If the user cannot view the patron there is no longer a link tot he brief popup and they will only see
'A patron from library X"

There is a FIXME asking if we should use search_limited - I believe we should check all branches, so the staff can ask the patron if they
have an exising account in a consortium depending on rules about multiple cards

To test:
 1 - Edit a user to grant catalogue and all borrower permissions except 'view_borrower_infos_from_any_libraries'
 2 - Find a patron from a different library and note surname and firstname
 3 - Login as the patron above
 4 - Enter a new patron with the same surname and firstname
 5 - See the 'Duplicate patron' warning
 6 - Click to view the patron
 7 - No info is listed
 8 - Apply patch
 9 - Reload and resubmit - or fill out form again
10 - Note that you see 'A patron from library XXX' and no popup link
11 - Add view_borrower_infos_from_any_libraries to the staff
12 - Repeat the duplication and confirm the warning now has patron name and the popup link is visible and works

Signed-off-by: Sam Lau <samalau@gmail.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit bdf224c653)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2024-08-02 17:42:54 +00:00 committed by Lucas Gass
parent ef7362b62b
commit 5e9315eee8
2 changed files with 9 additions and 3 deletions

View File

@ -143,7 +143,10 @@ legend.collapsed i.fa.fa-caret-down::before {
[% IF ( check_member ) %]
<div class="dialog alert">
<h3>Duplicate patron record?</h3>
<p><a class="popup_patronview" href="/cgi-bin/koha/members/moremember.pl?print=brief&amp;borrowernumber=[% check_member | uri %]"><i class="fa-solid fa-window-restore"></i> View existing record</a></p>
<p>[%- INCLUDE 'patron-title.inc' patron => check_patron hide_patron_infos_if_needed => 1 -%]</p>
[% IF logged_in_user.can_see_patron_infos( check_patron ) %]
<p><a class="popup_patronview" href="/cgi-bin/koha/members/moremember.pl?print=brief&amp;borrowernumber=[% check_member | uri %]"><i class="fa-solid fa-window-restore"></i> View existing record</a></p>
[% END %]
<a href="/cgi-bin/koha/members/memberentry.pl?op=edit_form&borrowernumber=[% check_member | uri %]" class="btn btn-default" id="duplicate"> <i class="fa-solid fa-pencil" aria-hidden="true"></i> It is a duplicate. Edit existing record </a>
<button type="submit" id="not-duplicate" class="new"> <i class="fa fa-plus"></i> Not a duplicate. Save as new record </button>
</div>

View File

@ -82,6 +82,7 @@ my $check_member = $input->param('check_member');
my $nodouble = $input->param('nodouble');
my $duplicate = $input->param('duplicate');
my $quickadd = $input->param('quickadd');
my $check_patron;
$nodouble = 1 if ($op eq 'edit_form' or $op eq 'duplicate'); # FIXME hack to represent fact that if we're
# modifying an existing patron, it ipso facto
@ -249,8 +250,9 @@ if ( ( $op eq 'cud-insert' ) and !$nodouble ) {
$nodouble = 1;
my $patrons = Koha::Patrons->search($conditions); # FIXME Should be search_limited?
if ( $patrons->count > 0) {
$nodouble = 0;
$check_member = $patrons->next->borrowernumber;
$nodouble = 0;
$check_patron = $patrons->next;
$check_member = $check_patron->borrowernumber;
}
}
@ -791,6 +793,7 @@ $template->param(
BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript
destination => $destination,#to know where u come from and where u must go in redirect
check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0)
check_patron => $check_patron
);
$template->param(