From aab0941587b510e2745ef1d74af88c265d0b8444 Mon Sep 17 00:00:00 2001 From: Dmitriy Shesterkin Date: Wed, 17 May 2017 08:31:07 +0300 Subject: [PATCH] add short name at individual entrepreneur in form add partner --- src/dokumentor/static/js/client/search-external-api.js | 8 +++++++- src/dokumentor/static/js/dialogs.js | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/dokumentor/static/js/client/search-external-api.js b/src/dokumentor/static/js/client/search-external-api.js index e8c01a2..c3d488e 100644 --- a/src/dokumentor/static/js/client/search-external-api.js +++ b/src/dokumentor/static/js/client/search-external-api.js @@ -60,7 +60,7 @@ $(document).ready(function() { function changeDataInInputs(data) { if (data.type === "LEGAL"|| data.type === "INDIVIDUAL" ) { - //console.log(data); + console.log(data); if (data.name) { clientName.val(join([data.opf && data.opf.short || "", data.name.short || data.name.full], " ")); clientNameShort.val(data.name.short); @@ -83,6 +83,12 @@ $(document).ready(function() { contactName.val(getShortPersonName(data.name.full)); } + // fill self contact name for individual entrepreneur + if (data.type === "INDIVIDUAL" && data.name && data.name.full) { + var resultName = ''; + clientNameShort.val(getShortPersonNameWithOpf(data.name.full, data.opf.short)); + } + clientInn.val(data.inn); clientKpp.val(data.kpp); clientOqrn.val(data.ogrn); diff --git a/src/dokumentor/static/js/dialogs.js b/src/dokumentor/static/js/dialogs.js index b5ca2a4..031933f 100644 --- a/src/dokumentor/static/js/dialogs.js +++ b/src/dokumentor/static/js/dialogs.js @@ -173,6 +173,15 @@ function getShortPersonName(fullName) { return getPartOfPersonName(fullName,0) + ' ' + getPartOfPersonName(fullName,1)[0] + '.' + getPartOfPersonName(fullName,2)[0] + '.'; } +function getShortPersonNameWithOpf(fullName, opf) { + if (!fullName) return; + if (opf) { + return opf + ' ' + getPartOfPersonName(fullName,0) + ' ' + getPartOfPersonName(fullName,1)[0] + '.' + getPartOfPersonName(fullName,2)[0] + '.'; + } else { + return 'ИП' + ' ' + getPartOfPersonName(fullName,0) + ' ' + getPartOfPersonName(fullName,1)[0] + '.' + getPartOfPersonName(fullName,2)[0] + '.'; + } +} + function expandObject(obj, width, align) { obj["templateColWidth"] = width;