From 5bdce695b9ea57ce0132495bc6499bdaafcd9a84 Mon Sep 17 00:00:00 2001 From: btoumi Date: Mon, 12 Jun 2006 13:00:40 +0000 Subject: [PATCH] Members.pm: modify getborrowercategory function to return dateofbirthrequired and upperagelimit memberentryC and P : add error message ERROR_age_limitations memberentry.pl : replace sql request by function getborrowercategory for return upperagelimit and dateofbirthrequired moremember.pl: modify call to function getborrowercategory --- C4/Members.pm | 11 +++++++--- .../prog/en/members/memberentryC.tmpl | 3 +++ .../prog/en/members/memberentryP.tmpl | 3 +++ members/memberentry.pl | 20 +++++-------------- members/moremember.pl | 2 +- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index cb0619ecea..4dbb81fb8f 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1174,13 +1174,15 @@ sub getborrowercategory { my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( - "SELECT description FROM categories WHERE categorycode = ?"); + "SELECT description,dateofbirthrequired,upperagelimit FROM categories WHERE categorycode = ?"); $sth->execute($catcode); - my $description = $sth->fetchrow(); + my ($description,$dateofbirthrequired,$upperagelimit) = $sth->fetchrow(); $sth->finish(); - return $description; + return ($description,$dateofbirthrequired,$upperagelimit); } # sub getborrowercategory + + =head2 ethnicitycategories ($codes_arrayref, $labels_hashref) = ðnicitycategories(); @@ -1305,4 +1307,7 @@ sub add_member_orgs { $sth->finish(); } # sub add_member_orgs + +END { } # module clean-up code here (global destructor) + 1; diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl index 2a434151a1..d59e3e8061 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryC.tmpl @@ -38,6 +38,9 @@

login/password already exist

+ + Member is too young or too old for this category + diff --git a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl index e59e424783..50da94fe16 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/members/memberentryP.tmpl @@ -38,6 +38,9 @@

login/password already exist

+ + Member is too young or too old for this category + diff --git a/members/memberentry.pl b/members/memberentry.pl index 8a4c8f4561..198b4435a5 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -148,21 +148,11 @@ if ($op eq 'add' or $op eq 'modify') { } } if ($categorycode ne 'I') { - # is the age of the borrower compatible with age limitations of - # the borrower category - my $query = ' -SELECT upperagelimit, - dateofbirthrequired - FROM categories - WHERE categorycode = ? -'; - my $sth=$dbh->prepare($query); - $sth->execute($categorycode); - my $category_info = $sth->fetchrow_hashref; - my $age = get_age(format_date_in_iso($data{dateofbirth})); - if ($age > $category_info->{upperagelimit} - or $age < $category_info->{dateofbirthrequired} - ) { + my $age = get_age(format_date_in_iso($data{dateofbirth})); + my (undef,$agelimitmin,$agelimitmax)=getborrowercategory($data{'categorycode'}); + if ($age > $agelimitmax + or $age < $agelimitmin + ) { push @errors, 'ERROR_age_limitations'; $nok = 1; } diff --git a/members/moremember.pl b/members/moremember.pl index e9583b5ff9..a9ab1d5f54 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -147,7 +147,7 @@ if (C4::Context->preference("IndependantBranches")) { $data->{'branchname'} = &getbranchdetail($data->{'branchcode'}); # Converts the categorycode to the description -$data->{'categorycode'} = &getborrowercategory($data->{'categorycode'}); +($data->{'categorycode'},undef,undef) = &getborrowercategory($data->{'categorycode'}); my ($numaccts,$accts,$total)=getboracctrecord('',\%bor); -- 2.39.5