Recettes : on avance sur le BO (ajout des produits)

This commit is contained in:
2021-05-06 20:12:59 +02:00
parent 9dcc1c1762
commit 16bfe33efd
4 changed files with 99 additions and 56 deletions

View File

@@ -36,6 +36,7 @@ class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface
foreach ($loopResult->getResultDataCollection() as $product) {
$pse = ProductSaleElementsQuery::create()->findOneById($product->getPseId());
$productId = $pse->getProductId();
$productLabel = ProductI18nQuery::create()->findOneById($pse->getProductId())->getTitle();
$attributeCombination = AttributeCombinationQuery::create()->findOneByProductSaleElementsId($product->getPseId());
$unity = AttributeAvI18nQuery::create()->findOneById($attributeCombination->getAttributeAvId())->getTitle();
@@ -45,6 +46,7 @@ class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface
$loopResultRow
->set("RECIPE_ID", $product->getRecipeId())
->set("PSE_ID", $product->getPseId())
->set("PRODUCT_ID", $productId)
->set("IN_STOCK", $inStock > 0)
->set("PRODUCT_LABEL", $productLabel)
->set("QUANTITY_NEEDED", $product->getQuantity())

View File

@@ -0,0 +1,37 @@
<table class="table table-condensed">
{loop type="recipe" name="recipe-loop" content_id=$content_id limit="1"}
{assign var="recipe_id" value="$ID"}
{/loop}
{loop type="recipe_products" name="products-loop" recipe_id=$recipe_id}
{loop type="product" visible='*' name="related-product" id=$PRODUCT_ID}
<tr>
<td>{$TITLE}<input type="hidden" value="{$PSE_ID}"</input></td>
<td>{$UNITY}</td>
<td>{$QUANTITY_PROPOSED}</td>
<td class="text-center">
<a href="{url path='/admin/module/Recettes/remove-product/%recipeId/%pseId' recipeId=$recipe_id pseId=$PSE_ID}" class="delete-product"><i class="glyphicon glyphicon-trash"></i></a>
</td>
</tr>
{/loop}
{/loop}
{elseloop rel="products-loop"}
<tr>
<td colspan="99">
<div class="alert alert-info" style="margin-bottom:0">
Aucun produit n'est attaché à cette recette.
</div>
</td>
</tr>
{/elseloop}
<tr>
<td colspan="2">
<input class="form-control" type="text" id="product_ref" autocomplete="off" data-content-id="{$content_id}" placeholder="Indiquez une référence de produit">
</td>
<td class="text-center">
<a href="{url path='/admin/module/Recettes/add-product/%recipeId' recipeId=$recipe_id}" class="btn btn-sm btn-primary add-product"><i class="glyphicon glyphicon-plus-sign"></i></a>
</td>
</tr>
</table>

View File

@@ -44,58 +44,60 @@
{form_error form=$form field="summary"}{$message}{/form_error}
{/form_field}
{form_field form=$form field="difficulty"}
<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>
<select id="{$label_attr.for}" name="{$name}">
<option value="0" {if $difficulty eq 0}selected{/if}>Facile</option>
<option value="1" {if $difficulty eq 1}selected{/if}>Moyen</option>
<option value="2" {if $difficulty eq 2}selected{/if}>Difficile</option>
</select>
<div class="row">
{form_field form=$form field="difficulty"}
<div class="col-md-6 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>
<select id="{$label_attr.for}" name="{$name}">
<option value="0" {if $difficulty eq 0}selected{/if}>Facile</option>
<option value="1" {if $difficulty eq 1}selected{/if}>Moyen</option>
<option value="2" {if $difficulty eq 2}selected{/if}>Difficile</option>
</select>
</div>
{form_error form=$form field="difficulty"}{$message}{/form_error}
{/form_field}
{form_field form=$form field="people"}
<div class="col-md-6 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 etroit" name="{$name}" value="{$people}" {if $required}required{/if} />&nbsp
</div>
{form_error form=$form field="people"}{$message}{/form_error}
{/form_field}
</div>
{form_error form=$form field="difficulty"}{$message}{/form_error}
{/form_field}
<div class="row">
{form_field form=$form field="preparation_time"}
<div class="col-md-6 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="{$preparation_time}" {if $required}required{/if} />&nbsp
<span class="help-block">{$label_attr.help}</span>
</div>
{form_error form=$form field="preparation_time"}{$message}{/form_error}
{/form_field}
{form_field form=$form field="people"}
<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 etroit" name="{$name}" value="{$people}" {if $required}required{/if} />&nbsp
{form_field form=$form field="cooking_time"}
<div class="col-md-6 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}" {if $required}required{/if} />&nbsp
<span class="help-block">{$label_attr.help}</span>
</div>
{form_error form=$form field="cooking_time"}{$message}{/form_error}
{/form_field}
</div>
{form_error form=$form field="people"}{$message}{/form_error}
{/form_field}
{form_field form=$form field="preparation_time"}
<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="{$preparation_time}" {if $required}required{/if} />&nbsp
<span class="help-block">{$label_attr.help}</span>
</div>
{form_error form=$form field="preparation_time"}{$message}{/form_error}
{/form_field}
{form_field form=$form field="cooking_time"}
<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}" {if $required}required{/if} />&nbsp
<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="other_ingredients"}
<div class="form-group form-inline">
@@ -110,14 +112,16 @@
{/form_field}
</div>
<div class="col-md-4">
<table class="table table-striped">
<thead>
<th>{intl l="Product" d="recettes"}</th>
<th>{intl l="Quantity" d="recettes"}</th>
</thead>
<tbody></tbody>
</table>
<div class="col-md-4 form-group">
<label class="control-label">Produits attachés</label>
<div id="related-products-block">
{include file='ajax/related-products.html'}
</div>
<br>
<label class="control-label">Etapes de la recette</label>
<div id="steps-block">
{include file='ajax/steps.html'}
</div>
</div>
<div class="form-group">