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

(-)a/Koha/Patrons.pm (+27 lines)
Lines 672-677 sub extended_attributes_config { Link Here
672
    };
672
    };
673
}
673
}
674
674
675
=head3 check_for_existing_matches
676
677
    my $match_result = Koha::Patrons->check_for_existing_matches( $patron_data );
678
679
    Uses the fields from the PatronDuplicateMatchingAddFields preference to check for existing matches
680
681
=cut
682
683
sub check_for_existing_matches {
684
    my ( $self, $new_patron_data ) = @_;
685
686
    my @duplicate_match_fields = split '\|', C4::Context->preference('PatronDuplicateMatchingAddFields');
687
    my $match_conditions;
688
    for my $field (@duplicate_match_fields) {
689
        $match_conditions->{$field} = $new_patron_data->{$field} if $new_patron_data->{$field};
690
    }
691
692
    my $patrons = Koha::Patrons->search($match_conditions);
693
    if ( $patrons->count > 0 ) {
694
        return {
695
            'duplicate_found'  => 1,
696
            'matching_patrons' => $patrons
697
        };
698
    }
699
    return { 'duplicate_found' => 0 };
700
}
701
675
=head3 _type
702
=head3 _type
676
703
677
=cut
704
=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