Module Recettes : on avance... un peu...
This commit is contained in:
@@ -4,10 +4,12 @@
|
||||
<column name="id" autoIncrement="true" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="content_id" type="INTEGER" />
|
||||
<column name="title" required="true" type="VARCHAR" />
|
||||
<column name="summary" required="false" type="VARCHAR" />
|
||||
<column name="people" required="true" type="INTEGER" />
|
||||
<column name="difficulty" required="true" type="INTEGER" />
|
||||
<column name="preparation_time" required="true" type="VARCHAR" />
|
||||
<column name="cooking_time" required="false" type="VARCHAR" />
|
||||
<column name="other_ingredients" required="false" type="VARCHAR" />
|
||||
|
||||
<foreign-key foreignTable="content" name="fk_content_content_id">
|
||||
<reference foreign="id" local="content_id" />
|
||||
@@ -15,8 +17,8 @@
|
||||
</table>
|
||||
|
||||
<table name="recipe_steps">
|
||||
<column name="recipe_id" required="true" type="INTEGER" />
|
||||
<column name="step" required="true" type="INTEGER" />
|
||||
<column name="recipe_id" required="true" primaryKey="true" type="INTEGER" />
|
||||
<column name="step" required="true" primaryKey="true" type="INTEGER" />
|
||||
<column name="description" required="true" type="VARCHAR" />
|
||||
|
||||
<foreign-key foreignTable="recipe" name="fk_recipesteps_recipe_id">
|
||||
@@ -25,9 +27,10 @@
|
||||
</table>
|
||||
|
||||
<table name="recipe_products">
|
||||
<column name="recipe_id" required="true" type="INTEGER" />
|
||||
<column name="pse_id" required="true" type="INTEGER" />
|
||||
<column name="quantity" required="true" type="INTEGER" />
|
||||
<column name="recipe_id" required="true" primaryKey="true" type="INTEGER" />
|
||||
<column name="pse_id" required="true" primaryKey="true" type="INTEGER" />
|
||||
<column name="nb_of_products" required="true" type="INTEGER" />
|
||||
<column name="quantity" required="true" type="VARCHAR" />
|
||||
|
||||
<foreign-key foreignTable="recipe" name="fk_recipeproducts_recipe_id">
|
||||
<reference foreign="id" local="recipe_id" />
|
||||
|
||||
@@ -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`)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class HookManager extends baseHook
|
||||
[
|
||||
"id" => 'recipe',
|
||||
"title" => 'Recette',
|
||||
"content" => ($this->render('recette-tab.html'))
|
||||
"content" => ($this->render('recette-tab.html'))
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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}
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
@@ -31,6 +33,16 @@
|
||||
{form_error form=$form field="title"}{$message}{/form_error}
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="summary"}
|
||||
<div class="form-group form-inline">
|
||||
<label class="control-label" for="{$label_attr.for}">
|
||||
{intl l=$label d='recettes'}
|
||||
</label>
|
||||
{if $required}<span class="required">*</span>{/if}
|
||||
<textarea id="summary" name="{$name}" rows="10" class="form-control wysiwyg">{$summary}</textarea>
|
||||
</div>
|
||||
{form_error form=$form field="summary"}{$message}{/form_error}
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field="difficulty"}
|
||||
<div class="form-group form-inline">
|
||||
@@ -77,22 +89,24 @@
|
||||
<div class="form-group form-inline">
|
||||
<label class="control-label" for="{$label_attr.for}">
|
||||
{intl l=$label d='recettes'}
|
||||
{if $required}<span class="required">*</span>{/if}
|
||||
</label>
|
||||
<input type="text" id="{$label_attr.for}" class="form-control" name="{$name}" value="{$cooking_time}" /> 
|
||||
<input type="text" id="{$label_attr.for}" class="form-control" name="{$name}" value="{$cooking_time}" {if $required}required{/if} /> 
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
</div>
|
||||
{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"}
|
||||
<div class="form-group form-inline">
|
||||
<label class="control-label" for="{$label_attr.for}">
|
||||
{intl l=$label d='recettes'}
|
||||
{if $required}<span class="required">*</span>{/if}
|
||||
</label>
|
||||
{if $required}<span class="required">*</span>{/if}
|
||||
<textarea id="attr-recipe" name="{$name}" rows="10" class="form-control wysiwyg">{$steps}</textarea>
|
||||
<textarea id="attr-recipe" name="{$name}" rows="10" class="form-control wysiwyg">{$other_ingredients}</textarea>
|
||||
</div>
|
||||
{form_error form=$form field="steps"}{$message}{/form_error}
|
||||
{form_error form=$form field="other_ingredients"}{$message}{/form_error}
|
||||
{/form_field}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user