Bug 10893: fix location facet in UNIMARC
[koha_fer] / members / memberentry.pl
index f9bc0c7..ff92447 100755 (executable)
@@ -293,9 +293,14 @@ if ($op eq 'save' || $op eq 'insert'){
     # If the cardnumber is blank, treat it as null.
     $newdata{'cardnumber'} = undef if $newdata{'cardnumber'} =~ /^\s*$/;
 
-    if (checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){ 
-        push @errors, 'ERROR_cardnumber';
-    } 
+    if (my $error_code = checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){
+        push @errors, $error_code == 1
+            ? 'ERROR_cardnumber_already_exists'
+            : $error_code == 2
+                ? 'ERROR_cardnumber_length'
+                : ()
+    }
+
     if ($newdata{dateofbirth} && $dateofbirthmandatory) {
         my $age = GetAge($newdata{dateofbirth});
         my $borrowercategory=GetBorrowercategory($newdata{'categorycode'});   
@@ -711,23 +716,13 @@ if(defined($data{'contacttitle'})){
   $template->param("contacttitle_" . $data{'contacttitle'} => "SELECTED");
 }
 
-if ( my $cardnumber_length = C4::Context->preference('CardnumberLength') ) {
-    my ( $min, $max );
-    # Is integer and length match
-    if ( $cardnumber_length =~ m|^\d+$| ) {
-        $min = $max = $cardnumber_length;
-    }
-    # Else assuming it is a range
-    elsif ( $cardnumber_length =~ m|(\d+),(\d*)| ) {
-        $min = $1;
-        $max = $2 || 16; # borrowers.cardnumber is a varchar(16)
-    }
-    if ( defined $min ) {
-        $template->param(
-            minlength_cardnumber => $min,
-            maxlength_cardnumber => $max
-        );
-    }
+
+my ( $min, $max ) = C4::Members::get_cardnumber_length();
+if ( defined $min ) {
+    $template->param(
+        minlength_cardnumber => $min,
+        maxlength_cardnumber => $max
+    );
 }
 
 output_html_with_http_headers $input, $cookie, $template->output;
@@ -786,7 +781,7 @@ sub patron_attributes_form {
         };
         if (exists $attr_hash{$attr_type->code()}) {
             foreach my $attr (@{ $attr_hash{$attr_type->code()} }) {
-                my $newentry = { map { $_ => $entry->{$_} } %$entry };
+                my $newentry = { %$entry };
                 $newentry->{value} = $attr->{value};
                 $newentry->{password} = $attr->{password};
                 $newentry->{use_dropdown} = 0;
@@ -800,7 +795,7 @@ sub patron_attributes_form {
             }
         } else {
             $i++;
-            my $newentry = { map { $_ => $entry->{$_} } %$entry };
+            my $newentry = { %$entry };
             if ($attr_type->authorised_value_category()) {
                 $newentry->{use_dropdown} = 1;
                 $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category());