diff --git a/core/lib/Thelia/Action/Attribute.php b/core/lib/Thelia/Action/Attribute.php index 44c5968a4..12478e8a1 100644 --- a/core/lib/Thelia/Action/Attribute.php +++ b/core/lib/Thelia/Action/Attribute.php @@ -123,19 +123,7 @@ class Attribute extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $attribute = AttributeQuery::create()->findPk($event->getObjectId())) { - - $attribute->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $attribute->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $attribute->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $attribute->movePositionDown(); - } + return $this->genericUpdatePosition(AttributeQuery::create(), $event); } protected function doAddToAllTemplates(AttributeModel $attribute) diff --git a/core/lib/Thelia/Action/AttributeAv.php b/core/lib/Thelia/Action/AttributeAv.php index a6b442fa2..0a72739d1 100644 --- a/core/lib/Thelia/Action/AttributeAv.php +++ b/core/lib/Thelia/Action/AttributeAv.php @@ -112,19 +112,7 @@ class AttributeAv extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $attribute = AttributeAvQuery::create()->findPk($event->getObjectId())) { - - $attribute->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $attribute->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $attribute->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $attribute->movePositionDown(); - } + return $this->genericUpdatePosition(AttributeAvQuery::create(), $event); } diff --git a/core/lib/Thelia/Action/BaseAction.php b/core/lib/Thelia/Action/BaseAction.php index 56565ddc6..7f501db83 100755 --- a/core/lib/Thelia/Action/BaseAction.php +++ b/core/lib/Thelia/Action/BaseAction.php @@ -23,6 +23,9 @@ namespace Thelia\Action; use Symfony\Component\DependencyInjection\ContainerInterface; +use Propel\Runtime\ActiveQuery\PropelQuery; +use Propel\Runtime\ActiveQuery\ModelCriteria; +use Thelia\Core\Event\UpdatePositionEvent; class BaseAction { @@ -45,4 +48,28 @@ class BaseAction { return $this->container->get('event_dispatcher'); } + + + /** + * Changes object position, selecting absolute ou relative change. + * + * @param $query the query to retrieve the object to move + * @param UpdatePositionEvent $event + */ + protected function genericUpdatePosition(ModelCriteria $query, UpdatePositionEvent $event) + { + if (null !== $object = $query->findPk($event->getObjectId())) { + + $object->setDispatcher($this->getDispatcher()); + + $mode = $event->getMode(); + + if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) + return $object->changeAbsolutePosition($event->getPosition()); + else if ($mode == UpdatePositionEvent::POSITION_UP) + return $object->movePositionUp(); + else if ($mode == UpdatePositionEvent::POSITION_DOWN) + return $object->movePositionDown(); + } + } } diff --git a/core/lib/Thelia/Action/Category.php b/core/lib/Thelia/Action/Category.php index 25a94711f..8429a7c4e 100755 --- a/core/lib/Thelia/Action/Category.php +++ b/core/lib/Thelia/Action/Category.php @@ -136,19 +136,7 @@ class Category extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $category = CategoryQuery::create()->findPk($event->getObjectId())) { - - $category->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $category->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $category->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $category->movePositionDown(); - } + return $this->genericUpdatePosition(CategoryQuery::create(), $event); } public function addContent(CategoryAddContentEvent $event) { diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php index 946fee375..3c428683b 100644 --- a/core/lib/Thelia/Action/Currency.php +++ b/core/lib/Thelia/Action/Currency.php @@ -166,20 +166,7 @@ class Currency extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $currency = CurrencyQuery::create()->findPk($event->getObjectId())) { - - $currency->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - echo "loaded $mode !"; - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $currency->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $currency->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $currency->movePositionDown(); - } + return $this->genericUpdatePosition(CurrencyQuery::create(), $event); } /** diff --git a/core/lib/Thelia/Action/Feature.php b/core/lib/Thelia/Action/Feature.php index a746ce4e2..01799510c 100644 --- a/core/lib/Thelia/Action/Feature.php +++ b/core/lib/Thelia/Action/Feature.php @@ -123,19 +123,7 @@ class Feature extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $feature = FeatureQuery::create()->findPk($event->getObjectId())) { - - $feature->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $feature->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $feature->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $feature->movePositionDown(); - } + return $this->genericUpdatePosition(FeatureQuery::create(), $event); } protected function doAddToAllTemplates(FeatureModel $feature) diff --git a/core/lib/Thelia/Action/FeatureAv.php b/core/lib/Thelia/Action/FeatureAv.php index 2bd117b4b..25f9ae5f2 100644 --- a/core/lib/Thelia/Action/FeatureAv.php +++ b/core/lib/Thelia/Action/FeatureAv.php @@ -112,19 +112,7 @@ class FeatureAv extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $feature = FeatureAvQuery::create()->findPk($event->getObjectId())) { - - $feature->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $feature->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $feature->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $feature->movePositionDown(); - } + return $this->genericUpdatePosition(FeatureAvQuery::create(), $event); } diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index 47576c8cc..97c3dbdd7 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -58,6 +58,9 @@ use Thelia\Core\Event\ProductSetTemplateEvent; use Thelia\Model\AttributeCombinationQuery; use Thelia\Core\Template\Loop\ProductSaleElements; use Thelia\Model\ProductSaleElementsQuery; +use Propel\Runtime\ActiveQuery\PropelQuery; +use Thelia\Core\Event\ProductDeleteCategoryEvent; +use Thelia\Core\Event\ProductAddCategoryEvent; class Product extends BaseAction implements EventSubscriberInterface { @@ -81,7 +84,15 @@ class Product extends BaseAction implements EventSubscriberInterface // Set the default tax rule to this product ->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true)) - ->create($event->getDefaultCategory()) + //public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight) { + + ->create( + $event->getDefaultCategory(), + $event->getBasePrice(), + $event->getCurrencyId(), + $event->getTaxRuleId(), + $event->getBaseWeight() + ); ; $event->setProduct($product); @@ -94,8 +105,6 @@ class Product extends BaseAction implements EventSubscriberInterface */ public function update(ProductUpdateEvent $event) { - $search = ProductQuery::create(); - if (null !== $product = ProductQuery::create()->findPk($event->getProductId())) { $product @@ -162,19 +171,7 @@ class Product extends BaseAction implements EventSubscriberInterface */ public function updatePosition(UpdatePositionEvent $event) { - if (null !== $product = ProductQuery::create()->findPk($event->getObjectId())) { - - $product->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $product->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $product->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $product->movePositionDown(); - } + return $this->genericUpdatePosition(ProductQuery::create(), $event); } public function addContent(ProductAddContentEvent $event) { @@ -208,6 +205,34 @@ class Product extends BaseAction implements EventSubscriberInterface ; } + public function addCategory(ProductAddCategoryEvent $event) { + + if (ProductCategoryQuery::create() + ->filterByProduct($event->getProduct()) + ->filterByCategoryId($event->getCategoryId()) + ->count() <= 0) { + + $productCategory = new ProductCategory(); + + $productCategory + ->setProduct($event->getProduct()) + ->setCategoryId($event->getCategoryId()) + ->setDefaultCategory(false) + ->save() + ; + } + } + + public function removeCategory(ProductDeleteCategoryEvent $event) { + + $productCategory = ProductCategoryQuery::create() + ->filterByProduct($event->getProduct()) + ->filterByCategoryId($event->getCategoryId()) + ->findOne(); + + if ($productCategory != null) $productCategory->delete(); + } + public function addAccessory(ProductAddAccessoryEvent $event) { if (AccessoryQuery::create() @@ -259,25 +284,23 @@ class Product extends BaseAction implements EventSubscriberInterface } /** - * Changes position, selecting absolute ou relative change. + * Changes accessry position, selecting absolute ou relative change. * * @param ProductChangePositionEvent $event */ public function updateAccessoryPosition(UpdatePositionEvent $event) { - if (null !== $accessory = AccessoryQuery::create()->findPk($event->getObjectId())) { + return $this->genericUpdatePosition(AccessoryQuery::create(), $event); + } - $accessory->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - return $accessory->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - return $accessory->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - return $accessory->movePositionDown(); - } + /** + * Changes position, selecting absolute ou relative change. + * + * @param ProductChangePositionEvent $event + */ + public function updateContentPosition(UpdatePositionEvent $event) + { + return $this->genericUpdatePosition(ProductAssociatedContentQuery::create(), $event); } public function updateFeatureProductValue(FeatureProductUpdateEvent $event) { @@ -299,10 +322,8 @@ class Product extends BaseAction implements EventSubscriberInterface } $featureProduct = $featureProductQuery->findOne(); -echo "
create or update: f=".$event->getFeatureId().", p=".$event->getProductId(); if ($featureProduct == null) { -echo " Create !"; $featureProduct = new FeatureProduct(); $featureProduct @@ -313,7 +334,6 @@ echo " Create !"; ; } - else echo " Update !"; if ($event->getIsTextValue() == true) { $featureProduct->setFreeTextValue($event->getFeatureValue()); @@ -321,7 +341,6 @@ echo " Create !"; else { $featureProduct->setFeatureAvId($event->getFeatureValue()); } -echo "value=".$event->getFeatureValue(); $featureProduct->save(); @@ -335,8 +354,6 @@ echo "value=".$event->getFeatureValue(); ->filterByFeatureId($event->getFeatureId()) ->delete() ; - - echo "
Delete p=".$event->getProductId().", f=".$event->getFeatureId(); } /** @@ -355,10 +372,14 @@ echo "value=".$event->getFeatureValue(); TheliaEvents::PRODUCT_ADD_CONTENT => array("addContent", 128), TheliaEvents::PRODUCT_REMOVE_CONTENT => array("removeContent", 128), TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION => array("updateAccessoryPosition", 128), + TheliaEvents::PRODUCT_UPDATE_CONTENT_POSITION => array("updateContentPosition", 128), TheliaEvents::PRODUCT_ADD_ACCESSORY => array("addAccessory", 128), TheliaEvents::PRODUCT_REMOVE_ACCESSORY => array("removeAccessory", 128), + TheliaEvents::PRODUCT_ADD_CATEGORY => array("addCategory", 128), + TheliaEvents::PRODUCT_REMOVE_CATEGORY => array("removeCategory", 128), + TheliaEvents::PRODUCT_SET_TEMPLATE => array("setProductTemplate", 128), TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE => array("updateFeatureProductValue", 128), diff --git a/core/lib/Thelia/Action/Template.php b/core/lib/Thelia/Action/Template.php index 101332a75..47d5d7a4d 100644 --- a/core/lib/Thelia/Action/Template.php +++ b/core/lib/Thelia/Action/Template.php @@ -142,9 +142,7 @@ class Template extends BaseAction implements EventSubscriberInterface */ public function updateAttributePosition(UpdatePositionEvent $event) { - $attributeTemplate = AttributeTemplateQuery::create()->findPk($event->getObjectId()); - - $this->updatePosition($attributeTemplate, $event); + return $this->genericUpdatePosition(AttributeTemplateQuery::create(), $event); } /** @@ -154,26 +152,7 @@ class Template extends BaseAction implements EventSubscriberInterface */ public function updateFeaturePosition(UpdatePositionEvent $event) { - $featureTemplate = FeatureTemplateQuery::create()->findPk($event->getObjectId()); - - $this->updatePosition($featureTemplate, $event); - } - - protected function updatePosition($object, UpdatePositionEvent $event) - { - if (null !== $object) { - - $object->setDispatcher($this->getDispatcher()); - - $mode = $event->getMode(); - - if ($mode == UpdatePositionEvent::POSITION_ABSOLUTE) - $object->changeAbsolutePosition($event->getPosition()); - else if ($mode == UpdatePositionEvent::POSITION_UP) - $object->movePositionUp(); - else if ($mode == UpdatePositionEvent::POSITION_DOWN) - $object->movePositionDown(); - } + return $this->genericUpdatePosition(FeatureTemplateQuery::create(), $event); } public function deleteAttribute(TemplateDeleteAttributeEvent $event) { diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 7eacde1cd..5b40ff65a 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -155,13 +155,24 @@ Thelia\Controller\Admin\ProductController::loadGeneralAjaxTabAction - + Thelia\Controller\Admin\ProductController::loadRelatedAjaxTabAction + + + + Thelia\Controller\Admin\ProductController::addAdditionalCategoryAction + + + + Thelia\Controller\Admin\ProductController::deleteAdditionalCategoryAction + + + Thelia\Controller\Admin\ProductController::addRelatedContentAction @@ -175,6 +186,10 @@ xml|json + + Thelia\Controller\Admin\ProductController::updateContentPositionAction + + diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 67d1e8a5b..2bac27101 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -446,6 +446,8 @@ abstract class AbstractCrudController extends BaseAdminController /** * Update object position (only for objects whichsupport that) + * + * FIXME: integrate with genericUpdatePositionAction */ public function updatePositionAction() { @@ -483,6 +485,38 @@ abstract class AbstractCrudController extends BaseAdminController } } + protected function genericUpdatePositionAction($object, $eventName, $doFinalRedirect = true) { + + // Check current user authorization + if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; + + if ($object != null) { + + try { + $mode = $this->getRequest()->get('mode', null); + + if ($mode == 'up') + $mode = UpdatePositionEvent::POSITION_UP; + else if ($mode == 'down') + $mode = UpdatePositionEvent::POSITION_DOWN; + else + $mode = UpdatePositionEvent::POSITION_ABSOLUTE; + + $position = $this->getRequest()->get('position', null); + + $event = new UpdatePositionEvent($object->getId(), $mode, $position); + + $this->dispatch($eventName, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + if ($doFinalRedirect) $this->redirectToEditionTemplate(); + } + /** * Online status toggle (only for object which support it) */ diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 12ad3510d..2b1cc9550 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -48,6 +48,9 @@ use Thelia\Model\FeatureQuery; use Thelia\Core\Event\FeatureProductDeleteEvent; use Thelia\Model\FeatureTemplateQuery; use Thelia\Core\Event\ProductSetTemplateEvent; +use Thelia\Model\Base\ProductSaleElementsQuery; +use Thelia\Core\Event\ProductAddCategoryEvent; +use Thelia\Core\Event\ProductDeleteCategoryEvent; /** * Manages products @@ -77,33 +80,6 @@ class ProductController extends AbstractCrudController ); } - /** - * General ajax tab loading - */ - public function loadGeneralAjaxTabAction() { - - // Load the object - $object = $this->getExistingObject(); - - if ($object != null) { - - // Hydrate the form abd pass it to the parser - $changeForm = $this->hydrateObjectForm($object); - - // Pass it to the parser - $this->getParserContext()->addForm($changeForm); - - return $this->render( - 'ajax/product-general-tab', - array( - 'product_id' => $this->getRequest()->get('product_id', 0), - ) - ); - } - - $this->redirectToListTemplate(); - } - /** * Attributes ajax tab loading */ @@ -125,9 +101,10 @@ class ProductController extends AbstractCrudController return $this->render( 'ajax/product-related-tab', array( - 'product_id' => $this->getRequest()->get('product_id', 0), - 'folder_id' => $this->getRequest()->get('folder_id', 0), - 'accessory_category_id'=> $this->getRequest()->get('accessory_category_id', 0) + 'product_id' => $this->getRequest()->get('product_id', 0), + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'accessory_category_id' => $this->getRequest()->get('accessory_category_id', 0) + ) ); } @@ -152,6 +129,10 @@ class ProductController extends AbstractCrudController ->setLocale($formData['locale']) ->setDefaultCategory($formData['default_category']) ->setVisible($formData['visible']) + ->setBasePrice($formData['price']) + ->setBaseWeight($formData['weight']) + ->setCurrencyId($formData['currency']) + ->setTaxRuleId($formData['tax_rule']) ; return $createEvent; @@ -171,6 +152,10 @@ class ProductController extends AbstractCrudController ->setVisible($formData['visible']) ->setUrl($formData['url']) ->setDefaultCategory($formData['default_category']) + ->setBasePrice($formData['price']) + ->setBaseWeight($formData['weight']) + ->setCurrencyId($formData['currency']) + ->setTaxRuleId($formData['tax_rule']) ; return $changeEvent; @@ -197,6 +182,11 @@ class ProductController extends AbstractCrudController protected function hydrateObjectForm($object) { + // Get the default produc sales element + $salesElement = ProductSaleElementsQuery::create()->filterByProduct($object)->filterByIsDefault(true)->findOne(); + +// $prices = $salesElement->getProductPrices(); + // Prepare the data that will hydrate the form $data = array( 'id' => $object->getId(), @@ -209,6 +199,8 @@ class ProductController extends AbstractCrudController 'visible' => $object->getVisible(), 'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()), 'default_category' => $object->getDefaultCategoryId() + + // A terminer pour les prix ); // Setup the object form @@ -240,10 +232,10 @@ class ProductController extends AbstractCrudController protected function getEditionArguments() { return array( - 'category_id' => $this->getCategoryId(), - 'product_id' => $this->getRequest()->get('product_id', 0), - 'folder_id' => $this->getRequest()->get('folder_id', 0), - 'accessory_category_id'=> $this->getRequest()->get('accessory_category_id', 0), + 'category_id' => $this->getCategoryId(), + 'product_id' => $this->getRequest()->get('product_id', 0), + 'folder_id' => $this->getRequest()->get('folder_id', 0), + 'accessory_category_id' => $this->getRequest()->get('accessory_category_id', 0), 'current_tab' => $this->getRequest()->get('current_tab', 'general') ); } @@ -478,7 +470,6 @@ class ProductController extends AbstractCrudController public function deleteAccessoryAction() { - // Check current user authorization if (null !== $response = $this->checkAuth("admin.products.update")) return $response; @@ -508,33 +499,26 @@ class ProductController extends AbstractCrudController */ public function updateAccessoryPositionAction() { - // Check current user authorization - if (null !== $response = $this->checkAuth('admin.products.update')) return $response; + $accessory = AccessoryQuery::create()->findPk($this->getRequest()->get('accessory_id', null)); - try { - $mode = $this->getRequest()->get('mode', null); - - if ($mode == 'up') - $mode = UpdatePositionEvent::POSITION_UP; - else if ($mode == 'down') - $mode = UpdatePositionEvent::POSITION_DOWN; - else - $mode = UpdatePositionEvent::POSITION_ABSOLUTE; - - $position = $this->getRequest()->get('position', null); - - $event = new UpdatePositionEvent($this->getRequest()->get('accessory_id', null), $mode, $position); - - $this->dispatch(TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION, $event); - } - catch (\Exception $ex) { - // Any error - return $this->errorPage($ex); - } - - $this->redirectToEditionTemplate(); + return $this->genericUpdatePositionAction( + $accessory, + TheliaEvents::PRODUCT_UPDATE_ACCESSORY_POSITION + ); } + /** + * Update related content position + */ + public function updateContentPositionAction() + { + $content = ProductAssociatedContentQuery::create()->findPk($this->getRequest()->get('content_id', null)); + + return $this->genericUpdatePositionAction( + $content, + TheliaEvents::PRODUCT_UPDATE_CONTENT_POSITION + ); + } /** * Change product template for a given product. @@ -636,4 +620,56 @@ class ProductController extends AbstractCrudController // Redirect to the category/product list $this->redirectToListTemplate(); } + + public function addAdditionalCategoryAction() { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $category_id = intval($this->getRequest()->get('additional_category_id')); + + if ($category_id > 0) { + + $event = new ProductAddCategoryEvent( + $this->getExistingObject(), + $category_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_ADD_CATEGORY, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } + + public function deleteAdditionalCategoryAction() { + + // Check current user authorization + if (null !== $response = $this->checkAuth("admin.products.update")) return $response; + + $category_id = intval($this->getRequest()->get('additional_category_id')); + + if ($category_id > 0) { + + $event = new ProductDeleteCategoryEvent( + $this->getExistingObject(), + $category_id + ); + + try { + $this->dispatch(TheliaEvents::PRODUCT_REMOVE_CATEGORY, $event); + } + catch (\Exception $ex) { + // Any error + return $this->errorPage($ex); + } + } + + $this->redirectToEditionTemplate(); + } } diff --git a/core/lib/Thelia/Controller/Admin/TemplateController.php b/core/lib/Thelia/Controller/Admin/TemplateController.php index b8e9c0082..fb32e4231 100644 --- a/core/lib/Thelia/Controller/Admin/TemplateController.php +++ b/core/lib/Thelia/Controller/Admin/TemplateController.php @@ -266,7 +266,7 @@ class TemplateController extends AbstractCrudController ->findOne() ; - return $this->updatePosition( + return $this->genericUpdatePositionAction( $attributeTemplate, TheliaEvents::TEMPLATE_CHANGE_ATTRIBUTE_POSITION ); @@ -325,41 +325,9 @@ class TemplateController extends AbstractCrudController ->findOne() ; - return $this->updatePosition( + return $this->genericUpdatePositionAction( $featureTemplate, TheliaEvents::TEMPLATE_CHANGE_FEATURE_POSITION ); } - - protected function updatePosition($object, $eventName) { - - // Check current user authorization - if (null !== $response = $this->checkAuth($this->updatePermissionIdentifier)) return $response; - - if ($object != null) { - - try { - $mode = $this->getRequest()->get('mode', null); - - if ($mode == 'up') - $mode = UpdatePositionEvent::POSITION_UP; - else if ($mode == 'down') - $mode = UpdatePositionEvent::POSITION_DOWN; - else - $mode = UpdatePositionEvent::POSITION_ABSOLUTE; - - $position = $this->getRequest()->get('position', null); - - $event = new UpdatePositionEvent($object->getId(), $mode, $position); - - $this->dispatch($eventName, $event); - } - catch (\Exception $ex) { - // Any error - return $this->errorPage($ex); - } - } - - $this->redirectToEditionTemplate(); - } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/ProductAddCategoryEvent.php b/core/lib/Thelia/Core/Event/ProductAddCategoryEvent.php new file mode 100644 index 000000000..215b61f99 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductAddCategoryEvent.php @@ -0,0 +1,48 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; + +use Thelia\Model\Product; + +class ProductAddCategoryEvent extends ProductEvent +{ + protected $category_id; + + public function __construct(Product $product, $category_id) + { + parent::__construct($product); + + $this->category_id = $category_id; + } + + public function getCategoryId() + { + return $this->category_id; + } + + public function setCategoryId($category_id) + { + $this->category_id = $category_id; + } +} diff --git a/core/lib/Thelia/Core/Event/ProductCreateEvent.php b/core/lib/Thelia/Core/Event/ProductCreateEvent.php index d2d30a11a..012d29793 100644 --- a/core/lib/Thelia/Core/Event/ProductCreateEvent.php +++ b/core/lib/Thelia/Core/Event/ProductCreateEvent.php @@ -31,6 +31,11 @@ class ProductCreateEvent extends ProductEvent protected $default_category; protected $visible; + protected $basePrice; + protected $baseWeight; + protected $taxRuleId; + protected $currencyId; + public function getRef() { return $this->ref; @@ -85,4 +90,48 @@ class ProductCreateEvent extends ProductEvent $this->visible = $visible; return $this; } + + public function getBasePrice() + { + return $this->basePrice; + } + + public function setBasePrice($basePrice) + { + $this->basePrice = $basePrice; + return $this; + } + + public function getBaseWeight() + { + return $this->baseWeight; + } + + public function setBaseWeight($baseWeight) + { + $this->baseWeight = $baseWeight; + return $this; + } + + public function getTaxRuleId() + { + return $this->taxRuleId; + } + + public function setTaxRuleId($taxRuleId) + { + $this->taxRuleId = $taxRuleId; + return $this; + } + + public function getCurrencyId() + { + return $this->currencyId; + } + + public function setCurrencyId($currencyId) + { + $this->currencyId = $currencyId; + return $this; + } } diff --git a/core/lib/Thelia/Core/Event/ProductDeleteCategoryEvent.php b/core/lib/Thelia/Core/Event/ProductDeleteCategoryEvent.php new file mode 100644 index 000000000..4fcfeee92 --- /dev/null +++ b/core/lib/Thelia/Core/Event/ProductDeleteCategoryEvent.php @@ -0,0 +1,50 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event; +use Thelia\Model\Product; + +class ProductDeleteCategoryEvent extends ProductEvent +{ + protected $category_id; + + public function __construct(Product $product, $category_id) + { + parent::__construct($product); + + $this->category_id = $category_id; + } + + public function getCategoryId() + { + return $this->category_id; + } + + public function setCategoryId($category_id) + { + $this->category_id = $category_id; + + return $this; + } + +} diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 31a1d4730..767800733 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -184,17 +184,21 @@ final class TheliaEvents const PRODUCT_TOGGLE_VISIBILITY = "action.toggleProductVisibility"; const PRODUCT_UPDATE_POSITION = "action.updateProductPosition"; - const PRODUCT_ADD_CONTENT = "action.productAddContent"; - const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent"; + const PRODUCT_ADD_CONTENT = "action.productAddContent"; + const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent"; + const PRODUCT_UPDATE_CONTENT_POSITION = "action.updateProductContentPosition"; const PRODUCT_SET_TEMPLATE = "action.productSetTemplate"; - const PRODUCT_ADD_ACCESSORY = "action.productAddAccessory"; - const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveAccessory"; - const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductPosition"; + const PRODUCT_ADD_ACCESSORY = "action.productAddProductAccessory"; + const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveProductAccessory"; + const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductAccessoryPosition"; - const PRODUCT_FEATURE_UPDATE_VALUE = "action.after_updateProductFeatureValue"; - const PRODUCT_FEATURE_DELETE_VALUE = "action.after_deleteProductFeatureValue"; + const PRODUCT_FEATURE_UPDATE_VALUE = "action.updateProductFeatureValue"; + const PRODUCT_FEATURE_DELETE_VALUE = "action.deleteProductFeatureValue"; + + const PRODUCT_ADD_CATEGORY = "action.addProductCategory"; + const PRODUCT_REMOVE_CATEGORY = "action.deleteProductCategory"; const BEFORE_CREATEPRODUCT = "action.before_createproduct"; const AFTER_CREATEPRODUCT = "action.after_createproduct"; diff --git a/core/lib/Thelia/Core/Template/Loop/Accessory.php b/core/lib/Thelia/Core/Template/Loop/Accessory.php index 6dc269b62..34d674c10 100755 --- a/core/lib/Thelia/Core/Template/Loop/Accessory.php +++ b/core/lib/Thelia/Core/Template/Loop/Accessory.php @@ -74,6 +74,7 @@ class Accessory extends Product $search = AccessoryQuery::create(); $product = $this->getProduct(); + $search->filterByProductId($product, Criteria::IN); $order = $this->getOrder(); @@ -93,10 +94,16 @@ class Accessory extends Product $accessories = $this->search($search); $accessoryIdList = array(0); - $accessoryPosition = array(); + $accessoryPosition = $accessoryId = array(); + foreach ($accessories as $accessory) { - array_push($accessoryIdList, $accessory->getAccessory()); - $accessoryPosition[$accessory->getAccessory()] = $accessory->getPosition(); + + $accessoryProductId = $accessory->getAccessory(); + + array_push($accessoryIdList, $accessoryProductId); + + $accessoryPosition[$accessoryProductId] = $accessory->getPosition(); + $accessoryId[$accessoryProductId] = $accessory->getId(); } $receivedIdList = $this->getId(); @@ -111,12 +118,15 @@ class Accessory extends Product $loopResult = parent::exec($pagination); foreach($loopResult as $loopResultRow) { + + $accessoryProductId = $loopResultRow->get('ID'); + $loopResultRow - ->set("POSITION" , $accessoryPosition[$loopResultRow->get('ID')]) - ; + ->set("ID" , $accessoryId[$accessoryProductId]) + ->set("POSITION", $accessoryPosition[$accessoryProductId]) + ; } return $loopResult; } - } diff --git a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php index 20fe5cb1e..78794b715 100755 --- a/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php +++ b/core/lib/Thelia/Core/Template/Loop/AssociatedContent.php @@ -135,8 +135,17 @@ class AssociatedContent extends Content $associatedContents = $this->search($search); $associatedContentIdList = array(0); + + $contentIdList = array(0); + $contentPosition = $contentId = array(); + foreach ($associatedContents as $associatedContent) { - array_push($associatedContentIdList, $associatedContent->getContentId()); + + $associatedContentId = $associatedContent->getContentId(); + + array_push($associatedContentIdList, $associatedContentId); + $contentPosition[$associatedContentId] = $associatedContent->getPosition(); + $contentId[$associatedContentId] = $associatedContent->getId(); } $receivedIdList = $this->getId(); @@ -148,7 +157,18 @@ class AssociatedContent extends Content $this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $associatedContentIdList)) ); } - return parent::exec($pagination); - } + $loopResult = parent::exec($pagination); + foreach($loopResult as $loopResultRow) { + + $relatedContentId = $loopResultRow->get('ID'); + + $loopResultRow + ->set("ID" , $contentId[$relatedContentId]) + ->set("POSITION", $contentPosition[$relatedContentId]) + ; + } + + return $loopResult; + } } diff --git a/core/lib/Thelia/Core/Template/Loop/Attribute.php b/core/lib/Thelia/Core/Template/Loop/Attribute.php index cb4a1cfdf..9a9aa6ff3 100755 --- a/core/lib/Thelia/Core/Template/Loop/Attribute.php +++ b/core/lib/Thelia/Core/Template/Loop/Attribute.php @@ -121,12 +121,15 @@ class Attribute extends BaseI18nLoop // Create template array if ($template == null) $template = array(); - foreach($products as $product) - $template[] = $product->getTemplateId(); + foreach($products as $product) { + $tpl_id = $product->getTemplateId(); + + if (! is_null($tpl_id)) $template[] = $tpl_id; + } } } - if (null !== $template) { + if (! empty($template)) { // Join with feature_template table to get position $search diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 7a0bac76d..9c9ddab7d 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -35,6 +35,7 @@ use Thelia\Model\CategoryQuery; use Thelia\Type\TypeCollection; use Thelia\Type; use Thelia\Type\BooleanOrBothType; +use Thelia\Model\ProductQuery; /** * @@ -73,6 +74,8 @@ class Category extends BaseI18nLoop return new ArgumentCollection( Argument::createIntListTypeArgument('id'), Argument::createIntTypeArgument('parent'), + Argument::createIntTypeArgument('product'), + Argument::createIntTypeArgument('exclude_product'), Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('not_empty', 0), Argument::createBooleanOrBothTypeArgument('visible', 1), @@ -128,6 +131,22 @@ class Category extends BaseI18nLoop if ($this->getVisible() != BooleanOrBothType::ANY) $search->filterByVisible($this->getVisible() ? 1 : 0); + $product = $this->getProduct(); + + if ($product != null) { + $obj = ProductQuery::create()->findPk($product); + + if ($obj != null) $search->filterByProduct($obj, Criteria::IN); + } + + $exclude_product = $this->getExclude_product(); + + if ($exclude_product != null) { + $obj = ProductQuery::create()->findPk($exclude_product); + + if ($obj != null) $search->filterByProduct($obj, Criteria::NOT_IN); + } + $orders = $this->getOrder(); foreach ($orders as $order) { diff --git a/core/lib/Thelia/Core/Template/Loop/Feature.php b/core/lib/Thelia/Core/Template/Loop/Feature.php index c8fb2b8f1..f542b2e8d 100755 --- a/core/lib/Thelia/Core/Template/Loop/Feature.php +++ b/core/lib/Thelia/Core/Template/Loop/Feature.php @@ -124,12 +124,15 @@ class Feature extends BaseI18nLoop // Create template array if ($template == null) $template = array(); - foreach($products as $product) - $template[] = $product->getTemplateId(); + foreach($products as $product) { + $tpl_id = $product->getTemplateId(); + + if (! is_null($tpl_id)) $template[] = $tpl_id; + } } } - if (null !== $template) { + if (! empty($template)) { // Join with feature_template table to get position $search diff --git a/core/lib/Thelia/Form/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php index 8050dcff9..82208981e 100644 --- a/core/lib/Thelia/Form/ProductCreationForm.php +++ b/core/lib/Thelia/Form/ProductCreationForm.php @@ -47,23 +47,43 @@ class ProductCreationForm extends BaseForm "label_attr" => array("for" => "ref") )) ->add("title", "text", array( - // "constraints" => array(new NotBlank()), + "constraints" => array(new NotBlank()), "label" => "Product title *", "label_attr" => array("for" => "title") )) ->add("default_category", "integer", array( - // "constraints" => array(new NotBlank()), - "label" => Translator::getInstance()->trans("Default product category."), + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Default product category *"), "label_attr" => array("for" => "default_category_field") )) ->add("locale", "text", array( - //"constraints" => array(new NotBlank()) + "constraints" => array(new NotBlank()) )) ->add("visible", "integer", array( - "label" => Translator::getInstance()->trans("This product is online."), + "label" => Translator::getInstance()->trans("This product is online"), "label_attr" => array("for" => "visible_field") )) - ; + ->add("price", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Product base price excluding taxes *"), + "label_attr" => array("for" => "price_field") + )) + ->add("currency", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Price currency *"), + "label_attr" => array("for" => "currency_field") + )) + ->add("tax_rule", "integer", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Tax rule for this product *"), + "label_attr" => array("for" => "tax_rule_field") + )) + ->add("weight", "number", array( + "constraints" => array(new NotBlank()), + "label" => Translator::getInstance()->trans("Weight *"), + "label_attr" => array("for" => "weight_field") + )) + ; } public function checkDuplicateRef($value, ExecutionContextInterface $context) diff --git a/core/lib/Thelia/Model/Product.php b/core/lib/Thelia/Model/Product.php index 09a9b75db..3070e1915 100755 --- a/core/lib/Thelia/Model/Product.php +++ b/core/lib/Thelia/Model/Product.php @@ -98,7 +98,8 @@ class Product extends BaseProduct ->filterByDefaultCategory(true) ->findOne() ; - +var_dump($productCategory); +exit; if ($productCategory == null || $productCategory->getCategoryId() != $defaultCategoryId) { // Delete the old default category @@ -120,8 +121,13 @@ class Product extends BaseProduct * Create a new product, along with the default category ID * * @param int $defaultCategoryId the default category ID of this product + * @param float $basePrice the product base price + * @param int $priceCurrencyId the price currency Id + * @param int $taxRuleId the product tax rule ID + * @param float $baseWeight base weight in Kg */ - public function create($defaultCategoryId) { + + public function create($defaultCategoryId, $basePrice, $priceCurrencyId, $taxRuleId, $baseWeight) { $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME); @@ -139,6 +145,8 @@ class Product extends BaseProduct // Set the position $this->setPosition($this->getNextPosition())->save($con); + $this->setTaxRuleId($taxRuleId); + // Create an empty product sale element $sale_elements = new ProductSaleElements(); @@ -147,7 +155,8 @@ class Product extends BaseProduct ->setRef($this->getRef()) ->setPromo(0) ->setNewness(0) - ->setWeight(0) + ->setWeight($baseWeight) + ->setIsDefault(true) ->save($con) ; @@ -156,9 +165,9 @@ class Product extends BaseProduct $product_price ->setProductSaleElements($sale_elements) - ->setPromoPrice(0) - ->setPrice(0) - ->setCurrency(CurrencyQuery::create()->findOneByByDefault(true)) + ->setPromoPrice($basePrice) + ->setPrice($basePrice) + ->setCurrencyId($priceCurrencyId) ->save($con) ; diff --git a/core/lib/Thelia/Model/ProductAssociatedContent.php b/core/lib/Thelia/Model/ProductAssociatedContent.php index e07ee2cd6..843d76ba1 100644 --- a/core/lib/Thelia/Model/ProductAssociatedContent.php +++ b/core/lib/Thelia/Model/ProductAssociatedContent.php @@ -11,11 +11,22 @@ class ProductAssociatedContent extends BaseProductAssociatedContent { use \Thelia\Model\Tools\ModelEventDispatcherTrait; + use \Thelia\Model\Tools\PositionManagementTrait; + + /** + * Calculate next position relative to our product + */ + protected function addCriteriaToPositionQuery($query) { + $query->filterByProductId($this->getProductId()); + } + /** * {@inheritDoc} */ public function preInsert(ConnectionInterface $con = null) { + $this->setPosition($this->getNextPosition()); + $this->dispatchEvent(TheliaEvents::BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT, new ProductAssociatedContentEvent($this)); return true; diff --git a/install/faker.php b/install/faker.php index 2c82f5d1b..fd74447db 100755 --- a/install/faker.php +++ b/install/faker.php @@ -404,6 +404,7 @@ try { $stock->setPromo($faker->randomNumber(0,1)); $stock->setNewness($faker->randomNumber(0,1)); $stock->setWeight($faker->randomFloat(2, 100,10000)); + $stock->setIsDefault($i == 0); $stock->save(); $productPrice = new \Thelia\Model\ProductPrice(); diff --git a/install/insert.sql b/install/insert.sql index aa7573d12..ec4e1b02b 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -1153,7 +1153,7 @@ INSERT INTO `tax` (`id`, `type`, `serialized_requirements`, `created_at`, `upda INSERT INTO `tax_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'French 19.6% VAT'); INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) VALUES @@ -1162,7 +1162,7 @@ INSERT INTO `tax_rule` (`id`, `is_default`, `created_at`, `updated_at`) INSERT INTO `tax_rule_i18n` (`id`, `locale`, `title`) VALUES (1, 'fr_FR', 'TVA française à 19.6%'), - (1, 'en_UK', 'french 19.6% tax'); + (1, 'en_US', 'French 19.6% VAT'); INSERT INTO `tax_rule_country` (`tax_rule_id`, `country_id`, `tax_id`, `position`, `created_at`, `updated_at`) VALUES diff --git a/templates/admin/default/ajax/product-attributes-tab.html b/templates/admin/default/ajax/product-attributes-tab.html index 2cccbfadf..a3215f215 100644 --- a/templates/admin/default/ajax/product-attributes-tab.html +++ b/templates/admin/default/ajax/product-attributes-tab.html @@ -31,7 +31,7 @@ - + @@ -43,9 +43,6 @@ {* Check if a product template is defined *} - {loop name="product_template" type="template" id={$TEMPLATE|default:0}}{/loop} - - {ifloop rel="product_template"}

{intl l='Product Attributes and Features'}

@@ -70,10 +67,18 @@

{intl l='Product Attributes'}

-

{intl - l="You can change attributes and their positions in the template configuration page." +

+ {if $TEMPLATE} + {intl + l="You can change template attributes and their positions in the template configuration page." tpl_mgmt_url={url path='/admin/configuration/templates/update' template_id=$TEMPLATE} - } + } + {else} + {intl + l="You can change attributes and their positions in the attributes configuration page." + tpl_mgmt_url={url path='/admin/configuration/attributes'} + } + {/if}

Please code me baby, oh yeah ! Code me NOW !
@@ -88,10 +93,18 @@

{intl l='Product Features'}

-

{intl - l="You can change feature products and their positions in the template configuration page." - tpl_mgmt_url={url path='/admin/configuration/templates/update' template_id=$TEMPLATE} - } +

+ {if $TEMPLATE} + {intl + l="You can change templates features and their positions in the template configuration page." + tpl_mgmt_url={url path='/admin/configuration/templates/update' template_id=$TEMPLATE} + } + {else} + {intl + l="You can change feature and their positions in the features configuration page." + tpl_mgmt_url={url path='/admin/configuration/features'} + } + {/if}

@@ -139,7 +152,7 @@
- {intl l='Use ctrl+clic to select more than one value. You can also clear selected values.' id=$ID} + {intl l='Use Ctrl+click to select more than one value. You can also clear selected values.' id=$ID} {/ifloop} @@ -179,18 +192,7 @@
- {/ifloop} - {elseloop rel="product_template"} -
-
-

{* <---- FIXME Lame ! *} -
- {intl l="This product is not attached to any product template. If you want to use features or attributes on this product, please select the proper template. You can define product templates in the Configuration section."} -
-
-
- {/elseloop}
{/loop} diff --git a/templates/admin/default/ajax/product-prices-tab.html b/templates/admin/default/ajax/product-prices-tab.html new file mode 100644 index 000000000..2878e1d9d --- /dev/null +++ b/templates/admin/default/ajax/product-prices-tab.html @@ -0,0 +1,75 @@ +{loop name="product_edit" type="product" visible="*" id=$product_id backend_context="1" lang=$edit_language_id} +
+ +
+
+
{intl l="Basic product information"}
+
+ +
+ +
+
+ {form_field form=$form field='price'} +
+ + {loop type="currency" name="default-currency" default_only="1" backend_context="1"} + +
+ + {$SYMBOL} +
+
{intl l='Enter here the product price in the default currency (%title)' title=$NAME}
+ + {form_field form=$form field='currency'} + + {/form_field} + + {/loop} +
+ {/form_field} +
+ +
+ {form_field form=$form field='tax_rule'} +
+ +
+ +
+ +
{intl l='Select here the tax applicable to this product'}
+ +
+ {/form_field} +
+ +
+ Price w/tax +
+
+ + {form_field form=$form field='weight'} +
+ + +
+
+
+ + {intl l="Kg"} +
+
+
+ +
{intl l='Enter here the product weight, in Kilogrammes'}
+
+ {/form_field} +
+
+{/loop} \ No newline at end of file diff --git a/templates/admin/default/ajax/product-related-tab.html b/templates/admin/default/ajax/product-related-tab.html index 8d705e9ae..977ecf83c 100644 --- a/templates/admin/default/ajax/product-related-tab.html +++ b/templates/admin/default/ajax/product-related-tab.html @@ -9,228 +9,347 @@ close_url = "{url path='/admin/categories' category_id=$DEFAULT_CATEGORY}" } - {* -- Begin related content management -- *} +
-
-
- + +
+ + {* -- Begin categories management ----------------------------------- *} + +
+
+
+ {elseloop rel="categories"} +
{intl l="No categories found"}
+ {/elseloop} -
-
- {intl l="No available content in this folder"} -
-
- {/ifloop} + +
- {elseloop rel="folders"} -
{intl l="No folders found"}
- {/elseloop} +
+ + + + - - + -
-
{intl l='ID'}{intl l='Category title'}
- - - + {module_include location='product_categories_table_header'} - + + + - {module_include location='product_contents_table_header'} + + {loop name="additional_categories" type="category" product=$product_id exclude=$DEFAULT_CATEGORY backend_context="1" lang="$edit_language_id"} + + - - - + - - {loop name="assigned_contents" type="associated_content" product="$product_id" backend_context="1" lang="$edit_language_id"} - - + {module_include location='product_categories_table_row'} - - - {module_include location='product_contents_table_row'} - - - - {/loop} - - {elseloop rel="assigned_contents"} - - - - {/elseloop} - -
{intl l='ID'}{intl l='Content title'}{intl l="Actions"}
{$ID}{intl l="Actions"}
+ {$TITLE} +
{$ID} - {$TITLE} - -
- {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.product.content.delete"} - - - - {/loop} -
-
-
- {intl l="This product contains no contents"} -
-
-
-
- - {* -- End related content management ---- *} - - {* -- Begin accessories management ------ *} - -
-
-
- -

{intl l='Product accessories'}

-

{intl l='Define here this product\'s accessories'}

- - - - - {ifloop rel="categories"} -
- - {intl l='Select a category to get its products'} -
- -
-
- - - - -
- - {intl l='Select a product and click (+) to add it as an accessory'} -
- -
-
- {intl l="No available product in this category"} -
-
- - {/ifloop} - - {elseloop rel="categories"} -
{intl l="No categories found"}
- {/elseloop} - -
-
- -
- - - - - - - - - - {module_include location='product_accessories_table_header'} - - - - - - - {loop name="assigned_accessories" order="accessory" type="accessory" product="$product_id" backend_context="1" lang="$edit_language_id"} - - - - - - - - {module_include location='product_accessories_table_row'} - - - - {/loop} - - {elseloop rel="assigned_accessories"} - - - - {/elseloop} - -
{intl l='ID'}{intl l='Accessory title'}{intl l='Position'}{intl l="Actions"}
{$ID} - {$TITLE} - - {admin_position_block - permission="admin.products.edit" - path={url path='/admin/product/update-accessory-position' product_id=$product_id current_tab="related"} - url_parameter="accessory_id" - in_place_edit_class="accessoryPositionChange" - position=$POSITION - id=$ID - } - -
- {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.configuration.product.accessory.delete"} - - - - {/loop} -
-
-
- {intl l="This product contains no accessories"} -
-
+ {elseloop rel="additional_categories"} + + +
+ {intl l="This product doesn't belong to any additional category."} +
+ + + {/elseloop} + + +
+ {* -- End categories management ------------------------------------- *}
- {* -- End accessories management -------- *} -
{* Delete related content confirmation dialog *} @@ -275,6 +394,26 @@ form_content = {$smarty.capture.delete_accessory_dialog nofilter} } +{* Delete category confirmation dialog *} + +{capture "delete_category_dialog"} + + + + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "delete_category_dialog" + dialog_title = {intl l="Remove from category"} + dialog_message = {intl l="Do you really want to remove the product from this category ?"} + + form_action = {url path='/admin/products/category/delete'} + form_content = {$smarty.capture.delete_category_dialog nofilter} +} +