Include meal plan recipes in the calendar (closes #368)

This commit is contained in:
Bernd Bestel
2019-09-24 09:40:56 +02:00
parent 2a9f927a13
commit 53c56cc1cb
3 changed files with 38 additions and 1 deletions

View File

@@ -87,6 +87,23 @@ class CalendarService extends BaseService
);
}
return array_merge($stockEvents, $taskEvents, $choreEvents, $batteryEvents);
$recipes = $this->Database->recipes();
$mealPlanDayRecipes = $this->Database->recipes()->where('type', 'mealplan-day');
$titlePrefix = $this->LocalizationService->__t('Meal plan') . ': ';
$mealPlanRecipeEvents = array();
foreach($mealPlanDayRecipes as $mealPlanDayRecipe)
{
$recipesOfCurrentDay = $this->Database->recipes_nestings_resolved()->where('recipe_id = :1 AND includes_recipe_id != :1', $mealPlanDayRecipe->id);
foreach ($recipesOfCurrentDay as $recipeOfCurrentDay)
{
$mealPlanRecipeEvents[] = array(
'title' => $titlePrefix . FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->includes_recipe_id)->name,
'start' => FindObjectInArrayByPropertyValue($recipes, 'id', $recipeOfCurrentDay->recipe_id)->name,
'date_format' => 'date'
);
}
}
return array_merge($stockEvents, $taskEvents, $choreEvents, $batteryEvents, $mealPlanRecipeEvents);
}
}