View | Details | Raw Unified | Return to bug 13757
Collapse All | Expand All

(-)a/opac/opac-memberentry.pl (-14 / +18 lines)
Lines 607-636 sub ParsePatronAttributes { Link Here
607
    my @codes  = $cgi->multi_param('patron_attribute_code');
607
    my @codes  = $cgi->multi_param('patron_attribute_code');
608
    my @values = $cgi->multi_param('patron_attribute_value');
608
    my @values = $cgi->multi_param('patron_attribute_value');
609
609
610
    my @editable_attribute_types
611
        = map { $_->code } Koha::Patron::Attribute::Types->search({ opac_editable => 1 });
612
610
    my $ea = each_array( @codes, @values );
613
    my $ea = each_array( @codes, @values );
611
    my @attributes;
614
    my @attributes;
612
615
613
    my $delete_candidates = {};
616
    my $delete_candidates = {};
614
617
615
    while ( my ( $code, $value ) = $ea->() ) {
618
    while ( my ( $code, $value ) = $ea->() ) {
616
        if ( !defined($value) or $value eq '' ) {
619
        if ( any { $_ eq $code } @editable_attribute_types ) {
617
            $delete_candidates->{$code} = 1
620
            # It is an editable attribute
618
                unless $delete_candidates->{$code};
621
            if ( !defined($value) or $value eq '' ) {
619
        }
622
                $delete_candidates->{$code} = 1
620
        else {
623
                    unless $delete_candidates->{$code};
621
            # we've got a value
624
            }
622
            push @attributes, { code => $code, value => $value };
625
            else {
626
                # we've got a value
627
                push @attributes, { code => $code, value => $value };
623
628
624
            # 'code' is no longer a delete candidate
629
                # 'code' is no longer a delete candidate
625
            delete $delete_candidates->{$code};
630
                delete $delete_candidates->{$code}
631
                    if defined $delete_candidates->{$code};
632
            }
626
        }
633
        }
627
    }
634
    }
628
635
629
    foreach my $code ( keys %{$delete_candidates} ) {
636
    foreach my $code ( keys %{$delete_candidates} ) {
630
        if (Koha::Patron::Attributes->search(
637
        if ( Koha::Patron::Attributes->search({
631
                { borrowernumber => $borrowernumber, code => $code }
638
                borrowernumber => $borrowernumber, code => $code })->count > 0 )
632
            )->count > 0
633
            )
634
        {
639
        {
635
            push @attributes, { code => $code, value => '' }
640
            push @attributes, { code => $code, value => '' }
636
                unless any { $_->{code} eq $code } @attributes;
641
                unless any { $_->{code} eq $code } @attributes;
637
- 

Return to bug 13757