Recettes : on finalise la fonction d'impression de la recette

This commit is contained in:
2021-05-05 22:37:10 +02:00
parent 347fbf2d77
commit 0790ae40ba
4 changed files with 50 additions and 36 deletions

View File

@@ -17,5 +17,7 @@ return array(
'Quantity needed' => 'Quantité nécessaire', 'Quantity needed' => 'Quantité nécessaire',
'Quantity proposed' => 'Quantité proposée', 'Quantity proposed' => 'Quantité proposée',
'Select' => 'Sélectionner', 'Select' => 'Sélectionner',
'Add to cart' => 'Ajouter ces produits au panier', 'Add to cart' => 'Ajouter au panier',
'Print recipe' => 'Imprimer la recette',
'Some products may not be in stock' => '* les produits que vous ne pouvez pas cocher ne sont plus en stock',
); );

View File

@@ -3,7 +3,6 @@
namespace Recettes\Loop; namespace Recettes\Loop;
use Recettes\Model\RecipeProductsQuery; use Recettes\Model\RecipeProductsQuery;
use Thelia\Action\AttributeAv;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
@@ -12,8 +11,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\AttributeAvI18nQuery; use Thelia\Model\AttributeAvI18nQuery;
use Thelia\Model\AttributeCombinationQuery; use Thelia\Model\AttributeCombinationQuery;
use Thelia\Model\AttributeI18n;
use Thelia\Model\AttributeI18nQuery;
use Thelia\Model\ProductI18nQuery; use Thelia\Model\ProductI18nQuery;
use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductSaleElementsQuery;
@@ -40,11 +37,13 @@ class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface
$productLabel = ProductI18nQuery::create()->findOneById($pse->getProductId())->getTitle(); $productLabel = ProductI18nQuery::create()->findOneById($pse->getProductId())->getTitle();
$attributeCombination = AttributeCombinationQuery::create()->findOneByProductSaleElementsId($product->getPseId()); $attributeCombination = AttributeCombinationQuery::create()->findOneByProductSaleElementsId($product->getPseId());
$unity = AttributeAvI18nQuery::create()->findOneById($attributeCombination->getAttributeAvId())->getTitle(); $unity = AttributeAvI18nQuery::create()->findOneById($attributeCombination->getAttributeAvId())->getTitle();
$inStock = $pse->getQuantity();
$loopResultRow = new LoopResultRow($product); $loopResultRow = new LoopResultRow($product);
$loopResultRow $loopResultRow
->set("RECIPE_ID", $product->getRecipeId()) ->set("RECIPE_ID", $product->getRecipeId())
->set("PSE_ID", $product->getPseId()) ->set("PSE_ID", $product->getPseId())
->set("IN_STOCK", $inStock > 0)
->set("PRODUCT_LABEL", $productLabel) ->set("PRODUCT_LABEL", $productLabel)
->set("QUANTITY_NEEDED", $product->getQuantity()) ->set("QUANTITY_NEEDED", $product->getQuantity())
->set("QUANTITY_PROPOSED", $product->getNbOfProducts()) ->set("QUANTITY_PROPOSED", $product->getNbOfProducts())

View File

@@ -65,7 +65,7 @@ div.entete span b {
white-space: nowrap; white-space: nowrap;
} }
.cellule-large { .cellule-large {
width: 40%; width: 20%;
} }
.cellule-etroite { .cellule-etroite {
width: 1%; width: 1%;
@@ -80,5 +80,16 @@ div.entete span b {
font-weight: bold; font-weight: bold;
} }
.bouton-imprimer { .bouton-imprimer {
margin: 20px 0;
text-align: center; text-align: center;
} }
@media print {
.footer-block,
header,
.nav-breadcrumb,
.table-ingredients tr:last-of-type,
#tarteaucitronAlertBig {
display: none !important;
}
}

View File

@@ -57,28 +57,28 @@
<p class="recette-titre">{intl l='Ingredients' d='recettes'}</p> <p class="recette-titre">{intl l='Ingredients' d='recettes'}</p>
<table class="table table-striped table-condensed table-ingredients"> <table class="table table-striped table-condensed table-ingredients">
<thead> <thead>
<th>{intl l="Ingredient" d="recettes"}</th> <th class="cellule-large">{intl l="Ingredient" d="recettes"}</th>
<th>{intl l="Quantity needed" d="recettes"}</th> <th class="cellule-etroite">{intl l="Quantity needed" d="recettes"}</th>
<th>{intl l="Quantity proposed" d="recettes"}</th> <th class="cellule-etroite">{intl l="Quantity proposed" d="recettes"}</th>
<th>{intl l="Select" d="recettes"}</th> <th class="cellule-etroite">{intl l="Select" d="recettes"}</th>
</thead> </thead>
<tbody> <tbody>
{loop type="recipe_products" name="products-loop" recipe_id=$ID} {loop type="recipe_products" name="products-loop" recipe_id=$ID}
<tr> <tr>
<td class="cellule-large">{$PRODUCT_LABEL}</td> <td>{$PRODUCT_LABEL}</td>
<td class="cellule-etroite">{$QUANTITY_NEEDED}</td> <td>{$QUANTITY_NEEDED}</td>
<td class="cellule-etroite">{$QUANTITY_PROPOSED}&nbsp;({$UNITY})</td> <td>{$QUANTITY_PROPOSED}&nbsp;({$UNITY})</td>
<td class="cellule-etroite"><input type="checkbox" name="pseid-{$PSE_ID}-qty-{$QUANTITY_PROPOSED}" class="cellule-checkbox"></td> <td><input type="checkbox" name="pseid-{$PSE_ID}-qty-{$QUANTITY_PROPOSED}" class="cellule-checkbox" {if not $IN_STOCK}disabled{/if}></td>
</tr> </tr>
{/loop} {/loop}
<tr> <tr>
<td colspan="3"></td> <td colspan="3"><i>{intl l="Some products may not be in stock" d="recettes"}</i></td>
<td> <td>
<div class="form-group"> <div class="form-group">
<button type="submit" class="btn btn-primary">{intl l='Add to cart' d='recettes'}</button> <button type="submit" class="btn btn-primary">{intl l='Add to cart' d='recettes'}</button>
</div> </div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<br> <br>
@@ -89,21 +89,19 @@
</form> </form>
<br> <br>
<br> <br>
<table class="table table-striped table-steps"> <table class="table table-striped table-steps">
{loop type="recipe_steps" name="steps-loop" recipe_id=$ID} {loop type="recipe_steps" name="steps-loop" recipe_id=$ID}
<tr> <tr>
<td class="number">{$STEP}</td> <td class="number">{$STEP}</td>
<td class="description">{$DESCRIPTION}</td> <td class="description">{$DESCRIPTION}</td>
</tr> </tr>
{/loop} {/loop}
</table> </table>
</div>
{/loop} {/loop}
</article> </article>
<br> <div class="bouton-imprimer">
<button type="button" class="btn btn-primary bouton-imprimer">{intl l="Print recipe" d="recettes"}</button> <button type="button" class="btn btn-primary">{intl l="Print recipe" d="recettes"}</button>
<br> </div>
<br>
</div> </div>
{/if} {/if}
{/block} {/block}
@@ -123,5 +121,9 @@
} }
}); });
$(".bouton-imprimer button").click(function () {
window.print();
});
</script> </script>
{/block} {/block}