import default phone number

This commit is contained in:
yuri
2019-04-25 12:14:42 +03:00
parent fa144847e5
commit 9cd2d1d21f
3 changed files with 25 additions and 7 deletions
@@ -228,9 +228,14 @@ class PhoneNumber extends \Espo\Core\ORM\Repositories\RDB
foreach ($phoneNumberData as $row) {
$key = trim($row->phoneNumber);
if (empty($key)) continue;
if (isset($row->type)) {
$type = $row->type;
} else {
$type = $this->getMetadata()->get(['entityDefs', $entity->getEntityType(), 'fields', 'phoneNumber', 'defaultType']);
}
$hash->$key = [
'primary' => $row->primary ? true : false,
'type' => $row->type,
'type' => $type,
'optOut' => !empty($row->optOut) ? true : false,
'invalid' => !empty($row->invalid) ? true : false,
];
+17 -5
View File
@@ -599,6 +599,18 @@ class Import extends \Espo\Services\Record
continue;
}
if ($attribute === 'phoneNumber' && $type === 'phone') {
$phoneNumberData = $entity->get('phoneNumberData');
$phoneNumberData = $phoneNumberData ?? [];
$o = (object) [
'phoneNumber' => $value,
'primary' => true,
];
$phoneNumberData[] = $o;
$entity->set('phoneNumberData', $phoneNumberData);
continue;
}
if ($type == 'personName') {
$firstNameAttribute = 'first' . ucfirst($attribute);
$lastNameAttribute = 'last' . ucfirst($attribute);
@@ -628,12 +640,12 @@ class Import extends \Espo\Services\Record
}
$type = str_replace('phoneNumber', '', $attribute);
$type = str_replace('_', ' ', $type);
$o = (object) [];
$o->phoneNumber = $value;
$o->type = $type;
$o->primary = $isPrimary;
$o = (object) [
'phoneNumber' => $value,
'type' => $type,
'primary' => $isPrimary,
];
$phoneNumberData[] = $o;
$entity->set('phoneNumberData', $phoneNumberData);
}
+2 -1
View File
@@ -200,7 +200,8 @@ Espo.define('views/import/step2', 'view', function (Dep) {
}
if (d.type == 'phone') {
(this.getMetadata().get('entityDefs.' + this.scope + '.fields.' + field + '.typeList' ) || []).map(function (item) {
attributeList.push(field);
(this.getMetadata().get('entityDefs.' + this.scope + '.fields.' + field + '.typeList') || []).map(function (item) {
return item.replace(/\s/g, '_');
}, this).forEach(function (item) {
attributeList.push(field + Espo.Utils.upperCaseFirst(item));