|
Lines 958-963
sub parse_extended_patron_attributes {
Link Here
|
| 958 |
return \@attr; |
958 |
return \@attr; |
| 959 |
} |
959 |
} |
| 960 |
|
960 |
|
|
|
961 |
sub patron_attributes_form { |
| 962 |
my $template = shift; |
| 963 |
my $attributes = shift; |
| 964 |
my $op = shift; |
| 965 |
|
| 966 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
| 967 |
my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, { order_by => 'display_order' }, $library_id); |
| 968 |
if ( $attribute_types->count == 0 ) { |
| 969 |
$template->param( no_patron_attribute_types => 1 ); |
| 970 |
return; |
| 971 |
} |
| 972 |
|
| 973 |
# map patron's attributes into a more convenient structure |
| 974 |
my %attr_hash = (); |
| 975 |
foreach my $attr (@$attributes) { |
| 976 |
push @{ $attr_hash{ $attr->{code} } }, $attr; |
| 977 |
} |
| 978 |
|
| 979 |
my @attribute_loop = (); |
| 980 |
my $i = 0; |
| 981 |
my %items_by_class; |
| 982 |
while ( my ($attr_type) = $attribute_types->next ) { |
| 983 |
my $entry = { |
| 984 |
class => $attr_type->class(), |
| 985 |
code => $attr_type->code(), |
| 986 |
description => $attr_type->description(), |
| 987 |
repeatable => $attr_type->repeatable(), |
| 988 |
category => $attr_type->authorised_value_category(), |
| 989 |
category_code => $attr_type->category_code(), |
| 990 |
mandatory => $attr_type->mandatory(), |
| 991 |
is_date => $attr_type->is_date(), |
| 992 |
}; |
| 993 |
if ( exists $attr_hash{ $attr_type->code() } ) { |
| 994 |
foreach my $attr ( @{ $attr_hash{ $attr_type->code() } } ) { |
| 995 |
my $newentry = {%$entry}; |
| 996 |
$newentry->{value} = $attr->{attribute}; |
| 997 |
$newentry->{use_dropdown} = 0; |
| 998 |
if ( $attr_type->authorised_value_category() ) { |
| 999 |
$newentry->{use_dropdown} = 1; |
| 1000 |
$newentry->{auth_val_loop} = |
| 1001 |
GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); |
| 1002 |
} |
| 1003 |
$i++; |
| 1004 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
| 1005 |
$newentry->{form_id} = "patron_attr_$i"; |
| 1006 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
| 1007 |
} |
| 1008 |
} else { |
| 1009 |
$i++; |
| 1010 |
my $newentry = {%$entry}; |
| 1011 |
if ( $attr_type->authorised_value_category() ) { |
| 1012 |
$newentry->{use_dropdown} = 1; |
| 1013 |
$newentry->{auth_val_loop} = GetAuthorisedValues( $attr_type->authorised_value_category() ); |
| 1014 |
} |
| 1015 |
$newentry->{form_id} = "patron_attr_$i"; |
| 1016 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
| 1017 |
} |
| 1018 |
} |
| 1019 |
for my $class ( sort keys %items_by_class ) { |
| 1020 |
my $av = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } ); |
| 1021 |
my $lib = $av->count ? $av->next->lib : $class; |
| 1022 |
push @attribute_loop, { |
| 1023 |
class => $class, |
| 1024 |
items => $items_by_class{$class}, |
| 1025 |
lib => $lib, |
| 1026 |
}; |
| 1027 |
} |
| 1028 |
|
| 1029 |
$template->param( patron_attributes => \@attribute_loop ); |
| 1030 |
|
| 1031 |
} |
| 1032 |
|
| 961 |
sub add_guarantors { |
1033 |
sub add_guarantors { |
| 962 |
my ( $patron, $input ) = @_; |
1034 |
my ( $patron, $input ) = @_; |
| 963 |
|
1035 |
|