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

(-)a/C4/Members.pm (-39 lines)
Lines 1175-1219 sub GetBorNotifyAcctRecord { Link Here
1175
    return ( $total, \@acctlines, $numlines );
1175
    return ( $total, \@acctlines, $numlines );
1176
}
1176
}
1177
1177
1178
=head2 checkuniquemember (OUEST-PROVENCE)
1179
1180
  ($result,$categorycode)  = &checkuniquemember($collectivity,$surname,$firstname,$dateofbirth);
1181
1182
Checks that a member exists or not in the database.
1183
1184
C<&result> is nonzero (=exist) or 0 (=does not exist)
1185
C<&categorycode> is from categorycode table
1186
C<&collectivity> is 1 (= we add a collectivity) or 0 (= we add a physical member)
1187
C<&surname> is the surname
1188
C<&firstname> is the firstname (only if collectivity=0)
1189
C<&dateofbirth> is the date of birth in ISO format (only if collectivity=0)
1190
1191
=cut
1192
1193
# FIXME: This function is not legitimate.  Multiple patrons might have the same first/last name and birthdate.
1194
# This is especially true since first name is not even a required field.
1195
1196
sub checkuniquemember {
1197
    my ( $collectivity, $surname, $firstname, $dateofbirth ) = @_;
1198
    my $dbh = C4::Context->dbh;
1199
    my $request = ($collectivity) ?
1200
        "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? " :
1201
            ($dateofbirth) ?
1202
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?  and dateofbirth=?" :
1203
            "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?";
1204
    my $sth = $dbh->prepare($request);
1205
    if ($collectivity) {
1206
        $sth->execute( uc($surname) );
1207
    } elsif($dateofbirth){
1208
        $sth->execute( uc($surname), ucfirst($firstname), $dateofbirth );
1209
    }else{
1210
        $sth->execute( uc($surname), ucfirst($firstname));
1211
    }
1212
    my @data = $sth->fetchrow;
1213
    ( $data[0] ) and return $data[0], $data[1];
1214
    return 0;
1215
}
1216
1217
sub checkcardnumber {
1178
sub checkcardnumber {
1218
    my ( $cardnumber, $borrowernumber ) = @_;
1179
    my ( $cardnumber, $borrowernumber ) = @_;
1219
1180
(-)a/members/memberentry.pl (-14 / +9 lines)
Lines 220-241 if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) Link Here
220
    }
220
    }
221
}
221
}
222
222
223
#############test for member being unique #############
223
# Test unicity of surname, firstname and dateofbirth
224
if ( ( $op eq 'insert' ) and !$nodouble ) {
224
if ( ( $op eq 'insert' ) and !$nodouble ) {
225
    my $category_type_send;
225
    my $conditions;
226
    if ( $category_type eq 'I' ) {
226
    $conditions->{surname} = $newdata{surname} if $newdata{surname};
227
        $category_type_send = $category_type;
227
    if ( $category_type ne 'I' ) {
228
        $conditions->{firstname} = $newdata{firstname} if $newdata{firstname};
229
        $conditions->{dateofbirth} = $newdata{dateofbirth} if $newdata{dateofbirth};
228
    }
230
    }
229
    my $check_category;    # recover the category code of the doublon suspect borrowers
231
    my $patrons = Koha::Patrons->search($conditions);
230
     #   ($result,$categorycode) = checkuniquemember($collectivity,$surname,$firstname,$dateofbirth)
232
    if ( $patrons->count > 0) {
231
    ( $check_member, $check_category ) = checkuniquemember(
232
        $category_type_send,
233
        ( $newdata{surname}     ? $newdata{surname}     : $data{surname} ),
234
        ( $newdata{firstname}   ? $newdata{firstname}   : $data{firstname} ),
235
        ( $newdata{dateofbirth} ? $newdata{dateofbirth} : $data{dateofbirth} )
236
    );
237
    if ( !$check_member ) {
238
        $nodouble = 1;
233
        $nodouble = 1;
234
        $check_member = $patrons->next->borrowernumber;
239
    }
235
    }
240
}
236
}
241
237
242
- 

Return to bug 16909