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 |
|