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 : + +
+
{% 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 : + +
+
{% endfor %}