|
Lines 29-35
use CGI qw ( -utf8 );
Link Here
|
| 29 |
use C4::Auth qw( get_template_and_user haspermission ); |
29 |
use C4::Auth qw( get_template_and_user haspermission ); |
| 30 |
use C4::Context; |
30 |
use C4::Context; |
| 31 |
use C4::Output qw( output_and_exit output_and_exit_if_error output_html_with_http_headers ); |
31 |
use C4::Output qw( output_and_exit output_and_exit_if_error output_html_with_http_headers ); |
| 32 |
use C4::Koha qw( GetAuthorisedValues ); |
|
|
| 33 |
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages ); |
32 |
use C4::Letters qw( GetPreparedLetter EnqueueLetter SendQueuedMessages ); |
| 34 |
use C4::Form::MessagingPreferences; |
33 |
use C4::Form::MessagingPreferences; |
| 35 |
use Koha::AuthUtils; |
34 |
use Koha::AuthUtils; |
|
Lines 839-845
if ( C4::Context->preference('uppercasesurnames') ) {
Link Here
|
| 839 |
} |
838 |
} |
| 840 |
|
839 |
|
| 841 |
if ( C4::Context->preference('ExtendedPatronAttributes') ) { |
840 |
if ( C4::Context->preference('ExtendedPatronAttributes') ) { |
| 842 |
patron_attributes_form( $template, $extended_patron_attributes, $op ); |
841 |
Koha::Patron::Attribute::Types::patron_attributes_form( $template, $extended_patron_attributes, $op ); |
| 843 |
} |
842 |
} |
| 844 |
|
843 |
|
| 845 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
844 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
|
Lines 929-1006
sub parse_extended_patron_attributes {
Link Here
|
| 929 |
return \@attr; |
928 |
return \@attr; |
| 930 |
} |
929 |
} |
| 931 |
|
930 |
|
| 932 |
sub patron_attributes_form { |
|
|
| 933 |
my $template = shift; |
| 934 |
my $attributes = shift; |
| 935 |
my $op = shift; |
| 936 |
|
| 937 |
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 ); |
| 939 |
if ( $attribute_types->count == 0 ) { |
| 940 |
$template->param( no_patron_attribute_types => 1 ); |
| 941 |
return; |
| 942 |
} |
| 943 |
|
| 944 |
# map patron's attributes into a more convenient structure |
| 945 |
my %attr_hash = (); |
| 946 |
foreach my $attr (@$attributes) { |
| 947 |
push @{ $attr_hash{ $attr->{code} } }, $attr; |
| 948 |
} |
| 949 |
|
| 950 |
my @attribute_loop = (); |
| 951 |
my $i = 0; |
| 952 |
my %items_by_class; |
| 953 |
while ( my ($attr_type) = $attribute_types->next ) { |
| 954 |
my $entry = { |
| 955 |
class => $attr_type->class(), |
| 956 |
code => $attr_type->code(), |
| 957 |
description => $attr_type->description(), |
| 958 |
repeatable => $attr_type->repeatable(), |
| 959 |
category => $attr_type->authorised_value_category(), |
| 960 |
category_code => $attr_type->category_code(), |
| 961 |
mandatory => $attr_type->mandatory(), |
| 962 |
is_date => $attr_type->is_date(), |
| 963 |
}; |
| 964 |
if ( exists $attr_hash{ $attr_type->code() } ) { |
| 965 |
foreach my $attr ( @{ $attr_hash{ $attr_type->code() } } ) { |
| 966 |
my $newentry = {%$entry}; |
| 967 |
$newentry->{value} = $attr->{attribute}; |
| 968 |
$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++; |
| 975 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
| 976 |
$newentry->{form_id} = "patron_attr_$i"; |
| 977 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
| 978 |
} |
| 979 |
} else { |
| 980 |
$i++; |
| 981 |
my $newentry = {%$entry}; |
| 982 |
if ( $attr_type->authorised_value_category() ) { |
| 983 |
$newentry->{use_dropdown} = 1; |
| 984 |
$newentry->{auth_val_loop} = GetAuthorisedValues( $attr_type->authorised_value_category() ); |
| 985 |
} |
| 986 |
$newentry->{form_id} = "patron_attr_$i"; |
| 987 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
| 988 |
} |
| 989 |
} |
| 990 |
for my $class ( sort keys %items_by_class ) { |
| 991 |
my $av = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } ); |
| 992 |
my $lib = $av->count ? $av->next->lib : $class; |
| 993 |
push @attribute_loop, { |
| 994 |
class => $class, |
| 995 |
items => $items_by_class{$class}, |
| 996 |
lib => $lib, |
| 997 |
}; |
| 998 |
} |
| 999 |
|
| 1000 |
$template->param( patron_attributes => \@attribute_loop ); |
| 1001 |
|
| 1002 |
} |
| 1003 |
|
| 1004 |
sub add_guarantors { |
931 |
sub add_guarantors { |
| 1005 |
my ( $patron, $input ) = @_; |
932 |
my ( $patron, $input ) = @_; |
| 1006 |
|
933 |
|
| 1007 |
- |
|
|