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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-3 / +3 lines)
Lines 1929-1938 legend:hover { Link Here
1929
            });
1929
            });
1930
        [% END %]
1930
        [% END %]
1931
        $("#guarantor_template").hide();
1931
        $("#guarantor_template").hide();
1932
        var guarantor_attributes;
1932
        var prefill_fields;
1933
        var to_api_mapping;
1933
        var to_api_mapping;
1934
        [% IF guarantor_attributes %]
1934
        [% IF prefill_fields %]
1935
            guarantor_attributes = [% To.json(guarantor_attributes) %];
1935
            prefill_fields = [% To.json(prefill_fields)%];
1936
        [% END %]
1936
        [% END %]
1937
        [% IF to_api_mapping %]
1937
        [% IF to_api_mapping %]
1938
            to_api_mapping = [% To.json(to_api_mapping) %];
1938
            to_api_mapping = [% To.json(to_api_mapping) %];
(-)a/koha-tmpl/intranet-tmpl/prog/js/members.js (-19 / +7 lines)
Lines 122-147 function select_user(borrowernumber, borrower, relationship) { Link Here
122
            fieldset.find('.new_guarantor_relationship').val(relationship);
122
            fieldset.find('.new_guarantor_relationship').val(relationship);
123
        }
123
        }
124
124
125
        if(guarantor_attributes && to_api_mapping) {
125
        if ( prefill_fields && to_api_mapping) {
126
            $('#saverecord').prop('disabled', true);
126
            for (let i = 0; i < parseInt(prefill_fields.length, 10); i++) {
127
            $.ajax({
127
                let field_name = prefill_fields[i];
128
                url: '/api/v1/patrons/'+borrowernumber,
128
                let attribute = to_api_mapping[field_name] || field_name;
129
                method: "GET",
129
                if ( borrower[attribute] != null && document.forms.entryform[field_name] && document.forms.entryform[field_name].value == "" ) {
130
                dataType: 'json',
130
                    document.forms.entryform[field_name].value = borrower[attribute];
131
                success: function(data){
132
                    for (let i = 0; i < parseInt(guarantor_attributes.length, 10); i++) {
133
                        let attribute = guarantor_attributes[i];
134
                        let key_data = to_api_mapping[attribute] || attribute;
135
                        if(data[key_data] != null && attribute in document.forms.entryform && document.forms.entryform[attribute].value == ""){
136
                            document.forms.entryform[attribute].value = data[key_data];
137
                        }
138
                    }
139
                    $('#saverecord').prop('disabled', false);
140
                },
141
                error:function(){
142
                    $('#saverecord').prop('disabled', false);
143
                }
131
                }
144
            });
132
            }
145
        }
133
        }
146
    }
134
    }
147
135
(-)a/members/memberentry.pl (-2 / +1 lines)
Lines 598-604 if (C4::Context->preference("IndependentBranches")) { Link Here
598
my $prefillguarantorfields=C4::Context->preference("PrefillGuaranteeField");
598
my $prefillguarantorfields=C4::Context->preference("PrefillGuaranteeField");
599
my @prefill_fields=split(/\,/,$prefillguarantorfields);
599
my @prefill_fields=split(/\,/,$prefillguarantorfields);
600
$template->param(
600
$template->param(
601
    guarantor_attributes => \@prefill_fields,
601
    prefill_fields => \@prefill_fields,
602
    to_api_mapping => Koha::Patron->new->to_api_mapping
602
    to_api_mapping => Koha::Patron->new->to_api_mapping
603
 );
603
 );
604
604
605
- 

Return to bug 26597