Fix for bug 1295 adding a borrower with the same cardnumber

This commit is contained in:
rangi 2007-07-08 23:07:31 +00:00
parent 4af7e13c70
commit 73e6be1340
5 changed files with 34 additions and 2 deletions

View file

@ -116,6 +116,7 @@ push @EXPORT, qw(
&fixEthnicity
&ethnicitycategories
&fixup_cardnumber
&checkcardnumber
);
=item SearchMember
@ -1234,6 +1235,22 @@ sub checkuniquemember {
}
}
sub checkcardnumber {
my ($cardnumber) = @_;
my $dbh = C4::Context->dbh;
my $query = "SELECT * FROM borrowers WHERE cardnumber=?";
my $sth = $dbh->prepare($query);
$sth->execute($cardnumber);
if (my $data= $sth->fetchrow_hashref()){
return 1;
}
else {
return 0;
}
$sth->finish();
}
=head2 getzipnamecity (OUEST-PROVENCE)
take all info from table city for the fields city and zip
@ -1606,6 +1623,7 @@ This function remove directly a borrower whitout writing it on deleteborrower.
sub DelMember {
my $dbh = C4::Context->dbh;
my $borrowernumber = shift;
warn "in delmember with $borrowernumber";
return unless $borrowernumber; # borrowernumber is mandatory.
my $query = qq|DELETE
@ -1619,7 +1637,7 @@ sub DelMember {
FROM borrowers
WHERE borrowernumber = ?
";
$sth = $dbh->prepare($query);
my $sth = $dbh->prepare($query);
$sth->execute($borrowernumber);
$sth->finish;
&logaction(C4::Context->userenv->{'number'},"MEMBERS","DELETE",$borrowernumber,"")

View file

@ -43,6 +43,9 @@
<!-- TMPL_IF NAME="ERROR_login_exist" -->
<p>login/password already exist</p>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="ERROR_cardnumber" -->
<p>Cardnumber already in use</p>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="ERROR_age_limitations" -->
Patron is too young or too old for this category
<!-- /TMPL_IF -->
@ -138,7 +141,7 @@
<label>
<!-- /TMPL_IF-->
Surname</label>
<! --TMPL_IF NAME="uppercasesurnames" -->
<!-- TMPL_IF NAME="uppercasesurnames" -->
<input style="text-transform:uppercase;" type="text" name="surname" size="20" value="<!-- TMPL_VAR NAME="surname" -->" >
<!-- TMPL_ELSE -->
<input style="text-transform:capitalize;" type="text" name="surname" size="20" value="<!-- TMPL_VAR NAME="surname" -->" >

View file

@ -40,6 +40,9 @@
<!-- TMPL_IF NAME="ERROR_login_exist" -->
<p>login/password already exist</p>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="ERROR_cardnumber" -->
<p>Cardnumber already in use</p>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="ERROR_age_limitations" -->
Patron is too young or too old for this category
<!-- /TMPL_IF -->

View file

@ -37,6 +37,9 @@
<h1>ERROR</h1>
<div id="problem">
<p>The following fields are wrong. Please fix it/them</p>
<!-- TMPL_IF NAME="ERROR_cardnumber" -->
<p>Cardnumber already in use</p>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="ERROR_login_exist" -->
<p>login/password already exist</p>
<!-- /TMPL_IF -->

View file

@ -83,6 +83,7 @@ my $check_categorytype=$input->param('check_categorytype');
# NOTE: Alert for ethnicity and ethnotes fields, they are unvalided in all borrowers form
my $borrower_data;
$template->param("uppercasesurnames" => C4::Context->preference('uppercasesurnames'));
#function to automatic setup the mandatory fields (visual with css)
@ -148,6 +149,10 @@ if ($category_type eq 'C' and $guarantorid ne '' ){
# CHECKS step by step
# STEP 1
if ($step eq 1) {
if (checkcardnumber($cardnumber)){
push @errors, 'ERROR_cardnumber';
$nok = 1;
}
###############test to take the right zipcode and city name ##############
if ( $guarantorid eq ''){
if ($select_city){