diff --git a/local/media/images/content/telechargement-1.jpeg b/local/media/images/content/telechargement-1.jpeg new file mode 100644 index 00000000..11b3ece7 Binary files /dev/null and b/local/media/images/content/telechargement-1.jpeg differ diff --git a/local/modules/Recettes/Config/schema.xml b/local/modules/Recettes/Config/schema.xml index 0601b34a..6cacd81a 100644 --- a/local/modules/Recettes/Config/schema.xml +++ b/local/modules/Recettes/Config/schema.xml @@ -4,10 +4,12 @@ + + @@ -15,8 +17,8 @@ - - + + @@ -25,9 +27,10 @@
- - - + + + + diff --git a/local/modules/Recettes/Config/thelia.sql b/local/modules/Recettes/Config/thelia.sql index 7d3ca2e3..4ac4be94 100644 --- a/local/modules/Recettes/Config/thelia.sql +++ b/local/modules/Recettes/Config/thelia.sql @@ -14,10 +14,12 @@ CREATE TABLE `recipe` `id` INTEGER NOT NULL AUTO_INCREMENT, `content_id` INTEGER, `title` VARCHAR(255) NOT NULL, + `summary` VARCHAR(255), `people` INTEGER NOT NULL, `difficulty` INTEGER NOT NULL, `preparation_time` VARCHAR(255) NOT NULL, `cooking_time` VARCHAR(255), + `other_ingredients` VARCHAR(255), PRIMARY KEY (`id`), INDEX `fi_content_content_id` (`content_id`), CONSTRAINT `fk_content_content_id` @@ -36,7 +38,7 @@ CREATE TABLE `recipe_steps` `recipe_id` INTEGER NOT NULL, `step` INTEGER NOT NULL, `description` VARCHAR(255) NOT NULL, - INDEX `fi_recipesteps_recipe_id` (`recipe_id`), + PRIMARY KEY (`recipe_id`,`step`), CONSTRAINT `fk_recipesteps_recipe_id` FOREIGN KEY (`recipe_id`) REFERENCES `recipe` (`id`) @@ -52,8 +54,9 @@ CREATE TABLE `recipe_products` ( `recipe_id` INTEGER NOT NULL, `pse_id` INTEGER NOT NULL, - `quantity` INTEGER NOT NULL, - INDEX `fi_recipeproducts_recipe_id` (`recipe_id`), + `nb_of_products` INTEGER NOT NULL, + `quantity` VARCHAR(255) NOT NULL, + PRIMARY KEY (`recipe_id`,`pse_id`), INDEX `fi_recipeproducts_pse_id` (`pse_id`), CONSTRAINT `fk_recipeproducts_recipe_id` FOREIGN KEY (`recipe_id`) diff --git a/local/modules/Recettes/Controller/MainController.php b/local/modules/Recettes/Controller/MainController.php index d1ebc2ce..8092cadd 100755 --- a/local/modules/Recettes/Controller/MainController.php +++ b/local/modules/Recettes/Controller/MainController.php @@ -40,11 +40,13 @@ class MainController extends BaseAdminController $contentId = $data['content_id']; $title = $data['title']; + $summary = $data['summary']; $difficulty = $data['difficulty']; $numberPeople = $data['people']; $preparationTime = $data['preparation_time']; $cookingTime = $data['cooking_time']; - $steps = $data['steps']; + $otherIngredients = $data['other_ingredients']; +// $steps = $data['steps']; if (null !== $title && null !== $contentId && null !== $difficulty && null !== $numberPeople && null !== $preparationTime) { @@ -58,20 +60,22 @@ class MainController extends BaseAdminController $recipeId = $recipe->getId(); $recipe->setContentId($contentId); + $recipe->setSummary($summary); $recipe->setTitle($title); $recipe->setDifficulty($difficulty); $recipe->setPeople($numberPeople); $recipe->setPreparationTime($preparationTime); $recipe->setCookingTime($cookingTime); + $recipe->setOtherIngredients($otherIngredients); $recipe->save($con); $con->commit(); if (!$nouvelleRecette) { // On supprime les étapes pour les recréer par la suite. - $steps = RecipeStepsQuery::create()->findByRecipeId($recipeId); - $steps->delete($con); - $con->commit(); +// $steps = RecipeStepsQuery::create()->findByRecipeId($recipeId); +// $steps->delete($con); +// $con->commit(); } /* foreach ($steps as $step) { diff --git a/local/modules/Recettes/Form/RecetteCreateForm.php b/local/modules/Recettes/Form/RecetteCreateForm.php index 210d896e..cce60131 100644 --- a/local/modules/Recettes/Form/RecetteCreateForm.php +++ b/local/modules/Recettes/Form/RecetteCreateForm.php @@ -53,6 +53,17 @@ class RecetteCreateForm extends BaseForm "required" => true ] ) + ->add( + "summary", + "textarea", + [ + "label" => $this->trans("Summary"), + "label_attr" => [ + "for" => "summary" + ], + "required" => false + ] + ) ->add( "difficulty", "integer", @@ -106,13 +117,15 @@ class RecetteCreateForm extends BaseForm ] ) ->add( - "steps", + "other_ingredients", "textarea", [ - "label" => $this->trans("Steps"), + "label" => $this->trans("Other ingredients"), "label_attr" => [ - "for" => "steps" + "for" => "other_ingredients" ] + , + "required" => false ] ); } diff --git a/local/modules/Recettes/Hook/HookManager.php b/local/modules/Recettes/Hook/HookManager.php index 5231c434..9326cb31 100644 --- a/local/modules/Recettes/Hook/HookManager.php +++ b/local/modules/Recettes/Hook/HookManager.php @@ -28,7 +28,7 @@ class HookManager extends baseHook [ "id" => 'recipe', "title" => 'Recette', - "content" => ($this->render('recette-tab.html')) + "content" => ($this->render('recette-tab.html')) ] ); } diff --git a/local/modules/Recettes/I18n/fr_FR.php b/local/modules/Recettes/I18n/fr_FR.php index deee86c3..87ecaa02 100644 --- a/local/modules/Recettes/I18n/fr_FR.php +++ b/local/modules/Recettes/I18n/fr_FR.php @@ -5,10 +5,9 @@ return array( 'Preparation time' => 'Temps de préparation', 'Cooking time' => 'Temps de cuisson', 'Difficulty' => 'Difficulté', - 'Number of people' => 'Nombre de personnes', + 'Number of people' => 'Nombre de couverts', 'Product' => 'Produit', 'Quantity' => 'Quantité', - 'Preparation time' => 'Préparation ', - 'Cooking time' => 'Cuisson ', - 'Difficulty' => 'Niveau ', + 'Summary' => 'Description de la recette', + 'Other ingredients' => 'Ingrédients supplémentaires', ); diff --git a/local/modules/Recettes/Loop/GeneralLoop.php b/local/modules/Recettes/Loop/GeneralLoop.php index 4c47cf0b..f31528f8 100644 --- a/local/modules/Recettes/Loop/GeneralLoop.php +++ b/local/modules/Recettes/Loop/GeneralLoop.php @@ -34,10 +34,12 @@ class GeneralLoop extends BaseLoop implements PropelSearchLoopInterface ->set("ID", $recipe->getId()) ->set("CONTENT_ID", $recipe->getContentId()) ->set("TITLE", $recipe->getTitle()) + ->set("SUMMARY", $recipe->getSummary()) ->set("PEOPLE", $recipe->getPeople()) ->set("DIFFICULTY", $recipe->getDifficulty()) ->set("PREPARATION_TIME", $recipe->getPreparationTime()) ->set("COOKING_TIME", $recipe->getCookingTime()) + ->set("OTHER_INGREDIENTS", $recipe->getOtherIngredients()) ; $loopResult->addRow($loopResultRow); } diff --git a/local/modules/Recettes/Loop/ProductsLoop.php b/local/modules/Recettes/Loop/ProductsLoop.php index 5864b05f..845e4475 100644 --- a/local/modules/Recettes/Loop/ProductsLoop.php +++ b/local/modules/Recettes/Loop/ProductsLoop.php @@ -9,6 +9,8 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\PropelSearchLoopInterface; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Model\ProductI18nQuery; +use Thelia\Model\ProductSaleElementsQuery; /** * Class ProductsLoop @@ -29,10 +31,14 @@ class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface { foreach ($loopResult->getResultDataCollection() as $product) { + $pse = ProductSaleElementsQuery::create()->findOneById($product->getPseId()); + $productLabel = ProductI18nQuery::create()->findOneById($pse->getProductId())->getTitle(); + $loopResultRow = new LoopResultRow($product); $loopResultRow - ->set("RECIPE_ID", $product->getId()) + ->set("RECIPE_ID", $product->getRecipeId()) ->set("PSE_ID", $product->getPseId()) + ->set("PRODUCT_LABEL", $productLabel) ->set("QUANTITY", $product->getQuantity()) ; $loopResult->addRow($loopResultRow); @@ -57,8 +63,8 @@ class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface { $products = RecipeProductsQuery::create(); - if (null != $id = $this->getRecipeId()) { - $products->filterById($id); + if (null != $recipeId = $this->getRecipeId()) { + $products->filterByRecipeId($recipeId); } return $products; diff --git a/local/modules/Recettes/templates/backOffice/default/recette-tab.html b/local/modules/Recettes/templates/backOffice/default/recette-tab.html index 70017b74..8109eb74 100644 --- a/local/modules/Recettes/templates/backOffice/default/recette-tab.html +++ b/local/modules/Recettes/templates/backOffice/default/recette-tab.html @@ -1,9 +1,11 @@ {loop type="recipe" name="recipe-loop" content_id=$content_id limit="1"} {assign var="title" value=$TITLE} + {assign var="summary" value=$SUMMARY} {assign var="people" value=$PEOPLE} {assign var="difficulty" value=$DIFFICULTY} {assign var="preparation_time" value=$PREPARATION_TIME} {assign var="cooking_time" value=$COOKING_TIME} + {assign var="other_ingredients" value=$OTHER_INGREDIENTS} {/loop}
@@ -31,6 +33,16 @@ {form_error form=$form field="title"}{$message}{/form_error} {/form_field} + {form_field form=$form field="summary"} +
+ + {if $required}*{/if} + +
+ {form_error form=$form field="summary"}{$message}{/form_error} + {/form_field} {form_field form=$form field="difficulty"}
@@ -77,22 +89,24 @@
-   +   {$label_attr.help}
{form_error form=$form field="cooking_time"}{$message}{/form_error} {/form_field} - {form_field form=$form field="steps"} + {form_field form=$form field="other_ingredients"}
{if $required}*{/if} - +
- {form_error form=$form field="steps"}{$message}{/form_error} + {form_error form=$form field="other_ingredients"}{$message}{/form_error} {/form_field}
diff --git a/local/modules/Recettes/templates/frontOffice/default/assets/css/Recettes.css b/local/modules/Recettes/templates/frontOffice/default/assets/css/Recettes.css index 95934e55..f2220d35 100644 --- a/local/modules/Recettes/templates/frontOffice/default/assets/css/Recettes.css +++ b/local/modules/Recettes/templates/frontOffice/default/assets/css/Recettes.css @@ -4,6 +4,7 @@ article#recette { display: flex; flex-direction: column; align-items: normal; + margin: auto; } div.entete { @@ -28,3 +29,7 @@ div.entete span { div.entete span b { color: #0e0e0e; } +.photo-principale img { + width: 250px; + box-shadow: 10px 10px 15px gray; +} \ No newline at end of file diff --git a/templates/frontOffice/custom/recette.html b/templates/frontOffice/custom/recette.html index cd2f8919..279c9917 100644 --- a/templates/frontOffice/custom/recette.html +++ b/templates/frontOffice/custom/recette.html @@ -29,31 +29,51 @@ {block name="main-content"} {if $content_id} -
-
+
+
{loop type="recipe" name="recipe-loop" content_id=$content_id limit="1"} {if $DIFFICULTY eq 0}{assign var="label_difficulty" value="Facile"}{/if} {if $DIFFICULTY eq 1}{assign var="label_difficulty" value="Moyen"}{/if} {if $DIFFICULTY eq 2}{assign var="label_difficulty" value="Difficile"}{/if} -

{$TITLE}

-
+
{intl l='Preparation time' d='recettes'}Preparation time{$PREPARATION_TIME} {intl l='Cooking time' d='recettes'}Cooking time{$COOKING_TIME} {intl l='Difficulty' d='recettes'}Difficulty{$label_difficulty}

-
- {loop type="image" name="image-loop" content=$content_id} - +
+ {loop type="image" name="image-loop" content=$content_id visible=true} + Photo principale {/loop}
-
+
+

{intl l='Nos produits' d='recettes'}

+
+ + + + + + + {loop type="recipe_products" name="products-loop" recipe_id=$ID} + + + + + + {/loop} + +
{intl l="Ingredient" d="recettes"}{intl l="Quantity needed" d="recettes"}{intl l="Choose this product" d="recettes"}
{$PRODUCT_LABEL}{$QUANTITY}
+
+

{intl l='Autres ingrédients' d='recettes'}

+ + - +
{/loop}