|
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 689-695
sub ParsePatronAttributes {
Link Here
|
| 689 |
} |
703 |
} |
| 690 |
|
704 |
|
| 691 |
foreach my $code ( keys %{$delete_candidates} ) { |
705 |
foreach my $code ( keys %{$delete_candidates} ) { |
| 692 |
if ( Koha::Patron::Attributes->search({ |
706 |
if ( not $borrowernumber # self-registration |
|
|
707 |
|| Koha::Patron::Attributes->search({ |
| 693 |
borrowernumber => $borrowernumber, code => $code })->count > 0 ) |
708 |
borrowernumber => $borrowernumber, code => $code })->count > 0 ) |
| 694 |
{ |
709 |
{ |
| 695 |
push @attributes, { code => $code, attribute => '' } |
710 |
push @attributes, { code => $code, attribute => '' } |
| 696 |
- |
|
|