Lines 415-420
if ($op eq 'save' || $op eq 'insert'){
Link Here
|
415 |
} |
415 |
} |
416 |
} |
416 |
} |
417 |
} |
417 |
} |
|
|
418 |
elsif ( $borrowernumber ) { |
419 |
$extended_patron_attributes = Koha::Patrons->find($borrowernumber)->extended_attributes->unblessed; |
420 |
} |
418 |
|
421 |
|
419 |
if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save'|| $op eq 'duplicate') and ($step == 0 or $step == 3 )){ |
422 |
if ( ($op eq 'modify' || $op eq 'insert' || $op eq 'save'|| $op eq 'duplicate') and ($step == 0 or $step == 3 )){ |
420 |
unless ($newdata{'dateexpiry'}){ |
423 |
unless ($newdata{'dateexpiry'}){ |
Lines 767-774
foreach (qw(dateenrolled dateexpiry dateofbirth)) {
Link Here
|
767 |
$template->param( $_ => $data{$_}); |
770 |
$template->param( $_ => $data{$_}); |
768 |
} |
771 |
} |
769 |
|
772 |
|
770 |
if (C4::Context->preference('ExtendedPatronAttributes')) { |
773 |
if ( C4::Context->preference('ExtendedPatronAttributes') ) { |
771 |
patron_attributes_form($template, $borrowernumber, $op); |
774 |
patron_attributes_form( $template, $extended_patron_attributes, $op ); |
772 |
} |
775 |
} |
773 |
|
776 |
|
774 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
777 |
if (C4::Context->preference('EnhancedMessagingPreferences')) { |
Lines 861-867
sub parse_extended_patron_attributes {
Link Here
|
861 |
|
864 |
|
862 |
sub patron_attributes_form { |
865 |
sub patron_attributes_form { |
863 |
my $template = shift; |
866 |
my $template = shift; |
864 |
my $borrowernumber = shift; |
867 |
my $attributes = shift; |
865 |
my $op = shift; |
868 |
my $op = shift; |
866 |
|
869 |
|
867 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
870 |
my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; |
Lines 870-885
sub patron_attributes_form {
Link Here
|
870 |
$template->param(no_patron_attribute_types => 1); |
873 |
$template->param(no_patron_attribute_types => 1); |
871 |
return; |
874 |
return; |
872 |
} |
875 |
} |
873 |
my @attributes; |
|
|
874 |
if ( $borrowernumber ) { |
875 |
my $patron = Koha::Patrons->find($borrowernumber); # Already fetched but outside of this sub |
876 |
@attributes = $patron->extended_attributes->as_list; # FIXME Must be improved! |
877 |
} |
878 |
|
876 |
|
879 |
# map patron's attributes into a more convenient structure |
877 |
# map patron's attributes into a more convenient structure |
880 |
my %attr_hash = (); |
878 |
my %attr_hash = (); |
881 |
foreach my $attr (@attributes) { |
879 |
foreach my $attr (@$attributes) { |
882 |
push @{ $attr_hash{$attr->code} }, $attr; |
880 |
push @{ $attr_hash{$attr->{code}} }, $attr; |
883 |
} |
881 |
} |
884 |
|
882 |
|
885 |
my @attribute_loop = (); |
883 |
my @attribute_loop = (); |
Lines 897-912
sub patron_attributes_form {
Link Here
|
897 |
if (exists $attr_hash{$attr_type->code()}) { |
895 |
if (exists $attr_hash{$attr_type->code()}) { |
898 |
foreach my $attr (@{ $attr_hash{$attr_type->code()} }) { |
896 |
foreach my $attr (@{ $attr_hash{$attr_type->code()} }) { |
899 |
my $newentry = { %$entry }; |
897 |
my $newentry = { %$entry }; |
900 |
$newentry->{value} = $attr->attribute; |
898 |
$newentry->{value} = $attr->{attribute}; |
901 |
$newentry->{use_dropdown} = 0; |
899 |
$newentry->{use_dropdown} = 0; |
902 |
if ($attr_type->authorised_value_category()) { |
900 |
if ($attr_type->authorised_value_category()) { |
903 |
$newentry->{use_dropdown} = 1; |
901 |
$newentry->{use_dropdown} = 1; |
904 |
$newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category(), $attr->attribute); |
902 |
$newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category(), $attr->{attribute}); |
905 |
} |
903 |
} |
906 |
$i++; |
904 |
$i++; |
907 |
undef $newentry->{value} if ($attr_type->unique_id() && $op eq 'duplicate'); |
905 |
undef $newentry->{value} if ($attr_type->unique_id() && $op eq 'duplicate'); |
908 |
$newentry->{form_id} = "patron_attr_$i"; |
906 |
$newentry->{form_id} = "patron_attr_$i"; |
909 |
push @{$items_by_class{$attr_type->class()}}, $newentry; |
907 |
push @{$items_by_class{$attr_type->{class}}}, $newentry; |
910 |
} |
908 |
} |
911 |
} else { |
909 |
} else { |
912 |
$i++; |
910 |
$i++; |
913 |
- |
|
|