From b5761ae5446ba11ce2398234b8d3942f10a89320 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 17 Sep 2019 16:28:11 +0200 Subject: [PATCH] Show to whom the chore execution is assigned in calendar events (references #253) --- localization/strings.pot | 3 +++ services/CalendarService.php | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/localization/strings.pot b/localization/strings.pot index 421945ba..c6fe570c 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1411,3 +1411,6 @@ msgstr[1] "" msgid "Assigned to me" msgstr "" + +msgid "assigned to %s" +msgstr "" diff --git a/services/CalendarService.php b/services/CalendarService.php index 1ffd47fd..80f35ea4 100644 --- a/services/CalendarService.php +++ b/services/CalendarService.php @@ -6,6 +6,7 @@ use \Grocy\Services\StockService; use \Grocy\Services\TasksService; use \Grocy\Services\ChoresService; use \Grocy\Services\BatteriesService; +use \Grocy\Services\UsersService; class CalendarService extends BaseService { @@ -51,13 +52,24 @@ class CalendarService extends BaseService ); } + $usersService = new UsersService(); + $users = $usersService->GetUsersAsDto(); + $chores = $this->Database->chores(); $titlePrefix = $this->LocalizationService->__t('Chore due') . ': '; $choreEvents = array(); foreach($this->ChoresService->GetCurrent() as $currentChoreEntry) { + $chore = FindObjectInArrayByPropertyValue($chores, 'id', $currentChoreEntry->chore_id); + + $assignedToText = ''; + if (!empty($currentChoreEntry->next_execution_assigned_to_user_id)) + { + $assignedToText = ' (' . $this->LocalizationService->__t('assigned to %s', FindObjectInArrayByPropertyValue($users, 'id', $currentChoreEntry->next_execution_assigned_to_user_id)->display_name) . ')'; + } + $choreEvents[] = array( - 'title' => $titlePrefix . FindObjectInArrayByPropertyValue($chores, 'id', $currentChoreEntry->chore_id)->name, + 'title' => $titlePrefix . $chore->name . $assignedToText, 'start' => $currentChoreEntry->next_estimated_execution_time, 'date_format' => 'datetime' );