diff --git a/application/Espo/Core/Export/Xlsx.php b/application/Espo/Core/Export/Xlsx.php index 9ad8c896ae..1d51cdd7e1 100644 --- a/application/Espo/Core/Export/Xlsx.php +++ b/application/Espo/Core/Export/Xlsx.php @@ -434,6 +434,36 @@ class Xlsx extends \Espo\Core\Injectable $value .= $row[$name.'Country']; } $sheet->setCellValue("$col$rowNumber", $value); + } else if ($type == 'duration') { + if (!empty($row[$name])) { + $seconds = intval($row[$name]); + + $days = intval(floor($seconds / 86400)); + $seconds = $seconds - $days * 86400; + $hours = intval(floor($seconds / 3600)); + $seconds = $seconds - $hours * 3600; + $minutes = intval(floor($seconds / 60)); + + $value = ''; + if ($days) { + $value .= (string) $days . $this->getInjection('language')->translate('d', 'durationUnits'); + if ($minutes || $hours) { + $value .= ' '; + } + } + if ($hours) { + $value .= (string) $hours . $this->getInjection('language')->translate('h', 'durationUnits'); + if ($minutes) { + $value .= ' '; + } + } + if ($minutes) { + $value .= (string) $minutes . $this->getInjection('language')->translate('m', 'durationUnits'); + } + + $sheet->setCellValue("$col$rowNumber", $value); + } + } else { if (array_key_exists($name, $row)) { $sheet->setCellValue("$col$rowNumber", $row[$name]); diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json index 96331caffc..023846d728 100644 --- a/application/Espo/Resources/i18n/en_US/Global.json +++ b/application/Espo/Resources/i18n/en_US/Global.json @@ -437,6 +437,12 @@ "dayNamesShort": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], "dayNamesMin": ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] }, + "durationUnits": { + "d": "d", + "h": "h", + "m": "m", + "s": "s" + }, "options": { "salutationName": { "Mr.": "Mr.", diff --git a/client/src/views/fields/duration.js b/client/src/views/fields/duration.js index 1cd518fa32..d44792eb30 100644 --- a/client/src/views/fields/duration.js +++ b/client/src/views/fields/duration.js @@ -112,13 +112,13 @@ Espo.define('views/fields/duration', 'views/fields/enum', function (Dep) { var parts = []; if (days) { - parts.push(days + '' + this.getLanguage().translate('d')); + parts.push(days + '' + this.getLanguage().translate('d', 'durationUnits')); } if (hours) { - parts.push(hours + '' + this.getLanguage().translate('h')); + parts.push(hours + '' + this.getLanguage().translate('h', 'durationUnits')); } if (minutes) { - parts.push(minutes + '' + this.getLanguage().translate('m')); + parts.push(minutes + '' + this.getLanguage().translate('m', 'durationUnits')); } return parts.join(' '); },