View | Details | Raw Unified | Return to bug 40082
Collapse All | Expand All

(-)a/Koha/Patrons.pm (+27 lines)
Lines 647-652 sub extended_attributes_config { Link Here
647
    };
647
    };
648
}
648
}
649
649
650
=head3 check_for_existing_matches
651
652
    my $match_result = Koha::Patrons->check_for_existing_matches( $patron_data );
653
654
    Uses the fields from the PatronDuplicateMatchingAddFields preference to check for existing matches
655
656
=cut
657
658
sub check_for_existing_matches {
659
    my ( $self, $new_patron_data ) = @_;
660
661
    my @duplicate_match_fields = split '\|', C4::Context->preference('PatronDuplicateMatchingAddFields');
662
    my $match_conditions;
663
    for my $field (@duplicate_match_fields) {
664
        $match_conditions->{$field} = $new_patron_data->{$field} if $new_patron_data->{$field};
665
    }
666
667
    my $patrons = Koha::Patrons->search($match_conditions);
668
    if ( $patrons->count > 0 ) {
669
        return {
670
            'duplicate_found'  => 1,
671
            'matching_patrons' => $patrons
672
        };
673
    }
674
    return { 'duplicate_found' => 0 };
675
}
676
650
=head3 _type
677
=head3 _type
651
678
652
=cut
679
=cut
(-)a/members/memberentry.pl (-10 / +4 lines)
Lines 252-269 if ( $op eq 'cud-insert' || $op eq 'edit_form' || $op eq 'cud-save' || $op eq 'd Link Here
252
    }
252
    }
253
}
253
}
254
254
255
# Test uniqueness of surname, firstname and dateofbirth
255
#Test uniqueness of fields in PatronDuplicateMatchingAddFields
256
if ( ( $op eq 'cud-insert' ) and !$nodouble ) {
256
if ( ( $op eq 'cud-insert' ) and !$nodouble ) {
257
    my @dup_fields = split '\|', C4::Context->preference('PatronDuplicateMatchingAddFields');
258
    my $conditions;
259
    for my $f (@dup_fields) {
260
        $conditions->{$f} = $newdata{$f} if $newdata{$f};
261
    }
262
    $nodouble = 1;
257
    $nodouble = 1;
263
    my $patrons = Koha::Patrons->search($conditions);
258
    my $match_result = Koha::Patrons->check_for_existing_matches( \%newdata );
264
    if ( $patrons->count > 0 ) {
259
    if ( $match_result->{duplicate_found} ) {
265
        $nodouble     = 0;
260
        $nodouble     = 0;
266
        $check_patron = $patrons->next;
261
        $check_patron = $match_result->{matching_patrons}->next;
267
        $check_member = $check_patron->borrowernumber;
262
        $check_member = $check_patron->borrowernumber;
268
    }
263
    }
269
}
264
}
270
- 

Return to bug 40082