|
|
|
|
@ -545,43 +545,84 @@ |
|
|
|
|
|
|
|
|
|
<script src="{{ STATIC_URL }}js/lib/jquery.suggestions.min.js"></script> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
var paramsType, |
|
|
|
|
profileForm = $("#profile-form"), |
|
|
|
|
profileSearch = $("#searchAPI"), |
|
|
|
|
profileBossName = ("#id_boss_name", profileForm), |
|
|
|
|
profileBossSurname =$("#id_boss_surname", profileForm), |
|
|
|
|
profileBossMiddleName =$("#id_boss_midname", profileForm), |
|
|
|
|
profileInn = $("#id_inn", profileForm), |
|
|
|
|
profileKpp = $("#id_kpp", profileForm), |
|
|
|
|
profileOqrn = $("#id_ogrn", profileForm), |
|
|
|
|
profileAddress = $("#id_address", profileForm), |
|
|
|
|
profileLegalAddress = $("#id_jur_address", profileForm), |
|
|
|
|
profilePostalAddress = $("#id_real_address", profileForm); |
|
|
|
|
|
|
|
|
|
function getType() { |
|
|
|
|
var False = false, |
|
|
|
|
True = true, |
|
|
|
|
isOrg = {{ profile.is_org }}; |
|
|
|
|
return isOrg ? "LEGAL" : "INDIVIDUAL"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function join(arr) { |
|
|
|
|
var separator = arguments.length > 1 ? arguments[1] : ", "; |
|
|
|
|
return arr.filter(function(n){return n}).join(separator); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getPartOfPersonName(fullName, part) { |
|
|
|
|
if (!fullName) return; |
|
|
|
|
return fullName.split(' ')[part]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function showSuggestion(suggestion) { |
|
|
|
|
<script> |
|
|
|
|
var paramsType, |
|
|
|
|
profileForm = $("#profile-form"), |
|
|
|
|
profileSearch = $("#searchAPI"), |
|
|
|
|
profileBossName = $("#id_boss_name", profileForm), |
|
|
|
|
profileBossSurname =$("#id_boss_surname", profileForm), |
|
|
|
|
profileBossMiddleName =$("#id_boss_midname", profileForm), |
|
|
|
|
profileInn = $("#id_inn", profileForm), |
|
|
|
|
profileKpp = $("#id_kpp", profileForm), |
|
|
|
|
profileOqrn = $("#id_ogrn", profileForm), |
|
|
|
|
profileAddress = $("#id_address", profileForm), |
|
|
|
|
profileLegalAddress = $("#id_jur_address", profileForm), |
|
|
|
|
profilePostalAddress = $("#id_real_address", profileForm), |
|
|
|
|
profileInputs = []; |
|
|
|
|
|
|
|
|
|
function getType() { |
|
|
|
|
var False = false, |
|
|
|
|
True = true, |
|
|
|
|
isOrg = {{ profile.is_org }}; |
|
|
|
|
return isOrg ? "LEGAL" : "INDIVIDUAL"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var data = suggestion.data; |
|
|
|
|
if (!data) return; |
|
|
|
|
function join(arr) { |
|
|
|
|
var separator = arguments.length > 1 ? arguments[1] : ", "; |
|
|
|
|
return arr.filter(function(n){return n}).join(separator); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getPartOfPersonName(fullName, part) { |
|
|
|
|
if (!fullName) return; |
|
|
|
|
return fullName.split(' ')[part]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function confirmChangeDataPromise(inputArray) { |
|
|
|
|
var dlg_msg = $('#dialog-message'); |
|
|
|
|
var emptyInput = true; |
|
|
|
|
var defer = $.Deferred(); |
|
|
|
|
|
|
|
|
|
for (var i = inputArray.length - 1; i >= 0; --i) { |
|
|
|
|
|
|
|
|
|
if (inputArray[i].val()) { |
|
|
|
|
emptyInput = false; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!emptyInput) { |
|
|
|
|
dlg_msg.dialog({ |
|
|
|
|
title: 'Изменить данные', |
|
|
|
|
buttons: |
|
|
|
|
{'Да': |
|
|
|
|
function(){ |
|
|
|
|
defer.resolve(true); |
|
|
|
|
$(this).dialog('close'); |
|
|
|
|
}, 'Нет': |
|
|
|
|
function(){ |
|
|
|
|
defer.resolve(false); |
|
|
|
|
$(this).dialog('close'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}).html('Имеются уже заполненные данные, они будут изменены, продолжить?'); |
|
|
|
|
dlg_msg.dialog('open'); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
defer.resolve(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return defer.promise(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function cleanSearchInput() { |
|
|
|
|
profileSearch.val(''); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function changeDataInInputs(data) { |
|
|
|
|
|
|
|
|
|
if (paramsType ==="LEGAL") { |
|
|
|
|
|
|
|
|
|
if (data.name) |
|
|
|
|
profileOrgName.val(join([data.opf && data.opf.short || "", data.name.short || data.name.full], " ")); |
|
|
|
|
if (data.name && data.name.full) |
|
|
|
|
@ -627,23 +668,47 @@ |
|
|
|
|
profileInn.val(data.inn); |
|
|
|
|
profileKpp.val(data.kpp); |
|
|
|
|
profileOqrn.val(data.ogrn); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
profileSearch.val(''); |
|
|
|
|
function showSuggestion(suggestion) { |
|
|
|
|
|
|
|
|
|
var data = suggestion.data; |
|
|
|
|
if (!data) return; |
|
|
|
|
|
|
|
|
|
confirmChangeDataPromise(profileInputs).then(function (answer) { |
|
|
|
|
if (answer) { |
|
|
|
|
changeDataInInputs(data) |
|
|
|
|
} |
|
|
|
|
cleanSearchInput(); |
|
|
|
|
}) ; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
paramsType = getType(); |
|
|
|
|
|
|
|
|
|
if (paramsType === "LEGAL") { |
|
|
|
|
|
|
|
|
|
paramsType = getType(); |
|
|
|
|
var profileOrgName = $('#id_name', profileForm), |
|
|
|
|
profileOrgFullName = $('#id_full_name', profileForm), |
|
|
|
|
profileBossTitle = $('#id_boss_title', profileForm); |
|
|
|
|
|
|
|
|
|
profileInputs = [ |
|
|
|
|
profileOrgName, profileOrgFullName, profileInn, profileKpp, |
|
|
|
|
profileOqrn, profileBossName, profileBossSurname, profileBossMiddleName, |
|
|
|
|
profileAddress, profileLegalAddress |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
if (paramsType === "LEGAL") { |
|
|
|
|
var profileOrgName = $('#id_name', profileForm), |
|
|
|
|
profileOrgFullName = $('#id_full_name', profileForm), |
|
|
|
|
profileBossTitle = $('#id_boss_title', profileForm); |
|
|
|
|
} else { |
|
|
|
|
var profileRegDate = $('#id_ip_reg_date', profileForm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
profileSearch.suggestions({ |
|
|
|
|
var profileRegDate = $('#id_ip_reg_date', profileForm); |
|
|
|
|
|
|
|
|
|
profileInputs = [ |
|
|
|
|
profileBossName, profileBossSurname, profileBossMiddleName, |
|
|
|
|
profileInn, profileKpp, profileOqrn, profileRegDate, |
|
|
|
|
profileAddress, profileLegalAddress, profilePostalAddress |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
profileSearch.suggestions({ |
|
|
|
|
token: "{{ dadata_api_key }}", |
|
|
|
|
type: "PARTY", |
|
|
|
|
params: { |
|
|
|
|
@ -655,7 +720,6 @@ |
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
|
|
|
|
|
var bankForm = $("#bank-account-edit-form"), |
|
|
|
|
|