diff --git a/application/Espo/Core/ORM/Entity.php b/application/Espo/Core/ORM/Entity.php index a163004617..b6f80fbe1d 100644 --- a/application/Espo/Core/ORM/Entity.php +++ b/application/Espo/Core/ORM/Entity.php @@ -218,14 +218,43 @@ class Entity extends \Espo\ORM\Entity $this->set($field . 'Name', $entityName); } + public function getLinkMultipleName($field, $id) + { + $namesAttribute = $field . 'Names'; + if (!$this->has($namesAttribute)) return; + + $names = $this->get($namesAttribute); + if ($names instanceof \StdClass) { + if (isset($names->$id)) { + if (isset($names->$id)) { + return $names->$id; + } + } + } + } + + public function setLinkMultipleName($field, $id, $value) + { + $namesAttribute = $field . 'Names'; + if (!$this->has($namesAttribute)) return; + + $object = $this->get($namesAttribute); + if (!isset($object) || !($object instanceof \StdClass)) { + $object = (object) []; + } + + $object->$id = $value; + $this->set($namesAttribute, $object); + } + public function getLinkMultipleColumn($field, $column, $id) { - $columnsField = $field . 'Columns'; + $columnsAttribute = $field . 'Columns'; - if (!$this->has($columnsField)) { + if (!$this->has($columnsAttribute)) { return; } - $columns = $this->get($columnsField); + $columns = $this->get($columnsAttribute); if ($columns instanceof \StdClass) { if (isset($columns->$id)) { if (isset($columns->$id->$column)) { @@ -237,11 +266,11 @@ class Entity extends \Espo\ORM\Entity public function setLinkMultipleColumn($field, $column, $id, $value) { - $columnsField = $field . 'Columns'; - if (!$this->hasAttribute($columnsField)) { + $columnsAttribute = $field . 'Columns'; + if (!$this->hasAttribute($columnsAttribute)) { return; } - $object = $this->get($columnsField); + $object = $this->get($columnsAttribute); if (!isset($object) || !($object instanceof \StdClass)) { $object = (object) []; } @@ -253,35 +282,35 @@ class Entity extends \Espo\ORM\Entity } $object->$id->$column = $value; - $this->set($columnsField, $object); + $this->set($columnsAttribute, $object); } public function setLinkMultipleIdList($field, array $idList) { - $idsField = $field . 'Ids'; - $this->set($idsField, $idList); + $idsAttribute = $field . 'Ids'; + $this->set($idsAttribute, $idList); } public function addLinkMultipleId($field, $id) { - $idsField = $field . 'Ids'; + $idsAttribute = $field . 'Ids'; - if (!$this->hasAttribute($idsField)) return; + if (!$this->hasAttribute($idsAttribute)) return; - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { if (!$this->isNew()) { $this->loadLinkMultipleField($field); } else { - $this->set($idsField, []); + $this->set($idsAttribute, []); } } - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { return; } - $idList = $this->get($idsField); + $idList = $this->get($idsAttribute); if (!in_array($id, $idList)) { $idList[] = $id; - $this->set($idsField, $idList); + $this->set($idsAttribute, $idList); } } @@ -300,16 +329,16 @@ class Entity extends \Espo\ORM\Entity public function getLinkMultipleIdList($field) { - $idsField = $field . 'Ids'; + $idsAttribute = $field . 'Ids'; - if (!$this->hasAttribute($idsField)) return null; + if (!$this->hasAttribute($idsAttribute)) return null; - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { if (!$this->isNew()) { $this->loadLinkMultipleField($field); } } - $valueList = $this->get($idsField); + $valueList = $this->get($idsAttribute); if (empty($valueList)) { return []; } @@ -318,21 +347,21 @@ class Entity extends \Espo\ORM\Entity public function hasLinkMultipleId($field, $id) { - $idsField = $field . 'Ids'; + $idsAttribute = $field . 'Ids'; - if (!$this->hasAttribute($idsField)) return null; + if (!$this->hasAttribute($idsAttribute)) return null; - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { if (!$this->isNew()) { $this->loadLinkMultipleField($field); } } - if (!$this->has($idsField)) { + if (!$this->has($idsAttribute)) { return; } - $idList = $this->get($idsField); + $idList = $this->get($idsAttribute); if (in_array($id, $idList)) { return true; } diff --git a/application/Espo/Modules/Crm/Repositories/Meeting.php b/application/Espo/Modules/Crm/Repositories/Meeting.php index 1458444879..3f17dacfaa 100644 --- a/application/Espo/Modules/Crm/Repositories/Meeting.php +++ b/application/Espo/Modules/Crm/Repositories/Meeting.php @@ -97,41 +97,24 @@ class Meeting extends \Espo\Core\Repositories\Event parent::beforeSave($entity, $options); - $assignedUserId = $entity->get('assignedUserId'); - if ($assignedUserId) { - if ($entity->has('usersIds')) { - $usersIds = $entity->get('usersIds'); - if (!is_array($usersIds)) { - $usersIds = []; - } - if (!in_array($assignedUserId, $usersIds)) { - $usersIds[] = $assignedUserId; - $entity->set('usersIds', $usersIds); - $hash = $entity->get('usersNames'); - if ($hash instanceof \StdClass) { - $hash->$assignedUserId = $entity->get('assignedUserName'); - $entity->set('usersNames', $hash); - } - } - } else { + if ($entity->hasLinkMultipleField('assignedUsers')) { + $assignedUserIdList = $entity->getLinkMultipleIdList('assignedUsers'); + foreach ($assignedUserIdList as $assignedUserId) { $entity->addLinkMultipleId('users', $assignedUserId); + $entity->setLinkMultipleName('users', $assignedUserId, $entity->getLinkMultipleName('assignedUsers', $assignedUserId)); } - if ($entity->isNew()) { - $currentUserId = $this->getEntityManager()->getUser()->id; - if (isset($usersIds) && in_array($currentUserId, $usersIds)) { - $usersColumns = $entity->get('usersColumns'); - if (empty($usersColumns)) { - $usersColumns = new \StdClass(); - } - if ($usersColumns instanceof \StdClass) { - if (empty($usersColumns->$currentUserId) || !($usersColumns->$currentUserId instanceof \StdClass)) { - $usersColumns->$currentUserId = new \StdClass(); - } - if (empty($usersColumns->$currentUserId->status)) { - $usersColumns->$currentUserId->status = 'Accepted'; - } - } - } + } else { + $assignedUserId = $entity->get('assignedUserId'); + if ($assignedUserId) { + $entity->addLinkMultipleId('users', $assignedUserId); + $entity->setLinkMultipleName('users', $assignedUserId, $entity->get('assignedUserName')); + } + } + + if ($entity->isNew()) { + $currentUserId = $this->getEntityManager()->getUser()->id; + if ($entity->hasLinkMultipleId('users', $currentUserId)) { + $entity->setLinkMultipleColumn('users', 'status', $currentUserId, 'Accepted'); } } } diff --git a/application/Espo/Resources/i18n/en_US/Settings.json b/application/Espo/Resources/i18n/en_US/Settings.json index 1e000bf961..4dcbd73f9d 100644 --- a/application/Espo/Resources/i18n/en_US/Settings.json +++ b/application/Espo/Resources/i18n/en_US/Settings.json @@ -107,6 +107,7 @@ "cleanupDeletedRecords": "Clean up deleted records", "addressCountryList": "Address Country Autocomplete List", "addressCityList": "Address City Autocomplete List", + "addressStateList": "Address State Autocomplete List", "fiscalYearShift": "Fiscal Year Start", "jobRunInParallel": "Jobs Run in Parallel", "jobMaxPortion": "Jobs Max Portion", diff --git a/application/Espo/Resources/i18n/fa_IR/Global.json b/application/Espo/Resources/i18n/fa_IR/Global.json index 951d801c58..ef22459bae 100644 --- a/application/Espo/Resources/i18n/fa_IR/Global.json +++ b/application/Espo/Resources/i18n/fa_IR/Global.json @@ -367,30 +367,9 @@ "assignSelf": "{user} خود اختصاص {entityType} {entity}" }, "lists": { - "dayNames": [ - "یکشنبه", - "دوشنبه", - "سه شنبه", - "چهارشنبه", - " پنجشنبه", - "جمعه شنبه" - ], - "dayNamesShort": [ - "یکشنبه", - "دوشنبه", - "سه شنبه", - "چهارشنبه", - " پنجشنبه", - "جمعه شنبه" - ], - "dayNamesMin": [ - "یکشنبه", - "دوشنبه", - "سه شنبه", - "چهارشنبه", - " پنجشنبه", - "جمعه شنبه" - ] + "dayNames": [ "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", " پنجشنبه", "جمعه", "شنبه" ], + "dayNamesShort": [ "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", " پنجشنبه", "جمعه", "شنبه" ], + "dayNamesMin": [ "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", " پنجشنبه", "جمعه", "شنبه" ] }, "options": { "salutationName": { diff --git a/application/Espo/Resources/layouts/Settings/settings.json b/application/Espo/Resources/layouts/Settings/settings.json index a23128c4b7..57535a135d 100644 --- a/application/Espo/Resources/layouts/Settings/settings.json +++ b/application/Espo/Resources/layouts/Settings/settings.json @@ -18,7 +18,8 @@ [{"name": "timeFormat"}, {"name": "thousandSeparator"}], [{"name": "fiscalYearShift"}, {"name": "decimalMark"}], [{"name": "addressFormat"}, {"name": "addressPreview"}], - [{"name": "addressCountryList"}, {"name": "addressCityList"}] + [{"name": "addressCountryList"}, {"name": "addressCityList"}], + [{"name": "addressStateList"}, false] ] }, { diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json index 284586e63e..bb4606dbc4 100644 --- a/application/Espo/Resources/metadata/entityDefs/Settings.json +++ b/application/Espo/Resources/metadata/entityDefs/Settings.json @@ -508,6 +508,9 @@ "addressCityList": { "type": "multiEnum" }, + "addressStateList": { + "type": "multiEnum" + }, "jobRunInParallel": { "type": "bool", "tooltip": true diff --git a/application/Espo/Resources/metadata/fields/address.json b/application/Espo/Resources/metadata/fields/address.json index c25a508dc3..157ec02d5a 100644 --- a/application/Espo/Resources/metadata/fields/address.json +++ b/application/Espo/Resources/metadata/fields/address.json @@ -6,30 +6,36 @@ "country", "postalCode" ], - "fields":{ - "street":{ + "fields": { + "street": { "type": "text", "maxLength": 255, "dbType": "varchar" }, - "city":{ + "city": { "type":"varchar", "trim": true, + "maxLength": 255, "view": "views/fields/address-city", "customizationOptionsDisabled": true }, - "state":{ - "type":"varchar", - "trim": true - }, - "country":{ + "state": { "type":"varchar", "trim": true, + "maxLength": 255, + "view": "views/fields/address-state", + "customizationOptionsDisabled": true + }, + "country": { + "type":"varchar", + "trim": true, + "maxLength": 255, "view": "views/fields/address-country", "customizationOptionsDisabled": true }, - "postalCode":{ + "postalCode": { "type":"varchar", + "maxLength": 40, "trim": true }, "map": { diff --git a/client/res/layout-types/list-row-expanded.tpl b/client/res/layout-types/list-row-expanded.tpl index b75c4d367b..d1dd5a57b6 100644 --- a/client/res/layout-types/list-row-expanded.tpl +++ b/client/res/layout-types/list-row-expanded.tpl @@ -5,10 +5,7 @@ <% } %> <% _.each(layout.rows, function (row, key) { %> -
<% }); %> - diff --git a/client/res/templates/fields/address/edit-1.tpl b/client/res/templates/fields/address/edit-1.tpl index ad84714eae..9dfe02b86c 100644 --- a/client/res/templates/fields/address/edit-1.tpl +++ b/client/res/templates/fields/address/edit-1.tpl @@ -1,13 +1,13 @@ - +