invitation dateStartFull

This commit is contained in:
Yuri Kuznetsov
2025-01-19 10:34:15 +02:00
parent 400a92c2a3
commit c6f9250d85
11 changed files with 54 additions and 12 deletions
@@ -47,4 +47,9 @@ class Preferences extends \Espo\Core\ORM\Entity
{
return $this->get('timeZone');
}
public function getLanguage(): ?string
{
return $this->get('language');
}
}
@@ -66,6 +66,7 @@ class Invitations
/**
* Some dependencies are unused to keep backward compatibility.
* @todo Revise.
*/
public function __construct(
private EntityManager $entityManager,
@@ -75,6 +76,7 @@ class Invitations
private TemplateFileManager $templateFileManager,
private HtmlizerFactory $htmlizerFactory,
private ApplicationConfig $applicationConfig,
private DateTimeUtil $dateTime,
) {}
/**
@@ -282,7 +284,10 @@ class Invitations
$data['entityType'] = $this->language->translateLabel($entity->getEntityType(), 'scopeNames');
$data['entityTypeLowerFirst'] = Util::mbLowerCaseFirst($data['entityType']);
$data['timeZone'] = $this->getTimeZone($invitee);
[$timeZone, $language] = $this->getTimeZoneAndLanguage($invitee);
$data['timeZone'] = $timeZone;
$data['dateStartFull'] = $this->prepareDateStartFull($entity, $timeZone, $language);
return $data;
}
@@ -340,9 +345,13 @@ class Invitations
return $attendees;
}
private function getTimeZone(Entity $invitee): string
/**
* @return array{string, string}
*/
private function getTimeZoneAndLanguage(Entity $invitee): array
{
$timeZone = $this->applicationConfig->getTimeZone();
$language = $this->applicationConfig->getLanguage();
if ($invitee instanceof User) {
$preferences = $this->entityManager
@@ -352,8 +361,36 @@ class Invitations
if ($preferences && $preferences->getTimeZone()) {
$timeZone = $preferences->getTimeZone();
}
if ($preferences && $preferences->getLanguage()) {
$language = $preferences->getLanguage();
}
}
return $timeZone;
return [$timeZone, $language];
}
/**
* @todo Take into account the invitees time format if a user.
*/
private function prepareDateStartFull(Entity $entity, string $timeZone, string $language): ?string
{
$format = "dddd, MMMM Do, YYYY";
if ($entity->get('dateStartDate')) {
$value = $entity->get('dateStartDate');
return $this->dateTime->convertSystemDate($value, $format, $language);
}
$value = $entity->get('dateStart');
if (!$value) {
return null;
}
$format = $this->applicationConfig->getTimeFormat() . ", " . $format;
return $this->dateTime->convertSystemDateTime($value, $timeZone, $format, $language);
}
}
@@ -1,5 +1,5 @@
<p>Betreff: {{name}}</p>
<p>Start: {{#if isAllDay}}{{dateStartDate}}{{else}}{{dateStart}} ({{timeZone}}){{/if}}</p>
<p>Start: {{#if isAllDay}}{{dateStartFull}}{{else}}{{dateStartFull}} ({{timeZone}}){{/if}}</p>
{{#if isUser}}
<p><a href="{{recordUrl}}">Eintrag öffnen</a></p>
{{/if}}
@@ -1,5 +1,5 @@
<p>Subject: {{name}}</p>
<p>Start: {{#if isAllDay}}{{dateStartDate}}{{else}}{{dateStart}} ({{timeZone}}){{/if}}</p>
<p>Start: {{#if isAllDay}}{{dateStartFull}}{{else}}{{dateStartFull}} ({{timeZone}}){{/if}}</p>
{{#if isUser}}
<p><a href="{{recordUrl}}">View record</a></p>
{{/if}}
@@ -1,5 +1,5 @@
<p>Betreff: {{name}}</p>
<p>Beginn: {{#if isAllDay}}{{dateStartDate}}{{else}}{{dateStart}} ({{timeZone}}){{/if}}</p>
<p>Beginn: {{#if isAllDay}}{{dateStartFull}}{{else}}{{dateStartFull}} ({{timeZone}}){{/if}}</p>
{{#if isUser}}
{{#if description}}
<p>{{{description}}}</p>
@@ -1,5 +1,5 @@
<p>Subject: {{name}}</p>
<p>Start: {{#if isAllDay}}{{dateStartDate}}{{else}}{{dateStart}} ({{timeZone}}){{/if}}</p>
<p>Start: {{#if isAllDay}}{{dateStartFull}}{{else}}{{dateStartFull}} ({{timeZone}}){{/if}}</p>
{{#if isUser}}
{{#if description}}
<p>{{{description}}}</p>
@@ -1,5 +1,5 @@
<p>Asunto: {{name}}</p>
<p>Comienzo: {{#if isAllDay}}{{dateStartDate}}{{else}}{{dateStart}} ({{timeZone}}){{/if}}</p>
<p>Comienzo: {{#if isAllDay}}{{dateStartFull}}{{else}}{{dateStartFull}} ({{timeZone}}){{/if}}</p>
{{#if isUser}}
{{#if description}}
<p>{{{description}}}</p>
@@ -1,5 +1,5 @@
<p>Objet: {{name}}</p>
<p>Débute à: {{#if isAllDay}}{{dateStartDate}}{{else}}{{dateStart}} ({{timeZone}}){{/if}}</p>
<p>Débute à: {{#if isAllDay}}{{dateStartFull}}{{else}}{{dateStartFull}} ({{timeZone}}){{/if}}</p>
{{#if isUser}}
{{#if description}}
<p>{{{description}}}</p>
@@ -1,5 +1,5 @@
<p>Название: {{name}}</p>
<p>Начало: {{#if isAllDay}}{{dateStartDate}}{{else}}{{dateStart}} ({{timeZone}}){{/if}}</p>
<p>Начало: {{#if isAllDay}}{{dateStartFull}}{{else}}{{dateStartFull}} ({{timeZone}}){{/if}}</p>
{{#if isUser}}
{{#if description}}
<p>{{{description}}}</p>
@@ -1,5 +1,5 @@
<p>Назва: {{name}}</p>
<p>Початок: {{#if isAllDay}}{{dateStartDate}}{{else}}{{dateStart}} ({{timeZone}}){{/if}}</p>
<p>Початок: {{#if isAllDay}}{{dateStartFull}}{{else}}{{dateStartFull}} ({{timeZone}}){{/if}}</p>
{{#if isUser}}
{{#if description}}
<p>{{{description}}}</p>
@@ -1,5 +1,5 @@
<p>Subject: {{name}}</p>
<p>Start: {{#if isAllDay}}{{dateStartDate}}{{else}}{{dateStart}} ({{timeZone}}){{/if}}</p>
<p>Start: {{#if isAllDay}}{{dateStartFull}}{{else}}{{dateStartFull}} ({{timeZone}}){{/if}}</p>
{{#if isUser}}
{{#if description}}
<p>{{{description}}}</p>