|
|
|
|
@ -49,4 +49,68 @@ |
|
|
|
|
<script src="{{ STATIC_URL }}js/client.list.js"></script> |
|
|
|
|
|
|
|
|
|
<script src="{{ STATIC_URL }}js/paginator.js"></script> |
|
|
|
|
|
|
|
|
|
<script src="{{ STATIC_URL }}js/lib/jquery.suggestions.min.js"></script> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
|
|
|
|
|
var index, |
|
|
|
|
clientForm = $("#client-edit-form"), |
|
|
|
|
clientName = $("#id_name", clientForm), |
|
|
|
|
clientInn = $("#id_inn", clientForm), |
|
|
|
|
clientKpp = $("#id_kpp", clientForm), |
|
|
|
|
clientOqrn = $("#id_ogrn", clientForm), |
|
|
|
|
clientAddress = $("#id_address", clientForm), |
|
|
|
|
bankBic = $("#id_bank_bik", clientForm), |
|
|
|
|
bankFullName = $("#id_bank_name", clientForm), |
|
|
|
|
bankCorrespondentAccount = $("#id_bank_korr_account", clientForm), |
|
|
|
|
bankInputs = [bankBic, bankFullName, bankCorrespondentAccount], |
|
|
|
|
clientInputs = [clientName, clientInn, clientKpp, clientOqrn]; |
|
|
|
|
|
|
|
|
|
function join(arr) { |
|
|
|
|
var separator = arguments.length > 1 ? arguments[1] : ", "; |
|
|
|
|
return arr.filter(function(n){return n}).join(separator); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function showSuggestion(suggestion) { |
|
|
|
|
|
|
|
|
|
var data = suggestion.data; |
|
|
|
|
if (!data) return; |
|
|
|
|
if (data.type === "LEGAL"|| data.type === "INDIVIDUAL" ) { |
|
|
|
|
if (data.name) |
|
|
|
|
clientName.val(join([data.opf && data.opf.short || "", data.name.short || data.name.full], " ")); |
|
|
|
|
if (data.name && data.name.full) |
|
|
|
|
clientName.val(join([data.opf && data.opf.full || "", data.name.full], " ")); |
|
|
|
|
clientInn.val(data.inn); |
|
|
|
|
clientKpp.val(data.kpp); |
|
|
|
|
clientOqrn.val(data.ogrn); |
|
|
|
|
if (data.address) |
|
|
|
|
clientAddress.val(data.address.value); |
|
|
|
|
} else { |
|
|
|
|
bankFullName.val(data.name && data.name.full || ""); |
|
|
|
|
bankBic.val(data.bic); |
|
|
|
|
bankCorrespondentAccount.val(data.correspondent_account); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function fillInput(input, type) { |
|
|
|
|
|
|
|
|
|
input.suggestions({ |
|
|
|
|
token: "{{ dadata_api_key }}", |
|
|
|
|
type: type, |
|
|
|
|
count: 5, |
|
|
|
|
onSelect: showSuggestion |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (index = clientInputs.length - 1; index >= 0; --index) { |
|
|
|
|
fillInput(clientInputs[index], "PARTY" ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (index = bankInputs.length - 1; index >= 0; --index) { |
|
|
|
|
fillInput(bankInputs[index], "BANK" ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
{% endblock %} |
|
|
|
|
|