From d138dbc13e915eaecc07235a65b6182132f284a1 Mon Sep 17 00:00:00 2001 From: LucileDT Date: Mon, 23 Jan 2023 17:58:02 +0100 Subject: [PATCH] Ref #141: add ingredients info on grocery list --- src/Service/GroceryListService.php | 25 ++++++++ templates/grocery_list/index.html.twig | 88 +++++++++++++++++++++++--- 2 files changed, 105 insertions(+), 8 deletions(-) diff --git a/src/Service/GroceryListService.php b/src/Service/GroceryListService.php index 0da96d2..3c1bc19 100644 --- a/src/Service/GroceryListService.php +++ b/src/Service/GroceryListService.php @@ -59,6 +59,7 @@ public static function generateFormattedGroceryList(ArrayCollection $mealLists) $item = [ 'id' => $ingredientId, 'label' => $ingredient->getLabel(), + 'brand' => $ingredient->getBrand(), 'quantity' => $quantity, 'unitQuantity' => $unitQuantity, 'unitSize' => $unitSize, @@ -89,6 +90,30 @@ public static function generateFormattedGroceryList(ArrayCollection $mealLists) $groceryList[$storeId]['checkNotNeeded'][$ingredientId]['unitQuantity'] += $unitQuantity; } } + + if ($ingredient->hasStockCheckNeededBeforeBuying()) { + $groceryList[$storeId]['checkNeeded'][$ingredientId]['recipes'][$ingredientQuantityForRecipe->getRecipe()->getId()] = [ + 'id' => $ingredientQuantityForRecipe->getRecipe()->getId(), + 'label' => $ingredientQuantityForRecipe->getRecipe()->getName(), + 'mealCount' => $mealQuantity, + 'quantity' => $quantity, + 'unitQuantity' => $unitQuantity, + 'unitSize' => $unitSize, + 'measureType' => $ingredient->getMeasureType(), + 'isMeasuredByUnit' => $isMeasuredByUnit, + ]; + } else { + $groceryList[$storeId]['checkNotNeeded'][$ingredientId]['recipes'][$ingredientQuantityForRecipe->getRecipe()->getId()] = [ + 'id' => $ingredientQuantityForRecipe->getRecipe()->getId(), + 'label' => $ingredientQuantityForRecipe->getRecipe()->getName(), + 'mealCount' => $mealQuantity, + 'quantity' => $quantity, + 'unitQuantity' => $unitQuantity, + 'unitSize' => $unitSize, + 'measureType' => $ingredient->getMeasureType(), + 'isMeasuredByUnit' => $isMeasuredByUnit, + ]; + } } } } diff --git a/templates/grocery_list/index.html.twig b/templates/grocery_list/index.html.twig index 36ae4a3..65746c6 100644 --- a/templates/grocery_list/index.html.twig +++ b/templates/grocery_list/index.html.twig @@ -53,12 +53,48 @@ {% if grocery.isMeasuredByUnit %} ({{ grocery.quantity }} {{ grocery.measureType }}) {% endif %} - - Voir la fiche ingrédient + + + +
+
+ Marque : {{ grocery.brand ?: 'générique' }} + Quantités : +
    + {% for recipe in grocery.recipes %} +
  • + + {{ recipe.mealCount }} * {{ recipe.label }} : + + {% if recipe.isMeasuredByUnit %} + {{ recipe.unitQuantity }} + {% else %} + {{ recipe.quantity }} {{ recipe.measureType }} + {% endif %} + {% if recipe.isMeasuredByUnit %} + ({{ recipe.quantity }} {{ recipe.measureType }}) + {% endif %} +
  • + {% endfor %} +
+
+
{% endfor %} @@ -78,12 +114,48 @@ {% if grocery.isMeasuredByUnit %} ({{ grocery.quantity }} {{ grocery.measureType }}) {% endif %} - - Voir la fiche ingrédient + + + +
+
+ Marque : {{ grocery.brand ?: 'générique' }} + Quantités : +
    + {% for recipe in grocery.recipes %} +
  • + + {{ recipe.mealCount }} * {{ recipe.label }} : + + {% if recipe.isMeasuredByUnit %} + {{ recipe.unitQuantity }} + {% else %} + {{ recipe.quantity }} {{ recipe.measureType }} + {% endif %} + {% if recipe.isMeasuredByUnit %} + ({{ recipe.quantity }} {{ recipe.measureType }}) + {% endif %} +
  • + {% endfor %} +
+
+
{% endfor %}