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 834-840
if ( C4::Context->preference('uppercasesurnames') ) {
Link Here
|
834 |
} |
833 |
} |
835 |
|
834 |
|
836 |
if ( C4::Context->preference('ExtendedPatronAttributes') ) { |
835 |
if ( C4::Context->preference('ExtendedPatronAttributes') ) { |
837 |
patron_attributes_form( $template, $extended_patron_attributes, $op ); |
836 |
Koha::Patron::Attribute::Types::patron_attributes_form( $template, $extended_patron_attributes, $op ); |
838 |
} |
837 |
} |
839 |
|
838 |
|
840 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
839 |
if ( C4::Context->preference('EnhancedMessagingPreferences') ) { |
Lines 920-997
sub parse_extended_patron_attributes {
Link Here
|
920 |
return \@attr; |
919 |
return \@attr; |
921 |
} |
920 |
} |
922 |
|
921 |
|
923 |
sub patron_attributes_form { |
|
|
924 |
my $template = shift; |
925 |
my $attributes = shift; |
926 |
my $op = shift; |
927 |
|
928 |
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 ); |
930 |
if ( $attribute_types->count == 0 ) { |
931 |
$template->param( no_patron_attribute_types => 1 ); |
932 |
return; |
933 |
} |
934 |
|
935 |
# map patron's attributes into a more convenient structure |
936 |
my %attr_hash = (); |
937 |
foreach my $attr (@$attributes) { |
938 |
push @{ $attr_hash{ $attr->{code} } }, $attr; |
939 |
} |
940 |
|
941 |
my @attribute_loop = (); |
942 |
my $i = 0; |
943 |
my %items_by_class; |
944 |
while ( my ($attr_type) = $attribute_types->next ) { |
945 |
my $entry = { |
946 |
class => $attr_type->class(), |
947 |
code => $attr_type->code(), |
948 |
description => $attr_type->description(), |
949 |
repeatable => $attr_type->repeatable(), |
950 |
category => $attr_type->authorised_value_category(), |
951 |
category_code => $attr_type->category_code(), |
952 |
mandatory => $attr_type->mandatory(), |
953 |
is_date => $attr_type->is_date(), |
954 |
}; |
955 |
if ( exists $attr_hash{ $attr_type->code() } ) { |
956 |
foreach my $attr ( @{ $attr_hash{ $attr_type->code() } } ) { |
957 |
my $newentry = {%$entry}; |
958 |
$newentry->{value} = $attr->{attribute}; |
959 |
$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++; |
966 |
undef $newentry->{value} if ( $attr_type->unique_id() && $op eq 'duplicate' ); |
967 |
$newentry->{form_id} = "patron_attr_$i"; |
968 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
969 |
} |
970 |
} else { |
971 |
$i++; |
972 |
my $newentry = {%$entry}; |
973 |
if ( $attr_type->authorised_value_category() ) { |
974 |
$newentry->{use_dropdown} = 1; |
975 |
$newentry->{auth_val_loop} = GetAuthorisedValues( $attr_type->authorised_value_category() ); |
976 |
} |
977 |
$newentry->{form_id} = "patron_attr_$i"; |
978 |
push @{ $items_by_class{ $attr_type->class() } }, $newentry; |
979 |
} |
980 |
} |
981 |
for my $class ( sort keys %items_by_class ) { |
982 |
my $av = Koha::AuthorisedValues->search( { category => 'PA_CLASS', authorised_value => $class } ); |
983 |
my $lib = $av->count ? $av->next->lib : $class; |
984 |
push @attribute_loop, { |
985 |
class => $class, |
986 |
items => $items_by_class{$class}, |
987 |
lib => $lib, |
988 |
}; |
989 |
} |
990 |
|
991 |
$template->param( patron_attributes => \@attribute_loop ); |
992 |
|
993 |
} |
994 |
|
995 |
sub add_guarantors { |
922 |
sub add_guarantors { |
996 |
my ( $patron, $input ) = @_; |
923 |
my ( $patron, $input ) = @_; |
997 |
|
924 |
|
998 |
- |
|
|