Lines 136-144
if ( $op eq 'show' ) {
Link Here
|
136 |
my $patron_attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id); |
136 |
my $patron_attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id); |
137 |
my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']})->as_list; |
137 |
my @patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']})->as_list; |
138 |
while ( my $attr_type = $patron_attribute_types->next ) { |
138 |
while ( my $attr_type = $patron_attribute_types->next ) { |
139 |
# TODO Repeatable attributes are not correctly managed and can cause data lost. |
|
|
140 |
# This should be implemented. |
141 |
next if $attr_type->repeatable; |
142 |
next if $attr_type->unique_id; # Don't display patron attributes that must be unqiue |
139 |
next if $attr_type->unique_id; # Don't display patron attributes that must be unqiue |
143 |
my $options = $attr_type->authorised_value_category |
140 |
my $options = $attr_type->authorised_value_category |
144 |
? GetAuthorisedValues( $attr_type->authorised_value_category ) |
141 |
? GetAuthorisedValues( $attr_type->authorised_value_category ) |
Lines 357-365
if ( $op eq 'do' ) {
Link Here
|
357 |
|
354 |
|
358 |
delete $infos->{password_expiration_date} unless $logged_in_user->is_superlibrarian; |
355 |
delete $infos->{password_expiration_date} unless $logged_in_user->is_superlibrarian; |
359 |
|
356 |
|
360 |
my @attributes = $input->multi_param('patron_attributes'); |
|
|
361 |
my @attr_values = $input->multi_param('patron_attributes_value'); |
362 |
|
363 |
my @errors; |
357 |
my @errors; |
364 |
my @borrowernumbers = $input->multi_param('borrowernumber'); |
358 |
my @borrowernumbers = $input->multi_param('borrowernumber'); |
365 |
# For each borrower selected |
359 |
# For each borrower selected |
Lines 398-430
if ( $op eq 'do' ) {
Link Here
|
398 |
} |
392 |
} |
399 |
|
393 |
|
400 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
394 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
401 |
my $i=0; |
395 |
my @attributes = $input->multi_param('patron_attributes'); |
402 |
for ( @attributes ) { |
396 |
my @attr_values = $input->multi_param('patron_attributes_value'); |
403 |
next unless $_; |
397 |
my $attributes; |
404 |
my $attribute; |
398 |
my $i = 0; |
405 |
$attribute->{code} = $_; |
399 |
for my $code ( @attributes ) { |
406 |
$attribute->{attribute} = $attr_values[$i]; |
400 |
push @{ $attributes->{$code}->{values} }, shift @attr_values; # Handling repeatables |
407 |
my $attr_type = Koha::Patron::Attribute::Types->find($_); |
401 |
$attributes->{$code}->{disabled} = grep { $_ eq sprintf("attr%s_value", ++$i) } @disabled; |
|
|
402 |
} |
403 |
|
404 |
for my $code ( keys %$attributes ) { |
405 |
my $attr_type = Koha::Patron::Attribute::Types->find($code); |
408 |
# If this borrower is not in the category of this attribute, we don't want to modify this attribute |
406 |
# If this borrower is not in the category of this attribute, we don't want to modify this attribute |
409 |
++$i and next if $attr_type->category_code and $attr_type->category_code ne $patron->categorycode; |
407 |
next if $attr_type->category_code and $attr_type->category_code ne $patron->categorycode; |
410 |
my $valuename = "attr" . $i . "_value"; |
408 |
|
411 |
if ( grep { $_ eq $valuename } @disabled ) { |
409 |
if ( $attributes->{$code}->{disabled} ) { |
412 |
# The attribute is disabled, we remove it for this borrower ! |
410 |
# The attribute is disabled, we remove it for this borrower ! |
413 |
eval { |
411 |
eval { |
414 |
$patron->get_extended_attribute($attribute->{code})->delete; |
412 |
$patron->get_extended_attribute($code)->delete; |
415 |
}; |
413 |
}; |
416 |
push @errors, { error => $@ } if $@; |
414 |
push @errors, { error => $@ } if $@; |
417 |
} else { |
415 |
} else { |
418 |
eval { |
416 |
eval { |
419 |
# Note: |
417 |
$patron->extended_attributes->search({'me.code' => $code})->filter_by_branch_limitations->delete; |
420 |
# We should not need to filter by branch, but stay on the safe side |
418 |
$patron->add_extended_attribute({ code => $code, attribute => $_ }) for @{$attributes->{$code}->{values}}; |
421 |
# Repeatable are not supported so we can do that - TODO |
|
|
422 |
$patron->extended_attributes->search({'me.code' => $attribute->{code}})->filter_by_branch_limitations->delete; |
423 |
$patron->add_extended_attribute($attribute); |
424 |
}; |
419 |
}; |
425 |
push @errors, { error => $@ } if $@; |
420 |
push @errors, { error => $@ } if $@; |
426 |
} |
421 |
} |
427 |
$i++; |
|
|
428 |
} |
422 |
} |
429 |
} |
423 |
} |
430 |
$op = "show_results"; # We have process modifications, the user want to view its |
424 |
$op = "show_results"; # We have process modifications, the user want to view its |
431 |
- |
|
|