From 73e6be13405ebda4779e047e22f4a973cad0fe7a Mon Sep 17 00:00:00 2001 From: rangi Date: Sun, 8 Jul 2007 23:07:31 +0000 Subject: [PATCH] Fix for bug 1295 adding a borrower with the same cardnumber --- C4/Members.pm | 20 ++++++++++++++++++- .../prog/en/members/memberentryA.tmpl | 5 ++++- .../prog/en/members/memberentryC.tmpl | 3 +++ .../prog/en/members/memberentryI.tmpl | 3 +++ members/memberentry.pl | 5 +++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index a978ca825c..141ae86991 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -116,6 +116,7 @@ push @EXPORT, qw( &fixEthnicity ðnicitycategories &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,"") diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl index 481323cf2b..2fee891a5a 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryA.tmpl @@ -43,6 +43,9 @@

login/password already exist

+ +

Cardnumber already in use

+ Patron is too young or too old for this category @@ -138,7 +141,7 @@ - + " > " > diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl index 252148e163..1c9e55f5fb 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl @@ -40,6 +40,9 @@

login/password already exist

+ +

Cardnumber already in use

+ Patron is too young or too old for this category diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl index ff3f9a5565..2288a3b586 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryI.tmpl @@ -37,6 +37,9 @@

ERROR

The following fields are wrong. Please fix it/them

+ +

Cardnumber already in use

+

login/password already exist

diff --git a/members/memberentry.pl b/members/memberentry.pl index aad5a04ceb..c9e21220a2 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -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){ -- 2.39.5