From 9aea8660dd06c80472edf608ab5b2bf53649ee78 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 5 Jun 2025 13:40:03 +0100 Subject: [PATCH] Bug 40082: Use the new duplicate checking method in the OPAC --- .../bootstrap/en/modules/opac-memberentry.tt | 6 ++++++ opac/opac-memberentry.pl | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 35456b194bf..63fa549a155 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -124,6 +124,12 @@ [% END %] + [% IF duplicate_found %] +
+ An existing account matching these details has been found, please contact a member of staff +
+ [% END %] + [% IF cardnumber_wrong_length || cardnumber_already_exists %]
[% IF cardnumber_wrong_length %] diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 65e6f3db162..28614e47c46 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -138,6 +138,8 @@ if ( $op eq 'cud-create' ) { my @empty_mandatory_fields = ( CheckMandatoryFields( \%borrower, $op ), CheckMandatoryAttributes( \%borrower, $attributes ) ); my $invalidformfields = CheckForInvalidFields( { borrower => \%borrower, context => 'create' } ); + my $match_result = Koha::Patrons->check_for_existing_matches( \%borrower ); + delete $borrower{'password2'}; my $is_cardnumber_valid; if ( !grep { $_ eq 'cardnumber' } @empty_mandatory_fields ) { @@ -158,12 +160,18 @@ if ( $op eq 'cud-create' ) { } } - if ( @empty_mandatory_fields || @$invalidformfields || !$is_cardnumber_valid || $conflicting_attribute ) { + if ( @empty_mandatory_fields + || @$invalidformfields + || !$is_cardnumber_valid + || $conflicting_attribute + || $match_result->{duplicate_found} ) + { $template->param( empty_mandatory_fields => \@empty_mandatory_fields, invalid_form_fields => $invalidformfields, - borrower => \%borrower + borrower => \%borrower, + duplicate_found => $match_result->{duplicate_found} ); $template->param( patron_attribute_classes => GeneratePatronAttributesForm( undef, $attributes ) ); } elsif ( md5_base64( uc( $cgi->param('captcha') ) ) ne $cgi->param('captcha_digest') ) { -- 2.48.1