my $dbh = C4::Context->dbh;
my $request = ($collectivity) ?
"SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? " :
- "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?";
+ ($dateofbirth) ?
+ "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=? and dateofbirth=?" :
+ "SELECT borrowernumber,categorycode FROM borrowers WHERE surname=? and firstname=?";
my $sth = $dbh->prepare($request);
+ warn $request;
if ($collectivity) {
$sth->execute( uc($surname) );
- } else {
- if($dateofbirth){
- $request .= " and dateofbirth=?";
- $sth->execute( uc($surname), ucfirst($firstname), $dateofbirth );
- }else{
- $sth->execute( uc($surname), ucfirst($firstname));
- }
+ } elsif($dateofbirth){
+ $sth->execute( uc($surname), ucfirst($firstname), $dateofbirth );
+ }else{
+ $sth->execute( uc($surname), ucfirst($firstname));
}
my @data = $sth->fetchrow;
$sth->finish;
}
if ($nok or !$nodouble){
- $op="add" if ($op eq "insert");
- $op="modify" if ($op eq "save");
- %data=%newdata;
- $template->param( updtype => ($op eq 'add' ?'I':'M')); # used to check for $op eq "insert"... but we just changed $op!
- unless ($step){
- $template->param( step_1 => 1,step_2 => 1,step_3 => 1, step_4 => 1);
- }
+ $op="add" if ($op eq "insert");
+ $op="modify" if ($op eq "save");
+ %data=%newdata;
+ $template->param( updtype => ($op eq 'add' ?'I':'M')); # used to check for $op eq "insert"... but we just changed $op!
+ unless ($step){
+ $template->param( step_1 => 1,step_2 => 1,step_3 => 1, step_4 => 1);
+ }
}
if (C4::Context->preference("IndependantBranches")) {
my $userenv = C4::Context->userenv;