diff --git a/local/modules/Recettes/Config/routing.xml b/local/modules/Recettes/Config/routing.xml index bfaef7bd..058e5abc 100644 --- a/local/modules/Recettes/Config/routing.xml +++ b/local/modules/Recettes/Config/routing.xml @@ -5,10 +5,11 @@ xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - Recettes\Controller\MainController::saveRecipe + Recettes\Controller\BackController::saveRecipe + - Recettes\Controller\MainController::addToCart + Recettes\Controller\FrontController::addToCart diff --git a/local/modules/Recettes/Controller/MainController.php b/local/modules/Recettes/Controller/BackController.php similarity index 94% rename from local/modules/Recettes/Controller/MainController.php rename to local/modules/Recettes/Controller/BackController.php index 9ac0c8c3..d8786cce 100755 --- a/local/modules/Recettes/Controller/MainController.php +++ b/local/modules/Recettes/Controller/BackController.php @@ -22,10 +22,10 @@ use Thelia\Tools\URL; /** - * Class MainController + * Class BackController * @package Recettes\Controller */ -class MainController extends BaseAdminController +class BackController extends BaseAdminController { public function saveRecipe(Request $request) @@ -99,9 +99,4 @@ class MainController extends BaseAdminController return new RedirectResponse(URL::getInstance()->absoluteUrl("/admin/content")); } - - public function addToCart(Request $request) - { - $order = $request->getSession()->getOrder(); - } } diff --git a/local/modules/Recettes/Controller/FrontController.php b/local/modules/Recettes/Controller/FrontController.php new file mode 100755 index 00000000..24bb7240 --- /dev/null +++ b/local/modules/Recettes/Controller/FrontController.php @@ -0,0 +1,54 @@ +request; + $dispatcher = $this->getDispatcher(); + $produitsHorsStock = false; + + foreach ($parameters as $key=>$value) { + $string = explode("-", $key); + $pseId = $string[1];; + $qty = $string[3]; + + $productId = ProductSaleElementsQuery::create()->findOneById($pseId)->getProductId(); + $stock = ProductSaleElementsQuery::create()->findOneById($pseId)->getQuantity(); + + if ($stock > 0) { + $eventAjout = new CartEvent($request->getSession()->getSessionCart($dispatcher)); + $eventAjout + ->setQuantity($qty) + ->setProduct($productId) + ->setProductSaleElementsId($pseId); + + $dispatcher->dispatch(TheliaEvents::CART_ADDITEM, $eventAjout); + } + else { + $produitsHorsStock = true; + } + } + + if (! $produitsHorsStock) + return new RedirectResponse(URL::getInstance()->absoluteUrl('/cart')); + + } +} diff --git a/local/modules/Recettes/Loop/ProductsLoop.php b/local/modules/Recettes/Loop/ProductsLoop.php index dfd3bcdd..4d3257aa 100644 --- a/local/modules/Recettes/Loop/ProductsLoop.php +++ b/local/modules/Recettes/Loop/ProductsLoop.php @@ -3,12 +3,17 @@ namespace Recettes\Loop; use Recettes\Model\RecipeProductsQuery; +use Thelia\Action\AttributeAv; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; 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\AttributeAvI18nQuery; +use Thelia\Model\AttributeCombinationQuery; +use Thelia\Model\AttributeI18n; +use Thelia\Model\AttributeI18nQuery; use Thelia\Model\ProductI18nQuery; use Thelia\Model\ProductSaleElementsQuery; @@ -33,6 +38,8 @@ class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface $pse = ProductSaleElementsQuery::create()->findOneById($product->getPseId()); $productLabel = ProductI18nQuery::create()->findOneById($pse->getProductId())->getTitle(); + $attributeCombination = AttributeCombinationQuery::create()->findOneByProductSaleElementsId($product->getPseId()); + $unity = AttributeAvI18nQuery::create()->findOneById($attributeCombination->getAttributeAvId())->getTitle(); $loopResultRow = new LoopResultRow($product); $loopResultRow @@ -41,6 +48,7 @@ class ProductsLoop extends BaseLoop implements PropelSearchLoopInterface ->set("PRODUCT_LABEL", $productLabel) ->set("QUANTITY_NEEDED", $product->getQuantity()) ->set("QUANTITY_PROPOSED", $product->getNbOfProducts()) + ->set('UNITY', $unity) ; $loopResult->addRow($loopResultRow); } 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 d5841e93..73030cc9 100644 --- a/local/modules/Recettes/templates/frontOffice/default/assets/css/Recettes.css +++ b/local/modules/Recettes/templates/frontOffice/default/assets/css/Recettes.css @@ -78,4 +78,7 @@ div.entete span b { .table-steps td.number{ padding-left: 30px; font-weight: bold; +} +.bouton-imprimer { + text-align: center; } \ No newline at end of file diff --git a/templates/frontOffice/custom/recette.html b/templates/frontOffice/custom/recette.html index d9929bba..c385a9d7 100644 --- a/templates/frontOffice/custom/recette.html +++ b/templates/frontOffice/custom/recette.html @@ -45,7 +45,7 @@ {intl l='Difficulty' d='recettes'}Difficulty{$label_difficulty}
-
+
{loop type="image" name="image-loop" content=$content_id visible=true} @@ -67,8 +67,8 @@ {$PRODUCT_LABEL} {$QUANTITY_NEEDED} - {$QUANTITY_PROPOSED} - + {$QUANTITY_PROPOSED} ({$UNITY}) + {/loop} @@ -101,6 +101,9 @@ {/loop}
+ +
+
{/if} {/block} @@ -114,7 +117,7 @@ $("#form-recette").off('submit').submit(function(ev) { - if ($('input[name=selected-product]:checked').length === 0) { + if ($('input[name*=pseid-]:checked').length === 0) { alert("Vous n'avez choisi aucun produit à rajouter dans votre panier."); ev.preventDefault(); }