Make it possible to add notes to meal plan (days) (closes #477)

This commit is contained in:
Bernd Bestel
2020-01-23 20:59:19 +01:00
parent 594dc0858b
commit 8d7f985b59
7 changed files with 217 additions and 82 deletions

View File

@@ -132,8 +132,20 @@ class RecipesController extends BaseController
public function MealPlan(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args)
{
$recipes = $this->Database->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->fetchAll();
$events = array();
foreach($this->Database->meal_plan_notes() as $mealPlanNote)
{
$events[] = array(
'id' => intval($mealPlanNote['id']) * -1,
'title' => '',
'start' => $mealPlanNote['day'],
'date_format' => 'date',
'note' => json_encode($mealPlanNote),
'type' => 'note'
);
}
foreach($this->Database->meal_plan() as $mealPlanEntry)
{
$recipe = FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id']);
@@ -149,7 +161,8 @@ class RecipesController extends BaseController
'start' => $mealPlanEntry['day'],
'date_format' => 'date',
'recipe' => json_encode($recipe),
'mealPlanEntry' => json_encode($mealPlanEntry)
'mealPlanEntry' => json_encode($mealPlanEntry),
'type' => 'recipe'
);
}