|
Lines 23-29
use Modern::Perl;
Link Here
|
| 23 |
use Try::Tiny; |
23 |
use Try::Tiny; |
| 24 |
|
24 |
|
| 25 |
# external modules |
25 |
# external modules |
| 26 |
use CGI qw ( -utf8 ); |
26 |
use CGI qw ( -utf8 ); |
|
|
27 |
use List::Util qw ( all ); |
| 27 |
|
28 |
|
| 28 |
# internal modules |
29 |
# internal modules |
| 29 |
use C4::Auth qw( get_template_and_user haspermission ); |
30 |
use C4::Auth qw( get_template_and_user haspermission ); |
|
Lines 164-171
foreach (@field_check) {
Link Here
|
| 164 |
$template->param( "quickadd" => 1 ) if ($quickadd); |
165 |
$template->param( "quickadd" => 1 ) if ($quickadd); |
| 165 |
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' ); |
166 |
$template->param( "duplicate" => 1 ) if ( $op eq 'duplicate' ); |
| 166 |
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); |
167 |
$template->param( "checked" => 1 ) if ( defined($nodouble) && $nodouble eq 1 ); |
|
|
168 |
my $logged_in_user = Koha::Patrons->find($loggedinuser); |
| 169 |
|
| 167 |
if ( $op eq 'edit_form' or $op eq 'cud-save' or $op eq 'duplicate' ) { |
170 |
if ( $op eq 'edit_form' or $op eq 'cud-save' or $op eq 'duplicate' ) { |
| 168 |
my $logged_in_user = Koha::Patrons->find($loggedinuser); |
|
|
| 169 |
output_and_exit_if_error( |
171 |
output_and_exit_if_error( |
| 170 |
$input, $cookie, $template, |
172 |
$input, $cookie, $template, |
| 171 |
{ module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } |
173 |
{ module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } |
|
Lines 627-633
if ( ( !$nok ) and $nodouble and ( $op eq 'cud-insert' or $op eq 'cud-save' ) )
Link Here
|
| 627 |
if ( C4::Context->preference('ExtendedPatronAttributes') |
629 |
if ( C4::Context->preference('ExtendedPatronAttributes') |
| 628 |
and $input->param('setting_extended_patron_attributes') ) |
630 |
and $input->param('setting_extended_patron_attributes') ) |
| 629 |
{ |
631 |
{ |
| 630 |
$patron->extended_attributes($extended_patron_attributes); |
632 |
$patron->extended_attributes( $extended_patron_attributes, { check_editable => 1 } ); |
| 631 |
} |
633 |
} |
| 632 |
|
634 |
|
| 633 |
if ( |
635 |
if ( |
|
Lines 927-933
sub patron_attributes_form {
Link Here
|
| 927 |
|
929 |
|
| 928 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
930 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
| 929 |
my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, {}, $library_id ); |
931 |
my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, {}, $library_id ); |
| 930 |
if ( $attribute_types->count == 0 ) { |
932 |
if ( $attribute_types->count == 0 |
|
|
933 |
|| ( !$logged_in_user->is_superlibrarian && all { $_->hidden } $attribute_types->as_list ) ) |
| 934 |
{ |
| 931 |
$template->param( no_patron_attribute_types => 1 ); |
935 |
$template->param( no_patron_attribute_types => 1 ); |
| 932 |
return; |
936 |
return; |
| 933 |
} |
937 |
} |
|
Lines 941-952
sub patron_attributes_form {
Link Here
|
| 941 |
my @attribute_loop = (); |
945 |
my @attribute_loop = (); |
| 942 |
my $i = 0; |
946 |
my $i = 0; |
| 943 |
my %items_by_class; |
947 |
my %items_by_class; |
|
|
948 |
my @hidden_attributes; |
| 949 |
|
| 950 |
my $is_superlibrarian = $logged_in_user->is_superlibrarian; |
| 944 |
while ( my ($attr_type) = $attribute_types->next ) { |
951 |
while ( my ($attr_type) = $attribute_types->next ) { |
| 945 |
my $entry = { |
952 |
my $entry = { |
| 946 |
class => $attr_type->class(), |
953 |
class => $attr_type->class(), |
| 947 |
code => $attr_type->code(), |
954 |
code => $attr_type->code(), |
| 948 |
description => $attr_type->description(), |
955 |
description => $attr_type->description(), |
| 949 |
repeatable => $attr_type->repeatable(), |
956 |
repeatable => $attr_type->repeatable(), |
|
|
957 |
hidden => !$is_superlibrarian && $attr_type->hidden(), |
| 958 |
readonly => !$is_superlibrarian && $attr_type->readonly(), |
| 959 |
secret => !$is_superlibrarian && $attr_type->secret(), |
| 950 |
category => $attr_type->authorised_value_category(), |
960 |
category => $attr_type->authorised_value_category(), |
| 951 |
category_code => $attr_type->category_code(), |
961 |
category_code => $attr_type->category_code(), |
| 952 |
mandatory => $attr_type->mandatory(), |
962 |
mandatory => $attr_type->mandatory(), |
|
Lines 957-971
sub patron_attributes_form {
Link Here
|
| 957 |
my $newentry = {%$entry}; |
967 |
my $newentry = {%$entry}; |
| 958 |
$newentry->{value} = $attr->{attribute}; |
968 |
$newentry->{value} = $attr->{attribute}; |
| 959 |
$newentry->{use_dropdown} = 0; |
969 |
$newentry->{use_dropdown} = 0; |
| 960 |
if ( $attr_type->authorised_value_category() ) { |
|
|
| 961 |
$newentry->{use_dropdown} = 1; |
| 962 |
$newentry->{auth_val_loop} = |
| 963 |
GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); |
| 964 |
} |
| 965 |
$i++; |
970 |
$i++; |
| 966 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
|
|
| 967 |
$newentry->{form_id} = "patron_attr_$i"; |
971 |
$newentry->{form_id} = "patron_attr_$i"; |
| 968 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
972 |
if ( !$is_superlibrarian && ( $attr_type->hidden() || $attr_type->secret() ) ) { |
|
|
973 |
push @hidden_attributes, $newentry; |
| 974 |
} else { |
| 975 |
if ( $attr_type->authorised_value_category() ) { |
| 976 |
$newentry->{use_dropdown} = 1; |
| 977 |
$newentry->{auth_val_loop} = |
| 978 |
GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); |
| 979 |
} |
| 980 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
| 981 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
| 982 |
} |
| 969 |
} |
983 |
} |
| 970 |
} else { |
984 |
} else { |
| 971 |
$i++; |
985 |
$i++; |
|
Lines 988-994
sub patron_attributes_form {
Link Here
|
| 988 |
}; |
1002 |
}; |
| 989 |
} |
1003 |
} |
| 990 |
|
1004 |
|
| 991 |
$template->param( patron_attributes => \@attribute_loop ); |
1005 |
$template->param( patron_attributes => \@attribute_loop, hidden_patron_attributes => \@hidden_attributes ); |
| 992 |
|
1006 |
|
| 993 |
} |
1007 |
} |
| 994 |
|
1008 |
|