Lines 123-129
if ( $action eq 'create' ) {
Link Here
|
123 |
|
123 |
|
124 |
%borrower = DelEmptyFields(%borrower); |
124 |
%borrower = DelEmptyFields(%borrower); |
125 |
|
125 |
|
126 |
my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action ); |
126 |
my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) ); |
127 |
my $invalidformfields = CheckForInvalidFields(\%borrower); |
127 |
my $invalidformfields = CheckForInvalidFields(\%borrower); |
128 |
delete $borrower{'password2'}; |
128 |
delete $borrower{'password2'}; |
129 |
my $cardnumber_error_code; |
129 |
my $cardnumber_error_code; |
Lines 259-265
elsif ( $action eq 'update' ) {
Link Here
|
259 |
$borrower{borrowernumber} = $borrowernumber; |
259 |
$borrower{borrowernumber} = $borrowernumber; |
260 |
|
260 |
|
261 |
my @empty_mandatory_fields = |
261 |
my @empty_mandatory_fields = |
262 |
CheckMandatoryFields( \%borrower, $action ); |
262 |
( CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) ); |
263 |
my $invalidformfields = CheckForInvalidFields(\%borrower); |
263 |
my $invalidformfields = CheckForInvalidFields(\%borrower); |
264 |
|
264 |
|
265 |
# Send back the data to the template |
265 |
# Send back the data to the template |
Lines 412-417
sub CheckMandatoryFields {
Link Here
|
412 |
return @empty_mandatory_fields; |
412 |
return @empty_mandatory_fields; |
413 |
} |
413 |
} |
414 |
|
414 |
|
|
|
415 |
sub CheckMandatoryAttributes{ |
416 |
my ( $borrower, $attributes ) = @_; |
417 |
|
418 |
my @empty_mandatory_fields; |
419 |
|
420 |
for my $attribute (@$attributes ) { |
421 |
my $attr = Koha::Patron::Attribute::Types->find($attribute->{code}); |
422 |
push @empty_mandatory_fields, $attribute->{code} |
423 |
if $attr && $attr->mandatory && $attribute->{attribute} =~ m|^\s*$|; |
424 |
} |
425 |
|
426 |
return @empty_mandatory_fields; |
427 |
} |
428 |
|
415 |
sub CheckForInvalidFields { |
429 |
sub CheckForInvalidFields { |
416 |
my $borrower = shift; |
430 |
my $borrower = shift; |
417 |
my @invalidFields; |
431 |
my @invalidFields; |
Lines 691-697
sub ParsePatronAttributes {
Link Here
|
691 |
} |
705 |
} |
692 |
|
706 |
|
693 |
foreach my $code ( keys %{$delete_candidates} ) { |
707 |
foreach my $code ( keys %{$delete_candidates} ) { |
694 |
if ( Koha::Patron::Attributes->search({ |
708 |
if ( not $borrowernumber # self-registration |
|
|
709 |
|| Koha::Patron::Attributes->search({ |
695 |
borrowernumber => $borrowernumber, code => $code })->count > 0 ) |
710 |
borrowernumber => $borrowernumber, code => $code })->count > 0 ) |
696 |
{ |
711 |
{ |
697 |
push @attributes, { code => $code, attribute => '' } |
712 |
push @attributes, { code => $code, attribute => '' } |
698 |
- |
|
|