|
Lines 50-60
sub patron_attributes_form {
Link Here
|
| 50 |
my $template = shift; |
50 |
my $template = shift; |
| 51 |
my $attributes = shift; |
51 |
my $attributes = shift; |
| 52 |
my $op = shift; |
52 |
my $op = shift; |
| 53 |
my $query = shift // {}; |
|
|
| 54 |
|
53 |
|
| 55 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
54 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
| 56 |
my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( $query, {}, $library_id ); |
55 |
my @attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, { order_by => \'display_order IS NULL, display_order ASC , code ASC' }, $library_id) -> as_list(); |
| 57 |
if ( $attribute_types->count == 0 ) { |
56 |
if ( !@attribute_types ) { |
| 58 |
$template->param( no_patron_attribute_types => 1 ); |
57 |
$template->param( no_patron_attribute_types => 1 ); |
| 59 |
return; |
58 |
return; |
| 60 |
} |
59 |
} |
|
Lines 68-74
sub patron_attributes_form {
Link Here
|
| 68 |
my @attribute_loop = (); |
67 |
my @attribute_loop = (); |
| 69 |
my $i = 0; |
68 |
my $i = 0; |
| 70 |
my %items_by_class; |
69 |
my %items_by_class; |
| 71 |
while ( my ($attr_type) = $attribute_types->next ) { |
70 |
for my $attr_type (@attribute_types) { |
| 72 |
my $entry = { |
71 |
my $entry = { |
| 73 |
class => $attr_type->class(), |
72 |
class => $attr_type->class(), |
| 74 |
code => $attr_type->code(), |
73 |
code => $attr_type->code(), |
|
Lines 87-93
sub patron_attributes_form {
Link Here
|
| 87 |
if ( $attr_type->authorised_value_category() ) { |
86 |
if ( $attr_type->authorised_value_category() ) { |
| 88 |
$newentry->{use_dropdown} = 1; |
87 |
$newentry->{use_dropdown} = 1; |
| 89 |
$newentry->{auth_val_loop} = |
88 |
$newentry->{auth_val_loop} = |
| 90 |
C4::Koha::GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); |
89 |
GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); |
| 91 |
} |
90 |
} |
| 92 |
$i++; |
91 |
$i++; |
| 93 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
92 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
|
Lines 99-105
sub patron_attributes_form {
Link Here
|
| 99 |
my $newentry = {%$entry}; |
98 |
my $newentry = {%$entry}; |
| 100 |
if ( $attr_type->authorised_value_category() ) { |
99 |
if ( $attr_type->authorised_value_category() ) { |
| 101 |
$newentry->{use_dropdown} = 1; |
100 |
$newentry->{use_dropdown} = 1; |
| 102 |
$newentry->{auth_val_loop} = C4::Koha::GetAuthorisedValues( $attr_type->authorised_value_category() ); |
101 |
$newentry->{auth_val_loop} = GetAuthorisedValues( $attr_type->authorised_value_category() ); |
| 103 |
} |
102 |
} |
| 104 |
$newentry->{form_id} = "patron_attr_$i"; |
103 |
$newentry->{form_id} = "patron_attr_$i"; |
| 105 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
104 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |