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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-1 / +8 lines)
Lines 907-913 Link Here
907
                                    [% IF loop.first %]<a name="patron-attr-start-[% pa.type.code | html %]"></a>[% END %]
907
                                    [% IF loop.first %]<a name="patron-attr-start-[% pa.type.code | html %]"></a>[% END %]
908
                                    [% form_id = 'patron-attr-' _ Math.int( Math.rand(1000000) ) %]
908
                                    [% form_id = 'patron-attr-' _ Math.int( Math.rand(1000000) ) %]
909
                                    <li data-category_code="[% pa.type.category_code | html %]">
909
                                    <li data-category_code="[% pa.type.category_code | html %]">
910
                                        <label for="[% form_id | html %]">[% pa.type.description | html %]: </label>
910
                                        [% IF pa.type.mandatory && pa.type.opac_editable %]
911
                                            <label for="[% form_id | html %]" class="required">[% pa.type.description | html %]: </label>
912
                                        [% ELSE %]
913
                                            <label for="[% form_id | html %]">[% pa.type.description | html %]: </label>
914
                                        [% END %]
911
                                        [% IF pa.type.opac_editable %]
915
                                        [% IF pa.type.opac_editable %]
912
                                            <input type="hidden" name="patron_attribute_code" value="[% pa.type.code | html %]" />
916
                                            <input type="hidden" name="patron_attribute_code" value="[% pa.type.code | html %]" />
913
                                            [% IF ( pa.type.authorised_value_category ) %]
917
                                            [% IF ( pa.type.authorised_value_category ) %]
Lines 928-933 Link Here
928
                                            [% ELSE %]
932
                                            [% ELSE %]
929
                                                <textarea rows="2" cols="30" id="[% form_id | html %]" name="patron_attribute_value">[% pa_value | html %]</textarea>
933
                                                <textarea rows="2" cols="30" id="[% form_id | html %]" name="patron_attribute_value">[% pa_value | html %]</textarea>
930
                                            [% END %]
934
                                            [% END %]
935
                                            [% IF pa.type.mandatory %]
936
                                                <span class="required">Required</span>
937
                                            [% END %]
931
                                            <a href="#" class="clear-attribute">Clear</a>
938
                                            <a href="#" class="clear-attribute">Clear</a>
932
                                            [% IF ( pa.type.repeatable ) %]
939
                                            [% IF ( pa.type.repeatable ) %]
933
                                            <a href="#" class="clone-attribute">New</a>
940
                                            <a href="#" class="clone-attribute">New</a>
(-)a/opac/opac-memberentry.pl (-4 / +18 lines)
Lines 123-129 if ( $action eq 'create' ) { Link Here
123
123
124
    %borrower = DelEmptyFields(%borrower);
124
    %borrower = DelEmptyFields(%borrower);
125
125
126
    my @empty_mandatory_fields = CheckMandatoryFields( \%borrower, $action );
126
    my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) );
127
    my $invalidformfields = CheckForInvalidFields(\%borrower);
127
    my $invalidformfields = CheckForInvalidFields(\%borrower);
128
    delete $borrower{'password2'};
128
    delete $borrower{'password2'};
129
    my $cardnumber_error_code;
129
    my $cardnumber_error_code;
Lines 259-265 elsif ( $action eq 'update' ) { Link Here
259
    $borrower{borrowernumber} = $borrowernumber;
259
    $borrower{borrowernumber} = $borrowernumber;
260
260
261
    my @empty_mandatory_fields =
261
    my @empty_mandatory_fields =
262
      CheckMandatoryFields( \%borrower, $action );
262
      ( CheckMandatoryFields( \%borrower, $action ), CheckMandatoryAttributes( \%borrower, $attributes ) );
263
    my $invalidformfields = CheckForInvalidFields(\%borrower);
263
    my $invalidformfields = CheckForInvalidFields(\%borrower);
264
264
265
    # Send back the data to the template
265
    # Send back the data to the template
Lines 412-417 sub CheckMandatoryFields { Link Here
412
    return @empty_mandatory_fields;
412
    return @empty_mandatory_fields;
413
}
413
}
414
414
415
sub CheckMandatoryAttributes{
416
    my ( $borrower, $attributes ) = @_;
417
418
    my @empty_mandatory_fields;
419
420
    for my $attribute (@$attributes ) {
421
        my $attr = Koha::Patron::Attribute::Types->find($attribute->{code});
422
        push @empty_mandatory_fields, $attribute->{code}
423
            if $attr && $attr->mandatory && $attribute->{attribute} =~ m|^\s*$|;
424
    }
425
426
    return @empty_mandatory_fields;
427
}
428
415
sub CheckForInvalidFields {
429
sub CheckForInvalidFields {
416
    my $borrower = shift;
430
    my $borrower = shift;
417
    my @invalidFields;
431
    my @invalidFields;
Lines 691-697 sub ParsePatronAttributes { Link Here
691
    }
705
    }
692
706
693
    foreach my $code ( keys %{$delete_candidates} ) {
707
    foreach my $code ( keys %{$delete_candidates} ) {
694
        if ( Koha::Patron::Attributes->search({
708
        if ( not $borrowernumber # self-registration
709
            || Koha::Patron::Attributes->search({
695
                borrowernumber => $borrowernumber, code => $code })->count > 0 )
710
                borrowernumber => $borrowernumber, code => $code })->count > 0 )
696
        {
711
        {
697
            push @attributes, { code => $code, attribute => '' }
712
            push @attributes, { code => $code, attribute => '' }
698
- 

Return to bug 22844