|
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 632-638
if ( ( !$nok ) and $nodouble and ( $op eq 'cud-insert' or $op eq 'cud-save' ) )
Link Here
|
| 632 |
if ( C4::Context->preference('ExtendedPatronAttributes') |
634 |
if ( C4::Context->preference('ExtendedPatronAttributes') |
| 633 |
and $input->param('setting_extended_patron_attributes') ) |
635 |
and $input->param('setting_extended_patron_attributes') ) |
| 634 |
{ |
636 |
{ |
| 635 |
$patron->extended_attributes($extended_patron_attributes); |
637 |
$patron->extended_attributes( $extended_patron_attributes, { check_editable => 1 } ); |
| 636 |
} |
638 |
} |
| 637 |
|
639 |
|
| 638 |
if ( |
640 |
if ( |
|
Lines 936-942
sub patron_attributes_form {
Link Here
|
| 936 |
|
938 |
|
| 937 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
939 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
| 938 |
my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, {}, $library_id ); |
940 |
my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits( {}, {}, $library_id ); |
| 939 |
if ( $attribute_types->count == 0 ) { |
941 |
if ( $attribute_types->count == 0 |
|
|
942 |
|| ( !$logged_in_user->is_superlibrarian && all { $_->hidden } $attribute_types->as_list ) ) |
| 943 |
{ |
| 940 |
$template->param( no_patron_attribute_types => 1 ); |
944 |
$template->param( no_patron_attribute_types => 1 ); |
| 941 |
return; |
945 |
return; |
| 942 |
} |
946 |
} |
|
Lines 950-961
sub patron_attributes_form {
Link Here
|
| 950 |
my @attribute_loop = (); |
954 |
my @attribute_loop = (); |
| 951 |
my $i = 0; |
955 |
my $i = 0; |
| 952 |
my %items_by_class; |
956 |
my %items_by_class; |
|
|
957 |
my @hidden_attributes; |
| 958 |
|
| 959 |
my $is_superlibrarian = $logged_in_user->is_superlibrarian; |
| 953 |
while ( my ($attr_type) = $attribute_types->next ) { |
960 |
while ( my ($attr_type) = $attribute_types->next ) { |
| 954 |
my $entry = { |
961 |
my $entry = { |
| 955 |
class => $attr_type->class(), |
962 |
class => $attr_type->class(), |
| 956 |
code => $attr_type->code(), |
963 |
code => $attr_type->code(), |
| 957 |
description => $attr_type->description(), |
964 |
description => $attr_type->description(), |
| 958 |
repeatable => $attr_type->repeatable(), |
965 |
repeatable => $attr_type->repeatable(), |
|
|
966 |
hidden => !$is_superlibrarian && $attr_type->hidden(), |
| 967 |
readonly => !$is_superlibrarian && $attr_type->readonly(), |
| 968 |
secret => !$is_superlibrarian && $attr_type->secret(), |
| 959 |
category => $attr_type->authorised_value_category(), |
969 |
category => $attr_type->authorised_value_category(), |
| 960 |
category_code => $attr_type->category_code(), |
970 |
category_code => $attr_type->category_code(), |
| 961 |
mandatory => $attr_type->mandatory(), |
971 |
mandatory => $attr_type->mandatory(), |
|
Lines 966-980
sub patron_attributes_form {
Link Here
|
| 966 |
my $newentry = {%$entry}; |
976 |
my $newentry = {%$entry}; |
| 967 |
$newentry->{value} = $attr->{attribute}; |
977 |
$newentry->{value} = $attr->{attribute}; |
| 968 |
$newentry->{use_dropdown} = 0; |
978 |
$newentry->{use_dropdown} = 0; |
| 969 |
if ( $attr_type->authorised_value_category() ) { |
|
|
| 970 |
$newentry->{use_dropdown} = 1; |
| 971 |
$newentry->{auth_val_loop} = |
| 972 |
GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); |
| 973 |
} |
| 974 |
$i++; |
979 |
$i++; |
| 975 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
|
|
| 976 |
$newentry->{form_id} = "patron_attr_$i"; |
980 |
$newentry->{form_id} = "patron_attr_$i"; |
| 977 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
981 |
if ( !$is_superlibrarian && ( $attr_type->hidden() || $attr_type->secret() ) ) { |
|
|
982 |
push @hidden_attributes, $newentry; |
| 983 |
} else { |
| 984 |
if ( $attr_type->authorised_value_category() ) { |
| 985 |
$newentry->{use_dropdown} = 1; |
| 986 |
$newentry->{auth_val_loop} = |
| 987 |
GetAuthorisedValues( $attr_type->authorised_value_category(), $attr->{attribute} ); |
| 988 |
} |
| 989 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
| 990 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
| 991 |
} |
| 978 |
} |
992 |
} |
| 979 |
} else { |
993 |
} else { |
| 980 |
$i++; |
994 |
$i++; |
|
Lines 997-1003
sub patron_attributes_form {
Link Here
|
| 997 |
}; |
1011 |
}; |
| 998 |
} |
1012 |
} |
| 999 |
|
1013 |
|
| 1000 |
$template->param( patron_attributes => \@attribute_loop ); |
1014 |
$template->param( patron_attributes => \@attribute_loop, hidden_patron_attributes => \@hidden_attributes ); |
| 1001 |
|
1015 |
|
| 1002 |
} |
1016 |
} |
| 1003 |
|
1017 |
|