diff --git a/application/Espo/Core/defaults/config.php b/application/Espo/Core/defaults/config.php index 0f8c3d26e5..e80273ba54 100644 --- a/application/Espo/Core/defaults/config.php +++ b/application/Espo/Core/defaults/config.php @@ -40,6 +40,7 @@ return array ( 'weekStart' => 0, 'thousandSeparator' => ',', 'decimalMark' => '.', + 'exportDelimiter' => ',', 'currencyList' => array ( ), diff --git a/application/Espo/Repositories/Preferences.php b/application/Espo/Repositories/Preferences.php index a4549cbef9..086c8f7be7 100644 --- a/application/Espo/Repositories/Preferences.php +++ b/application/Espo/Repositories/Preferences.php @@ -40,7 +40,8 @@ class Preferences extends \Espo\Core\ORM\Repository 'thousandSeparator', 'weekStart', 'timeZone', - 'language' + 'language', + 'exportDelimiter' ); protected $data = array(); diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json index 7e51145248..9eeb8a8490 100644 --- a/application/Espo/Resources/i18n/en_US/Global.json +++ b/application/Espo/Resources/i18n/en_US/Global.json @@ -18,6 +18,7 @@ "ScheduledJob": "Scheduled Jobs" }, "labels": { + "Misc": "Misc", "Merge": "Merge", "None": "None", "by": "by", diff --git a/application/Espo/Resources/i18n/en_US/Preferences.json b/application/Espo/Resources/i18n/en_US/Preferences.json index c8e42a7cf7..a67dae5202 100644 --- a/application/Espo/Resources/i18n/en_US/Preferences.json +++ b/application/Espo/Resources/i18n/en_US/Preferences.json @@ -17,7 +17,9 @@ "smtpUsername": "Username", "emailAddress": "Email", "smtpPassword": "Password", - "smtpEmailAddress": "Email Address" + "smtpEmailAddress": "Email Address", + + "exportDelimiter": "Export Delimiter" }, "links": { }, diff --git a/application/Espo/Resources/i18n/en_US/Settings.json b/application/Espo/Resources/i18n/en_US/Settings.json index 9159b2a5bc..295393abc4 100644 --- a/application/Espo/Resources/i18n/en_US/Settings.json +++ b/application/Espo/Resources/i18n/en_US/Settings.json @@ -25,7 +25,9 @@ "recordsPerPage": "Records Per Page", "recordsPerPageSmall": "Records Per Page (Small)", "tabList": "Tab List", - "quickCreateList": "Quick Create List" + "quickCreateList": "Quick Create List", + + "exportDelimiter": "Export Delimiter" }, "options": { "weekStart": { diff --git a/application/Espo/Resources/layouts/Preferences/detail.json b/application/Espo/Resources/layouts/Preferences/detail.json index 9178b3bac5..6ea25698d2 100644 --- a/application/Espo/Resources/layouts/Preferences/detail.json +++ b/application/Espo/Resources/layouts/Preferences/detail.json @@ -22,5 +22,11 @@ [{"name": "smtpUsername"}], [{"name": "smtpPassword"}] ] + }, + { + "label": "Misc", + "rows": [ + [{"name": "exportDelimiter"}] + ] } ] diff --git a/application/Espo/Resources/layouts/Settings/settings.json b/application/Espo/Resources/layouts/Settings/settings.json index 9e3f1d3d12..ea547202ee 100644 --- a/application/Espo/Resources/layouts/Settings/settings.json +++ b/application/Espo/Resources/layouts/Settings/settings.json @@ -4,7 +4,8 @@ "rows": [ [{"name": "useCache"}] ] - },{ + }, + { "label": "Locale", "rows": [ [{"name": "dateFormat"}, {"name": "timeZone"}], diff --git a/application/Espo/Resources/metadata/entityDefs/Preferences.json b/application/Espo/Resources/metadata/entityDefs/Preferences.json index a4455ea8c3..d3923f7797 100644 --- a/application/Espo/Resources/metadata/entityDefs/Preferences.json +++ b/application/Espo/Resources/metadata/entityDefs/Preferences.json @@ -74,6 +74,12 @@ "language": { "type": "enum", "default": "en_US" + }, + "exportDelimiter": { + "type": "varchar", + "default": ",", + "required": true, + "maxLength": 1 } } } diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json index d688055c99..2b0d242644 100644 --- a/application/Espo/Resources/metadata/entityDefs/Settings.json +++ b/application/Espo/Resources/metadata/entityDefs/Settings.json @@ -113,6 +113,12 @@ "type": "enum", "options": ["en_US"], "default": "en_US" + }, + "exportDelimiter": { + "type": "varchar", + "default": ",", + "required": true, + "maxLength": 1 } } } diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index 8cf39ac197..27aca22bf9 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -42,6 +42,7 @@ class Record extends \Espo\Core\Services\Base 'serviceFactory', 'fileManager', 'selectManagerFactory', + 'preferences' ); protected $entityName; @@ -104,6 +105,11 @@ class Record extends \Espo\Core\Services\Base return $this->injections['config']; } + protected function getPreferences() + { + return $this->injections['preferences']; + } + protected function getMetadata() { return $this->injections['metadata']; @@ -531,12 +537,17 @@ class Record extends \Espo\Core\Services\Base $row[$field] = $entity->get($field); } $arr[] = $row; + } + + $delimiter = $this->getPreferences()->get('exportDelimiter'); + if (empty($delimiter)) { + $delimiter = ','; } $fp = fopen('php://temp', 'w'); - fputcsv($fp, array_keys($arr[0])); + fputcsv($fp, array_keys($arr[0]), $delimiter); foreach ($arr as $row) { - fputcsv($fp, $row); + fputcsv($fp, $row, $delimiter); } rewind($fp); $csv = stream_get_contents($fp);