From 2653083ac436b8370bb69a6ad2d504922641740c Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Fri, 4 Nov 2016 09:19:01 +0000
Subject: [PATCH] Bug 17548: Fix step 1 of memberentry

This bug has been highlighted by bug 15407.

The date limit check on the category code did not work on step 1. But
after bug 15407 the script crashes with
  Can't call method "dateofbirthrequired" on an undefined value at
  /home/vagrant/kohaclone/members/memberentry.pl line 311.

Test plan:
- Edit "step 1" information of a patron (first 'Edit' on a patron detail
page).
- Save
=> Without this patch it BOOMs
=> With this patch, the info should be correctly saved
---
 members/memberentry.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/members/memberentry.pl b/members/memberentry.pl
index d2f462f..95d2af0 100755
--- a/members/memberentry.pl
+++ b/members/memberentry.pl
@@ -307,7 +307,7 @@ if ($op eq 'save' || $op eq 'insert'){
 
     if ( $newdata{dateofbirth} ) {
         my $age = GetAge($newdata{dateofbirth});
-        my $borrowercategory = Koha::Patron::Categories->find($newdata{categorycode});
+        my $borrowercategory = Koha::Patron::Categories->find($categorycode);
         my ($low,$high) = ($borrowercategory->dateofbirthrequired, $borrowercategory->upperagelimit);
         if (($high && ($age > $high)) or ($age < $low)) {
             push @errors, 'ERROR_age_limitations';
-- 
2.1.4